public function init() { if ($this->name !== null) { $cache_key = 'menu-' . $this->name; $items = Yii::$app->cache->get($cache_key); if ($items === false) { $items = $this->items; $menus = MenuModel::find()->where(['menu' => $this->name])->andWhere('parent_id IS NULL')->orderBy('sort')->all(); foreach ($menus as $name) { $items[] = $this->processItem($name); } $dependency = new \yii\caching\DbDependency(['sql' => 'SELECT MAX(updated_at) FROM ' . MenuModel::tableName()]); Yii::$app->cache->set($cache_key, $items, 86400, $dependency); } $this->items = $items; } parent::init(); }
<section class="forum"> <article class="forum-view forum-panel"> <h1><?php echo $this->title; ?> </h1> <?php if (!Yii::$app->user->isGuest && (Yii::$app->user->can('moder') || Yii::$app->user->can('admin'))) { ?> <?php echo Nav::widget(['options' => ['class' => 'uk-subnav-line uk-margin-top post-header'], 'navClass' => 'uk-subnav', 'encodeLabels' => false, 'items' => [['label' => Yii::t('forum', 'Edit forum'), 'url' => ['/forum/default/forum-create', 'lang' => $lang, 'id' => $forum->id]], ['label' => Yii::t('forum', 'Activate forum'), 'linkOptions' => ['data' => ['method' => 'post']], 'url' => ['/forum/default/forum-activate', 'lang' => $lang, 'id' => $forum->id], 'visible' => $forum->state == $forum::STATE_HIDDEN], ['label' => Yii::t('forum', 'Hide forum'), 'linkOptions' => ['data' => ['method' => 'post']], 'url' => ['/forum/default/forum-delete', 'lang' => $lang, 'id' => $forum->id], 'visible' => $forum->state == $forum::STATE_ACTIVE], ['label' => Yii::t('forum', 'Delete forum'), 'linkOptions' => ['data' => ['method' => 'post', 'confirm' => Yii::t('forum', 'Sure to delete?')]], 'url' => ['/forum/default/forum-delete', 'lang' => $lang, 'id' => $forum->id], 'visible' => $forum->state == $forum::STATE_HIDDEN]]]); ?> <?php } ?> <?php echo $forum->description; ?> </article> <?php Pjax::begin();
?> <?php NavBar::begin(['container' => true, 'offcanvas' => true]); ?> <?php echo Nav::widget(['navbar' => true, 'options' => ['class' => 'uk-hidden-small'], 'items' => [['label' => '<i class="uk-icon-bars"></i> Приложения', 'url' => ['/zooadmin/default/index'], 'items' => ArrayHelper::toArray(Yii::$app->zoo->applications, ['worstinme\\zoo\\models\\Applications' => ['label' => 'title', 'url' => function ($app) { return ['/zooadmin/items/index', 'app' => $app->id]; }]])], ['label' => 'Виджеты', 'url' => ['/widgets/default/index']], ['label' => 'Настройки', 'encodeLabels' => false, 'url' => ['/zooadmin/config/index']], ['label' => 'Файлы', 'encodeLabels' => false, 'url' => ['/zooadmin/elfinder/index']], ['label' => 'Меню', 'url' => ['/zooadmin/menu/index']], ['label' => 'Пользователи', 'encodeLabels' => false, 'url' => ['/useradmin/default/index']]]]); ?> <div class="uk-navbar-flip"> <?php echo Nav::widget(['navbar' => true, 'options' => ['class' => 'uk-hidden-small'], 'items' => [['label' => '<i class="uk-icon-home"></i>', 'encodeLabels' => false, 'url' => '/', 'linkOptions' => ['target' => '_blank']], Yii::$app->user->isGuest ? ['label' => 'Войти', 'url' => ['/user/default/login'], 'items' => [['label' => 'Зарегистрироваться', 'url' => ['/user/default/signup']]]] : ['label' => Yii::$app->user->identity->username, 'url' => ['/user/default/update'], 'items' => [['label' => 'Выйти', 'url' => ['/user/default/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]); ?> </div> <?php NavBar::end(); ?> <section id="content" class="uk-container uk-container-center uk-margin-top"> <?php echo Alert::widget(); ?> <?php echo Breadcrumbs::widget(['homeLink' => ['label' => 'Админка', 'url' => ['/zooadmin/default/index']], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?>
<?php use yii\helpers\Html; use worstinme\uikit\Nav; ?> <?php echo Nav::widget(['id' => 'post-' . $model->id, 'options' => ['class' => 'uk-subnav-line post-header'], 'navClass' => 'uk-subnav', 'items' => [['label' => $model->userAvatar ? Html::img($model->userAvatar) : Html::tag('i', '', ['class' => 'uk-icon-user']), 'options' => ['class' => 'small-avatar']], ['label' => !empty($model->user->name) ? $model->user->name : Yii::t('forum', 'Deleted user'), 'url' => !empty($model->user->url) ? $model->user->url : '#', 'linkOptions' => ['class' => 'author', 'data' => ['pjax' => 0]]], ['label' => Yii::$app->formatter->asRelativeTime($model->created_at)], ['label' => Yii::t('forum', 'Edit post'), 'url' => $model->editUrl, 'visible' => $model->canEdit, 'linkOptions' => ['data' => ['pjax' => 0]]], ['label' => Yii::t('forum', 'Delete post'), 'url' => $model->deleteUrl, 'visible' => $model->canDelete, 'linkOptions' => ['encode' => false, 'data' => ['method' => 'post', 'confirm' => Yii::t('forum', 'Sure, delete post?')]]]]]); ?> <div class="post-content"> <?php echo $model->content; ?> </div>
echo time() - $thread->updated_at < 600000 ? Yii::$app->formatter->asRelativeTime($thread->updated_at) : Yii::$app->formatter->asDate($thread->updated_at, 'php:d.m.Y'); ?> , <?php } ?> <?php echo Yii::t('forum', 'published'); ?> <?php echo time() - $thread->created_at < 600000 ? Yii::$app->formatter->asRelativeTime($thread->created_at) : Yii::$app->formatter->asDate($thread->created_at, 'php:d.m.Y'); ?> <?php echo Nav::widget(['options' => ['class' => 'uk-subnav-line'], 'navClass' => 'uk-subnav', 'items' => [['label' => Yii::t('forum', 'Reply'), 'url' => '#reply', 'linkOptions' => ['data-uk-smooth-scroll' => ""]], ['label' => Yii::t('forum', 'Edit thread'), 'url' => $thread->editUrl, 'visible' => $thread->canEdit, 'linkOptions' => ['data' => ['pjax' => 0]]], ['label' => Yii::t('forum', 'Delete thread'), 'url' => $thread->deleteUrl, 'visible' => $thread->canDelete, 'linkOptions' => ['encode' => false, 'data' => ['pjax' => 0, 'method' => 'post', 'confirm' => Yii::t('forum', 'Sure to delete?')]]], ['label' => Yii::t('forum', $thread->flag ? 'Unlock thread' : 'Lock thread'), 'url' => $thread->lockUrl, 'visible' => $thread->canEdit, 'linkOptions' => ['data' => ['pjax' => 0, 'method' => 'post']]]]]); ?> </div> </div> </article> <?php Pjax::begin(['id' => 'posts', 'timeout' => 5000, 'options' => ['class' => 'uk-margin-top', 'data-uk-observe' => true]]); ?> <?php echo ListView::widget(['dataProvider' => $postProvider, 'options' => ['class' => 'thread-posts uk-margin-top'], 'itemOptions' => ['class' => 'thread-post forum-panel'], 'summaryOptions' => ['class' => 'uk-margin-top'], 'layout' => '{pager}{items}{summary}{pager}', 'itemView' => '_post', 'pager' => ['class' => 'worstinme\\uikit\\widgets\\LinkPager', 'options' => ['class' => 'uk-pagination']]]); ?> <?php
<?php use worstinme\uikit\Nav; ?> <div class="uk-panel uk-panel-box"> <h3 class="uk-panel-title">Пользователи</h3> <?php echo Nav::widget(['options' => ['class' => 'uk-nav-side', 'data-uk-nav' => true], 'items' => [['label' => 'Список пользователей', 'url' => ['/' . Yii::$app->controller->module->id . '/default/index']], '<li class="uk-nav-divider"></li>', ['label' => 'Управление ролями', 'url' => ['/' . Yii::$app->controller->module->id . '/default/role']], ['label' => 'Управление доступами', 'url' => ['/' . Yii::$app->controller->module->id . '/default/permission']], '<li class="uk-nav-divider"></li>', ['label' => 'Добавить правило', 'url' => ['/' . Yii::$app->controller->module->id . '/default/add-permission']], ['label' => 'Добавить роль', 'url' => ['/' . Yii::$app->controller->module->id . '/default/add-role']]]]); ?> </div>
$mainnav = [['label' => '<i class="uk-icon-bars"></i> ' . $app->title, 'url' => ['/' . Yii::$app->controller->module->id . '/items/index', 'app' => $app->id]]]; if ($this->context->module->accessRoles !== null || Yii::$app->user->can('admin') || Yii::$app->user->can('moder') && Yii::$app->user->can('zoo_edit_category')) { $subnav[] = ['label' => '<i class="uk-icon-plus"></i> ' . Yii::t('backend', 'Категория'), 'linkOptions' => ['class' => 'uk-button-success'], 'url' => ['/' . Yii::$app->controller->module->id . '/categories/update', 'app' => $app->id]]; $mainnav = array_merge($mainnav, [['label' => Yii::t('backend', 'Категории'), 'url' => ['/' . Yii::$app->controller->module->id . '/categories/index', 'app' => $app->id]], ['label' => Yii::t('backend', 'Элементы'), 'url' => ['/' . Yii::$app->controller->module->id . '/elements/index', 'app' => $app->id]], ['label' => Yii::t('backend', 'Шаблоны'), 'url' => ['/' . Yii::$app->controller->module->id . '/templates/index', 'app' => $app->id]], ['label' => '<i class="uk-icon-cog"></i>', 'url' => ['/' . Yii::$app->controller->module->id . '/default/update', 'app' => $app->id]]]); } $mainnav[] = ['label' => '<i class="uk-icon-external-link-square"></i>', 'url' => isset($model) && $model !== null ? $model->url : $app->url, 'linkOptions' => ['target' => '_blank']]; if (isset($items) && is_array($items) && count($items)) { $subnav = array_merge($items, $subnav); } ?> <div class="items-filters"> <?php NavBar::begin(['container' => false, 'offcanvas' => false, 'brandUrl' => false, 'options' => ['class' => 'application-nav']]); ?> <?php echo Nav::widget(['navbar' => true, 'options' => ['data-uk-nav' => true], 'items' => $mainnav]); ?> <div class="uk-navbar-flip"> <?php echo Nav::widget(['navbar' => true, 'options' => ['data-uk-nav' => true], 'items' => $subnav]); ?> </div> <?php NavBar::end(); ?> </div>