public function render(Menu $menu)
 {
     $html = '<ul class="nav navbar-nav">';
     foreach ($menu->getChildren() as $menu_elem) {
         $html .= $this->renderElem($menu_elem);
     }
     $html .= '</ul>';
     return $html;
 }
 public function serialize(Menu $menu)
 {
     $doc_xml = new DOMDocument('1.0', 'UTF-8');
     $menu_xml = $doc_xml->createElement('menu');
     $doc_xml->appendChild($menu_xml);
     foreach ($menu->getChildren() as $id => $menu_elem) {
         $this->serializeElem($doc_xml, $menu_xml, $id, $menu_elem);
     }
     $doc_xml->preserveWhiteSpace = false;
     $doc_xml->formatOutput = true;
     return $doc_xml->saveXML();
 }
Пример #3
0
<?php

include "../../includes/inc.main.php";
if ($_GET['id']) {
    $MenuID = $_GET['id'];
    $Switcher = new Menu($MenuID);
    $Children = $Switcher->getChildren();
    if (count($Children) < 1) {
        if ($Switcher->MenuData['link'] != "#" && $Switcher->MenuData['link']) {
            header("Location: " . $Switcher->MenuData['link']);
            die;
        }
    }
} else {
    header("Location: ../main/main.php");
    die;
}
$Head->setTitle($Switcher->GetTitle());
$Head->setHead();
include '../../includes/inc.top.php';
?>

  <div class="box box-success">
    <div class="box-body">
      <?php 
foreach ($Children as $Child) {
    ?>
        <div class="col-md-4 col-sm-6">
          <a href="<?php 
    echo $Child['link'];
    ?>
Пример #4
0
 function getNavAsList($page_id = false, $treat_title = false, $title_recurse = true)
 {
     $menu = new Menu();
     if ($page_id == false) {
         $page_id = $menu->getRootNode();
     }
     if (CURRENT_SITE == 'admin') {
         $checkactive = false;
         $checkvisible = false;
     } else {
         $checkactive = true;
         $checkvisible = true;
     }
     $main_nav = $menu->getChildren($page_id, $checkactive, $checkvisible);
     $html = '';
     foreach ($main_nav as $nav) {
         $html .= "<div>";
         if (isset($GLOBALS['page_id']) && $GLOBALS['page_id'] == $nav['id']) {
             $html .= '<b>';
         }
         $html .= Menu::getLink($nav, $treat_title);
         if (isset($GLOBALS['page_id']) && $GLOBALS['page_id'] == $nav['id']) {
             $html .= '</b>';
         }
         $html .= "</div>\n";
         if ($menu->isBranch($nav['id'], $checkactive, $checkactive)) {
             $sub_treat_title = $title_recurse == true ? $treat_title : false;
             $html .= Menu::getChildList($menu, $nav['id'], $sub_treat_title);
         }
     }
     return $html;
 }