searchKeyword.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 . "params.inc.php");
  9. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  10. bx_import('BxDolSearch');
  11. bx_import('BxDolTemplate');
  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. $sSearchArea = '<div id="searchArea" class="bx-def-margin-top">'.$sCode.'</div>';
  20. /*
  21. bx_import('BxTemplMenu');
  22. $aVars = array();
  23. BxTemplMenu::getInstance()->setCustomSubActions($aVars, '');
  24. */
  25. $oTemplate = BxDolTemplate::getInstance();
  26. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  27. $oTemplate->setPageHeader (_t("_Search"));
  28. $oTemplate->setPageContent ('page_main_code', getExtraJs() . getSearchForm($oTemplate) . $sSearchArea);
  29. $oTemplate->getPageCode();
  30. function getSearchForm ($oTemplate)
  31. {
  32. $aList = BxDolDb::getInstance()->fromCache('sys_objects_search', 'getAllWithKey',
  33. 'SELECT `ID` as `id`,
  34. `Title` as `title`,
  35. `ClassName` as `class`,
  36. `ClassPath` as `file`,
  37. `ObjectName`
  38. FROM `sys_objects_search`', 'ObjectName'
  39. );
  40. $aValues = array();
  41. foreach ($aList as $sKey => $aValue) {
  42. $aValues[$sKey] = _t($aValue['title']);
  43. if (!class_exists($aValue['class'])) {
  44. $sPath = BX_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $oTemplate->getCode(), $aValue['file']);
  45. require_once($sPath);
  46. }
  47. $oClass = new $aValue['class']();
  48. }
  49. if (isset($_GET['type'])) {
  50. $aValue = bx_process_input($_GET['type']);
  51. } else {
  52. $aValue = array_keys($aValues);
  53. }
  54. $aForm = array(
  55. 'form_attrs' => array(
  56. 'id' => 'searchForm',
  57. 'action' => '',
  58. 'method' => 'post',
  59. 'onsubmit' => '',
  60. ),
  61. 'inputs' => array(
  62. 'section' => array(
  63. 'type' => 'checkbox_set',
  64. 'name' => 'section',
  65. 'caption' => _t('_Section'),
  66. 'values' => $aValues,
  67. 'value' => $aValue,
  68. ),
  69. 'keyword' => array(
  70. 'type' => 'text',
  71. 'name' => 'keyword',
  72. 'caption' => _t('_Keyword')
  73. ),
  74. 'search' => array(
  75. 'type' => 'submit',
  76. 'name' => 'search',
  77. 'value' => _t('_Search')
  78. )
  79. )
  80. );
  81. bx_import('BxTemplFormView');
  82. $oForm = new BxTemplFormView($aForm);
  83. $sFormVal = $oForm->getCode();
  84. bx_import('BxTemplPaginate');
  85. $o = new BxTemplPaginate(array());
  86. $o->addCssJs();
  87. return DesignBoxContent(_t( "_Search" ), $sFormVal, BX_DB_PADDING_DEF);
  88. }
  89. function getExtraJs() {
  90. ob_start();
  91. ?>
  92. <script language="javascript">
  93. $(document).ready( function() {
  94. $('#searchForm').bind( 'submit', function() {
  95. bx_loading('searchForm', true);
  96. var sQuery = $('input', '#searchForm').serialize();
  97. $.post('searchKeywordContent.php', sQuery, function(data) {
  98. $('#searchArea').html(data).bxTime();
  99. bx_loading('searchForm', false);
  100. });
  101. return false;
  102. });
  103. });
  104. </script>
  105. <?php
  106. return ob_get_clean();
  107. }