/** * Initialize the widget * @throws InvalidConfigException */ public function init() { if (!class_exists($this->dropdownClass)) { throw new InvalidConfigException("The dropdownClass '{$this->dropdownClass}' does not exist or is not accessible."); } parent::init(); }
public function init() { parent::init(); try { $tableSchema = Yii::$app->db->schema->getTableSchema(MenuItem::tableName()); } catch (\yii\db\Exception $e) { } if (empty($tableSchema)) { return; } $models = MenuItem::find()->where(['menu_id' => $this->menu])->orderBy(['order_id' => SORT_ASC])->all(); $items = []; // top menu items foreach ($models as $model) { if ($model->parent_id == 0) { $items[$model->id] = ['label' => $model->title, 'url' => $this->parseRoute($model->route)]; } } foreach ($models as $model) { if (isset($items[$model->parent_id])) { $items[$model->parent_id]['items'][] = ['label' => $model->title, 'url' => $this->parseRoute($model->route)]; } } $this->items = ArrayHelper::merge($items, $this->items); if (Yii::$app->user->identity && Yii::$app->user->identity->getIsAdmin()) { $this->items[] = ['label' => 'Admin Panel', 'url' => '/admin']; } }
/** * @inheritdoc */ public function init() { parent::init(); $userModuleClass = 'dektrium\\user\\Module'; $isUserModuleInstalled = \Yii::$app->getModule('user') instanceof $userModuleClass; $this->items = [['label' => \Yii::t('rbac', 'Users'), 'url' => ['/user/admin/index'], 'visible' => $isUserModuleInstalled], ['label' => \Yii::t('rbac', 'Roles'), 'url' => ['/rbac/role/index']], ['label' => \Yii::t('rbac', 'Permissions'), 'url' => ['/rbac/permission/index']], ['label' => \Yii::t('rbac', 'Rules'), 'url' => ['/rbac/rule/index']], ['label' => \Yii::t('rbac', 'Create'), 'items' => [['label' => \Yii::t('rbac', 'New user'), 'url' => ['/user/admin/create'], 'visible' => $isUserModuleInstalled], ['label' => \Yii::t('rbac', 'New role'), 'url' => ['/rbac/role/create']], ['label' => \Yii::t('rbac', 'New permission'), 'url' => ['/rbac/permission/create']], ['label' => \Yii::t('rbac', 'New rule'), 'url' => ['/rbac/rule/create']]]]]; }
/** * @inheritdoc * @throws InvalidConfigException */ public function init() { if (!class_exists($this->dropdownClass)) { throw new InvalidConfigException("The dropdownClass '{$this->dropdownClass}' does not exist or is not accessible."); } NavXAsset::register($this->getView()); parent::init(); }
/** * @inheritdoc */ public function init() { if (!$this->model instanceof User) { throw new InvalidParamException('Model must be an instance of ' . User::className()); } $this->items = [['url' => ['/user/user-manager/update', 'id' => $this->model->id], 'label' => Yii::t('user', 'Common settings')], ['url' => ['/user/user-manager/vcs-bindings', 'id' => $this->model->id], 'label' => Yii::t('user', 'VCS bindings')]]; parent::init(); }
/** * @inheritdoc */ public function init() { if (!$this->authUser instanceof User) { throw new InvalidParamException('AuthUser must be an instance of ' . User::className()); } $this->items = [['url' => ['/user/profile/index'], 'label' => Yii::t('user', 'Common settings')], ['url' => ['/user/profile/vcs-bindings'], 'label' => Yii::t('user', 'VCS bindings')]]; parent::init(); }
public function init() { parent::init(); $items = []; if (Yii::$app->user->can(User::ROLE_ADMIN)) { $items = Yii::$app->params['menuItems']; } $this->items = $items; }
public function init() { parent::init(); $userId = Yii::$app->user->id; $roles = $userId ? Yii::$app->authManager->getRolesByUser($userId) : []; foreach ($roles as $role) { $items = $this->rolesMenuItems()[$role->name]; $this->items = ArrayHelper::merge($this->items, $items); } }
public function init() { parent::init(); $items = []; if (Yii::$app->user->isGuest) { $items[] = ['label' => 'Login', 'url' => ['/admin/default/login']]; } else { $items[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/admin/default/logout'], 'linkOptions' => ['data-method' => 'post']]; } $this->items = $items; }
public function init() { if (php_sapi_name() === 'cli') { return true; } parent::init(); $cookies = Yii::$app->request->cookies; $languageNew = Yii::$app->request->get('language'); if ($languageNew) { $this->setNewLanguage($languageNew); } elseif ($cookies->has('language')) { $this->setNewLanguage($cookies->getValue('language')); } }
/** * Initializes the widget. */ public function init() { parent::init(); $this->dropDownCaret = Html::tag('i', '', ['class' => 'fa fa-angle-down']); if ($this->route === null && Yii::$app->controller !== null) { $this->route = Yii::$app->controller->getRoute(); } if ($this->params === null) { $this->params = Yii::$app->request->getQueryParams(); } if ($this->dropDownCaret === null) { } Html::addCssClass($this->options, 'nav'); }
public function init() { parent::init(); if (!in_array($this->toggle, [static::TOGGLE_DROPDOWN, static::TOGGLE_COLLAPSE])) { $this->toggle = static::TOGGLE_DROPDOWN; } foreach ($this->items as $key => $item) { $item = static::prepareItem($item); if ($item !== null) { $this->items[$key] = $item; } else { unset($this->items[$key]); } } BootstrapPluginAsset::register($this->getView()); }
/** * @inheritdoc */ public function init() { /** * @var Module $m */ $m = Yii::$app->getModule('user'); $currUser = Yii::$app->user; $isAdmin = $currUser->isAdmin || $currUser->isSuperuser; if ($currUser->id == $this->user) { $this->items[] = ['label' => $m->icon('eye-open') . Yii::t('user', 'View'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_INDEX]], 'active' => $this->ui === 'view', 'linkOptions' => ['title' => Yii::t('user', 'View user profile')]]; $this->items[] = ['label' => $m->icon('pencil') . Yii::t('user', 'Edit'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_UPDATE]], 'active' => $this->ui === 'edit', 'linkOptions' => ['title' => Yii::t('user', 'Edit user profile')]]; $this->items[] = ['label' => $m->icon('lock') . Yii::t('user', 'Password'), 'url' => [$m->actionSettings[Module::ACTION_ACCOUNT_PASSWORD]], 'active' => $this->ui === 'password', 'linkOptions' => ['title' => Yii::t('user', 'Change user password')]]; } elseif ($isAdmin) { $this->items[] = ['label' => $m->icon('eye-open') . Yii::t('user', 'View'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_INDEX]], 'active' => $this->ui === 'view', 'linkOptions' => ['title' => Yii::t('user', 'View user profile')]]; } if ($isAdmin) { $this->items[] = ['label' => $m->icon('wrench') . Yii::t('user', 'Manage'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_VIEW], 'id' => $this->user], 'linkOptions' => ['title' => Yii::t('user', 'Administer user profile')]]; } parent::init(); }
/** * @inheritdoc */ public function init() { /** * @var Module $m */ $m = Yii::$app->getModule('user'); $settings = $this->user === null ? [] : $m->getEditSettingsAdmin($this->user); $this->items[] = ['label' => $m->icon('list') . Yii::t('user', 'Users'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_INDEX]], 'active' => $this->ui === 'list', 'linkOptions' => ['title' => Yii::t('user', 'View user listing')]]; if ($m->checkSettings($settings, 'createUser')) { $this->items[] = ['label' => $m->icon('plus') . Yii::t('user', 'Create'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_CREATE]], 'active' => $this->ui === 'create', 'linkOptions' => ['title' => Yii::t('user', 'Create new user')]]; } if (empty($settings) || $this->user->isNewRecord) { parent::init(); return; } if ($m->checkSettings($settings, 'changeUsername') || $m->checkSettings($settings, 'changeEmail')) { $this->items[] = ['label' => $m->icon('pencil') . Yii::t('user', 'Edit'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_UPDATE], 'id' => $this->user->id], 'active' => $this->ui === 'edit', 'linkOptions' => ['title' => Yii::t('user', 'Edit user profile')]]; } $this->items[] = ['label' => $m->icon('wrench') . Yii::t('user', 'Manage'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_VIEW], 'id' => $this->user->id], 'active' => $this->ui === 'manage', 'linkOptions' => ['title' => Yii::t('user', 'Administer user profile')]]; $this->items[] = ['label' => $m->icon('eye-open') . Yii::t('user', 'Profile'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_VIEW], 'id' => $this->user->id], 'linkOptions' => ['title' => Yii::t('user', 'View user profile')]]; parent::init(); }
public function init() { $this->items = ArrayHelper::merge($this->convertToNav(ArrayHelper::getValue(Yii::$app->params, 'nav', [])), $this->items); parent::init(); }
/** * @inheritdoc * @throws InvalidConfigException */ public function init() { $this->getMenuByName("default"); $this->items = $this->getMenuByName("default"); parent::init(); }
/** * @inheritdoc */ public function init() { parent::init(); $this->options = ArrayHelper::merge($this->options, ['class' => 'filter-list']); }
/** * Initializes the widget. */ public function init() { Html::addCssClass($this->options, $this->navbar); Html::addCssClass($this->options, $this->position); parent::init(); }
/** * Renders the widget. */ public function init() { parent::init(); $this->items = $this->getMenuItems($this->menuType); }
/** * Initializes the widget. */ public function init() { parent::init(); Html::removeCssClass($this->options, ['widget' => 'nav']); Html::addCssClass($this->options, ['navlist' => $this->warpClass]); }
public function init() { parent::init(); Html::addCssClass($this->options, 'nav-sidebar'); }
/** * @inheritdoc */ public function init() { parent::init(); Html::removeCssClass($this->options, 'nav'); Html::addCssClass($this->options, 'sidebar-menu'); }
public function init() { parent::init(); $this->ensureVisibility($this->items); }
public function init() { parent::init(); }
public function init() { $this->items = $this->filterItems($this->items); parent::init(); }