Commit fa68c38d3a8a0c7dffcdcaf134c77d5a2e2e84ac

Authored by Administrator
1 parent cb6805b8

12.04.16 finish event, service

backend/config/main.php
@@ -61,6 +61,8 @@ return [ @@ -61,6 +61,8 @@ return [
61 'rules' => [ 61 'rules' => [
62 'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'slider-image/<action>', 62 'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'slider-image/<action>',
63 'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>' => 'slider-image/<action>', 63 'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>' => 'slider-image/<action>',
  64 + 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
  65 + 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
64 66
65 67
66 ] 68 ]
backend/controllers/SeoCategoryController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use common\models\SeoCategory;
  7 +use common\models\SeoCategorySearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +
  12 +/**
  13 + * SeoCategoryController implements the CRUD actions for SeoCategory model.
  14 + */
  15 +class SeoCategoryController extends Controller
  16 +{
  17 + /**
  18 + * @inheritdoc
  19 + */
  20 + public function behaviors()
  21 + {
  22 + return [
  23 + 'verbs' => [
  24 + 'class' => VerbFilter::className(),
  25 + 'actions' => [
  26 + 'delete' => ['POST'],
  27 + ],
  28 + ],
  29 + ];
  30 + }
  31 +
  32 + /**
  33 + * Lists all SeoCategory models.
  34 + * @return mixed
  35 + */
  36 + public function actionIndex()
  37 + {
  38 + $searchModel = new SeoCategorySearch();
  39 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  40 +
  41 + return $this->render('index', [
  42 + 'searchModel' => $searchModel,
  43 + 'dataProvider' => $dataProvider,
  44 + ]);
  45 + }
  46 +
  47 + /**
  48 + * Displays a single SeoCategory model.
  49 + * @param integer $id
  50 + * @return mixed
  51 + */
  52 + public function actionView($id)
  53 + {
  54 + return $this->render('view', [
  55 + 'model' => $this->findModel($id),
  56 + ]);
  57 + }
  58 +
  59 + /**
  60 + * Creates a new SeoCategory model.
  61 + * If creation is successful, the browser will be redirected to the 'view' page.
  62 + * @return mixed
  63 + */
  64 + public function actionCreate()
  65 + {
  66 + $model = new SeoCategory();
  67 +
  68 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  69 + return $this->redirect(['view', 'id' => $model->seo_category_id]);
  70 + } else {
  71 + return $this->render('create', [
  72 + 'model' => $model,
  73 + ]);
  74 + }
  75 + }
  76 +
  77 + /**
  78 + * Updates an existing SeoCategory model.
  79 + * If update is successful, the browser will be redirected to the 'view' page.
  80 + * @param integer $id
  81 + * @return mixed
  82 + */
  83 + public function actionUpdate($id)
  84 + {
  85 + $model = $this->findModel($id);
  86 +
  87 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  88 + return $this->redirect(['view', 'id' => $model->seo_category_id]);
  89 + } else {
  90 + return $this->render('update', [
  91 + 'model' => $model,
  92 + ]);
  93 + }
  94 + }
  95 +
  96 + /**
  97 + * Deletes an existing SeoCategory model.
  98 + * If deletion is successful, the browser will be redirected to the 'index' page.
  99 + * @param integer $id
  100 + * @return mixed
  101 + */
  102 + public function actionDelete($id)
  103 + {
  104 + $this->findModel($id)->delete();
  105 +
  106 + return $this->redirect(['index']);
  107 + }
  108 +
  109 + /**
  110 + * Finds the SeoCategory model based on its primary key value.
  111 + * If the model is not found, a 404 HTTP exception will be thrown.
  112 + * @param integer $id
  113 + * @return SeoCategory the loaded model
  114 + * @throws NotFoundHttpException if the model cannot be found
  115 + */
  116 + protected function findModel($id)
  117 + {
  118 + if (($model = SeoCategory::findOne($id)) !== null) {
  119 + return $model;
  120 + } else {
  121 + throw new NotFoundHttpException('The requested page does not exist.');
  122 + }
  123 + }
  124 +}
backend/controllers/SeoDynamicController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use common\models\SeoDynamic;
  7 +use common\models\SeoDynamicSearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +
  12 +/**
  13 + * SeoDynamicController implements the CRUD actions for SeoDynamic model.
  14 + */
  15 +class SeoDynamicController extends Controller
  16 +{
  17 + /**
  18 + * @inheritdoc
  19 + */
  20 + public function behaviors()
  21 + {
  22 + return [
  23 + 'verbs' => [
  24 + 'class' => VerbFilter::className(),
  25 + 'actions' => [
  26 + 'delete' => ['POST'],
  27 + ],
  28 + ],
  29 + ];
  30 + }
  31 +
  32 + /**
  33 + * Lists all SeoDynamic models.
  34 + * @return mixed
  35 + */
  36 + public function actionIndex($seo_category_id)
  37 + {
  38 + $searchModel = new SeoDynamicSearch();
  39 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  40 +
  41 + return $this->render('index', [
  42 + 'searchModel' => $searchModel,
  43 + 'dataProvider' => $dataProvider,
  44 + 'seo_category_id' => $seo_category_id
  45 + ]);
  46 + }
  47 +
  48 + /**
  49 + * Displays a single SeoDynamic model.
  50 + * @param integer $id
  51 + * @return mixed
  52 + */
  53 + public function actionView($seo_category_id, $id)
  54 + {
  55 + return $this->render('view', [
  56 + 'model' => $this->findModel($id),
  57 + 'seo_category_id' => $seo_category_id
  58 + ]);
  59 + }
  60 +
  61 + /**
  62 + * Creates a new SeoDynamic model.
  63 + * If creation is successful, the browser will be redirected to the 'view' page.
  64 + * @return mixed
  65 + */
  66 + public function actionCreate($seo_category_id)
  67 + {
  68 + $model = new SeoDynamic();
  69 +
  70 + if ($model->load(Yii::$app->request->post())) {
  71 + $model->seo_category_id = $seo_category_id;
  72 + $model->save();
  73 + return $this->redirect(['index', 'seo_category_id' => $model->seo_category_id]);
  74 + } else {
  75 + return $this->render('create', [
  76 + 'model' => $model,
  77 + 'seo_category_id' => $seo_category_id
  78 + ]);
  79 + }
  80 + }
  81 +
  82 + /**
  83 + * Updates an existing SeoDynamic model.
  84 + * If update is successful, the browser will be redirected to the 'view' page.
  85 + * @param integer $id
  86 + * @return mixed
  87 + */
  88 + public function actionUpdate($seo_category_id,$id)
  89 + {
  90 + $model = $this->findModel($id);
  91 +
  92 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  93 + return $this->redirect(['index', 'seo_category_id' => $model->seo_category_id]);
  94 + } else {
  95 + return $this->render('update', [
  96 + 'model' => $model,
  97 + 'seo_category_id' => $seo_category_id
  98 + ]);
  99 + }
  100 + }
  101 +
  102 + /**
  103 + * Deletes an existing SeoDynamic model.
  104 + * If deletion is successful, the browser will be redirected to the 'index' page.
  105 + * @param integer $id
  106 + * @return mixed
  107 + */
  108 + public function actionDelete($seo_category_id,$id)
  109 + {
  110 + $this->findModel($id)->delete();
  111 +
  112 + return $this->redirect(['index','seo_category_id'=> $seo_category_id]);
  113 + }
  114 +
  115 + /**
  116 + * Finds the SeoDynamic model based on its primary key value.
  117 + * If the model is not found, a 404 HTTP exception will be thrown.
  118 + * @param integer $id
  119 + * @return SeoDynamic the loaded model
  120 + * @throws NotFoundHttpException if the model cannot be found
  121 + */
  122 + protected function findModel($id)
  123 + {
  124 + if (($model = SeoDynamic::findOne($id)) !== null) {
  125 + return $model;
  126 + } else {
  127 + throw new NotFoundHttpException('The requested page does not exist.');
  128 + }
  129 + }
  130 +}
backend/views/layouts/main-sidebar.php
@@ -54,7 +54,14 @@ use yii\widgets\Menu; @@ -54,7 +54,14 @@ use yii\widgets\Menu;
54 ['label' => 'Статические страницы', 'url' => ['/page/index']], 54 ['label' => 'Статические страницы', 'url' => ['/page/index']],
55 ['label' => 'Акции', 'url' => ['/event/index']], 55 ['label' => 'Акции', 'url' => ['/event/index']],
56 ['label' => 'Услуги', 'url' => ['/service/index']], 56 ['label' => 'Услуги', 'url' => ['/service/index']],
57 - ['label' => 'SEO', 'url' => ['/seo/index']], 57 + [
  58 + 'label' => 'SEO',
  59 + 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-search"></i> <span>{label}</span></a>',
  60 + 'items' => [
  61 + ['label' => 'URL', 'url' => ['/seo/index']],
  62 + ['label' => 'Шаблоны', 'url' => ['/seo-category/index']]
  63 + ]
  64 + ],
58 // ['label' => 'Rubrication', 'url' => ['/rubrication/tax-group']], 65 // ['label' => 'Rubrication', 'url' => ['/rubrication/tax-group']],
59 // ['label' => 'Relation', 'url' => ['/relation/manage']], 66 // ['label' => 'Relation', 'url' => ['/relation/manage']],
60 ], 67 ],
backend/views/seo-category/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoCategory */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-category-form">
  12 +
  13 + <?php $form = ActiveForm::begin(); ?>
  14 +
  15 + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  16 +
  17 + <?= $form->field($model, 'controller')->textInput(['maxlength' => true]) ?>
  18 +
  19 + <?= $form->field($model, 'status')->textInput() ?>
  20 +
  21 + <div class="form-group">
  22 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  23 + </div>
  24 +
  25 + <?php ActiveForm::end(); ?>
  26 +
  27 +</div>
backend/views/seo-category/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoCategorySearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-category-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'seo_category_id') ?>
  19 +
  20 + <?= $form->field($model, 'name') ?>
  21 +
  22 + <?= $form->field($model, 'controller') ?>
  23 +
  24 + <?= $form->field($model, 'status') ?>
  25 +
  26 + <div class="form-group">
  27 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  28 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  29 + </div>
  30 +
  31 + <?php ActiveForm::end(); ?>
  32 +
  33 +</div>
backend/views/seo-category/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoCategory */
  8 +
  9 +$this->title = Yii::t('app', 'Create Seo Category');
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-category-create">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
backend/views/seo-category/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +use yii\helpers\Url;
  6 +
  7 +/* @var $this yii\web\View */
  8 +/* @var $searchModel common\models\SeoCategorySearch */
  9 +/* @var $dataProvider yii\data\ActiveDataProvider */
  10 +
  11 +$this->title = Yii::t('app', 'Seo Categories');
  12 +$this->params['breadcrumbs'][] = $this->title;
  13 +?>
  14 +<div class="seo-category-index">
  15 +
  16 + <h1><?= Html::encode($this->title) ?></h1>
  17 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  18 +
  19 + <p>
  20 + <?= Html::a(Yii::t('app', 'Create Seo Category'), ['create'], ['class' => 'btn btn-success']) ?>
  21 + </p>
  22 + <?= GridView::widget([
  23 + 'dataProvider' => $dataProvider,
  24 + 'filterModel' => $searchModel,
  25 + 'columns' => [
  26 + ['class' => 'yii\grid\SerialColumn'],
  27 +
  28 + 'seo_category_id',
  29 + 'name',
  30 + 'controller',
  31 + 'status',
  32 +
  33 + [
  34 + 'class' => 'yii\grid\ActionColumn',
  35 + 'template' => '{update}&nbsp;{image}&nbsp;{delete}',
  36 + 'buttons' => [
  37 + 'update' => function ($url, $model)
  38 + {
  39 + return Html::a (
  40 + '<span class="glyphicon glyphicon-pencil"></span>',
  41 + Url::toRoute(['seo-category/update', 'id' => $model->seo_category_id]),
  42 + [
  43 + 'title' => "Редактировать",
  44 + ]
  45 + );
  46 + },
  47 + 'image' => function ($url, $model)
  48 + {
  49 + return Html::a (
  50 + '<span class="glyphicon glyphicon-picture"></span>',
  51 + Url::toRoute(['seo-dynamic/index', 'seo_category_id' => $model->seo_category_id]),
  52 + [
  53 + 'title' => "слайды",
  54 + ]
  55 + );
  56 + },
  57 + 'delete' => function ($url, $model)
  58 + {
  59 + return Html::a (
  60 + '<span class="glyphicon glyphicon-trash"></span>',
  61 + Url::toRoute(['seo-category/delete', 'id' => $model->seo_category_id]),
  62 + [
  63 + 'title' => "Удалить",
  64 + ]
  65 + );
  66 + },
  67 + ],
  68 + 'contentOptions' => ['style' => 'width: 70px;'],
  69 + ],
  70 + ],
  71 + ]); ?>
  72 +</div>
backend/views/seo-category/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\models\SeoCategory */
  7 +
  8 +$this->title = Yii::t('app', 'Update {modelClass}: ', [
  9 + 'modelClass' => 'Seo Category',
  10 +]) . $model->name;
  11 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']];
  12 +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->seo_category_id]];
  13 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  14 +?>
  15 +<div class="seo-category-update">
  16 +
  17 + <h1><?= Html::encode($this->title) ?></h1>
  18 +
  19 + <?= $this->render('_form', [
  20 + 'model' => $model,
  21 + ]) ?>
  22 +
  23 +</div>
backend/views/seo-category/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoCategory */
  8 +
  9 +$this->title = $model->name;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-category-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->seo_category_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->seo_category_id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'seo_category_id',
  32 + 'name',
  33 + 'controller',
  34 + 'status',
  35 + ],
  36 + ]) ?>
  37 +
  38 +</div>
backend/views/seo-dynamic/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoDynamic */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-dynamic-form">
  12 +
  13 + <?php $form = ActiveForm::begin(); ?>
  14 +
  15 + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  16 +
  17 + <?= $form->field($model, 'action')->textInput(['maxlength' => true]) ?>
  18 +
  19 + <?= $form->field($model, 'fields')->textInput(['maxlength' => true]) ?>
  20 +
  21 + <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
  22 +
  23 + <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
  24 +
  25 + <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
  26 +
  27 + <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
  28 +
  29 + <?= $form->field($model, 'status')->textInput() ?>
  30 +
  31 + <div class="form-group">
  32 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  33 + </div>
  34 +
  35 + <?php ActiveForm::end(); ?>
  36 +
  37 +</div>
backend/views/seo-dynamic/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoDynamicSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-dynamic-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'seo_dynamic_id') ?>
  19 +
  20 + <?= $form->field($model, 'seo_category_id') ?>
  21 +
  22 + <?= $form->field($model, 'name') ?>
  23 +
  24 + <?= $form->field($model, 'action') ?>
  25 +
  26 + <?= $form->field($model, 'fields') ?>
  27 +
  28 + <?php // echo $form->field($model, 'title') ?>
  29 +
  30 + <?php // echo $form->field($model, 'h1') ?>
  31 +
  32 + <?php // echo $form->field($model, 'description') ?>
  33 +
  34 + <?php // echo $form->field($model, 'seo_text') ?>
  35 +
  36 + <?php // echo $form->field($model, 'status') ?>
  37 +
  38 + <div class="form-group">
  39 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  40 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  41 + </div>
  42 +
  43 + <?php ActiveForm::end(); ?>
  44 +
  45 +</div>
backend/views/seo-dynamic/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\helpers\Url;
  5 +
  6 +
  7 +/* @var $this yii\web\View */
  8 +/* @var $model common\models\SeoDynamic */
  9 +
  10 +$this->title = Yii::t('app', 'Create Seo Dynamic');
  11 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => Url::toRoute(['index','seo_category_id'=>$seo_category_id])];
  12 +$this->params['breadcrumbs'][] = $this->title;
  13 +?>
  14 +<div class="seo-dynamic-create">
  15 +
  16 + <h1><?= Html::encode($this->title) ?></h1>
  17 +
  18 + <?= $this->render('_form', [
  19 + 'model' => $model,
  20 + ]) ?>
  21 +
  22 +</div>
backend/views/seo-dynamic/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +use yii\helpers\Url;
  6 +
  7 +/* @var $this yii\web\View */
  8 +/* @var $searchModel common\models\SeoDynamicSearch */
  9 +/* @var $dataProvider yii\data\ActiveDataProvider */
  10 +
  11 +$this->title = Yii::t('app', 'Seo Dynamics');
  12 +$this->params['breadcrumbs'][] = $this->title;
  13 +?>
  14 +<div class="seo-dynamic-index">
  15 +
  16 + <h1><?= Html::encode($this->title) ?></h1>
  17 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  18 +
  19 + <p>
  20 + <?= Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute(['create','seo_category_id'=>$seo_category_id]), ['class' => 'btn btn-success']) ?>
  21 + </p>
  22 + <?= GridView::widget([
  23 + 'dataProvider' => $dataProvider,
  24 + 'filterModel' => $searchModel,
  25 + 'columns' => [
  26 + ['class' => 'yii\grid\SerialColumn'],
  27 +
  28 + 'seo_dynamic_id',
  29 + 'seo_category_id',
  30 + 'name',
  31 + 'action',
  32 + 'fields',
  33 + // 'title',
  34 + // 'h1',
  35 + // 'description',
  36 + // 'seo_text:ntext',
  37 + // 'status',
  38 +
  39 + [
  40 + 'class' => 'yii\grid\ActionColumn',
  41 + 'buttons' => [
  42 + 'view' => function ($url, $model)
  43 + {
  44 + return Html::a (
  45 + '<span class="glyphicon glyphicon-eye-open"></span>',
  46 + Url::toRoute(['view','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]),
  47 + [
  48 + 'title' => "Просмотр",
  49 + ]
  50 + );
  51 + },
  52 + 'update' => function ($url, $model)
  53 + {
  54 + return Html::a (
  55 + '<span class="glyphicon glyphicon-pencil"></span>',
  56 + Url::toRoute(['update','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]),
  57 + [
  58 + 'title' => "Редактировать",
  59 + ]
  60 + );
  61 + },
  62 + 'delete' => function ($url, $model)
  63 + {
  64 +
  65 + return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute(['delete','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]), [
  66 + 'title' => Yii::t('yii', 'Delete'),
  67 + 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
  68 + 'data-method' => 'post',
  69 + ]);
  70 +
  71 + },
  72 + ],
  73 + ],
  74 + ],
  75 + ]); ?>
  76 +</div>
backend/views/seo-dynamic/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\helpers\Url;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoDynamic */
  8 +
  9 +$this->title = Yii::t('app', 'Update {modelClass}: ', [
  10 + 'modelClass' => 'Seo Dynamic',
  11 +]) . $model->name;
  12 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => Url::toRoute(['index','seo_category_id'=>$seo_category_id])];
  13 +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => Url::toRoute(['view', 'seo_category_id'=>$seo_category_id, 'id' => $model->seo_dynamic_id])];
  14 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  15 +?>
  16 +<div class="seo-dynamic-update">
  17 +
  18 + <h1><?= Html::encode($this->title) ?></h1>
  19 +
  20 + <?= $this->render('_form', [
  21 + 'model' => $model,
  22 + ]) ?>
  23 +
  24 +</div>
backend/views/seo-dynamic/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoDynamic */
  8 +
  9 +$this->title = $model->name;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-dynamic-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->seo_dynamic_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->seo_dynamic_id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'seo_dynamic_id',
  32 + 'seo_category_id',
  33 + 'name',
  34 + 'action',
  35 + 'fields',
  36 + 'title',
  37 + 'h1',
  38 + 'description',
  39 + 'seo_text:ntext',
  40 + 'status',
  41 + ],
  42 + ]) ?>
  43 +
  44 +</div>
backend/views/seo/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Seo */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-form">
  12 +
  13 + <?php $form = ActiveForm::begin(); ?>
  14 +
  15 + <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
  16 +
  17 + <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
  18 +
  19 + <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
  20 +
  21 + <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
  22 +
  23 + <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
  24 +
  25 + <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']) ?>
  27 + </div>
  28 +
  29 + <?php ActiveForm::end(); ?>
  30 +
  31 +</div>
backend/views/seo/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\SeoSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="seo-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'seo_id') ?>
  19 +
  20 + <?= $form->field($model, 'url') ?>
  21 +
  22 + <?= $form->field($model, 'title') ?>
  23 +
  24 + <?= $form->field($model, 'description') ?>
  25 +
  26 + <?= $form->field($model, 'h1') ?>
  27 +
  28 + <?php // echo $form->field($model, 'seo_text') ?>
  29 +
  30 + <div class="form-group">
  31 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  32 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  33 + </div>
  34 +
  35 + <?php ActiveForm::end(); ?>
  36 +
  37 +</div>
backend/views/seo/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Seo */
  8 +
  9 +$this->title = Yii::t('app', 'Create Seo');
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-create">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
backend/views/seo/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $searchModel common\models\SeoSearch */
  8 +/* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 +$this->title = Yii::t('app', 'Seo');
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-index">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  17 +
  18 + <p>
  19 + <?= Html::a(Yii::t('app', 'Create Seo'), ['create'], ['class' => 'btn btn-success']) ?>
  20 + </p>
  21 + <?= GridView::widget([
  22 + 'dataProvider' => $dataProvider,
  23 + 'filterModel' => $searchModel,
  24 + 'columns' => [
  25 + ['class' => 'yii\grid\SerialColumn'],
  26 +
  27 + 'seo_id',
  28 + 'url:url',
  29 + 'title',
  30 + 'description',
  31 + 'h1',
  32 + // 'seo_text:ntext',
  33 +
  34 + ['class' => 'yii\grid\ActionColumn'],
  35 + ],
  36 + ]); ?>
  37 +</div>
backend/views/seo/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\models\Seo */
  7 +
  8 +$this->title = Yii::t('app', 'Update {modelClass}: ', [
  9 + 'modelClass' => 'Seo',
  10 +]) . $model->title;
  11 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
  12 +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->seo_id]];
  13 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  14 +?>
  15 +<div class="seo-update">
  16 +
  17 + <h1><?= Html::encode($this->title) ?></h1>
  18 +
  19 + <?= $this->render('_form', [
  20 + 'model' => $model,
  21 + ]) ?>
  22 +
  23 +</div>
backend/views/seo/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Seo */
  8 +
  9 +$this->title = $model->title;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="seo-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->seo_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->seo_id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'seo_id',
  32 + 'url:url',
  33 + 'title',
  34 + 'description',
  35 + 'h1',
  36 + 'seo_text:ntext',
  37 + ],
  38 + ]) ?>
  39 +
  40 +</div>
common/models/SeoCategory.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "seo_category".
  9 + *
  10 + * @property integer $seo_category_id
  11 + * @property string $name
  12 + * @property string $controller
  13 + * @property integer $status
  14 + *
  15 + * @property SeoDynamic[] $seoDynamics
  16 + */
  17 +class SeoCategory extends \yii\db\ActiveRecord
  18 +{
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public static function tableName()
  23 + {
  24 + return 'seo_category';
  25 + }
  26 +
  27 + /**
  28 + * @inheritdoc
  29 + */
  30 + public function rules()
  31 + {
  32 + return [
  33 + [['status'], 'integer'],
  34 + [['name'], 'string', 'max' => 255],
  35 + [['controller'], 'string', 'max' => 100],
  36 + ];
  37 + }
  38 +
  39 + /**
  40 + * @inheritdoc
  41 + */
  42 + public function attributeLabels()
  43 + {
  44 + return [
  45 + 'seo_category_id' => Yii::t('app', 'Seo Category ID'),
  46 + 'name' => Yii::t('app', 'Name'),
  47 + 'controller' => Yii::t('app', 'Controller'),
  48 + 'status' => Yii::t('app', 'Status'),
  49 + ];
  50 + }
  51 +
  52 + /**
  53 + * @return \yii\db\ActiveQuery
  54 + */
  55 + public function getSeoDynamics()
  56 + {
  57 + return $this->hasMany(SeoDynamic::className(), ['seo_category_id' => 'seo_category_id']);
  58 + }
  59 +}
common/models/SeoCategorySearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use common\models\SeoCategory;
  9 +
  10 +/**
  11 + * SeoCategorySearch represents the model behind the search form about `common\models\SeoCategory`.
  12 + */
  13 +class SeoCategorySearch extends SeoCategory
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function rules()
  19 + {
  20 + return [
  21 + [['seo_category_id', 'status'], 'integer'],
  22 + [['name', 'controller'], 'safe'],
  23 + ];
  24 + }
  25 +
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public function scenarios()
  30 + {
  31 + // bypass scenarios() implementation in the parent class
  32 + return Model::scenarios();
  33 + }
  34 +
  35 + /**
  36 + * Creates data provider instance with search query applied
  37 + *
  38 + * @param array $params
  39 + *
  40 + * @return ActiveDataProvider
  41 + */
  42 + public function search($params)
  43 + {
  44 + $query = SeoCategory::find();
  45 +
  46 + // add conditions that should always apply here
  47 +
  48 + $dataProvider = new ActiveDataProvider([
  49 + 'query' => $query,
  50 + ]);
  51 +
  52 + $this->load($params);
  53 +
  54 + if (!$this->validate()) {
  55 + // uncomment the following line if you do not want to return any records when validation fails
  56 + // $query->where('0=1');
  57 + return $dataProvider;
  58 + }
  59 +
  60 + // grid filtering conditions
  61 + $query->andFilterWhere([
  62 + 'seo_category_id' => $this->seo_category_id,
  63 + 'status' => $this->status,
  64 + ]);
  65 +
  66 + $query->andFilterWhere(['like', 'name', $this->name])
  67 + ->andFilterWhere(['like', 'controller', $this->controller]);
  68 +
  69 + return $dataProvider;
  70 + }
  71 +}
common/models/SeoDynamic.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "seo_dynamic".
  9 + *
  10 + * @property integer $seo_dynamic_id
  11 + * @property integer $seo_category_id
  12 + * @property string $name
  13 + * @property string $action
  14 + * @property string $fields
  15 + * @property string $title
  16 + * @property string $h1
  17 + * @property string $description
  18 + * @property string $seo-text
  19 + * @property integer $status
  20 + *
  21 + * @property SeoCategory $seoCategory
  22 + */
  23 +class SeoDynamic extends \yii\db\ActiveRecord
  24 +{
  25 + /**
  26 + * @inheritdoc
  27 + */
  28 + public static function tableName()
  29 + {
  30 + return 'seo_dynamic';
  31 + }
  32 +
  33 + /**
  34 + * @inheritdoc
  35 + */
  36 + public function rules()
  37 + {
  38 + return [
  39 + [['seo_category_id', 'status'], 'integer'],
  40 + [['seo_text'], 'string'],
  41 + [['name', 'action'], 'string', 'max' => 200],
  42 + [['fields', 'title', 'h1', 'description'], 'string', 'max' => 255],
  43 + [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']],
  44 + ];
  45 + }
  46 +
  47 + /**
  48 + * @inheritdoc
  49 + */
  50 + public function attributeLabels()
  51 + {
  52 + return [
  53 + 'seo_dynamic_id' => Yii::t('app', 'Seo Dynamic ID'),
  54 + 'seo_category_id' => Yii::t('app', 'Seo Category ID'),
  55 + 'name' => Yii::t('app', 'Name'),
  56 + 'action' => Yii::t('app', 'Action'),
  57 + 'fields' => Yii::t('app', 'Fields'),
  58 + 'title' => Yii::t('app', 'Title'),
  59 + 'h1' => Yii::t('app', 'H1'),
  60 + 'description' => Yii::t('app', 'Description'),
  61 + 'seo_text' => Yii::t('app', 'Seo Text'),
  62 + 'status' => Yii::t('app', 'Status'),
  63 + ];
  64 + }
  65 +
  66 + /**
  67 + * @return \yii\db\ActiveQuery
  68 + */
  69 + public function getSeoCategory()
  70 + {
  71 + return $this->hasOne(SeoCategory::className(), ['seo_category_id' => 'seo_category_id']);
  72 + }
  73 +}
common/models/SeoDynamicSearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use common\models\SeoDynamic;
  9 +
  10 +/**
  11 + * SeoDynamicSearch represents the model behind the search form about `common\models\SeoDynamic`.
  12 + */
  13 +class SeoDynamicSearch extends SeoDynamic
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function rules()
  19 + {
  20 + return [
  21 + [['seo_dynamic_id', 'seo_category_id', 'status'], 'integer'],
  22 + [['name', 'action', 'fields', 'title', 'h1', 'description', 'seo_text'], 'safe'],
  23 + ];
  24 + }
  25 +
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public function scenarios()
  30 + {
  31 + // bypass scenarios() implementation in the parent class
  32 + return Model::scenarios();
  33 + }
  34 +
  35 + /**
  36 + * Creates data provider instance with search query applied
  37 + *
  38 + * @param array $params
  39 + *
  40 + * @return ActiveDataProvider
  41 + */
  42 + public function search($params)
  43 + {
  44 + $query = SeoDynamic::find();
  45 +
  46 + // add conditions that should always apply here
  47 +
  48 + $dataProvider = new ActiveDataProvider([
  49 + 'query' => $query,
  50 + ]);
  51 +
  52 + $this->load($params);
  53 +
  54 + if (!$this->validate()) {
  55 + // uncomment the following line if you do not want to return any records when validation fails
  56 + // $query->where('0=1');
  57 + return $dataProvider;
  58 + }
  59 +
  60 + // grid filtering conditions
  61 + $query->andFilterWhere([
  62 + 'seo_dynamic_id' => $this->seo_dynamic_id,
  63 + 'seo_category_id' => $this->seo_category_id,
  64 + 'status' => $this->status,
  65 + ]);
  66 +
  67 + $query->andFilterWhere(['like', 'name', $this->name])
  68 + ->andFilterWhere(['like', 'action', $this->action])
  69 + ->andFilterWhere(['like', 'fields', $this->fields])
  70 + ->andFilterWhere(['like', 'title', $this->title])
  71 + ->andFilterWhere(['like', 'h1', $this->h1])
  72 + ->andFilterWhere(['like', 'description', $this->description])
  73 + ->andFilterWhere(['like', 'seo_text', $this->seo_text]);
  74 +
  75 + return $dataProvider;
  76 + }
  77 +}
console/migrations/m160412_133944_create_seo_category.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation for table `seo_category`.
  7 + */
  8 +class m160412_133944_create_seo_category extends Migration
  9 +{
  10 + /**
  11 + * @inheritdoc
  12 + */
  13 + public function up()
  14 + {
  15 + $this->createTable('seo_category', [
  16 + 'seo_category_id' => $this->primaryKey(),
  17 + 'name' => $this->string(),
  18 + 'controller' => $this->string(100),
  19 + 'status' => $this->smallInteger(1),
  20 + ]);
  21 + }
  22 +
  23 + /**
  24 + * @inheritdoc
  25 + */
  26 + public function down()
  27 + {
  28 + $this->dropTable('seo_category');
  29 + }
  30 +}
console/migrations/m160413_112158_create_seo_dynamic.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation for table `seo_dynamic`.
  7 + */
  8 +class m160413_112158_create_seo_dynamic extends Migration
  9 +{
  10 + /**
  11 + * @inheritdoc
  12 + */
  13 + public function up()
  14 + {
  15 + $this->createTable('seo_dynamic', [
  16 + 'seo_dynamic_id' => $this->primaryKey(),
  17 + 'seo_category_id' => $this->integer(),
  18 + 'name' => $this->string(200),
  19 + 'action' => $this->string(200),
  20 + 'fields' => $this->string(),
  21 + 'title' => $this->string(),
  22 + 'h1' => $this->string(),
  23 + 'description' => $this->string(),
  24 + 'seo_text' => $this->text(),
  25 + 'status' => $this->smallInteger()
  26 + ]);
  27 +
  28 + $this->addForeignKey('seo_category_seo_dynamic_fk', 'seo_dynamic', 'seo_category_id', 'seo_category', 'seo_category_id', 'CASCADE', 'CASCADE');
  29 + }
  30 +
  31 + /**
  32 + * @inheritdoc
  33 + */
  34 + public function down()
  35 + {
  36 + $this->dropForeignKey('seo_category_seo_dynamic_fk', '{{%seo_dynamic}}');
  37 + $this->dropTable('seo_dynamic');
  38 + }
  39 +}
frontend/views/event/index.php
1 <?php 1 <?php
2 use yii\widgets\ListView; 2 use yii\widgets\ListView;
  3 +use frontend\widgets\Seo;
3 $this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']]; 4 $this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']];
4 ?> 5 ?>
  6 +
5 <?php 7 <?php
6 echo ListView::widget( [ 8 echo ListView::widget( [
7 'dataProvider' => $dataProvider, 9 'dataProvider' => $dataProvider,
@@ -11,3 +13,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = [&#39;label&#39; =&gt; &#39;Акции&#39;, &#39;url&#39; =&gt; [&#39;index&#39;]]; @@ -11,3 +13,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = [&#39;label&#39; =&gt; &#39;Акции&#39;, &#39;url&#39; =&gt; [&#39;index&#39;]];
11 <div class='pager-block' id='pager-block-single'>{pager}</div>" 13 <div class='pager-block' id='pager-block-single'>{pager}</div>"
12 ] ); 14 ] );
13 ?> 15 ?>
  16 +<div class="seo-text">
  17 + <?= Seo::widget(['row'=>'seo_text'])?>
  18 +</div>
frontend/views/event/view.php
@@ -2,14 +2,14 @@ @@ -2,14 +2,14 @@
2 2
3 use yii\helpers\Html; 3 use yii\helpers\Html;
4 use yii\widgets\DetailView; 4 use yii\widgets\DetailView;
5 - 5 +use frontend\widgets\Seo;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\models\Stone */ 7 /* @var $model common\models\Stone */
8 8
9 $this->title = $model->name; 9 $this->title = $model->name;
10 $this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 - 12 +$this->params['name'] = $this->title;
13 ?> 13 ?>
14 <div class="events-one-item"> 14 <div class="events-one-item">
15 <h1><?= $model->name?></h1> 15 <h1><?= $model->name?></h1>
@@ -21,3 +21,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -21,3 +21,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
21 <?= $model->body?> 21 <?= $model->body?>
22 </div> 22 </div>
23 </div> 23 </div>
  24 +<div class="seo-text">
  25 + <?= Seo::widget(['row'=>'seo_text'])?>
  26 +</div>
frontend/views/layouts/main.php
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 use common\widgets\BasketHead; 7 use common\widgets\BasketHead;
8 use common\widgets\BasketModal; 8 use common\widgets\BasketModal;
9 use frontend\assets\AppAsset; 9 use frontend\assets\AppAsset;
  10 +use frontend\widgets\Seo;
10 use yii\helpers\Html; 11 use yii\helpers\Html;
11 use yii\helpers\Url; 12 use yii\helpers\Url;
12 13
@@ -18,8 +19,26 @@ AppAsset::register($this); @@ -18,8 +19,26 @@ AppAsset::register($this);
18 <html lang="en"> 19 <html lang="en">
19 <head> 20 <head>
20 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 21 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
21 - <title><?= Html::encode($this->title)?></title> 22 + <title><?= Seo::widget([
  23 + 'row'=>'title',
  24 + 'own_attr'=>$this->title,
  25 + 'fields' =>[
  26 + 'name' => isset($this->params[ 'name' ]) ? $this->params[ 'name' ] : ''
  27 + ]
  28 + ])?>
  29 + </title>
  30 + <?php $this->registerMetaTag([
  31 + 'name' => 'description',
  32 + 'content' => Seo::widget([
  33 + 'row'=>'description',
  34 + 'own_attr'=>isset($this->params[ 'description' ]) ? $this->params[ 'description' ] : '',
  35 + 'fields' =>[
  36 + 'name' => isset($this->params[ 'name' ]) ? $this->params[ 'name' ] : ''
  37 + ]
  38 + ])
  39 + ]); ?>
22 <?php $this->head() ?> 40 <?php $this->head() ?>
  41 + <?//= Html::csrfMetaTags() ?>
23 <link href='https://fonts.googleapis.com/css?family=Ubuntu:400,300italic,300,400italic,500,500italic,700italic,700' rel='stylesheet' type='text/css'> 42 <link href='https://fonts.googleapis.com/css?family=Ubuntu:400,300italic,300,400italic,500,500italic,700italic,700' rel='stylesheet' type='text/css'>
24 43
25 44
frontend/widgets/Seo.php
1 <?php 1 <?php
2 -namespace frontend\components;  
3 -use common\models\SeoSearch; 2 +namespace frontend\widgets;
  3 +use common\models\SeoCategory;
  4 +use common\models\SeoDynamic;
4 use yii\base\Widget; 5 use yii\base\Widget;
  6 +use yii\helpers\Html;
5 7
6 class Seo extends Widget 8 class Seo extends Widget
7 { 9 {
8 private $url; 10 private $url;
9 public $row; 11 public $row;
  12 + public $own_attr;
  13 + public $fields;
10 14
11 public function init(){ 15 public function init(){
12 $this->url = $_SERVER['REQUEST_URI']; 16 $this->url = $_SERVER['REQUEST_URI'];
@@ -17,17 +21,49 @@ class Seo extends Widget @@ -17,17 +21,49 @@ class Seo extends Widget
17 21
18 public function run() 22 public function run()
19 { 23 {
20 - $widgetData = $this->findModel(); 24 + $row = '';
  25 +
  26 +
  27 + $widgetData = $this->findSeoByUrl();
  28 + if($widgetData instanceof \common\models\Seo){
  29 +
  30 + $row = $widgetData->{$this->row};
  31 + } else{
  32 +
  33 + $widgetData = $this->findSeoByDynamic();
  34 + if($widgetData instanceof SeoDynamic){
  35 + $row = $widgetData->{$this->row};
  36 + }
  37 + }
  38 + if(!empty($this->own_attr) && empty($row)) {
  39 +
  40 + $row = $this->own_attr;
  41 + }
  42 +
  43 +
  44 + return $this->replaceData($row);
  45 +
21 46
22 - return $widgetData->{$this->row};  
23 } 47 }
24 48
25 - protected function findModel() 49 + protected function replaceData($str)
26 { 50 {
27 - if (($model = \common\models\Seo::findOne(['url'=>$this->url])) !== null) {  
28 - return $model;  
29 - } else {  
30 - return new SeoSearch(); 51 +
  52 + if(!empty($this->fields)){
  53 + foreach($this->fields as $field_name => $field_value){
  54 + $str = str_replace('{'.$field_name.'}', $field_value, $str);
  55 + }
31 } 56 }
  57 + return Html::encode($str);
  58 + }
  59 +
  60 + protected function findSeoByUrl()
  61 + {
  62 + return \common\models\Seo::findOne(['url'=>$this->url]);
  63 + }
  64 +
  65 + protected function findSeoByDynamic()
  66 + {
  67 + return SeoDynamic::find()->joinWith('seoCategory')->where(['controller'=> \Yii::$app->controller->id, 'action'=>\Yii::$app->controller->action->id])->one();
32 } 68 }
33 } 69 }
34 \ No newline at end of file 70 \ No newline at end of file