diff --git a/backend/config/main.php b/backend/config/main.php index 1995c18..0fa8aa9 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -35,7 +35,7 @@ ], 'components' => [ 'assetManager' => [ - 'bundles' => [ + 'bundles' => [ 'yiister\gentelella\assets\ThemeAsset' => [ 'basePath' => '@webroot', 'baseUrl' => '@web', @@ -47,6 +47,7 @@ ], ], ], + 'appendTimestamp' => true, ], 'imagemanager' => [ 'class' => 'noam148\imagemanager\components\ImageManagerGetPath', diff --git a/backend/controllers/SettingsController.php b/backend/controllers/SettingsController.php index b0a0f9c..02f710d 100755 --- a/backend/controllers/SettingsController.php +++ b/backend/controllers/SettingsController.php @@ -31,10 +31,6 @@ 'allow' => true, ], [ - 'actions' => [ - 'logout', - 'index', - ], 'allow' => true, 'roles' => [ '@' ], ], @@ -53,7 +49,7 @@ $model = $this->findSettings(); if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->session->setFlash('success', 'Settings saved'); + Yii::$app->session->setFlash('success', \Yii::t('core', 'Settings saved')); return $this->goHome(); } @@ -65,6 +61,23 @@ ] ); } + + public function actionRobots() + { + $model = $this->findSettings(); + $model->scenario = Settings::SCENARIO_ROBOTS; + + if ($model->load(\Yii::$app->request->post()) && $model->save()) { + \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved')); + } + + return $this->render( + 'robots', + [ + 'model' => $model, + ] + ); + } /** * Find site settings diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php index 264925e..007a51d 100755 --- a/backend/views/layouts/main.php +++ b/backend/views/layouts/main.php @@ -135,6 +135,14 @@ $homeLink, [ [ + 'label' => \Yii::t('core', 'Main'), + 'url' => [ '/site/index' ], + 'icon' => ( \Yii::$app->controller->id === 'site' ) ? 'check' : 'undo', + 'active' => function () { + return \Yii::$app->controller->id === 'site'; + }, + ], + [ 'label' => \Yii::t('core', 'Static pages'), 'url' => [ 'page/index' ], 'icon' => 'file-text', @@ -143,12 +151,21 @@ }, ], [ - 'label' => \Yii::t('core', 'SEO'), - 'url' => [ 'seo/index' ], - 'icon' => 'bolt', - 'active' => function () { - return \Yii::$app->controller->id === 'seo'; - }, + 'label' => \Yii::t('core', 'SEO'), + 'url' => '#', + 'icon' => 'bolt', + 'items' => [ + [ + 'label' => \Yii::t('core', 'Seo pages'), + 'url' => [ 'seo/index' ], + 'icon' => 'file-text', + ], + [ + 'label' => \Yii::t('core', 'Robots'), + 'url' => [ 'settings/robots' ], + 'icon' => 'android', + ], + ], ], ] ); diff --git a/backend/views/settings/robots.php b/backend/views/settings/robots.php new file mode 100755 index 0000000..003c839 --- /dev/null +++ b/backend/views/settings/robots.php @@ -0,0 +1,45 @@ +title = $model->getAttributeLabel('robots'); + + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + + $this->title, + 'toolbar' => false, + ] +); ?> + +
+ + field($model, 'robots') + ->label(false) + ->textarea(); + + echo Html::submitButton( + \Yii::t('core', 'Save'), + [ + 'class' => 'btn btn-primary', + ] + ); + ActiveForm::end(); + ?> + +
+ + diff --git a/common/config/settings.php b/common/config/settings.php index 878125f..ee69344 100755 --- a/common/config/settings.php +++ b/common/config/settings.php @@ -17,5 +17,6 @@ return [ ', 'analytics_key' => '119240817', + 'robots' => 'TEst 321', ], ]; \ No newline at end of file diff --git a/common/models/Settings.php b/common/models/Settings.php index b1772ac..852854e 100755 --- a/common/models/Settings.php +++ b/common/models/Settings.php @@ -6,22 +6,37 @@ /** * Class Settings - * -*@package artbox\core\models + * @package artbox\core\models * @property string $name * @property string $id * @property string $description * @property string $analytics * @property string $analytics_key + * @property string $robots */ class Settings extends ActiveRecord { + const SCENARIO_ROBOTS = 'robots'; + private static $instance; /** * @inheritdoc */ + public function scenarios() + { + return array_merge( + parent::scenarios(), + [ + self::SCENARIO_ROBOTS => [ 'robots' ], + ] + ); + } + + /** + * @inheritdoc + */ public function rules() { return [ @@ -32,6 +47,7 @@ 'id', 'analytics', 'analytics_key', + 'robots', ], 'string', ], @@ -52,11 +68,12 @@ public function attributeLabels() { return [ - 'id' => Yii::t('core', 'ID'), - 'name' => Yii::t('core', 'Name'), - 'description' => Yii::t('core', 'Description'), - 'analytics' => Yii::t('core', 'Google Analytics Code'), + 'id' => Yii::t('core', 'ID'), + 'name' => Yii::t('core', 'Name'), + 'description' => Yii::t('core', 'Description'), + 'analytics' => Yii::t('core', 'Google Analytics Code'), 'analytics_key' => Yii::t('core', 'Google Analytics Key'), + 'robots' => Yii::t('core', 'Robots'), ]; } @@ -67,7 +84,7 @@ */ public static function getInstance() { - if (empty(self::$instance)) { + if (empty( self::$instance )) { self::$instance = self::findOne([ 'id' => 1 ]); return self::$instance; } -- libgit2 0.21.4