/** * Construct the taskbar * @return null */ public function __construct() { $translator = I18n::getInstance()->getTranslator(); $this->applicationsMenu = new Menu($translator->translate(self::TRANSLATION_APPLICATIONS)); $this->applicationsMenu->setId(self::APPLICATIONS_STYLE_ID); $this->applicationsMenu->setClass(self::APPLICATIONS_STYLE_CLASS); $this->settingsMenu = new Menu($translator->translate(self::TRANSLATION_SETTINGS)); $this->notificationPanels = array(); }
/** * Creates a menu from an array of actions * @param string $label Label for the menu * @param array $actions Array with the action label as key and the action path or another action array as value * @return zibo\admin\view\taskbar\Menu; */ private function createMenuFromActions($label, array $actions) { $menu = new Menu($label); foreach ($actions as $label => $action) { if (is_array($action)) { $actionMenu = $this->createMenuFromActions($label, $action); $menu->addMenu($actionMenu); } else { $menu->addMenuItem(new MenuItem($label, $action)); } } return $menu; }
/** * Add the orm menu to the taskbar * @param zibo\admin\view\taskbar\Taskbar $taskbar * @return null */ public function prepareTaskbar(Taskbar $taskbar) { $translator = I18n::getInstance()->getTranslator(); $ormMenu = new Menu($translator->translate('orm.title')); $ormMenu->addMenuItem(new MenuItem($translator->translate('orm.title.models'), self::ROUTE_ADMIN)); $ormMenu->addMenuItem(new MenuItem($translator->translate('orm.title.log'), self::ROUTE_LOG)); $settingsMenu = $taskbar->getSettingsMenu(); $settingsMenu->addMenu($ormMenu); }
/** * Prepares the taskbar and adds it to the view * @return null */ protected function addTaskbar() { $securityModel = SecurityManager::getInstance()->getSecurityModel(); $translator = $this->getTranslator(); $systemMenu = new Menu($translator->translate(self::TRANSLATION_TASKBAR_SYSTEM)); $systemMenu->addMenuItem(new MenuItem($translator->translate(LocalesController::TRANSLATION_TITLE), Module::ROUTE_LOCALES)); $systemMenu->addMenuItem(new MenuItem($translator->translate(ModulesController::TRANSLATION_TITLE), Module::ROUTE_MODULES)); if ($securityModel) { $systemMenu->addMenuItem(new MenuItem($translator->translate(SecurityController::TRANSLATION_TITLE), Module::ROUTE_SECURITY)); } $systemMenu->addMenuItem(new MenuItem($translator->translate(SystemController::TRANSLATION_TITLE), Module::ROUTE_SYSTEM)); $settingsMenu = $this->taskbar->getSettingsMenu(); $settingsMenu->addMenu($systemMenu); Zibo::getInstance()->runEvent(self::EVENT_TASKBAR, $this->taskbar); if ($securityModel) { $this->taskbar->addNotificationPanel(new UserPanelView()); } $view = new TaskbarView($this->taskbar); $this->setSubview('taskbar', $view); }
/** * Compare 2 items of a menu * @param Menu|MenuItem $a * @param Menu|MenuItem $b * @return 0 when $a and $b are the same, 1 when $a is bigger then $b, -1 otherwise */ public static function compareItems($a, $b) { $al = strtolower($a->getLabel()); $bl = strtolower($b->getLabel()); if ($al == $bl) { return 0; } return $al > $bl ? +1 : -1; }