search.class.php 1.8 KB

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