use tests\models\Tree; use Yii; ?> <!-- Sidebar user panel --> <?php if (!\Yii::$app->user->isGuest) { ?> <div class="user-panel"> <div class="pull-left image"> <?php echo \cebe\gravatar\Gravatar::widget(['email' => \Yii::$app->user->identity->profile->gravatar_email === null ? \Yii::$app->user->identity->email : \Yii::$app->user->identity->profile->gravatar_email, 'options' => ['alt' => \Yii::$app->user->identity->username], 'size' => 64]); ?> </div> <div class="pull-left info"> <p><?php echo \Yii::$app->user->identity->username; ?> </p> <a href="#"><i class="fa fa-circle text-success"></i> Online</a> </div> </div> <?php } ?> <?php echo \dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'encodeLabels' => false, 'items' => \yii\helpers\ArrayHelper::merge(['items' => ['label' => 'Backend navigation', 'options' => ['class' => 'header']]], \dmstr\modules\pages\models\Tree::getMenuItems('backend', true, \dmstr\modules\pages\models\Tree::GLOBAL_ACCESS_DOMAIN))]);
?> </div> <div class="pull-left info"> <p><?php echo \Yii::$app->user->identity->username; ?> </p> <a href="#"><i class="fa fa-circle text-success"></i> Online</a> </div> </div> <?php } ?> <?php // prepare menu items, get all modules $adminMenuItems = []; $developerMenuItems = []; foreach (\dmstr\helpers\Metadata::getModules() as $name => $module) { $role = $name; $defaultItem = ['icon' => 'fa fa-cube', 'label' => $name, 'url' => ['/' . $name], 'visible' => Yii::$app->user->can($role) || Yii::$app->user->identity && Yii::$app->user->identity->isAdmin, 'items' => []]; $developerMenuItems[] = $defaultItem; } // create developer menu, when user is admin if (Yii::$app->user->identity && Yii::$app->user->identity->isAdmin) { $adminMenuItems[] = ['url' => '#', 'icon' => 'fa fa-cogs', 'label' => 'Modules', 'items' => $developerMenuItems, 'options' => ['class' => 'treeview'], 'visible' => Yii::$app->user->identity->isAdmin]; } echo \dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => \yii\helpers\ArrayHelper::merge(['items' => ['label' => 'Backend navigation', 'options' => ['class' => 'header']]], \dmstr\modules\pages\models\Tree::getMenuItems('backend', true), $adminMenuItems)]);
<?php /** * @package yii2-cms * @author Yuri Shekhovtsov <*****@*****.**> * @copyright Copyright © Yuri Shekhovtsov, lowbase.ru, 2015 - 2016 * @version 1.0.0 */ use dmstr\widgets\Menu; ?> <aside class="main-sidebar"> <section class="sidebar"> <?php echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => [['label' => 'Панель администрирования', 'options' => ['class' => 'header']], ['label' => 'Рабочий стол', 'icon' => 'glyphicon glyphicon-home', 'url' => ['/admin/index']], ['label' => 'Документы', 'icon' => 'glyphicon glyphicon-file', 'url' => ['/admin-document/document/index']], ['label' => 'Шаблоны', 'icon' => 'glyphicon glyphicon-book', 'url' => ['/admin-document/template/index']], ['label' => 'Пользователи', 'icon' => 'glyphicon glyphicon-user', 'url' => ['/admin-user/user/index']], ['label' => 'Роли и права', 'icon' => 'glyphicon glyphicon-eye-close', 'url' => ['/admin-user/auth-item/index']], ['label' => 'Правила допусков', 'icon' => 'glyphicon glyphicon-lock', 'url' => ['/admin-user/auth-rule/index']], ['label' => 'Страны', 'icon' => 'glyphicon glyphicon-globe', 'url' => ['/admin-user/country/index']], ['label' => 'Города', 'icon' => 'glyphicon glyphicon-stats', 'url' => ['/admin-user/city/index']], ['label' => 'Файловый менеджер', 'icon' => 'glyphicon glyphicon-hdd', 'url' => ['/admin/manager']]]]); ?> </section> </aside>