- md5
- 409babeaa6412f2e2de55e247153de12
- sha1
- ad218b25c4353aee6a7273bd715cb977e4a2060f
- sha256
- f87d8ce7c477f7957a1c5b38918555e18705ab2f3ffdb7f7b09ad3102629f297
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
<?php
/**
* @package Joomla.Site
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Finder\Site\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Controller\BaseController;
/**
* Suggestions \JSON controller for Finder.
*
* @since 2.5
*/
class SuggestionsController extends BaseController
{
/**
* Method to find search query suggestions. Uses jQuery and autocompleter.js
*
* @return void
*
* @since 3.4
*/
public function suggest()
{
$app = $this->app;
$app->mimeType = 'application/json';
$suggestions = $this->getSuggestions();
// Send the response.
$app->setHeader('Content-Type', $app->mimeType . '; charset=' . $app->charSet);
$app->sendHeaders();
echo '{ "suggestions": ' . json_encode($suggestions) . ' }';
}
/**
* Method to find search query suggestions for OpenSearch
*
* @return void
*
* @since 4.0.0
*/
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);
}
/**
* Method to retrieve the data from the database
*
* @return array The suggested words
*
* @since 3.4
*/
protected function getSuggestions()
{
$return = array();
$params = ComponentHelper::getParams('com_finder');
if ($params->get('show_autosuggest', 1))
{
// Get the suggestions.
$model = $this->getModel('Suggestions');
$return = $model->getItems();
}
// Check the data.
if (empty($return))
{
$return = array();
}
return $return;
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.