Clean code

This commit is contained in:
Laurent Destailleur 2021-10-25 12:09:17 +02:00
parent 98f4f0b1c9
commit 940c69b46d
2 changed files with 128 additions and 4 deletions

View File

@ -0,0 +1,126 @@
<?php
/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This file is a modified version of datepicker.php from phpBSM to fix some
* bugs, to add new features and to dramatically increase speed.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/bookmarks_page.php
* \brief File to return a page with the complete list of bookmarks (all search input fields)
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
require_once '../main.inc.php';
if (GETPOST('lang', 'aZ09')) {
$langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
}
$langs->load("main");
$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
/*
* View
*/
$title = $langs->trans("Bookmarks");
// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
$head = '<!-- Bookmarks access -->'."\n";
$arrayofjs = array();
$arrayofcss = array();
top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
print '<body>'."\n";
print '<div>';
//print '<br>';
$nbofsearch = 0;
// Instantiate hooks of thirdparty module
$hookmanager->initHooks(array('bookmarks'));
// Define $bookmarks
$bookmarks = '';
$arrayresult = array();
//include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
$i = 0;
$accesskeyalreadyassigned = array();
foreach ($arrayresult as $key => $val) {
$tmp = explode('?', $val['url']);
$urlaction = $tmp[0];
$keysearch = 'search_all';
$accesskey = '';
if (!$accesskeyalreadyassigned[$val['label'][0]]) {
$accesskey = $val['label'][0];
$accesskeyalreadyassigned[$accesskey] = $accesskey;
}
//$bookmarks .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
$i++;
}
// Execute hook printSearchForm
$parameters = array('bookmarks'=>$bookmarks);
$reshook = $hookmanager->executeHooks('printBookmarks', $parameters); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
$bookmarks .= $hookmanager->resPrint;
} else {
$bookmarks = $hookmanager->resPrint;
}
print "\n";
print "<!-- Begin Bookmarks list -->\n";
print '<div class="center"><div class="center" style="padding: 6px;">';
print '<style>.menu_titre { padding-top: 7px; }</style>';
print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
print $bookmarks;
print '</div>'."\n";
print '</div></div>';
print "\n<!-- End SearchForm -->\n";
print '</div>';
print '</body></html>'."\n";
$db->close();

View File

@ -1795,7 +1795,6 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
global $hookmanager, $menumanager;
$searchform = '';
$bookmarks = '';
// Instantiate hooks for external modules
$hookmanager->initHooks(array('toprightmenu'));
@ -1825,7 +1824,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
// Show menu entries
print '<div id="tmenu_tooltip'.(empty($conf->global->MAIN_MENU_INVERT) ? '' : 'invert').'" class="tmenu">'."\n";
$menumanager->atarget = $target;
$menumanager->showmenu('top', array('searchform'=>$searchform, 'bookmarks'=>$bookmarks)); // This contains a \n
$menumanager->showmenu('top', array('searchform'=>$searchform)); // This contains a \n
print "</div>\n";
// Define link to login card
@ -2712,7 +2711,6 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_
global $hookmanager, $menumanager;
$searchform = '';
$bookmarks = '';
if (!empty($menu_array_before)) {
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);
@ -2783,7 +2781,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_
// Show left menu with other forms
$menumanager->menu_array = $menu_array_before;
$menumanager->menu_array_after = $menu_array_after;
$menumanager->showmenu('left', array('searchform'=>$searchform, 'bookmarks'=>$bookmarks)); // output menu_array and menu found in database
$menumanager->showmenu('left', array('searchform'=>$searchform)); // output menu_array and menu found in database
// Dolibarr version + help + bug report link
print "\n";