/** * 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(); }
/** * 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(); }
/** * 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(); }
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']); }
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 }
/** * 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)); } }
/** * 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'); }
/** * 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'); }
public function run() { $this->items = $this->getMenuItems(); parent::run(); }
public function run() { parent::run(); $this->itemOffset = 0; }
public function run() { $this->registerScript(); parent::run(); }
public function run() { $view = $this->getView(); LangSwitcherAsset::register($view); parent::run(); }