php yii-bootstrap-Nav类(方法)实例源码

下面列出了php yii-bootstrap-Nav 类(方法)源码代码实例,从而了解它的用法。

作者:mark3    项目:yii2-to   
public function run()
 {
     $user = User::findOne(Yii::$app->user->id);
     echo Nav::widget(['items' => [['label' => 'Контактная информация', 'url' => ['/tor/profile']], ['label' => 'Добавить лот на продажу', 'url' => ['/tor/mng-ad']], ['label' => 'Мои объявления <span class="badge">' . TorAds::find()->count() . '</span>', 'url' => ['/tor/my-ads']], ['label' => 'Пополнить баланс ', 'url' => ['/']], ['label' => 'История платежей', 'url' => ['/']], ['label' => 'Реферальная ссылка', 'url' => ['/']]], 'options' => ['class' => 'account-nav'], 'encodeLabels' => false]);
     $view = $this->view;
     NavAsset::register($view);
 }

作者:nhatvuva    项目:yii2-widget   
public function run()
    {
        $chatModel = new \nitm\widgets\models\Replies(['constrain' => ['type' => 'chat']]);
        $notificationModel = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId()], 'queryOptions' => ['read' => 0]]);
        $uniqid = uniqid();
        $chatWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-messages-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('comment') . Html::tag('span', $chatModel->hasNew(), ['class' => 'badge']), 'options' => ['class' => !$chatModel->hasNew() ? 'text-disabled' : 'text-success'], 'linkOptions' => ['id' => 'communication-center-messages-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#chat' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Messages...', ['class' => 'text-center']) . Html::script('$("#communication-center-messages-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $alertWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-notifications-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('bell') . Html::tag('span', $notificationModel->count(), ['class' => 'badge']), 'options' => ['class' => !$notificationModel->count() ? 'bg-disabled' : 'bg-success'], 'linkOptions' => ['id' => 'communication-center-notifications-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#communication-center-notifications' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#communication-center-notifications' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html'])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Alerts...', ['class' => 'text-center']) . Html::script('$("#communication-center-notifications-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['id' => 'communication-center-notifications' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $widget = $alertWidget . $chatWidget;
        //$js = "\$nitm.onModuleLoad('communication-center', function (module) {
        //	module.initChatTabs('#".$this->options['id']."');
        //});";
        $js = "";
        if ($this->chatUpdateOptions['enabled']) {
            $js .= "\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('chat', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\turl: '" . $this->chatUpdateOptions['url'] . "', \r\n\t\t\t\t\tinterval: " . $this->chatUpdateOptions['interval'] . ",\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('replies'), method: 'chatStatus'});\r\n\t\t\t});";
        }
        if ($this->notificationUpdateOptions['enabled']) {
            $js .= "\r\n\t\t\t\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('notifications', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\tinterval: " . $this->notificationUpdateOptions['interval'] . ",\r\n\t\t\t\t\turl: '" . $this->notificationUpdateOptions['url'] . "',\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('notifications'), method: 'notificationStatus'});\r\n\t\t\t});";
        }
        if ($js) {
            $js = Html::script($js, ['type' => 'text/javascript']);
        }
        return $widget . $js;
    }

作者:jatupon    项目:iwe   
/**
  * @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();
 }

作者:glcod    项目:yii2-2.0.3-annotate   
public function testIds()
    {
        Nav::$counter = 0;
        $out = Nav::widget(['items' => [['label' => 'Page1', 'content' => 'Page1'], ['label' => 'Dropdown1', 'items' => [['label' => 'Page2', 'content' => 'Page2'], ['label' => 'Page3', 'content' => 'Page3']]], ['label' => 'Dropdown2', 'visible' => false, 'items' => [['label' => 'Page4', 'content' => 'Page4'], ['label' => 'Page5', 'content' => 'Page5']]]]]);
        $expected = <<<EXPECTED
<ul id="w0" class="nav"><li><a href="#">Page1</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Dropdown1 <b class="caret"></b></a><ul id="w1" class="dropdown-menu"><li class="dropdown-header">Page2</li>
<li class="dropdown-header">Page3</li></ul></li></ul>
EXPECTED;
        $this->assertEqualsWithoutLE($expected, $out);
    }

作者:apure    项目:cm   
/**
  * @return string
  */
 public function run()
 {
     $list = [];
     list($route, $params) = Yii::$app->getUrlManager()->parseRequest(Yii::$app->getRequest());
     $params = ArrayHelper::merge($_GET, $params);
     $url = isset($params['route']) ? $params['route'] : $route;
     foreach ($this->languages as $row) {
         $list = ArrayHelper::merge($list, [['label' => $row['title'], 'url' => Yii::$app->urlManager->createUrl(ArrayHelper::merge($params, [$url, 'language' => $row['iso']]))]]);
     }
     return Nav::widget(['options' => $this->options, 'items' => [['label' => Language::getCurrentRecord()->title, 'items' => $list]]]);
 }

作者:ochie    项目:app-cm   
/**
  * Renders mini-toolbar at the end of page body.
  *
  * @param \yii\base\Event $event
  */
 public function renderToolbar($event)
 {
     /* @var $view View */
     /* @var $urlManagerBack \yii\web\UrlManager */
     $urlManagerBack = Yii::$app->urlManagerBack;
     $view = $event->sender;
     $view->registerCss($view->renderPhpFile(__DIR__ . '/assets/toolbar.min.css'));
     NavBar::begin(['id' => 'wd-frontend-toolbar', 'brandLabel' => Html::img('@web/img/logo-mini.png'), 'brandUrl' => $urlManagerBack->baseUrl, 'innerContainerOptions' => ['class' => 'container-fluid'], 'options' => ['class' => 'navbar navbar-inverse navbar-fixed-top']]);
     echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-dashboard"></span> ' . Option::get('sitetitle'), 'items' => [['label' => Yii::t('toolbar', 'Dashboard'), 'url' => $urlManagerBack->baseUrl], ['label' => Yii::t('toolbar', 'Themes'), 'url' => $urlManagerBack->createUrl(['/theme']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Menus'), 'url' => $urlManagerBack->createUrl(['/menu']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Modules'), 'url' => $urlManagerBack->createUrl(['/module']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Widgets'), 'url' => $urlManagerBack->createUrl(['/widget']), 'visible' => Yii::$app->user->can('administrator')]]], ['label' => '<span aria-hidden="true" class="glyphicon glyphicon-plus"></span> ' . Yii::t('toolbar', 'New'), 'items' => $this->getAddNewMenu() ? $this->getAddNewMenu() : null]]]);
     echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-user"></span> ' . Yii::$app->user->identity->username, 'items' => [['label' => 'Profile', 'url' => $urlManagerBack->createUrl(['/user/profile'])], ['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]);
     NavBar::end();
 }

作者:mark3    项目:yii2-site-mn   
public function run()
 {
     $items[] = ['label' => '<span class="sr-only">Вид навигации</span>', 'url' => '#', 'linkOptions' => ['class' => 'sidebar-toggle hidden-xs', 'data-toggle' => 'offcanvas', 'role' => 'button']];
     $items[] = ['label' => 'Карта сайта', 'url' => ['/map/index'], 'active' => $this->active_module && $this->active_module->id == 'map' ? true : false];
     $modules = \common\models\main\Modules::find()->where(['visible' => 1])->orderBy(['seq' => SORT_ASC])->all();
     if ($modules) {
         $model_items = array();
         foreach ($modules as $model) {
             $model_items[] = ['label' => $model->name, 'url' => [$model->url]];
         }
         $items[] = ['label' => 'Модули', 'items' => $model_items];
     }
     echo Nav::widget(['items' => $items, 'options' => ['class' => 'nav navbar-nav'], 'encodeLabels' => false]);
 }

作者:timurmelniko    项目:yii2-panel-men   
/**
  * Выполнение виджета
  * @return string строка, содержащая HTML виджета
  */
 public function run()
 {
     //Заполнение заголовка
     if (isset($this->heading)) {
         $heading = '<div class="panel-heading">' . $this->heading . '</div>';
     } else {
         $heading = '';
     }
     //Заполнение подвала
     if (isset($this->footer)) {
         $footer = '<div class="panel-footer">' . $this->footer . '</div>';
     } else {
         $footer = '';
     }
     //Возврат результата
     return '<div class="panel ' . $this->type . '">' . $heading . '<div class="panel-body"> ' . Nav::widget(['options' => ['class' => 'nav-stacked'], 'items' => $this->items]) . ' </div>' . $footer . '</div>';
 }

作者:yiiste    项目:yii2-gentelell   
/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->options['id'] = $this->id;
     echo Html::beginTag('div', $this->options);
     if ($this->header !== null) {
         $this->initTools();
         echo Html::beginTag('div', ['class' => 'x_title']);
         echo Html::tag('h2', ($this->icon !== null ? new Icon($this->icon) . ' ' : '') . $this->header);
         if (empty($this->tools) === false) {
             echo Nav::widget(['dropDownCaret' => '', 'items' => $this->tools, 'options' => ['class' => 'nav navbar-right panel_toolbox']]);
         }
         echo Html::tag('div', null, ['class' => 'clearfix']);
         echo Html::endTag('div');
     }
     echo Html::beginTag('div', ['class' => 'x_content', 'style' => $this->expandable === true ? 'display: none;' : null]);
 }

作者:TF0    项目:yii2-advanced-de   
/**
     * Render the widget.
     */
    public function run()
    {
        $menuItems = [];
        if (Yii::$app->user->isGuest) {
            $menuItems[] = ['label' => 'Регистрация', 'url' => ['/site/signup']];
            $menuItems[] = ['label' => 'Войти', 'url' => ['/site/login']];
        } else {
            $menuItems[] = ['label' => 'Счета', 'url' => ['/accounts'], 'active' => $this->controller->id === 'accounts'];
            $menuItems[] = ['label' => 'Операции', 'url' => ['/transaction'], 'active' => $this->controller->id === 'transaction'];
            $menuItems[] = ['label' => 'Цели', 'url' => ['/targets'], 'active' => $this->controller->id === 'targets'];
            $menuItems[] = ['label' => 'Категории', 'url' => ['/category'], 'active' => $this->controller->id === 'category'];
            $menuItems[] = ['label' => Yii::$app->user->identity->username, 'items' => [['label' => 'Профиль', 'url' => ['/user-panel/settings']], ['label' => 'Выход', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]];
        }
        $menus = Nav::widget(['options' => ['class' => 'nav navbar-nav navbar-right'], 'items' => $menuItems]);
        return $HTML = <<<HTML
                {$menus}
HTML;
    }

作者:pc-brain    项目:blit   
public function getMenu()
 {
     $isAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false;
     $canAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false;
     $networksVisible = count(Yii::$app->authClientCollection->clients) > 0;
     $menuItems = [['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']]];
     if (Yii::$app->user->isGuest) {
         $menuItems[] = ['label' => Yii::t('user', 'Sign up'), 'url' => ['/user/registration/register']];
         $menuItems[] = ['label' => Yii::t('user', 'Sign in'), 'url' => ['/user/security/login']];
     } else {
         $menuItems['user'] = ['label' => $isAdmin ? Yii::$app->user->identity->profile->fullname . ' (admin)' : Yii::$app->user->identity->profile->fullname, 'items' => [['label' => Yii::t('user', 'Profile'), 'url' => ['/user/settings/profile']], ['label' => Yii::t('user', 'Account'), 'url' => ['/user/settings/account']], ['label' => Yii::t('user', 'Networks'), 'url' => ['/user/settings/networks'], 'visible' => $networksVisible], '<li class="divider"></li>', ['label' => Yii::t('user', 'Logout'), 'url' => ['/user/security/logout'], 'linkOptions' => ['data-method' => 'post']]]];
     }
     if ($canAdmin) {
         $menuItems['user']['items'][] = '<li class="divider"></li>';
         $menuItems['user']['items'][] = ['label' => Yii::t('user', 'Admin Panel'), 'url' => Yii::$app->urlManagerBackEnd->createUrl('')];
     }
     NavBar::begin(['brandLabel' => Yii::$app->params['companyName'], 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
     echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
     NavBar::end();
 }

作者:andreyvasl    项目:cr   
protected function isItemActive($item)
 {
     if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) {
         return true;
     }
     return parent::isItemActive($item);
 }

作者:orcsi    项目:yii2-orcsi   
/**
  * 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();
 }

作者:semn    项目:tp0   
protected function renderDropdown($items, $parentItem)
 {
     foreach ($items as &$item) {
         $this->changeItem($item);
     }
     return parent::renderDropdown($items, $parentItem);
 }

作者:dektriu    项目:yii2-rba   
/**
  * @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']]]]];
 }

作者:chabberwoc    项目:halo-de   
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'];
     }
 }

作者:kalyabi    项目:comitk   
/**
  * @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();
 }

作者:kalyabi    项目:comitk   
/**
  * @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();
 }

作者:tolik50    项目:b   
public function init()
 {
     parent::init();
     $items = [];
     if (Yii::$app->user->can(User::ROLE_ADMIN)) {
         $items = Yii::$app->params['menuItems'];
     }
     $this->items = $items;
 }

作者:barie    项目:yii2-dropdown-   
/**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->direction == 'left') {
         $this->options['class'] .= ' drop-left';
     }
     $itemTree = $this->generateItemsTree($this->items);
     $this->items = $this->createItems($itemTree);
     return parent::run();
 }


问题


面经


文章

微信
公众号

扫码关注公众号