dolibarr  18.0.0
search_page.php
Go to the documentation of this file.
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 
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
27 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
28 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
29 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
30 if (!defined('NOCSRFCHECK')) {
31  define('NOCSRFCHECK', 1);
32 }
33 if (!defined('NOTOKENRENEWAL')) {
34  define('NOTOKENRENEWAL', 1);
35 }
36 //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
37 if (!defined('NOREQUIREMENU')) {
38  define('NOREQUIREMENU', 1);
39 }
40 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
41 
42 require_once '../main.inc.php';
43 
44 if (GETPOST('lang', 'aZ09')) {
45  $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
46 }
47 
48 $langs->load("main");
49 
50 $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
51 $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
52 
53 
54 /*
55  * View
56  */
57 
58 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
59 if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) {
60  header('Cache-Control: max-age='.GETPOST('cache', 'int').', public');
61  // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
62  header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT');
63  // HTTP/1.0
64  header('Pragma: token=public');
65 } else {
66  // HTTP/1.0
67  header('Cache-Control: no-cache');
68 }
69 
70 $title = $langs->trans("Search");
71 
72 // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
73 $head = '<!-- Quick access -->'."\n"; // This is used by DoliDroid to know page is a search page
74 $arrayofjs = array();
75 $arrayofcss = array();
76 top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
77 
78 
79 
80 print '<body>'."\n";
81 print '<div>';
82 //print '<br>';
83 
84 $nbofsearch = 0;
85 
86 // Instantiate hooks of thirdparty module
87 $hookmanager->initHooks(array('searchform'));
88 
89 // Define $searchform
90 $searchform = '';
91 
92 if ($conf->use_javascript_ajax && 1 == 2) { // select2 is not best with smartphone
93  if (!is_object($form)) {
94  $form = new Form($db);
95  }
96  $selected = -1;
97  $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
98 } else {
99  $usedbyinclude = 1; // Used into next include
100  $showtitlebefore = GETPOST('showtitlebefore', 'int');
101  $arrayresult = array();
102  include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
103 
104  $i = 0;
105  $accesskeyalreadyassigned = array();
106  foreach ($arrayresult as $key => $val) {
107  $tmp = explode('?', $val['url']);
108  $urlaction = $tmp[0];
109  $keysearch = 'search_all';
110 
111  $accesskey = '';
112  if (empty($accesskeyalreadyassigned[$val['label'][0]])) {
113  $accesskey = $val['label'][0]; // First char of string
114  $accesskeyalreadyassigned[$accesskey] = $accesskey;
115  }
116 
117  $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
118 
119  $i++;
120  }
121 }
122 
123 // Execute hook printSearchForm
124 $parameters = array('searchform'=>$searchform);
125 $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
126 if (empty($reshook)) {
127  $searchform .= $hookmanager->resPrint;
128 } else {
129  $searchform = $hookmanager->resPrint;
130 }
131 
132 
133 print "\n";
134 print "<!-- Begin SearchForm -->\n";
135 print '<div class="center"><div class="center" style="padding: 6px;">';
136 print '<style>.menu_titre { padding-top: 7px; }</style>';
137 print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
138 print $searchform;
139 print '</div>'."\n";
140 print '</div></div>';
141 print "\n<!-- End SearchForm -->\n";
142 
143 print '</div>';
144 print '</body></html>'."\n";
145 
146 $db->close();
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1625
printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='', $img='', $showtitlebefore=0, $autofocus=0)
Show a search area.
Definition: main.inc.php:3429