Commit b6fcf30a068811575e98fcbd356c690acdef2094

Authored by Alexey Boroda
2 parents aace0200 6966d71b

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	backend/views/layouts/main.php
backend/config/main.php
1 <?php 1 <?php
  2 + use yii\web\UrlManager;
  3 +
2 $params = array_merge( 4 $params = array_merge(
3 require( __DIR__ . '/../../common/config/params.php' ), 5 require( __DIR__ . '/../../common/config/params.php' ),
4 require( __DIR__ . '/../../common/config/params-local.php' ), 6 require( __DIR__ . '/../../common/config/params-local.php' ),
@@ -33,7 +35,7 @@ @@ -33,7 +35,7 @@
33 ], 35 ],
34 ], 36 ],
35 'components' => [ 37 'components' => [
36 - 'assetManager' => [ 38 + 'assetManager' => [
37 'bundles' => [ 39 'bundles' => [
38 'yiister\gentelella\assets\ThemeAsset' => [ 40 'yiister\gentelella\assets\ThemeAsset' => [
39 'sourcePath' => '@backend/assets/', 41 'sourcePath' => '@backend/assets/',
@@ -46,22 +48,18 @@ @@ -46,22 +48,18 @@
46 ], 48 ],
47 ], 49 ],
48 ], 50 ],
49 - 'filedb' => [  
50 - 'class' => 'yii2tech\filedb\Connection',  
51 - 'path' => '@common/config',  
52 - ],  
53 - 'imagemanager' => [ 51 + 'imagemanager' => [
54 'class' => 'noam148\imagemanager\components\ImageManagerGetPath', 52 'class' => 'noam148\imagemanager\components\ImageManagerGetPath',
55 'mediaPath' => dirname(dirname(__DIR__)) . '/storage', 53 'mediaPath' => dirname(dirname(__DIR__)) . '/storage',
56 'cachePath' => 'assets/images', 54 'cachePath' => 'assets/images',
57 'useFilename' => true, 55 'useFilename' => true,
58 'absoluteUrl' => false, 56 'absoluteUrl' => false,
59 ], 57 ],
60 - 'request' => [ 58 + 'request' => [
61 'csrfParam' => '_csrf-backend', 59 'csrfParam' => '_csrf-backend',
62 'baseUrl' => '/admin', 60 'baseUrl' => '/admin',
63 ], 61 ],
64 - 'user' => [ 62 + 'user' => [
65 'identityClass' => 'artweb\artbox\core\models\User', 63 'identityClass' => 'artweb\artbox\core\models\User',
66 'enableAutoLogin' => true, 64 'enableAutoLogin' => true,
67 'identityCookie' => [ 65 'identityCookie' => [
@@ -69,11 +67,11 @@ @@ -69,11 +67,11 @@
69 'httpOnly' => true, 67 'httpOnly' => true,
70 ], 68 ],
71 ], 69 ],
72 - 'session' => [ 70 + 'session' => [
73 // this is the name of the session cookie used for login on the backend 71 // this is the name of the session cookie used for login on the backend
74 'name' => 'advanced-backend', 72 'name' => 'advanced-backend',
75 ], 73 ],
76 - 'log' => [ 74 + 'log' => [
77 'traceLevel' => YII_DEBUG ? 3 : 0, 75 'traceLevel' => YII_DEBUG ? 3 : 0,
78 'targets' => [ 76 'targets' => [
79 [ 77 [
@@ -85,10 +83,17 @@ @@ -85,10 +83,17 @@
85 ], 83 ],
86 ], 84 ],
87 ], 85 ],
88 - 'errorHandler' => [ 86 + 'errorHandler' => [
89 'errorAction' => 'site/error', 87 'errorAction' => 'site/error',
90 ], 88 ],
91 - 'urlManager' => [ 89 + 'urlManager' => [
  90 + 'enablePrettyUrl' => true,
  91 + 'showScriptName' => false,
  92 + 'rules' => [],
  93 + ],
  94 + 'urlManagerFrontend' => [
  95 + 'class' => UrlManager::className(),
  96 + 'baseUrl' => '/',
92 'enablePrettyUrl' => true, 97 'enablePrettyUrl' => true,
93 'showScriptName' => false, 98 'showScriptName' => false,
94 'rules' => [], 99 'rules' => [],
backend/views/layouts/main.php
@@ -12,8 +12,11 @@ @@ -12,8 +12,11 @@
12 use hiqdev\assets\icheck\iCheckAsset; 12 use hiqdev\assets\icheck\iCheckAsset;
13 use hiqdev\assets\pnotify\PNotifyAsset; 13 use hiqdev\assets\pnotify\PNotifyAsset;
14 use yii\helpers\Html; 14 use yii\helpers\Html;
  15 + use yii\bootstrap\Html;
  16 + use yii\web\UrlManager;
15 use yii\web\View; 17 use yii\web\View;
16 use yii\widgets\Breadcrumbs; 18 use yii\widgets\Breadcrumbs;
  19 + use yiister\gentelella\widgets\Menu;
17 20
18 yiister\gentelella\assets\Asset::register($this); 21 yiister\gentelella\assets\Asset::register($this);
19 PNotifyAsset::register($this); 22 PNotifyAsset::register($this);
@@ -24,6 +27,7 @@ @@ -24,6 +27,7 @@
24 * @var User $user 27 * @var User $user
25 */ 28 */
26 $user = \Yii::$app->user->identity; 29 $user = \Yii::$app->user->identity;
  30 + $userData = $user->ensureExistance();
27 ?> 31 ?>
28 <?php $this->beginPage(); ?> 32 <?php $this->beginPage(); ?>
29 <!DOCTYPE html> 33 <!DOCTYPE html>
@@ -36,11 +40,6 @@ @@ -36,11 +40,6 @@
36 <?= Html::csrfMetaTags() ?> 40 <?= Html::csrfMetaTags() ?>
37 <title><?= Html::encode($this->title) ?></title> 41 <title><?= Html::encode($this->title) ?></title>
38 <?php $this->head() ?> 42 <?php $this->head() ?>
39 - <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
40 - <!--[if lt IE 9]>  
41 - <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
42 - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>  
43 - <![endif]-->  
44 </head> 43 </head>
45 <body class="nav-md"> 44 <body class="nav-md">
46 <?php $this->beginBody(); ?> 45 <?php $this->beginBody(); ?>
@@ -52,19 +51,55 @@ @@ -52,19 +51,55 @@
52 <div class="left_col scroll-view"> 51 <div class="left_col scroll-view">
53 52
54 <div class="navbar nav_title" style="border: 0;"> 53 <div class="navbar nav_title" style="border: 0;">
55 - <a href="/" class="site_title"><i class="fa fa-rocket"></i> <span>Artbox!</span></a> 54 + <?php
  55 + echo Html::a(
  56 + Html::icon(
  57 + 'rocket',
  58 + [
  59 + 'prefix' => 'fa fa-',
  60 + ]
  61 + ) . Html::tag('span', 'Artbox!'),
  62 + [ 'site/index' ],
  63 + [
  64 + 'class' => 'site_title',
  65 + ]
  66 + );
  67 + ?>
56 </div> 68 </div>
57 <div class="clearfix"></div> 69 <div class="clearfix"></div>
58 70
59 <!-- menu prile quick info --> 71 <!-- menu prile quick info -->
60 <div class="profile"> 72 <div class="profile">
61 <div class="profile_pic"> 73 <div class="profile_pic">
62 - <img src="http://placehold.it/128x128" alt="..." class="img-circle profile_img"> 74 + <?php
  75 + echo Html::a(
  76 + Html::img(
  77 + 'http://placehold.it/128x128',
  78 + [
  79 + 'alt' => $userData->fullname,
  80 + 'title' => \Yii::t('core', 'Change image'),
  81 + 'class' => 'img-circle profile_img',
  82 + ]
  83 + ),
  84 + [ 'profile/index' ]
  85 + )
  86 + ?>
63 </div> 87 </div>
64 <div class="profile_info"> 88 <div class="profile_info">
65 - <span>Welcome,</span>  
66 - <h2>John Doe</h2> 89 + <span><?= \Yii::t('core', 'Welcome,'); ?></span>
  90 + <h2>
  91 + <?php
  92 + echo Html::a(
  93 + $userData->fullname,
  94 + [ 'profile/index' ],
  95 + [
  96 + 'title' => \Yii::t('core', 'Change name'),
  97 + ]
  98 + );
  99 + ?>
  100 + </h2>
67 </div> 101 </div>
  102 + <div class="clearfix"></div>
68 </div> 103 </div>
69 <!-- /menu prile quick info --> 104 <!-- /menu prile quick info -->
70 105
@@ -74,92 +109,50 @@ @@ -74,92 +109,50 @@
74 <div id="sidebar-menu" class="main_menu_side hidden-print main_menu"> 109 <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
75 110
76 <div class="menu_section"> 111 <div class="menu_section">
77 - <h3>General</h3>  
78 - <?= \yiister\gentelella\widgets\Menu::widget(  
79 - [  
80 - "items" => [  
81 - [  
82 - "label" => "Home",  
83 - "url" => "/",  
84 - "icon" => "home",  
85 - ],  
86 - [  
87 - "label" => "Layout",  
88 - "url" => [ "site/layout" ],  
89 - "icon" => "files-o",  
90 - ],  
91 - [  
92 - "label" => "Error page",  
93 - "url" => [ "site/error-page" ],  
94 - "icon" => "close",  
95 - ], 112 + <?php
  113 + $homeLink = [];
  114 + /**
  115 + * @var UrlManager $urlManagerFrontend
  116 + */
  117 + if ($urlManagerFrontend = \Yii::$app->get('urlManagerFrontend', false)) {
  118 + $homeLink = [
96 [ 119 [
97 - "label" => "Widgets",  
98 - "icon" => "th",  
99 - "url" => "#",  
100 - "items" => [  
101 - [  
102 - "label" => "Menu",  
103 - "url" => [ "site/menu" ],  
104 - ],  
105 - [  
106 - "label" => "Panel",  
107 - "url" => [ "site/panel" ],  
108 - ], 120 + 'label' => \Yii::t('core', 'My website'),
  121 + 'url' => $urlManagerFrontend->createUrl([ 'site/index' ]),
  122 + 'icon' => 'home',
  123 + 'template' => '<a href="{url}" target="_blank">{icon}<span>{label}</span>{badge}</a>',
  124 + 'options' => [
  125 + 'class' => 'homepage_link',
109 ], 126 ],
110 ], 127 ],
  128 + ];
  129 + }
  130 + $menuItems = array_merge(
  131 + $homeLink,
  132 + [
111 [ 133 [
112 - "label" => "Badges",  
113 - "url" => "#",  
114 - "icon" => "table",  
115 - "items" => [  
116 - [  
117 - "label" => "Default",  
118 - "url" => "#",  
119 - "badge" => "123",  
120 - ],  
121 - [  
122 - "label" => "Success",  
123 - "url" => "#",  
124 - "badge" => "new",  
125 - "badgeOptions" => [ "class" => "label-success" ],  
126 - ],  
127 - [  
128 - "label" => "Danger",  
129 - "url" => "#",  
130 - "badge" => "!",  
131 - "badgeOptions" => [ "class" => "label-danger" ],  
132 - ],  
133 - ], 134 + 'label' => \Yii::t('core', 'Static pages'),
  135 + 'url' => [ 'page/index' ],
  136 + 'icon' => 'file-text',
  137 + 'active' => function () {
  138 + return \Yii::$app->controller->id === 'page';
  139 + },
134 ], 140 ],
135 [ 141 [
136 - "label" => "Multilevel",  
137 - "url" => "#",  
138 - "icon" => "table",  
139 - "items" => [  
140 - [  
141 - "label" => "Second level 1",  
142 - "url" => "#",  
143 - ],  
144 - [  
145 - "label" => "Second level 2",  
146 - "url" => "#",  
147 - "items" => [  
148 - [  
149 - "label" => "Third level 1",  
150 - "url" => "#",  
151 - ],  
152 - [  
153 - "label" => "Third level 2",  
154 - "url" => "#",  
155 - ],  
156 - ],  
157 - ],  
158 - ], 142 + 'label' => \Yii::t('core', 'SEO'),
  143 + 'url' => [ 'seo/index' ],
  144 + 'icon' => 'bolt',
  145 + 'active' => function () {
  146 + return \Yii::$app->controller->id === 'seo';
  147 + },
159 ], 148 ],
160 - ],  
161 - ]  
162 - ) ?> 149 + ]
  150 + );
  151 + echo Menu::widget(
  152 + [
  153 + "items" => $menuItems,
  154 + ]
  155 + ); ?>
163 </div> 156 </div>
164 157
165 </div> 158 </div>
@@ -219,9 +212,9 @@ @@ -219,9 +212,9 @@
219 </li> 212 </li>
220 </ul> 213 </ul>
221 </li> 214 </li>
222 - <li role="presentation">  
223 - <?= FeedbackWidget::widget(); ?>  
224 - </li> 215 + <li role="presentation">
  216 + <?= FeedbackWidget::widget(); ?>
  217 + </li>
225 </ul> 218 </ul>
226 </nav> 219 </nav>
227 </div> 220 </div>
@@ -252,10 +245,10 @@ @@ -252,10 +245,10 @@
252 245
253 <?= Breadcrumbs::widget( 246 <?= Breadcrumbs::widget(
254 [ 247 [
255 - 'links' => isset($this->params[ 'breadcrumbs' ]) ? $this->params[ 'breadcrumbs' ] : [], 248 + 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [],
256 ] 249 ]
257 ) ?> 250 ) ?>
258 - 251 +
259 <?= $content ?> 252 <?= $content ?>
260 </div> 253 </div>
261 <!-- /page content --> 254 <!-- /page content -->
common/config/main.php
1 <?php 1 <?php
2 -return [  
3 - 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',  
4 - 'components' => [  
5 - 'cache' => [  
6 - 'class' => 'yii\caching\FileCache',  
7 - ],  
8 - 'i18n' => [  
9 - 'translations' => [  
10 - 'core' => [  
11 - 'class' => 'yii\i18n\PhpMessageSource',  
12 - 'basePath' => '@artbox-core/messages', 2 + return [
  3 + 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
  4 + 'components' => [
  5 + 'cache' => [
  6 + 'class' => 'yii\caching\FileCache',
  7 + ],
  8 + 'i18n' => [
  9 + 'translations' => [
  10 + 'core' => [
  11 + 'class' => 'yii\i18n\PhpMessageSource',
  12 + 'basePath' => '@artbox-core/messages',
  13 + ],
13 ], 14 ],
14 ], 15 ],
  16 + 'filedb' => [
  17 + 'class' => 'yii2tech\filedb\Connection',
  18 + 'path' => '@common/config',
  19 + ],
15 ], 20 ],
16 - ],  
17 -]; 21 + ];
common/config/settings.php
@@ -5,5 +5,16 @@ return [ @@ -5,5 +5,16 @@ return [
5 'id' => '1', 5 'id' => '1',
6 'name' => 'Admin321', 6 'name' => 'Admin321',
7 'description' => 'Site administrator', 7 'description' => 'Site administrator',
  8 + 'analytics' => '<!-- Google Analytics -->
  9 +<script>
  10 +(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
  11 +(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  12 +m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  13 +})(window,document,\'script\',\'https://www.google-analytics.com/analytics.js\',\'ga\');
  14 +
  15 +ga(\'create\', \'UA-XXXXX-Y\', \'auto\');
  16 +ga(\'send\', \'pageview\');
  17 +</script>
  18 +<!-- End Google Analytics -->',
8 ], 19 ],
9 ]; 20 ];
10 \ No newline at end of file 21 \ No newline at end of file
frontend/views/layouts/main.php
1 <?php 1 <?php
2 -  
3 -/* @var $this \yii\web\View */  
4 -/* @var $content string */  
5 -  
6 -use yii\helpers\Html;  
7 -use yii\bootstrap\Nav;  
8 -use yii\bootstrap\NavBar;  
9 -use yii\widgets\Breadcrumbs;  
10 -use frontend\assets\AppAsset;  
11 -use common\widgets\Alert;  
12 -  
13 -AppAsset::register($this); 2 +
  3 + /* @var $this \yii\web\View */
  4 + /* @var $content string */
  5 +
  6 + use artweb\artbox\core\models\Settings;
  7 + use artweb\artbox\core\models\User;
  8 + use yii\helpers\Html;
  9 + use yii\bootstrap\Nav;
  10 + use yii\bootstrap\NavBar;
  11 + use yii\widgets\Breadcrumbs;
  12 + use frontend\assets\AppAsset;
  13 + use common\widgets\Alert;
  14 +
  15 + AppAsset::register($this);
  16 + /**
  17 + * @var User $user
  18 + */
  19 + $user = \Yii::$app->user->identity;
14 ?> 20 ?>
15 <?php $this->beginPage() ?> 21 <?php $this->beginPage() ?>
16 <!DOCTYPE html> 22 <!DOCTYPE html>
17 <html lang="<?= Yii::$app->language ?>"> 23 <html lang="<?= Yii::$app->language ?>">
18 -<head>  
19 - <meta charset="<?= Yii::$app->charset ?>">  
20 - <meta name="viewport" content="width=device-width, initial-scale=1">  
21 - <?= Html::csrfMetaTags() ?>  
22 - <title><?= Html::encode($this->title) ?></title>  
23 - <?php $this->head() ?>  
24 -</head>  
25 -<body>  
26 -<?php $this->beginBody() ?>  
27 -  
28 -<div class="wrap">  
29 - <?php  
30 - NavBar::begin([  
31 - 'brandLabel' => 'My Company',  
32 - 'brandUrl' => Yii::$app->homeUrl,  
33 - 'options' => [  
34 - 'class' => 'navbar-inverse navbar-fixed-top',  
35 - ],  
36 - ]);  
37 - $menuItems = [  
38 - ['label' => 'Home', 'url' => ['/site/index']],  
39 - ['label' => 'About', 'url' => ['/site/about']],  
40 - ['label' => 'Contact', 'url' => ['/site/contact']],  
41 - ];  
42 - if (Yii::$app->user->isGuest) {  
43 - $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];  
44 - $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];  
45 - } else {  
46 - $menuItems[] = '<li>'  
47 - . Html::beginForm(['/site/logout'], 'post')  
48 - . Html::submitButton(  
49 - 'Logout (' . Yii::$app->user->identity->username . ')',  
50 - ['class' => 'btn btn-link logout']  
51 - )  
52 - . Html::endForm()  
53 - . '</li>';  
54 - }  
55 - echo Nav::widget([  
56 - 'options' => ['class' => 'navbar-nav navbar-right'],  
57 - 'items' => $menuItems,  
58 - ]);  
59 - NavBar::end();  
60 - ?>  
61 -  
62 - <div class="container">  
63 - <?= Breadcrumbs::widget([  
64 - 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],  
65 - ]) ?>  
66 - <?= Alert::widget() ?>  
67 - <?= $content ?>  
68 - </div>  
69 -</div>  
70 -  
71 -<footer class="footer">  
72 - <div class="container">  
73 - <p class="pull-left">&copy; My Company <?= date('Y') ?></p>  
74 -  
75 - <p class="pull-right"><?= Yii::powered() ?></p>  
76 - </div>  
77 -</footer>  
78 -  
79 -<?php $this->endBody() ?>  
80 -</body> 24 + <head>
  25 + <meta charset="<?= Yii::$app->charset ?>">
  26 + <meta name="viewport" content="width=device-width, initial-scale=1">
  27 + <?= Html::csrfMetaTags() ?>
  28 + <title><?= Html::encode($this->title) ?></title>
  29 + <?php $this->head() ?>
  30 + </head>
  31 + <body>
  32 + <?php $this->beginBody() ?>
  33 +
  34 + <div class="wrap">
  35 + <?php
  36 + NavBar::begin(
  37 + [
  38 + 'brandLabel' => 'My Company',
  39 + 'brandUrl' => Yii::$app->homeUrl,
  40 + 'options' => [
  41 + 'class' => 'navbar-inverse navbar-fixed-top',
  42 + ],
  43 + ]
  44 + );
  45 + $menuItems = [
  46 + [
  47 + 'label' => 'Home',
  48 + 'url' => [ '/site/index' ],
  49 + ],
  50 + [
  51 + 'label' => 'About',
  52 + 'url' => [ '/site/about' ],
  53 + ],
  54 + [
  55 + 'label' => 'Contact',
  56 + 'url' => [ '/site/contact' ],
  57 + ],
  58 + ];
  59 + if (Yii::$app->user->isGuest) {
  60 + $menuItems[] = [
  61 + 'label' => 'Signup',
  62 + 'url' => [ '/site/signup' ],
  63 + ];
  64 + $menuItems[] = [
  65 + 'label' => 'Login',
  66 + 'url' => [ '/site/login' ],
  67 + ];
  68 + } else {
  69 + $menuItems[] = '<li>' . Html::beginForm([ '/site/logout' ], 'post') . Html::submitButton(
  70 + 'Logout (' . $user->username . ')',
  71 + [ 'class' => 'btn btn-link logout' ]
  72 + ) . Html::endForm() . '</li>';
  73 + }
  74 + echo Nav::widget(
  75 + [
  76 + 'options' => [ 'class' => 'navbar-nav navbar-right' ],
  77 + 'items' => $menuItems,
  78 + ]
  79 + );
  80 + NavBar::end();
  81 + ?>
  82 +
  83 + <div class="container">
  84 + <?= Breadcrumbs::widget(
  85 + [
  86 + 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [],
  87 + ]
  88 + ) ?>
  89 + <?= Alert::widget() ?>
  90 + <?= $content ?>
  91 + </div>
  92 + </div>
  93 +
  94 + <footer class="footer">
  95 + <div class="container">
  96 + <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
  97 +
  98 + <p class="pull-right"><?= Yii::powered() ?></p>
  99 + </div>
  100 + </footer>
  101 +
  102 + <?php $this->endBody() ?>
  103 + <?php
  104 + $settings = Settings::getInstance();
  105 + if (!empty( $settings->analytics )) {
  106 + echo $settings->analytics;
  107 + }
  108 + ?>
  109 + </body>
81 </html> 110 </html>
82 <?php $this->endPage() ?> 111 <?php $this->endPage() ?>