Cheetah
searchKeyword.php
Go to the documentation of this file.
1 <?php
2 
8 require_once('inc/header.inc.php');
9 require_once(CH_DIRECTORY_PATH_INC . 'design.inc.php');
10 require_once(CH_DIRECTORY_PATH_INC . 'languages.inc.php');
11 
12 ch_import('ChWsbSearch');
13 ch_import('ChTemplFormView');
14 
15 check_logged();
16 $member['ID'] = getLoggedId();
17 
18 $_page['name_index'] = 81;
19 $_page['css_name'] = array('searchKeyword.css', 'plugins/fancybox/|jquery.fancybox.css');
20 $_page['js_name'] = array('plugins/fancybox/|jquery.fancybox.js');
21 
22 $_page['header'] = _t( "_Search" );
23 $_page['header_text'] = _t("_Search");
24 
25 ob_start();
26 ?>
27 <script language="javascript">
28  function toggleState(sItem) {
29  $('#'+sItem).toggleClass('ch-btn-disabled', !$('#'+sItem).hasClass('ch-btn-disabled'));
30  }
31  function serializeButtons() {
32  var sQuery = '';
33  $('button', '#buttonArea').each(function(index) {
34  if (!$(this).hasClass('ch-btn-disabled')) {
35  sQuery += '&section[]=' + $(this).prop('id');
36  }
37  });
38  return sQuery;
39  }
40  $(document).ready(function() {
41  $('#searchForm').bind('submit', function() {
42  ch_loading('searchForm', true);
43  var sQuery = $('input', '#searchForm').serialize();
44  sQuery += serializeButtons();
45  $.post('searchKeywordContent.php', sQuery, function(data) {
46  $('#searchArea').html(data);
47  ch_loading('searchForm', false);
48  });
49  return false;
50  });
51  });
52 </script>
53 <?php
54 $sCode = '';
55 $_page['extra_js'] = ob_get_clean();
56 
57 $_ni = $_page['name_index'];
58 
59 $oZ = new ChWsbSearch();
60 if (ch_get('keyword')) {
61  $sCode = $oZ->response();
62  if (mb_strlen($sCode) == 0)
63  $sCode = $oZ->getEmptyResult();
64 }
65 
67 $sSearchArea = '<div id="searchArea">'.$sCode.'</div>';
68 
69 $_page_cont[$_ni]['page_main_code'] = $sForm . $sSearchArea;
70 
71 $aVars = array ();
72 $GLOBALS['oTopMenu']->setCustomSubActions($aVars, '');
73 
74 PageCode();
75 
76 function getSearchForm ()
77 {
78  $aList = $GLOBALS['MySQL']->fromCache('sys_objects_search', 'getAllWithKey',
79  'SELECT `ID` as `id`,
80  `Title` as `title`,
81  `ClassName` as `class`,
82  `ClassPath` as `file`,
83  `ObjectName`
84  FROM `sys_objects_search`', 'ObjectName'
85  );
86  $aValues = array();
87  foreach ($aList as $sKey => $aValue) {
88  $aValues[$sKey] = _t($aValue['title']);
89  if (!class_exists($aValue['class'])) {
90  $sPath = CH_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $GLOBALS['tmpl'], $aValue['file']);
91  require_once($sPath);
92  }
93  $oClass = new $aValue['class']();
94  $oClass->addCustomParts();
95  }
96 
97  $sButtons = '<div id="buttonArea" class="ch-btn-area clearfix">';
98  foreach ($aList as $sKey => $aValue) {
99  $sClassAdd = '';
100  if (isset($_GET['type']))
101  $sClassAdd = $_GET['type'] == $sKey ? '' : 'ch-btn-disabled';
102  $sButtons .= '<button class="ch-btn ch-btn-centered ' . $sClassAdd . '" type="button" id="' . $sKey . '" onclick="toggleState(\'' . $sKey . '\');">' . _t($aValue['title']) . '</button>';
103  }
104  $sButtons .= '</div>';
105 
106  $aForm = array(
107  'form_attrs' => array(
108  'id' => 'searchForm',
109  'action' => '',
110  'method' => 'post',
111  'onsubmit' => '',
112  ),
113  'inputs' => array(
114  'keyword' => array(
115  'type' => 'text',
116  'name' => 'keyword',
117  'caption' => _t('_Keyword')
118  ),
119  'search' => array(
120  'type' => 'submit',
121  'name' => 'search',
122  'value' => _t('_Search')
123  )
124  )
125  );
126 
127  $oForm = new ChTemplFormView($aForm);
128  $sFormVal = $oForm->getCode();
129 
130  return DesignBoxContent(_t( "_Search" ), $sButtons . $sFormVal, 11);
131 }
document
Output SortAttr HTML Purifier will sort attributes by name before writing them back to the document
Definition: Output.SortAttr.txt:8
check_logged
check_logged()
Definition: admin.inc.php:238
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
$oZ
$oZ
Definition: searchKeyword.php:59
$sCode
$sCode
Definition: searchKeyword.php:54
getSearchForm
getSearchForm()
Definition: searchKeyword.php:76
php
$_GET
$_GET['debug']
Definition: index.php:67
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
$member
$member['ID']
Definition: searchKeyword.php:16
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
$sSearchArea
$sSearchArea
Definition: searchKeyword.php:67
$sForm
if(ch_get('keyword')) $sForm
Definition: searchKeyword.php:66
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: searchKeyword.php:69
$_page
$_page['name_index']
Definition: searchKeyword.php:18
$aVars
$aVars
Definition: searchKeyword.php:71
$_ni
$_ni
Definition: searchKeyword.php:57
ChWsbSearch
Definition: ChWsbSearch.php:39
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10