search_page.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 <http://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. include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
  66. $i=0;
  67. $accesskeyalreadyassigned=array();
  68. foreach($arrayresult as $key => $val)
  69. {
  70. $tmp=explode('?', $val['url']);
  71. $urlaction=$tmp[0];
  72. $keysearch='search_all';
  73. $accesskey='';
  74. if (! $accesskeyalreadyassigned[$val['label'][0]])
  75. {
  76. $accesskey=$val['label'][0];
  77. $accesskeyalreadyassigned[$accesskey]=$accesskey;
  78. }
  79. $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore, ($i>0?0:1));
  80. $i++;
  81. }
  82. }
  83. // Execute hook printSearchForm
  84. $parameters=array('searchform'=>$searchform);
  85. $reshook=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks
  86. if (empty($reshook))
  87. {
  88. $searchform.=$hookmanager->resPrint;
  89. }
  90. else $searchform=$hookmanager->resPrint;
  91. print "\n";
  92. print "<!-- Begin SearchForm -->\n";
  93. print '<div class="center" align="center"><div align="center" style="padding: 6px;">';
  94. print '<style>.menu_titre { padding-top: 7px; }</style>';
  95. print '<div id="blockvmenusearch">'."\n";
  96. print $searchform;
  97. print '</div>'."\n";
  98. print '</div></div>';
  99. print "\n<!-- End SearchForm -->\n";
  100. print '</div>';
  101. print '</body></html>'."\n";
  102. $db->close();