示例#1
0
 /**
  * Initialize navigation system
  *
  * @param array $sitemap
  */
 public static function init(array $sitemap)
 {
     foreach ($sitemap as $section) {
         // Invalid
         if (!isset($section['name'])) {
             continue;
         }
         // Add page
         if (isset($section['url']) && !isset($section['top'])) {
             //var_dump($section);
             $page = Navigation_Page::factory($section);
             $section_object = Navigation::get_root_section();
             $section_object->add_page($page);
         } else {
             $section_object = Navigation::get_section($section['name'], null, isset($section['priority']) ? $section['priority'] : 1);
             // URL
             if (isset($section['url'])) {
                 $section_object->url = $section['url'];
             }
             // Icon
             if (isset($section['icon'])) {
                 $section_object->icon = $section['icon'];
             }
             // Buttons
             if (isset($section['buttons'])) {
                 $section_object->add_buttons($section['buttons']);
             }
             // Priority
             if (isset($section['priority'])) {
                 $section_object->priority = (int) $section['priority'];
             }
             if (!empty($section['children'])) {
                 $section_object->add_pages($section['children']);
             }
         }
     }
 }
示例#2
0
文件: Section.php 项目: NegoCore/core
 /**
  * Add multiple pages to section
  *
  * @param array $pages
  */
 public function add_pages(array $pages)
 {
     foreach ($pages as $page) {
         if (isset($page['children'])) {
             $section = Navigation::get_section($page['name'], $this);
             if (isset($page['icon'])) {
                 $section->icon = $page['icon'];
             }
             // Buttons
             if (isset($section['buttons'])) {
                 $section->add_buttons($section['buttons']);
             }
             // Hijos
             if (count($page['children']) > 0) {
                 $section->add_pages($page['children']);
             }
         } else {
             $page = Navigation_Page::factory($page);
             $this->add_page($page);
         }
     }
 }
示例#3
0
 /**
  * Add buttons to page.
  *
  * @param array $buttons
  */
 public function add_buttons(array $buttons)
 {
     foreach ($buttons as $uri => $_buttons) {
         foreach ($_buttons as $button) {
             $this->_buttons[trim($uri, '/')][] = Navigation_Page::factory($button);
         }
     }
 }