/** * Lists all StaticPageTable models. * @return mixed */ public function actionIndex() { if (!Yii::$app->user->can('static-page-table/index')) { Yii::$app->session->setFlash('error', 'Нет доступа!'); return $this->redirect('/'); } if (isset($_POST['sort_list_2'])) { $mas = explode(',', $_POST['sort_list_2']); for ($i = 0; $i <= sizeof($mas) - 1; $i++) { $model = $this->findModel($mas[$i]); $model->position = $i; $model->save(); } } $staticPagesTrue = StaticPageTable::find()->where(['status' => 1])->orderBy(['position' => SORT_ASC])->all(); $staticPagesFalse = StaticPageTable::find()->where(['status' => 0])->orderBy(['position' => SORT_ASC])->all(); $list = []; $value = ""; foreach ($staticPagesTrue as $statispage) { $list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url])]; $value .= $statispage->id . ","; } foreach ($staticPagesFalse as $statispage) { $list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url]), 'disabled' => true]; $value .= $statispage->id . ","; } $value = substr($value, 0, -1); return $this->render('index', ['list' => $list, 'value' => $value]); }
/** * @inheritdoc */ public function init() { parent::init(); Html::addCssClass($this->options, ['widget' => 'info-box']); $iconOptions = ['class' => 'info-box-icon']; if ($this->type === self::COLORED_ICON) { Html::addCssClass($iconOptions, 'bg-' . $this->color); } else { Html::addCssClass($this->options, 'bg-' . $this->color); } echo Html::beginTag('div', $this->options); echo Html::tag('span', FA::icon($this->icon), $iconOptions); echo '<div class="info-box-content">'; if (!empty($this->contents)) { foreach ($this->contents as $content) { if (is_array($content)) { $type = ArrayHelper::getValue($content, 'type', 'text'); $text = ArrayHelper::getValue($content, 'text', ''); if (in_array($type, ['text', 'number'])) { echo Html::tag('span', $text, ['class' => 'info-box-' . $type]); } elseif ($type == 'progress') { $value = ArrayHelper::getValue($content, 'value', $text); echo '<div class="progress">'; echo Html::tag('div', '', ['class' => 'progress-bar', 'style' => ['width' => $value . '%']]); echo '</div>'; } else { echo Html::tag('span', $text, ['class' => $type]); } } else { echo $content; } } } }
/** * Creates the label for a button * * @return string the label */ protected function createLabel() { $icon = empty($this->icon) ? '' : FA::icon($this->icon); if (empty($this->label) || strcmp($this->label, 'Button') === 0) { $label = ''; } else { $label = Html::tag('span', $this->encodeLabel ? Html::encode($this->label) : $this->label); } return $icon . $label; }
/** * @param array|string $item * @return null|string */ function renderItem($item) { $options = []; if (isset($item['visible']) && $item['visible'] !== true) { return null; } $anchor_options = []; if (!isset($item['items']) || empty($item['items'])) { $label = ''; $subitems = ''; if (isset($item['icon']) && !empty($item['icon'])) { $label .= $item['icon'] . ' '; } $label .= Html::tag('span', $item['label']); if (isset($item['badge'])) { if (!is_array($item['badge'])) { $item['badge'] = ['text' => $item['badge']]; } $opt = ['class' => 'label pull-right']; if (isset($item['badge']['class'])) { Html::addCssClass($opt, $item['badge']['class']); } $label .= ' ' . Html::tag('small', $item['badge']['text'], $opt); } } else { $label = ''; $subitems = ''; if (isset($item['icon']) && !empty($item['icon'])) { $label .= $item['icon'] . ' '; } $label .= Html::tag('span', $item['label']) . FA::icon('angle-left')->pullRight(); foreach ($item['items'] as $subitem) { $subitems .= renderItem($subitem); } $opt = ['class' => 'treeview-menu']; if (true === $item['selected']) { Html::addCssClass($opt, 'menu-open'); } $subitems = Html::tag('ul', $subitems, $opt); Html::addCssClass($options, 'treeview'); } if (true === $item['selected']) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $item['url'], $anchor_options) . $subitems, $options); }
public function getMenuItems() { return [['label' => ($this->_model ? FA::icon(FA::_EDIT) : FA::icon(FA::_PLUS_SQUARE)) . ' <b>' . $this->generateKey() . '</b> <span class="label label-danger">HTML</span>', 'url' => $this->_model ? $this->generateEditRoute($this->_model->id) : $this->generateCreateRoute()]]; }
<div class="col-lg-3"> <h2><?php echo FA::icon('youtube-play'); ?> Видео</h2> <p>Вставка видео на главной странице и описания к нему</p> <p><a class="btn btn-primary" href="<?php echo Url::to(['/admin/video']); ?> ">Начать »</a></p> </div> <div class="col-lg-3"> <h2><?php echo FA::icon('floppy-o'); ?> Релизы</h2> <p>Добавление и редактирование вышедших релизов для отображения на странице /releases</p> <p><a class="btn btn-primary" href="<?php echo Url::to(['/admin/release']); ?> ">Начать »</a></p> </div> </div> </div> </div>
echo $this->render('_general_content', ['ActiveForm' => $ActiveForm, 'PageEditForm' => $PageEditForm]); ?> </uib-tab> <uib-tab heading="Meta"> <?php echo $this->render('_general_meta', ['ActiveForm' => $ActiveForm, 'PageEditForm' => $PageEditForm]); ?> </uib-tab> </uib-tabset> <?php ?> </div> </div> </div> <div class="box-footer"> <?php echo Html::submitButton(FA::icon('check') . ' ' . Yii::t('cookyii', 'Save'), ['class' => 'btn btn-success', 'ng-disabled' => 'in_progress']); echo Html::button(Yii::t('cookyii', 'Cancel'), ['class' => 'btn btn-link', 'ng-click' => 'reload()']); ?> </div> <div class="overlay" ng-if="inProgress"> <?php echo FA::icon('cog')->spin(); ?> </div> </div> <?php ActiveForm::end();
public function testIconFlipException() { $this->setExpectedException('yii\\base\\InvalidConfigException', 'FA::flip() - invalid value. Use one of the constants: FA::FLIP_HORIZONTAL, FA::FLIP_VERTICAL.'); FA::icon('cog')->flip('badvalue'); }
/** * @inheritdoc */ public function menu($Controller) { return [['label' => \Yii::t('cookyii.account', 'Accounts'), 'url' => ['/account/list/index'], 'icon' => FA::icon('user'), 'visible' => User()->can(Account\backend\Permissions::ACCESS), 'selected' => $Controller->module->id === 'account', 'sort' => 10000]]; }
/** * Renders a widget's item. * @param string|array $item the item to render. * @return string the rendering result. * @throws InvalidConfigException */ public function renderItem($item) { if (is_string($item)) { return $item; } if (!isset($item['label']) && !isset($item['icon'])) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = ArrayHelper::getValue($item, 'label', ''); if ($encodeLabel) { $label = Html::encode($label); } $icon = ArrayHelper::getValue($item, 'icon'); if ($icon) { $label = FA::icon($icon) . ' ' . $label; } $badge = ArrayHelper::getValue($item, 'badge'); if (!empty($badge)) { $badgeColor = ArrayHelper::getValue($item, 'badgeColor', 'red'); $label .= ' ' . Html::tag('small', $badge, ['class' => 'badge pull-right bg-' . $badgeColor]); } $options = ArrayHelper::getValue($item, 'options', []); $items = ArrayHelper::getValue($item, 'items'); $url = ArrayHelper::getValue($item, 'url', '#'); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if ($items !== null) { Html::addCssClass($options, ['widget' => 'treeview']); if ($this->treeviewCaret !== '') { $label .= ' ' . $this->treeviewCaret; } if (is_array($items)) { if ($this->activateItems) { $items = $this->isChildActive($items, $active); } $items = $this->renderItems($items, ['class' => 'treeview-menu']); } } if ($this->activateItems && $active) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); }
</script> <script type="text/ng-template" id="toast-warning.html"> <md-toast class="warning"> <span flex> <?php echo FA::icon('exclamation-triangle')->fixedWidth(); ?> <strong ng-show="false">{{ message.title }}<br></strong> <span>{{ message.text }}</span> </span> <md-button ng-click="resolve()" class="md-action"> {{ action }} </md-button> </md-toast> </script> <script type="text/ng-template" id="toast-danger.html"> <md-toast class="danger"> <span flex> <?php echo FA::icon('times')->fixedWidth(); ?> <strong ng-show="false">{{ message.title }}<br></strong> <span>{{ message.text }}</span> </span> <md-button ng-click="resolve()" class="md-action"> {{ action }} </md-button> </md-toast> </script>
?> </span> <div class="info-box-content"> <strong class="info-box-text"><?php echo Yii::t('cookyii', 'Warning'); ?> </strong> <span class="progress-description"> <?php echo Yii::t('cookyii', 'The data of this item has been changed.'); ?> <br> <?php echo Yii::t('cookyii', 'Recommended {refresh} the page.', ['refresh' => Html::a(FA::icon('refresh') . ' ' . Yii::t('cookyii', 'Refresh'), null, ['class' => 'btn btn-danger btn-xs', 'ng-click' => 'reload()'])]); ?> </span> </div> </div> </div> </div> <div class="row"> <div class="col-xs-12"> <?php echo $this->render('_general', ['PageEditForm' => $PageEditForm]); ?> </div> </div> </section>
* @link https://rmrevin.com */ use rmrevin\yii\fontawesome\FA; ?> <script type="text/ng-template" id="directives/progressbar/progressbar.html"> <div class="toast-progress"></div> </script> <script type="text/ng-template" id="directives/toast/toast.html"> <div class="{{ toastClass }} {{ toastType }} wo-animate animated flipInX" ng-click="tapToast()"> <div class="icon"> <div ng-switch on="toastType"> <?php echo FA::icon('times', ['ng-switch-when' => 'error'])->fixedWidth(); echo FA::icon('exclamation-triangle', ['ng-switch-when' => 'warning'])->fixedWidth(); echo FA::icon('check', ['ng-switch-when' => 'success'])->fixedWidth(); echo FA::icon('info', ['ng-switch-when' => 'info'])->fixedWidth(); ?> </div> </div> <div class="body" ng-switch on="allowHtml"> <div ng-switch-default ng-if="title" class="{{ titleClass }}" aria-label="{{ title }}" ng-bind="title"></div> <div ng-switch-default class="{{ messageClass }}" aria-label="{{ message }}" ng-bind="message"></div> <div ng-switch-when="true" ng-if="title" class="{{ titleClass }}" ng-bind-html="title"></div> <div ng-switch-when="true" class="{{ messageClass }}" ng-bind-html="message"></div> </div> <progress-bar ng-if="progressBar"></progress-bar> </div> </script>
} ?> <?php foreach ($properties as $i => $property) { ?> <div class="item panel panel-default"><!-- widgetItem --> <div class="panel-heading"> <h3 class="panel-title pull-left">Характеристика <?php echo $i + 1; ?> </h3> <div class="pull-right"> <button type="button" class="remove-item btn btn-danger btn-xs"> <?php echo FA::icon('minus'); ?> Удалить </button> </div> <div class="clearfix"></div> </div> <div class="panel-body"> <?php // necessary for update action. if (!$property->isNewRecord) { echo Html::activeHiddenInput($property, "[{$i}]id"); } ?> <?php echo $form->field($property, "[{$i}]name")->textInput(['maxlength' => true]);
/** * Renders a widget's item. * @param string|array $item the item to render. * @return string the rendering result. * @throws InvalidConfigException */ public function renderItem($item) { if (is_string($item)) { return $item; } if (!isset($item['label']) && !isset($item['icon'])) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = ArrayHelper::getValue($item, 'label', ''); if ($encodeLabel) { $label = Html::encode($label); } $icon = ArrayHelper::getValue($item, 'icon'); if ($icon) { $label .= ' ' . FA::icon($icon); } $badge = ArrayHelper::getValue($item, 'badge'); if (!empty($badge)) { if (is_array($badge)) { $badgeValue = ArrayHelper::getValue($badge, 'value'); $badgeType = ArrayHelper::getValue($badge, 'type'); $label .= ' ' . Html::tag('span', $badgeValue, ['class' => 'label label-' . $badgeType]); } else { $label .= ' ' . $badge; } } $options = ArrayHelper::getValue($item, 'options', []); $items = ArrayHelper::getValue($item, 'items'); $url = ArrayHelper::getValue($item, 'url', '#'); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if ($items !== null) { $linkOptions['data-toggle'] = 'dropdown'; Html::addCssClass($options, ['widget' => 'dropdown']); Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']); if ($this->dropDownCaret !== '') { $label .= ' ' . $this->dropDownCaret; } if (is_array($items)) { if ($this->activateItems) { $items = $this->isChildActive($items, $active); } $items = $this->renderDropdown($items, $item); } } if ($this->activateItems && $active) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); }
</div> <div class="col-md-10"> <span class="pull-left creater"> <?php echo $commentt->user->username; ?> </span> <span><?php echo strftime('%d.%m.%Y %H:%M', $commentt->create_at - 60 * 60); ?> </span> <span class="pull-right "> <?php if (Yii::$app->user->can('admin')) { ?> <?php echo Html::a(FA::icon('trash'), ['delete-comment', 'id' => $commentt->id], ['class' => 'btn btn-danger btn-xs', 'onclick' => 'delete_comment("' . $commentt->id . '",' . $commentt->product_id . ');return false;', 'data-toggle' => "tooltip", 'data-placement' => "top", 'title' => "Удалить комментарий"]); ?> <?php } ?> </span> <div class="review"> <?php echo $commentt->comment; ?> </div> </div> <hr> </div> <?php
/** * @inheritdoc */ public function menu($Controller) { return [['label' => \Yii::t('cookyii.postman', 'Postman'), 'url' => ['/postman'], 'icon' => FA::icon('envelope'), 'visible' => User()->can(\cookyii\modules\Postman\backend\Permissions::ACCESS), 'selected' => $Controller->module->id === 'postman', 'sort' => 9000, 'items' => [['label' => \Yii::t('cookyii.postman', 'Messages'), 'url' => ['/postman/message/list'], 'icon' => FA::icon('send'), 'selected' => $Controller->module->id === 'postman' && $Controller->id === 'message'], ['label' => \Yii::t('cookyii.postman', 'Templates'), 'url' => ['/postman/template/list'], 'icon' => FA::icon('table'), 'selected' => $Controller->module->id === 'postman' && $Controller->id === 'template']]]]; }
<h2 class="text-center"> Вход<small> (<?php echo Html::a('зарегистрироваться', ['/site/reg']); ?> )</small> </h2> <div class="col-md-6 col-md-offset-3"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'username', ['addon' => ['prepend' => ['content' => \rmrevin\yii\fontawesome\FA::icon('user')]]]); ?> <?php echo $form->field($model, 'password', ['addon' => ['prepend' => ['content' => \rmrevin\yii\fontawesome\FA::icon('key')]]])->passwordInput(); ?> <?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?php echo Html::a('Забыли пароль?', ['site/send-email']); ?> <div class="form-group"> <div class="text-centre"> <?php echo Html::submitButton('Войти', ['class' => 'btn btn-primary btn-block']); ?> </div>
?> </div> <?php } ?> <div class="actions"> <?php if (!$Comment->isDeleted()) { if ($Comment->canCreate()) { echo Html::a(FA::icon('reply') . ' ' . Yii::t('app', 'Reply'), '#', ['class' => 'btn btn-info btn-xs', 'data-role' => 'reply']); } if ($Comment->canUpdate()) { echo Html::a(FA::icon('pencil') . ' ' . Yii::t('app', 'Edit'), '#', ['data-role' => 'edit', 'class' => 'btn btn-primary btn-xs']); } if ($Comment->canDelete()) { echo Html::a(FA::icon('times') . ' ' . Yii::t('app', 'Delete'), ['', 'delete-comment' => $Comment->id], ['class' => 'btn btn-danger btn-xs']); } } ?> </div> </div> </div> <?php return ob_get_clean(); }]); /** @var Comments\models\Comment $CommentModel */ $CommentModel = \Yii::createObject(Comments\Module::instance()->model('comment')); if ($CommentListWidget->showCreateForm && $CommentModel::canCreate()) { echo Html::tag('h3', Yii::t('app', 'Add comment'), ['class' => 'comment-title']); echo Comments\widgets\CommentFormWidget::widget(['theme' => $CommentListWidget->theme, 'entity' => $CommentListWidget->entity, 'Comment' => $CommentModel, 'anchor' => $CommentListWidget->anchorAfterUpdate]); }
<li><?php echo Html::a('Отзывы о проекте ' . FA::icon('book'), ['/site/review']); ?> </li> <li><?php echo Html::a('Обратная связь <span class="glyphicon glyphicon-envelope">', ['/feedback/create']); ?> </li> </ul> </span> <span class="pull-right copy">© Dosh <?php echo date('Y'); ?> </span> </div> </footer> <div id="scrollup"> <span class="scrollup">Наверх <?php echo FA::icon('arrow-up '); ?> </span> </div> <?php $this->endBody(); ?> </body> </html> <?php $this->endPage();
/** * @param string $type * @param string $label * @return string */ function sortLink($type, $label) { $label .= ' ' . FA::icon('sort-numeric-desc', ['ng-show' => 'items.sort.order === "-' . $type . '"']); $label .= ' ' . FA::icon('sort-numeric-asc', ['ng-show' => 'items.sort.order === "' . $type . '"']); return Html::a($label, null, ['ng-click' => 'items.sort.setOrder("' . $type . '")']); }
<div class="divider mt2 mb1"></div> <ul> <li class="inline mr1"><a href="#!" class="grey-text text-lighten-1"><?php echo FA::icon('vk')->size(FA::SIZE_2X); ?> </a></li> <li class="inline mr1"><a href="#!" class="grey-text text-lighten-1"><?php echo FA::icon('google-plus')->size(FA::SIZE_2X); ?> </a></li> <li class="inline mr1"><a href="#!" class="grey-text text-lighten-1"><?php echo FA::icon('twitter')->size(FA::SIZE_2X); ?> </a></li> <li class="inline mr1"><a href="mailto::info@tc-alpha.ru" class="grey-text text-lighten-1"><?php echo FA::icon('envelope')->size(FA::SIZE_2X); ?> </a></li> </ul> </div> </div> </div> <div class="footer-copyright"> <div class="container p0 grey-text text-darken-1 center-align"> © <?php echo date('Y'); ?> Торговый дом "Альфа" </div> </div> </footer>
/** * @inheritdoc */ public function menu($Controller) { return [['label' => \Yii::t('cookyii.translation', 'Translation'), 'url' => ['/translation/list/index'], 'icon' => FA::icon('globe'), 'visible' => User()->can(Permissions::ACCESS), 'selected' => $Controller->module->id === 'translation', 'sort' => 9000]]; }
public function testIconAddCssClassCondition() { $this->assertEquals(FA::icon('cog')->addCssClass('highlight', true), '<i class="fa fa-cog highlight"></i>'); $this->setExpectedException('yii\\base\\InvalidConfigException', 'Condition is false'); FA::icon('cog')->addCssClass('highlight', false, true); }
/** * @inheritdoc */ public function menu($Controller) { return [['label' => \Yii::t('cookyii.feed', 'Feeds'), 'url' => ['/feed/list/index'], 'icon' => FA::icon('bars'), 'visible' => User()->can(Feed\backend\Permissions::ACCESS), 'selected' => $Controller->module->id === 'feed', 'sort' => 1000]]; }
echo Html::encode(Yii::$app->id . ' | ' . $this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => 'Админка Lollipops ' . FA::icon('star'), 'brandUrl' => Url::to('/admin'), 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'encodeLabels' => false, 'items' => [['label' => FA::icon('newspaper-o') . ' Новости', 'url' => ['/admin/news']], ['label' => FA::icon('music') . ' Концерты', 'url' => ['/admin/concert']], ['label' => FA::icon('youtube-play') . ' Видео', 'url' => ['/admin/video']], ['label' => FA::icon('floppy-o') . ' Релизы', 'url' => ['/admin/release']], Yii::$app->user->isGuest ? ['label' => FA::icon('sign-in') . ' Авторизация', 'url' => ['/login']] : ['label' => FA::icon('sign-out') . ' Выход (' . Yii::$app->user->identity->username . ')', 'url' => ['/logout'], 'linkOptions' => ['data-method' => 'post']], ['label' => 'Открыть сайт', 'url' => Url::home(), 'linkOptions' => ['target' => '_blank']]]]); NavBar::end(); ?> <div class="container"> <?php echo Breadcrumbs::widget(['homeLink' => ['label' => 'Home', 'url' => Url::to('/admin')], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo $content; ?> </div> </div> <footer class="footer"> <div class="container">
<?php use yii\bootstrap\Html; use yii\helpers\Url; echo Html::a(Html::img($post->photo), Url::to('/post/' . $post->id), ['class' => 'ad-image']) . Html::tag('div', Html::tag('span', Html::tag('div', \rmrevin\yii\fontawesome\FA::icon($post->categoryObject->image), ['style' => 'background-color: ' . $post->categoryObject->color, 'class' => 'category-icon-box']), ['class' => 'ad-category']) . Html::a($post->title, Url::to('/post/' . $post->id)) . Html::tag('div', Html::tag('span', $post->price), ['class' => 'add-price']), ['class' => 'ad-box-content']);
</div> <div class="col-md-1"> <div class="equal"> <?php echo Html::img('@web/images/equal.png', ['class' => 'multiply']); ?> </div> </div> <div class="col-md-3"> <div class="form-group" style="display: inline;" > <div class="input-group"> <input type="number" id="prise" disabled class="form-control" form="buy_coupon" name="prise" min="1" placeholder="Сумма" > <span class="input-group-addon"><?php echo FA::icon('rub'); ?> </span> </div> </div> </div> <div class="col-md-3"> <div class="form-group"> <?php echo Html::submitButton('КУПИТЬ', ['class' => 'btn btn-warning btn-block', 'id' => 'payCoupon']); ?> </div> </div>
$AuthAuthChoiceClients = $authAuthChoice->getClients(); if (!empty($AuthAuthChoiceClients)) { ?> <div class="social-auth-links text-center"> <p>- OR -</p> <?php foreach ($authAuthChoice->getClients() as $Client) { $name = $Client->getName(); $icon = $name; if ($icon === 'live') { $icon = 'windows'; } if ($icon === 'vkontakte') { $icon = 'vk'; } if ($icon === 'yandex') { $icon = 'yahoo'; } $icon = FA::icon($icon); echo Html::a(sprintf('%s Sign in using %s', $icon, $Client->getName()), $authAuthChoice->createClientUrl($Client), ['class' => sprintf('btn btn-block btn-flat btn-social btn-%s', $name)]); } ?> </div> <?php } \yii\authclient\widgets\AuthChoice::end(); ?> <a href="#">I forgot my password</a><br> </div> </div>
/** * Renders menu items. * @param array $items the menu items to be rendered * @param array $options the container HTML attributes * @return string the rendering result. * @throws InvalidConfigException if the label option is not specified in one of the items. */ protected function renderItems($items, $options = []) { $lines = []; foreach ($items as $item) { if (isset($item['visible']) && !$item['visible']) { continue; } if (is_string($item)) { $lines[] = $item; continue; } if (!isset($item['label']) && !isset($item['icon'])) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = ArrayHelper::getValue($item, 'label', ''); if ($encodeLabel) { $label = Html::encode($label); } $icon = ArrayHelper::getValue($item, 'icon'); if ($icon) { $label .= ' ' . FA::icon($icon); } $itemOptions = ArrayHelper::getValue($item, 'options', []); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); $linkOptions['tabindex'] = '-1'; $url = array_key_exists('url', $item) ? $item['url'] : null; if (empty($item['items'])) { if ($url === null) { $content = $label; } else { $content = Html::a($label, $url, $linkOptions); } } else { $submenuOptions = $this->submenuOptions; if (isset($item['submenuOptions'])) { $submenuOptions = array_merge($submenuOptions, $item['submenuOptions']); } $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions); Html::addCssClass($itemOptions, ['widget' => 'dropdown-submenu']); } $lines[] = Html::tag('li', $content, $itemOptions); } return Html::tag('ul', implode("\n", $lines), $options); }