run() 공개 메소드

Renders the menu.
public run ( )
예제 #1
0
 /**
  * Renders the menu.
  */
 public function run()
 {
     // Get Module list
     $modules = array_keys(Yii::$app->modules);
     // Get sub menu for each module
     foreach ($modules as $moduleName) {
         // Get module
         $moduleObj = Yii::$app->getModule($moduleName);
         $iconClass = isset($moduleObj->iconClass) ? $moduleObj->iconClass : 'fa-dashboard';
         // Get menu
         if (property_exists($moduleObj, 'backendMenu')) {
             $getModule = Yii::$app->request->get('module');
             $item = ['label' => Icon::show($iconClass) . '<span class="nav-label">' . Yii::t($moduleName, ucfirst($moduleName)) . '</span>', 'url' => ['/' . $moduleName . '/default']];
             if (Yii::$app->controller->module->id == $moduleName and empty($getModule) or $getModule == $moduleName) {
                 $item['active'] = TRUE;
             }
             $backendMenu = $moduleObj->backendMenu;
             if (is_array($backendMenu)) {
                 foreach ($backendMenu as $itemMenu) {
                     if (isset($itemMenu['access']) and $this->checkAccess($itemMenu['access'])) {
                         $item['items'][] = ['label' => $itemMenu['label'], 'url' => $itemMenu['url']];
                     }
                 }
                 if (isset($item['items']) and !empty($item['items'])) {
                     $item['label'] .= '<span class="fa arrow"></span>';
                 }
             }
             // assign to $this->items
             $this->items[] = $item;
         }
     }
     parent::run();
 }
예제 #2
0
 /**
  * Renders the menu.
  */
 public function run()
 {
     $this->options = ['tag' => 'ul', 'class' => 'nav navbar-nav navbar-right'];
     $this->encodeLabels = false;
     $this->items[] = ['label' => \Yii::t('app', 'Home'), 'url' => [DummyModel::getHomeRoute()]];
     /** @var ArticleCategory[] $categories */
     $categories = ArticleCategory::find()->from(['t' => ArticleCategory::tableName()])->joinWith(['articles'], true, 'RIGHT JOIN')->andWhere(['t.published' => 1])->orderBy('t.position DESC, t.id')->groupBy('t.id')->all();
     \Yii::$app->params['categoryModels'] = $categories;
     foreach ($categories as $category) {
         $this->items[] = ['label' => $category->label, 'url' => [ArticleCategory::getIndexRoute(), 'alias' => $category->alias]];
     }
     parent::run();
 }
예제 #3
0
파일: Menu.php 프로젝트: kaihatsusha/kpimon
 /**
  * Renders the menu.
  */
 public function run()
 {
     $controller = \Yii::$app->controller;
     $moduleObj = $controller->module;
     $paths = [];
     $moduleId = isset($moduleObj->id) ? $moduleObj->id : false;
     if ($moduleId && in_array($moduleId, ['fin', 'net', 'jar', 'oef'])) {
         $paths[] = $moduleId;
     }
     $paths[] = $controller->id;
     $this->objectId = isset($controller->objectId) ? $controller->objectId : false;
     $this->pathPattern = '/^\\/' . implode('\\/', $paths) . '\\/.*$/';
     parent::run();
 }
예제 #4
0
 public function run()
 {
     ob_start();
     parent::run();
     $body = ob_get_contents();
     ob_end_clean();
     // Adds the header
     if ($this->header) {
         $encodeHeader = ArrayHelper::getValue($this->options, 'encodeHeader', TRUE);
         $header = strtr($this->headerTemplate, ['{header}' => $encodeHeader ? Html::encode($this->header) : $this->header]);
         $body = $header . $body;
     }
     echo Html::tag('div', $body, ['class' => 'sidebar']);
 }
예제 #5
0
파일: Menu.php 프로젝트: oakcms/oakcms
 public function run()
 {
     if ($this->cache) {
         /** @var Cache $cache */
         $this->cache = Instance::ensure($this->cache, Cache::className());
         $cacheKey = [__CLASS__, $this->items];
         if (($this->items = $this->cache->get($cacheKey)) === false) {
             $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
             $this->cache->set($cacheKey, $this->items, $this->cacheDuration, $this->cacheDependency);
         }
     } else {
         $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
     }
     $this->items += $this->customItems;
     parent::run();
     // TODO: Change the autogenerated stub
 }
예제 #6
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     parent::run();
     $view = $this->getView();
     $id = $this->options['id'];
     if ($this->clientOptions !== false) {
         $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
         $js = "jQuery('#{$id}').menu({$options});";
         $view->registerJs($js);
     }
     if (!empty($this->clientEvents)) {
         $js = [];
         foreach ($this->clientEvents as $event => $handler) {
             $js[] = "jQuery('#{$id}').on('menu{$event}', {$handler});";
         }
         $view->registerJs(implode("\n", $js));
     }
 }
예제 #7
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::beginTag('div', ['class' => 'page-sidebar-wrapper']);
     echo Html::beginTag('div', ['class' => 'page-sidebar navbar-collapse collapse']);
     parent::run();
     echo Html::endTag('div');
     echo Html::endTag('div');
 }
예제 #8
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::beginTag('div', ['class' => 'page-sidebar-wrapper']);
     echo Html::beginTag('div', ['class' => 'page-sidebar navbar-collapse collapse']);
     echo Html::beginTag('ul', $this->options);
     echo $this->toggleMenu ? $this->toggleMenu : '';
     if ($this->searchMenu) {
         $options = ArrayHelper::merge(['url' => '', 'method' => 'GET', 'name' => 'keyword', 'placeholder' => '搜索'], $this->searchMenu);
         echo strtr($this->_searchTemplate, ['{action}' => Url::to($options['url']), '{method}' => $options['method'], '{name}' => $options['name'], '{placeholder}' => $options['placeholder']]);
     }
     parent::run();
     echo Html::endTag('ul');
     echo Html::endTag('div');
     echo Html::endTag('div');
 }
예제 #9
0
 public function run()
 {
     $this->items = $this->getMenuItems();
     parent::run();
 }
예제 #10
0
 public function run()
 {
     parent::run();
     $this->itemOffset = 0;
 }
예제 #11
0
 public function run()
 {
     $this->registerScript();
     parent::run();
 }
예제 #12
0
 public function run()
 {
     $view = $this->getView();
     LangSwitcherAsset::register($view);
     parent::run();
 }