search.class.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. /**
  11. * Loads the search page
  12. *
  13. * @package modx
  14. * @subpackage manager.controllers
  15. */
  16. class SearchManagerController extends modManagerController {
  17. public $searchQuery = '';
  18. /**
  19. * Check for any permissions or requirements to load page
  20. * @return bool
  21. */
  22. public function checkPermissions() {
  23. return $this->modx->hasPermission('search');
  24. }
  25. /**
  26. * Register custom CSS/JS for the page
  27. * @return void
  28. */
  29. public function loadCustomCssJs() {
  30. $mgrUrl = $this->modx->getOption('manager_url',null,MODX_MANAGER_URL);
  31. $this->addJavascript($mgrUrl.'assets/modext/widgets/modx.panel.search.js');
  32. $this->addJavascript($mgrUrl.'assets/modext/sections/search.js');
  33. $this->addHtml("<script type=\"text/javascript\">Ext.onReady(function() {
  34. MODx.load({
  35. xtype: 'modx-page-search'
  36. ,record: {
  37. q: '".$this->searchQuery."'
  38. }
  39. });
  40. });</script>");
  41. }
  42. /**
  43. * Custom logic code here for setting placeholders, etc
  44. * @param array $scriptProperties
  45. * @return mixed
  46. */
  47. public function process(array $scriptProperties = array()) {
  48. if (!empty($this->scriptProperties['q'])) {
  49. $this->searchQuery = str_replace("'","\'",urldecode($this->scriptProperties['q']));
  50. }
  51. }
  52. /**
  53. * Return the pagetitle
  54. *
  55. * @return string
  56. */
  57. public function getPageTitle() {
  58. return $this->modx->lexicon('search');
  59. }
  60. /**
  61. * Return the location of the template file
  62. * @return string
  63. */
  64. public function getTemplateFile() {
  65. return '';
  66. }
  67. /**
  68. * Specify the language topics to load
  69. * @return array
  70. */
  71. public function getLanguageTopics() {
  72. return array('resource');
  73. }
  74. }