本文整理汇总了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();
}
示例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'];
}
}
示例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']]]]];
}
示例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();
}
示例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();
}
示例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();
}
示例7: init
public function init()
{
parent::init();
$items = [];
if (Yii::$app->user->can(User::ROLE_ADMIN)) {
$items = Yii::$app->params['menuItems'];
}
$this->items = $items;
}
示例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);
}
}
示例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;
}
示例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'));
}
}
示例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');
}
示例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());
}
示例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();
}
示例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();
}
示例15: init
public function init()
{
$this->items = ArrayHelper::merge($this->convertToNav(ArrayHelper::getValue(Yii::$app->params, 'nav', [])), $this->items);
parent::init();
}