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