search_page.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 search boxes
  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')) define('NOCSRFCHECK', 1);
  29. if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
  30. //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
  31. if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
  32. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
  33. require_once '../main.inc.php';
  34. if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
  35. $langs->load("main");
  36. $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
  37. $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
  38. /*
  39. * View
  40. */
  41. $title = $langs->trans("Search");
  42. // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
  43. $head = '<!-- Quick access -->'."\n";
  44. $arrayofjs = array();
  45. $arrayofcss = array();
  46. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  47. print '<body>'."\n";
  48. print '<div>';
  49. //print '<br>';
  50. $nbofsearch = 0;
  51. // Instantiate hooks of thirdparty module
  52. $hookmanager->initHooks(array('searchform'));
  53. // Define $searchform
  54. $searchform = '';
  55. if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile
  56. {
  57. if (!is_object($form)) $form = new Form($db);
  58. $selected = -1;
  59. $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
  60. }
  61. else
  62. {
  63. $usedbyinclude = 1; // Used into next include
  64. $showtitlebefore = GETPOST('showtitlebefore', 'int');
  65. $arrayresult = array();
  66. include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
  67. $i = 0;
  68. $accesskeyalreadyassigned = array();
  69. foreach ($arrayresult as $key => $val)
  70. {
  71. $tmp = explode('?', $val['url']);
  72. $urlaction = $tmp[0];
  73. $keysearch = 'search_all';
  74. $accesskey = '';
  75. if (!$accesskeyalreadyassigned[$val['label'][0]])
  76. {
  77. $accesskey = $val['label'][0];
  78. $accesskeyalreadyassigned[$accesskey] = $accesskey;
  79. }
  80. $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
  81. $i++;
  82. }
  83. }
  84. // Execute hook printSearchForm
  85. $parameters = array('searchform'=>$searchform);
  86. $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
  87. if (empty($reshook))
  88. {
  89. $searchform .= $hookmanager->resPrint;
  90. }
  91. else $searchform = $hookmanager->resPrint;
  92. print "\n";
  93. print "<!-- Begin SearchForm -->\n";
  94. print '<div class="center"><div class="center" style="padding: 6px;">';
  95. print '<style>.menu_titre { padding-top: 7px; }</style>';
  96. print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
  97. print $searchform;
  98. print '</div>'."\n";
  99. print '</div></div>';
  100. print "\n<!-- End SearchForm -->\n";
  101. print '</div>';
  102. print '</body></html>'."\n";
  103. $db->close();