Commit 3e16e21886b55d3b4969ca96a52373e94ddfb433

Authored by Yarik
1 parent 3bc0d351

Admin fixes

backend/config/main.php
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 ], 35 ],
36 'components' => [ 36 'components' => [
37 'assetManager' => [ 37 'assetManager' => [
38 - 'bundles' => [ 38 + 'bundles' => [
39 'yiister\gentelella\assets\ThemeAsset' => [ 39 'yiister\gentelella\assets\ThemeAsset' => [
40 'basePath' => '@webroot', 40 'basePath' => '@webroot',
41 'baseUrl' => '@web', 41 'baseUrl' => '@web',
@@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
47 ], 47 ],
48 ], 48 ],
49 ], 49 ],
  50 + 'appendTimestamp' => true,
50 ], 51 ],
51 'imagemanager' => [ 52 'imagemanager' => [
52 'class' => 'noam148\imagemanager\components\ImageManagerGetPath', 53 'class' => 'noam148\imagemanager\components\ImageManagerGetPath',
backend/controllers/SettingsController.php
@@ -31,10 +31,6 @@ @@ -31,10 +31,6 @@
31 'allow' => true, 31 'allow' => true,
32 ], 32 ],
33 [ 33 [
34 - 'actions' => [  
35 - 'logout',  
36 - 'index',  
37 - ],  
38 'allow' => true, 34 'allow' => true,
39 'roles' => [ '@' ], 35 'roles' => [ '@' ],
40 ], 36 ],
@@ -53,7 +49,7 @@ @@ -53,7 +49,7 @@
53 $model = $this->findSettings(); 49 $model = $this->findSettings();
54 50
55 if ($model->load(Yii::$app->request->post()) && $model->save()) { 51 if ($model->load(Yii::$app->request->post()) && $model->save()) {
56 - Yii::$app->session->setFlash('success', 'Settings saved'); 52 + Yii::$app->session->setFlash('success', \Yii::t('core', 'Settings saved'));
57 53
58 return $this->goHome(); 54 return $this->goHome();
59 } 55 }
@@ -65,6 +61,23 @@ @@ -65,6 +61,23 @@
65 ] 61 ]
66 ); 62 );
67 } 63 }
  64 +
  65 + public function actionRobots()
  66 + {
  67 + $model = $this->findSettings();
  68 + $model->scenario = Settings::SCENARIO_ROBOTS;
  69 +
  70 + if ($model->load(\Yii::$app->request->post()) && $model->save()) {
  71 + \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved'));
  72 + }
  73 +
  74 + return $this->render(
  75 + 'robots',
  76 + [
  77 + 'model' => $model,
  78 + ]
  79 + );
  80 + }
68 81
69 /** 82 /**
70 * Find site settings 83 * Find site settings
backend/views/layouts/main.php
@@ -135,6 +135,14 @@ @@ -135,6 +135,14 @@
135 $homeLink, 135 $homeLink,
136 [ 136 [
137 [ 137 [
  138 + 'label' => \Yii::t('core', 'Main'),
  139 + 'url' => [ '/site/index' ],
  140 + 'icon' => ( \Yii::$app->controller->id === 'site' ) ? 'check' : 'undo',
  141 + 'active' => function () {
  142 + return \Yii::$app->controller->id === 'site';
  143 + },
  144 + ],
  145 + [
138 'label' => \Yii::t('core', 'Static pages'), 146 'label' => \Yii::t('core', 'Static pages'),
139 'url' => [ 'page/index' ], 147 'url' => [ 'page/index' ],
140 'icon' => 'file-text', 148 'icon' => 'file-text',
@@ -143,12 +151,21 @@ @@ -143,12 +151,21 @@
143 }, 151 },
144 ], 152 ],
145 [ 153 [
146 - 'label' => \Yii::t('core', 'SEO'),  
147 - 'url' => [ 'seo/index' ],  
148 - 'icon' => 'bolt',  
149 - 'active' => function () {  
150 - return \Yii::$app->controller->id === 'seo';  
151 - }, 154 + 'label' => \Yii::t('core', 'SEO'),
  155 + 'url' => '#',
  156 + 'icon' => 'bolt',
  157 + 'items' => [
  158 + [
  159 + 'label' => \Yii::t('core', 'Seo pages'),
  160 + 'url' => [ 'seo/index' ],
  161 + 'icon' => 'file-text',
  162 + ],
  163 + [
  164 + 'label' => \Yii::t('core', 'Robots'),
  165 + 'url' => [ 'settings/robots' ],
  166 + 'icon' => 'android',
  167 + ],
  168 + ],
152 ], 169 ],
153 ] 170 ]
154 ); 171 );
backend/views/settings/robots.php 0 โ†’ 100755
  1 +<?php
  2 + /**
  3 + * @var View $this
  4 + * @var Settings $model
  5 + */
  6 +
  7 + use common\models\Settings;
  8 + use artbox\gentelella\widgets\XPanel;
  9 + use yii\bootstrap\ActiveForm;
  10 + use yii\bootstrap\Html;
  11 + use yii\web\View;
  12 +
  13 + $this->title = $model->getAttributeLabel('robots');
  14 +
  15 + $this->params[ 'breadcrumbs' ][] = $this->title;
  16 +?>
  17 +
  18 +<?php $panel = XPanel::begin(
  19 + [
  20 + 'title' => $this->title,
  21 + 'toolbar' => false,
  22 + ]
  23 +); ?>
  24 +
  25 +<div class="settings-form">
  26 +
  27 + <?php
  28 + $form = ActiveForm::begin();
  29 +
  30 + echo $form->field($model, 'robots')
  31 + ->label(false)
  32 + ->textarea();
  33 +
  34 + echo Html::submitButton(
  35 + \Yii::t('core', 'Save'),
  36 + [
  37 + 'class' => 'btn btn-primary',
  38 + ]
  39 + );
  40 + ActiveForm::end();
  41 + ?>
  42 +
  43 +</div>
  44 +
  45 +<?php $panel::end(); ?>
common/config/settings.php
@@ -17,5 +17,6 @@ return [ @@ -17,5 +17,6 @@ return [
17 </script> 17 </script>
18 <!-- End Google Analytics -->', 18 <!-- End Google Analytics -->',
19 'analytics_key' => '119240817', 19 'analytics_key' => '119240817',
  20 + 'robots' => 'TEst 321',
20 ], 21 ],
21 ]; 22 ];
22 \ No newline at end of file 23 \ No newline at end of file
common/models/Settings.php
@@ -6,22 +6,37 @@ @@ -6,22 +6,37 @@
6 6
7 /** 7 /**
8 * Class Settings 8 * Class Settings
9 -  
10 * 9 *
11 -*@package artbox\core\models 10 + * @package artbox\core\models
12 * @property string $name 11 * @property string $name
13 * @property string $id 12 * @property string $id
14 * @property string $description 13 * @property string $description
15 * @property string $analytics 14 * @property string $analytics
16 * @property string $analytics_key 15 * @property string $analytics_key
  16 + * @property string $robots
17 */ 17 */
18 class Settings extends ActiveRecord 18 class Settings extends ActiveRecord
19 { 19 {
  20 + const SCENARIO_ROBOTS = 'robots';
  21 +
20 private static $instance; 22 private static $instance;
21 23
22 /** 24 /**
23 * @inheritdoc 25 * @inheritdoc
24 */ 26 */
  27 + public function scenarios()
  28 + {
  29 + return array_merge(
  30 + parent::scenarios(),
  31 + [
  32 + self::SCENARIO_ROBOTS => [ 'robots' ],
  33 + ]
  34 + );
  35 + }
  36 +
  37 + /**
  38 + * @inheritdoc
  39 + */
25 public function rules() 40 public function rules()
26 { 41 {
27 return [ 42 return [
@@ -32,6 +47,7 @@ @@ -32,6 +47,7 @@
32 'id', 47 'id',
33 'analytics', 48 'analytics',
34 'analytics_key', 49 'analytics_key',
  50 + 'robots',
35 ], 51 ],
36 'string', 52 'string',
37 ], 53 ],
@@ -52,11 +68,12 @@ @@ -52,11 +68,12 @@
52 public function attributeLabels() 68 public function attributeLabels()
53 { 69 {
54 return [ 70 return [
55 - 'id' => Yii::t('core', 'ID'),  
56 - 'name' => Yii::t('core', 'Name'),  
57 - 'description' => Yii::t('core', 'Description'),  
58 - 'analytics' => Yii::t('core', 'Google Analytics Code'), 71 + 'id' => Yii::t('core', 'ID'),
  72 + 'name' => Yii::t('core', 'Name'),
  73 + 'description' => Yii::t('core', 'Description'),
  74 + 'analytics' => Yii::t('core', 'Google Analytics Code'),
59 'analytics_key' => Yii::t('core', 'Google Analytics Key'), 75 'analytics_key' => Yii::t('core', 'Google Analytics Key'),
  76 + 'robots' => Yii::t('core', 'Robots'),
60 ]; 77 ];
61 } 78 }
62 79
@@ -67,7 +84,7 @@ @@ -67,7 +84,7 @@
67 */ 84 */
68 public static function getInstance() 85 public static function getInstance()
69 { 86 {
70 - if (empty(self::$instance)) { 87 + if (empty( self::$instance )) {
71 self::$instance = self::findOne([ 'id' => 1 ]); 88 self::$instance = self::findOne([ 'id' => 1 ]);
72 return self::$instance; 89 return self::$instance;
73 } 90 }