Commit 22827c55112dde11f0c1acc229ee60b294ab325f

Authored by Karnovsky A
2 parents fecf4bd1 4495dea0

Merge remote-tracking branch 'origin/master'

backend/config/main.php
@@ -13,19 +13,27 @@ return [ @@ -13,19 +13,27 @@ return [
13 'layout' => 'admin', 13 'layout' => 'admin',
14 'controllerNamespace' => 'backend\controllers', 14 'controllerNamespace' => 'backend\controllers',
15 'bootstrap' => ['log'], 15 'bootstrap' => ['log'],
16 -// 'as AccessBehavior' => [  
17 -// 'class' => AccessBehavior::className(),  
18 -// 'rules' =>  
19 -// ['permit/access' =>  
20 -// [  
21 -// [  
22 -// 'actions' => ['role', 'permission','add-role', 'update-role','add-permission', 'update-permission' ],  
23 -// 'allow' => true,  
24 -// ]  
25 -// ]  
26 -// ],  
27 -//  
28 -// ], 16 + 'as AccessBehavior' => [
  17 + 'class' => AccessBehavior::className(),
  18 + 'rules' =>
  19 + [
  20 + 'permit/access' =>
  21 + [
  22 + [
  23 + 'actions' => ['role', 'permission','add-role', 'update-role','add-permission', 'update-permission' ],
  24 + 'allow' => true,
  25 + ]
  26 + ],
  27 + 'site' =>
  28 + [
  29 + [
  30 + 'actions' => ['login', 'error' ],
  31 + 'allow' => true,
  32 + ]
  33 +
  34 + ]
  35 + ]
  36 + ],
29 'modules' => [ 37 'modules' => [
30 'permit' => [ 38 'permit' => [
31 'class' => 'developeruz\db_rbac\Yii2DbRbac', 39 'class' => 'developeruz\db_rbac\Yii2DbRbac',
backend/controllers/SiteController.php
@@ -10,6 +10,7 @@ use common\modules\product\models\ProductVariant; @@ -10,6 +10,7 @@ use common\modules\product\models\ProductVariant;
10 use common\modules\product\models\ProductVariantType; 10 use common\modules\product\models\ProductVariantType;
11 use Yii; 11 use Yii;
12 use yii\filters\AccessControl; 12 use yii\filters\AccessControl;
  13 +use yii\helpers\Url;
13 use yii\web\Controller; 14 use yii\web\Controller;
14 use backend\models\LoginForm; 15 use backend\models\LoginForm;
15 use yii\filters\VerbFilter; 16 use yii\filters\VerbFilter;
@@ -82,7 +83,7 @@ class SiteController extends Controller @@ -82,7 +83,7 @@ class SiteController extends Controller
82 83
83 $model = new LoginForm(); 84 $model = new LoginForm();
84 if ($model->load(Yii::$app->request->post()) && $model->login()) { 85 if ($model->load(Yii::$app->request->post()) && $model->login()) {
85 - return $this->goBack(); 86 + return $this->redirect(Url::to('/admin/site/index'));
86 } else { 87 } else {
87 return $this->render('login', [ 88 return $this->render('login', [
88 'model' => $model, 89 'model' => $model,
backend/views/layouts/header.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);
  14 +?>
1 <header class="main-header"> 15 <header class="main-header">
2 <!-- Logo --> 16 <!-- Logo -->
3 <a href="index2.html" class="logo"> 17 <a href="index2.html" class="logo">
@@ -14,6 +28,31 @@ @@ -14,6 +28,31 @@
14 </a> 28 </a>
15 29
16 <div class="navbar-custom-menu"> 30 <div class="navbar-custom-menu">
  31 + <?php
  32 + NavBar::begin([
  33 + 'options' => [
  34 + 'class' => 'navbar-inverse navbar-fixed-top',
  35 + ],
  36 + ]);
  37 + if (Yii::$app->user->isGuest) {
  38 + $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
  39 + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
  40 + } else {
  41 + $menuItems[] = '<li>'
  42 + . Html::beginForm(['/site/logout'], 'post')
  43 + . Html::submitButton(
  44 + 'Logout (' . Yii::$app->user->identity->username . ')',
  45 + ['class' => 'btn btn-link']
  46 + )
  47 + . Html::endForm()
  48 + . '</li>';
  49 + }
  50 + echo Nav::widget([
  51 + 'options' => ['class' => 'navbar-nav navbar-right'],
  52 + 'items' => $menuItems,
  53 + ]);
  54 + NavBar::end();
  55 + ?>
17 </div> 56 </div>
18 </nav> 57 </nav>
19 </header> 58 </header>
20 \ No newline at end of file 59 \ No newline at end of file
backend/views/seo/_form.php
@@ -2,7 +2,8 @@ @@ -2,7 +2,8 @@
2 2
3 use yii\helpers\Html; 3 use yii\helpers\Html;
4 use yii\widgets\ActiveForm; 4 use yii\widgets\ActiveForm;
5 - 5 +use mihaildev\ckeditor\CKEditor;
  6 +use mihaildev\elfinder\ElFinder;
6 /* @var $this yii\web\View */ 7 /* @var $this yii\web\View */
7 /* @var $model common\models\Seo */ 8 /* @var $model common\models\Seo */
8 /* @var $form yii\widgets\ActiveForm */ 9 /* @var $form yii\widgets\ActiveForm */
@@ -19,8 +20,15 @@ use yii\widgets\ActiveForm; @@ -19,8 +20,15 @@ use yii\widgets\ActiveForm;
19 <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?> 20 <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
20 21
21 <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?> 22 <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
22 -  
23 - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> 23 + <?= $form->field($model, 'seo_text')->widget(CKEditor::className(),
  24 + [
  25 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
  26 + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать
  27 + 'inline' => false, //по умолчанию false]),
  28 + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
  29 + ]
  30 + )
  31 + ]) ?>
24 32
25 <div class="form-group"> 33 <div class="form-group">
26 <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 34 <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
frontend/views/layouts/main.php
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 use common\models\Subscribe; 11 use common\models\Subscribe;
12 use yii\widgets\ActiveForm; 12 use yii\widgets\ActiveForm;
13 use common\modules\product\models\Category; 13 use common\modules\product\models\Category;
  14 + use frontend\widgets\Seo;
14 15
15 AppAsset::register ($this); 16 AppAsset::register ($this);
16 $this->registerJs (" 17 $this->registerJs ("
@@ -70,7 +71,8 @@ @@ -70,7 +71,8 @@
70 <head> 71 <head>
71 <meta charset="<?= Yii::$app->charset ?>"/> 72 <meta charset="<?= Yii::$app->charset ?>"/>
72 <?= Html::csrfMetaTags () ?> 73 <?= Html::csrfMetaTags () ?>
73 - <title><?= Html::encode ($this->title) ?></title> 74 + <title><?= Seo::widget([ 'row'=>'title'])?></title>
  75 + <?= Seo::widget([ 'row'=>'description'])?>
74 <link rel="shortcut icon" href="<?= Yii::$app->request->baseUrl ?>/img/favicon.ico" type="image/x-icon"/> 76 <link rel="shortcut icon" href="<?= Yii::$app->request->baseUrl ?>/img/favicon.ico" type="image/x-icon"/>
75 <?= HreflangWidget::widget ([]) ?> 77 <?= HreflangWidget::widget ([]) ?>
76 <?php $this->head () ?> 78 <?php $this->head () ?>
frontend/views/site/index.php
@@ -4,10 +4,11 @@ use yii\helpers\Html; @@ -4,10 +4,11 @@ use yii\helpers\Html;
4 use yii\web\View; 4 use yii\web\View;
5 use frontend\widgets\BannerWidget; 5 use frontend\widgets\BannerWidget;
6 use yii\helpers\Url; 6 use yii\helpers\Url;
7 -  
8 -// $this->title = $text->meta_title;  
9 -// $this->registerMetaTag (['name' => 'description', 'content' => $text->meta_description]);  
10 -// $this->registerMetaTag (['name' => 'keywords', 'content' => $text->meta_keywords]); 7 +use frontend\widgets\Seo;
  8 +$this->params['seo']['seo_text'] = 'TEST SEO TEXT';
  9 +$this->params['seo']['h1'] = 'TEST H1';
  10 +$this->params['seo']['description'] = 'TEST DESCRIPTION';
  11 +$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';
11 $this->registerJsFile ( 12 $this->registerJsFile (
12 Yii::$app->request->baseUrl . '/js/slides.min.jquery.js', 13 Yii::$app->request->baseUrl . '/js/slides.min.jquery.js',
13 ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); 14 ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]);
@@ -65,7 +66,7 @@ echo &#39;&lt;/div&gt;&#39;; @@ -65,7 +66,7 @@ echo &#39;&lt;/div&gt;&#39;;
65 <?=BannerWidget::widget(['title' => 'HOME_CENTER']);?> 66 <?=BannerWidget::widget(['title' => 'HOME_CENTER']);?>
66 67
67 <div class="seo_text"> 68 <div class="seo_text">
68 - <!-- --><?//= $text->body ?> 69 + <?= Seo::widget(['row'=>'seo_text'])?>
69 </div> 70 </div>
70 71
71 72
frontend/widgets/BannerWidget.php
@@ -21,7 +21,7 @@ class BannerWidget extends Widget @@ -21,7 +21,7 @@ class BannerWidget extends Widget
21 public function run () 21 public function run ()
22 { 22 {
23 // слайдер 23 // слайдер
24 - $banner = Banner::find()->where([Banner::tableName().'.title'=>$this->title])->one(); 24 + $banner = Banner::find()->where([Banner::tableName().'.title'=>$this->title, Banner::tableName().'.status' => '1'] )->one();
25 if (! empty ($banner)) 25 if (! empty ($banner))
26 { 26 {
27 // html 27 // html
frontend/widgets/Seo.php
@@ -100,7 +100,7 @@ class Seo extends Widget @@ -100,7 +100,7 @@ class Seo extends Widget
100 } 100 }
101 } 101 }
102 $str = str_replace('{project_name}', $this->project_name, $str); 102 $str = str_replace('{project_name}', $this->project_name, $str);
103 - return Html::encode($str); 103 + return $str;
104 } 104 }
105 105
106 protected function findSeoByUrl() 106 protected function findSeoByUrl()