search_page.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2005-2013 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 search box
  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. $langs->load("main");
  35. $right=($langs->trans("DIRECTION")=='rtl'?'left':'right');
  36. $left=($langs->trans("DIRECTION")=='rtl'?'right':'left');
  37. /*
  38. * View
  39. */
  40. $title=$langs->trans("Search");
  41. // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
  42. $head='<!-- Quick access -->'."\n";
  43. $arrayofjs=array();
  44. $arrayofcss=array();
  45. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  46. print '<body>'."\n";
  47. print '<div>';
  48. //print '<br>';
  49. $nbofsearch=0;
  50. // Instantiate hooks of thirdparty module
  51. $hookmanager->initHooks(array('searchform'));
  52. // Define $searchform
  53. $searchform = '';
  54. if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile
  55. {
  56. if (! is_object($form)) $form=new Form($db);
  57. $selected=-1;
  58. $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'data-role="none"', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
  59. }
  60. else
  61. {
  62. $conf->global->MAIN_HTML5_PLACEHOLDER = 1;
  63. $usedbyinclude = 1; // Used into next include
  64. include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
  65. $accesskeyalreadyassigned=array();
  66. foreach($arrayresult as $key => $val)
  67. {
  68. $tmp=explode('?', $val['url']);
  69. $urlaction=$tmp[0];
  70. $keysearch=$tmp[1];
  71. $keysearch=preg_replace('/mainmenu=(.*)&/','',$keysearch);
  72. $keysearch=preg_replace('/=/','',$keysearch);
  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));
  80. }
  81. }
  82. // Execute hook printSearchForm
  83. $parameters=array('searchform'=>$searchform);
  84. $reshook=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks
  85. if (empty($reshook))
  86. {
  87. $searchform.=$hookmanager->resPrint;
  88. }
  89. else $searchform=$hookmanager->resPrint;
  90. print "\n";
  91. print "<!-- Begin SearchForm -->\n";
  92. print '<div class="center" align="center"><div align="center" style="padding: 6px;">';
  93. print '<style>.menu_titre { padding-top: 7px; }</style>';
  94. //print '<div id="distance"></div><div id="container" class="center">';
  95. print '<div id="blockvmenusearch">'."\n";
  96. print $searchform;
  97. print '</div>'."\n";
  98. //print '</div></div>';
  99. print '</div></div>';
  100. print "\n<!-- End SearchForm -->\n";
  101. print '</div>';
  102. print '</body></html>'."\n";
  103. $db->close();