diff --git a/administrator/components/com_finder/config.xml b/administrator/components/com_finder/config.xml
index 351aaebb213cd..6184523d104f6 100644
--- a/administrator/components/com_finder/config.xml
+++ b/administrator/components/com_finder/config.xml
@@ -176,11 +176,23 @@
+
+
+
+
+
diff --git a/administrator/language/en-GB/en-GB.com_finder.ini b/administrator/language/en-GB/en-GB.com_finder.ini
index a27de9f07328d..c670d629c1d9c 100644
--- a/administrator/language/en-GB/en-GB.com_finder.ini
+++ b/administrator/language/en-GB/en-GB.com_finder.ini
@@ -23,6 +23,7 @@ COM_FINDER_CONFIG_LANGUAGE_DEFAULT_NONE="None"
COM_FINDER_CONFIG_MEMORY_TABLE_LIMIT_LABEL="Memory Table Limit"
COM_FINDER_CONFIG_META_MULTIPLIER_LABEL="Metadata Weight Multiplier"
COM_FINDER_CONFIG_MISC_MULTIPLIER_LABEL="Misc. Text Weight Multiplier"
+COM_FINDER_CONFIG_OPENSEARCH_LABEL="Enable OpenSearch"
COM_FINDER_CONFIG_PATH_MULTIPLIER_LABEL="Path Text Weight Multiplier"
COM_FINDER_CONFIG_SHOW_ADVANCED_LABEL="Advanced Search"
COM_FINDER_CONFIG_SHOW_ADVANCED_TIPS_LABEL="Advanced Tips"
diff --git a/components/com_finder/Controller/SuggestionsController.php b/components/com_finder/Controller/SuggestionsController.php
index 6a288711935d3..c4027eab201f9 100644
--- a/components/com_finder/Controller/SuggestionsController.php
+++ b/components/com_finder/Controller/SuggestionsController.php
@@ -38,7 +38,28 @@ public function suggest()
$app->setHeader('Content-Type', $app->mimeType . '; charset=' . $app->charSet);
$app->sendHeaders();
echo '{ "suggestions": ' . json_encode($suggestions) . ' }';
- $app->close();
+ }
+
+ /**
+ * Method to find search query suggestions for OpenSearch
+ *
+ * @return void
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function opensearchsuggest()
+ {
+ $app = $this->app;
+ $app->mimeType = 'application/json';
+ $result = array();
+ $result[] = $app->input->request->get('q', '', 'string');
+
+ $result[] = $this->getSuggestions();
+
+ // Send the response.
+ $app->setHeader('Content-Type', $app->mimeType . '; charset=' . $app->charSet);
+ $app->sendHeaders();
+ echo json_encode($result);
}
/**
diff --git a/components/com_finder/View/Search/FeedView.php b/components/com_finder/View/Search/FeedView.php
index 73773b9e80550..afc5f57c23260 100644
--- a/components/com_finder/View/Search/FeedView.php
+++ b/components/com_finder/View/Search/FeedView.php
@@ -40,7 +40,8 @@ public function display($tpl = null)
$state = $this->get('State');
$params = $state->get('params');
$query = $this->get('Query');
- $results = $this->get('Results');
+ $results = $this->get('Items');
+ $total = $this->get('Total');
// Push out the query data.
\JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
@@ -87,17 +88,7 @@ public function display($tpl = null)
$item->title = $result->title;
$item->link = \JRoute::_($result->route);
$item->description = $result->description;
- $item->date = (int) $result->start_date ? \JHtml::_('date', $result->start_date, 'l d F Y') : $result->indexdate;
-
- // Get the taxonomy data.
- $taxonomy = $result->getTaxonomy();
-
- // Add the category to the feed if available.
- if (isset($taxonomy['Category']))
- {
- $node = array_pop($taxonomy['Category']);
- $item->category = $node->title;
- }
+ $item->date = date('r', strtotime($result->start_date));
// Loads item info into RSS array
$this->document->addItem($item);
diff --git a/components/com_finder/View/Search/HtmlView.php b/components/com_finder/View/Search/HtmlView.php
index 0566d0d41e8cc..93a596b08560d 100644
--- a/components/com_finder/View/Search/HtmlView.php
+++ b/components/com_finder/View/Search/HtmlView.php
@@ -13,6 +13,10 @@
use Joomla\CMS\Helper\SearchHelper;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Router\Route;
+use Joomla\CMS\Uri\Uri;
/**
* Search HTML view class for the Finder package.
@@ -314,6 +318,16 @@ protected function prepareDocument($query)
$this->document->setMetaData('robots', $this->params->get('robots'));
}
+ // Check for OpenSearch
+ if ($this->params->get('opensearch', 1))
+ {
+ $ostitle = $this->params->get('opensearch_name', Text::_('COM_FINDER_OPENSEARCH_NAME') . ' ' . Factory::getApplication()->get('sitename'));
+ Factory::getDocument()->addHeadLink(
+ Uri::getInstance()->toString(array('scheme', 'host', 'port')) . Route::_('index.php?option=com_finder&view=search&format=opensearch'),
+ 'search', 'rel', array('title' => $ostitle, 'type' => 'application/opensearchdescription+xml')
+ );
+ }
+
// Add feed link to the document head.
if ($this->params->get('show_feed_link', 1) == 1)
{
diff --git a/components/com_finder/View/Search/OpensearchView.php b/components/com_finder/View/Search/OpensearchView.php
index e05bd66a42fab..85daa721b78d3 100644
--- a/components/com_finder/View/Search/OpensearchView.php
+++ b/components/com_finder/View/Search/OpensearchView.php
@@ -11,6 +11,8 @@
defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
+use Joomla\CMS\Document\Opensearch\OpensearchUrl;
+use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\AbstractView;
/**
@@ -31,27 +33,55 @@ class OpensearchView extends AbstractView
*/
public function display($tpl = null)
{
- $doc = \JFactory::getDocument();
- $app = \JFactory::getApplication();
+ $doc = Factory::getDocument();
+ $app = Factory::getApplication();
$params = ComponentHelper::getParams('com_finder');
$doc->setShortName($params->get('opensearch_name', $app->get('sitename')));
$doc->setDescription($params->get('opensearch_description', $app->get('MetaDesc')));
- // Add the URL for the search
- $searchUri = \JUri::base() . 'index.php?option=com_finder&q={searchTerms}';
+ // Prevent any output when OpenSearch Support is disabled
+ if (!$params->get('opensearch', 1))
+ {
+ return;
+ }
- // Find the menu item for the search
- $menu = $app->getMenu();
- $items = $menu->getItems('link', 'index.php?option=com_finder&view=search');
+ // Add the URL for the search
+ $searchUri = 'index.php?option=com_finder&view=search&q={searchTerms}';
+ $suggestionsUri = 'index.php?option=com_finder&task=suggestions.opensearchsuggest&format=json&q={searchTerms}';
+ $baseUrl = \JUri::getInstance()->toString(array('host', 'port', 'scheme'));
+ $active = $app->getMenu()->getActive();
- if (isset($items[0]))
+ if ($active->component == 'com_finder')
{
- $searchUri .= '&Itemid=' . $items[0]->id;
+ $searchUri .= '&Itemid=' . $active->id;
+ $suggestionsUri .= '&Itemid=' . $active->id;
}
- $htmlSearch = new \JOpenSearchUrl;
- $htmlSearch->template = \JRoute::_($searchUri);
+ // Add the HTML result view
+ $htmlSearch = new OpenSearchUrl;
+ $htmlSearch->template = $baseUrl . \JRoute::_($searchUri, false);
+ $doc->addUrl($htmlSearch);
+
+ // Add the RSS result view
+ $htmlSearch = new OpenSearchUrl;
+ $htmlSearch->template = $baseUrl . \JRoute::_($searchUri . '&format=feed&type=rss', false);
+ $htmlSearch->type = 'application/rss+xml';
$doc->addUrl($htmlSearch);
+
+ // Add the Atom result view
+ $htmlSearch = new OpenSearchUrl;
+ $htmlSearch->template = $baseUrl . \JRoute::_($searchUri . '&format=feed&type=atom', false);
+ $htmlSearch->type = 'application/atom+xml';
+ $doc->addUrl($htmlSearch);
+
+ // Add suggestions URL
+ if ($params->get('show_autosuggest', 1))
+ {
+ $htmlSearch = new OpenSearchUrl;
+ $htmlSearch->template = $baseUrl . \JRoute::_($suggestionsUri, false);
+ $htmlSearch->type = 'application/x-suggestions+json';
+ $doc->addUrl($htmlSearch);
+ }
}
}
diff --git a/language/en-GB/en-GB.com_finder.ini b/language/en-GB/en-GB.com_finder.ini
index ef3d837a13775..640518cec04c1 100644
--- a/language/en-GB/en-GB.com_finder.ini
+++ b/language/en-GB/en-GB.com_finder.ini
@@ -18,6 +18,7 @@ COM_FINDER_FILTER_DATE2_DESC="Enter a date in YYYY-MM-DD format."
COM_FINDER_FILTER_SELECT_ALL_LABEL="Search All"
COM_FINDER_FILTER_WHEN_AFTER="After"
COM_FINDER_FILTER_WHEN_BEFORE="Before"
+COM_FINDER_OPENSEARCH_NAME="Search"
COM_FINDER_QUERY_DATE_CONDITION_AFTER="after"
COM_FINDER_QUERY_DATE_CONDITION_BEFORE="before"
COM_FINDER_QUERY_DATE_CONDITION_EXACT="exactly on"
diff --git a/language/en-GB/en-GB.mod_finder.ini b/language/en-GB/en-GB.mod_finder.ini
index c4f08e48b3dd8..0f764ccfe5316 100644
--- a/language/en-GB/en-GB.mod_finder.ini
+++ b/language/en-GB/en-GB.mod_finder.ini
@@ -21,8 +21,8 @@ MOD_FINDER_FIELDSET_BASIC_AUTOSUGGEST_LABEL="Search Suggestions"
MOD_FINDER_FIELDSET_BASIC_SEARCHFILTER_LABEL="Search Filter"
MOD_FINDER_FIELDSET_BASIC_SHOW_ADVANCED_LABEL="Advanced Search"
MOD_FINDER_FIELDSET_BASIC_SHOW_ADVANCED_OPTION_LINK="Link to Component"
-MOD_FINDER_FIELD_OPENSEARCH_LABEL="OpenSearch Autodiscovery"
-MOD_FINDER_FIELD_OPENSEARCH_TEXT_LABEL="OpenSearch title"
+MOD_FINDER_FIELD_OPENSEARCH_LABEL="Enable OpenSearch"
+MOD_FINDER_FIELD_OPENSEARCH_TEXT_LABEL="OpenSearch Name"
MOD_FINDER_SEARCHBUTTON_TEXT="Search"
MOD_FINDER_SEARCH_BUTTON="Go"
MOD_FINDER_SEARCH_VALUE="Search ..."
diff --git a/libraries/src/Document/OpensearchDocument.php b/libraries/src/Document/OpensearchDocument.php
index cb288f860fa9d..33c73425dca29 100644
--- a/libraries/src/Document/OpensearchDocument.php
+++ b/libraries/src/Document/OpensearchDocument.php
@@ -135,7 +135,7 @@ public function render($cache = false, $params = array())
$osns = 'http://a9.com/-/spec/opensearch/1.1/';
// Create the root element
- $elOs = $xml->createElementNs($osns, 'OpensearchDescription');
+ $elOs = $xml->createElementNs($osns, 'OpenSearchDescription');
$elShortName = $xml->createElementNs($osns, 'ShortName');
$elShortName->appendChild($xml->createTextNode(htmlspecialchars($this->_shortName)));
diff --git a/modules/mod_finder/mod_finder.php b/modules/mod_finder/mod_finder.php
index e40f8fd1fe7d1..5307cf08c2e11 100644
--- a/modules/mod_finder/mod_finder.php
+++ b/modules/mod_finder/mod_finder.php
@@ -9,6 +9,7 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Module\Finder\Site\Helper\FinderHelper;
use Joomla\CMS\Factory;
@@ -26,17 +27,17 @@
JLoader::register('FinderIndexerQuery', FINDER_PATH_INDEXER . '/query.php');
+$cparams = ComponentHelper::getParams('com_finder');
+
// Check for OpenSearch
-if ($params->get('opensearch', 1))
+if ($params->get('opensearch', $cparams->get('opensearch', 1)))
{
- /*
- This code intentionally commented
- $ostitle = $params->get('opensearch_title', Text::_('MOD_FINDER_SEARCHBUTTON_TEXT') . ' ' . Factory::getApplication()->get('sitename'));
+ $defaultTitle = Text::_('MOD_FINDER_OPENSEARCH_NAME') . ' ' . Factory::getApplication()->get('sitename');
+ $ostitle = $params->get('opensearch_name', $cparams->get('opensearch_name', $defaultTitle));
Factory::getDocument()->addHeadLink(
- Uri::getInstance()->toString(array('scheme', 'host', 'port')) . Route::_('&option=com_finder&format=opensearch'),
+ Uri::getInstance()->toString(array('scheme', 'host', 'port')) . Route::_('index.php?option=com_finder&view=search&format=opensearch'),
'search', 'rel', array('title' => $ostitle, 'type' => 'application/opensearchdescription+xml')
);
- */
}
// Get the route.
diff --git a/modules/mod_finder/mod_finder.xml b/modules/mod_finder/mod_finder.xml
index fa3a394aa2191..01dcacff3fb04 100644
--- a/modules/mod_finder/mod_finder.xml
+++ b/modules/mod_finder/mod_finder.xml
@@ -90,13 +90,14 @@
-
+
-
+