init() публичный Метод

Initializes the widget.
public init ( )
Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 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'];
     }
 }
Пример #3
0
 /**
  * @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']]]]];
 }
Пример #4
0
 /**
  * @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();
 }
Пример #5
0
 /**
  * @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();
 }
Пример #6
0
 /**
  * @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();
 }
Пример #7
0
 public function init()
 {
     parent::init();
     $items = [];
     if (Yii::$app->user->can(User::ROLE_ADMIN)) {
         $items = Yii::$app->params['menuItems'];
     }
     $this->items = $items;
 }
Пример #8
0
 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);
     }
 }
Пример #9
0
 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;
 }
Пример #10
0
 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'));
     }
 }
Пример #11
0
 /**
  * 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');
 }
Пример #12
0
 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());
 }
Пример #13
0
 /**
  * @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();
 }
Пример #14
0
 /**
  * @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();
 }
Пример #15
0
 public function init()
 {
     $this->items = ArrayHelper::merge($this->convertToNav(ArrayHelper::getValue(Yii::$app->params, 'nav', [])), $this->items);
     parent::init();
 }
Пример #16
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     $this->getMenuByName("default");
     $this->items = $this->getMenuByName("default");
     parent::init();
 }
Пример #17
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->options = ArrayHelper::merge($this->options, ['class' => 'filter-list']);
 }
Пример #18
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     Html::addCssClass($this->options, $this->navbar);
     Html::addCssClass($this->options, $this->position);
     parent::init();
 }
Пример #19
0
 /**
  * Renders the widget.
  */
 public function init()
 {
     parent::init();
     $this->items = $this->getMenuItems($this->menuType);
 }
Пример #20
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, ['widget' => 'nav']);
     Html::addCssClass($this->options, ['navlist' => $this->warpClass]);
 }
Пример #21
0
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, 'nav-sidebar');
 }
Пример #22
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, 'nav');
     Html::addCssClass($this->options, 'sidebar-menu');
 }
Пример #23
0
 public function init()
 {
     parent::init();
     $this->ensureVisibility($this->items);
 }
 public function init()
 {
     parent::init();
 }
Пример #25
0
 public function init()
 {
     $this->items = $this->filterItems($this->items);
     parent::init();
 }