示例#1
0
 public function index($context = null)
 {
     // Get a list of modules with a controller matching
     // $context ('content', 'appearance', 'settings', 'statistics', or 'developer')
     foreach (module_list() as $module) {
         if (module_controller_exists($context, $module)) {
             $this->actions[] = $module;
         }
     }
     // Do we have any actions?
     if (!count($this->actions)) {
         return '<ul class="nav-sub clearfix"></ul>';
     }
     // Grab our module permissions so we know who can see what on the sidebar
     $permissions = config_item('module_permissions');
     // Build up our menu array
     foreach ($this->actions as $module) {
         // Make sure the user has permission to view this page.
         if (isset($permissions[$context][$module]) && has_permission($permissions[$context][$module]) || !array_key_exists($module, $permissions[$context])) {
             // Grab our module config array, if any.
             $mod_config = module_config($module);
             $display_name = isset($mod_config['name']) ? $mod_config['name'] : $module;
             $title = isset($mod_config['description']) ? $mod_config['description'] : $module;
             $menu_topic = isset($mod_config['menu_topic'][$context]) ? $mod_config['menu_topic'][$context] : $display_name;
             // Drop-down menus?
             if (isset($mod_config['menus']) && isset($mod_config['menus'][$context])) {
                 $menu_view = $mod_config['menus'][$context];
             } else {
                 $menu_view = '';
             }
             $this->menu[$menu_topic][$module] = array('title' => $title, 'display_name' => $display_name, 'menu_view' => $menu_view, 'menu_topic' => $menu_topic);
         }
     }
     return $this->build_menu($context);
 }
示例#2
0
	public function index($type=null) 
	{	
		// Get a list of modules with a controller matching
		// $type ('content', 'appearance', 'settings', 'statistics', or 'developer')
		foreach (module_list() as $module)
		{
			if (module_controller_exists($type, $module))
			{
				$this->actions[] = $module;
			}
		}
		
		// Do we have any actions? 
		if (!count($this->actions))
		{
			return '<ul class="nav-sub clearfix"></ul>';
		}
		
		// Grab our module permissions so we know who can see what on the sidebar
		$permissions = config_item('module_permissions');
		
		// Build a ul to return
		$list = "<ul class='nav-sub clearfix'>\n";
		
		foreach ($this->actions as $module)
		{
			// Make sure the user has permission to view this page.
			if ((isset($permissions[$type][$module]) && has_permission($permissions[$type][$module])) || !array_key_exists($module, $permissions[$type]))
			{
				// Is this the current module? 
				if ($module == $this->uri->segment(3))
				{
					$class = 'class="current"';
				}
				else
				{
					$class = '';
				}
				
				// Build our list item.
				$list .= '<li><a href="'. site_url('admin/'. $type .'/'. $module) .'" '. $class;
				// Icon
				/*
				if ($icon = module_icon($module))
				{
					$list .= ' style="background: url('. $icon .')"';
				}
				*/
				$list .= '>'. ucwords(str_replace('_', '', $module)) ."</a></li>\n";
			}
		}
		
		$list .= "</ul>\n";
		
		return $list;
	}
示例#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;
 }