<commit_before><commit_msg>NEW TaxonomyTerm filter option<commit_after><?php

if (!class_exists('TaxonomyTerm')) {
	return;
}

/**
 * @author marcus
 */
class ListFilterTaxonomyTerms extends ListFilterTags 
{
    private static $many_many = array(
		'Terms' => 'TaxonomyTerm',
	);

	/**
	 * {@inheritdoc}
	 */
	public function SelectableTags() {
		return $this->Terms();
	}

	/**
	 * {@inheritdoc}
	 */
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->removeByName(array('Terms'));
        $source = TreeMultiselectField::create('Terms', 'Terms to filter on', 'TaxonomyTerm', 'ID', 'Name');
		$fields->addFieldToTab('Root.Main', $source);
		return $fields;
	}

	public function getComponentRelationName() {
		$componentRelationNames = ListFilterUtility::get_component_names_using_class($this->getListClassName(), 'TaxonomyTerm');
		if (count($componentRelationNames) > 1) {
			// todo(Jake): maybe make dropdown to select a specific relation for these cases.
			throw new Exception('Multiple many_many relationships with "FusionTag"');
		}
		$componentRelationName = reset($componentRelationNames);
		return $componentRelationName;
	}
}
{'fraction_non_alphanumeric': 0.14554794520547945, 'fraction_numerical': 0.0008561643835616438, 'mean_word_length': 5.251336898395722, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '395743', 'n_tokens_mistral': 384, 'n_tokens_neox': 360, 'n_words': 77}