|  | 
| static | addEntry ($db, $menuID, $text, $href) | 
|  | add new entry to an existing menu  More... 
 | 
|  | 
| static | changeLanguage ($db, $menu, $menuLanguage) | 
|  | Change the menu language.  More... 
 | 
|  | 
| static | changeTitle ($db, $menu, $menutitle) | 
|  | Change the menu title.  More... 
 | 
|  | 
| static | createMenu ($db, $name, $lang) | 
|  | create a new menu  More... 
 | 
|  | 
| static | delete ($db, $id, $lang) | 
|  | delete a whole menu  More... 
 | 
|  | 
| static | deleteEntry ($db, $menu, $id) | 
|  | delete a single menu entry  More... 
 | 
|  | 
| static | display ($db, $id, $user, $template) | 
|  | get menu from database, build and draw it  More... 
 | 
|  | 
| static | displayEditable ($db, $id, $lang) | 
|  | display menu entries for editing in backend  More... 
 | 
|  | 
| static | displayGlobalMenu ($db, $user, $template) | 
|  | display the global menu  More... 
 | 
|  | 
| static | drawLogoutMenu ($db) | 
|  | draw the logout menu (if user is logged in...)  More... 
 | 
|  | 
| static | editEntry ($db, $menu, $id, $text, $title, $href, $sort, $gid, $published, $parentID, $target, $icon) | 
|  | edit a single menu entry  More... 
 | 
|  | 
| static | getMenuEntryStatus ($db, $menuid) | 
|  | check if a single menu entry is published or not  More... 
 | 
|  | 
| static | getMenuIdFromLanguage ($db, $menuLanguage) | 
|  | Get menu ID by language.  More... 
 | 
|  | 
| static | getMenuItemTitleByID ($db, $itemID, $menuID) | 
|  | returns the item title for given item and menu ID  More... 
 | 
|  | 
| static | getMenuNameByID ($db, $id) | 
|  | get menu name for given id  More... 
 | 
|  | 
| static | getMenuStatus ($db, $menuid) | 
|  | check if a whole menu is published or not  More... 
 | 
|  | 
The default menu class. Serves all the menu functions. 
The default menu class. Serves all the menu functions.
This class serves all functions to create, edit, delete and modify menus and menu entries. 
Class covers both, backend & frontend functionality. See Methods Summary for Details!
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com 
- Copyright
- 2009-2021 Daniel Retzl @license https://opensource.org/licenses/MIT 
- Version
- 1.0.0 
Definition at line 16 of file menu.php.
  
  | 
        
          | static YAWK\menu::display | ( |  | $db, |  
          |  |  |  | $id, |  
          |  |  |  | $user, |  
          |  |  |  | $template |  
          |  | ) |  |  |  | static | 
 
get menu from database, build and draw it 
- Copyright
- 2009-2016 Daniel Retzl @license https://opensource.org/licenses/MIT 
- Version
- 1.0.0 
- Parameters
- 
  
    | object | $db | database obj |  | int | $id | affected menu ID |  | object | $user | current user obj |  | object | $template | template obj |  
 
- Parameters
- 
  
  
Definition at line 678 of file menu.php.
  681             if (isset($_SESSION[
'gid'])) {
 
  682                 $currentRole = $_SESSION[
'gid'];
 
  683             } 
else $currentRole = 2;
 
  687             if (isset($_COOKIE[
'userSelectedLanguage']) && (!empty($_COOKIE[
'userSelectedLanguage'])))
 
  689                 $searchstring = 
"WHERE menuLanguage = '".$_COOKIE[
'userSelectedLanguage'].
"'";
 
  693                 $searchstring = 
"WHERE menuID = '" . 
$id . 
"'";
 
  697             $res = 
$db->query(
"SELECT id, text, title, href, target, parentID, divider, icon 
  700                             and gid <= '" . $currentRole . 
"' 
  702                             AND (date_publish <= NOW() or date_publish <=> NULL) 
  703                             AND (date_unpublish >= NOW() or date_unpublish <=> NULL) 
  704                             ORDER BY parentid, sort, title");
 
  712             while ($items = mysqli_fetch_assoc(
$res)) {
 
  714                 $menu[
'items'][$items[
'id']] = $items;
 
  716                 $menu[
'parents'][$items[
'parentID']][] = $items[
'id'];
 
  721             function buildMenu(
$db, 
$parent, $menu, 
$id, $currentRole, $divider, $user, $template)
 
  725                 if (isset($template) && (!empty($template)))
 
  727                     if (isset($template->id) && (!empty($template->id)))
 
  745                 $navbar_center = template::getTemplateSetting(
$db, 
"value", 
"navbar-center", $user, $template);
 
  746                 $navbar_brand = template::getTemplateSetting(
$db, 
"value", 
"navbar-brand", $user, $template);
 
  747                 $frontendSwitch = template::getTemplateSetting(
$db, 
"value", 
"frontendSwitch", $user, $template);
 
  749                 if ($navbar_center == 
"1") { $navbar_center = 
" w-100 justify-content-center"; }
 
  750                 else { $navbar_center = 
""; }
 
  752                 if (!empty($navbar_brand) && ($navbar_brand == 1))
 
  755                     $res = 
$db->query(
"SELECT name FROM {menu_names} WHERE id='" . 
$id . 
"'");
 
  756                     $row = mysqli_fetch_row(
$res);
 
  760                         $navBarBrand = 
"<a class=\"navbar-brand\" id=\"navbar-brand\" href=\"index.html\">" . 
$menuName . 
"</a>";
 
  773                 if (!empty($frontendSwitch) && ($frontendSwitch == 1))
 
  776                     $darkThemeID = template::getTemplateSetting(
$db, 
"value", 
"darkThemeID", $user, $template);
 
  777                     $lightThemeID = template::getTemplateSetting(
$db, 
"value", 
"lightThemeID", $user, $template);
 
  778                     if (!empty($darkThemeID) && !empty($lightThemeID))
 
  780                         $templateSwitchMarkup = 
"<div id=\"frontendSwitch\" class=\"pull-right\"> 
  781                         <a href=\"index.php?templateID=".$darkThemeID.
"\" class=\"text-muted\"><i id=\"darkMode\" data-id=\"".$darkThemeID.
"\" class=\"fa fa-moon-o\"></i></a>  
  782                             <span style=\"color:#ccc; margin-left:5px; margin-right:5px;\">|</span>  
  783                         <a href=\"index.php?templateID=".$lightThemeID.
"\" class=\"text-muted\"><i id=\"lightMode\" data-id=\"".$lightThemeID.
"\" class=\"fa fa-sun-o\"></i></a></div>";
 
  788                 if ($bootstrapVersion == 
"4")
 
  793 <nav id=\"navbar\" class=\"navbar navbar-expand-lg navbar-light navbar-bg-custom\" style=\"z-index: 9999;\"> 
  795   <button class=\"navbar-toggler custom-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#navbarSupportedContent\" aria-controls=\"navbarSupportedContent\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"> 
  796     <span class=\"navbar-toggler-icon\"></span> 
  799   <div class=\"collapse navbar-collapse\" id=\"navbarSupportedContent\">";
 
  803     <ul class=\"navbar-nav ".$navbar_center.
"\">";
 
  804                     foreach ($menu[
'parents'][
$parent] as $itemId) {
 
  807                         if (!empty($menu[
'items'][$itemId][
'icon'])){
 
  809                             $icon = 
"<i class=\"".$menu[
'items'][$itemId][
'icon'].
" text-muted\"></i> ";
 
  817                         if (!isset($menu[
'parents'][$itemId])) {
 
  819                             if (!isset($menu[
'items'][$itemId][
'title']) || (empty($menu[
'items'][$itemId][
'title']))) {
 
  822                                 $title = 
"title=\"" . $menu[
'items'][$itemId][
'title'] . 
"\"";
 
  825         <li class=\"nav-item\"> 
  826             <a class=\"nav-link\" href=\"".$menu[
'items'][$itemId][
'href'].
"\" target=\"".$menu[
'items'][$itemId][
'target'] . 
"\" $title>".$icon.
"  " . $menu[
'items'][$itemId][
'text'] . 
"</a> 
  834         <li class=\"nav-item dropdown\"> 
  835             <a class=\"nav-link dropdown-toggle\" href=\"" . $menu[
'items'][$itemId][
'href'] . 
"\" id=\"" . $menu[
'items'][$itemId][
'text'] . 
"\" role=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">".$icon.
"  " . $menu[
'items'][$itemId][
'text'] . 
"</a> 
  840                         if (isset($menu[
'parents'][$itemId])) {
 
  842               <div class=\"dropdown-menu\" aria-labelledby=\"navbarDropdown\">";
 
  845                             foreach ($menu[
'parents'][$itemId] as $child)
 
  848                                 if (!empty($menu[
'items'][$itemId][
'icon'])){
 
  850                                     $icon = 
"<i class=\"".$menu[
'items'][$child][
'icon'].
" text-muted\"></i> ";
 
  857                                 if (!isset($menu[
'items'][$itemId][
'title']) || (empty($menu[
'items'][$itemId][
'title'])))
 
  863                                     $title = 
"title=\"$menu[items][$itemId][title]\"";
 
  866                 <a class=\"dropdown-item\" href=\"" . $menu[
'items'][$child][
'href'].
"\" target=\"".$menu[
'items'][$itemId][
'target'].
"\" $title>".$icon.
"  ".$menu[
'items'][$child][
'text'].
"</a>";
 
  881                     if (isset($_SESSION[
'username']) && isset($_SESSION[
'logged_in'])){
 
  882                         if ($_SESSION[
'logged_in'] == 
true){
 
  889                     else {$html .= 
"</ul> 
  890                             <ul class=\"nav navbar-nav navbar-collapse navbar-right\"> 
  897                         $html .= 
"</li></ul>";
 
  902 ".$templateSwitchMarkup.
" 
  910                 else if ($bootstrapVersion == 
"3")
 
  914              <nav class=\"navbar navbar-default\" role=\"navigation\" id=\"topnavbar\"> 
  915              <!-- <nav class=\"navbar navbar-default\" role=\"navigation\" id=\"topnavbar\"> --> 
  916              <div class=\"container\"> 
  917              <div class=\"navbar-header\"> 
  918              <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\"> 
  919                 <span class=\"sr-only\">Toggle navigation</span> 
  920                 <span class=\"icon-bar\"></span> 
  921                 <span class=\"icon-bar\"></span> 
  922                 <span class=\"icon-bar\"></span> 
  925               </div> <!-- end nav header --> 
  926             <div id=\"navbar\" class=\"navbar-collapse collapse\">";
 
  927                     if (isset($menu[
'parents'][
$parent])) {
 
  929                         $html .= 
"<ul class=\"nav navbar-nav\">";
 
  931                         foreach ($menu[
'parents'][
$parent] as $itemId)
 
  934                             if (!isset($menu[
'parents'][$itemId])) {
 
  935                                 if (!isset($menu[
'items'][$itemId][
'title']) || (empty($menu[
'items'][$itemId][
'title'])))
 
  941                                     $title = 
"title=\"".$menu[
'items'][$itemId][
'title'].
"\"";
 
  943                                 $html .= 
"<li><a href=\"".$menu[
'items'][$itemId][
'href'].
"\" target=\"".$menu[
'items'][$itemId][
'target'].
"\" $title>" . $menu[
'items'][$itemId][
'text'] . 
"</a></li>";
 
  950                             if (isset($menu[
'parents'][$itemId])) {
 
  951                                 $html .= 
"<li class=\"dropdown\"> 
  952                             <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">" . $menu[
'items'][$itemId][
'text'] . 
" <b class=\"caret\"></b></a> 
  953                             <ul class=\"dropdown-menu\">";
 
  956                                 foreach ($menu[
'parents'][$itemId] as $child) {
 
  957                                     if (!isset($menu[
'items'][$itemId][
'title']) || (empty($menu[
'items'][$itemId][
'title'])))
 
  963                                         $title = 
"title=\"$menu[items][$itemId][title]\"";
 
  965                                     $html .= 
"<li><a href=\"" . $menu[
'items'][$child][
'href'].
"\" target=\"".$menu[
'items'][$itemId][
'target'].
"\" $title>".$menu[
'items'][$child][
'text'].
"</a></li>\n";
 
  974                         if (isset($_SESSION[
'username']) && isset($_SESSION[
'logged_in'])){
 
  975                             if ($_SESSION[
'logged_in'] == 
true){
 
  982                         else {$html .= 
"</ul> 
  983                             <ul class=\"nav navbar-nav navbar-collapse navbar-right\"> 
  990                             $html .= 
"</li></ul>";
 
  992                         $html .= 
"<!-- /.nav-collapse --> 
  993   </div><!-- /navbar-inn --> 
  994  </div> <!-- /container --> 
  995 </nav><!-- navbar --> 
 1003                     "Unable to load Bootstrap Menu";
 
 1008             echo buildMenu(
$db, 0, $menu, 
$id, $currentRole, $divider, $user, $template);
 
static getSetting($db, $property)
Get and return value for property from settings database.
static getCurrentTemplateId(object $db)
return ID of current (active) template
static returnCurrentBootstrapVersion($db, $templateID)
Return which Bootstrap version is currently loaded in given template.
static drawMenuLoginBox($username, $password, $style)
return the html for a menu login box
This class serves methods to create backup from files.
 
References $db, YAWK\menu\$id, $menuName, YAWK\menu\$parent, $res, $templateID, YAWK\menu\drawLogoutMenu(), YAWK\user\drawMenuLoginBox(), YAWK\template\getCurrentTemplateId(), YAWK\settings\getSetting(), and YAWK\template\returnCurrentBootstrapVersion().
Referenced by YAWK\menu\displayGlobalMenu().
 
 
  
  | 
        
          | static YAWK\menu::displayEditable | ( |  | $db, |  
          |  |  |  | $id, |  
          |  |  |  | $lang |  
          |  | ) |  |  |  | static | 
 
display menu entries for editing in backend 
- Parameters
- 
  
    | object | $db | database |  | int | $id | affected menuID |  | array | $lang | language array |  
 
UPDATE: OPTIMIZATION NEEDED HERE SHOULD BE A SELECT JOIN user_groups + parent items instead of 3 different SELECTs - can anybody help here?
- Parameters
- 
  
  
Definition at line 515 of file menu.php.
  522 <table class=\"table table-striped table-hover table-responsive\" id=\"table-sort\"> 
  525       <td><strong> </strong></td> 
  526       <td><strong>$lang[ID]</strong></td> 
  527       <td><strong>$lang[ICON] ".\YAWK\backend::printTooltip(
$lang[
'TT_MENU_ICON']).
"</strong></td> 
  535       <td><strong> </td> 
  540             if (
$res = 
$db->query(
"SELECT id, text, title, href, gid, target, sort, parentID, published, icon 
  542                              WHERE menuID = '".$id.
"' 
  543                              ORDER BY sort, parentID, title"))
 
  545                 while ($row = mysqli_fetch_assoc(
$res))
 
  548                     if ($row[
'published'] === 
'1') {
 
  551                         $pubtext = 
$lang[
'ON_'];
 
  555                         $pubtext = 
$lang[
'OFF_'];
 
  558                     if ($group_res = 
$db->query(
"SELECT id, value FROM {user_groups} ORDER BY id")){
 
  559                         $groupArray = array();
 
  561                         while ($group_row = $group_res->fetch_assoc()){
 
  562                             $groupArray[] = $group_row;
 
  564                         foreach ($groupArray AS $group){
 
  566                             <option value=\"$group[id]\">$group[value]</option>";
 
  570                     if (isset($row[
'gid'])){
 
  571                         $gid2name = 
$db->query(
"SELECT id, value FROM {user_groups} WHERE id = '".$row[
'gid'].
"'");
 
  572                         $groupName = mysqli_fetch_row($gid2name);
 
  577                     if($entries_res = 
$db->query(
"SELECT id, text, title, parentID FROM {menu} WHERE menuID = $id ORDER BY sort, parentID, title"))
 
  581                         $menuSelectAddon = 
'';
 
  582                         while ($entries_row = mysqli_fetch_assoc($entries_res))
 
  584                             if ($row[
'id'] !== $entries_row[
'id']){
 
  586                                     <option value=\"" . $entries_row[
'id'] . 
"\">" . $entries_row[
'text'] . 
"</option>";
 
  587                                 $menuSelectAddon = 
"<option value=\"0\">$lang[NO_PARENT]</option>";
 
  589                                 if ($row[
'parentID'] === 
'0')
 
  591                                     $menuSelected = 
"<option value=\"0\" selected>$lang[NO_PARENT]</option>";
 
  594                                     $parentID2name = 
$db->query(
"SELECT text FROM {menu} WHERE menuID = $id AND id=$row[parentID]");
 
  595                                     $parentName = mysqli_fetch_row($parentID2name);
 
  596                                     $menuSelected = 
"<option value=\"" . isset($row[
'parentID']) . 
"\" selected>" . isset($parentName[0]) . 
"</option>";
 
  605       <td><a href=\"index.php?page=menu-edit&toggleItem=1&menu=$id&id=$row[id]&published=$row[published]\"> 
  606           <span class=\"label label-$pub\">$pubtext</span></a></td> 
  608           <input type=\"text\" class=\"form-control pull-left\" name=\"" . $row[
'id'] . 
"_id\" readonly value=\"" . $row[
'id'] . 
"\" size=\"1\"> 
  611           <input type=\"text\" class=\"form-control pull-left icp icp-auto iconpicker-element iconpicker-input\" role=\"iconpicker\" name=\"" . $row[
'id'] . 
"_icon\" value=\"" . $row[
'icon'] . 
"\" size=\"2\"> 
  614           <input type=\"text\" class=\"form-control pull-left\" name=\"" . $row[
'id'] . 
"_text\" value=\"" . $row[
'text'] . 
"\" size=\"12\"> 
  617           <input type=\"text\" class=\"form-control pull-left\" name=\"" . $row[
'id'] . 
"_href\" value=\"" . $row[
'href'] . 
"\" size=\"45\"> 
  620           <input type=\"text\" class=\"form-control pull-left\" name=\"" . $row[
'id'] . 
"_title\" value=\"" . $row[
'title'] . 
"\" size=\"12\"> 
  624       <select class=\"form-control\" name=\"" . $row[
'id'] . 
"_gid\"> 
  625         <option value=\"$groupName[0]\">$groupName[1]</option> 
  631       <select class=\"form-control\" name=\"" . $row[
'id'] . 
"_target\"> 
  632       <option value=\"" . $row[
'target'] . 
"\" selected>" . $row[
'target'] . 
"</option> 
  633       <option value=\"_self\">$lang[SELF]</option> 
  634       <option value=\"_blank\">$lang[BLANK]</option> 
  635       <option value=\"_parent\">$lang[PARENT]</option> 
  636       <option value=\"_top\">$lang[TOP]</option> 
  641         <input type=\"text\" class=\"form-control pull-left\" name=\"" . $row[
'id'] . 
"_sort\" value=\"" . $row[
'sort'] . 
"\" size=\"1\" maxlength=\"3\"> 
  645       <select class=\"form-control\" name=\"" . $row[
'id'] . 
"_parentID\"> 
  653        <!-- <a href=\"index.php?page=menu-edit&menu=" . 
$id . 
"&entry=" . $row[
'id'] . 
"&deleteitem=1\"><i class=\"fa fa-trash-o\" alt=\"delete\"></i></a> --> 
  655        <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$lang[DELETE] $lang[ENTRY] « $row[text] / $row[href] » $lang[FOR_SURE]?\"  
  656         title=\"$lang[DELETE]\" href=\"index.php?page=menu-edit&menu=" . 
$id . 
"&entry=" . $row[
'id'] . 
"&del=1&deleteitem=1delete=true\"> 
  659         <input type=\"hidden\" name=\"" . $row[
'id'] .
"_published\" value=\"".$row[
'published'].
"\"> 
print $lang['FILEMAN_UPLOAD']
static printTooltip($toolTipText)
Draw a small question mark, enabling a tooltip on hover. toolTipText must be a string and will usuall...
 
References $db, YAWK\menu\$id, $lang, $res, and YAWK\backend\printTooltip().