1 | <?php |
||
2 | /* Copyright (C) 2019 Alxarafe <[email protected]> |
||
3 | * |
||
4 | * This program is free software; you can redistribute it and/or modify |
||
5 | * it under the terms of the GNU General Public License as published by |
||
6 | * the Free Software Foundation; either version 3 of the License, or |
||
7 | * (at your option) any later version. |
||
8 | * |
||
9 | * This program is distributed in the hope that it will be useful, |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
12 | * GNU General Public License for more details. |
||
13 | * |
||
14 | * You should have received a copy of the GNU General Public License |
||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
16 | */ |
||
17 | namespace Alixar\Base; |
||
18 | |||
19 | use Alxarafe\Helpers\Debug; |
||
20 | use Alixar\Helpers\Globals; |
||
21 | use Alixar\Helpers\DolUtils; |
||
22 | |||
23 | /** |
||
24 | * This class contains the methods and attributes common to all Alixar view |
||
25 | * |
||
26 | * @author Alxarafe |
||
27 | */ |
||
28 | class AlixarView extends \Alixar\Base\AlixarBasicView |
||
29 | { |
||
30 | |||
31 | //public $menumanager; |
||
32 | |||
33 | public function __construct($ctrl) |
||
34 | { |
||
35 | parent::__construct($ctrl); |
||
36 | //Globals::$menuManager = $this->ctrl->menuManager; |
||
37 | } |
||
38 | |||
39 | public function getTopMenu() |
||
40 | { |
||
41 | $ret[] = [ |
||
42 | 'text' => '<i class="fa fa-cog fa-fw"></i> Config', |
||
43 | 'href' => '?call=EditConfig', |
||
44 | ]; |
||
45 | $ret[] = [ |
||
46 | 'text' => '<i class="fa fa-database fa-fw"></i> Database', |
||
47 | 'href' => 'index.html', |
||
48 | 'options' => [ |
||
49 | [ |
||
50 | 'text' => '<i class="fa fa-address-book fa-fw"></i> People', |
||
51 | 'href' => '?call=People' |
||
52 | ], |
||
53 | [ |
||
54 | 'text' => '<i class="fa fa-automobile fa-fw"></i> Vehicles', |
||
55 | 'href' => '?call=Vehicles', |
||
56 | 'options' => [ |
||
57 | 'text' => '<i class="fa fa-address-book fa-fw"></i> People', |
||
58 | 'href' => '?call=People' |
||
59 | ] |
||
60 | ] |
||
61 | ] |
||
62 | ]; |
||
63 | |||
64 | return $ret; |
||
65 | } |
||
66 | |||
67 | public function getLeftMenu(): array |
||
68 | { |
||
69 | $ret[] = [ |
||
70 | 'text' => '<i class="fa fa-cog fa-fw"></i> Config', |
||
71 | 'href' => '?call=EditConfig', |
||
72 | ]; |
||
73 | $ret[] = [ |
||
74 | 'text' => '<i class="fa fa-database fa-fw"></i> Database', |
||
75 | 'href' => 'index.html', |
||
76 | 'options' => [ |
||
77 | [ |
||
78 | 'text' => '<i class="fa fa-address-book fa-fw"></i> People', |
||
79 | 'href' => '?call=People' |
||
80 | ], |
||
81 | [ |
||
82 | 'text' => '<i class="fa fa-automobile fa-fw"></i> Vehicles', |
||
83 | 'href' => '?call=Vehicles', |
||
84 | 'options' => [ |
||
85 | 'text' => '<i class="fa fa-address-book fa-fw"></i> People', |
||
86 | 'href' => '?call=People' |
||
87 | ] |
||
88 | ] |
||
89 | ] |
||
90 | ]; |
||
91 | |||
92 | return $ret; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Show HTML header HTML + BODY + Top menu + left menu + DIV |
||
97 | * |
||
98 | * @param string $head Optionnal head lines |
||
99 | * @param string $title HTML title |
||
100 | * @param string $help_url Url links to help page |
||
101 | * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage |
||
102 | * For other external page: http://server/url |
||
103 | * @param string $target Target to use on links |
||
104 | * @param int $disablejs More content into html header |
||
105 | * @param int $disablehead More content into html header |
||
106 | * @param array $arrayofjs Array of complementary js files |
||
107 | * @param array $arrayofcss Array of complementary css files |
||
108 | * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) |
||
109 | * @param string $morecssonbody More CSS on body tag. |
||
110 | * @param string $replacemainareaby Replace call to main_area() by a print of this string |
||
111 | * @return void |
||
112 | */ |
||
113 | function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '') |
||
114 | { |
||
115 | //global $conf; |
||
116 | // html header |
||
117 | $this->top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); |
||
118 | |||
119 | print '<body id="mainbody"' . ($morecssonbody ? ' class="' . $morecssonbody . '"' : '') . '>' . "\n"; |
||
120 | |||
121 | // top menu and left menu area |
||
122 | if (empty(Globals::$conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) { |
||
123 | $this->top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); |
||
124 | } |
||
125 | |||
126 | if (empty(Globals::$conf->dol_hide_leftmenu)) { |
||
127 | $this->left_menu('', $help_url, '', '', 1, $title, 1); // $menumanager is retreived with a global $menumanager inside this function |
||
128 | } |
||
129 | |||
130 | // main area |
||
131 | if ($replacemainareaby) { |
||
132 | print $replacemainareaby; |
||
133 | return; |
||
134 | } |
||
135 | $this->main_area($title); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * Show an HTML header + a BODY + The top menu bar |
||
140 | * |
||
141 | * @param string $head Lines in the HEAD |
||
142 | * @param string $title Title of web page |
||
143 | * @param string $target Target to use in menu links (Example: '' or '_top') |
||
144 | * @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) |
||
145 | * @param int $disablehead Do not output head section |
||
146 | * @param array $arrayofjs Array of js files to add in header |
||
147 | * @param array $arrayofcss Array of css files to add in header |
||
148 | * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) |
||
149 | * @param string $helppagename Name of wiki page for help ('' by default). |
||
150 | * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage |
||
151 | * For other external page: http://server/url |
||
152 | * @return void |
||
153 | */ |
||
154 | function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $helppagename = '') |
||
155 | { |
||
156 | // global Globals::$user, Globals::$conf, Globals::$langs, $db; |
||
157 | // global $dolibarr_main_authentication, $dolibarr_main_demo; |
||
158 | // global Globals::$hookManager, $menumanager; |
||
159 | |||
160 | $searchform = ''; |
||
161 | $bookmarks = ''; |
||
162 | |||
163 | // Instantiate hooks of thirdparty module |
||
164 | Globals::$hookManager->initHooks(array('toprightmenu')); |
||
165 | |||
166 | $toprightmenu = ''; |
||
167 | |||
168 | // For backward compatibility with old modules |
||
169 | if (empty(Globals::$conf->headerdone)) { |
||
170 | $this->top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); |
||
171 | print '<body id="mainbody">'; |
||
172 | } |
||
173 | |||
174 | /* |
||
175 | * Top menu |
||
176 | */ |
||
177 | if ((empty(Globals::$conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { |
||
178 | print "\n" . '<!-- Start top horizontal -->' . "\n"; |
||
179 | |||
180 | print '<div class="side-nav-vert' . (DolUtils::GETPOST('dol_invisible_topmenu', 'int') ? ' hidden' : '') . '"><div id="id-top">'; // dol_invisible_topmenu differs from dol_hide_topmenu: dol_invisible_topmenu means we output menu but we make it invisible. |
||
181 | // Show menu entries |
||
182 | print '<div id="tmenu_tooltip' . (empty(Globals::$conf->global->MAIN_MENU_INVERT) ? '' : 'invert') . '" class="tmenu">' . "\n"; |
||
183 | Globals::$menuManager->atarget = $target; |
||
184 | Globals::$menuManager->showmenu('top', array('searchform' => $searchform, 'bookmarks' => $bookmarks)); // This contains a \n |
||
185 | print "</div>\n"; |
||
186 | |||
187 | // Define link to login card |
||
188 | $appli = constant('DOL_APPLICATION_TITLE'); |
||
189 | if (!empty(Globals::$conf->global->MAIN_APPLICATION_TITLE)) { |
||
190 | $appli = Globals::$conf->global->MAIN_APPLICATION_TITLE; |
||
191 | if (preg_match('/\d\.\d/', $appli)) { |
||
192 | if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
||
193 | $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
||
194 | } else |
||
195 | $appli .= " " . DOL_VERSION; |
||
196 | } else |
||
197 | $appli .= " " . DOL_VERSION; |
||
198 | |||
199 | if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
||
200 | $appli .= "<br>" . Globals::$langs->trans("LevelOfFeature") . ': ' . Globals::$conf->global->MAIN_FEATURES_LEVEL; |
||
201 | |||
202 | $logouttext = ''; |
||
203 | if (empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
||
204 | //$logouthtmltext=$appli.'<br>'; |
||
205 | $logouthtmltext = ''; |
||
206 | if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') { { |
||
207 | $logouthtmltext .= Globals::$langs->trans("Logout") . '<br>'; |
||
208 | } |
||
209 | |||
210 | //$logouttext .='<a accesskey="l" href="'.DOL_BASE_URI.'/user/logout.php">'; |
||
211 | $logouttext .= '<a accesskey="l" href="' . BASE_URI . '?controller=user&method=logout">'; |
||
212 | //$logouttext .= img_picto(Globals::$langs->trans('Logout').":".Globals::$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); |
||
213 | $logouttext .= '<span class="fa fa-sign-out atoplogin"></span>'; |
||
214 | $logouttext .= '</a>'; |
||
215 | } else { |
||
216 | $logouthtmltext .= Globals::$langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]); |
||
217 | $logouttext .= img_picto(Globals::$langs->trans('Logout') . ":" . Globals::$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); |
||
218 | } |
||
219 | } |
||
220 | |||
221 | print '<div class="login_block">' . "\n"; |
||
222 | |||
223 | // Add login user link |
||
224 | $toprightmenu .= '<div class="login_block_user">'; |
||
225 | |||
226 | // Login name with photo and tooltip |
||
227 | $mode = -1; |
||
228 | $toprightmenu .= '<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">'; |
||
229 | $toprightmenu .= Globals::$user->getNomUrl($mode, '', 1, 0, 11, 0, (Globals::$user->firstname ? 'firstname' : -1), 'atoplogin'); |
||
230 | $toprightmenu .= '</div></div>'; |
||
231 | |||
232 | $toprightmenu .= '</div>' . "\n"; |
||
233 | |||
234 | $toprightmenu .= '<div class="login_block_other">'; |
||
235 | |||
236 | // Execute hook printTopRightMenu (hooks should output string like '<div class="login"><a href="">mylink</a></div>') |
||
237 | $parameters = array(); |
||
238 | $result = Globals::$hookManager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks |
||
239 | if (is_numeric($result)) { |
||
240 | if ($result == 0) |
||
241 | $toprightmenu .= Globals::$hookManager->resPrint; // add |
||
242 | else |
||
243 | $toprightmenu = Globals::$hookManager->resPrint; // replace |
||
244 | } |
||
245 | else { |
||
246 | $toprightmenu .= $result; // For backward compatibility |
||
247 | } |
||
248 | |||
249 | // Link to module builder |
||
250 | if (!empty(Globals::$conf->modulebuilder->enabled)) { |
||
251 | //$text = '<a href="' . DOL_BASE_URI . '/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="_modulebuilder">'; |
||
252 | $text = '<a href="' . BASE_URI . '?controller=modulebuilder&method=index&mainmenu=home&leftmenu=admintools" target="_modulebuilder">'; |
||
253 | //$text.= img_picto(":".Globals::$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); |
||
254 | $text .= '<span class="fa fa-bug atoplogin"></span>'; |
||
255 | $text .= '</a>'; |
||
256 | $toprightmenu .= @Form::textwithtooltip('', Globals::$langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); |
||
257 | } |
||
258 | |||
259 | // Link to print main content area |
||
260 | if (empty(Globals::$conf->global->MAIN_PRINT_DISABLELINK) && empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && Globals::$conf->browser->layout != 'phone') { |
||
261 | $qs = dol_escape_htmltag($_SERVER["QUERY_STRING"]); |
||
262 | |||
263 | if (is_array($_POST)) { |
||
264 | foreach ($_POST as $key => $value) { |
||
265 | if ($key !== 'action' && $key !== 'password' && !is_array($value)) { |
||
266 | $qs .= '&' . $key . '=' . urlencode($value); |
||
267 | } |
||
268 | } |
||
269 | } |
||
270 | $qs .= (($qs && $morequerystring) ? '&' : '') . $morequerystring; |
||
271 | $text = '<a href="' . dol_escape_htmltag($_SERVER["PHP_SELF"]) . '?' . $qs . ($qs ? '&' : '') . 'optioncss=print" target="_blank">'; |
||
272 | //$text.= img_picto(":".Globals::$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); |
||
273 | $text .= '<span class="fa fa-print atoplogin"></span>'; |
||
274 | $text .= '</a>'; |
||
275 | $toprightmenu .= @Form::textwithtooltip('', Globals::$langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2); |
||
276 | } |
||
277 | |||
278 | // Link to Dolibarr wiki pages |
||
279 | if (empty(Globals::$conf->global->MAIN_HELP_DISABLELINK) && empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
||
280 | Globals::$langs->load("help"); |
||
281 | |||
282 | $helpbaseurl = ''; |
||
283 | $helppage = ''; |
||
284 | $mode = ''; |
||
285 | |||
286 | if (empty($helppagename)) { |
||
287 | $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios'; |
||
288 | } |
||
289 | // Get helpbaseurl, helppage and mode from helppagename and langs |
||
290 | $arrayres = getHelpParamFor($helppagename, Globals::$langs); |
||
291 | $helpbaseurl = $arrayres['helpbaseurl']; |
||
292 | $helppage = $arrayres['helppage']; |
||
293 | $mode = $arrayres['mode']; |
||
294 | |||
295 | // Link to help pages |
||
296 | if ($helpbaseurl && $helppage) { |
||
297 | $text = ''; |
||
298 | if (!empty(Globals::$conf->global->MAIN_SHOWDATABASENAMEINHELPPAGESLINK)) { |
||
299 | Globals::$langs->load('admin'); |
||
300 | $appli .= '<br>' . Globals::$langs->trans("Database") . ': ' . $db->database_name; |
||
301 | } |
||
302 | $title = $appli . '<br>'; |
||
303 | $title .= Globals::$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage'); |
||
304 | if ($mode == 'wiki') { |
||
305 | $title .= ' - ' . Globals::$langs->trans("PageWiki") . ' "' . dol_escape_htmltag(strtr($helppage, '_', ' ')) . '"'; |
||
306 | } |
||
307 | $text .= '<a class="help" target="_blank" rel="noopener" href="'; |
||
308 | if ($mode == 'wiki') { |
||
309 | $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage))); |
||
310 | } else { |
||
311 | $text .= sprintf($helpbaseurl, $helppage); |
||
312 | } |
||
313 | $text .= '">'; |
||
314 | //$text.=img_picto('', 'helpdoc_top').' '; |
||
315 | $text .= '<span class="fa fa-question-circle atoplogin"></span>'; |
||
316 | //$toprightmenu.=Globals::$langs->trans($mode == 'wiki' ? 'OnlineHelp': 'Help'); |
||
317 | //if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')'; |
||
318 | $text .= '</a>'; |
||
319 | //$toprightmenu.='</div>'."\n"; |
||
320 | $toprightmenu .= @Form::textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); |
||
321 | } |
||
322 | } |
||
323 | |||
324 | // Logout link |
||
325 | $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2); |
||
326 | |||
327 | $toprightmenu .= '</div>'; |
||
328 | |||
329 | print $toprightmenu; |
||
330 | |||
331 | print "</div>\n"; // end div class="login_block" |
||
332 | |||
333 | print '</div></div>'; |
||
334 | |||
335 | print '<div style="clear: both;"></div>'; |
||
336 | print "<!-- End top horizontal menu -->\n\n"; |
||
337 | } |
||
338 | |||
339 | if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) |
||
340 | print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">'; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
341 | } |
||
342 | |||
343 | /** |
||
344 | * Show left menu bar |
||
345 | * |
||
346 | * @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''. |
||
347 | * @param string $helppagename Name of wiki page for help ('' by default). |
||
348 | * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage |
||
349 | * For other external page: http://server/url |
||
350 | * @param string $notused Deprecated. Used in past to add content into left menu. Hooks can be used now. |
||
351 | * @param array $menu_array_after Table of menu entries to show after entries of menu handler |
||
352 | * @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules. |
||
353 | * @param string $title Title of web page |
||
354 | * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) |
||
355 | * @return void |
||
356 | */ |
||
357 | function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_array_after = '', $leftmenuwithoutmainarea = 0, $title = '', $acceptdelayedhtml = 0) |
||
358 | { |
||
359 | // global Globals::$user, Globals::$conf, Globals::$langs, $db, $form; |
||
360 | // global Globals::$hookManager, $menumanager; |
||
361 | |||
362 | $searchform = ''; |
||
363 | $bookmarks = ''; |
||
364 | |||
365 | if (!empty($menu_array_before)) |
||
366 | dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING); |
||
367 | |||
368 | if (empty(Globals::$conf->dol_hide_leftmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { |
||
369 | // Instantiate hooks of thirdparty module |
||
370 | Globals::$hookManager->initHooks(array('searchform', 'leftblock')); |
||
371 | |||
372 | print "\n" . '<!-- Begin side-nav id-left -->' . "\n" . '<div class="side-nav"><div id="id-left">' . "\n"; |
||
373 | |||
374 | if (Globals::$conf->browser->layout == 'phone') |
||
375 | Globals::$conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? |
||
376 | |||
377 | print "\n"; |
||
378 | |||
379 | if (!is_object($form)) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
380 | $form = new Form($db); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
381 | } |
||
382 | $selected = -1; |
||
383 | $usedbyinclude = 1; |
||
384 | include_once DOL_BASE_PATH . '/core/ajax/selectsearchbox.php'; // This set $arrayresult |
||
385 | |||
386 | if (Globals::$conf->use_javascript_ajax && empty(Globals::$conf->global->MAIN_USE_OLD_SEARCH_FORM)) { |
||
387 | //$searchform.=$form->selectArrayAjax('searchselectcombo', DOL_BASE_URI.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, Globals::$langs->trans("Search"), 1); |
||
388 | $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty(Globals::$conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, Globals::$langs->trans("Search"), 1); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
389 | } else { |
||
390 | foreach ($arrayresult as $key => $val) { |
||
391 | //$searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth100', 'sall', $val['shortcut'], 'searchleft', img_picto('',$val['img'])); |
||
392 | $searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft', img_picto('', $val['img'], '', false, 1, 1)); |
||
393 | } |
||
394 | } |
||
395 | |||
396 | // Execute hook printSearchForm |
||
397 | $parameters = array('searchform' => $searchform); |
||
398 | |||
399 | $reshook = Globals::$hookManager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks |
||
400 | if (empty($reshook)) { |
||
401 | $searchform .= Globals::$hookManager->resPrint; |
||
402 | } else |
||
403 | $searchform = Globals::$hookManager->resPrint; |
||
404 | |||
405 | // Force special value for $searchform |
||
406 | if (!empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty(Globals::$conf->use_javascript_ajax)) { |
||
407 | $urltosearch = DOL_BASE_URI . '/core/search_page.php?showtitlebefore=1'; |
||
408 | $searchform = '<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="' . $urltosearch . '" alt="' . dol_escape_htmltag(Globals::$langs->trans("ShowSearchFields")) . '">' . Globals::$langs->trans("Search") . '...</a></div></div>'; |
||
409 | } elseif (Globals::$conf->use_javascript_ajax && !empty(Globals::$conf->global->MAIN_USE_OLD_SEARCH_FORM)) { |
||
410 | $searchform = '<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="#" alt="' . dol_escape_htmltag(Globals::$langs->trans("ShowSearchFields")) . '">' . Globals::$langs->trans("Search") . '...</a></div><div id="divsearchforms2" style="display: none">' . $searchform . '</div>'; |
||
411 | $searchform .= '<script type="text/javascript"> |
||
412 | jQuery(document).ready(function () { |
||
413 | jQuery("#divsearchforms1").click(function(){ |
||
414 | jQuery("#divsearchforms2").toggle(); |
||
415 | }); |
||
416 | }); |
||
417 | </script>' . "\n"; |
||
418 | $searchform .= '</div>'; |
||
419 | } |
||
420 | |||
421 | // Define $bookmarks |
||
422 | if (!empty(Globals::$conf->bookmark->enabled) && Globals::$user->rights->bookmark->lire) { |
||
423 | include_once DOL_BASE_PATH . '/bookmarks/bookmarks.lib.php'; |
||
424 | Globals::$langs->load("bookmarks"); |
||
425 | |||
426 | $bookmarks = printBookmarksList($db, Globals::$langs); |
||
427 | } |
||
428 | |||
429 | // Left column |
||
430 | print '<!-- Begin left menu -->' . "\n"; |
||
431 | |||
432 | print '<div class="vmenu"' . (empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Left menu"') . '>' . "\n\n"; |
||
433 | |||
434 | // Show left menu with other forms |
||
435 | Globals::$menuManager->menu_array = $menu_array_before; |
||
436 | Globals::$menuManager->menu_array_after = $menu_array_after; |
||
437 | Globals::$menuManager->showmenu('left', array('searchform' => $searchform, 'bookmarks' => $bookmarks)); // output menu_array and menu found in database |
||
438 | // Dolibarr version + help + bug report link |
||
439 | print "\n"; |
||
440 | print "<!-- Begin Help Block-->\n"; |
||
441 | print '<div id="blockvmenuhelp" class="blockvmenuhelp">' . "\n"; |
||
442 | |||
443 | // Version |
||
444 | if (empty(Globals::$conf->global->MAIN_HIDE_VERSION)) { // Version is already on help picto and on login page. |
||
445 | $doliurl = 'https://www.dolibarr.org'; |
||
446 | //local communities |
||
447 | if (preg_match('/fr/i', Globals::$langs->defaultlang)) |
||
448 | $doliurl = 'https://www.dolibarr.fr'; |
||
449 | if (preg_match('/es/i', Globals::$langs->defaultlang)) |
||
450 | $doliurl = 'https://www.dolibarr.es'; |
||
451 | if (preg_match('/de/i', Globals::$langs->defaultlang)) |
||
452 | $doliurl = 'https://www.dolibarr.de'; |
||
453 | if (preg_match('/it/i', Globals::$langs->defaultlang)) |
||
454 | $doliurl = 'https://www.dolibarr.it'; |
||
455 | if (preg_match('/gr/i', Globals::$langs->defaultlang)) |
||
456 | $doliurl = 'https://www.dolibarr.gr'; |
||
457 | |||
458 | $appli = constant('DOL_APPLICATION_TITLE'); |
||
459 | if (!empty(Globals::$conf->global->MAIN_APPLICATION_TITLE)) { |
||
460 | $appli = Globals::$conf->global->MAIN_APPLICATION_TITLE; |
||
461 | $doliurl = ''; |
||
462 | if (preg_match('/\d\.\d/', $appli)) { |
||
463 | if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
||
464 | $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
||
465 | } else |
||
466 | $appli .= " " . DOL_VERSION; |
||
467 | } else |
||
468 | $appli .= " " . DOL_VERSION; |
||
469 | print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">'; |
||
470 | if ($doliurl) |
||
471 | print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">'; |
||
472 | else |
||
473 | print '<span class="help">'; |
||
474 | print $appli; |
||
475 | if ($doliurl) |
||
476 | print '</a>'; |
||
477 | else |
||
478 | print '</span>'; |
||
479 | print '</div>' . "\n"; |
||
480 | } |
||
481 | |||
482 | // Link to bugtrack |
||
483 | if (!empty(Globals::$conf->global->MAIN_BUGTRACK_ENABLELINK)) { |
||
484 | require_once DOL_BASE_PATH . '/core/lib/functions2.lib.php'; |
||
485 | |||
486 | $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new'; |
||
487 | $bugbaseurl .= '?title='; |
||
488 | $bugbaseurl .= urlencode("Bug: "); |
||
489 | $bugbaseurl .= '&body='; |
||
490 | $bugbaseurl .= urlencode("# Bug\n"); |
||
491 | $bugbaseurl .= urlencode("\n"); |
||
492 | $bugbaseurl .= urlencode("## Environment\n"); |
||
493 | $bugbaseurl .= urlencode("- **Version**: " . DOL_VERSION . "\n"); |
||
494 | $bugbaseurl .= urlencode("- **OS**: " . php_uname('s') . "\n"); |
||
495 | $bugbaseurl .= urlencode("- **Web server**: " . $_SERVER["SERVER_SOFTWARE"] . "\n"); |
||
496 | $bugbaseurl .= urlencode("- **PHP**: " . php_sapi_name() . ' ' . phpversion() . "\n"); |
||
497 | $bugbaseurl .= urlencode("- **Database**: " . $db::LABEL . ' ' . $db->getVersion() . "\n"); |
||
498 | $bugbaseurl .= urlencode("- **URL**: " . $_SERVER["REQUEST_URI"] . "\n"); |
||
499 | $bugbaseurl .= urlencode("\n"); |
||
500 | $bugbaseurl .= urlencode("## Report\n"); |
||
501 | print '<div id="blockvmenuhelpbugreport" class="blockvmenuhelp">'; |
||
502 | print '<a class="help" target="_blank" rel="noopener" href="' . $bugbaseurl . '">' . Globals::$langs->trans("FindBug") . '</a>'; |
||
503 | print '</div>'; |
||
504 | } |
||
505 | |||
506 | print "</div>\n"; |
||
507 | print "<!-- End Help Block-->\n"; |
||
508 | print "\n"; |
||
509 | |||
510 | print "</div>\n"; |
||
511 | print "<!-- End left menu -->\n"; |
||
512 | print "\n"; |
||
513 | |||
514 | // Execute hook printLeftBlock |
||
515 | $parameters = array(); |
||
516 | $reshook = Globals::$hookManager->executeHooks('printLeftBlock', $parameters); // Note that $action and $object may have been modified by some hooks |
||
517 | print Globals::$hookManager->resPrint; |
||
518 | |||
519 | print '</div></div> <!-- End side-nav id-left -->'; // End div id="side-nav" div id="id-left" |
||
520 | } |
||
521 | |||
522 | print "\n"; |
||
523 | print '<!-- Begin right area -->' . "\n"; |
||
524 | |||
525 | if (empty($leftmenuwithoutmainarea)) |
||
526 | main_area($title); |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * Begin main area |
||
531 | * |
||
532 | * @param string $title Title |
||
533 | * @return void |
||
534 | */ |
||
535 | function main_area($title = '') |
||
536 | { |
||
537 | // global Globals::$conf, Globals::$langs; |
||
538 | |||
539 | if (empty(Globals::$conf->dol_hide_leftmenu)) |
||
540 | print '<div id="id-right">'; |
||
541 | |||
542 | print "\n"; |
||
543 | |||
544 | print '<!-- Begin div class="fiche" -->' . "\n" . '<div class="fiche">' . "\n"; |
||
545 | |||
546 | if (!empty(Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)) |
||
547 | print info_admin(Globals::$langs->trans("WarningYouAreInMaintenanceMode", Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); |
||
548 | } |
||
549 | |||
550 | /** |
||
551 | * Return helpbaseurl, helppage and mode |
||
552 | * |
||
553 | * @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff...' or 'http://localpage') |
||
554 | * @param Translate Globals::$langs Language |
||
555 | * @return array Array of help urls |
||
556 | */ |
||
557 | function getHelpParamFor($helppagename, $langs) |
||
558 | { |
||
559 | $helpbaseurl = ''; |
||
560 | $helppage = ''; |
||
561 | $mode = ''; |
||
562 | |||
563 | if (preg_match('/^http/i', $helppagename)) { |
||
564 | // If complete URL |
||
565 | $helpbaseurl = '%s'; |
||
566 | $helppage = $helppagename; |
||
567 | $mode = 'local'; |
||
568 | } else { |
||
569 | // If WIKI URL |
||
570 | if (preg_match('/^es/i', Globals::$langs->defaultlang)) { |
||
571 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
||
572 | if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) |
||
573 | $helppage = $reg[1]; |
||
574 | } |
||
575 | if (preg_match('/^fr/i', Globals::$langs->defaultlang)) { |
||
576 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
||
577 | if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) |
||
578 | $helppage = $reg[1]; |
||
579 | } |
||
580 | if (empty($helppage)) { // If help page not already found |
||
581 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
||
582 | if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) |
||
583 | $helppage = $reg[1]; |
||
584 | } |
||
585 | $mode = 'wiki'; |
||
586 | } |
||
587 | return array('helpbaseurl' => $helpbaseurl, 'helppage' => $helppage, 'mode' => $mode); |
||
588 | } |
||
589 | |||
590 | /** |
||
591 | * Show a search area. |
||
592 | * Used when the javascript quick search is not used. |
||
593 | * |
||
594 | * @param string $urlaction Url post |
||
595 | * @param string $urlobject Url of the link under the search box |
||
596 | * @param string $title Title search area |
||
597 | * @param string $htmlmorecss Add more css |
||
598 | * @param string $htmlinputname Field Name input form |
||
599 | * @param string $accesskey Accesskey |
||
600 | * @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page |
||
601 | * @param string $img Image to use |
||
602 | * @param string $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers. |
||
603 | * @return string |
||
604 | */ |
||
605 | function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey = '', $prefhtmlinputname = '', $img = '', $showtitlebefore = 0) |
||
606 | { |
||
607 | // global Globals::$conf, Globals::$langs, Globals::$user; |
||
608 | |||
609 | $ret = ''; |
||
610 | $ret .= '<form action="' . $urlaction . '" method="post" class="searchform">'; |
||
611 | $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
||
612 | $ret .= '<input type="hidden" name="mode" value="search">'; |
||
613 | $ret .= '<input type="hidden" name="savelogin" value="' . dol_escape_htmltag(Globals::$user->login) . '">'; |
||
614 | if ($showtitlebefore) |
||
615 | $ret .= $title . ' '; |
||
616 | $ret .= '<input type="text" class="flat ' . $htmlmorecss . '"'; |
||
617 | $ret .= ' style="text-indent: 22px; background-image: url(\'' . $img . '\'); background-repeat: no-repeat; background-position: 3px;"'; |
||
618 | $ret .= ($accesskey ? ' accesskey="' . $accesskey . '"' : ''); |
||
619 | $ret .= ' placeholder="' . strip_tags($title) . '"'; |
||
620 | $ret .= ' name="' . $htmlinputname . '" id="' . $prefhtmlinputname . $htmlinputname . '" />'; |
||
621 | //$ret.='<input type="submit" class="button" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px" value="'.Globals::$langs->trans("Go").'">'; |
||
622 | $ret .= '<button type="submit" class="button" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px">'; |
||
623 | $ret .= '<span class="fa fa-search"></span>'; |
||
624 | $ret .= '</button>'; |
||
625 | $ret .= "</form>\n"; |
||
626 | return $ret; |
||
627 | } |
||
628 | |||
629 | /** |
||
630 | * Show HTML footer |
||
631 | * Close div /DIV class=fiche + /DIV id-right + /DIV id-container + /BODY + /HTML. |
||
632 | * If global var $delayedhtmlcontent was filled, we output it just before closing the body. |
||
633 | * |
||
634 | * @param string $comment A text to add as HTML comment into HTML generated page |
||
635 | * @param string $zone 'private' (for private pages) or 'public' (for public pages) |
||
636 | * @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them |
||
637 | * @return void |
||
638 | */ |
||
639 | function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0) |
||
640 | { |
||
641 | // global Globals::$conf, Globals::$langs, Globals::$user, $object; |
||
642 | // global $delayedhtmlcontent; |
||
643 | // global $contextpage, $page, $limit; |
||
644 | |||
645 | $ext = 'layout=' . Globals::$conf->browser->layout . '&version=' . urlencode(DOL_VERSION); |
||
646 | |||
647 | // Global html output events ($mesgs, $errors, $warnings) |
||
648 | dol_htmloutput_events($disabledoutputofmessages); |
||
649 | |||
650 | // Code for search criteria persistence. |
||
651 | // Globals::$user->lastsearch_values was set by the GETPOST when form field search_xxx exists |
||
652 | if (is_object(Globals::$user) && !empty(Globals::$user->lastsearch_values_tmp) && is_array(Globals::$user->lastsearch_values_tmp)) { |
||
653 | // Clean and save data |
||
654 | foreach (Globals::$user->lastsearch_values_tmp as $key => $val) { |
||
655 | unset($_SESSION['lastsearch_values_tmp_' . $key]); // Clean array to rebuild it just after |
||
656 | if (count($val) && empty($_POST['button_removefilter'])) { // If there is search criteria to save and we did not click on 'Clear filter' button |
||
657 | if (empty($val['sortfield'])) |
||
658 | unset($val['sortfield']); |
||
659 | if (empty($val['sortorder'])) |
||
660 | unset($val['sortorder']); |
||
661 | dol_syslog('Save lastsearch_values_tmp_' . $key . '=' . json_encode($val, 0) . " (systematic recording of last search criterias)"); |
||
662 | $_SESSION['lastsearch_values_tmp_' . $key] = json_encode($val); |
||
663 | unset($_SESSION['lastsearch_values_' . $key]); |
||
664 | } |
||
665 | } |
||
666 | } |
||
667 | |||
668 | |||
669 | $relativepathstring = $_SERVER["PHP_SELF"]; |
||
670 | // Clean $relativepathstring |
||
671 | if (constant('DOL_BASE_URI')) |
||
672 | $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
||
673 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
||
674 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
||
675 | if (preg_match('/list\.php$/', $relativepathstring)) { |
||
676 | unset($_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring]); |
||
677 | unset($_SESSION['lastsearch_page_tmp_' . $relativepathstring]); |
||
678 | unset($_SESSION['lastsearch_limit_tmp_' . $relativepathstring]); |
||
679 | |||
680 | if (!empty($contextpage)) |
||
681 | $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage; |
||
682 | if (!empty($page) && $page > 1) |
||
683 | $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page; |
||
684 | if (!empty($limit) && $limit != Globals::$conf->limit) |
||
685 | $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit; |
||
686 | |||
687 | unset($_SESSION['lastsearch_contextpage_' . $relativepathstring]); |
||
688 | unset($_SESSION['lastsearch_page_' . $relativepathstring]); |
||
689 | unset($_SESSION['lastsearch_limit_' . $relativepathstring]); |
||
690 | } |
||
691 | |||
692 | // Core error message |
||
693 | if (!empty(Globals::$conf->global->MAIN_CORE_ERROR)) { |
||
694 | // Ajax version |
||
695 | if (Globals::$conf->use_javascript_ajax) { |
||
696 | $title = img_warning() . ' ' . Globals::$langs->trans('CoreErrorTitle'); |
||
697 | print ajax_dialog($title, Globals::$langs->trans('CoreErrorMessage')); |
||
0 ignored issues
–
show
Are you sure the usage of
ajax_dialog($title, Alix...ns('CoreErrorMessage')) is correct as it seems to always return null .
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
698 | } |
||
699 | // html version |
||
700 | else { |
||
701 | $msg = img_warning() . ' ' . Globals::$langs->trans('CoreErrorMessage'); |
||
702 | print '<div class="error">' . $msg . '</div>'; |
||
703 | } |
||
704 | |||
705 | //define("MAIN_CORE_ERROR",0); // Constant was defined and we can't change value of a constant |
||
706 | } |
||
707 | |||
708 | print "\n\n"; |
||
709 | |||
710 | print '</div> <!-- End div class="fiche" -->' . "\n"; // End div fiche |
||
711 | |||
712 | if (empty(Globals::$conf->dol_hide_leftmenu)) |
||
713 | print '</div> <!-- End div id-right -->' . "\n"; // End div id-right |
||
714 | |||
715 | if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) |
||
716 | print '</div> <!-- End div id-container -->' . "\n"; // End div container |
||
717 | |||
718 | print "\n"; |
||
719 | if ($comment) |
||
720 | print '<!-- ' . $comment . ' -->' . "\n"; |
||
721 | |||
722 | printCommonFooter($zone); |
||
723 | |||
724 | if (!empty($delayedhtmlcontent)) |
||
725 | print $delayedhtmlcontent; |
||
726 | |||
727 | if (!empty(Globals::$conf->use_javascript_ajax)) { |
||
728 | print "\n" . '<!-- Includes JS Footer of Dolibarr -->' . "\n"; |
||
729 | print '<script type="text/javascript" src="' . BASE_URI . '?controller=core/js/&method=lib_foot.js&lang=' . Globals::$langs->defaultlang . ($ext ? '&' . $ext : '') . '"></script>' . "\n"; |
||
730 | } |
||
731 | |||
732 | // Wrapper to add log when clicking on download or preview |
||
733 | if (!empty(Globals::$conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) { |
||
734 | if (in_array($object->element, array('facture'))) { // Restrict for the moment to element 'facture' |
||
735 | print "\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n"; |
||
736 | |||
737 | ?> |
||
738 | <script type="text/javascript"> |
||
739 | jQuery(document).ready(function () { |
||
740 | $('a.documentpreview').click(function () { |
||
741 | $.post('<?php echo DOL_BASE_URI . "/blockedlog/ajax/block-add.php" ?>' |
||
742 | , { |
||
743 | id:<?php echo $object->id; ?> |
||
744 | , element: '<?php echo $object->element ?>' |
||
745 | , action: 'DOC_PREVIEW' |
||
746 | } |
||
747 | ); |
||
748 | }); |
||
749 | $('a.documentdownload').click(function () { |
||
750 | $.post('<?php echo DOL_BASE_URI . "/blockedlog/ajax/block-add.php" ?>' |
||
751 | , { |
||
752 | id:<?php echo $object->id; ?> |
||
753 | , element: '<?php echo $object->element ?>' |
||
754 | , action: 'DOC_DOWNLOAD' |
||
755 | } |
||
756 | ); |
||
757 | }); |
||
758 | }); |
||
759 | </script> |
||
760 | <?php |
||
761 | } |
||
762 | } |
||
763 | |||
764 | // A div for the address popup |
||
765 | print "\n<!-- A div to allow dialog popup -->\n"; |
||
766 | print '<div id="dialogforpopup" style="display: none;"></div>' . "\n"; |
||
767 | |||
768 | print "</body>\n"; |
||
769 | |||
770 | print "<!-- Alixar debugBar footer -->"; |
||
771 | print Debug::getRenderFooter(); // Includes Alixar debugBar footer |
||
772 | |||
773 | print "</html>\n"; |
||
774 | } |
||
775 | } |
||
776 |