searchKeyword.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * @package Dolphin Core
  4. * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  5. * @license CC-BY - http://creativecommons.org/licenses/by/3.0/
  6. */
  7. require_once('./inc/header.inc.php');
  8. require_once(BX_DIRECTORY_PATH_INC . "languages.inc.php");
  9. require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
  10. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  11. bx_import('BxDolSearch');
  12. $oZ = new BxDolSearch();
  13. $sCode = '';
  14. if (bx_get('keyword')) {
  15. $sCode = $oZ->response();
  16. if (mb_strlen($sCode) == 0)
  17. $sCode = $oZ->getEmptyResult();
  18. }
  19. bx_import('BxTemplMenu');
  20. $aVars = array();
  21. BxTemplMenu::getInstance()->setCustomSubActions($aVars, '');
  22. $oTemplate = BxDolTemplate::getInstance();
  23. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  24. $oTemplate->setPageHeader (_t("_Search"));
  25. $oTemplate->setPageContent ('page_main_code', getExtraJs() . getSearchForm() . $sCode);
  26. PageCode();
  27. function getSearchForm () {
  28. $aList = BxDolDb::getInstance()->fromCache('sys_objects_search', 'getAllWithKey',
  29. 'SELECT `ID` as `id`,
  30. `Title` as `title`,
  31. `ClassName` as `class`,
  32. `ClassPath` as `file`,
  33. `ObjectName`
  34. FROM `sys_objects_search`', 'ObjectName'
  35. );
  36. $aValues = array();
  37. foreach ($aList as $sKey => $aValue) {
  38. $aValues[$sKey] = _t($aValue['title']);
  39. if (!class_exists($aValue['class'])) {
  40. $sPath = BX_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $GLOBALS['tmpl'], $aValue['file']);
  41. require_once($sPath);
  42. }
  43. $oClass = new $aValue['class']();
  44. $oClass->addCustomParts();
  45. }
  46. if (isset($_GET['type'])) {
  47. $aValue = bx_process_input($_GET['type']);
  48. } else {
  49. $aValue = array_keys($aValues);
  50. }
  51. $aForm = array(
  52. 'form_attrs' => array(
  53. 'id' => 'searchForm',
  54. 'action' => '',
  55. 'method' => 'post',
  56. 'onsubmit' => '',
  57. ),
  58. 'inputs' => array(
  59. 'section' => array(
  60. 'type' => 'checkbox_set',
  61. 'name' => 'section',
  62. 'caption' => _t('_Section'),
  63. 'values' => $aValues,
  64. 'value' => $aValue,
  65. ),
  66. 'keyword' => array(
  67. 'type' => 'text',
  68. 'name' => 'keyword',
  69. 'caption' => _t('_Keyword')
  70. ),
  71. 'search' => array(
  72. 'type' => 'submit',
  73. 'name' => 'search',
  74. 'value' => _t('_Search')
  75. )
  76. )
  77. );
  78. bx_import('BxTemplFormView');
  79. $oForm = new BxTemplFormView($aForm);
  80. $sFormVal = $oForm->getCode();
  81. return DesignBoxContent(_t( "_Search" ), $sFormVal, 1);
  82. }
  83. function getExtraJs() {
  84. ob_start();
  85. ?>
  86. <script language="javascript">
  87. $(document).ready( function() {
  88. $('#searchForm').bind( 'submit', function() {
  89. bx_loading('searchForm', true);
  90. var sQuery = $('input', '#searchForm').serialize();
  91. $.post('searchKeywordContent.php', sQuery, function(data) {
  92. $('#searchArea').html(data);
  93. bx_loading('searchForm', false);
  94. }
  95. );
  96. return false;
  97. }
  98. );
  99. }
  100. );
  101. </script>
  102. <?php
  103. return ob_get_clean();
  104. }