Browse Source

Admin menu fix

master
Egorka 6 years ago
parent
commit
ec14ba429c
  1. 138
      backend/views/layouts/left.php
  2. 16
      common/bootstrap/SetUp.php

138
backend/views/layouts/left.php

@ -15,7 +15,8 @@ $model = new SearchForm();
<!-- Sidebar user panel --> <!-- Sidebar user panel -->
<div class="user-panel"> <div class="user-panel">
<div class="pull-left image"> <div class="pull-left image">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>" class="img-circle" alt="<?= Yii::$app->user->identity->user->username ?>"/> <img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>" class="img-circle"
alt="<?= Yii::$app->user->identity->user->username ?>"/>
</div> </div>
<div class="pull-left info"> <div class="pull-left info">
<p><?= Yii::$app->user->identity->user->username ?></p> <p><?= Yii::$app->user->identity->user->username ?></p>
@ -41,7 +42,7 @@ $model = new SearchForm();
<?= $form->field($model, 'query', [ <?= $form->field($model, 'query', [
'addon' => [ 'addon' => [
'append' => [ 'append' => [
'content' => Html::button('<i class="fa fa-search"></i>', ['class'=>'btn btn-flat', 'id' => 'search-btn']), 'content' => Html::button('<i class="fa fa-search"></i>', ['class' => 'btn btn-flat', 'id' => 'search-btn']),
'asButton' => true 'asButton' => true
] ]
], ],
@ -53,7 +54,7 @@ $model = new SearchForm();
<?= dmstr\widgets\Menu::widget( <?= dmstr\widgets\Menu::widget(
[ [
'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'], 'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => \yii\helpers\ArrayHelper::merge([ 'items' => \yii\helpers\ArrayHelper::merge([
['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']], ['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']],
@ -61,7 +62,8 @@ $model = new SearchForm();
'label' => Yii::t('dashboard', 'Dashboard'), 'label' => Yii::t('dashboard', 'Dashboard'),
'icon' => 'dashboard', 'icon' => 'dashboard',
'url' => ['/site/index'], 'url' => ['/site/index'],
'active' => $this->context->id == '/site/index'], 'active' => $this->context->id == '/site/index'
],
[ [
'label' => Yii::t('user', 'Users'), 'label' => Yii::t('user', 'Users'),
@ -71,22 +73,53 @@ $model = new SearchForm();
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement'), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement'),
], ],
['label' => Yii::t('user', 'Access Rules'), 'icon' => 'lock', 'items' => [ [
['label' => Yii::t('user', 'Roles'), 'icon' => 'caret-right', 'url' => ['/role/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'role'], 'label' => Yii::t('user', 'Access Rules'),
['label' => Yii::t('user', 'Permissions'), 'icon' => 'caret-right', 'url' => ['/permission/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'permission'], 'icon' => 'lock',
], 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement')], 'items' => [
[
'label' => Yii::t('user', 'Roles'),
'icon' => 'caret-right',
'url' => ['/role/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'role'
],
[
'label' => Yii::t('user', 'Permissions'),
'icon' => 'caret-right',
'url' => ['/permission/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'permission'
],
],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement')
],
[ [
'label' => Yii::t('menu', 'Menu'), 'label' => Yii::t('menu', 'Menu'),
'icon' => 'bars', 'url' => ['/menu/index'], 'icon' => 'bars',
'url' => ['/menu/index'],
'active' => $this->context->id == 'menu', 'active' => $this->context->id == 'menu',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('MenuManagement'), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('MenuManagement'),
], ],
['label' => Yii::t('main', 'Modules'), 'icon' => 'cubes', 'items' => [ [
['label' => Yii::t('main', 'Modules'), 'icon' => 'caret-right', 'url' => ['/module/list'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/list'], 'label' => Yii::t('main', 'Modules'),
['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'], 'icon' => 'cubes',
], 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('ModuleManagement')], 'items' => [
[
'label' => Yii::t('main', 'Modules'),
'icon' => 'caret-right',
'url' => ['/module/list'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/list'
],
[
'label' => Yii::t('main', 'Find modules'),
'icon' => 'caret-right',
'url' => ['/module/search'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'
],
],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('ModuleManagement')
],
/*[ /*[
'label' => Yii::t('pages', 'Pages'), 'label' => Yii::t('pages', 'Pages'),
@ -95,31 +128,80 @@ $model = new SearchForm();
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PagesManagement'), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PagesManagement'),
],*/ ],*/
['label' => Yii::t('post', 'Posts'), 'icon' => 'newspaper-o', 'items' => array_merge( [
array_map(function(\core\entities\post\PostType $type) { 'label' => Yii::t('post', 'Posts'),
return ['label' => $type->plural, 'icon' => 'caret-right', 'items' => [ 'icon' => 'newspaper-o',
['label' => Yii::t('post', 'Categories'), 'icon' => 'caret-right', 'url' => ['/post/category', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/category' && \Yii::$app->request->get('tid') == $type->id], 'items' => array_merge(
['label' => $type->plural, 'icon' => 'caret-right', 'url' => ['/post/post', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/post' && \Yii::$app->request->get('tid') == $type->id], array_map(function (\core\entities\post\PostType $type) {
['label' => Yii::t('post', 'Tags'), 'icon' => 'caret-right', 'url' => ['/post/tag', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/tag' && \Yii::$app->request->get('tid') == $type->id], return [
]]; 'label' => $type->plural,
'icon' => 'caret-right',
'items' => [
[
'label' => Yii::t('post', 'Categories'),
'icon' => 'caret-right',
'url' => ['/post/category', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/category' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => $type->plural,
'icon' => 'caret-right',
'url' => ['/post/post', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/post' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => Yii::t('post', 'Tags'),
'icon' => 'caret-right',
'url' => ['/post/tag', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/tag' && \Yii::$app->request->get('tid') == $type->id
],
]
];
}, \core\entities\post\PostType::find()->all()), }, \core\entities\post\PostType::find()->all()),
[['label' => Yii::t('post', 'Comments'), 'icon' => 'caret-right', 'url' => ['/post/comment'], 'active' => \Yii::$app->controller->getUniqueId() == 'post/comment']], [
[['label' => Yii::t('post', 'Types'), 'icon' => 'caret-right', 'url' => ['/post/type'], 'active' => \Yii::$app->controller->getUniqueId() == 'post/type']] [
), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PostManagement')], 'label' => Yii::t('post', 'Comments'),
'icon' => 'caret-right',
'url' => ['/post/comment'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/comment'
]
],
[
[
'label' => Yii::t('post', 'Types'),
'icon' => 'caret-right',
'url' => ['/post/type'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/type'
]
]
),
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PostManagement')
],
[ [
'label' => Yii::t('slider', 'Slider'), 'label' => Yii::t('slider', 'Slider'),
'icon' => 'retweet', 'url' => ['/slider/index'], 'icon' => 'retweet',
'url' => ['/slider/index'],
'active' => $this->context->id == 'slider', 'active' => $this->context->id == 'slider',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SliderManagement'), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SliderManagement'),
], ],
['label' => Yii::t('main', 'Settings'), 'icon' => 'cog', 'items' => [ [
['label' => Yii::t('main', 'Settings List'), 'icon' => 'caret-right', 'url' => ['/settings/list/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'settings/list'], 'label' => Yii::t('main', 'Settings'),
'icon' => 'cog',
'items' => [
[
'label' => Yii::t('main', 'Settings List'),
'icon' => 'caret-right',
'url' => ['/settings/list/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'settings/list'
],
//['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'], //['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'],
], 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SettingsManagement')], ],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SettingsManagement')
],
], Yii::$app->params['adminMenu']), ], (isset(Yii::$app->params['adminMenu']) && is_array(Yii::$app->params['adminMenu']) ? Yii::$app->params['adminMenu'] : [])),
] ]
) ?> ) ?>

16
common/bootstrap/SetUp.php

@ -7,6 +7,7 @@ namespace common\bootstrap;
//use core\components\modules\ModuleInterface; //use core\components\modules\ModuleInterface;
use common\modules\languages\entities\Language; use common\modules\languages\entities\Language;
use core\entities\ModuleRecord; use core\entities\ModuleRecord;
//use League\Flysystem\Adapter\Ftp; //use League\Flysystem\Adapter\Ftp;
//use League\Flysystem\Filesystem; //use League\Flysystem\Filesystem;
//use shop\cart\Cart; //use shop\cart\Cart;
@ -17,16 +18,19 @@ use core\dispatchers\AsyncEventDispatcher;
use core\dispatchers\DeferredEventDispatcher; use core\dispatchers\DeferredEventDispatcher;
use core\dispatchers\EventDispatcher; use core\dispatchers\EventDispatcher;
use core\dispatchers\SimpleEventDispatcher; use core\dispatchers\SimpleEventDispatcher;
//use core\entities\behaviors\FlySystemImageUploadBehavior; //use core\entities\behaviors\FlySystemImageUploadBehavior;
//use shop\entities\Shop\Product\events\ProductAppearedInStock; //use shop\entities\Shop\Product\events\ProductAppearedInStock;
use core\jobs\AsyncEventJobHandler; use core\jobs\AsyncEventJobHandler;
use core\listeners\user\UserSignupConfirmedListener; use core\listeners\user\UserSignupConfirmedListener;
use core\listeners\user\UserSignupRequestedListener; use core\listeners\user\UserSignupRequestedListener;
//use shop\repositories\events\EntityPersisted; //use shop\repositories\events\EntityPersisted;
//use shop\repositories\events\EntityRemoved; //use shop\repositories\events\EntityRemoved;
use core\services\newsletter\FakeSubscribe; use core\services\newsletter\FakeSubscribe;
use core\services\newsletter\MailChimp; use core\services\newsletter\MailChimp;
use core\services\newsletter\Newsletter; use core\services\newsletter\Newsletter;
//use shop\services\sms\LoggedSender; //use shop\services\sms\LoggedSender;
//use shop\services\sms\SmsRu; //use shop\services\sms\SmsRu;
//use shop\services\sms\SmsSender; //use shop\services\sms\SmsSender;
@ -144,16 +148,15 @@ class SetUp implements BootstrapInterface
if (\Yii::$app->moduleManager->isTableExist('{{%languages}}') && file_exists(Yii::getAlias('@common/modules/languages/LanguagesModule.php'))) { if (\Yii::$app->moduleManager->isTableExist('{{%languages}}') && file_exists(Yii::getAlias('@common/modules/languages/LanguagesModule.php'))) {
$language = Language::find()->active()->default()->one(); $language = Language::find()->active()->default()->one();
Yii::$app->params['defaultLanguage'] = $language ? $language->name : 'ru'; Yii::$app->params['defaultLanguage'] = $language ? $language->name : 'ru';
Yii::$app->params['translatedLanguages'] = ArrayHelper::map( Language::find()->active()->all(), 'name', 'title' ); Yii::$app->params['translatedLanguages'] = ArrayHelper::map(Language::find()->active()->all(), 'name', 'title');
} } else {
else {
Yii::$app->params['defaultLanguage'] = 'en'; Yii::$app->params['defaultLanguage'] = 'en';
Yii::$app->params['translatedLanguages'] = ['en']; Yii::$app->params['translatedLanguages'] = ['en'];
} }
// Set backend languages // Set backend languages
if (basename($app->getBasePath()) === 'backend') { if (basename($app->getBasePath()) === 'backend') {
$app->language = ! $app->user->isGuest && $app->user->identity->user->backend_language ? $app->user->identity->user->backend_language : Yii::$app->params['defaultLanguage']; $app->language = !$app->user->isGuest && $app->user->identity->user->backend_language ? $app->user->identity->user->backend_language : Yii::$app->params['defaultLanguage'];
$app->params['frontendLanguage'] = Yii::$app->session->get('frontendLanguage', Yii::$app->params['defaultLanguage']); $app->params['frontendLanguage'] = Yii::$app->session->get('frontendLanguage', Yii::$app->params['defaultLanguage']);
} }
@ -166,8 +169,7 @@ class SetUp implements BootstrapInterface
]); ]);
Yii::$app->getModule($module->name)->bootstrap(Yii::$app); Yii::$app->getModule($module->name)->bootstrap(Yii::$app);
} }
} } else { // connect all existing modules
else { // connect all existing modules
$this->connectExistingModules(); $this->connectExistingModules();
} }
} }
@ -180,7 +182,7 @@ class SetUp implements BootstrapInterface
Yii::$app->setModule($module['name'], [ Yii::$app->setModule($module['name'], [
'class' => 'common\modules\\' . $module['name'] . '\\' . $module['module'], 'class' => 'common\modules\\' . $module['name'] . '\\' . $module['module'],
]); ]);
Yii::$app->getModule( $module['name'] )->bootstrap( Yii::$app ); Yii::$app->getModule($module['name'])->bootstrap(Yii::$app);
} }
} }
} }
Loading…
Cancel
Save