本文整理汇总了PHP中yii\bootstrap\Nav类的典型用法代码示例。如果您正苦于以下问题:PHP Nav类的具体用法?PHP Nav怎么用?PHP Nav使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Nav类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
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);
}
示例2: run
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;
}
示例3: 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();
}
示例4: testIds
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);
}
示例5: run
/**
* @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]]]);
}
示例6: renderToolbar
/**
* 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();
}
示例7: isItemActive
protected function isItemActive($item)
{
if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) {
return true;
}
return parent::isItemActive($item);
}
示例8: 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();
}
示例9: renderDropdown
protected function renderDropdown($items, $parentItem)
{
foreach ($items as &$item) {
$this->changeItem($item);
}
return parent::renderDropdown($items, $parentItem);
}
示例10: 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']]]]];
}
示例11: 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'];
}
}
示例12: 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();
}
示例13: 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();
}
示例14: init
public function init()
{
parent::init();
$items = [];
if (Yii::$app->user->can(User::ROLE_ADMIN)) {
$items = Yii::$app->params['menuItems'];
}
$this->items = $items;
}
示例15: run
/**
* @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();
}