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

https://bitbucket.org/kraymitchell/fcd · PHP · 53 lines · 22 code · 6 blank · 25 comment · 2 complexity · 5fb97acdcff05812d7459ef9b7dfb406 MD5 · raw file

  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. defined('_JEXEC') or die;
  10. /**
  11. * Suggestions JSON controller for Finder.
  12. *
  13. * @package Joomla.Site
  14. * @subpackage com_finder
  15. * @since 2.5
  16. */
  17. class FinderControllerSuggestions extends JControllerLegacy
  18. {
  19. /**
  20. * Method to find search query suggestions.
  21. *
  22. * @return void
  23. *
  24. * @since 2.5
  25. */
  26. public function display()
  27. {
  28. $return = array();
  29. $params = JComponentHelper::getParams('com_finder');
  30. if ($params->get('show_autosuggest', 1))
  31. {
  32. // Get the suggestions.
  33. $model = $this->getModel('Suggestions', 'FinderModel');
  34. $return = $model->getItems();
  35. }
  36. // Check the data.
  37. if (empty($return))
  38. {
  39. $return = array();
  40. }
  41. // Use the correct json mime-type
  42. header('Content-Type: application/json');
  43. // Send the response.
  44. echo json_encode($return);
  45. JFactory::getApplication()->close();
  46. }
  47. }