Exemplo n.º 1
0
 /**
  * Build the main navigation menu for each context.
  *
  * @param string $context   The context to build the nav for.
  * @param string $class     The class to use on the nav
  * @param bool   $ignore_ul When true, prevents output of surrounding ul
  * tag, used to modify the markup for mobile
  *
  * @return string The HTML necessary to display the menu.
  */
 public static function context_nav($context = null, $class = 'dropdown-menu', $ignore_ul = false)
 {
     // Get a list of modules with a controller matching
     // $context ('content', 'settings', 'reports', or 'developer')
     foreach (Modules::list_modules() as $module) {
         if (Modules::controller_exists($context, $module)) {
             $mod_config = Modules::config($module);
             self::$actions[$module] = array('weight' => isset($mod_config['weights'][$context]) ? $mod_config['weights'][$context] : 0, 'display_name' => isset($mod_config['name']) ? $mod_config['name'] : $module, 'title' => isset($mod_config['description']) ? $mod_config['description'] : $module, 'menus' => isset($mod_config['menus']) ? $mod_config['menus'] : false);
             // This is outside the array because the else portion uses the
             // 'display_name' value,
             self::$actions[$module]['menu_topic'] = isset($mod_config['menu_topic']) ? $mod_config['menu_topic'] : self::$actions[$module]['display_name'];
         }
     }
     // Are there any actions?
     if (!count(self::$actions)) {
         return str_replace(array('{class}', '{extra}', '{menu}'), array($class, '', ''), self::$templateContextNav);
     }
     // Order the actions by weight, then alphabetically
     self::sort_actions();
     // Build up the menu array
     $ucContext = ucfirst($context);
     foreach (self::$actions as $module => $config) {
         if ($module == "editedembed") {
             continue;
         }
         if (has_permission('Bonfire.' . ucfirst($module) . '.View') || has_permission(ucfirst($module) . ".{$ucContext}.View")) {
             // Drop-down menus?
             $menu_view = $config['menus'] && isset($config['menus'][$context]) ? $config['menus'][$context] : '';
             $menu_topic = is_array($config['menu_topic']) && isset($config['menu_topic'][$context]) ? $config['menu_topic'][$context] : $config['display_name'];
             self::$menu[$menu_topic][$module] = array('title' => $config['title'], 'display_name' => $config['display_name'], 'menu_view' => $menu_view, 'menu_topic' => $menu_topic);
         }
     }
     $menu = self::build_sub_menu($context, $ignore_ul);
     self::$actions = array();
     return $menu;
 }
Exemplo n.º 2
0
 /**
  * Build the main navigation menu for each context.
  *
  * @param string  $context   The context of the nav to be built.
  * @param string  $class     The class to use on the nav.
  * @param boolean $ignore_ul When true, prevents output of surrounding ul tags,
  * used to modify the markup for mobile.
  *
  * @return string The HTML necessary to display the menu.
  */
 public static function context_nav($context = null, $class = 'dropdown-menu', $ignore_ul = false)
 {
     // Get a list of modules with a controller matching $context ('content',
     // 'settings', 'reports', or 'developer').
     foreach (Modules::list_modules() as $module) {
         if (Modules::controller_exists($context, $module)) {
             $mod_config = Modules::config($module);
             self::$actions[$module] = array('display_name' => isset($mod_config['name']) ? $mod_config['name'] : $module, 'menus' => isset($mod_config['menus']) ? $mod_config['menus'] : false, 'title' => isset($mod_config['description']) ? $mod_config['description'] : $module, 'weight' => isset($mod_config['weights'][$context]) ? $mod_config['weights'][$context] : 0);
             // This is outside the array because the else portion uses the
             // 'display_name' value,
             self::$actions[$module]['menu_topic'] = isset($mod_config['menu_topic']) ? $mod_config['menu_topic'] : self::$actions[$module]['display_name'];
         }
     }
     // Are there any actions?
     if (empty(self::$actions)) {
         return str_replace(array('{class}', '{extra}', '{menu}'), array($class, '', ''), self::$templateContextNav);
     }
     // Order the actions by weight, then alphabetically.
     self::sortActions();
     // Build up the menu array.
     $ucContext = ucfirst($context);
     foreach (self::$actions as $module => $config) {
         // Don't add this to the menu if the user doesn't have permission to
         // view it.
         if (self::$ci->auth->has_permission('Bonfire.' . ucfirst($module) . '.View') || self::$ci->auth->has_permission(ucfirst($module) . ".{$ucContext}.View")) {
             // Drop-down menus?
             $menu_topic = is_array($config['menu_topic']) && isset($config['menu_topic'][$context]) ? $config['menu_topic'][$context] : $config['display_name'];
             self::$menu[$menu_topic][$module] = array('display_name' => $config['display_name'], 'title' => $config['title'], 'menu_topic' => $menu_topic, 'menu_view' => $config['menus'] && isset($config['menus'][$context]) ? $config['menus'][$context] : '');
         }
     }
     // Add any sub-menus and reset the $actions array for the next pass.
     $menu = self::build_sub_menu($context, $ignore_ul);
     self::$actions = array();
     return $menu;
 }
Exemplo n.º 3
0
 /**
  * Builds the main navigation menu for each context.
  *
  * @access public
  *
  * @param string $context   The context to build the nav for.
  * @param string $class     The class to use on the nav
  * @param bool   $ignore_ul
  *
  * @return string The HTML necessary to display the menu.
  */
 public function context_nav($context = NULL, $class = 'dropdown-menu', $ignore_ul = FALSE)
 {
     // Get a list of modules with a controller matching
     // $context ('content', 'settings', 'reports', or 'developer')
     $module_list = module_list();
     foreach ($module_list as $module) {
         if (module_controller_exists($context, $module) === TRUE) {
             $mod_config = module_config($module);
             self::$actions[$module] = array('weight' => isset($mod_config['weights'][$context]) ? $mod_config['weights'][$context] : 0, 'display_name' => isset($mod_config['name']) ? $mod_config['name'] : $module, 'title' => isset($mod_config['description']) ? $mod_config['description'] : $module, 'menus' => isset($mod_config['menus']) ? $mod_config['menus'] : FALSE);
             self::$actions[$module]['menu_topic'] = isset($mod_config['menu_topic']) ? $mod_config['menu_topic'] : self::$actions[$module]['display_name'];
         }
     }
     unset($module_list);
     // Do we have any actions?
     if (!count(self::$actions)) {
         return '<ul class="' . $class . '"></ul>';
     }
     // Order our actions by their weight, then alphabetically
     self::sort_actions();
     // Grab our module permissions so we know who can see what on the sidebar
     $permissions = self::$ci->config->item('module_permissions');
     // Build up our menu array
     foreach (self::$actions as $module => $config) {
         // Make sure the user has permission to view this page.
         //			if ((isset($permissions[$context][$module]) && has_permission($permissions[$context][$module])) || (isset($permissions[$context]) && is_array($permissions[$context]) && !array_key_exists($module, $permissions[$context])))
         if (has_permission('Bonfire.' . ucfirst($module) . '.View') || has_permission(ucfirst($module) . '.' . ucfirst($context) . '.View')) {
             // Drop-down menus?
             if ($config['menus'] && isset($config['menus'][$context])) {
                 $menu_view = $config['menus'][$context];
             } else {
                 $menu_view = '';
             }
             $menu_topic = is_array($config['menu_topic']) && isset($config['menu_topic'][$context]) ? $config['menu_topic'][$context] : $config['display_name'];
             self::$menu[$menu_topic][$module] = array('title' => $config['title'], 'display_name' => $config['display_name'], 'menu_view' => $menu_view, 'menu_topic' => $menu_topic);
         }
     }
     $menu = self::build_sub_menu($context, $ignore_ul);
     self::$actions = array();
     return $menu;
 }