当前位置: 首页>>代码示例>>PHP>>正文


PHP Nav::init方法代码示例

本文整理汇总了PHP中yii\bootstrap\Nav::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Nav::init方法的具体用法?PHP Nav::init怎么用?PHP Nav::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\bootstrap\Nav的用法示例。


在下文中一共展示了Nav::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * 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();
 }
开发者ID:orcsis,项目名称:yii2-orcsis,代码行数:11,代码来源:NavX.php

示例2: 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'];
     }
 }
开发者ID:chabberwock,项目名称:halo-dev,代码行数:28,代码来源:Nav.php

示例3: init

 /**
  * @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']]]]];
 }
开发者ID:dektrium,项目名称:yii2-rbac,代码行数:10,代码来源:Menu.php

示例4: init

 /**
  * @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();
 }
开发者ID:jatuponp,项目名称:iweb,代码行数:12,代码来源:NavX.php

示例5: 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();
 }
开发者ID:kalyabin,项目名称:comitka,代码行数:11,代码来源:UserMenu.php

示例6: 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();
 }
开发者ID:kalyabin,项目名称:comitka,代码行数:11,代码来源:ProfileMenu.php

示例7: init

 public function init()
 {
     parent::init();
     $items = [];
     if (Yii::$app->user->can(User::ROLE_ADMIN)) {
         $items = Yii::$app->params['menuItems'];
     }
     $this->items = $items;
 }
开发者ID:tolik505,项目名称:bl,代码行数:9,代码来源:MainMenu.php

示例8: init

 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);
     }
 }
开发者ID:agarb7,项目名称:mybriop,代码行数:10,代码来源:Nav.php

示例9: init

 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;
 }
开发者ID:tolik505,项目名称:bl,代码行数:11,代码来源:LoginMenu.php

示例10: init

 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'));
     }
 }
开发者ID:EuresTools,项目名称:eVote-web,代码行数:14,代码来源:languageSwitcher.php

示例11: init

 /**
  * 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');
 }
开发者ID:p2made,项目名称:yii2-triangle-theme,代码行数:17,代码来源:Nav.php

示例12: init

 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());
 }
开发者ID:chervand,项目名称:yii2-bootstrap,代码行数:16,代码来源:Nav.php

示例13: init

 /**
  * @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();
 }
开发者ID:communityii,项目名称:yii2-user,代码行数:23,代码来源:UserMenu.php

示例14: 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();
 }
开发者ID:communityii,项目名称:yii2-user,代码行数:25,代码来源:AdminMenu.php

示例15: init

 public function init()
 {
     $this->items = ArrayHelper::merge($this->convertToNav(ArrayHelper::getValue(Yii::$app->params, 'nav', [])), $this->items);
     parent::init();
 }
开发者ID:apurey,项目名称:cmf,代码行数:5,代码来源:NavWidget.php


注:本文中的yii\bootstrap\Nav::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。