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 13 'layout' => 'admin',
14 14 'controllerNamespace' => 'backend\controllers',
15 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 37 'modules' => [
30 38 'permit' => [
31 39 'class' => 'developeruz\db_rbac\Yii2DbRbac',
... ...
backend/controllers/SiteController.php
... ... @@ -10,6 +10,7 @@ use common\modules\product\models\ProductVariant;
10 10 use common\modules\product\models\ProductVariantType;
11 11 use Yii;
12 12 use yii\filters\AccessControl;
  13 +use yii\helpers\Url;
13 14 use yii\web\Controller;
14 15 use backend\models\LoginForm;
15 16 use yii\filters\VerbFilter;
... ... @@ -82,7 +83,7 @@ class SiteController extends Controller
82 83  
83 84 $model = new LoginForm();
84 85 if ($model->load(Yii::$app->request->post()) && $model->login()) {
85   - return $this->goBack();
  86 + return $this->redirect(Url::to('/admin/site/index'));
86 87 } else {
87 88 return $this->render('login', [
88 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 15 <header class="main-header">
2 16 <!-- Logo -->
3 17 <a href="index2.html" class="logo">
... ... @@ -14,6 +28,31 @@
14 28 </a>
15 29  
16 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 56 </div>
18 57 </nav>
19 58 </header>
20 59 \ No newline at end of file
... ...
backend/views/seo/_form.php
... ... @@ -2,7 +2,8 @@
2 2  
3 3 use yii\helpers\Html;
4 4 use yii\widgets\ActiveForm;
5   -
  5 +use mihaildev\ckeditor\CKEditor;
  6 +use mihaildev\elfinder\ElFinder;
6 7 /* @var $this yii\web\View */
7 8 /* @var $model common\models\Seo */
8 9 /* @var $form yii\widgets\ActiveForm */
... ... @@ -19,8 +20,15 @@ use yii\widgets\ActiveForm;
19 20 <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
20 21  
21 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 33 <div class="form-group">
26 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 11 use common\models\Subscribe;
12 12 use yii\widgets\ActiveForm;
13 13 use common\modules\product\models\Category;
  14 + use frontend\widgets\Seo;
14 15  
15 16 AppAsset::register ($this);
16 17 $this->registerJs ("
... ... @@ -70,7 +71,8 @@
70 71 <head>
71 72 <meta charset="<?= Yii::$app->charset ?>"/>
72 73 <?= Html::csrfMetaTags () ?>
73   - <title><?= Html::encode ($this->title) ?></title>
  74 + <title><?= Seo::widget([ 'row'=>'title'])?></title>
  75 + <?= Seo::widget([ 'row'=>'description'])?>
74 76 <link rel="shortcut icon" href="<?= Yii::$app->request->baseUrl ?>/img/favicon.ico" type="image/x-icon"/>
75 77 <?= HreflangWidget::widget ([]) ?>
76 78 <?php $this->head () ?>
... ...
frontend/views/site/index.php
... ... @@ -4,10 +4,11 @@ use yii\helpers\Html;
4 4 use yii\web\View;
5 5 use frontend\widgets\BannerWidget;
6 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 12 $this->registerJsFile (
12 13 Yii::$app->request->baseUrl . '/js/slides.min.jquery.js',
13 14 ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]);
... ... @@ -65,7 +66,7 @@ echo &#39;&lt;/div&gt;&#39;;
65 66 <?=BannerWidget::widget(['title' => 'HOME_CENTER']);?>
66 67  
67 68 <div class="seo_text">
68   - <!-- --><?//= $text->body ?>
  69 + <?= Seo::widget(['row'=>'seo_text'])?>
69 70 </div>
70 71  
71 72  
... ...
frontend/widgets/BannerWidget.php
... ... @@ -21,7 +21,7 @@ class BannerWidget extends Widget
21 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 25 if (! empty ($banner))
26 26 {
27 27 // html
... ...
frontend/widgets/Seo.php
... ... @@ -100,7 +100,7 @@ class Seo extends Widget
100 100 }
101 101 }
102 102 $str = str_replace('{project_name}', $this->project_name, $str);
103   - return Html::encode($str);
  103 + return $str;
104 104 }
105 105  
106 106 protected function findSeoByUrl()
... ...