PageRenderTime 40ms CodeModel.GetById 27ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_finder/controllers/suggestions.json.php

https://bitbucket.org/eternaware/joomus
PHP | 56 lines | 22 code | 6 blank | 28 comment | 2 complexity | 6ec7c8a5f8288461f86a9bd08d753526 MD5 | raw file
Possible License(s): LGPL-2.1
 1<?php
 2/**
 3 * @package     Joomla.Site
 4 * @subpackage  com_finder
 5 *
 6 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 7 * @license     GNU General Public License version 2 or later; see LICENSE
 8 */
 9
10defined('_JEXEC') or die;
11
12/**
13 * Suggestions JSON controller for Finder.
14 *
15 * @package     Joomla.Site
16 * @subpackage  com_finder
17 * @since       2.5
18 */
19class FinderControllerSuggestions extends JControllerLegacy
20{
21	/**
22	 * Method to find search query suggestions.
23	 *
24	 * @param   boolean  $cachable   If true, the view output will be cached
25	 * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
26	 *
27	 * @return  void
28	 *
29	 * @since   2.5
30	 */
31	public function display($cachable = false, $urlparams = false)
32	{
33		$return = array();
34
35		$params = JComponentHelper::getParams('com_finder');
36		if ($params->get('show_autosuggest', 1))
37		{
38			// Get the suggestions.
39			$model = $this->getModel('Suggestions', 'FinderModel');
40			$return = $model->getItems();
41		}
42
43		// Check the data.
44		if (empty($return))
45		{
46			$return = array();
47		}
48
49		// Use the correct json mime-type
50		header('Content-Type: application/json');
51
52		// Send the response.
53		echo json_encode($return);
54		JFactory::getApplication()->close();
55	}
56}