From cc1d4901350ebc029ffc7363af373bd2b336bd32 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 29 Sep 2019 11:47:34 +0200 Subject: [PATCH 01/61] Prepare dropdown bookmark menu --- htdocs/bookmarks/bookmarks.lib.php | 171 +++++++++++++++++++++++++++++ htdocs/main.inc.php | 77 +++++++++++++ htdocs/theme/eldy/dropdown.inc.php | 58 +++++++++- 3 files changed, 304 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 5dd55a95873..2e7d105af34 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -150,3 +150,174 @@ function printBookmarksList($aDb, $aLangs) return $ret; } + + + +/** + * Add area with bookmarks in top menu + * + * @param DoliDb $aDb Database handler + * @param Translate $aLangs Object lang + * @return string + */ +function printDropdownBookmarksList($aDb, $aLangs) +{ + global $conf, $user; + + $db = $aDb; + $langs = $aLangs; + + require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; + if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; + + $langs->load("bookmarks"); + + $url= $_SERVER["PHP_SELF"]; + + if (! empty($_SERVER["QUERY_STRING"])) + { + $url.=(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); + } + else + { + global $sortfield,$sortorder; + $tmpurl=''; + // No urlencode, all param $url will be urlencoded later + if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield; + if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder; + if (is_array($_POST)) + { + foreach($_POST as $key => $val) + { + if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; + } + } + $url.=($tmpurl?'?'.$tmpurl:''); + } + + $searchForm = ''."\n"; + $searchForm.= '
'; + $searchForm.= ''; + $searchForm.= '
'; + + // Url to list bookmark + $listbtn = ''; + + $listbtn = ''; + $listbtn.= ' '.$langs->trans('Bookmarks').'...'; + + // Url to go on create new bookmark page + $newbtn = ''; + if (! empty($user->rights->bookmark->creer)) + { + //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url); + $urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); + $newbtn.= ''; + $newbtn.= ' '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').''; + } + + + $html = ' + + +
+ '.$searchForm.' +
+ + +
+ + + '; + + + + return $html; + + + + if (! empty($conf->use_javascript_ajax)) { // Bookmark autosubmit can't work when javascript is off. + + + + + + // Menu bookmark + $ret = ''."\n"; + + $ret.= ''."\n"; + $ret.= '
'; + $ret.= ''; + $ret.= '
'; + + $ret.=ajax_combobox('boxbookmark'); + + $ret.=''; + } + + $ret.= ''."\n"; + + return $ret; +} \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ce8b1d6027e..1584bded9f7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1606,6 +1606,12 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead print '
'."\n"; + + // Add bookmark dropdown + $toprightmenu.=top_menu_bookmark($user, $langs); + + + // Add login user link $toprightmenu.='