Exemplo n.º 1
0
 function Render($ret = FALSE)
 {
     if (function_exists("Menu_Rendering") && $this->IsRoot) {
         Menu_Rendering($this);
     }
     if (!$this->RenderMenu()) {
         return;
     }
     if (!$this->IsMobile) {
         if ($this->IsRoot) {
             $str = "<ul";
             if ($this->Id != "") {
                 if (is_numeric($this->Id)) {
                     $str .= " id=\"menu_" . $this->Id . "\"";
                 } else {
                     $str .= " id=\"" . $this->Id . "\"";
                 }
             }
             $str .= " class=\"" . EW_MENU_CLASSNAME . "\">\n";
         } else {
             $str = "<ul class=\"" . EW_SUBMENU_CLASSNAME . "\">\n";
         }
     } else {
         $str = "";
     }
     $gcnt = 0;
     // Group count
     $gtitle = FALSE;
     // Last item is group title
     $i = 0;
     // Menu item count
     $cururl = substr(ew_CurrentUrl(), strrpos(ew_CurrentUrl(), "/") + 1);
     foreach ($this->ItemData as $item) {
         if ($this->RenderItem($item)) {
             $i++;
             if (!$this->IsMobile && $gtitle && ($gcnt >= 1 || $this->IsRoot)) {
                 // add divider for previous group
                 $str .= "<li class=\"" . EW_MENU_DIVIDER_CLASSNAME . "\"></li>\n";
             }
             if ($item->GroupTitle && (!$this->IsRoot || !EW_MENU_ROOT_GROUP_TITLE_AS_SUBMENU)) {
                 // Group title
                 $gtitle = TRUE;
                 $gcnt += 1;
                 if (strval($item->Text) != "") {
                     if ($this->IsMobile) {
                         $str .= "<li data-role=\"list-divider\">" . $item->Text . "</li>\n";
                     } else {
                         $str .= "<li class=\"dropdown-header\">" . $item->Text . "</li>\n";
                     }
                 }
                 if (!is_null($item->SubMenu)) {
                     foreach ($item->SubMenu->ItemData as $subitem) {
                         $liclass = !is_null($subitem->SubMenu) ? EW_SUBMENU_ITEM_CLASSNAME : "";
                         $aclass = "";
                         if (!$subitem->IsCustomUrl && ew_CurrentPage() == ew_GetPageName($subitem->Url) || $subitem->IsCustomUrl && $cururl == $subitem->Url) {
                             ew_AppendClass($liclass, EW_MENU_ACTIVE_ITEM_CLASS);
                         }
                         if ($this->RenderItem($subitem)) {
                             if ($this->IsMobile && $item->GroupTitle) {
                                 ew_AppendClass($aclass, "ewIndent");
                             }
                             $str .= $subitem->Render($aclass, $liclass, $this->IsMobile) . "\n";
                             // Create <LI>
                         }
                     }
                 }
             } else {
                 $gtitle = FALSE;
                 $liclass = !is_null($item->SubMenu) ? $this->IsRoot ? EW_MENU_ITEM_CLASSNAME : EW_SUBMENU_ITEM_CLASSNAME : "";
                 $aclass = "";
                 if (!$item->IsCustomUrl && ew_CurrentPage() == ew_GetPageName($item->Url) || $item->IsCustomUrl && $cururl == $item->Url) {
                     if ($this->IsRoot) {
                         ew_AppendClass($liclass, EW_MENU_ACTIVE_ITEM_CLASS);
                     } else {
                         ew_AppendClass($liclass, EW_SUBMENU_ACTIVE_ITEM_CLASS);
                     }
                 }
                 $str .= $item->Render($aclass, $liclass, $this->IsMobile) . "\n";
                 // Create <LI>
             }
         }
     }
     if ($this->IsMobile) {
         $str = "<ul data-role=\"listview\" data-filter=\"true\">" . $str . "</ul>\n";
     } elseif ($this->IsRoot) {
         $str .= "</ul>\n";
         if (EW_MENUBAR_BRAND != "") {
             $brandhref = EW_MENUBAR_BRAND_HYPERLINK == "" ? "#" : EW_MENUBAR_BRAND_HYPERLINK;
             $str = "<a class=\"brand\" href=\"" . ew_HtmlEncode($brandhref) . "\">" . EW_MENUBAR_BRAND . "</a>" . $str;
         }
         if (EW_MENUBAR_CLASSNAME != "" && EW_MENUBAR_INNER_CLASSNAME != "") {
             $str = "<div class=\"" . EW_MENUBAR_CLASSNAME . "\"><div class=\"" . EW_MENUBAR_INNER_CLASSNAME . "\">" . $str . "</div></div>";
         }
     } else {
         $str .= "</ul>\n";
     }
     if ($ret) {
         // Return as string
         return $str;
     }
     echo $str;
     // Output
 }
Exemplo n.º 2
0
 function Render($ret = FALSE)
 {
     if (function_exists("Menu_Rendering") && $this->IsRoot) {
         Menu_Rendering($this);
     }
     if (!$this->RenderMenu()) {
         return;
     }
     if (!$this->IsMobile) {
         if ($this->IsRoot) {
             $str = "<ul";
             if ($this->Id != "") {
                 if (is_numeric($this->Id)) {
                     $str .= " id=\"menu_" . $this->Id . "\"";
                 } else {
                     $str .= " id=\"" . $this->Id . "\"";
                 }
             }
             $str .= " class=\"" . $this->MenuClassName . "\">\n";
         } else {
             $str = "<ul class=\"" . $this->SubMenuClassName . "\" role=\"menu\">\n";
         }
     } else {
         $str = "";
     }
     $gcnt = 0;
     // Group count
     $gtitle = FALSE;
     // Last item is group title
     $i = 0;
     // Menu item count
     $cururl = substr(ew_CurrentUrl(), strrpos(ew_CurrentUrl(), "/") + 1);
     foreach ($this->ItemData as $item) {
         if ($this->RenderItem($item)) {
             $i++;
             if (!$this->IsMobile && $gtitle && ($gcnt >= 1 || $this->IsRoot)) {
                 // add divider for previous group
                 $str .= "<li class=\"" . $this->MenuDividerClassName . "\"></li>\n";
             }
             if ($item->GroupTitle && (!$this->IsRoot || !$this->MenuRootGroupTitleAsSubMenu)) {
                 // Group title
                 $gtitle = TRUE;
                 $gcnt += 1;
                 if (strval($item->Text) != "") {
                     if ($this->IsMobile) {
                         $str .= "<li data-role=\"list-divider\">" . $item->Text . "</li>\n";
                     } else {
                         $str .= "<li class=\"dropdown-header\">" . $item->Text . "</li>\n";
                     }
                 }
                 if (!is_null($item->SubMenu)) {
                     foreach ($item->SubMenu->ItemData as $subitem) {
                         $liclass = !is_null($subitem->SubMenu) && $this->RenderSubMenu($subitem) ? $this->SubMenuItemClassName : "";
                         $aclass = "";
                         if (!$subitem->IsCustomUrl && ew_CurrentPage() == ew_GetPageName($subitem->Url) || $subitem->IsCustomUrl && $cururl == $subitem->Url) {
                             ew_AppendClass($liclass, $this->MenuActiveItemClassName);
                             $subitem->Url = "javascript:void(0);";
                         }
                         if ($this->RenderItem($subitem)) {
                             if ($this->IsMobile && $item->GroupTitle) {
                                 ew_AppendClass($aclass, "ewIndent");
                             }
                             $str .= $subitem->Render($aclass, $liclass, $this->IsMobile) . "\n";
                             // Create <LI>
                         }
                     }
                 }
             } else {
                 $gtitle = FALSE;
                 $liclass = !is_null($item->SubMenu) && $this->RenderSubMenu($item) ? $this->IsRoot ? $this->MenuItemClassName : $this->SubMenuItemClassName : "";
                 $aclass = "";
                 if (!$item->IsCustomUrl && ew_CurrentPage() == ew_GetPageName($item->Url) || $item->IsCustomUrl && $cururl == $item->Url) {
                     if ($this->IsRoot) {
                         ew_AppendClass($liclass, $this->MenuActiveItemClassName);
                     } else {
                         ew_AppendClass($liclass, $this->SubMenuActiveItemClassName);
                     }
                     $item->Url = "javascript:void(0);";
                 }
                 $str .= $item->Render($aclass, $liclass, $this->IsMobile) . "\n";
                 // Create <LI>
             }
         }
     }
     if ($this->IsMobile) {
         $str = "<ul data-role=\"listview\" data-filter=\"true\">" . $str . "</ul>\n";
     } elseif ($this->IsRoot) {
         $str .= "</ul>\n";
         if (EW_MENUBAR_BRAND != "") {
             $brandhref = EW_MENUBAR_BRAND_HYPERLINK == "" ? "#" : EW_MENUBAR_BRAND_HYPERLINK;
             $str = "<a class=\"navbar-brand hidden-xs\" href=\"" . ew_HtmlEncode($brandhref) . "\">" . EW_MENUBAR_BRAND . "</a>" . $str;
         }
         // Add right menu
         if ($this->ShowRightMenu) {
             $str .= "<ul class=\"nav navbar-nav navbar-right\"></ul>";
         }
         if ($this->MenuBarClassName != "") {
             $str = "<div class=\"" . $this->MenuBarClassName . "\">" . $str . "</div>";
         }
     } else {
         $str .= "</ul>\n";
     }
     if ($ret) {
         // Return as string
         return $str;
     }
     echo $str;
     // Output
 }
Exemplo n.º 3
0
 function Render($ret = FALSE)
 {
     if (function_exists("Menu_Rendering") && $this->IsRoot) {
         Menu_Rendering($this);
     }
     if (!$this->RenderMenu()) {
         return;
     }
     if (!$this->IsMobile) {
         $str = "<div";
         if ($this->Id != "") {
             if (is_numeric($this->Id)) {
                 $str .= " id=\"menu_" . $this->Id . "\"";
             } else {
                 $str .= " id=\"" . $this->Id . "\"";
             }
         }
         $str .= " class=\"" . ($this->IsRoot ? EW_MENUBAR_CLASSNAME : EW_MENU_CLASSNAME) . "\">";
         $str .= "<div class=\"bd" . ($this->IsRoot ? " first-of-type" : "") . "\">\n";
     } else {
         $str = "";
     }
     $gopen = FALSE;
     // Group open status
     $gcnt = 0;
     // Group count
     $i = 0;
     // Menu item count
     $classfot = " class=\"first-of-type\"";
     foreach ($this->ItemData as $item) {
         if ($this->RenderItem($item)) {
             $i++;
             // Begin a group
             if ($i == 1 && !$item->GroupTitle) {
                 $gcnt++;
                 if (!$this->IsMobile) {
                     $str .= "<ul " . $classfot . ">\n";
                 }
                 $gopen = TRUE;
             }
             $aclass = $this->IsRoot ? EW_MENUBAR_ITEM_LABEL_CLASSNAME : EW_MENU_ITEM_LABEL_CLASSNAME;
             $liclass = $this->IsRoot ? EW_MENUBAR_ITEM_CLASSNAME : EW_MENU_ITEM_CLASSNAME;
             if ($item->GroupTitle && EW_MENU_ITEM_CLASSNAME != "") {
                 // Group title
                 $gcnt++;
                 if ($i > 1 && $gopen) {
                     if (!$this->IsMobile) {
                         $str .= "</ul>\n";
                     }
                     // End last group
                     $gopen = FALSE;
                 }
                 // Begin a new group with title
                 if (strval($item->Text) != "") {
                     if ($this->IsMobile) {
                         $str .= "<li data-role=\"list-divider\">" . $item->Text . "</li>\n";
                     } else {
                         $str .= "<h6" . ($gcnt == 1 ? $classfot : "") . ">" . $item->Text . "</h6>\n";
                     }
                 }
                 if (!$this->IsMobile) {
                     $str .= "<ul" . ($gcnt == 1 ? $classfot : "") . ">\n";
                 }
                 $gopen = TRUE;
                 if (!is_null($item->SubMenu)) {
                     foreach ($item->SubMenu->ItemData as $subitem) {
                         if ($this->RenderItem($subitem)) {
                             $str .= $subitem->Render($aclass, $liclass, $this->IsMobile) . "\n";
                         }
                         // Create <LI>
                     }
                 }
                 if (!$this->IsMobile) {
                     $str .= "</ul>\n";
                 }
                 // End the group
                 $gopen = FALSE;
             } else {
                 // Menu item
                 if (!$gopen) {
                     // Begin a group if no opened group
                     $gcnt++;
                     if (!$this->IsMobile) {
                         $str .= "<ul" . ($gcnt == 1 ? $classfot : "") . ">\n";
                     }
                     $gopen = TRUE;
                 }
                 if ($this->IsRoot && $i == 1) {
                     // For horizontal menu
                     $liclass .= " first-of-type";
                 }
                 $str .= $item->Render($aclass, $liclass, $this->IsMobile) . "\n";
                 // Create <LI>
             }
         }
     }
     if ($gopen) {
         if (!$this->IsMobile) {
             $str .= "</ul>\n";
         }
     }
     // End last group
     if ($this->IsMobile) {
         $str = "<ul data-role=\"listview\" data-filter=\"true\" class=\"first-of-type\">" . $str . "</ul>\n";
     } else {
         $str .= "</div></div>\n";
     }
     if ($ret) {
         // Return as string
         return $str;
     }
     echo $str;
     // Output
 }