search_page.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This file is a modified version of datepicker.php from phpBSM to fix some
  5. * bugs, to add new features and to dramatically increase speed.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/core/search_page.php
  22. * \brief File to return a page with the complete search form (all search input fields)
  23. */
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
  25. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
  26. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  27. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
  28. if (!defined('NOCSRFCHECK')) {
  29. define('NOCSRFCHECK', 1);
  30. }
  31. if (!defined('NOTOKENRENEWAL')) {
  32. define('NOTOKENRENEWAL', 1);
  33. }
  34. //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
  35. if (!defined('NOREQUIREMENU')) {
  36. define('NOREQUIREMENU', 1);
  37. }
  38. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
  39. require_once '../main.inc.php';
  40. if (GETPOST('lang', 'aZ09')) {
  41. $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
  42. }
  43. $langs->load("main");
  44. $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
  45. $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
  46. /*
  47. * View
  48. */
  49. $title = $langs->trans("Search");
  50. // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
  51. $head = '<!-- Quick access -->'."\n";
  52. $arrayofjs = array();
  53. $arrayofcss = array();
  54. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  55. print '<body>'."\n";
  56. print '<div>';
  57. //print '<br>';
  58. $nbofsearch = 0;
  59. // Instantiate hooks of thirdparty module
  60. $hookmanager->initHooks(array('searchform'));
  61. // Define $searchform
  62. $searchform = '';
  63. if ($conf->use_javascript_ajax && 1 == 2) { // select2 is not best with smartphone
  64. if (!is_object($form)) {
  65. $form = new Form($db);
  66. }
  67. $selected = -1;
  68. $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
  69. } else {
  70. $usedbyinclude = 1; // Used into next include
  71. $showtitlebefore = GETPOST('showtitlebefore', 'int');
  72. $arrayresult = array();
  73. include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
  74. $i = 0;
  75. $accesskeyalreadyassigned = array();
  76. foreach ($arrayresult as $key => $val) {
  77. $tmp = explode('?', $val['url']);
  78. $urlaction = $tmp[0];
  79. $keysearch = 'search_all';
  80. $accesskey = '';
  81. if (!$accesskeyalreadyassigned[$val['label'][0]]) {
  82. $accesskey = $val['label'][0];
  83. $accesskeyalreadyassigned[$accesskey] = $accesskey;
  84. }
  85. $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
  86. $i++;
  87. }
  88. }
  89. // Execute hook printSearchForm
  90. $parameters = array('searchform'=>$searchform);
  91. $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
  92. if (empty($reshook)) {
  93. $searchform .= $hookmanager->resPrint;
  94. } else {
  95. $searchform = $hookmanager->resPrint;
  96. }
  97. print "\n";
  98. print "<!-- Begin SearchForm -->\n";
  99. print '<div class="center"><div class="center" style="padding: 6px;">';
  100. print '<style>.menu_titre { padding-top: 7px; }</style>';
  101. print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
  102. print $searchform;
  103. print '</div>'."\n";
  104. print '</div></div>';
  105. print "\n<!-- End SearchForm -->\n";
  106. print '</div>';
  107. print '</body></html>'."\n";
  108. $db->close();