diff --git a/administrator/components/com_finder/src/Field/TaxonomytypesField.php b/administrator/components/com_finder/src/Field/TaxonomytypesField.php new file mode 100644 index 0000000000000..f8f763f22726a --- /dev/null +++ b/administrator/components/com_finder/src/Field/TaxonomytypesField.php @@ -0,0 +1,50 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\Component\Finder\Administrator\Field; + +use Joomla\CMS\Form\Field\CheckboxesField; + +/** + * Taxonomy Types field for the Finder package. + * This is a helper to allow to save an empty set of + * options by having a hidden field with a "none" value. + * + * @since __DEPLOY_VERSION__ + */ +class TaxonomytypesField extends CheckboxesField +{ + /** + * The form field type. + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $type = 'TaxonomyTypes'; + + /** + * Method to get the field input markup for a generic list. + * Use the multiple attribute to enable multiselect. + * + * @return string The field input markup. + * + * @since __DEPLOY_VERSION__ + */ + protected function getInput() + { + $html = parent::getInput(); + + $data = $this->getLayoutData(); + $data['id'] .= '_hidden'; + $data['value'] = 'none'; + + return $html . $this->getRenderer('joomla.form.field.hidden')->render($data); + } +} diff --git a/administrator/language/en-GB/plg_finder_categories.ini b/administrator/language/en-GB/plg_finder_categories.ini index d97f8c763fe88..62e086af6adf5 100644 --- a/administrator/language/en-GB/plg_finder_categories.ini +++ b/administrator/language/en-GB/plg_finder_categories.ini @@ -5,3 +5,6 @@ PLG_FINDER_CATEGORIES="Smart Search - Categories" PLG_FINDER_CATEGORIES_XML_DESCRIPTION="This plugin indexes Joomla! Categories." +PLG_FINDER_CATEGORIES_TAXONOMIES_LABEL="Taxonomies to Index" +PLG_FINDER_CATEGORIES_TAXONOMIES_LANGUAGE="Language" +PLG_FINDER_CATEGORIES_TAXONOMIES_TYPE="Type" diff --git a/administrator/language/en-GB/plg_finder_contacts.ini b/administrator/language/en-GB/plg_finder_contacts.ini index f7ca248056249..d55214f36b51a 100644 --- a/administrator/language/en-GB/plg_finder_contacts.ini +++ b/administrator/language/en-GB/plg_finder_contacts.ini @@ -5,6 +5,12 @@ PLG_FINDER_CONTACTS="Smart Search - Contacts" PLG_FINDER_CONTACTS_XML_DESCRIPTION="This plugin indexes Joomla! Contacts." +PLG_FINDER_CONTACTS_TAXONOMIES_CATEGORY="Category" +PLG_FINDER_CONTACTS_TAXONOMIES_COUNTRY="Country" +PLG_FINDER_CONTACTS_TAXONOMIES_LABEL="Taxonomies to Index" +PLG_FINDER_CONTACTS_TAXONOMIES_LANGUAGE="Language" +PLG_FINDER_CONTACTS_TAXONOMIES_REGION="Region" +PLG_FINDER_CONTACTS_TAXONOMIES_TYPE="Type" PLG_FINDER_QUERY_FILTER_BRANCH_P_CONTACT="Contacts" PLG_FINDER_QUERY_FILTER_BRANCH_P_COUNTRY="Countries" PLG_FINDER_QUERY_FILTER_BRANCH_P_REGION="Regions" diff --git a/administrator/language/en-GB/plg_finder_content.ini b/administrator/language/en-GB/plg_finder_content.ini index 8666746f3b9ab..4a58a44c7c390 100644 --- a/administrator/language/en-GB/plg_finder_content.ini +++ b/administrator/language/en-GB/plg_finder_content.ini @@ -4,6 +4,11 @@ ; Note : All ini files need to be saved as UTF-8 PLG_FINDER_CONTENT="Smart Search - Content" +PLG_FINDER_CONTENT_TAXONOMIES_AUTHOR="Author" +PLG_FINDER_CONTENT_TAXONOMIES_CATEGORY="Category" +PLG_FINDER_CONTENT_TAXONOMIES_LABEL="Taxonomies to Index" +PLG_FINDER_CONTENT_TAXONOMIES_LANGUAGE="Language" +PLG_FINDER_CONTENT_TAXONOMIES_TYPE="Type" PLG_FINDER_CONTENT_XML_DESCRIPTION="Updates the indexes of Joomla! Articles whenever an article is created, modified or deleted. NOTE the Content - Smart Search plugin must be enabled." PLG_FINDER_QUERY_FILTER_BRANCH_P_ARTICLE="Articles" PLG_FINDER_QUERY_FILTER_BRANCH_P_AUTHOR="Authors" diff --git a/administrator/language/en-GB/plg_finder_newsfeeds.ini b/administrator/language/en-GB/plg_finder_newsfeeds.ini index c3a6c37ade57b..e311469ada5a2 100644 --- a/administrator/language/en-GB/plg_finder_newsfeeds.ini +++ b/administrator/language/en-GB/plg_finder_newsfeeds.ini @@ -5,5 +5,9 @@ PLG_FINDER_NEWSFEEDS="Smart Search - News Feeds" PLG_FINDER_NEWSFEEDS_XML_DESCRIPTION="This plugin indexes Joomla! News feeds." +PLG_FINDER_NEWSFEEDS_TAXONOMIES_CATEGORY="Category" +PLG_FINDER_NEWSFEEDS_TAXONOMIES_LABEL="Taxonomies to Index" +PLG_FINDER_NEWSFEEDS_TAXONOMIES_LANGUAGE="Language" +PLG_FINDER_NEWSFEEDS_TAXONOMIES_TYPE="Type" PLG_FINDER_QUERY_FILTER_BRANCH_P_NEWS_FEED="News feeds" PLG_FINDER_QUERY_FILTER_BRANCH_S_NEWS_FEED="News feed" diff --git a/administrator/language/en-GB/plg_finder_tags.ini b/administrator/language/en-GB/plg_finder_tags.ini index 9ddbd0c01124d..14b009a250aad 100644 --- a/administrator/language/en-GB/plg_finder_tags.ini +++ b/administrator/language/en-GB/plg_finder_tags.ini @@ -7,3 +7,7 @@ PLG_FINDER_QUERY_FILTER_BRANCH_P_TAG="Tags" PLG_FINDER_QUERY_FILTER_BRANCH_S_TAG="Tag" PLG_FINDER_TAGS="Smart Search - Tags" PLG_FINDER_TAGS_XML_DESCRIPTION="This plugin indexes Joomla! Tags." +PLG_FINDER_TAGS_TAXONOMIES_AUTHOR="Author" +PLG_FINDER_TAGS_TAXONOMIES_LABEL="Taxonomies to Index" +PLG_FINDER_TAGS_TAXONOMIES_LANGUAGE="Language" +PLG_FINDER_TAGS_TAXONOMIES_TYPE="Type" diff --git a/plugins/finder/categories/categories.xml b/plugins/finder/categories/categories.xml index 337b2dd77d131..20838b34bdb3a 100644 --- a/plugins/finder/categories/categories.xml +++ b/plugins/finder/categories/categories.xml @@ -18,4 +18,20 @@ language/en-GB/plg_finder_categories.ini language/en-GB/plg_finder_categories.sys.ini + + +
+ + + + +
+
+
diff --git a/plugins/finder/categories/src/Extension/Categories.php b/plugins/finder/categories/src/Extension/Categories.php index 396c0eee1b619..ef31ca18d73ed 100644 --- a/plugins/finder/categories/src/Extension/Categories.php +++ b/plugins/finder/categories/src/Extension/Categories.php @@ -335,11 +335,18 @@ protected function index(Result $item) // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); + // Get taxonomies to display + $taxonomies = $this->params->get('taxonomies', ['type', 'language']); + // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Category'); + if (in_array('type', $taxonomies)) { + $item->addTaxonomy('Type', 'Category'); + } // Add the language taxonomy data. - $item->addTaxonomy('Language', $item->language); + if (in_array('language', $taxonomies)) { + $item->addTaxonomy('Language', $item->language); + } // Get content extras. Helper::getContentExtras($item); diff --git a/plugins/finder/contacts/contacts.xml b/plugins/finder/contacts/contacts.xml index 4aebc5bd728a4..6afe144f6eb3c 100644 --- a/plugins/finder/contacts/contacts.xml +++ b/plugins/finder/contacts/contacts.xml @@ -18,4 +18,23 @@ language/en-GB/plg_finder_contacts.ini language/en-GB/plg_finder_contacts.sys.ini + + +
+ + + + + + + +
+
+
diff --git a/plugins/finder/contacts/src/Extension/Contacts.php b/plugins/finder/contacts/src/Extension/Contacts.php index 0ee4955acc8cb..293366e318d5e 100644 --- a/plugins/finder/contacts/src/Extension/Contacts.php +++ b/plugins/finder/contacts/src/Extension/Contacts.php @@ -333,30 +333,39 @@ protected function index(Result $item) // Handle the contact user name. $item->addInstruction(Indexer::META_CONTEXT, 'user'); + // Get taxonomies to display + $taxonomies = $this->params->get('taxonomies', ['type', 'category', 'language', 'region', 'country']); + // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Contact'); + if (in_array('type', $taxonomies)) { + $item->addTaxonomy('Type', 'Contact'); + } // Add the category taxonomy data. $categories = $this->getApplication()->bootComponent('com_contact')->getCategory(['published' => false, 'access' => false]); $category = $categories->get($item->catid); - // Category does not exist, stop here if (!$category) { return; } - $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + // Add the category taxonomy data. + if (in_array('category', $taxonomies)) { + $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + } // Add the language taxonomy data. - $item->addTaxonomy('Language', $item->language); + if (in_array('language', $taxonomies)) { + $item->addTaxonomy('Language', $item->language); + } // Add the region taxonomy data. - if (!empty($item->region) && $this->params->get('tax_add_region', true)) { + if (in_array('region', $taxonomies) && !empty($item->region) && $this->params->get('tax_add_region', true)) { $item->addTaxonomy('Region', $item->region); } // Add the country taxonomy data. - if (!empty($item->country) && $this->params->get('tax_add_country', true)) { + if (in_array('country', $taxonomies) && !empty($item->country) && $this->params->get('tax_add_country', true)) { $item->addTaxonomy('Country', $item->country); } diff --git a/plugins/finder/content/content.xml b/plugins/finder/content/content.xml index d5b79e0403b8c..03fbccf34988f 100644 --- a/plugins/finder/content/content.xml +++ b/plugins/finder/content/content.xml @@ -18,4 +18,22 @@ language/en-GB/plg_finder_content.ini language/en-GB/plg_finder_content.sys.ini + + +
+ + + + + + +
+
+
diff --git a/plugins/finder/content/src/Extension/Content.php b/plugins/finder/content/src/Extension/Content.php index b1ca7fd98ce99..041fdc68cd856 100644 --- a/plugins/finder/content/src/Extension/Content.php +++ b/plugins/finder/content/src/Extension/Content.php @@ -305,11 +305,16 @@ protected function index(Result $item) // Translate the state. Articles should only be published if the category is published. $item->state = $this->translateState($item->state, $item->cat_state); + // Get taxonomies to display + $taxonomies = $this->params->get('taxonomies', ['type', 'author', 'category', 'language']); + // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Article'); + if (in_array('type', $taxonomies)) { + $item->addTaxonomy('Type', 'Article'); + } // Add the author taxonomy data. - if (!empty($item->author) || !empty($item->created_by_alias)) { + if (in_array('author', $taxonomies) && (!empty($item->author) || !empty($item->created_by_alias))) { $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author, $item->state); } @@ -317,15 +322,19 @@ protected function index(Result $item) $categories = $this->getApplication()->bootComponent('com_content')->getCategory(['published' => false, 'access' => false]); $category = $categories->get($item->catid); - // Category does not exist, stop here if (!$category) { return; } - $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + // Add the category taxonomy data. + if (in_array('category', $taxonomies)) { + $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + } // Add the language taxonomy data. - $item->addTaxonomy('Language', $item->language); + if (in_array('language', $taxonomies)) { + $item->addTaxonomy('Language', $item->language); + } // Get content extras. Helper::getContentExtras($item); diff --git a/plugins/finder/newsfeeds/newsfeeds.xml b/plugins/finder/newsfeeds/newsfeeds.xml index e31e27ddff8b6..9d6d67c155828 100644 --- a/plugins/finder/newsfeeds/newsfeeds.xml +++ b/plugins/finder/newsfeeds/newsfeeds.xml @@ -18,4 +18,21 @@ language/en-GB/plg_finder_newsfeeds.ini language/en-GB/plg_finder_newsfeeds.sys.ini + + +
+ + + + + +
+
+
diff --git a/plugins/finder/newsfeeds/src/Extension/Newsfeeds.php b/plugins/finder/newsfeeds/src/Extension/Newsfeeds.php index 130489c47e454..15a6f7044f826 100644 --- a/plugins/finder/newsfeeds/src/Extension/Newsfeeds.php +++ b/plugins/finder/newsfeeds/src/Extension/Newsfeeds.php @@ -281,22 +281,31 @@ protected function index(Result $item) $item->addInstruction(Indexer::META_CONTEXT, 'author'); $item->addInstruction(Indexer::META_CONTEXT, 'created_by_alias'); + // Get taxonomies to display + $taxonomies = $this->params->get('taxonomies', ['type', 'category', 'language']); + // Add the type taxonomy data. - $item->addTaxonomy('Type', 'News Feed'); + if (in_array('type', $taxonomies)) { + $item->addTaxonomy('Type', 'News Feed'); + } // Add the category taxonomy data. $categories = $this->getApplication()->bootComponent('com_newsfeeds')->getCategory(['published' => false, 'access' => false]); $category = $categories->get($item->catid); - // Category does not exist, stop here if (!$category) { return; } - $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + // Add the category taxonomy data. + if (in_array('category', $taxonomies)) { + $item->addNestedTaxonomy('Category', $category, $this->translateState($category->published), $category->access, $category->language); + } // Add the language taxonomy data. - $item->addTaxonomy('Language', $item->language); + if (in_array('language', $taxonomies)) { + $item->addTaxonomy('Language', $item->language); + } // Get content extras. Helper::getContentExtras($item); diff --git a/plugins/finder/tags/src/Extension/Tags.php b/plugins/finder/tags/src/Extension/Tags.php index 7fcbcbd912c75..555ed298f4d77 100644 --- a/plugins/finder/tags/src/Extension/Tags.php +++ b/plugins/finder/tags/src/Extension/Tags.php @@ -246,16 +246,23 @@ protected function index(Result $item) $item->addInstruction(Indexer::META_CONTEXT, 'author'); $item->addInstruction(Indexer::META_CONTEXT, 'created_by_alias'); + // Get taxonomies to display + $taxonomies = $this->params->get('taxonomies', ['type', 'author', 'language']); + // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Tag'); + if (in_array('type', $taxonomies)) { + $item->addTaxonomy('Type', 'Tag'); + } // Add the author taxonomy data. - if (!empty($item->author) || !empty($item->created_by_alias)) { + if (in_array('author', $taxonomies) && (!empty($item->author) || !empty($item->created_by_alias))) { $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); } // Add the language taxonomy data. - $item->addTaxonomy('Language', $item->language); + if (in_array('language', $taxonomies)) { + $item->addTaxonomy('Language', $item->language); + } // Get content extras. Helper::getContentExtras($item); diff --git a/plugins/finder/tags/tags.xml b/plugins/finder/tags/tags.xml index 0f2951a8850b9..1a259abe98eb5 100644 --- a/plugins/finder/tags/tags.xml +++ b/plugins/finder/tags/tags.xml @@ -18,4 +18,21 @@ language/en-GB/plg_finder_tags.ini language/en-GB/plg_finder_tags.sys.ini + + +
+ + + + + +
+
+