Exemplo n.º 1
0
 /**
  * Build out the HTML for the menu.
  *
  * @param string $context   The context to build the nav for.
  * @param bool   $ignore_ul
  *
  * @return string HTML for the sub menu
  */
 public static function build_sub_menu($context, $ignore_ul = false)
 {
     $list = '';
     $childClass = self::$child_class;
     $search = array('{submenu_class}', '{url}', '{display}', '{child_class}', '{view}');
     foreach (self::$menu as $topic_name => $topic) {
         // If there is more than one item in the topic, we need to build out
         // a menu based on the multiple items.
         if (count($topic) > 1) {
             $subMenu = '';
             foreach ($topic as $module => $vals) {
                 // If it has no sub-menu, add it like normal
                 if (empty($vals['menu_view'])) {
                     $subMenu .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
                 } else {
                     $view = self::$ci->load->view($vals['menu_view'], null, true);
                     // To maintain backwards compatility, strip out any <ul> tags
                     $subMenu .= str_ireplace(array('<ul>', '</ul>'), array('', ''), $view);
                 }
             }
             // Handle localization of the topic name, if needed.
             if (strpos($topic_name, 'lang:') === 0) {
                 $topic_name = lang(str_replace('lang:', '', $topic_name));
             }
             $replace = array(self::$submenu_class, '#', ucwords($topic_name), $childClass, $subMenu);
             $list .= str_replace($search, $replace, self::$templateSubMenu);
         } else {
             foreach ($topic as $module => $vals) {
                 $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
             }
         }
     }
     self::$menu = array();
     if ($ignore_ul) {
         return $list;
     }
     return str_replace(array('{class}', '{extra}', '{menu}'), array($childClass, '', $list), self::$templateContextNav);
 }
Exemplo n.º 2
0
 /**
  * Build out the HTML for the menu.
  *
  * @param string  $context   The context to build the nav for.
  * @param boolean $ignore_ul If true, the list will be returned without being
  * placed into the template.
  *
  * @return string HTML for the sub menu.
  */
 public static function build_sub_menu($context, $ignore_ul = false)
 {
     $search = array('{submenu_class}', '{url}', '{display}', '{child_class}', '{view}');
     $list = '';
     foreach (self::$menu as $topic_name => $topic) {
         if (count($topic) <= 1) {
             foreach ($topic as $module => $vals) {
                 $list .= self::buildItem($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
             }
         } else {
             // If there is more than one item in the topic, build out a menu
             // based on the multiple items.
             $subMenu = '';
             foreach ($topic as $module => $vals) {
                 if (empty($vals['menu_view'])) {
                     // If it has no sub-menu, add the item.
                     $subMenu .= self::buildItem($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
                 } else {
                     // Otherwise, echo out the sub-menu only. To maintain backwards
                     // compatility, strip out any <ul> tags.
                     $subMenu .= str_ireplace(array('<ul>', '</ul>'), array('', ''), self::$ci->load->view($vals['menu_view'], null, true));
                 }
             }
             // Handle localization of the topic name, if needed.
             if (strpos($topic_name, 'lang:') === 0) {
                 $topic_name = self::$ci->lang->line(str_replace('lang:', '', $topic_name));
             }
             $list .= str_replace($search, array(self::$submenu_class, '#', ucwords($topic_name), self::$child_class, $subMenu), self::$templateSubMenu);
         }
     }
     self::$menu = array();
     if ($ignore_ul) {
         return $list;
     }
     return str_replace(array('{class}', '{extra}', '{menu}'), array(self::$child_class, '', $list), self::$templateContextNav);
 }
Exemplo n.º 3
0
 /**
  * Handles building out the HTML for the menu.
  *
  * @access public
  * @static
  *
  * @param string $context   The context to build the nav for.
  * @param bool   $ignore_ul
  *
  * @return string HTML for the sub menu
  */
 public static function build_sub_menu($context, $ignore_ul = FALSE)
 {
     $list = '';
     // Build a ul to return
     if (!$ignore_ul) {
         $list = "<ul class='" . self::$child_class . "'>\n";
     }
     foreach (self::$menu as $topic_name => $topic) {
         // If the topic has other items, we're not closed.
         $closed = TRUE;
         // If there is more than one item in the topic, we need to build
         // out a menu based on the multiple items.
         if (count($topic) > 1) {
             $list .= '<li class="no-link parent-menu"><a href="#" class="no-link parent-menu">' . ucwords($topic_name) . '</a>';
             $list .= '<ul>';
             foreach ($topic as $module => $vals) {
                 $class = $module == self::$ci->uri->segment(3) ? ' class="active"' : '';
                 // If it has a sub-menu, echo out that menu only…
                 if (isset($vals['menu_view']) && !empty($vals['menu_view'])) {
                     $view = self::$ci->load->view($vals['menu_view'], NULL, TRUE);
                     // To maintain backwards compatility, strip out and <ul> tags
                     $view = str_ireplace('<ul>', '', $view);
                     $view = str_ireplace('</ul>', '', $view);
                     $list .= $view;
                 } else {
                     $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
                 }
             }
             $list .= '</ul></li>';
         } else {
             foreach ($topic as $module => $vals) {
                 $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']);
             }
         }
         //end if
     }
     //end foreach
     if (!$ignore_ul) {
         $list .= "</ul>\n";
     }
     self::$menu = array();
     return $list;
 }