Пример #1
0
 /**
  * Replace a navigation item to the main administration menu showing in the top bar.
  *
  * @param string $code Unique identifier for this menu item (e.g. used by {@link replace_menu_item()} and
  * 					{@link remove_menu_item}. Also used as a CSS-class for icon customization.
  * @param string $menuTitle Localized title showing in the menu bar 
  * @param string $url A relative URL that will be linked in the menu bar.
  * 					Make sure to add a matching route via {@link Director::addRules()} to this url.
  * @param string $controllerClass The controller class for this menu, used to check permisssions.  
  * 					If blank, it's assumed that this is public, and always shown to users who 
  * 					have the rights to access some other part of the admin area.
  * @return boolean Success
  */
 public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1)
 {
     $menuItems = self::$menu_items;
     $menuItems[$code] = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority);
     $menuPriority = array();
     $i = 0;
     foreach ($menuItems as $key => $menuItem) {
         $i++;
         // This funny litle formula ensures that the first item added with the same priority will be left-most.
         $menuPriority[$key] = $menuItem->priority * 100 - $i;
     }
     array_multisort($menuPriority, SORT_DESC, $menuItems);
     self::$menu_items = $menuItems;
     return true;
 }