PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/BigBlueHat-dotproject-527fa57/dotproject/modules/smartsearch/index.php

https://github.com/dvilboy/Techweb
PHP | 259 lines | 238 code | 21 blank | 0 comment | 28 complexity | ce393ddd495446ea1d41c5fa13d227f2 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php /* SMARTSEARCH$Id$ */
  2. if (!defined('DP_BASE_DIR')) {
  3. die('You should not access this file directly.');
  4. }
  5. $files = $AppUI->readFiles((DP_BASE_DIR . '/modules/' . $m . '/searchobjects'), '\.php$');
  6. sort($files);
  7. $keyword1 = dPgetParam($_POST, 'keyword1', '');
  8. $keyword2 = dPgetParam($_POST, 'keyword2', '');
  9. $keyword3 = dPgetParam($_POST, 'keyword3', '');
  10. $keyword4 = dPgetParam($_POST, 'keyword4', '');
  11. $all_words = dPgetParam($_POST, 'allwords', '');
  12. $mod_selection = dPgetParam($_POST, 'modselection', '');
  13. $advanced_search = dPgetParam($_POST, 'advancedsearch', '');
  14. if ($advanced_search == 'on') {
  15. $ignore_specchar = dPgetParam($_POST, 'ignorespecchar', '');
  16. $ignore_case = dPgetParam($_POST, 'ignorecase', '');
  17. $display_all_flds = dPgetParam($_POST, 'displayallflds', '');
  18. $show_empty = dPgetParam($_POST, 'showempty', '');
  19. }
  20. else {
  21. $ignore_case = 'on';
  22. }
  23. ?>
  24. <script language="JavaScript">
  25. function focusOnSearchBox() {
  26. document.forms.frmSearch.keyword1.focus();
  27. }
  28. function toggleStatus(obj) {
  29. if (obj.checked) {
  30. var block=document.getElementById("div_advancedsearch");
  31. block.style.display="block";
  32. var block1=document.getElementById("div_advancedsearch1");
  33. block1.style.visibility="visible";
  34. }
  35. else {
  36. var block=document.getElementById("div_advancedsearch");
  37. block.style.display="none";
  38. var block1=document.getElementById("div_advancedsearch1");
  39. block1.style.visibility="hidden";
  40. var key2=document.getElementById("keyword2");
  41. key2.value="";
  42. var key3=document.getElementById("keyword3");
  43. key3.value="";
  44. var key4=document.getElementById("keyword4");
  45. key4.value="";
  46. }
  47. }
  48. function toggleModules(obj) {
  49. var block=document.getElementById("div_selmodules");
  50. if (obj.checked) {
  51. block.style.display="block";
  52. }
  53. else {
  54. block.style.display="none";
  55. }
  56. }
  57. function selModAll() {
  58. <?php
  59. $objarray = Array();
  60. foreach ($files as $tmp) {
  61. $temp = mb_substr($tmp,0,-8);
  62. ?>
  63. document.frmSearch.mod_<?php echo $temp ?>.checked=true;
  64. <?php
  65. }
  66. ?>
  67. }
  68. function deselModAll() {
  69. <?php
  70. $objarray = Array();
  71. foreach ($files as $tmp) {
  72. $temp = mb_substr($tmp,0,-8);
  73. ?>
  74. document.frmSearch.mod_<?php echo $temp ?>.checked=false;
  75. <?php
  76. }
  77. ?>
  78. }
  79. window.onload = focusOnSearchBox;
  80. </script>
  81. <?php
  82. $titleBlock = new CTitleBlock('SmartSearch', 'kfind.png', $m, $m . '.' . $a);
  83. $titleBlock->show();
  84. ?>
  85. <form name="frmSearch" action="?m=<?php echo $m ;?>" method="POST">
  86. <table cellspacing="5" cellpadding="0" border="0">
  87. <tr>
  88. <td align="left">
  89. <div id="div_advancedsearch1" name="div_advancedsearch1" style="<?php
  90. echo ($advanced_search == 'on' ? 'visibility:visible':'visibility:hidden'); ?> ">
  91. 1.
  92. </div>
  93. </td>
  94. <td align="left">
  95. <input class="text" size="18" type="text" id="keyword1" name="keyword1" value="<?php
  96. echo stripslashes($keyword1); ?>" />
  97. </td>
  98. <td align="left">
  99. <input class="button" type="submit" value="<?php echo $AppUI->_('Search'); ?>" />
  100. </td>
  101. <td align="left">
  102. <input name="allwords" id="allwords" type="checkbox" value="on"<?php
  103. echo (($all_words == 'on') ? ' checked="checked"' : ''); ?> />
  104. <label for="all_words"><?php echo $AppUI->_('All words');?></label>
  105. </td>
  106. <td align="left">
  107. <input name="modselection" id="modselection" type="checkbox" value="on"<?php
  108. echo (($mod_selection == 'on') ? ' checked="checked"' : ''); ?> onclick="toggleModules(this)" />
  109. <label for="modselection"><?php
  110. echo $AppUI->_('Modules selection');?></label>
  111. </td>
  112. <td align="left">
  113. <input name="advancedsearch" id="advancedsearch" type="checkbox"<?php
  114. echo (($advanced_search == 'on') ? ' checked="checked"' : ''); ?> onclick="toggleStatus(this)" />
  115. <label for="advancedsearch"><?php echo $AppUI->_('Advanced search'); ?></label>
  116. </td>
  117. </tr>
  118. </table>
  119. <div id="div_advancedsearch" name="div_advancedsearch" style="<?php
  120. echo ($advanced_search== 'on' ? 'display:block' : 'display:none'); ?> ">
  121. <table cellspacing="5" cellpadding="0" border="0">
  122. <tr>
  123. <td align="left">
  124. <label for="keyword2">2.</label>
  125. <input class="text" size="18" type="text" id="keyword2" name="keyword2" value="<?php
  126. echo stripslashes($keyword2); ?>" />
  127. </td>
  128. <td align="left">
  129. <label for="keyword3">3.</label>
  130. <input class="text" size="18" type="text" id="keyword3" name="keyword3" value="<?php
  131. echo stripslashes($keyword3); ?>" />
  132. </td>
  133. <td align="left">
  134. <label for="keyword4">4.</label>
  135. <input class="text" size="18" type="text" id="keyword4" name="keyword4" value="<?php
  136. echo stripslashes($keyword4); ?>" />
  137. </td>
  138. <td align="left">
  139. <input name="ignorespecchar" id="ignorespecchar" type="checkbox" value="on"<?php
  140. echo (($ignore_specchar == 'on') ? ' checked="checked"' : ''); ?> />
  141. <label for="ignorespecchar"><?php echo $AppUI->_('Ignore special chars'); ?></label>
  142. </td>
  143. <td align="left">
  144. <input name="ignorecase" id="ignorecase" type="checkbox" value="on"<?php
  145. echo (($ignore_case == 'on') ? ' checked="checked"' : ''); ?> />
  146. <label for="ignorecase"><?php echo $AppUI->_('Ignore case'); ?></label>
  147. </td>
  148. <td align="left">
  149. <input name="displayallflds" id="displayallflds" type="checkbox" value="on"<?php
  150. echo (($display_all_flds == 'on') ? ' checked="checked"' : ''); ?> />
  151. <label for="displayallflds"><?php echo $AppUI->_('Display all fields'); ?></label>
  152. </td>
  153. <td align="left">
  154. <input name="showempty" id="showempty" type="checkbox" value="on"<?php
  155. echo (($show_empty == 'on') ? ' checked="checked"' : ''); ?> />
  156. <label for="showempty"><?php echo $AppUI->_('Show empty'); ?></label>
  157. </td>
  158. </tr>
  159. </table>
  160. </div>
  161. <div id="div_selmodules" name="div_selmodules" style="<?php
  162. echo ($mod_selection == 'on' ? 'display:block' : 'display:none'); ?> ">
  163. <table cellspacing="0" cellpadding="0" border="0">
  164. <tr>
  165. <td>
  166. <a href="#" onclick="selModAll(this)"><?php echo $AppUI->_('Select all'); ?></a> |
  167. <a href="#" onclick="deselModAll(this)"><?php echo $AppUI->_('Deselect all'); ?></a>
  168. </td>
  169. </tr>
  170. <?php
  171. $objarray = Array();
  172. foreach ($files as $tmp) {
  173. $temp = mb_substr($tmp,0,-8);
  174. require_once('./modules/' . $m . '/searchobjects/' . $tmp);
  175. $class_obj = new $temp();
  176. $mod_select[$temp] = dPgetParam($_POST, ('mod_' . $temp), '');
  177. if (getPermission($class_obj->table_module, 'access')) {
  178. ?>
  179. <tr>
  180. <td align="left">
  181. <input name="mod_<?php echo $temp; ?>" id="mod_<?php echo $temp; ?>" type="checkbox" value="on"<?php
  182. echo (($mod_select[$temp] == 'on') ? ' checked="checked"' : ''); ?> />
  183. <label for="mod_<?php echo $temp; ?>"><?php echo $AppUI->_($class_obj->table_title); ?></label>
  184. </td>
  185. </tr>
  186. <?php
  187. }
  188. }
  189. ?>
  190. </table>
  191. </div>
  192. </form>
  193. <?php
  194. if ($keyword1) {
  195. $search = new smartsearch();
  196. $search->keyword = addslashes($keyword1);
  197. $keywords = array();
  198. for ($x = 1; $x <= 4; $x++) {
  199. if (isset(${('keyword' . $x)}) && mb_strlen(${('keyword'.$x)}) > 0) {
  200. $or_keywords = preg_split('/[\s,;]+/', addslashes(${('keyword'.$x)}));
  201. foreach ($or_keywords as $or_keyword) {
  202. $keywords[$or_keyword][0] = $or_keyword;
  203. $keywords[$or_keyword][1] = $x -1;
  204. }
  205. } else {
  206. $or_keywords = preg_split('/[\s,;]+/', addslashes(${('keyword'.$x)}));
  207. foreach ($or_keywords as $or_keyword) {
  208. unset($keywords[$or_keyword]);
  209. }
  210. }
  211. }
  212. ?>
  213. <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
  214. <?php
  215. $reccount = 0;
  216. foreach ($files as $tmp) {
  217. require_once('./modules/' . $m . '/searchobjects/' . $tmp);
  218. $temp = mb_substr($tmp, 0, -8);
  219. $search_opts['all_words'] = $all_words;
  220. $search_opts['ignore_specchar'] = $ignore_specchar;
  221. $search_opts['ignore_case'] = $ignore_case;
  222. $search_opts['display_all_flds'] = $display_all_flds;
  223. $search_opts['show_empty'] = $show_empty;
  224. $search_opts['keywords'] = $keywords;
  225. if ($mod_selection != 'on' || $mod_select[$temp] == 'on') {
  226. $class_search = new $temp();
  227. $class_search->setKeyword($search->keyword);
  228. $class_search->setAdvanced($search_opts);
  229. $results = $class_search->fetchResults($reccount);
  230. echo $results;
  231. }
  232. }
  233. echo ('<tr><td><b>' . $AppUI->_('Total records found') . ': ' . $reccount . '</b></td></tr>');
  234. ?>
  235. </table>
  236. <?php
  237. }
  238. ?>