Commit 6966d71b61a506c836e4286239581c202d57d3f0
1 parent
15047df7
Makeup
Showing
5 changed files
with
235 additions
and
194 deletions
Show diff stats
backend/config/main.php
1 | 1 | <?php |
2 | + use yii\web\UrlManager; | |
3 | + | |
2 | 4 | $params = array_merge( |
3 | 5 | require( __DIR__ . '/../../common/config/params.php' ), |
4 | 6 | require( __DIR__ . '/../../common/config/params-local.php' ), |
... | ... | @@ -33,7 +35,7 @@ |
33 | 35 | ], |
34 | 36 | ], |
35 | 37 | 'components' => [ |
36 | - 'assetManager' => [ | |
38 | + 'assetManager' => [ | |
37 | 39 | 'bundles' => [ |
38 | 40 | 'yiister\gentelella\assets\ThemeAsset' => [ |
39 | 41 | 'sourcePath' => '@backend/assets/', |
... | ... | @@ -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 | 52 | 'class' => 'noam148\imagemanager\components\ImageManagerGetPath', |
55 | 53 | 'mediaPath' => dirname(dirname(__DIR__)) . '/storage', |
56 | 54 | 'cachePath' => 'assets/images', |
57 | 55 | 'useFilename' => true, |
58 | 56 | 'absoluteUrl' => false, |
59 | 57 | ], |
60 | - 'request' => [ | |
58 | + 'request' => [ | |
61 | 59 | 'csrfParam' => '_csrf-backend', |
62 | 60 | 'baseUrl' => '/admin', |
63 | 61 | ], |
64 | - 'user' => [ | |
62 | + 'user' => [ | |
65 | 63 | 'identityClass' => 'artweb\artbox\core\models\User', |
66 | 64 | 'enableAutoLogin' => true, |
67 | 65 | 'identityCookie' => [ |
... | ... | @@ -69,11 +67,11 @@ |
69 | 67 | 'httpOnly' => true, |
70 | 68 | ], |
71 | 69 | ], |
72 | - 'session' => [ | |
70 | + 'session' => [ | |
73 | 71 | // this is the name of the session cookie used for login on the backend |
74 | 72 | 'name' => 'advanced-backend', |
75 | 73 | ], |
76 | - 'log' => [ | |
74 | + 'log' => [ | |
77 | 75 | 'traceLevel' => YII_DEBUG ? 3 : 0, |
78 | 76 | 'targets' => [ |
79 | 77 | [ |
... | ... | @@ -85,10 +83,17 @@ |
85 | 83 | ], |
86 | 84 | ], |
87 | 85 | ], |
88 | - 'errorHandler' => [ | |
86 | + 'errorHandler' => [ | |
89 | 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 | 97 | 'enablePrettyUrl' => true, |
93 | 98 | 'showScriptName' => false, |
94 | 99 | 'rules' => [], | ... | ... |
backend/views/layouts/main.php
... | ... | @@ -9,9 +9,11 @@ |
9 | 9 | use artweb\artbox\core\models\User; |
10 | 10 | use artweb\artbox\core\widgets\FeedbackWidget; |
11 | 11 | use artweb\artbox\core\widgets\FlashWidget; |
12 | - use yii\helpers\Html; | |
12 | + use yii\bootstrap\Html; | |
13 | + use yii\web\UrlManager; | |
13 | 14 | use yii\web\View; |
14 | 15 | use yii\widgets\Breadcrumbs; |
16 | + use yiister\gentelella\widgets\Menu; | |
15 | 17 | |
16 | 18 | yiister\gentelella\assets\Asset::register($this); |
17 | 19 | ArtboxCoreAsset::register($this); |
... | ... | @@ -19,6 +21,7 @@ |
19 | 21 | * @var User $user |
20 | 22 | */ |
21 | 23 | $user = \Yii::$app->user->identity; |
24 | + $userData = $user->ensureExistance(); | |
22 | 25 | ?> |
23 | 26 | <?php $this->beginPage(); ?> |
24 | 27 | <!DOCTYPE html> |
... | ... | @@ -31,11 +34,6 @@ |
31 | 34 | <?= Html::csrfMetaTags() ?> |
32 | 35 | <title><?= Html::encode($this->title) ?></title> |
33 | 36 | <?php $this->head() ?> |
34 | - <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | |
35 | - <!--[if lt IE 9]> | |
36 | - <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | |
37 | - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |
38 | - <![endif]--> | |
39 | 37 | </head> |
40 | 38 | <body class="nav-md"> |
41 | 39 | <?php $this->beginBody(); ?> |
... | ... | @@ -47,19 +45,55 @@ |
47 | 45 | <div class="left_col scroll-view"> |
48 | 46 | |
49 | 47 | <div class="navbar nav_title" style="border: 0;"> |
50 | - <a href="/" class="site_title"><i class="fa fa-rocket"></i> <span>Artbox!</span></a> | |
48 | + <?php | |
49 | + echo Html::a( | |
50 | + Html::icon( | |
51 | + 'rocket', | |
52 | + [ | |
53 | + 'prefix' => 'fa fa-', | |
54 | + ] | |
55 | + ) . Html::tag('span', 'Artbox!'), | |
56 | + [ 'site/index' ], | |
57 | + [ | |
58 | + 'class' => 'site_title', | |
59 | + ] | |
60 | + ); | |
61 | + ?> | |
51 | 62 | </div> |
52 | 63 | <div class="clearfix"></div> |
53 | 64 | |
54 | 65 | <!-- menu prile quick info --> |
55 | 66 | <div class="profile"> |
56 | 67 | <div class="profile_pic"> |
57 | - <img src="http://placehold.it/128x128" alt="..." class="img-circle profile_img"> | |
68 | + <?php | |
69 | + echo Html::a( | |
70 | + Html::img( | |
71 | + 'http://placehold.it/128x128', | |
72 | + [ | |
73 | + 'alt' => $userData->fullname, | |
74 | + 'title' => \Yii::t('core', 'Change image'), | |
75 | + 'class' => 'img-circle profile_img', | |
76 | + ] | |
77 | + ), | |
78 | + [ 'profile/index' ] | |
79 | + ) | |
80 | + ?> | |
58 | 81 | </div> |
59 | 82 | <div class="profile_info"> |
60 | - <span>Welcome,</span> | |
61 | - <h2>John Doe</h2> | |
83 | + <span><?= \Yii::t('core', 'Welcome,'); ?></span> | |
84 | + <h2> | |
85 | + <?php | |
86 | + echo Html::a( | |
87 | + $userData->fullname, | |
88 | + [ 'profile/index' ], | |
89 | + [ | |
90 | + 'title' => \Yii::t('core', 'Change name'), | |
91 | + ] | |
92 | + ); | |
93 | + ?> | |
94 | + </h2> | |
62 | 95 | </div> |
96 | + <div class="clearfix"></div> | |
63 | 97 | </div> |
64 | 98 | <!-- /menu prile quick info --> |
65 | 99 | |
... | ... | @@ -69,92 +103,50 @@ |
69 | 103 | <div id="sidebar-menu" class="main_menu_side hidden-print main_menu"> |
70 | 104 | |
71 | 105 | <div class="menu_section"> |
72 | - <h3>General</h3> | |
73 | - <?= \yiister\gentelella\widgets\Menu::widget( | |
74 | - [ | |
75 | - "items" => [ | |
76 | - [ | |
77 | - "label" => "Home", | |
78 | - "url" => "/", | |
79 | - "icon" => "home", | |
80 | - ], | |
81 | - [ | |
82 | - "label" => "Layout", | |
83 | - "url" => [ "site/layout" ], | |
84 | - "icon" => "files-o", | |
85 | - ], | |
86 | - [ | |
87 | - "label" => "Error page", | |
88 | - "url" => [ "site/error-page" ], | |
89 | - "icon" => "close", | |
90 | - ], | |
106 | + <?php | |
107 | + $homeLink = []; | |
108 | + /** | |
109 | + * @var UrlManager $urlManagerFrontend | |
110 | + */ | |
111 | + if ($urlManagerFrontend = \Yii::$app->get('urlManagerFrontend', false)) { | |
112 | + $homeLink = [ | |
91 | 113 | [ |
92 | - "label" => "Widgets", | |
93 | - "icon" => "th", | |
94 | - "url" => "#", | |
95 | - "items" => [ | |
96 | - [ | |
97 | - "label" => "Menu", | |
98 | - "url" => [ "site/menu" ], | |
99 | - ], | |
100 | - [ | |
101 | - "label" => "Panel", | |
102 | - "url" => [ "site/panel" ], | |
103 | - ], | |
114 | + 'label' => \Yii::t('core', 'My website'), | |
115 | + 'url' => $urlManagerFrontend->createUrl([ 'site/index' ]), | |
116 | + 'icon' => 'home', | |
117 | + 'template' => '<a href="{url}" target="_blank">{icon}<span>{label}</span>{badge}</a>', | |
118 | + 'options' => [ | |
119 | + 'class' => 'homepage_link', | |
104 | 120 | ], |
105 | 121 | ], |
122 | + ]; | |
123 | + } | |
124 | + $menuItems = array_merge( | |
125 | + $homeLink, | |
126 | + [ | |
106 | 127 | [ |
107 | - "label" => "Badges", | |
108 | - "url" => "#", | |
109 | - "icon" => "table", | |
110 | - "items" => [ | |
111 | - [ | |
112 | - "label" => "Default", | |
113 | - "url" => "#", | |
114 | - "badge" => "123", | |
115 | - ], | |
116 | - [ | |
117 | - "label" => "Success", | |
118 | - "url" => "#", | |
119 | - "badge" => "new", | |
120 | - "badgeOptions" => [ "class" => "label-success" ], | |
121 | - ], | |
122 | - [ | |
123 | - "label" => "Danger", | |
124 | - "url" => "#", | |
125 | - "badge" => "!", | |
126 | - "badgeOptions" => [ "class" => "label-danger" ], | |
127 | - ], | |
128 | - ], | |
128 | + 'label' => \Yii::t('core', 'Static pages'), | |
129 | + 'url' => [ 'page/index' ], | |
130 | + 'icon' => 'file-text', | |
131 | + 'active' => function () { | |
132 | + return \Yii::$app->controller->id === 'page'; | |
133 | + }, | |
129 | 134 | ], |
130 | 135 | [ |
131 | - "label" => "Multilevel", | |
132 | - "url" => "#", | |
133 | - "icon" => "table", | |
134 | - "items" => [ | |
135 | - [ | |
136 | - "label" => "Second level 1", | |
137 | - "url" => "#", | |
138 | - ], | |
139 | - [ | |
140 | - "label" => "Second level 2", | |
141 | - "url" => "#", | |
142 | - "items" => [ | |
143 | - [ | |
144 | - "label" => "Third level 1", | |
145 | - "url" => "#", | |
146 | - ], | |
147 | - [ | |
148 | - "label" => "Third level 2", | |
149 | - "url" => "#", | |
150 | - ], | |
151 | - ], | |
152 | - ], | |
153 | - ], | |
136 | + 'label' => \Yii::t('core', 'SEO'), | |
137 | + 'url' => [ 'seo/index' ], | |
138 | + 'icon' => 'bolt', | |
139 | + 'active' => function () { | |
140 | + return \Yii::$app->controller->id === 'seo'; | |
141 | + }, | |
154 | 142 | ], |
155 | - ], | |
156 | - ] | |
157 | - ) ?> | |
143 | + ] | |
144 | + ); | |
145 | + echo Menu::widget( | |
146 | + [ | |
147 | + "items" => $menuItems, | |
148 | + ] | |
149 | + ); ?> | |
158 | 150 | </div> |
159 | 151 | |
160 | 152 | </div> |
... | ... | @@ -214,9 +206,9 @@ |
214 | 206 | </li> |
215 | 207 | </ul> |
216 | 208 | </li> |
217 | - <li role="presentation"> | |
218 | - <?= FeedbackWidget::widget(); ?> | |
219 | - </li> | |
209 | + <li role="presentation"> | |
210 | + <?= FeedbackWidget::widget(); ?> | |
211 | + </li> | |
220 | 212 | </ul> |
221 | 213 | </nav> |
222 | 214 | </div> |
... | ... | @@ -247,10 +239,10 @@ |
247 | 239 | |
248 | 240 | <?= Breadcrumbs::widget( |
249 | 241 | [ |
250 | - 'links' => isset($this->params[ 'breadcrumbs' ]) ? $this->params[ 'breadcrumbs' ] : [], | |
242 | + 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [], | |
251 | 243 | ] |
252 | 244 | ) ?> |
253 | - | |
245 | + | |
254 | 246 | <?= $content ?> |
255 | 247 | </div> |
256 | 248 | <!-- /page content --> | ... | ... |
common/config/main.php
1 | 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 | 'id' => '1', |
6 | 6 | 'name' => 'Admin321', |
7 | 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 | 21 | \ No newline at end of file | ... | ... |
frontend/views/layouts/main.php
1 | 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 | 21 | <?php $this->beginPage() ?> |
16 | 22 | <!DOCTYPE html> |
17 | 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">© 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">© 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 | 110 | </html> |
82 | 111 | <?php $this->endPage() ?> | ... | ... |