Commit 93c267f7eb898589ee414a9be24cc69927999935

Authored by Yarik
1 parent d55d2fe0

Multilanguage big commit.

Showing 150 changed files with 2858 additions and 3266 deletions   Show diff stats
backend/controllers/ArticlesController.php
@@ -86,17 +86,7 @@ @@ -86,17 +86,7 @@
86 $model_langs = $model->generateLangs(); 86 $model_langs = $model->generateLangs();
87 if($model->load(Yii::$app->request->post())) { 87 if($model->load(Yii::$app->request->post())) {
88 $model->loadLangs(\Yii::$app->request, $model_langs); 88 $model->loadLangs(\Yii::$app->request, $model_langs);
89 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
90 - $model->image = $image->name;  
91 - }  
92 - $imgDir = Yii::getAlias('@storage/articles/');  
93 - if(!is_dir($imgDir)) {  
94 - mkdir($imgDir, 0755, true);  
95 - }  
96 if($model->save()) { 89 if($model->save()) {
97 - if($image) {  
98 - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));  
99 - }  
100 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 90 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
101 return $this->redirect([ 91 return $this->redirect([
102 'view', 92 'view',
@@ -130,17 +120,7 @@ @@ -130,17 +120,7 @@
130 $model_langs = $model->generateLangs(); 120 $model_langs = $model->generateLangs();
131 if($model->load(Yii::$app->request->post())) { 121 if($model->load(Yii::$app->request->post())) {
132 $model->loadLangs(\Yii::$app->request, $model_langs); 122 $model->loadLangs(\Yii::$app->request, $model_langs);
133 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
134 - $model->image = $image->name;  
135 - }  
136 - $imgDir = Yii::getAlias('@storage/articles/');  
137 - if(!is_dir($imgDir)) {  
138 - mkdir($imgDir, 0755, true);  
139 - }  
140 if($model->save()) { 123 if($model->save()) {
141 - if($image) {  
142 - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));  
143 - }  
144 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 124 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
145 return $this->redirect([ 125 return $this->redirect([
146 'view', 126 'view',
backend/controllers/BannerController.php
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace backend\controllers; 3 namespace backend\controllers;
4 4
5 - use common\modules\file\widgets\ImageUploader;  
6 use Yii; 5 use Yii;
7 use common\models\Banner; 6 use common\models\Banner;
8 use common\models\BannerSearch; 7 use common\models\BannerSearch;
backend/controllers/BgController.php
@@ -119,7 +119,7 @@ @@ -119,7 +119,7 @@
119 $model_langs = $model->generateLangs(); 119 $model_langs = $model->generateLangs();
120 120
121 if($model->load(Yii::$app->request->post()) && $model->save()) { 121 if($model->load(Yii::$app->request->post()) && $model->save()) {
122 - $model->loadLangs(\Yii::$app->request); 122 + $model->loadLangs(\Yii::$app->request, $model_langs);
123 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 123 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
124 return $this->redirect([ 124 return $this->redirect([
125 'view', 125 'view',
backend/controllers/BrandController.php
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 use yii\web\NotFoundHttpException; 9 use yii\web\NotFoundHttpException;
10 use yii\filters\VerbFilter; 10 use yii\filters\VerbFilter;
11 use yii\filters\AccessControl; 11 use yii\filters\AccessControl;
12 - use yii\web\UploadedFile;  
13 12
14 /** 13 /**
15 * BrandController implements the CRUD actions for Brand model. 14 * BrandController implements the CRUD actions for Brand model.
backend/controllers/CategoryController.php
@@ -88,14 +88,8 @@ @@ -88,14 +88,8 @@
88 88
89 if($model->load(Yii::$app->request->post())) { 89 if($model->load(Yii::$app->request->post())) {
90 $model->loadLangs(\Yii::$app->request, $model_langs); 90 $model->loadLangs(\Yii::$app->request, $model_langs);
91 - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {  
92 - $model->image = $image->name;  
93 - }  
94 91
95 if($model->save()) { 92 if($model->save()) {
96 - if($image) {  
97 - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));  
98 - }  
99 93
100 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 94 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
101 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ 95 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([
@@ -117,7 +111,7 @@ @@ -117,7 +111,7 @@
117 'model' => $model, 111 'model' => $model,
118 'model_langs' => $model_langs, 112 'model_langs' => $model_langs,
119 'categories' => ArtboxTreeHelper::treeMap(Category::find() 113 'categories' => ArtboxTreeHelper::treeMap(Category::find()
120 - ->getTree(), 'category_id', 'name', '.'), 114 + ->getTree(), 'category_id', 'category_id', '.'),
121 ]); 115 ]);
122 } 116 }
123 117
@@ -136,14 +130,8 @@ @@ -136,14 +130,8 @@
136 $model_langs = $model->generateLangs(); 130 $model_langs = $model->generateLangs();
137 131
138 if($model->load(Yii::$app->request->post())) { 132 if($model->load(Yii::$app->request->post())) {
139 - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {  
140 - $model->image = $image->name;  
141 - }  
142 $model->loadLangs(\Yii::$app->request, $model_langs); 133 $model->loadLangs(\Yii::$app->request, $model_langs);
143 if($model->save()) { 134 if($model->save()) {
144 - if($image) {  
145 - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));  
146 - }  
147 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 135 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
148 return $this->redirect([ 136 return $this->redirect([
149 'view', 137 'view',
@@ -156,7 +144,7 @@ @@ -156,7 +144,7 @@
156 'model' => $model, 144 'model' => $model,
157 'model_langs' => $model_langs, 145 'model_langs' => $model_langs,
158 'categories' => ArtboxTreeHelper::treeMap(Category::find() 146 'categories' => ArtboxTreeHelper::treeMap(Category::find()
159 - ->getTree(), 'category_id', 'name', '.'), 147 + ->getTree(), 'category_id', 'category_id', '.'),
160 ]); 148 ]);
161 } 149 }
162 150
backend/controllers/EventController.php
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 use yii\web\NotFoundHttpException; 9 use yii\web\NotFoundHttpException;
10 use yii\filters\VerbFilter; 10 use yii\filters\VerbFilter;
11 use developeruz\db_rbac\behaviors\AccessBehavior; 11 use developeruz\db_rbac\behaviors\AccessBehavior;
12 - use yii\web\UploadedFile;  
13 12
14 /** 13 /**
15 * EventController implements the CRUD actions for Event model. 14 * EventController implements the CRUD actions for Event model.
@@ -89,14 +88,7 @@ @@ -89,14 +88,7 @@
89 88
90 $model->loadLangs(\Yii::$app->request, $model_langs); 89 $model->loadLangs(\Yii::$app->request, $model_langs);
91 90
92 - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {  
93 - $model->image = $image->name;  
94 - }  
95 -  
96 if($model->save()) { 91 if($model->save()) {
97 - if($image) {  
98 - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));  
99 - }  
100 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 92 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
101 return $this->redirect([ 93 return $this->redirect([
102 'view', 94 'view',
@@ -133,14 +125,7 @@ @@ -133,14 +125,7 @@
133 125
134 $model->loadLangs(\Yii::$app->request, $model_langs); 126 $model->loadLangs(\Yii::$app->request, $model_langs);
135 127
136 - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {  
137 - $model->image = $image->name;  
138 - }  
139 -  
140 if($model->save()) { 128 if($model->save()) {
141 - if($image) {  
142 - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));  
143 - }  
144 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 129 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
145 return $this->redirect([ 130 return $this->redirect([
146 'view', 131 'view',
backend/controllers/ProjectController.php
@@ -201,8 +201,9 @@ @@ -201,8 +201,9 @@
201 $project = $this->findModel($id); 201 $project = $this->findModel($id);
202 $model = new ProductToProject(); 202 $model = new ProductToProject();
203 $products = Product::find() 203 $products = Product::find()
  204 + ->distinct()
204 ->select([ 205 ->select([
205 - 'product.name', 206 + 'product.product_id',
206 'product.product_id', 207 'product.product_id',
207 ]) 208 ])
208 ->joinWith('variants', true, 'INNER JOIN') 209 ->joinWith('variants', true, 'INNER JOIN')
@@ -221,7 +222,6 @@ @@ -221,7 +222,6 @@
221 if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) { 222 if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) {
222 $variants = ProductVariant::find() 223 $variants = ProductVariant::find()
223 ->select([ 224 ->select([
224 - 'name',  
225 'product_variant_id', 225 'product_variant_id',
226 ]) 226 ])
227 ->where([ 'product_id' => $model->product_id ]) 227 ->where([ 'product_id' => $model->product_id ])
@@ -261,7 +261,7 @@ @@ -261,7 +261,7 @@
261 } 261 }
262 $products = Product::find() 262 $products = Product::find()
263 ->select([ 263 ->select([
264 - 'product.name', 264 + 'product.product_id',
265 'product.product_id', 265 'product.product_id',
266 ]) 266 ])
267 ->joinWith('variants', true, 'INNER JOIN') 267 ->joinWith('variants', true, 'INNER JOIN')
@@ -272,7 +272,6 @@ @@ -272,7 +272,6 @@
272 if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) { 272 if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) {
273 $variants = ProductVariant::find() 273 $variants = ProductVariant::find()
274 ->select([ 274 ->select([
275 - 'name',  
276 'product_variant_id', 275 'product_variant_id',
277 ]) 276 ])
278 ->where([ 'product_id' => $model->product_id ]) 277 ->where([ 'product_id' => $model->product_id ])
backend/controllers/SliderImageController.php
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 use yii\web\Controller; 10 use yii\web\Controller;
11 use yii\web\NotFoundHttpException; 11 use yii\web\NotFoundHttpException;
12 use yii\filters\VerbFilter; 12 use yii\filters\VerbFilter;
13 - use yii\web\UploadedFile;  
14 13
15 /** 14 /**
16 * SliderImageController implements the CRUD actions for SliderImage model. 15 * SliderImageController implements the CRUD actions for SliderImage model.
@@ -97,38 +96,29 @@ @@ -97,38 +96,29 @@
97 if($model->load(Yii::$app->request->post())) { 96 if($model->load(Yii::$app->request->post())) {
98 $model->loadLangs(\Yii::$app->request, $model_langs); 97 $model->loadLangs(\Yii::$app->request, $model_langs);
99 $model->slider_id = $slider_id; 98 $model->slider_id = $slider_id;
100 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
101 - $model->image = $image->name;  
102 - }  
103 - if($model->save() && $image) {  
104 - $imgDir = Yii::getAlias('@storage/slider/');  
105 - if(!is_dir($imgDir)) {  
106 - mkdir($imgDir, 0755, true); 99 + if($model->save()) {
  100 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  101 + return $this->redirect([
  102 + 'view',
  103 + 'slider_id' => $slider_id,
  104 + 'id' => $model->slider_image_id,
  105 + ]);
  106 + } else {
  107 + return $this->redirect([
  108 + 'update',
  109 + 'slider_id' => $slider_id,
  110 + 'id' => $model->slider_image_id,
  111 + ]);
107 } 112 }
108 - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));  
109 - }  
110 - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {  
111 - return $this->redirect([  
112 - 'view',  
113 - 'slider_id' => $slider_id,  
114 - 'id' => $model->slider_image_id,  
115 - ]);  
116 - } else {  
117 - return $this->redirect([  
118 - 'update',  
119 - 'slider_id' => $slider_id,  
120 - 'id' => $model->slider_image_id,  
121 - ]);  
122 } 113 }
123 - } else {  
124 - $slider = Slider::findOne($slider_id);  
125 - return $this->render('create', [  
126 - 'slider_id' => $slider_id,  
127 - 'model' => $model,  
128 - 'model_langs' => $model_langs,  
129 - 'slider' => $slider,  
130 - ]);  
131 } 114 }
  115 + $slider = Slider::findOne($slider_id);
  116 + return $this->render('create', [
  117 + 'slider_id' => $slider_id,
  118 + 'model' => $model,
  119 + 'model_langs' => $model_langs,
  120 + 'slider' => $slider,
  121 + ]);
132 } 122 }
133 123
134 /** 124 /**
@@ -146,20 +136,7 @@ @@ -146,20 +136,7 @@
146 $model_langs = $model->generateLangs(); 136 $model_langs = $model->generateLangs();
147 if($model->load(Yii::$app->request->post())) { 137 if($model->load(Yii::$app->request->post())) {
148 $model->loadLangs(\Yii::$app->request, $model_langs); 138 $model->loadLangs(\Yii::$app->request, $model_langs);
149 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
150 - $model->image = $image->name;  
151 - }  
152 - if(!$model->image) {  
153 - $model->image = $model->getOldAttribute('image');  
154 - }  
155 - if($model->save() && $image) {  
156 - $imgDir = Yii::getAlias('@storage/slider/');  
157 - if(!is_dir($imgDir)) {  
158 - mkdir($imgDir, 0755, true);  
159 - }  
160 - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));  
161 - }  
162 - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 139 + if($model->save() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
163 return $this->redirect([ 140 return $this->redirect([
164 'view', 141 'view',
165 'slider_id' => $slider_id, 142 'slider_id' => $slider_id,
backend/models/Label.php
@@ -11,9 +11,9 @@ use yii\web\Request; @@ -11,9 +11,9 @@ use yii\web\Request;
11 * Class Label 11 * Class Label
12 * 12 *
13 * * From language behavior * 13 * * From language behavior *
14 - * @property {TableLang} $lang  
15 - * @property {TableLang}[] $langs  
16 - * @property {TableLang} $object_lang 14 + * @property OrdersLabelLang $lang
  15 + * @property OrdersLabelLang[] $langs
  16 + * @property OrdersLabelLang $object_lang
17 * @property string $ownerKey 17 * @property string $ownerKey
18 * @property string $langKey 18 * @property string $langKey
19 * @method string getOwnerKey() 19 * @method string getOwnerKey()
@@ -22,7 +22,7 @@ use yii\web\Request; @@ -22,7 +22,7 @@ use yii\web\Request;
22 * @method void setLangKey(string $value) 22 * @method void setLangKey(string $value)
23 * @method ActiveQuery getLangs() 23 * @method ActiveQuery getLangs()
24 * @method ActiveQuery getLang( integer $language_id ) 24 * @method ActiveQuery getLang( integer $language_id )
25 - * @method {TableLang}[] generateLangs() 25 + * @method OrdersLabelLang[] generateLangs()
26 * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) 26 * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
27 * @method bool linkLangs(ActiveRecord[] $model_langs) 27 * @method bool linkLangs(ActiveRecord[] $model_langs)
28 * @method bool saveLangs(ActiveRecord[] $model_langs) 28 * @method bool saveLangs(ActiveRecord[] $model_langs)
@@ -44,8 +44,4 @@ class Label extends \yii\db\ActiveRecord @@ -44,8 +44,4 @@ class Label extends \yii\db\ActiveRecord
44 ], 44 ],
45 ]; 45 ];
46 } 46 }
47 -  
48 - public function getNl(){  
49 - return $this->name;  
50 - }  
51 } 47 }
backend/views/articles/_form.php
@@ -29,31 +29,9 @@ @@ -29,31 +29,9 @@
29 ->widget(DatePicker::className(), [ 29 ->widget(DatePicker::className(), [
30 'dateFormat' => 'dd-MM-yyyy', 30 'dateFormat' => 'dd-MM-yyyy',
31 ]) ?> 31 ]) ?>
32 - <?= $form->field($model, 'title')  
33 - ->textInput([ 'maxlength' => true ]) ?>  
34 -  
35 - <?= $form->field($model, 'body')  
36 - ->widget(CKEditor::className(), [  
37 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
38 - 'preset' => 'full',  
39 - 'inline' => false,  
40 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
41 - ->createUrl('file/uploader/images-upload'),  
42 - ]),  
43 - ]) ?>  
44 -  
45 - <?= $form->field($model, 'body_preview')  
46 - ->widget(CKEditor::className(), [  
47 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
48 - 'preset' => 'full',  
49 - 'inline' => false,  
50 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
51 - ->createUrl('file/uploader/images-upload'),  
52 - ]),  
53 - ]) ?>  
54 32
55 <?= $form->field($model, 'image') 33 <?= $form->field($model, 'image')
56 - ->widget(\kartik\file\FileInput::classname(), [ 34 + ->widget(\kartik\file\FileInput::className(), [
57 'language' => 'ru', 35 'language' => 'ru',
58 'options' => [ 36 'options' => [
59 'accept' => 'image/*', 37 'accept' => 'image/*',
@@ -73,24 +51,6 @@ @@ -73,24 +51,6 @@
73 ], 51 ],
74 ]); ?> 52 ]); ?>
75 53
76 - <?= $form->field($model, 'translit')  
77 - ->textInput([ 'maxlength' => true ]) ?>  
78 -  
79 - <?= $form->field($model, 'meta_title')  
80 - ->textInput([ 'maxlength' => true ]) ?>  
81 -  
82 - <?= $form->field($model, 'meta_keywords')  
83 - ->textInput([ 'maxlength' => true ]) ?>  
84 -  
85 - <?= $form->field($model, 'meta_description')  
86 - ->textInput([ 'maxlength' => true ]) ?>  
87 -  
88 - <?= $form->field($model, 'seo_text')  
89 - ->textarea([ 'rows' => 6 ]) ?>  
90 -  
91 - <?= $form->field($model, 'h1')  
92 - ->textInput([ 'maxlength' => true ]) ?>  
93 -  
94 <?php 54 <?php
95 echo LanguageForm::widget([ 55 echo LanguageForm::widget([
96 'model_langs' => $model_langs, 56 'model_langs' => $model_langs,
backend/views/articles/_form_language.php
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']title') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']title')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  19 + ->textInput([ 'maxlength' => true ]); ?>
18 <?= $form->field($model_lang, '[' . $language->language_id . ']body') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']body')
19 ->widget(CKEditor::className(), [ 21 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 22 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/articles/create.php
@@ -9,9 +9,9 @@ @@ -9,9 +9,9 @@
9 * @var Articles $model 9 * @var Articles $model
10 * @var ArticlesLang[] $model_langs 10 * @var ArticlesLang[] $model_langs
11 */ 11 */
12 - $this->title = 'Create Articles'; 12 + $this->title = \Yii::t('app', 'Create Articles');
13 $this->params[ 'breadcrumbs' ][] = [ 13 $this->params[ 'breadcrumbs' ][] = [
14 - 'label' => 'Articles', 14 + 'label' => \Yii::t('app', 'Articles'),
15 'url' => [ 'index' ], 15 'url' => [ 'index' ],
16 ]; 16 ];
17 $this->params[ 'breadcrumbs' ][] = $this->title; 17 $this->params[ 'breadcrumbs' ][] = $this->title;
backend/views/articles/index.php
@@ -7,34 +7,22 @@ use yii\grid\GridView; @@ -7,34 +7,22 @@ use yii\grid\GridView;
7 /* @var $searchModel common\models\ArticlesSearch */ 7 /* @var $searchModel common\models\ArticlesSearch */
8 /* @var $dataProvider yii\data\ActiveDataProvider */ 8 /* @var $dataProvider yii\data\ActiveDataProvider */
9 9
10 -$this->title = 'Articles'; 10 +$this->title = \Yii::t('app', 'Articles');
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="articles-index" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">  
14 -  
15 - <h1 itemprop="title"><?= Html::encode($this->title) ?></h1>  
16 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
17 - 13 +<div class="articles-index">
  14 + <h1><?= Html::encode($this->title) ?></h1>
18 <p> 15 <p>
19 - <?= Html::a('Create Articles', ['create'], ['class' => 'btn btn-success']) ?> 16 + <?= Html::a(\Yii::t('app', 'Create Articles'), ['create'], ['class' => 'btn btn-success']) ?>
20 </p> 17 </p>
21 <?= GridView::widget([ 18 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 19 'dataProvider' => $dataProvider,
23 'filterModel' => $searchModel, 20 'filterModel' => $searchModel,
24 'columns' => [ 21 'columns' => [
25 ['class' => 'yii\grid\SerialColumn'], 22 ['class' => 'yii\grid\SerialColumn'],
26 -  
27 'id', 23 'id',
28 'date', 24 'date',
29 - 'title',  
30 - 'image',  
31 - // 'translit',  
32 - // 'meta_title',  
33 - // 'meta_keywords',  
34 - // 'meta_description',  
35 - // 'seo_text:ntext',  
36 - // 'h1',  
37 - 25 + 'imageUrl:image',
38 ['class' => 'yii\grid\ActionColumn'], 26 ['class' => 'yii\grid\ActionColumn'],
39 ], 27 ],
40 ]); ?> 28 ]); ?>
backend/views/articles/update.php
@@ -9,19 +9,19 @@ @@ -9,19 +9,19 @@
9 * @var Articles $model 9 * @var Articles $model
10 * @var ArticlesLang[] $model_langs 10 * @var ArticlesLang[] $model_langs
11 */ 11 */
12 - $this->title = 'Update Articles: ' . $model->title; 12 + $this->title = \Yii::t('app', 'Update Articles').': ' . $model->id;
13 $this->params[ 'breadcrumbs' ][] = [ 13 $this->params[ 'breadcrumbs' ][] = [
14 - 'label' => 'Articles', 14 + 'label' => \Yii::t('app', 'Articles'),
15 'url' => [ 'index' ], 15 'url' => [ 'index' ],
16 ]; 16 ];
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 - 'label' => $model->title, 18 + 'label' => $model->id,
19 'url' => [ 19 'url' => [
20 'view', 20 'view',
21 'id' => $model->id, 21 'id' => $model->id,
22 ], 22 ],
23 ]; 23 ];
24 - $this->params[ 'breadcrumbs' ][] = 'Update'; 24 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update');
25 ?> 25 ?>
26 <div class="articles-update"> 26 <div class="articles-update">
27 27
backend/views/articles/view.php
@@ -6,37 +6,27 @@ use yii\widgets\DetailView; @@ -6,37 +6,27 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\models\Articles */ 7 /* @var $model common\models\Articles */
8 8
9 -$this->title = $model->title;  
10 -$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']]; 9 +$this->title = $model->id;
  10 +$this->params['breadcrumbs'][] = ['label' => \Yii::t('app', 'Articles'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="articles-view" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">  
14 -  
15 - <h1 itemprop="title"><?= Html::encode($this->title) ?></h1>  
16 - 13 +<div class="articles-view">
  14 + <h1><?= Html::encode($this->title) ?></h1>
17 <p> 15 <p>
18 - <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a('Delete', ['delete', 'id' => $model->id], [ 16 + <?= Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  17 + <?= Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
20 'class' => 'btn btn-danger', 18 'class' => 'btn btn-danger',
21 'data' => [ 19 'data' => [
22 - 'confirm' => 'Are you sure you want to delete this item?', 20 + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'),
23 'method' => 'post', 21 'method' => 'post',
24 ], 22 ],
25 ]) ?> 23 ]) ?>
26 </p> 24 </p>
27 -  
28 <?= DetailView::widget([ 25 <?= DetailView::widget([
29 'model' => $model, 26 'model' => $model,
30 'attributes' => [ 27 'attributes' => [
31 'id', 28 'id',
32 'date', 29 'date',
33 - 'title',  
34 - 'translit',  
35 - 'meta_title',  
36 - 'meta_keywords',  
37 - 'meta_description',  
38 - 'h1',  
39 ], 30 ],
40 ]) ?> 31 ]) ?>
41 -  
42 </div> 32 </div>
backend/views/banner/_form.php
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 use common\models\Banner; 3 use common\models\Banner;
4 use common\models\BannerLang; 4 use common\models\BannerLang;
5 - use common\modules\file\widgets\ImageUploader;  
6 use common\modules\language\widgets\LanguageForm; 5 use common\modules\language\widgets\LanguageForm;
7 use kartik\select2\Select2; 6 use kartik\select2\Select2;
8 use yii\helpers\Html; 7 use yii\helpers\Html;
@@ -25,12 +24,6 @@ @@ -25,12 +24,6 @@
25 ], 24 ],
26 ]); ?> 25 ]); ?>
27 26
28 - <?= $form->field($model, 'alt')  
29 - ->textInput([ 'maxlength' => true ]) ?>  
30 -  
31 - <?= $form->field($model, 'title')  
32 - ->textInput([ 'maxlength' => true ]) ?>  
33 -  
34 <?= $form->field($model, 'url') 27 <?= $form->field($model, 'url')
35 ->textInput([ 'maxlength' => true ]) ?> 28 ->textInput([ 'maxlength' => true ]) ?>
36 29
@@ -39,10 +32,10 @@ @@ -39,10 +32,10 @@
39 'name' => 'status', 32 'name' => 'status',
40 'hideSearch' => true, 33 'hideSearch' => true,
41 'data' => [ 34 'data' => [
42 - 1 => 'Active',  
43 - 2 => 'Inactive', 35 + 1 => \Yii::t('app', 'Active'),
  36 + 2 => \Yii::t('app', 'Inactive'),
44 ], 37 ],
45 - 'options' => [ 'placeholder' => 'Select status...' ], 38 + 'options' => [ 'placeholder' => \Yii::t('app', 'Select status...') ],
46 'pluginOptions' => [ 39 'pluginOptions' => [
47 'allowClear' => true, 40 'allowClear' => true,
48 ], 41 ],
backend/views/banner/index.php
1 <?php 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\BannerSearch */  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('app', 'Banners');  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\grid\GridView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $searchModel common\models\BannerSearch */
  8 + /* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 + $this->title = Yii::t('app', 'Banners');
  11 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 12 ?>
13 <div class="banner-index"> 13 <div class="banner-index">
14 - 14 +
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17 - 17 +
18 <p> 18 <p>
19 - <?= Html::a(Yii::t('app', 'Create Banner'), ['create'], ['class' => 'btn btn-success']) ?> 19 + <?= Html::a(Yii::t('app', 'Create Banner'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
20 </p> 20 </p>
21 <?= GridView::widget([ 21 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 22 'dataProvider' => $dataProvider,
23 - 'filterModel' => $searchModel,  
24 - 'columns' => [  
25 - ['class' => 'yii\grid\SerialColumn'],  
26 - 23 + 'filterModel' => $searchModel,
  24 + 'columns' => [
  25 + [ 'class' => 'yii\grid\SerialColumn' ],
27 'banner_id', 26 'banner_id',
28 - 'image',  
29 - 'alt',  
30 - 'title',  
31 - // 'url:url',  
32 - // 'status',  
33 -  
34 - ['class' => 'yii\grid\ActionColumn'], 27 + 'url',
  28 + 'status',
  29 + [ 'class' => 'yii\grid\ActionColumn' ],
35 ], 30 ],
36 ]); ?> 31 ]); ?>
37 </div> 32 </div>
backend/views/banner/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('app', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('app', 'Update {modelClass}: ', [
15 'modelClass' => 'Banner', 15 'modelClass' => 'Banner',
16 - ]) . $model->title; 16 + ]) . $model->banner_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('app', 'Banners'), 18 'label' => Yii::t('app', 'Banners'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->title, 22 + 'label' => $model->banner_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->banner_id, 25 'id' => $model->banner_id,
backend/views/banner/view.php
1 <?php 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\Banner */  
8 -  
9 -$this->title = $model->title;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Banners'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\models\Banner */
  8 +
  9 + $this->title = $model->banner_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('app', 'Banners'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="banner-view"> 16 <div class="banner-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->banner_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->banner_id], [ 21 + <?= Html::a(Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->banner_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->banner_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'banner_id', 40 'banner_id',
32 - 'image',  
33 - 'alt',  
34 - 'title',  
35 - 'url:url', 41 + 'url',
36 'status', 42 'status',
37 ], 43 ],
38 ]) ?> 44 ]) ?>
backend/views/bg/_form.php
@@ -17,16 +17,37 @@ @@ -17,16 +17,37 @@
17 17
18 <div class="bg-form"> 18 <div class="bg-form">
19 19
20 - <?php $form = ActiveForm::begin(); ?>  
21 -  
22 - <?= $form->field($model, 'title')  
23 - ->textInput([ 'maxlength' => true ]) ?> 20 + <?php $form = ActiveForm::begin([
  21 + 'options' => [
  22 + 'enctype' => 'multipart/form-data',
  23 + ],
  24 + ]); ?>
24 25
25 <?= $form->field($model, 'url') 26 <?= $form->field($model, 'url')
26 ->textInput([ 'maxlength' => true ]) ?> 27 ->textInput([ 'maxlength' => true ]) ?>
27 28
  29 +
28 <?= $form->field($model, 'image') 30 <?= $form->field($model, 'image')
29 - ->textInput([ 'maxlength' => true ]) ?> 31 + ->widget(\kartik\file\FileInput::className(), [
  32 + 'model' => $model,
  33 + 'attribute' => 'image',
  34 + 'options' => [
  35 + 'accept' => 'image/*',
  36 + 'multiple' => false,
  37 + ],
  38 + 'pluginOptions' => [
  39 + 'allowedFileExtensions' => [
  40 + 'jpg',
  41 + 'gif',
  42 + 'png',
  43 + ],
  44 + 'initialPreview' => $model->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'slider') : '',
  45 + 'showRemove' => false,
  46 + 'overwriteInitial' => true,
  47 + 'showUpload' => false,
  48 + 'showClose' => false,
  49 + ],
  50 + ]); ?>
30 51
31 <?= LanguageForm::widget([ 52 <?= LanguageForm::widget([
32 'model_langs' => $model_langs, 53 'model_langs' => $model_langs,
@@ -35,7 +56,7 @@ @@ -35,7 +56,7 @@
35 ]) ?> 56 ]) ?>
36 57
37 <div class="form-group"> 58 <div class="form-group">
38 - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> 59 + <?= Html::submitButton($model->isNewRecord ? \Yii::t('app', 'Create') : \Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
39 </div> 60 </div>
40 61
41 <?php ActiveForm::end(); ?> 62 <?php ActiveForm::end(); ?>
backend/views/bg/create.php
@@ -11,9 +11,9 @@ @@ -11,9 +11,9 @@
11 * @var BgLang[] $model_langs 11 * @var BgLang[] $model_langs
12 */ 12 */
13 13
14 - $this->title = 'Create Bg'; 14 + $this->title = \Yii::t('app', 'Create Bg');
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
16 - 'label' => 'Bgs', 16 + 'label' => \Yii::t('app', 'Bgs'),
17 'url' => [ 'index' ], 17 'url' => [ 'index' ],
18 ]; 18 ];
19 $this->params[ 'breadcrumbs' ][] = $this->title; 19 $this->params[ 'breadcrumbs' ][] = $this->title;
backend/views/bg/index.php
@@ -7,7 +7,7 @@ use yii\grid\GridView; @@ -7,7 +7,7 @@ use yii\grid\GridView;
7 /* @var $searchModel common\models\BgSearch */ 7 /* @var $searchModel common\models\BgSearch */
8 /* @var $dataProvider yii\data\ActiveDataProvider */ 8 /* @var $dataProvider yii\data\ActiveDataProvider */
9 9
10 -$this->title = 'Bgs'; 10 +$this->title = \Yii::t('app', 'Bgs');
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 <div class="bg-index"> 13 <div class="bg-index">
@@ -16,19 +16,16 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -16,19 +16,16 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17 17
18 <p> 18 <p>
19 - <?= Html::a('Create Bg', ['create'], ['class' => 'btn btn-success']) ?> 19 + <?= Html::a(\Yii::t('app', 'Create Bg'), ['create'], ['class' => 'btn btn-success']) ?>
20 </p> 20 </p>
21 <?= GridView::widget([ 21 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 22 'dataProvider' => $dataProvider,
23 'filterModel' => $searchModel, 23 'filterModel' => $searchModel,
24 'columns' => [ 24 'columns' => [
25 ['class' => 'yii\grid\SerialColumn'], 25 ['class' => 'yii\grid\SerialColumn'],
26 -  
27 'id', 26 'id',
28 - 'title',  
29 - 'url:url',  
30 - 'image',  
31 - 27 + 'url',
  28 + 'imageUrl:image',
32 ['class' => 'yii\grid\ActionColumn'], 29 ['class' => 'yii\grid\ActionColumn'],
33 ], 30 ],
34 ]); ?> 31 ]); ?>
backend/views/bg/update.php
@@ -11,19 +11,19 @@ @@ -11,19 +11,19 @@
11 * @var BgLang[] $model_langs 11 * @var BgLang[] $model_langs
12 */ 12 */
13 13
14 - $this->title = 'Update Bg: ' . $model->title; 14 + $this->title = \Yii::t('app', 'Update Bg: ') . $model->id;
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
16 - 'label' => 'Bgs', 16 + 'label' => \Yii::t('app', 'Bgs'),
17 'url' => [ 'index' ], 17 'url' => [ 'index' ],
18 ]; 18 ];
19 $this->params[ 'breadcrumbs' ][] = [ 19 $this->params[ 'breadcrumbs' ][] = [
20 - 'label' => $model->title, 20 + 'label' => $model->id,
21 'url' => [ 21 'url' => [
22 'view', 22 'view',
23 'id' => $model->id, 23 'id' => $model->id,
24 ], 24 ],
25 ]; 25 ];
26 - $this->params[ 'breadcrumbs' ][] = 'Update'; 26 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update');
27 ?> 27 ?>
28 <div class="bg-update"> 28 <div class="bg-update">
29 29
backend/views/bg/view.php
@@ -6,8 +6,8 @@ use yii\widgets\DetailView; @@ -6,8 +6,8 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\models\Bg */ 7 /* @var $model common\models\Bg */
8 8
9 -$this->title = $model->title;  
10 -$this->params['breadcrumbs'][] = ['label' => 'Bgs', 'url' => ['index']]; 9 +$this->title = $model->id;
  10 +$this->params['breadcrumbs'][] = ['label' => \Yii::t('app', 'Bgs'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 <div class="bg-view"> 13 <div class="bg-view">
@@ -15,11 +15,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -15,11 +15,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 16
17 <p> 17 <p>
18 - <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a('Delete', ['delete', 'id' => $model->id], [ 18 + <?= Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
20 'class' => 'btn btn-danger', 20 'class' => 'btn btn-danger',
21 'data' => [ 21 'data' => [
22 - 'confirm' => 'Are you sure you want to delete this item?', 22 + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'),
23 'method' => 'post', 23 'method' => 'post',
24 ], 24 ],
25 ]) ?> 25 ]) ?>
@@ -29,9 +29,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -29,9 +29,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
29 'model' => $model, 29 'model' => $model,
30 'attributes' => [ 30 'attributes' => [
31 'id', 31 'id',
32 - 'title',  
33 - 'url:url',  
34 - 'image', 32 + 'url',
  33 + 'imageUrl:image',
35 ], 34 ],
36 ]) ?> 35 ]) ?>
37 36
backend/views/brand/_form.php
@@ -22,14 +22,8 @@ @@ -22,14 +22,8 @@
22 'options' => [ 'enctype' => 'multipart/form-data' ], 22 'options' => [ 'enctype' => 'multipart/form-data' ],
23 ]); ?> 23 ]); ?>
24 24
25 - <?= $form->field($model, 'name')  
26 - ->textInput() ?>  
27 -  
28 - <?= $form->field($model, 'alias')  
29 - ->textInput([ 'maxlength' => true ]) ?>  
30 -  
31 <?= $form->field($model, 'image') 25 <?= $form->field($model, 'image')
32 - ->widget(\kartik\file\FileInput::classname(), [ 26 + ->widget(\kartik\file\FileInput::className(), [
33 'language' => 'ru', 27 'language' => 'ru',
34 'options' => [ 28 'options' => [
35 'accept' => 'image/*', 29 'accept' => 'image/*',
@@ -49,18 +43,6 @@ @@ -49,18 +43,6 @@
49 ], 43 ],
50 ]); ?> 44 ]); ?>
51 45
52 - <?= $form->field($model, 'meta_title')  
53 - ->textInput([ 'maxlength' => true ]) ?>  
54 -  
55 - <?= $form->field($model, 'meta_desc')  
56 - ->textarea([ 'rows' => 6 ]) ?>  
57 -  
58 - <?= $form->field($model, 'meta_robots')  
59 - ->textInput([ 'maxlength' => true ]) ?>  
60 -  
61 - <?= $form->field($model, 'seo_text')  
62 - ->textarea([ 'rows' => 6 ]) ?>  
63 -  
64 <?= LanguageForm::widget([ 46 <?= LanguageForm::widget([
65 'model_langs' => $model_langs, 47 'model_langs' => $model_langs,
66 'formView' => '@backend/views/brand/_form_language', 48 'formView' => '@backend/views/brand/_form_language',
backend/views/brand/_form_language.php
@@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
14 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 14 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
15 ->textInput([ 'maxlength' => true ]); ?> 15 ->textInput([ 'maxlength' => true ]); ?>
16 16
  17 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  18 + ->textInput([ 'maxlength' => true ]); ?>
  19 +
17 <?= $form->field($model_lang, '[' . $language->language_id . ']meta_title') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
18 ->textInput([ 'maxlength' => true ]) ?> 21 ->textInput([ 'maxlength' => true ]) ?>
19 22
backend/views/brand/index.php
@@ -13,27 +13,16 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -13,27 +13,16 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
13 <div class="brand-index"> 13 <div class="brand-index">
14 14
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
17 16
18 <p> 17 <p>
19 <?= Html::a(Yii::t('product', 'Create Brand'), ['create'], ['class' => 'btn btn-success']) ?> 18 <?= Html::a(Yii::t('product', 'Create Brand'), ['create'], ['class' => 'btn btn-success']) ?>
20 </p> 19 </p>
21 <?= GridView::widget([ 20 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 21 'dataProvider' => $dataProvider,
23 -// 'filterModel' => $searchModel,  
24 'columns' => [ 22 'columns' => [
25 ['class' => 'yii\grid\SerialColumn'], 23 ['class' => 'yii\grid\SerialColumn'],
26 -  
27 - 'name',  
28 - 'alias',  
29 - [  
30 - 'attribute' => 'title',  
31 - 'format' => 'html',  
32 - 'value' => function($data) {  
33 - return Html::img($data->imageUrl, ['width'=>'100']);  
34 - },  
35 - ],  
36 - 24 + 'brand_id',
  25 + 'imageUrl:image',
37 ['class' => 'yii\grid\ActionColumn'], 26 ['class' => 'yii\grid\ActionColumn'],
38 ], 27 ],
39 ]); ?> 28 ]); ?>
backend/views/brand/view.php
@@ -29,12 +29,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -29,12 +29,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
29 'model' => $model, 29 'model' => $model,
30 'attributes' => [ 30 'attributes' => [
31 'brand_id', 31 'brand_id',
32 - 'alias',  
33 'imageUrl:image', 32 'imageUrl:image',
34 - 'meta_title',  
35 - 'meta_desc:ntext',  
36 - 'meta_robots',  
37 - 'seo_text:ntext',  
38 ], 33 ],
39 ]) ?> 34 ]) ?>
40 35
backend/views/category/_form.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use yii\helpers\Html; 6 use yii\helpers\Html;
7 use yii\web\View; 7 use yii\web\View;
8 use yii\widgets\ActiveForm; 8 use yii\widgets\ActiveForm;
9 - use mihaildev\ckeditor\CKEditor;  
10 - use mihaildev\elfinder\ElFinder;  
11 9
12 /** 10 /**
13 * @var View $this 11 * @var View $this
@@ -25,12 +23,6 @@ @@ -25,12 +23,6 @@
25 'options' => [ 'enctype' => 'multipart/form-data' ], 23 'options' => [ 'enctype' => 'multipart/form-data' ],
26 ]); ?> 24 ]); ?>
27 25
28 - <?= $form->field($model, 'name')  
29 - ->textInput() ?>  
30 -  
31 - <?= $form->field($model, 'alias')  
32 - ->textInput([ 'maxlength' => true ]) ?>  
33 -  
34 <?= $form->field($model, 'parent_id') 26 <?= $form->field($model, 'parent_id')
35 ->dropDownList($categories, [ 27 ->dropDownList($categories, [
36 'prompt' => Yii::t('rubrication', 'Root category'), 28 'prompt' => Yii::t('rubrication', 'Root category'),
@@ -40,26 +32,8 @@ @@ -40,26 +32,8 @@
40 ]) 32 ])
41 ->label(Yii::t('product', 'Parent category')) ?> 33 ->label(Yii::t('product', 'Parent category')) ?>
42 34
43 - <?php  
44 - /* Tax group - add to controller  
45 - ?>  
46 - <?= $form->field($model, 'taxGroup')->widget(Select2::className(), [  
47 - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'),  
48 - 'language' => 'ru',  
49 - 'options' => [  
50 - 'placeholder' => 'Linked options',  
51 - 'multiple' => true,  
52 - ],  
53 - 'pluginOptions' => [  
54 - 'allowClear' => true  
55 - ],  
56 - ]  
57 - ) ?>  
58 - */  
59 - ?>  
60 -  
61 - <?= $form->field($model, 'imageUpload')  
62 - ->widget(\kartik\file\FileInput::classname(), [ 35 + <?= $form->field($model, 'image')
  36 + ->widget(\kartik\file\FileInput::className(), [
63 'language' => 'ru', 37 'language' => 'ru',
64 'options' => [ 38 'options' => [
65 'accept' => 'image/*', 39 'accept' => 'image/*',
@@ -80,30 +54,6 @@ @@ -80,30 +54,6 @@
80 ]) 54 ])
81 ->hint('Для корректного отображения на сайте, размер изображения должен быть 262x144 либо соблюдать соотношение сторон примерно 2:1'); ?> 55 ->hint('Для корректного отображения на сайте, размер изображения должен быть 262x144 либо соблюдать соотношение сторон примерно 2:1'); ?>
82 56
83 - <?= $form->field($model, 'meta_title')  
84 - ->textInput([ 'maxlength' => true ]) ?>  
85 -  
86 - <?= $form->field($model, 'meta_desc')  
87 - ->textarea([ 'rows' => 6 ]) ?>  
88 -  
89 - <?= $form->field($model, 'meta_robots')  
90 - ->textInput([ 'maxlength' => true ]) ?>  
91 -  
92 - <?= $form->field($model, 'h1')  
93 - ->textInput([ 'maxlength' => true ]) ?>  
94 -  
95 - <?= $form->field($model, 'seo_text')  
96 - ->widget(CKEditor::className(), [  
97 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
98 - 'preset' => 'full',  
99 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
100 - 'inline' => false,  
101 - //по умолчанию false]),  
102 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
103 - ->createUrl('file/uploader/images-upload'),  
104 - ]),  
105 - ]) ?>  
106 -  
107 <?= LanguageForm::widget([ 57 <?= LanguageForm::widget([
108 'model_langs' => $model_langs, 58 'model_langs' => $model_langs,
109 'formView' => '@backend/views/category/_form_language', 59 'formView' => '@backend/views/category/_form_language',
backend/views/category/_form_language.php
@@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
14 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 14 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
15 ->textInput([ 'maxlength' => true ]); ?> 15 ->textInput([ 'maxlength' => true ]); ?>
16 16
  17 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  18 + ->textInput([ 'maxlength' => true ]); ?>
  19 +
17 <?= $form->field($model_lang, '[' . $language->language_id . ']meta_title') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
18 ->textInput([ 'maxlength' => true ]) ?> 21 ->textInput([ 'maxlength' => true ]) ?>
19 22
backend/views/category/index.php
1 <?php 1 <?php
2 2
  3 + use common\modules\product\models\Category;
3 use yii\helpers\Html; 4 use yii\helpers\Html;
4 use kartik\grid\GridView; 5 use kartik\grid\GridView;
5 6
@@ -25,12 +26,15 @@ @@ -25,12 +26,15 @@
25 [ 26 [
26 'label' => Yii::t('product', 'Name'), 27 'label' => Yii::t('product', 'Name'),
27 'content' => function($data) { 28 'content' => function($data) {
  29 + /**
  30 + * @var Category $data
  31 + */
28 $op = []; 32 $op = [];
29 foreach($data->getParents() 33 foreach($data->getParents()
30 ->all() as $parent) { 34 ->all() as $parent) {
31 - $op[] = $parent->name; 35 + $op[] = $parent->category_id;
32 } 36 }
33 - $op[] = $data->name; 37 + $op[] = $data->category_id;
34 return implode('&nbsp;&rarr;&nbsp;', $op); 38 return implode('&nbsp;&rarr;&nbsp;', $op);
35 }, 39 },
36 ], 40 ],
backend/views/category/update.php
@@ -14,13 +14,13 @@ @@ -14,13 +14,13 @@
14 14
15 $this->title = Yii::t('product', 'Update {modelClass}: ', [ 15 $this->title = Yii::t('product', 'Update {modelClass}: ', [
16 'modelClass' => 'Category', 16 'modelClass' => 'Category',
17 - ]) . ' ' . $model->name; 17 + ]) . ' ' . $model->category_id;
18 $this->params[ 'breadcrumbs' ][] = [ 18 $this->params[ 'breadcrumbs' ][] = [
19 'label' => Yii::t('product', 'Categories'), 19 'label' => Yii::t('product', 'Categories'),
20 'url' => [ 'index' ], 20 'url' => [ 'index' ],
21 ]; 21 ];
22 $this->params[ 'breadcrumbs' ][] = [ 22 $this->params[ 'breadcrumbs' ][] = [
23 - 'label' => $model->name, 23 + 'label' => $model->category_id,
24 'url' => [ 24 'url' => [
25 'view', 25 'view',
26 'id' => $model->category_id, 26 'id' => $model->category_id,
backend/views/category/view.php
@@ -6,7 +6,7 @@ use yii\widgets\DetailView; @@ -6,7 +6,7 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\modules\product\models\Category */ 7 /* @var $model common\modules\product\models\Category */
8 8
9 -$this->title = $model->name; 9 +$this->title = $model->category_id;
10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
@@ -25,7 +25,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -25,7 +25,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
25 ]) ?> 25 ]) ?>
26 <?= Html::a(Yii::t('product', 'Create Category'), ['category/create'], ['class' => 'btn btn-success']) ?> 26 <?= Html::a(Yii::t('product', 'Create Category'), ['category/create'], ['class' => 'btn btn-success']) ?>
27 <?php if (!empty($model->parent_id)) :?> 27 <?php if (!empty($model->parent_id)) :?>
28 - <?= Html::a(Yii::t('product', 'Create category By {name}', ['name' => $model->parent->name]), ['category/create?parent='. $model->parent->category_id], ['class' => 'btn btn-success']) ?> 28 + <?= Html::a(Yii::t('product', 'Create category By {name}', ['name' => $model->parent->category_id]), ['category/create?parent='. $model->parent->category_id], ['class' => 'btn btn-success']) ?>
29 <?php endif?> 29 <?php endif?>
30 </p> 30 </p>
31 31
@@ -37,13 +37,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -37,13 +37,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
37 'path', 37 'path',
38 'depth', 38 'depth',
39 'imageUrl:image', 39 'imageUrl:image',
40 - 'meta_title',  
41 - 'meta_desc:ntext',  
42 - 'meta_robots',  
43 - 'h1',  
44 - 'seo_text:ntext',  
45 'product_unit_id', 40 'product_unit_id',
46 - 'alias',  
47 ], 41 ],
48 ]) ?> 42 ]) ?>
49 43
backend/views/event/_form.php
@@ -25,25 +25,6 @@ @@ -25,25 +25,6 @@
25 'options' => [ 'enctype' => 'multipart/form-data' ], 25 'options' => [ 'enctype' => 'multipart/form-data' ],
26 ]); ?> 26 ]); ?>
27 27
28 - <?= $form->field($model, 'name')  
29 - ->textInput([ 'maxlength' => true ]) ?>  
30 -  
31 - <?= $form->field($model, 'alias')  
32 - ->textInput([ 'maxlength' => true ]) ?>  
33 -  
34 - <?= $form->field($model, 'body')  
35 - ->widget(CKEditor::className(), [  
36 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
37 - 'preset' => 'full',  
38 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
39 - 'inline' => false,  
40 - //по умолчанию false]),  
41 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
42 - ->createUrl('file/uploader/images-upload'),  
43 - ]),  
44 - ]) ?>  
45 -  
46 -  
47 <?= $form->field($model, 'end_at') 28 <?= $form->field($model, 'end_at')
48 ->widget(DatePicker::className(), [ 29 ->widget(DatePicker::className(), [
49 'pluginOptions' => [ 30 'pluginOptions' => [
@@ -53,7 +34,7 @@ @@ -53,7 +34,7 @@
53 ]) ?> 34 ]) ?>
54 35
55 36
56 - <?= $form->field($model, 'imageUpload') 37 + <?= $form->field($model, 'image')
57 ->widget(\kartik\file\FileInput::className(), [ 38 ->widget(\kartik\file\FileInput::className(), [
58 'language' => 'ru', 39 'language' => 'ru',
59 'options' => [ 40 'options' => [
@@ -74,18 +55,6 @@ @@ -74,18 +55,6 @@
74 ], 55 ],
75 ]); ?> 56 ]); ?>
76 57
77 - <?= $form->field($model, 'meta_title')  
78 - ->textInput([ 'maxlength' => true ]) ?>  
79 -  
80 - <?= $form->field($model, 'description')  
81 - ->textInput([ 'maxlength' => true ]) ?>  
82 -  
83 - <?= $form->field($model, 'h1')  
84 - ->textInput([ 'maxlength' => true ]) ?>  
85 -  
86 - <?= $form->field($model, 'seo_text')  
87 - ->textarea([ 'rows' => 6 ]) ?>  
88 -  
89 <?= LanguageForm::widget([ 58 <?= LanguageForm::widget([
90 'model_langs' => $model_langs, 59 'model_langs' => $model_langs,
91 'formView' => '@backend/views/event/_form_language', 60 'formView' => '@backend/views/event/_form_language',
backend/views/event/_form_language.php
@@ -15,6 +15,10 @@ @@ -15,6 +15,10 @@
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +
  19 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  20 + ->textInput([ 'maxlength' => true ]); ?>
  21 +
18 <?= $form->field($model_lang, '[' . $language->language_id . ']body') 22 <?= $form->field($model_lang, '[' . $language->language_id . ']body')
19 ->widget(CKEditor::className(), [ 23 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 24 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/event/index.php
1 <?php 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\EventSearch */  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('app', 'Events');  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\grid\GridView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $searchModel common\models\EventSearch */
  8 + /* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 + $this->title = Yii::t('app', 'Events');
  11 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 12 ?>
13 <div class="event-index"> 13 <div class="event-index">
14 - 14 +
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17 - 17 +
18 <p> 18 <p>
19 - <?= Html::a(Yii::t('app', 'Create Event'), ['create'], ['class' => 'btn btn-success']) ?> 19 + <?= Html::a(Yii::t('app', 'Create Event'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
20 </p> 20 </p>
21 <?= GridView::widget([ 21 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 22 'dataProvider' => $dataProvider,
23 - 'filterModel' => $searchModel,  
24 - 'columns' => [  
25 - ['class' => 'yii\grid\SerialColumn'],  
26 - 23 + 'filterModel' => $searchModel,
  24 + 'columns' => [
  25 + [ 'class' => 'yii\grid\SerialColumn' ],
27 'event_id', 26 'event_id',
28 - 'name',  
29 - 'alias',  
30 - [  
31 - 'format' => 'image',  
32 - 'attribute'=>'image',  
33 - ],  
34 - // 'meta_title',  
35 - // 'description',  
36 - // 'h1',  
37 - // 'seo_text:ntext',  
38 - // 'created_at',  
39 - // 'updated_at',  
40 - // 'end_at',  
41 -  
42 - ['class' => 'yii\grid\ActionColumn'], 27 + 'imageUrl:image',
  28 + [ 'class' => 'yii\grid\ActionColumn' ],
43 ], 29 ],
44 ]); ?> 30 ]); ?>
45 </div> 31 </div>
backend/views/event/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('app', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('app', 'Update {modelClass}: ', [
15 'modelClass' => 'Event', 15 'modelClass' => 'Event',
16 - ]) . $model->name; 16 + ]) . $model->event_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('app', 'Events'), 18 'label' => Yii::t('app', 'Events'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->name, 22 + 'label' => $model->event_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->event_id, 25 'id' => $model->event_id,
backend/views/event/view.php
1 <?php 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\Event */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Events'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\models\Event */
  8 +
  9 + $this->title = $model->event_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('app', 'Events'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="event-view"> 16 <div class="event-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->event_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->event_id], [ 21 + <?= Html::a(Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->event_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->event_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'event_id', 40 'event_id',
32 - 'name',  
33 - 'alias',  
34 - 'meta_title',  
35 - 'description',  
36 - 'h1', 41 + 'imageUrl:image',
37 ], 42 ],
38 ]) ?> 43 ]) ?>
39 44
backend/views/page/_form.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use yii\helpers\Html; 6 use yii\helpers\Html;
7 use yii\web\View; 7 use yii\web\View;
8 use yii\widgets\ActiveForm; 8 use yii\widgets\ActiveForm;
9 - use mihaildev\ckeditor\CKEditor;  
10 - use mihaildev\elfinder\ElFinder;  
11 9
12 /** 10 /**
13 * @var View $this 11 * @var View $this
@@ -21,49 +19,15 @@ @@ -21,49 +19,15 @@
21 19
22 <?php $form = ActiveForm::begin(); ?> 20 <?php $form = ActiveForm::begin(); ?>
23 21
24 - <?= $form->field($model, 'title')  
25 - ->textInput([ 'maxlength' => true ]) ?>  
26 -  
27 - <?= $form->field($model, 'translit')  
28 - ->textInput([ 'maxlength' => true ]) ?>  
29 -  
30 - <?= $form->field($model, 'body')  
31 - ->widget(CKEditor::className(), [  
32 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
33 - 'preset' => 'full',  
34 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
35 - 'inline' => false,  
36 - //по умолчанию false]),  
37 - 'allowedContent' => true,  
38 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
39 - ->createUrl('file/uploader/images-upload'),  
40 - ]),  
41 - ]) ?>  
42 -  
43 - <?= $form->field($model, 'meta_title')  
44 - ->textInput([ 'maxlength' => true ]) ?>  
45 -  
46 - <?= $form->field($model, 'meta_keywords')  
47 - ->textInput([ 'maxlength' => true ]) ?>  
48 -  
49 - <?= $form->field($model, 'meta_description')  
50 - ->textInput([ 'maxlength' => true ]) ?>  
51 -  
52 - <?= $form->field($model, 'seo_text')  
53 - ->textarea([ 'rows' => 6 ]) ?>  
54 -  
55 - <?= $form->field($model, 'h1')  
56 - ->textInput([ 'maxlength' => true ]) ?>  
57 -  
58 - <?= $form->field($model, 'in_menu')  
59 - ->checkbox() ?>  
60 -  
61 <?= LanguageForm::widget([ 22 <?= LanguageForm::widget([
62 'model_langs' => $model_langs, 23 'model_langs' => $model_langs,
63 'formView' => '@backend/views/page/_form_language', 24 'formView' => '@backend/views/page/_form_language',
64 'form' => $form, 25 'form' => $form,
65 ]) ?> 26 ]) ?>
66 27
  28 + <?= $form->field($model, 'in_menu')
  29 + ->checkbox() ?>
  30 +
67 <div class="form-group"> 31 <div class="form-group">
68 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> 32 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
69 </div> 33 </div>
backend/views/page/_form_language.php
@@ -7,15 +7,16 @@ @@ -7,15 +7,16 @@
7 use yii\widgets\ActiveForm; 7 use yii\widgets\ActiveForm;
8 8
9 /** 9 /**
10 - * @var PageLang $model_lang  
11 - * @var Language $language  
12 - * @var ActiveForm $form  
13 - * @var View $this 10 + * @var PageLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
14 */ 14 */
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']title') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']title')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
18 - 18 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  19 + ->textInput([ 'maxlength' => true ]); ?>
19 <?= $form->field($model_lang, '[' . $language->language_id . ']body') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']body')
20 ->widget(CKEditor::className(), [ 21 ->widget(CKEditor::className(), [
21 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 22 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/page/create.php
@@ -10,9 +10,9 @@ @@ -10,9 +10,9 @@
10 * @var Page $model 10 * @var Page $model
11 * @var PageLang[] $model_langs 11 * @var PageLang[] $model_langs
12 */ 12 */
13 - $this->title = 'Create Page'; 13 + $this->title = \Yii::t('app', 'Create Page');
14 $this->params[ 'breadcrumbs' ][] = [ 14 $this->params[ 'breadcrumbs' ][] = [
15 - 'label' => 'Pages', 15 + 'label' => \Yii::t('app', 'Pages'),
16 'url' => [ 'index' ], 16 'url' => [ 'index' ],
17 ]; 17 ];
18 $this->params[ 'breadcrumbs' ][] = $this->title; 18 $this->params[ 'breadcrumbs' ][] = $this->title;
backend/views/page/index.php
@@ -7,32 +7,22 @@ use yii\grid\GridView; @@ -7,32 +7,22 @@ use yii\grid\GridView;
7 /* @var $searchModel common\models\PageSearch */ 7 /* @var $searchModel common\models\PageSearch */
8 /* @var $dataProvider yii\data\ActiveDataProvider */ 8 /* @var $dataProvider yii\data\ActiveDataProvider */
9 9
10 -$this->title = 'Pages'; 10 +$this->title = \Yii::t('app', 'Pages');
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 <div class="page-index"> 13 <div class="page-index">
14 14
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
17 16
18 <p> 17 <p>
19 - <?= Html::a('Create Page', ['create'], ['class' => 'btn btn-success']) ?> 18 + <?= Html::a(\Yii::t('app', 'Create Page'), ['create'], ['class' => 'btn btn-success']) ?>
20 </p> 19 </p>
21 <?= GridView::widget([ 20 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 21 'dataProvider' => $dataProvider,
23 'filterModel' => $searchModel, 22 'filterModel' => $searchModel,
24 'columns' => [ 23 'columns' => [
25 ['class' => 'yii\grid\SerialColumn'], 24 ['class' => 'yii\grid\SerialColumn'],
26 -  
27 'id', 25 'id',
28 - 'translit',  
29 - 'title',  
30 - 'meta_title',  
31 - // 'meta_keywords',  
32 - // 'meta_description',  
33 - // 'seo_text:ntext',  
34 - // 'h1',  
35 -  
36 ['class' => 'yii\grid\ActionColumn'], 26 ['class' => 'yii\grid\ActionColumn'],
37 ], 27 ],
38 ]); ?> 28 ]); ?>
backend/views/page/update.php
@@ -11,19 +11,19 @@ @@ -11,19 +11,19 @@
11 * @var PageLang[] $model_langs 11 * @var PageLang[] $model_langs
12 */ 12 */
13 13
14 - $this->title = 'Update Page: ' . $model->title; 14 + $this->title = \Yii::t('app', 'Update Page').': ' . $model->id;
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
16 - 'label' => 'Pages', 16 + 'label' => \Yii::t('app', 'Pages'),
17 'url' => [ 'index' ], 17 'url' => [ 'index' ],
18 ]; 18 ];
19 $this->params[ 'breadcrumbs' ][] = [ 19 $this->params[ 'breadcrumbs' ][] = [
20 - 'label' => $model->title, 20 + 'label' => $model->id,
21 'url' => [ 21 'url' => [
22 'view', 22 'view',
23 'id' => $model->id, 23 'id' => $model->id,
24 ], 24 ],
25 ]; 25 ];
26 - $this->params[ 'breadcrumbs' ][] = 'Update'; 26 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update');
27 ?> 27 ?>
28 <div class="page-update"> 28 <div class="page-update">
29 29
backend/views/page/view.php
1 <?php 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\Page */  
8 -  
9 -$this->title = $model->title;  
10 -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\models\Page */
  8 +
  9 + $this->title = $model->id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => \Yii::t('app', 'Pages'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="page-view"> 16 <div class="page-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a('Delete', ['delete', 'id' => $model->id], [ 21 + <?= Html::a(\Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(\Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [  
22 - 'confirm' => 'Are you sure you want to delete this item?',  
23 - 'method' => 'post', 30 + 'data' => [
  31 + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'),
  32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'id', 40 'id',
32 - 'translit',  
33 - 'title',  
34 - 'body:ntext',  
35 - 'meta_title',  
36 - 'meta_keywords',  
37 - 'meta_description',  
38 - 'seo_text:ntext',  
39 - 'h1',  
40 ], 41 ],
41 ]) ?> 42 ]) ?>
42 43
backend/views/project/_form.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use yii\helpers\Html; 6 use yii\helpers\Html;
7 use yii\web\View; 7 use yii\web\View;
8 use yii\widgets\ActiveForm; 8 use yii\widgets\ActiveForm;
9 - use mihaildev\ckeditor\CKEditor;  
10 - use mihaildev\elfinder\ElFinder;  
11 use yii\jui\DatePicker; 9 use yii\jui\DatePicker;
12 10
13 /** 11 /**
@@ -30,24 +28,6 @@ @@ -30,24 +28,6 @@
30 'dateFormat' => 'dd-MM-yyyy', 28 'dateFormat' => 'dd-MM-yyyy',
31 ]) ?> 29 ]) ?>
32 30
33 - <?= $form->field($model, 'title')  
34 - ->textInput([ 'maxlength' => true ]) ?>  
35 -  
36 - <?= $form->field($model, 'link')  
37 - ->textInput([ 'maxlength' => true ]) ?>  
38 -  
39 - <?= $form->field($model, 'description')  
40 - ->widget(CKEditor::className(), [  
41 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
42 - 'preset' => 'full',  
43 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
44 - 'inline' => false,  
45 - //по умолчанию false]),  
46 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
47 - ->createUrl('file/uploader/images-upload'),  
48 - ]),  
49 - ]) ?>  
50 -  
51 <?= $form->field($model, 'imagesUpload[]') 31 <?= $form->field($model, 'imagesUpload[]')
52 ->widget(\kartik\file\FileInput::className(), [ 32 ->widget(\kartik\file\FileInput::className(), [
53 'language' => 'ru', 33 'language' => 'ru',
@@ -78,7 +58,7 @@ @@ -78,7 +58,7 @@
78 ]) ?> 58 ]) ?>
79 59
80 <div class="form-group"> 60 <div class="form-group">
81 - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> 61 + <?= Html::submitButton($model->isNewRecord ? \Yii::t('app', 'Create') : \Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
82 </div> 62 </div>
83 63
84 <?php ActiveForm::end(); ?> 64 <?php ActiveForm::end(); ?>
backend/views/project/_form_language.php
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']title') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']title')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  19 + ->textInput([ 'maxlength' => true ]); ?>
18 <?= $form->field($model_lang, '[' . $language->language_id . ']description') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']description')
19 ->widget(CKEditor::className(), [ 21 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 22 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/project/create.php
@@ -11,9 +11,9 @@ @@ -11,9 +11,9 @@
11 * @var ProjectLang $model_langs 11 * @var ProjectLang $model_langs
12 */ 12 */
13 13
14 - $this->title = 'Create Project'; 14 + $this->title = \Yii::t('app', 'Create Project');
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
16 - 'label' => 'Projects', 16 + 'label' => \Yii::t('app', 'Projects'),
17 'url' => [ 'index' ], 17 'url' => [ 'index' ],
18 ]; 18 ];
19 $this->params[ 'breadcrumbs' ][] = $this->title; 19 $this->params[ 'breadcrumbs' ][] = $this->title;
backend/views/project/index.php
@@ -7,15 +7,15 @@ use yii\grid\GridView; @@ -7,15 +7,15 @@ use yii\grid\GridView;
7 /* @var $searchModel common\models\ArticlesSearch */ 7 /* @var $searchModel common\models\ArticlesSearch */
8 /* @var $dataProvider yii\data\ActiveDataProvider */ 8 /* @var $dataProvider yii\data\ActiveDataProvider */
9 9
10 -$this->title = 'Project'; 10 +$this->title = \Yii::t('app', 'Project');
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="articles-index" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> 13 +<div class="articles-index">
14 14
15 - <h1 itemprop="title"><?= Html::encode($this->title) ?></h1> 15 + <h1><?= Html::encode($this->title) ?></h1>
16 16
17 <p> 17 <p>
18 - <?= Html::a('Create Project', ['create'], ['class' => 'btn btn-success']) ?> 18 + <?= Html::a(\Yii::t('app', 'Create Project'), ['create'], ['class' => 'btn btn-success']) ?>
19 </p> 19 </p>
20 <?= GridView::widget([ 20 <?= GridView::widget([
21 'dataProvider' => $dataProvider, 21 'dataProvider' => $dataProvider,
@@ -24,8 +24,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -24,8 +24,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
24 ['class' => 'yii\grid\SerialColumn'], 24 ['class' => 'yii\grid\SerialColumn'],
25 'project_id', 25 'project_id',
26 'date_add:date', 26 'date_add:date',
27 - 'title',  
28 -  
29 [ 27 [
30 'class' => 'yii\grid\ActionColumn', 28 'class' => 'yii\grid\ActionColumn',
31 'buttons' => [ 29 'buttons' => [
backend/views/project/product-create.php
@@ -14,9 +14,9 @@ @@ -14,9 +14,9 @@
14 * @var ProductToProject $model 14 * @var ProductToProject $model
15 * @var array $variants 15 * @var array $variants
16 */ 16 */
17 - $this->title = 'Create product to project'; 17 + $this->title = \Yii::t('app', 'Create product to project');
18 $this->params[ 'breadcrumbs' ][] = [ 18 $this->params[ 'breadcrumbs' ][] = [
19 - 'label' => 'Products to project', 19 + 'label' => \Yii::t('app', 'Products to project'),
20 'url' => [ 20 'url' => [
21 'product', 21 'product',
22 'id' => $project->project_id, 22 'id' => $project->project_id,
@@ -29,30 +29,28 @@ @@ -29,30 +29,28 @@
29 <?php 29 <?php
30 $form = ActiveForm::begin(); 30 $form = ActiveForm::begin();
31 echo $form->field($model, 'product_id') 31 echo $form->field($model, 'product_id')
32 - ->dropDownList($products, [ 'prompt' => 'Выберите коллекцию' ]); 32 + ->dropDownList($products, [ 'prompt' => \Yii::t('app', 'Выберите коллекцию')]);
33 ?> 33 ?>
34 <div class="<?php echo( !empty( $variants ) ? '' : 'hidden' ); ?> product_variant_container"> 34 <div class="<?php echo( !empty( $variants ) ? '' : 'hidden' ); ?> product_variant_container">
35 <?php 35 <?php
36 echo $form->field($model, 'product_variant_id') 36 echo $form->field($model, 'product_variant_id')
37 - ->dropDownList($variants, [ 'prompt' => 'Выберите товар' ]); 37 + ->dropDownList($variants, [ 'prompt' => \Yii::t('app', 'Выберите товар')]);
38 ?> 38 ?>
39 </div> 39 </div>
40 <?php 40 <?php
41 - echo Html::submitInput(($model->isNewRecord?'Добавить':'Обновить'), [ 'class' => 'btn btn-success' ]); 41 + echo Html::submitInput(($model->isNewRecord?\Yii::t('app', 'Добавить'):\Yii::t('app', 'Обновить')), [ 'class' => 'btn btn-success' ]);
42 $form::end(); 42 $form::end();
43 ?> 43 ?>
44 </div> 44 </div>
45 -<script>  
46 - $(  
47 - function()  
48 - {  
49 - $(document).on( 45 +<?php
  46 +$this->registerJs("
  47 + $(document).on(
50 'change', '#producttoproject-product_id', function(e) 48 'change', '#producttoproject-product_id', function(e)
51 { 49 {
52 var value = parseInt($(this).val()); 50 var value = parseInt($(this).val());
53 var dropDown = $('#producttoproject-product_variant_id'); 51 var dropDown = $('#producttoproject-product_variant_id');
54 var container = $(dropDown).parents('.product_variant_container'); 52 var container = $(dropDown).parents('.product_variant_container');
55 - $(dropDown).find('option[value!=""]').remove(); 53 + $(dropDown).find('option[value!=\"\"]').remove();
56 $(container).addClass('hidden'); 54 $(container).addClass('hidden');
57 if(value) 55 if(value)
58 { 56 {
@@ -65,7 +63,7 @@ @@ -65,7 +63,7 @@
65 data, function(key, value) 63 data, function(key, value)
66 { 64 {
67 $(dropDown) 65 $(dropDown)
68 - .append('<option value="' + value.product_variant_id + '">' + value.name + '</option>'); 66 + .append('<option value=\"' + value.product_variant_id + '\">' + value.product_variant_id + '</option>');
69 } 67 }
70 ); 68 );
71 console.log('hiodde'); 69 console.log('hiodde');
@@ -76,6 +74,5 @@ @@ -76,6 +74,5 @@
76 } 74 }
77 } 75 }
78 ); 76 );
79 - }  
80 - );  
81 -</script>  
82 \ No newline at end of file 77 \ No newline at end of file
  78 +");
  79 +?>
83 \ No newline at end of file 80 \ No newline at end of file
backend/views/project/product.php
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 * @var Project $project 16 * @var Project $project
17 */ 17 */
18 18
19 - $this->title = 'Product to project'; 19 + $this->title = \Yii::t('app', 'Product to project');
20 $this->params[ 'breadcrumbs' ][] = $this->title; 20 $this->params[ 'breadcrumbs' ][] = $this->title;
21 ?> 21 ?>
22 <div class="articles-index"> 22 <div class="articles-index">
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <h1 itemprop="title"><?= Html::encode($this->title) ?></h1> 24 <h1 itemprop="title"><?= Html::encode($this->title) ?></h1>
25 25
26 <p> 26 <p>
27 - <?= Html::a('Product to project', [ 27 + <?= Html::a(\Yii::t('app', 'Product to project'), [
28 'product-create', 28 'product-create',
29 'id' => $project->project_id, 29 'id' => $project->project_id,
30 ], [ 'class' => 'btn btn-success' ]) ?> 30 ], [ 'class' => 'btn btn-success' ]) ?>
@@ -34,8 +34,8 @@ @@ -34,8 +34,8 @@
34 'filterModel' => $searchModel, 34 'filterModel' => $searchModel,
35 'columns' => [ 35 'columns' => [
36 [ 'class' => 'yii\grid\SerialColumn' ], 36 [ 'class' => 'yii\grid\SerialColumn' ],
37 - 'product.name',  
38 - 'productVariant.name', 37 + 'product_variant_id',
  38 + 'project_id',
39 [ 39 [
40 'class' => 'yii\grid\ActionColumn', 40 'class' => 'yii\grid\ActionColumn',
41 'template' => '{update} {delete}', 41 'template' => '{update} {delete}',
@@ -62,8 +62,8 @@ @@ -62,8 +62,8 @@
62 'project/product-delete', 62 'project/product-delete',
63 'product_to_project_id' => $model->product_to_project_id, 63 'product_to_project_id' => $model->product_to_project_id,
64 ]), [ 64 ]), [
65 - 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?',  
66 - 'title' => 'Удалить', 65 + 'data-confirm' => \Yii::t('app', 'Вы уверены, что хотите удалить этот элемент?'),
  66 + 'title' => \Yii::t('app', 'Удалить'),
67 'data-method' => 'post', 67 'data-method' => 'post',
68 'data-pjax' => 0, 68 'data-pjax' => 0,
69 ]); 69 ]);
backend/views/project/update.php
@@ -10,19 +10,19 @@ @@ -10,19 +10,19 @@
10 * @var Project $model 10 * @var Project $model
11 * @var ProjectLang $model_langs 11 * @var ProjectLang $model_langs
12 */ 12 */
13 - $this->title = 'Update Project: ' . $model->title; 13 + $this->title = \Yii::t('app', 'Update Project').': ' . $model->project_id;
14 $this->params[ 'breadcrumbs' ][] = [ 14 $this->params[ 'breadcrumbs' ][] = [
15 - 'label' => 'Project', 15 + 'label' => \Yii::t('app', 'Project'),
16 'url' => [ 'index' ], 16 'url' => [ 'index' ],
17 ]; 17 ];
18 $this->params[ 'breadcrumbs' ][] = [ 18 $this->params[ 'breadcrumbs' ][] = [
19 - 'label' => $model->title, 19 + 'label' => $model->project_id,
20 'url' => [ 20 'url' => [
21 'view', 21 'view',
22 'id' => $model->project_id, 22 'id' => $model->project_id,
23 ], 23 ],
24 ]; 24 ];
25 - $this->params[ 'breadcrumbs' ][] = 'Update'; 25 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update');
26 ?> 26 ?>
27 <div class="articles-update"> 27 <div class="articles-update">
28 28
backend/views/project/view.php
@@ -6,20 +6,20 @@ use yii\widgets\DetailView; @@ -6,20 +6,20 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\models\Project */ 7 /* @var $model common\models\Project */
8 8
9 -$this->title = $model->title;  
10 -$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']]; 9 +$this->title = $model->project_id;
  10 +$this->params['breadcrumbs'][] = ['label' => \Yii::t('app', 'Project'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="articles-view" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> 13 +<div class="articles-view">
14 14
15 - <h1 itemprop="title"><?= Html::encode($this->title) ?></h1> 15 + <h1><?= Html::encode($this->title) ?></h1>
16 16
17 <p> 17 <p>
18 - <?= Html::a('Update', ['update', 'id' => $model->project_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a('Delete', ['delete', 'id' => $model->project_id], [ 18 + <?= Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->project_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->project_id], [
20 'class' => 'btn btn-danger', 20 'class' => 'btn btn-danger',
21 'data' => [ 21 'data' => [
22 - 'confirm' => 'Are you sure you want to delete this item?', 22 + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'),
23 'method' => 'post', 23 'method' => 'post',
24 ], 24 ],
25 ]) ?> 25 ]) ?>
@@ -30,7 +30,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -30,7 +30,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
30 'attributes' => [ 30 'attributes' => [
31 'project_id', 31 'project_id',
32 'date_add:date', 32 'date_add:date',
33 - 'title',  
34 ], 33 ],
35 ]) ?> 34 ]) ?>
36 35
backend/views/seo-category/_form.php
@@ -19,9 +19,6 @@ @@ -19,9 +19,6 @@
19 19
20 <?php $form = ActiveForm::begin(); ?> 20 <?php $form = ActiveForm::begin(); ?>
21 21
22 - <?= $form->field($model, 'name')  
23 - ->textInput([ 'maxlength' => true ]) ?>  
24 -  
25 <?= $form->field($model, 'controller') 22 <?= $form->field($model, 'controller')
26 ->textInput([ 'maxlength' => true ]) ?> 23 ->textInput([ 'maxlength' => true ]) ?>
27 24
backend/views/seo-category/index.php
@@ -24,12 +24,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -24,12 +24,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
24 'filterModel' => $searchModel, 24 'filterModel' => $searchModel,
25 'columns' => [ 25 'columns' => [
26 ['class' => 'yii\grid\SerialColumn'], 26 ['class' => 'yii\grid\SerialColumn'],
27 -  
28 'seo_category_id', 27 'seo_category_id',
29 - 'name',  
30 'controller', 28 'controller',
31 'status', 29 'status',
32 -  
33 [ 30 [
34 'class' => 'yii\grid\ActionColumn', 31 'class' => 'yii\grid\ActionColumn',
35 'template' => '{update}&nbsp;{image}&nbsp;{delete}', 32 'template' => '{update}&nbsp;{image}&nbsp;{delete}',
backend/views/seo-category/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('app', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('app', 'Update {modelClass}: ', [
15 'modelClass' => 'Seo Category', 15 'modelClass' => 'Seo Category',
16 - ]) . $model->name; 16 + ]) . $model->seo_category_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('app', 'Seo Categories'), 18 'label' => Yii::t('app', 'Seo Categories'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->name, 22 + 'label' => $model->seo_category_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->seo_category_id, 25 'id' => $model->seo_category_id,
backend/views/seo-category/view.php
1 <?php 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; 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->seo_category_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('app', 'Seo Categories'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="seo-category-view"> 16 <div class="seo-category-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <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], [ 21 + <?= Html::a(Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->seo_category_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->seo_category_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'seo_category_id', 40 'seo_category_id',
32 - 'name',  
33 'controller', 41 'controller',
34 'status', 42 'status',
35 ], 43 ],
backend/views/seo-dynamic/_form.php
@@ -24,36 +24,15 @@ @@ -24,36 +24,15 @@
24 24
25 <?php $form = ActiveForm::begin(); ?> 25 <?php $form = ActiveForm::begin(); ?>
26 26
27 - <?= $form->field($model, 'name')  
28 - ->textInput([ 'maxlength' => true ]) ?>  
29 -  
30 <?= $form->field($model, 'action') 27 <?= $form->field($model, 'action')
31 ->textInput([ 'maxlength' => true ]) ?> 28 ->textInput([ 'maxlength' => true ]) ?>
32 29
33 <?= $form->field($model, 'param') 30 <?= $form->field($model, 'param')
34 ->textInput([ 'maxlength' => true ]) ?> 31 ->textInput([ 'maxlength' => true ]) ?>
35 32
36 - <?= $form->field($model, 'key')  
37 - ->textInput([ 'maxlength' => true ]) ?>  
38 -  
39 <?= $form->field($model, 'fields') 33 <?= $form->field($model, 'fields')
40 ->textInput([ 'maxlength' => true ]) ?> 34 ->textInput([ 'maxlength' => true ]) ?>
41 35
42 - <?= $form->field($model, 'title')  
43 - ->textInput([ 'maxlength' => true ]) ?>  
44 -  
45 - <?= $form->field($model, 'meta')  
46 - ->textInput([ 'maxlength' => true ]) ?>  
47 -  
48 - <?= $form->field($model, 'h1')  
49 - ->textInput([ 'maxlength' => true ]) ?>  
50 -  
51 - <?= $form->field($model, 'description')  
52 - ->textInput([ 'maxlength' => true ]) ?>  
53 -  
54 - <?= $form->field($model, 'seo_text')  
55 - ->textarea([ 'rows' => 6 ]) ?>  
56 -  
57 <?= $form->field($model, 'status') 36 <?= $form->field($model, 'status')
58 ->textInput() ?> 37 ->textInput() ?>
59 38
backend/views/seo-dynamic/index.php
1 <?php 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; 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 ?> 13 ?>
14 <div class="seo-dynamic-index"> 14 <div class="seo-dynamic-index">
15 - 15 +
16 <h1><?= Html::encode($this->title) ?></h1> 16 <h1><?= Html::encode($this->title) ?></h1>
17 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 17 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
18 - 18 +
19 <p> 19 <p>
20 - <?= Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute(['create','seo_category_id'=>$seo_category_id]), ['class' => 'btn btn-success']) ?> 20 + <?= Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute([
  21 + 'create',
  22 + 'seo_category_id' => $seo_category_id,
  23 + ]), [ 'class' => 'btn btn-success' ]) ?>
21 </p> 24 </p>
22 <?= GridView::widget([ 25 <?= GridView::widget([
23 'dataProvider' => $dataProvider, 26 'dataProvider' => $dataProvider,
24 - 'filterModel' => $searchModel,  
25 - 'columns' => [  
26 - ['class' => 'yii\grid\SerialColumn'],  
27 - 27 + 'filterModel' => $searchModel,
  28 + 'columns' => [
  29 + [ 'class' => 'yii\grid\SerialColumn' ],
28 'seo_dynamic_id', 30 'seo_dynamic_id',
29 'seo_category_id', 31 'seo_category_id',
30 - 'name',  
31 'action', 32 'action',
32 'fields', 33 'fields',
33 - 'meta',  
34 - // 'title',  
35 - // 'h1',  
36 - // 'description',  
37 - // 'seo_text:ntext',  
38 - // 'status',  
39 - 34 + 'status',
40 [ 35 [
41 - 'class' => 'yii\grid\ActionColumn',  
42 - 'buttons' => [  
43 - 'view' => function ($url, $model)  
44 - {  
45 - return Html::a (  
46 - '<span class="glyphicon glyphicon-eye-open"></span>',  
47 - Url::toRoute(['view','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]),  
48 - [ 36 + 'class' => 'yii\grid\ActionColumn',
  37 + 'buttons' => [
  38 + 'view' => function($url, $model) {
  39 + return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Url::toRoute([
  40 + 'view',
  41 + 'seo_category_id' => $model->seo_category_id,
  42 + 'id' => $model->seo_dynamic_id,
  43 + ]), [
49 'title' => "Просмотр", 44 'title' => "Просмотр",
50 - ]  
51 - ); 45 + ]);
52 }, 46 },
53 - 'update' => function ($url, $model)  
54 - {  
55 - return Html::a (  
56 - '<span class="glyphicon glyphicon-pencil"></span>',  
57 - Url::toRoute(['update','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]),  
58 - [ 47 + 'update' => function($url, $model) {
  48 + return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Url::toRoute([
  49 + 'update',
  50 + 'seo_category_id' => $model->seo_category_id,
  51 + 'id' => $model->seo_dynamic_id,
  52 + ]), [
59 'title' => "Редактировать", 53 'title' => "Редактировать",
60 - ]  
61 - ); 54 + ]);
62 }, 55 },
63 - 'delete' => function ($url, $model)  
64 - {  
65 -  
66 - return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute(['delete','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]), [  
67 - 'title' => Yii::t('yii', 'Delete'), 56 + 'delete' => function($url, $model) {
  57 +
  58 + return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute([
  59 + 'delete',
  60 + 'seo_category_id' => $model->seo_category_id,
  61 + 'id' => $model->seo_dynamic_id,
  62 + ]), [
  63 + 'title' => Yii::t('yii', 'Delete'),
68 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 64 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
69 - 'data-method' => 'post', 65 + 'data-method' => 'post',
70 ]); 66 ]);
71 - 67 +
72 }, 68 },
73 ], 69 ],
74 ], 70 ],
backend/views/seo-dynamic/update.php
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 15
16 $this->title = Yii::t('app', 'Update {modelClass}: ', [ 16 $this->title = Yii::t('app', 'Update {modelClass}: ', [
17 'modelClass' => 'Seo Dynamic', 17 'modelClass' => 'Seo Dynamic',
18 - ]) . $model->name; 18 + ]) . $model->seo_dynamic_id;
19 $this->params[ 'breadcrumbs' ][] = [ 19 $this->params[ 'breadcrumbs' ][] = [
20 'label' => Yii::t('app', 'Seo Dynamics'), 20 'label' => Yii::t('app', 'Seo Dynamics'),
21 'url' => Url::toRoute([ 21 'url' => Url::toRoute([
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 ]), 24 ]),
25 ]; 25 ];
26 $this->params[ 'breadcrumbs' ][] = [ 26 $this->params[ 'breadcrumbs' ][] = [
27 - 'label' => $model->name, 27 + 'label' => $model->seo_dynamic_id,
28 'url' => Url::toRoute([ 28 'url' => Url::toRoute([
29 'view', 29 'view',
30 'seo_category_id' => $seo_category_id, 30 'seo_category_id' => $seo_category_id,
backend/views/seo-dynamic/view.php
1 <?php 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; 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->seo_dynamic_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('app', 'Seo Dynamics'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="seo-dynamic-view"> 16 <div class="seo-dynamic-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <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], [ 21 + <?= Html::a(Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->seo_dynamic_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->seo_dynamic_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'seo_dynamic_id', 40 'seo_dynamic_id',
32 'seo_category_id', 41 'seo_category_id',
33 - 'name',  
34 'action', 42 'action',
35 'fields', 43 'fields',
36 - 'title',  
37 - 'meta',  
38 - 'h1',  
39 - 'description',  
40 - 'seo_text:ntext',  
41 'status', 44 'status',
42 ], 45 ],
43 ]) ?> 46 ]) ?>
backend/views/seo/_form.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use yii\helpers\Html; 6 use yii\helpers\Html;
7 use yii\web\View; 7 use yii\web\View;
8 use yii\widgets\ActiveForm; 8 use yii\widgets\ActiveForm;
9 - use mihaildev\ckeditor\CKEditor;  
10 - use mihaildev\elfinder\ElFinder;  
11 9
12 /** 10 /**
13 * @var View $this 11 * @var View $this
@@ -24,29 +22,6 @@ @@ -24,29 +22,6 @@
24 <?= $form->field($model, 'url') 22 <?= $form->field($model, 'url')
25 ->textInput([ 'maxlength' => true ]) ?> 23 ->textInput([ 'maxlength' => true ]) ?>
26 24
27 - <?= $form->field($model, 'title')  
28 - ->textInput([ 'maxlength' => true ]) ?>  
29 -  
30 - <?= $form->field($model, 'meta')  
31 - ->textInput([ 'maxlength' => true ]) ?>  
32 -  
33 - <?= $form->field($model, 'description')  
34 - ->textInput([ 'maxlength' => true ]) ?>  
35 -  
36 - <?= $form->field($model, 'h1')  
37 - ->textInput([ 'maxlength' => true ]) ?>  
38 - <?= $form->field($model, 'seo_text')  
39 - ->widget(CKEditor::className(), [  
40 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
41 - 'preset' => 'full',  
42 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
43 - 'inline' => false,  
44 - //по умолчанию false]),  
45 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
46 - ->createUrl('file/uploader/images-upload'),  
47 - ]),  
48 - ]) ?>  
49 -  
50 <?= LanguageForm::widget([ 25 <?= LanguageForm::widget([
51 'model_langs' => $model_langs, 26 'model_langs' => $model_langs,
52 'formView' => '@backend/views/seo/_form_language', 27 'formView' => '@backend/views/seo/_form_language',
backend/views/seo/_form_language.php
@@ -7,14 +7,15 @@ @@ -7,14 +7,15 @@
7 use yii\widgets\ActiveForm; 7 use yii\widgets\ActiveForm;
8 8
9 /** 9 /**
10 - * @var SeoLang $model_lang  
11 - * @var Language $language  
12 - * @var ActiveForm $form  
13 - * @var View $this 10 + * @var SeoLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
14 */ 14 */
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']title') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']title')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +
18 <?= $form->field($model_lang, '[' . $language->language_id . ']description') 19 <?= $form->field($model_lang, '[' . $language->language_id . ']description')
19 ->widget(CKEditor::className(), [ 20 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 21 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/seo/index.php
@@ -23,13 +23,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -23,13 +23,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
23 'filterModel' => $searchModel, 23 'filterModel' => $searchModel,
24 'columns' => [ 24 'columns' => [
25 ['class' => 'yii\grid\SerialColumn'], 25 ['class' => 'yii\grid\SerialColumn'],
26 -  
27 'seo_id', 26 'seo_id',
28 - 'url:url',  
29 - 'meta',  
30 - 'h1',  
31 - // 'seo_text:ntext',  
32 - 27 + 'url',
33 ['class' => 'yii\grid\ActionColumn'], 28 ['class' => 'yii\grid\ActionColumn'],
34 ], 29 ],
35 ]); ?> 30 ]); ?>
backend/views/seo/update.php
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->title, 22 + 'label' => $model->seo_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->seo_id, 25 'id' => $model->seo_id,
backend/views/seo/view.php
@@ -6,7 +6,7 @@ use yii\widgets\DetailView; @@ -6,7 +6,7 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\models\Seo */ 7 /* @var $model common\models\Seo */
8 8
9 -$this->title = $model->title; 9 +$this->title = $model->seo_id;
10 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
@@ -29,12 +29,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -29,12 +29,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
29 'model' => $model, 29 'model' => $model,
30 'attributes' => [ 30 'attributes' => [
31 'seo_id', 31 'seo_id',
32 - 'url:url',  
33 - 'title',  
34 - 'meta',  
35 - 'description',  
36 - 'h1',  
37 - 'seo_text:ntext', 32 + 'url',
38 ], 33 ],
39 ]) ?> 34 ]) ?>
40 35
backend/views/service/_form.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use yii\helpers\Html; 6 use yii\helpers\Html;
7 use yii\web\View; 7 use yii\web\View;
8 use yii\widgets\ActiveForm; 8 use yii\widgets\ActiveForm;
9 - use mihaildev\ckeditor\CKEditor;  
10 - use mihaildev\elfinder\ElFinder;  
11 9
12 /** 10 /**
13 * @var View $this 11 * @var View $this
@@ -19,56 +17,32 @@ @@ -19,56 +17,32 @@
19 17
20 <div class="service-form"> 18 <div class="service-form">
21 19
22 - <?php $form = ActiveForm::begin(); ?>  
23 -  
24 - <?= $form->field($model, 'name')  
25 - ->textInput([ 'maxlength' => true ]) ?>  
26 -  
27 - <?= $form->field($model, 'alias')  
28 - ->textInput([ 'maxlength' => true ]) ?>  
29 -  
30 - <?= $form->field($model, 'body')  
31 - ->widget(CKEditor::className(), [  
32 - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [  
33 - 'preset' => 'full',  
34 - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать  
35 - 'inline' => false,  
36 - //по умолчанию false]),  
37 - 'filebrowserUploadUrl' => Yii::$app->getUrlManager()  
38 - ->createUrl('file/uploader/images-upload'),  
39 - ]),  
40 - ]) ?>  
41 -  
42 -  
43 - <?= \common\modules\file\widgets\ImageUploader::widget([  
44 - 'model' => $model,  
45 - 'field' => 'image',  
46 - 'size' => [  
47 - [  
48 - 'width' => 200,  
49 - 'height' => 200,  
50 - ],  
51 - [  
52 - 'width' => 940,  
53 - 'height' => 480,  
54 - ], 20 + <?php $form = ActiveForm::begin([
  21 + 'options' => [
  22 + 'enctype' => 'multipart/form-data',
55 ], 23 ],
56 - 'multi' => false,  
57 - 'gallery' => $model->image,  
58 - 'name' => 'Загрузить изображение',  
59 ]); ?> 24 ]); ?>
60 25
61 - <?= $form->field($model, 'meta_title')  
62 - ->textInput([ 'maxlength' => true ]) ?>  
63 -  
64 - <?= $form->field($model, 'description')  
65 - ->textInput([ 'maxlength' => true ]) ?>  
66 -  
67 - <?= $form->field($model, 'h1')  
68 - ->textInput([ 'maxlength' => true ]) ?>  
69 -  
70 - <?= $form->field($model, 'seo_text')  
71 - ->textarea([ 'rows' => 6 ]) ?> 26 + <?= $form->field($model, 'image')
  27 + ->widget(\kartik\file\FileInput::className(), [
  28 + 'language' => 'ru',
  29 + 'options' => [
  30 + 'accept' => 'image/*',
  31 + 'multiple' => false,
  32 + ],
  33 + 'pluginOptions' => [
  34 + 'allowedFileExtensions' => [
  35 + 'jpg',
  36 + 'gif',
  37 + 'png',
  38 + ],
  39 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  40 + 'overwriteInitial' => true,
  41 + 'showRemove' => false,
  42 + 'showUpload' => false,
  43 + 'previewFileType' => 'image',
  44 + ],
  45 + ]); ?>
72 46
73 <?= LanguageForm::widget([ 47 <?= LanguageForm::widget([
74 'model_langs' => $model_langs, 48 'model_langs' => $model_langs,
backend/views/service/_form_language.php
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  19 + ->textInput([ 'maxlength' => true ]); ?>
18 <?= $form->field($model_lang, '[' . $language->language_id . ']body') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']body')
19 ->widget(CKEditor::className(), [ 21 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 22 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
backend/views/service/index.php
1 <?php 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\ServiceSearch */  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('app', 'Services');  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\grid\GridView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $searchModel common\models\ServiceSearch */
  8 + /* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 + $this->title = Yii::t('app', 'Services');
  11 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 12 ?>
13 <div class="service-index"> 13 <div class="service-index">
14 - 14 +
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17 - 17 +
18 <p> 18 <p>
19 - <?= Html::a(Yii::t('app', 'Create Service'), ['create'], ['class' => 'btn btn-success']) ?> 19 + <?= Html::a(Yii::t('app', 'Create Service'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
20 </p> 20 </p>
21 <?= GridView::widget([ 21 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 22 'dataProvider' => $dataProvider,
23 - 'filterModel' => $searchModel,  
24 - 'columns' => [  
25 - ['class' => 'yii\grid\SerialColumn'],  
26 - 23 + 'filterModel' => $searchModel,
  24 + 'columns' => [
  25 + [ 'class' => 'yii\grid\SerialColumn' ],
  26 +
27 'service_id', 27 'service_id',
28 - 'name',  
29 - 'alias',  
30 - [  
31 - 'format' => 'image',  
32 - 'attribute'=>'image',  
33 - ],  
34 - // 'meta_title',  
35 - // 'description',  
36 - // 'h1',  
37 - // 'seo_text:ntext',  
38 - // 'created_at',  
39 - // 'updated_at',  
40 -  
41 - ['class' => 'yii\grid\ActionColumn'], 28 + 'imageUrl:image',
  29 + 'created_at:date',
  30 +
  31 + [ 'class' => 'yii\grid\ActionColumn' ],
42 ], 32 ],
43 ]); ?> 33 ]); ?>
44 </div> 34 </div>
backend/views/service/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('app', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('app', 'Update {modelClass}: ', [
15 'modelClass' => 'Service', 15 'modelClass' => 'Service',
16 - ]) . $model->name; 16 + ]) . $model->service_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('app', 'Services'), 18 'label' => Yii::t('app', 'Services'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->name, 22 + 'label' => $model->service_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->service_id, 25 'id' => $model->service_id,
backend/views/service/view.php
1 <?php 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\Service */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Services'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\models\Service */
  8 +
  9 + $this->title = $model->service_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('app', 'Services'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="service-view"> 16 <div class="service-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->service_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->service_id], [ 21 + <?= Html::a(Yii::t('app', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->service_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('app', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->service_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 'model' => $model, 38 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'service_id', 40 'service_id',
32 - 'name',  
33 - 'alias',  
34 - [  
35 - 'format' => 'image',  
36 - 'attribute'=>'image',  
37 - ],  
38 - 'meta_title',  
39 - 'description',  
40 - 'h1',  
41 - 'seo_text:ntext',  
42 - 'created_at',  
43 - 'updated_at', 41 + 'imageUrl:image',
  42 + 'created_at:date',
44 ], 43 ],
45 ]) ?> 44 ]) ?>
46 45
backend/views/slider-image/_form.php
@@ -44,13 +44,6 @@ @@ -44,13 +44,6 @@
44 ], 44 ],
45 ]); ?> 45 ]); ?>
46 46
47 -  
48 - <?= $form->field($model, 'alt')  
49 - ->textInput([ 'maxlength' => true ]) ?>  
50 -  
51 - <?= $form->field($model, 'title')  
52 - ->textInput([ 'maxlength' => true ]) ?>  
53 -  
54 <?= $form->field($model, 'url') 47 <?= $form->field($model, 'url')
55 ->textInput([ 'maxlength' => true ]) ?> 48 ->textInput([ 'maxlength' => true ]) ?>
56 49
@@ -59,8 +52,8 @@ @@ -59,8 +52,8 @@
59 'name' => 'status', 52 'name' => 'status',
60 'hideSearch' => true, 53 'hideSearch' => true,
61 'data' => [ 54 'data' => [
62 - 1 => 'Active',  
63 - 2 => 'Inactive', 55 + 1 => \Yii::t('app', 'Active'),
  56 + 2 => \Yii::t('app', 'Inactive'),
64 ], 57 ],
65 'options' => [ 'placeholder' => 'Select status...' ], 58 'options' => [ 'placeholder' => 'Select status...' ],
66 'pluginOptions' => [ 59 'pluginOptions' => [
backend/views/slider-image/index.php
@@ -27,13 +27,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -27,13 +27,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
27 27
28 'slider_image_id', 28 'slider_image_id',
29 'slider_id', 29 'slider_id',
30 - 'image',  
31 - 'alt',  
32 - 'title',  
33 - // 'url:url',  
34 - // 'status',  
35 - // 'sort',  
36 - 30 + 'imageUrl:image',
  31 + 'url',
  32 + 'status',
37 [ 33 [
38 'class' => 'yii\grid\ActionColumn', 34 'class' => 'yii\grid\ActionColumn',
39 'buttons' => [ 35 'buttons' => [
backend/views/slider-image/view.php
@@ -31,10 +31,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -31,10 +31,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
31 'attributes' => [ 31 'attributes' => [
32 'slider_image_id', 32 'slider_image_id',
33 'slider_id', 33 'slider_id',
34 - 'image',  
35 - 'alt',  
36 - 'title',  
37 - 'url:url', 34 + 'imageUrl:image',
  35 + 'url',
38 'status', 36 'status',
39 'sort', 37 'sort',
40 ], 38 ],
common/behaviors/SaveImgBehavior.php
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 40
41 if(empty($image) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) { 41 if(empty($image) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) {
42 $this->owner->$field_name = $this->owner->getOldAttribute($field_name); 42 $this->owner->$field_name = $this->owner->getOldAttribute($field_name);
43 - } else { 43 + } elseif(!empty($image)) {
44 $imgDir = \Yii::getAlias('@storage/'.$field['directory'].'/'); 44 $imgDir = \Yii::getAlias('@storage/'.$field['directory'].'/');
45 45
46 if(!is_dir($imgDir)) { 46 if(!is_dir($imgDir)) {
common/behaviors/Slug.php
1 <?php 1 <?php
2 -  
3 -namespace common\behaviors;  
4 -  
5 -use yii;  
6 -use yii\base\Behavior;  
7 -use yii\db\ActiveRecord;  
8 -use dosamigos\transliterator\TransliteratorHelper;  
9 -class Slug extends Behavior  
10 -{  
11 - public $in_attribute = 'name';  
12 - public $out_attribute = 'slug';  
13 - public $translit = true;  
14 -  
15 - public function events() 2 +
  3 + namespace common\behaviors;
  4 +
  5 + use yii;
  6 + use yii\base\Behavior;
  7 + use yii\db\ActiveRecord;
  8 + use dosamigos\transliterator\TransliteratorHelper;
  9 +
  10 + class Slug extends Behavior
16 { 11 {
17 - return [  
18 - ActiveRecord::EVENT_BEFORE_INSERT=> 'getSlug',  
19 - ActiveRecord::EVENT_BEFORE_UPDATE=> 'getSlug'  
20 - ];  
21 - }  
22 -  
23 - public function getSlug( $event )  
24 - {  
25 - if(!empty($this->owner->{$this->in_attribute})){  
26 - if ( empty( $this->owner->{$this->out_attribute} ) ) {  
27 - $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->in_attribute} ); 12 +
  13 + public $in_attribute = 'name';
  14 +
  15 + public $out_attribute = 'slug';
  16 +
  17 + public $translit = true;
  18 +
  19 + public function events()
  20 + {
  21 + return [
  22 + ActiveRecord::EVENT_BEFORE_INSERT => 'getSlug',
  23 + ActiveRecord::EVENT_BEFORE_UPDATE => 'getSlug',
  24 + ];
  25 + }
  26 +
  27 + public function getSlug($event)
  28 + {
  29 + if(!empty( $this->owner->{$this->in_attribute} )) {
  30 + if(empty( $this->owner->{$this->out_attribute} )) {
  31 + $this->owner->{$this->out_attribute} = $this->generateSlug($this->owner->{$this->in_attribute});
  32 + } else {
  33 + $this->owner->{$this->out_attribute} = $this->generateSlug($this->owner->{$this->out_attribute});
  34 + }
  35 + }
  36 +
  37 + }
  38 +
  39 + private function generateSlug($slug)
  40 + {
  41 + $slug = $this->slugify($slug);
  42 + if($this->checkUniqueSlug($slug)) {
  43 + return $slug;
28 } else { 44 } else {
29 - $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->out_attribute} ); 45 + for($suffix = 2; !$this->checkUniqueSlug($new_slug = $slug . '-' . $suffix); $suffix++) {
  46 + }
  47 + return $new_slug;
30 } 48 }
31 } 49 }
32 -  
33 - }  
34 -  
35 - private function generateSlug( $slug )  
36 - {  
37 - $slug = $this->slugify( $slug );  
38 - if ( $this->checkUniqueSlug( $slug ) ) {  
39 - return $slug;  
40 - } else {  
41 - for ( $suffix = 2; !$this->checkUniqueSlug( $new_slug = $slug . '-' . $suffix ); $suffix++ ) {}  
42 - return $new_slug; 50 +
  51 + private function slugify($slug)
  52 + {
  53 + if($this->translit) {
  54 + return yii\helpers\Inflector::slug(TransliteratorHelper::process($slug), '-', true);
  55 + } else {
  56 + return $this->slug($slug, '-', true);
  57 + }
43 } 58 }
44 - }  
45 -  
46 - private function slugify( $slug )  
47 - {  
48 - if ( $this->translit ) {  
49 - return yii\helpers\Inflector::slug( TransliteratorHelper::process( $slug ), '-', true );  
50 - } else {  
51 - return $this->slug( $slug, '-', true ); 59 +
  60 + private function slug($string, $replacement = '-', $lowercase = true)
  61 + {
  62 + $string = preg_replace('/[^\p{L}\p{Nd}]+/u', $replacement, $string);
  63 + $string = trim($string, $replacement);
  64 + return $lowercase ? strtolower($string) : $string;
52 } 65 }
53 - }  
54 -  
55 - private function slug( $string, $replacement = '-', $lowercase = true )  
56 - {  
57 - $string = preg_replace( '/[^\p{L}\p{Nd}]+/u', $replacement, $string );  
58 - $string = trim( $string, $replacement );  
59 - return $lowercase ? strtolower( $string ) : $string;  
60 - }  
61 -  
62 - private function checkUniqueSlug( $slug )  
63 - {  
64 - $pk = $this->owner->primaryKey();  
65 - $pk = $pk[0];  
66 -  
67 - $condition = $this->out_attribute . ' = :out_attribute';  
68 - $params = [ ':out_attribute' => $slug ];  
69 - if ( !$this->owner->isNewRecord ) {  
70 - $condition .= ' and ' . $pk . ' != :pk';  
71 - $params[':pk'] = $this->owner->{$pk}; 66 +
  67 + private function checkUniqueSlug($slug)
  68 + {
  69 + $pk = $this->owner->primaryKey();
  70 + $pk = $pk[ 0 ];
  71 +
  72 + $condition = $this->out_attribute . ' = :out_attribute';
  73 + $params = [ ':out_attribute' => $slug ];
  74 + if(!$this->owner->isNewRecord) {
  75 + $condition .= ' and ' . $pk . ' != :pk';
  76 + $params[ ':pk' ] = $this->owner->{$pk};
  77 + }
  78 + return !$this->owner->find()
  79 + ->where($condition, $params)
  80 + ->one();
72 } 81 }
73 -  
74 - return !$this->owner->find()  
75 - ->where( $condition, $params )  
76 - ->one();  
77 - }  
78 -  
79 -}  
80 \ No newline at end of file 82 \ No newline at end of file
  83 +
  84 + }
81 \ No newline at end of file 85 \ No newline at end of file
common/models/Articles.php
@@ -14,16 +14,7 @@ @@ -14,16 +14,7 @@
14 * This is the model class for table "articles". 14 * This is the model class for table "articles".
15 * @property integer $id 15 * @property integer $id
16 * @property integer $date 16 * @property integer $date
17 - * @property string $title  
18 - * @property string $body  
19 * @property string $image 17 * @property string $image
20 - * @property string $translit  
21 - * @property string $meta_title  
22 - * @property string $meta_keywords  
23 - * @property string $meta_description  
24 - * @property string $seo_text  
25 - * @property string $h1  
26 - * @property string $body_preview  
27 * * From language behavior * 18 * * From language behavior *
28 * @property ArticlesLang $lang 19 * @property ArticlesLang $lang
29 * @property ArticlesLang[] $langs 20 * @property ArticlesLang[] $langs
@@ -60,14 +51,14 @@ @@ -60,14 +51,14 @@
60 public function behaviors() 51 public function behaviors()
61 { 52 {
62 return [ 53 return [
63 - 'slug' => [  
64 - 'class' => 'common\behaviors\Slug',  
65 - 'in_attribute' => 'title',  
66 - 'out_attribute' => 'translit',  
67 - 'translit' => true,  
68 - ],  
69 [ 54 [
70 'class' => SaveImgBehavior::className(), 55 'class' => SaveImgBehavior::className(),
  56 + 'fields' => [
  57 + [
  58 + 'name' => 'image',
  59 + 'directory' => 'articles',
  60 + ]
  61 + ],
71 ], 62 ],
72 'language' => [ 63 'language' => [
73 'class' => LanguageBehavior::className(), 64 'class' => LanguageBehavior::className(),
@@ -94,28 +85,7 @@ @@ -94,28 +85,7 @@
94 ], 85 ],
95 [ 86 [
96 [ 87 [
97 - 'title',  
98 - 'body',  
99 - ],  
100 - 'required',  
101 - ],  
102 - [  
103 - [  
104 - 'body',  
105 - 'body_preview',  
106 - 'seo_text',  
107 - ],  
108 - 'string',  
109 - ],  
110 - [  
111 - [  
112 - 'title',  
113 'image', 88 'image',
114 - 'translit',  
115 - 'meta_title',  
116 - 'meta_keywords',  
117 - 'meta_description',  
118 - 'h1',  
119 ], 89 ],
120 'string', 90 'string',
121 'max' => 255, 91 'max' => 255,
@@ -145,19 +115,10 @@ @@ -145,19 +115,10 @@
145 public function attributeLabels() 115 public function attributeLabels()
146 { 116 {
147 return [ 117 return [
148 - 'id' => 'ID',  
149 - 'date' => 'Date',  
150 - 'title' => 'Title',  
151 - 'body' => 'Body',  
152 - 'body_preview' => 'Body preview',  
153 - 'image' => 'Image', 118 + 'id' => Yii::t('app', 'ID'),
  119 + 'date' => Yii::t('app', 'Date'),
  120 + 'image' => Yii::t('app', 'Image'),
154 'imageUrl' => Yii::t('app', 'Image'), 121 'imageUrl' => Yii::t('app', 'Image'),
155 - 'translit' => 'Translit',  
156 - 'meta_title' => 'Meta Title',  
157 - 'meta_keywords' => 'Meta Keywords',  
158 - 'meta_description' => 'Meta Description',  
159 - 'seo_text' => 'Seo Text',  
160 - 'h1' => 'H1',  
161 ]; 122 ];
162 } 123 }
163 124
common/models/ArticlesLang.php
@@ -18,6 +18,7 @@ use Yii; @@ -18,6 +18,7 @@ use Yii;
18 * @property string $seo_text 18 * @property string $seo_text
19 * @property string $h1 19 * @property string $h1
20 * @property string $body_preview 20 * @property string $body_preview
  21 + * @property string $alias
21 * 22 *
22 * @property Articles $articles 23 * @property Articles $articles
23 * @property Language $language 24 * @property Language $language
@@ -40,6 +41,18 @@ class ArticlesLang extends \yii\db\ActiveRecord @@ -40,6 +41,18 @@ class ArticlesLang extends \yii\db\ActiveRecord
40 return 'articles_lang'; 41 return 'articles_lang';
41 } 42 }
42 43
  44 + public function behaviors()
  45 + {
  46 + return [
  47 + 'slug' => [
  48 + 'class' => 'common\behaviors\Slug',
  49 + 'in_attribute' => 'title',
  50 + 'out_attribute' => 'alias',
  51 + 'translit' => true,
  52 + ],
  53 + ];
  54 + }
  55 +
43 /** 56 /**
44 * @inheritdoc 57 * @inheritdoc
45 */ 58 */
@@ -47,7 +60,7 @@ class ArticlesLang extends \yii\db\ActiveRecord @@ -47,7 +60,7 @@ class ArticlesLang extends \yii\db\ActiveRecord
47 { 60 {
48 return [ 61 return [
49 [['title', 'body'], 'required'], 62 [['title', 'body'], 'required'],
50 - [['body', 'seo_text', 'body_preview'], 'string'], 63 + [['body', 'seo_text', 'body_preview', 'alias'], 'string'],
51 [['title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], 64 [['title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
52 [['articles_id', 'language_id'], 'unique', 'targetAttribute' => ['articles_id', 'language_id'], 'message' => 'The combination of Articles ID and Language ID has already been taken.'], 65 [['articles_id', 'language_id'], 'unique', 'targetAttribute' => ['articles_id', 'language_id'], 'message' => 'The combination of Articles ID and Language ID has already been taken.'],
53 [['articles_id'], 'exist', 'skipOnError' => true, 'targetClass' => Articles::className(), 'targetAttribute' => ['articles_id' => 'id']], 66 [['articles_id'], 'exist', 'skipOnError' => true, 'targetClass' => Articles::className(), 'targetAttribute' => ['articles_id' => 'id']],
common/models/ArticlesSearch.php
@@ -2,10 +2,8 @@ @@ -2,10 +2,8 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
5 -use Yii;  
6 use yii\base\Model; 5 use yii\base\Model;
7 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
8 -use common\models\Articles;  
9 7
10 /** 8 /**
11 * ArticlesSearch represents the model behind the search form about `common\models\Articles`. 9 * ArticlesSearch represents the model behind the search form about `common\models\Articles`.
@@ -19,7 +17,6 @@ class ArticlesSearch extends Articles @@ -19,7 +17,6 @@ class ArticlesSearch extends Articles
19 { 17 {
20 return [ 18 return [
21 [['id'], 'integer'], 19 [['id'], 'integer'],
22 - [['title', 'body', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'],  
23 ]; 20 ];
24 } 21 }
25 22
@@ -67,15 +64,6 @@ class ArticlesSearch extends Articles @@ -67,15 +64,6 @@ class ArticlesSearch extends Articles
67 'id' => $this->id, 64 'id' => $this->id,
68 ]); 65 ]);
69 66
70 - $query->andFilterWhere(['like', 'title', $this->title])  
71 - ->andFilterWhere(['like', 'body', $this->body])  
72 - ->andFilterWhere(['like', 'translit', $this->translit])  
73 - ->andFilterWhere(['like', 'meta_title', $this->meta_title])  
74 - ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])  
75 - ->andFilterWhere(['like', 'meta_description', $this->meta_description])  
76 - ->andFilterWhere(['like', 'seo_text', $this->seo_text])  
77 - ->andFilterWhere(['like', 'h1', $this->h1]);  
78 -  
79 return $dataProvider; 67 return $dataProvider;
80 } 68 }
81 } 69 }
common/models/Banner.php
@@ -12,9 +12,6 @@ use yii\web\Request; @@ -12,9 +12,6 @@ use yii\web\Request;
12 * This is the model class for table "banner". 12 * This is the model class for table "banner".
13 * 13 *
14 * @property integer $banner_id 14 * @property integer $banner_id
15 - * @property string $image  
16 - * @property string $alt  
17 - * @property string $title  
18 * @property string $url 15 * @property string $url
19 * @property integer $status 16 * @property integer $status
20 * * From language behavior * 17 * * From language behavior *
@@ -61,10 +58,7 @@ class Banner extends \yii\db\ActiveRecord @@ -61,10 +58,7 @@ class Banner extends \yii\db\ActiveRecord
61 { 58 {
62 return [ 59 return [
63 [['status'], 'integer'], 60 [['status'], 'integer'],
64 - [['image', 'alt', 'title', 'url'], 'string', 'max' => 255],  
65 - ['title', 'unique', 'targetClass' => '\common\models\Slider', 'message' => Yii::t('app','message',[  
66 - 'field' => 'Title'  
67 - ])], 61 + [['url'], 'string', 'max' => 255],
68 ]; 62 ];
69 } 63 }
70 64
@@ -74,10 +68,7 @@ class Banner extends \yii\db\ActiveRecord @@ -74,10 +68,7 @@ class Banner extends \yii\db\ActiveRecord
74 public function attributeLabels() 68 public function attributeLabels()
75 { 69 {
76 return [ 70 return [
77 - 'banner_id' => Yii::t('app', 'status'),  
78 - 'image' => Yii::t('app', 'image'),  
79 - 'alt' => Yii::t('app', 'alt'),  
80 - 'title' => Yii::t('app', 'title'), 71 + 'banner_id' => Yii::t('app', 'banner_id'),
81 'url' => Yii::t('app', 'url'), 72 'url' => Yii::t('app', 'url'),
82 'status' => Yii::t('app', 'status'), 73 'status' => Yii::t('app', 'status'),
83 ]; 74 ];
common/models/BannerSearch.php
1 <?php 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\Banner;  
9 -  
10 -/**  
11 - * BannerSearch represents the model behind the search form about `common\models\Banner`.  
12 - */  
13 -class BannerSearch extends Banner  
14 -{  
15 - /**  
16 - * @inheritdoc  
17 - */  
18 - public function rules()  
19 - {  
20 - return [  
21 - [['banner_id', 'status'], 'integer'],  
22 - [['image', 'alt', 'title', 'url'], 'safe'],  
23 - ];  
24 - }  
25 -  
26 - public function behaviors()  
27 - {  
28 - return [];  
29 - } 2 +
  3 + namespace common\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
30 7
31 /** 8 /**
32 - * @inheritdoc  
33 - */  
34 - public function scenarios()  
35 - {  
36 - // bypass scenarios() implementation in the parent class  
37 - return Model::scenarios();  
38 - }  
39 -  
40 - /**  
41 - * Creates data provider instance with search query applied  
42 - *  
43 - * @param array $params  
44 - *  
45 - * @return ActiveDataProvider 9 + * BannerSearch represents the model behind the search form about `common\models\Banner`.
46 */ 10 */
47 - public function search($params) 11 + class BannerSearch extends Banner
48 { 12 {
49 - $query = Banner::find();  
50 -  
51 - // add conditions that should always apply here  
52 -  
53 - $dataProvider = new ActiveDataProvider([  
54 - 'query' => $query,  
55 - ]);  
56 -  
57 - $this->load($params);  
58 -  
59 - if (!$this->validate()) {  
60 - // uncomment the following line if you do not want to return any records when validation fails  
61 - // $query->where('0=1'); 13 +
  14 + /**
  15 + * @inheritdoc
  16 + */
  17 + public function rules()
  18 + {
  19 + return [
  20 + [
  21 + [
  22 + 'banner_id',
  23 + 'status',
  24 + ],
  25 + 'integer',
  26 + ],
  27 + [
  28 + [ 'url' ],
  29 + 'safe',
  30 + ],
  31 + ];
  32 + }
  33 +
  34 + public function behaviors()
  35 + {
  36 + return [];
  37 + }
  38 +
  39 + /**
  40 + * @inheritdoc
  41 + */
  42 + public function scenarios()
  43 + {
  44 + // bypass scenarios() implementation in the parent class
  45 + return Model::scenarios();
  46 + }
  47 +
  48 + /**
  49 + * Creates data provider instance with search query applied
  50 + *
  51 + * @param array $params
  52 + *
  53 + * @return ActiveDataProvider
  54 + */
  55 + public function search($params)
  56 + {
  57 + $query = Banner::find();
  58 +
  59 + // add conditions that should always apply here
  60 +
  61 + $dataProvider = new ActiveDataProvider([
  62 + 'query' => $query,
  63 + ]);
  64 +
  65 + $this->load($params);
  66 +
  67 + if(!$this->validate()) {
  68 + // uncomment the following line if you do not want to return any records when validation fails
  69 + // $query->where('0=1');
  70 + return $dataProvider;
  71 + }
  72 +
  73 + // grid filtering conditions
  74 + $query->andFilterWhere([
  75 + 'banner_id' => $this->banner_id,
  76 + 'status' => $this->status,
  77 + ]);
  78 +
  79 + $query->andFilterWhere([
  80 + 'like',
  81 + 'url',
  82 + $this->url,
  83 + ]);
  84 +
62 return $dataProvider; 85 return $dataProvider;
63 } 86 }
64 -  
65 - // grid filtering conditions  
66 - $query->andFilterWhere([  
67 - 'banner_id' => $this->banner_id,  
68 - 'status' => $this->status,  
69 - ]);  
70 -  
71 - $query->andFilterWhere(['like', 'image', $this->image])  
72 - ->andFilterWhere(['like', 'alt', $this->alt])  
73 - ->andFilterWhere(['like', 'title', $this->title])  
74 - ->andFilterWhere(['like', 'url', $this->url]);  
75 -  
76 - return $dataProvider;  
77 } 87 }
78 -}  
common/models/Bg.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\behaviors\LanguageBehavior;  
6 -use yii\db\ActiveQuery;  
7 -use yii\db\ActiveRecord;  
8 -use yii\web\Request;  
9 -  
10 -/**  
11 - * Class Bg  
12 - * * From language behavior *  
13 - * @property BgLang $lang  
14 - * @property BgLang[] $langs  
15 - * @property BgLang $object_lang  
16 - * @property string $ownerKey  
17 - * @property string $langKey  
18 - * @method string getOwnerKey()  
19 - * @method void setOwnerKey(string $value)  
20 - * @method string getLangKey()  
21 - * @method void setLangKey(string $value)  
22 - * @method ActiveQuery getLangs()  
23 - * @method ActiveQuery getLang( integer $language_id )  
24 - * @method BgLang[] generateLangs()  
25 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
26 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
27 - * @method bool saveLangs(ActiveRecord[] $model_langs)  
28 - * * End language behavior *  
29 - */  
30 -class Bg extends \yii\db\ActiveRecord  
31 -{  
32 - public $old_image;  
33 -  
34 - public static function tableName()  
35 - {  
36 - return 'bg';  
37 - }  
38 2
39 - public function behaviors()  
40 - {  
41 - return [  
42 - 'language' => [  
43 - 'class' => LanguageBehavior::className(),  
44 - ],  
45 - ];  
46 - } 3 + namespace common\models;
47 4
48 - public function rules()  
49 - {  
50 - return [  
51 - [['title'], 'required'],  
52 - [['old_image','url'], 'safe'],  
53 - [['image'], 'file', 'extensions'=>'jpg, gif, png', 'skipOnEmpty'=>true],  
54 -  
55 - ];  
56 - }  
57 -  
58 - public function attributeLabels()  
59 - {  
60 - return [  
61 - 'title'=>'Название',  
62 - 'body'=>'Описание',  
63 - 'date'=>'Дата',  
64 - 'image'=>'Изображения',  
65 - ];  
66 - } 5 + use common\behaviors\SaveImgBehavior;
  6 + use common\modules\language\behaviors\LanguageBehavior;
  7 + use yii\db\ActiveQuery;
  8 + use yii\db\ActiveRecord;
  9 + use yii\web\Request;
  10 +
  11 + /**
  12 + * Class Bg
  13 + * * From language behavior *
  14 + * @property BgLang $lang
  15 + * @property BgLang[] $langs
  16 + * @property BgLang $object_lang
  17 + * @property string $ownerKey
  18 + * @property string $langKey
  19 + * @method string getOwnerKey()
  20 + * @method void setOwnerKey( string $value )
  21 + * @method string getLangKey()
  22 + * @method void setLangKey( string $value )
  23 + * @method ActiveQuery getLangs()
  24 + * @method ActiveQuery getLang( integer $language_id )
  25 + * @method BgLang[] generateLangs()
  26 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  27 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  28 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  29 + * * End language behavior *
  30 + */
  31 + class Bg extends \yii\db\ActiveRecord
  32 + {
67 33
68 - 34 + public static function tableName()
  35 + {
  36 + return 'bg';
  37 + }
69 38
70 - public function beforeDelete() {  
71 - $this->deleteImage($this->image);  
72 - return parent::beforeDelete();  
73 - }  
74 -  
75 - public function deleteImage($file){  
76 - if(!empty($file)){  
77 - @unlink('upload/bg/'.$file);  
78 - }  
79 - }  
80 -  
81 -  
82 -} 39 + public function behaviors()
  40 + {
  41 + return [
  42 + [
  43 + 'class' => SaveImgBehavior::className(),
  44 + 'fields' => [
  45 + [
  46 + 'name' => 'image',
  47 + 'directory' => 'bg',
  48 + ],
  49 + ],
  50 + ],
  51 + 'language' => [
  52 + 'class' => LanguageBehavior::className(),
  53 + ],
  54 + ];
  55 + }
  56 +
  57 + public function rules()
  58 + {
  59 + return [
  60 + [
  61 + [ 'url' ],
  62 + 'string',
  63 + ],
  64 + ];
  65 + }
  66 +
  67 + public function attributeLabels()
  68 + {
  69 + return [
  70 + 'image' => \Yii::t('app', 'Image'),
  71 + 'url' => \Yii::t('app', 'Url'),
  72 + ];
  73 + }
  74 + }
83 75
common/models/BgSearch.php
1 <?php 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\Bg;  
9 -  
10 -/**  
11 - * BgSearch represents the model behind the search form about `common\models\Bg`.  
12 - */  
13 -class BgSearch extends Bg  
14 -{  
15 - /**  
16 - * @inheritdoc  
17 - */  
18 - public function rules()  
19 - {  
20 - return [  
21 - [['id'], 'integer'],  
22 - [['title', 'url', 'image'], 'safe'],  
23 - ];  
24 - }  
25 2
26 - public function behaviors()  
27 - {  
28 - return [];  
29 - } 3 + namespace common\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
30 7
31 /** 8 /**
32 - * @inheritdoc  
33 - */  
34 - public function scenarios()  
35 - {  
36 - // bypass scenarios() implementation in the parent class  
37 - return Model::scenarios();  
38 - }  
39 -  
40 - /**  
41 - * Creates data provider instance with search query applied  
42 - *  
43 - * @param array $params  
44 - *  
45 - * @return ActiveDataProvider 9 + * BgSearch represents the model behind the search form about `common\models\Bg`.
46 */ 10 */
47 - public function search($params) 11 + class BgSearch extends Bg
48 { 12 {
49 - $query = Bg::find();  
50 -  
51 - // add conditions that should always apply here  
52 -  
53 - $dataProvider = new ActiveDataProvider([  
54 - 'query' => $query,  
55 - ]);  
56 -  
57 - $this->load($params);  
58 -  
59 - if (!$this->validate()) {  
60 - // uncomment the following line if you do not want to return any records when validation fails  
61 - // $query->where('0=1'); 13 +
  14 + /**
  15 + * @inheritdoc
  16 + */
  17 + public function rules()
  18 + {
  19 + return [
  20 + [
  21 + [ 'id' ],
  22 + 'integer',
  23 + ],
  24 + [
  25 + [ 'url' ],
  26 + 'safe',
  27 + ],
  28 + ];
  29 + }
  30 +
  31 + public function behaviors()
  32 + {
  33 + return [];
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function scenarios()
  40 + {
  41 + // bypass scenarios() implementation in the parent class
  42 + return Model::scenarios();
  43 + }
  44 +
  45 + /**
  46 + * Creates data provider instance with search query applied
  47 + *
  48 + * @param array $params
  49 + *
  50 + * @return ActiveDataProvider
  51 + */
  52 + public function search($params)
  53 + {
  54 + $query = Bg::find();
  55 +
  56 + // add conditions that should always apply here
  57 +
  58 + $dataProvider = new ActiveDataProvider([
  59 + 'query' => $query,
  60 + ]);
  61 +
  62 + $this->load($params);
  63 +
  64 + if(!$this->validate()) {
  65 + // uncomment the following line if you do not want to return any records when validation fails
  66 + // $query->where('0=1');
  67 + return $dataProvider;
  68 + }
  69 +
  70 + // grid filtering conditions
  71 + $query->andFilterWhere([
  72 + 'id' => $this->id,
  73 + ]);
  74 +
  75 + $query->andFilterWhere([
  76 + 'like',
  77 + 'url',
  78 + $this->url,
  79 + ]);
  80 +
62 return $dataProvider; 81 return $dataProvider;
63 } 82 }
64 -  
65 - // grid filtering conditions  
66 - $query->andFilterWhere([  
67 - 'id' => $this->id,  
68 - ]);  
69 -  
70 - $query->andFilterWhere(['like', 'title', $this->title])  
71 - ->andFilterWhere(['like', 'url', $this->url])  
72 - ->andFilterWhere(['like', 'image', $this->image]);  
73 -  
74 - return $dataProvider;  
75 } 83 }
76 -}  
common/models/Delivery.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\behaviors\LanguageBehavior;  
6 -use yii\db\ActiveQuery;  
7 -use yii\db\ActiveRecord;  
8 -use yii\web\Request;  
9 -  
10 -/**  
11 - * Class Delivery  
12 - *  
13 - * * From language behavior *  
14 - * @property OrdersDeliveryLang $lang  
15 - * @property OrdersDeliveryLang[] $langs  
16 - * @property OrdersDeliveryLang $object_lang  
17 - * @property string $ownerKey  
18 - * @property string $langKey  
19 - * @method string getOwnerKey()  
20 - * @method void setOwnerKey(string $value)  
21 - * @method string getLangKey()  
22 - * @method void setLangKey(string $value)  
23 - * @method ActiveQuery getLangs()  
24 - * @method ActiveQuery getLang( integer $language_id )  
25 - * @method OrdersDeliveryLang[] generateLangs()  
26 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
27 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
28 - * @method bool saveLangs(ActiveRecord[] $model_langs)  
29 - * * End language behavior *  
30 - */  
31 -class Delivery extends \yii\db\ActiveRecord  
32 -{  
33 2
34 - public function behaviors()  
35 - {  
36 - return [  
37 - 'language' => [  
38 - 'class' => LanguageBehavior::className(),  
39 - ],  
40 - ];  
41 - } 3 + namespace common\models;
42 4
43 - public static function tableName()  
44 - {  
45 - return 'orders_delivery';  
46 - } 5 + use common\modules\language\behaviors\LanguageBehavior;
  6 + use yii\db\ActiveQuery;
  7 + use yii\db\ActiveRecord;
  8 + use yii\web\Request;
47 9
48 -}  
49 \ No newline at end of file 10 \ No newline at end of file
  11 + /**
  12 + * Class Delivery
  13 + * * From language behavior *
  14 + * @property OrdersDeliveryLang $lang
  15 + * @property OrdersDeliveryLang[] $langs
  16 + * @property OrdersDeliveryLang $object_lang
  17 + * @property string $ownerKey
  18 + * @property string $langKey
  19 + * @method string getOwnerKey()
  20 + * @method void setOwnerKey( string $value )
  21 + * @method string getLangKey()
  22 + * @method void setLangKey( string $value )
  23 + * @method ActiveQuery getLangs()
  24 + * @method ActiveQuery getLang( integer $language_id )
  25 + * @method OrdersDeliveryLang[] generateLangs()
  26 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  27 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  28 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  29 + * * End language behavior *
  30 + */
  31 + class Delivery extends \yii\db\ActiveRecord
  32 + {
  33 +
  34 + public function behaviors()
  35 + {
  36 + return [
  37 + 'language' => [
  38 + 'class' => LanguageBehavior::className(),
  39 + ],
  40 + ];
  41 + }
  42 +
  43 + public static function tableName()
  44 + {
  45 + return 'orders_delivery';
  46 + }
  47 +
  48 + }
50 \ No newline at end of file 49 \ No newline at end of file
common/models/Event.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
  5 +use common\behaviors\SaveImgBehavior;
5 use common\modules\language\behaviors\LanguageBehavior; 6 use common\modules\language\behaviors\LanguageBehavior;
6 use Yii; 7 use Yii;
7 use yii\behaviors\TimestampBehavior; 8 use yii\behaviors\TimestampBehavior;
@@ -13,14 +14,7 @@ use yii\web\Request; @@ -13,14 +14,7 @@ use yii\web\Request;
13 * This is the model class for table "event". 14 * This is the model class for table "event".
14 * 15 *
15 * @property integer $event_id 16 * @property integer $event_id
16 - * @property string $name  
17 - * @property string $alias  
18 - * @property string $body  
19 * @property string $image 17 * @property string $image
20 - * @property string $meta_title  
21 - * @property string $description  
22 - * @property string $h1  
23 - * @property string $seo_text  
24 * @property integer $created_at 18 * @property integer $created_at
25 * @property integer $updated_at 19 * @property integer $updated_at
26 * @property integer $end_at 20 * @property integer $end_at
@@ -45,8 +39,6 @@ use yii\web\Request; @@ -45,8 +39,6 @@ use yii\web\Request;
45 */ 39 */
46 class Event extends \yii\db\ActiveRecord 40 class Event extends \yii\db\ActiveRecord
47 { 41 {
48 - public $imageUpload;  
49 -  
50 /** 42 /**
51 * @inheritdoc 43 * @inheritdoc
52 */ 44 */
@@ -62,18 +54,21 @@ class Event extends \yii\db\ActiveRecord @@ -62,18 +54,21 @@ class Event extends \yii\db\ActiveRecord
62 { 54 {
63 return [ 55 return [
64 TimestampBehavior::className(), 56 TimestampBehavior::className(),
65 - 'slug' => [  
66 - 'class' => 'common\behaviors\Slug',  
67 - 'in_attribute' => 'name',  
68 - 'out_attribute' => 'alias',  
69 - 'translit' => true  
70 - ],  
71 [ 57 [
72 'class' => 'common\behaviors\ShowImage', 58 'class' => 'common\behaviors\ShowImage',
73 ], 59 ],
74 'language' => [ 60 'language' => [
75 'class' => LanguageBehavior::className(), 61 'class' => LanguageBehavior::className(),
76 ], 62 ],
  63 + [
  64 + 'class' => SaveImgBehavior::className(),
  65 + 'fields' => [
  66 + [
  67 + 'name' => 'image',
  68 + 'directory' => 'event',
  69 + ],
  70 + ],
  71 + ],
77 ]; 72 ];
78 } 73 }
79 74
@@ -99,12 +94,8 @@ class Event extends \yii\db\ActiveRecord @@ -99,12 +94,8 @@ class Event extends \yii\db\ActiveRecord
99 public function rules() 94 public function rules()
100 { 95 {
101 return [ 96 return [
102 - [['body', 'seo_text'], 'string'],  
103 [['created_at', 'updated_at' ], 'integer'], 97 [['created_at', 'updated_at' ], 'integer'],
104 - [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at'], 'string', 'max' => 255],  
105 - [['name','body'], 'required'],  
106 - [['imageUpload'], 'safe'],  
107 - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], 98 + [['end_at'], 'string', 'max' => 255],
108 ]; 99 ];
109 } 100 }
110 101
@@ -115,27 +106,10 @@ class Event extends \yii\db\ActiveRecord @@ -115,27 +106,10 @@ class Event extends \yii\db\ActiveRecord
115 { 106 {
116 return [ 107 return [
117 'event_id' => Yii::t('app', 'event_id'), 108 'event_id' => Yii::t('app', 'event_id'),
118 - 'name' => Yii::t('app', 'name'),  
119 - 'alias' => Yii::t('app', 'alias'),  
120 - 'body' => Yii::t('app', 'body'),  
121 'image' => Yii::t('app', 'image'), 109 'image' => Yii::t('app', 'image'),
122 - 'meta_title' => Yii::t('app', 'meta_title'),  
123 - 'description' => Yii::t('app', 'description'),  
124 - 'h1' => Yii::t('app', 'h1'),  
125 - 'seo_text' => Yii::t('app', 'seo_text'),  
126 'created_at' => Yii::t('app', 'created_at'), 110 'created_at' => Yii::t('app', 'created_at'),
127 'updated_at' => Yii::t('app', 'updated_at'), 111 'updated_at' => Yii::t('app', 'updated_at'),
128 'end_at' => Yii::t('app', 'end_at'), 112 'end_at' => Yii::t('app', 'end_at'),
129 ]; 113 ];
130 } 114 }
131 -  
132 -  
133 - public function getImageFile() {  
134 - return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);  
135 - }  
136 -  
137 - public function getImageUrl()  
138 - {  
139 - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);  
140 - }  
141 } 115 }
common/models/EventLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "event_lang".  
10 - *  
11 - * @property integer $event_id  
12 - * @property integer $language_id  
13 - * @property string $name  
14 - * @property string $body  
15 - * @property string $meta_title  
16 - * @property string $description  
17 - * @property string $seo_text  
18 - * @property string $h1  
19 - *  
20 - * @property Event $event  
21 - * @property Language $language  
22 - */  
23 -class EventLang extends \yii\db\ActiveRecord  
24 -{  
25 2
26 - public static function primaryKey()  
27 - {  
28 - return [  
29 - 'event_id',  
30 - 'language_id',  
31 - ];  
32 - } 3 + namespace common\models;
33 4
34 - /**  
35 - * @inheritdoc  
36 - */  
37 - public static function tableName()  
38 - {  
39 - return 'event_lang';  
40 - } 5 + use common\modules\language\models\Language;
  6 + use Yii;
41 7
42 /** 8 /**
43 - * @inheritdoc  
44 - */  
45 - public function rules()  
46 - {  
47 - return [  
48 - [['name', 'body'], 'required'],  
49 - [['body', 'seo_text'], 'string'],  
50 - [['name', 'meta_title', 'description', 'h1'], 'string', 'max' => 255],  
51 - [['event_id', 'language_id'], 'unique', 'targetAttribute' => ['event_id', 'language_id'], 'message' => 'The combination of Event ID and Language ID has already been taken.'],  
52 - [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::className(), 'targetAttribute' => ['event_id' => 'event_id']],  
53 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
54 - ];  
55 - }  
56 -  
57 - /**  
58 - * @inheritdoc  
59 - */  
60 - public function attributeLabels()  
61 - {  
62 - return [  
63 - 'event_id' => Yii::t('app', 'Event ID'),  
64 - 'language_id' => Yii::t('app', 'Language ID'),  
65 - 'name' => Yii::t('app', 'Name'),  
66 - 'body' => Yii::t('app', 'Body'),  
67 - 'meta_title' => Yii::t('app', 'Meta Title'),  
68 - 'description' => Yii::t('app', 'Description'),  
69 - 'seo_text' => Yii::t('app', 'Seo Text'),  
70 - 'h1' => Yii::t('app', 'H1'),  
71 - ];  
72 - }  
73 -  
74 - /**  
75 - * @return \yii\db\ActiveQuery  
76 - */  
77 - public function getEvent()  
78 - {  
79 - return $this->hasOne(Event::className(), ['event_id' => 'event_id']);  
80 - }  
81 -  
82 - /**  
83 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "event_lang".
  10 + * @property integer $event_id
  11 + * @property integer $language_id
  12 + * @property string $name
  13 + * @property string $body
  14 + * @property string $meta_title
  15 + * @property string $description
  16 + * @property string $seo_text
  17 + * @property string $h1
  18 + * @property string $alias
  19 + * @property Event $event
  20 + * @property Language $language
84 */ 21 */
85 - public function getLanguage() 22 + class EventLang extends \yii\db\ActiveRecord
86 { 23 {
87 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); 24 +
  25 + public static function primaryKey()
  26 + {
  27 + return [
  28 + 'event_id',
  29 + 'language_id',
  30 + ];
  31 + }
  32 +
  33 + /**
  34 + * @inheritdoc
  35 + */
  36 + public static function tableName()
  37 + {
  38 + return 'event_lang';
  39 + }
  40 +
  41 + public function behaviors()
  42 + {
  43 + return [
  44 + 'slug' => [
  45 + 'class' => 'common\behaviors\Slug',
  46 + 'in_attribute' => 'name',
  47 + 'out_attribute' => 'alias',
  48 + 'translit' => true,
  49 + ],
  50 + ];
  51 + }
  52 +
  53 + /**
  54 + * @inheritdoc
  55 + */
  56 + public function rules()
  57 + {
  58 + return [
  59 + [
  60 + [
  61 + 'name',
  62 + 'body',
  63 + ],
  64 + 'required',
  65 + ],
  66 + [
  67 + [
  68 + 'body',
  69 + 'seo_text',
  70 + ],
  71 + 'string',
  72 + ],
  73 + [
  74 + [
  75 + 'name',
  76 + 'meta_title',
  77 + 'description',
  78 + 'h1',
  79 + 'alias',
  80 + ],
  81 + 'string',
  82 + 'max' => 255,
  83 + ],
  84 + [
  85 + [
  86 + 'event_id',
  87 + 'language_id',
  88 + ],
  89 + 'unique',
  90 + 'targetAttribute' => [
  91 + 'event_id',
  92 + 'language_id',
  93 + ],
  94 + 'message' => 'The combination of Event ID and Language ID has already been taken.',
  95 + ],
  96 + [
  97 + [ 'event_id' ],
  98 + 'exist',
  99 + 'skipOnError' => true,
  100 + 'targetClass' => Event::className(),
  101 + 'targetAttribute' => [ 'event_id' => 'event_id' ],
  102 + ],
  103 + [
  104 + [ 'language_id' ],
  105 + 'exist',
  106 + 'skipOnError' => true,
  107 + 'targetClass' => Language::className(),
  108 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  109 + ],
  110 + ];
  111 + }
  112 +
  113 + /**
  114 + * @inheritdoc
  115 + */
  116 + public function attributeLabels()
  117 + {
  118 + return [
  119 + 'event_id' => Yii::t('app', 'Event ID'),
  120 + 'language_id' => Yii::t('app', 'Language ID'),
  121 + 'name' => Yii::t('app', 'Name'),
  122 + 'body' => Yii::t('app', 'Body'),
  123 + 'meta_title' => Yii::t('app', 'Meta Title'),
  124 + 'description' => Yii::t('app', 'Description'),
  125 + 'seo_text' => Yii::t('app', 'Seo Text'),
  126 + 'h1' => Yii::t('app', 'H1'),
  127 + ];
  128 + }
  129 +
  130 + /**
  131 + * @return \yii\db\ActiveQuery
  132 + */
  133 + public function getEvent()
  134 + {
  135 + return $this->hasOne(Event::className(), [ 'event_id' => 'event_id' ]);
  136 + }
  137 +
  138 + /**
  139 + * @return \yii\db\ActiveQuery
  140 + */
  141 + public function getLanguage()
  142 + {
  143 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  144 + }
88 } 145 }
89 -}  
common/models/EventSearch.php
@@ -17,7 +17,6 @@ class EventSearch extends Event @@ -17,7 +17,6 @@ class EventSearch extends Event
17 { 17 {
18 return [ 18 return [
19 [['event_id', 'created_at', 'updated_at', 'end_at'], 'integer'], 19 [['event_id', 'created_at', 'updated_at', 'end_at'], 'integer'],
20 - [['name', 'alias', 'body', 'image', 'meta_title', 'description', 'h1', 'seo_text'], 'safe'],  
21 ]; 20 ];
22 } 21 }
23 22
@@ -70,15 +69,6 @@ class EventSearch extends Event @@ -70,15 +69,6 @@ class EventSearch extends Event
70 'end_at' => $this->end_at, 69 'end_at' => $this->end_at,
71 ]); 70 ]);
72 71
73 - $query->andFilterWhere(['like', 'name', $this->name])  
74 - ->andFilterWhere(['like', 'alias', $this->alias])  
75 - ->andFilterWhere(['like', 'body', $this->body])  
76 - ->andFilterWhere(['like', 'image', $this->image])  
77 - ->andFilterWhere(['like', 'meta_title', $this->meta_title])  
78 - ->andFilterWhere(['like', 'description', $this->description])  
79 - ->andFilterWhere(['like', 'h1', $this->h1])  
80 - ->andFilterWhere(['like', 'seo_text', $this->seo_text]);  
81 -  
82 return $dataProvider; 72 return $dataProvider;
83 } 73 }
84 } 74 }
common/models/OrdersDeliveryLang.php
@@ -46,7 +46,7 @@ class OrdersDeliveryLang extends \yii\db\ActiveRecord @@ -46,7 +46,7 @@ class OrdersDeliveryLang extends \yii\db\ActiveRecord
46 [['title'], 'string', 'max' => 255], 46 [['title'], 'string', 'max' => 255],
47 [['orders_delivery_id', 'language_id'], 'unique', 'targetAttribute' => ['orders_delivery_id', 'language_id'], 'message' => 'The combination of Orders Delivery ID and Language ID has already been taken.'], 47 [['orders_delivery_id', 'language_id'], 'unique', 'targetAttribute' => ['orders_delivery_id', 'language_id'], 'message' => 'The combination of Orders Delivery ID and Language ID has already been taken.'],
48 [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], 48 [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
49 - [['orders_delivery_id'], 'exist', 'skipOnError' => true, 'targetClass' => OrdersDelivery::className(), 'targetAttribute' => ['orders_delivery_id' => 'id']], 49 + [['orders_delivery_id'], 'exist', 'skipOnError' => true, 'targetClass' => Delivery::className(), 'targetAttribute' => ['orders_delivery_id' => 'id']],
50 ]; 50 ];
51 } 51 }
52 52
common/models/Page.php
@@ -9,14 +9,6 @@ @@ -9,14 +9,6 @@
9 /** 9 /**
10 * This is the model class for table "page". 10 * This is the model class for table "page".
11 * @property integer $id 11 * @property integer $id
12 - * @property string $translit  
13 - * @property string $title  
14 - * @property string $body  
15 - * @property string $meta_title  
16 - * @property string $meta_keywords  
17 - * @property string $meta_description  
18 - * @property string $seo_text  
19 - * @property string $h1  
20 * @property bool $in_menu 12 * @property bool $in_menu
21 * * From language behavior * 13 * * From language behavior *
22 * @property PageLang $lang 14 * @property PageLang $lang
@@ -53,12 +45,6 @@ @@ -53,12 +45,6 @@
53 public function behaviors() 45 public function behaviors()
54 { 46 {
55 return [ 47 return [
56 - 'slug' => [  
57 - 'class' => 'common\behaviors\Slug',  
58 - 'in_attribute' => 'title',  
59 - 'out_attribute' => 'translit',  
60 - 'translit' => true,  
61 - ],  
62 'language' => [ 48 'language' => [
63 'class' => LanguageBehavior::className(), 49 'class' => LanguageBehavior::className(),
64 ], 50 ],
@@ -73,25 +59,6 @@ @@ -73,25 +59,6 @@
73 return [ 59 return [
74 [ 60 [
75 [ 61 [
76 - 'body',  
77 - 'seo_text',  
78 - ],  
79 - 'string',  
80 - ],  
81 - [  
82 - [  
83 - 'translit',  
84 - 'title',  
85 - 'meta_title',  
86 - 'meta_keywords',  
87 - 'meta_description',  
88 - 'h1',  
89 - ],  
90 - 'string',  
91 - 'max' => 255,  
92 - ],  
93 - [  
94 - [  
95 'in_menu', 62 'in_menu',
96 ], 63 ],
97 'boolean', 64 'boolean',
@@ -99,14 +66,6 @@ @@ -99,14 +66,6 @@
99 ]; 66 ];
100 } 67 }
101 68
102 - public function getPageTranslit($page)  
103 - {  
104 - return self::find()  
105 - ->where([ 'translit' => $page ])  
106 - ->one();  
107 -  
108 - }  
109 -  
110 /** 69 /**
111 * @inheritdoc 70 * @inheritdoc
112 */ 71 */
@@ -114,14 +73,6 @@ @@ -114,14 +73,6 @@
114 { 73 {
115 return [ 74 return [
116 'id' => 'ID', 75 'id' => 'ID',
117 - 'translit' => 'Translit',  
118 - 'title' => 'Title',  
119 - 'body' => 'Body',  
120 - 'meta_title' => 'Meta Title',  
121 - 'meta_keywords' => 'Meta Keywords',  
122 - 'meta_description' => 'Meta Description',  
123 - 'seo_text' => 'Seo Text',  
124 - 'h1' => 'H1',  
125 'in_menu' => 'Show in menu', 76 'in_menu' => 'Show in menu',
126 ]; 77 ];
127 } 78 }
common/models/PageLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "page_lang".  
10 - *  
11 - * @property integer $page_id  
12 - * @property integer $language_id  
13 - * @property string $title  
14 - * @property string $body  
15 - * @property string $meta_title  
16 - * @property string $meta_keywords  
17 - * @property string $meta_description  
18 - * @property string $seo_text  
19 - * @property string $h1  
20 - *  
21 - * @property Language $language  
22 - * @property Page $page  
23 - */  
24 -class PageLang extends \yii\db\ActiveRecord  
25 -{  
26 2
27 - public static function primaryKey()  
28 - {  
29 - return [  
30 - 'page_id',  
31 - 'language_id',  
32 - ];  
33 - } 3 + namespace common\models;
  4 +
  5 + use common\modules\language\models\Language;
  6 + use Yii;
34 7
35 /** 8 /**
36 - * @inheritdoc  
37 - */  
38 - public static function tableName()  
39 - {  
40 - return 'page_lang';  
41 - }  
42 -  
43 - /**  
44 - * @inheritdoc  
45 - */  
46 - public function rules()  
47 - {  
48 - return [  
49 - [['title', 'body'], 'required'],  
50 - [['body', 'seo_text'], 'string'],  
51 - [['title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],  
52 - [['page_id', 'language_id'], 'unique', 'targetAttribute' => ['page_id', 'language_id'], 'message' => 'The combination of Page ID and Language ID has already been taken.'],  
53 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
54 - [['page_id'], 'exist', 'skipOnError' => true, 'targetClass' => Page::className(), 'targetAttribute' => ['page_id' => 'id']],  
55 - ];  
56 - }  
57 -  
58 - /**  
59 - * @inheritdoc  
60 - */  
61 - public function attributeLabels()  
62 - {  
63 - return [  
64 - 'page_id' => Yii::t('app', 'Page ID'),  
65 - 'language_id' => Yii::t('app', 'Language ID'),  
66 - 'title' => Yii::t('app', 'Title'),  
67 - 'body' => Yii::t('app', 'Body'),  
68 - 'meta_title' => Yii::t('app', 'Meta Title'),  
69 - 'meta_keywords' => Yii::t('app', 'Meta Keywords'),  
70 - 'meta_description' => Yii::t('app', 'Meta Description'),  
71 - 'seo_text' => Yii::t('app', 'Seo Text'),  
72 - 'h1' => Yii::t('app', 'H1'),  
73 - ];  
74 - }  
75 -  
76 - /**  
77 - * @return \yii\db\ActiveQuery  
78 - */  
79 - public function getLanguage()  
80 - {  
81 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);  
82 - }  
83 -  
84 - /**  
85 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "page_lang".
  10 + * @property integer $page_id
  11 + * @property integer $language_id
  12 + * @property string $title
  13 + * @property string $body
  14 + * @property string $meta_title
  15 + * @property string $meta_keywords
  16 + * @property string $meta_description
  17 + * @property string $seo_text
  18 + * @property string $h1
  19 + * @property string $alias
  20 + * @property Language $language
  21 + * @property Page $page
86 */ 22 */
87 - public function getPage() 23 + class PageLang extends \yii\db\ActiveRecord
88 { 24 {
89 - return $this->hasOne(Page::className(), ['id' => 'page_id']); 25 +
  26 + public static function primaryKey()
  27 + {
  28 + return [
  29 + 'page_id',
  30 + 'language_id',
  31 + ];
  32 + }
  33 +
  34 + /**
  35 + * @inheritdoc
  36 + */
  37 + public static function tableName()
  38 + {
  39 + return 'page_lang';
  40 + }
  41 +
  42 + public function behaviors()
  43 + {
  44 + return [
  45 + 'slug' => [
  46 + 'class' => 'common\behaviors\Slug',
  47 + 'in_attribute' => 'title',
  48 + 'out_attribute' => 'alias',
  49 + 'translit' => true,
  50 + ],
  51 + ];
  52 + }
  53 +
  54 + /**
  55 + * @inheritdoc
  56 + */
  57 + public function rules()
  58 + {
  59 + return [
  60 + [
  61 + [
  62 + 'title',
  63 + 'body',
  64 + ],
  65 + 'required',
  66 + ],
  67 + [
  68 + [
  69 + 'body',
  70 + 'seo_text',
  71 + ],
  72 + 'string',
  73 + ],
  74 + [
  75 + [
  76 + 'title',
  77 + 'meta_title',
  78 + 'meta_keywords',
  79 + 'meta_description',
  80 + 'h1',
  81 + 'alias',
  82 + ],
  83 + 'string',
  84 + 'max' => 255,
  85 + ],
  86 + [
  87 + [
  88 + 'page_id',
  89 + 'language_id',
  90 + ],
  91 + 'unique',
  92 + 'targetAttribute' => [
  93 + 'page_id',
  94 + 'language_id',
  95 + ],
  96 + 'message' => 'The combination of Page ID and Language ID has already been taken.',
  97 + ],
  98 + [
  99 + [ 'language_id' ],
  100 + 'exist',
  101 + 'skipOnError' => true,
  102 + 'targetClass' => Language::className(),
  103 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  104 + ],
  105 + [
  106 + [ 'page_id' ],
  107 + 'exist',
  108 + 'skipOnError' => true,
  109 + 'targetClass' => Page::className(),
  110 + 'targetAttribute' => [ 'page_id' => 'id' ],
  111 + ],
  112 + ];
  113 + }
  114 +
  115 + /**
  116 + * @inheritdoc
  117 + */
  118 + public function attributeLabels()
  119 + {
  120 + return [
  121 + 'page_id' => Yii::t('app', 'Page ID'),
  122 + 'language_id' => Yii::t('app', 'Language ID'),
  123 + 'title' => Yii::t('app', 'Title'),
  124 + 'body' => Yii::t('app', 'Body'),
  125 + 'meta_title' => Yii::t('app', 'Meta Title'),
  126 + 'meta_keywords' => Yii::t('app', 'Meta Keywords'),
  127 + 'meta_description' => Yii::t('app', 'Meta Description'),
  128 + 'seo_text' => Yii::t('app', 'Seo Text'),
  129 + 'h1' => Yii::t('app', 'H1'),
  130 + 'alias' => Yii::t('app', 'Alias'),
  131 + ];
  132 + }
  133 +
  134 + /**
  135 + * @return \yii\db\ActiveQuery
  136 + */
  137 + public function getLanguage()
  138 + {
  139 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  140 + }
  141 +
  142 + /**
  143 + * @return \yii\db\ActiveQuery
  144 + */
  145 + public function getPage()
  146 + {
  147 + return $this->hasOne(Page::className(), [ 'id' => 'page_id' ]);
  148 + }
90 } 149 }
91 -}  
common/models/PageSearch.php
@@ -17,7 +17,6 @@ class PageSearch extends Page @@ -17,7 +17,6 @@ class PageSearch extends Page
17 { 17 {
18 return [ 18 return [
19 [['id'], 'integer'], 19 [['id'], 'integer'],
20 - [['translit', 'title', 'body', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'],  
21 ]; 20 ];
22 } 21 }
23 22
@@ -65,15 +64,6 @@ class PageSearch extends Page @@ -65,15 +64,6 @@ class PageSearch extends Page
65 'id' => $this->id, 64 'id' => $this->id,
66 ]); 65 ]);
67 66
68 - $query->andFilterWhere(['like', 'translit', $this->translit])  
69 - ->andFilterWhere(['like', 'title', $this->title])  
70 - ->andFilterWhere(['like', 'body', $this->body])  
71 - ->andFilterWhere(['like', 'meta_title', $this->meta_title])  
72 - ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])  
73 - ->andFilterWhere(['like', 'meta_description', $this->meta_description])  
74 - ->andFilterWhere(['like', 'seo_text', $this->seo_text])  
75 - ->andFilterWhere(['like', 'h1', $this->h1]);  
76 -  
77 return $dataProvider; 67 return $dataProvider;
78 } 68 }
79 } 69 }
common/models/ProductSpec.php
@@ -13,10 +13,8 @@ @@ -13,10 +13,8 @@
13 * This is the model class for table "product_spec". 13 * This is the model class for table "product_spec".
14 * @property integer $product_spec_id 14 * @property integer $product_spec_id
15 * @property integer $product_id 15 * @property integer $product_id
16 - * @property string $tech_spec_text  
17 * @property string $tech_spec_link 16 * @property string $tech_spec_link
18 * @property string $tech_char_link 17 * @property string $tech_char_link
19 - * @property string $instruction  
20 * @property Product $product 18 * @property Product $product
21 * 19 *
22 * * From language behavior * 20 * * From language behavior *
@@ -75,13 +73,6 @@ @@ -75,13 +73,6 @@
75 return [ 73 return [
76 [ 74 [
77 [ 75 [
78 - 'tech_spec_text',  
79 - 'instruction',  
80 - ],  
81 - 'string',  
82 - ],  
83 - [  
84 - [  
85 'techSpecFile', 76 'techSpecFile',
86 'techCharFile', 77 'techCharFile',
87 ], 78 ],
@@ -99,10 +90,8 @@ @@ -99,10 +90,8 @@
99 return [ 90 return [
100 'product_spec_id' => 'Product Spec ID', 91 'product_spec_id' => 'Product Spec ID',
101 'product_id' => 'Product ID', 92 'product_id' => 'Product ID',
102 - 'tech_spec_text' => 'Tech Spec Text',  
103 'tech_spec_link' => 'Tech Spec Link', 93 'tech_spec_link' => 'Tech Spec Link',
104 'tech_char_link' => 'Tech Char Link', 94 'tech_char_link' => 'Tech Char Link',
105 - 'instruction' => 'Instruction',  
106 'techSpecFile' => 'techSpecFile', 95 'techSpecFile' => 'techSpecFile',
107 'techCharFile' => 'techCharFile', 96 'techCharFile' => 'techCharFile',
108 ]; 97 ];
common/models/Project.php
@@ -11,9 +11,6 @@ @@ -11,9 +11,6 @@
11 /** 11 /**
12 * This is the model class for table "project". 12 * This is the model class for table "project".
13 * @property integer $project_id 13 * @property integer $project_id
14 - * @property string $title  
15 - * @property string $link  
16 - * @property string $description  
17 * @property integer $date_add 14 * @property integer $date_add
18 * @property ProjectImage[] $images 15 * @property ProjectImage[] $images
19 * @property ProjectImage $image 16 * @property ProjectImage $image
@@ -57,12 +54,6 @@ @@ -57,12 +54,6 @@
57 public function behaviors() 54 public function behaviors()
58 { 55 {
59 return [ 56 return [
60 - 'slug' => [  
61 - 'class' => 'common\behaviors\Slug',  
62 - 'in_attribute' => 'title',  
63 - 'out_attribute' => 'link',  
64 - 'translit' => true,  
65 - ],  
66 'language' => [ 57 'language' => [
67 'class' => LanguageBehavior::className(), 58 'class' => LanguageBehavior::className(),
68 ], 59 ],
@@ -83,14 +74,6 @@ @@ -83,14 +74,6 @@
83 }, 74 },
84 ], 75 ],
85 [ 76 [
86 - [ 'title' ],  
87 - 'required',  
88 - ],  
89 - [  
90 - [ 'description' ],  
91 - 'string',  
92 - ],  
93 - [  
94 [ 77 [
95 'date_add', 78 'date_add',
96 'imagesUpload', 79 'imagesUpload',
common/models/ProjectLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "project_lang".  
10 - *  
11 - * @property integer $project_id  
12 - * @property integer $language_id  
13 - * @property string $title  
14 - * @property string $description  
15 - *  
16 - * @property Language $language  
17 - * @property Project $project  
18 - */  
19 -class ProjectLang extends \yii\db\ActiveRecord  
20 -{  
21 2
22 - public static function primaryKey()  
23 - {  
24 - return [  
25 - 'project_id',  
26 - 'language_id',  
27 - ];  
28 - } 3 + namespace common\models;
  4 +
  5 + use common\modules\language\models\Language;
  6 + use Yii;
29 7
30 /** 8 /**
31 - * @inheritdoc  
32 - */  
33 - public static function tableName()  
34 - {  
35 - return 'project_lang';  
36 - }  
37 -  
38 - /**  
39 - * @inheritdoc  
40 - */  
41 - public function rules()  
42 - {  
43 - return [  
44 - [['title'], 'required'],  
45 - [['description'], 'string'],  
46 - [['title'], 'string', 'max' => 255],  
47 - [['project_id', 'language_id'], 'unique', 'targetAttribute' => ['project_id', 'language_id'], 'message' => 'The combination of Project ID and Language ID has already been taken.'],  
48 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
49 - [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']],  
50 - ];  
51 - }  
52 -  
53 - /**  
54 - * @inheritdoc  
55 - */  
56 - public function attributeLabels()  
57 - {  
58 - return [  
59 - 'project_id' => Yii::t('app', 'Project ID'),  
60 - 'language_id' => Yii::t('app', 'Language ID'),  
61 - 'title' => Yii::t('app', 'Title'),  
62 - 'description' => Yii::t('app', 'Description'),  
63 - ];  
64 - }  
65 -  
66 - /**  
67 - * @return \yii\db\ActiveQuery  
68 - */  
69 - public function getLanguage()  
70 - {  
71 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);  
72 - }  
73 -  
74 - /**  
75 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "project_lang".
  10 + * @property integer $project_id
  11 + * @property integer $language_id
  12 + * @property string $title
  13 + * @property string $description
  14 + * @property string $alias
  15 + * @property Language $language
  16 + * @property Project $project
76 */ 17 */
77 - public function getProject() 18 + class ProjectLang extends \yii\db\ActiveRecord
78 { 19 {
79 - return $this->hasOne(Project::className(), ['project_id' => 'project_id']); 20 +
  21 + public static function primaryKey()
  22 + {
  23 + return [
  24 + 'project_id',
  25 + 'language_id',
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return 'project_lang';
  35 + }
  36 +
  37 + public function behaviors()
  38 + {
  39 + return [
  40 + 'slug' => [
  41 + 'class' => 'common\behaviors\Slug',
  42 + 'in_attribute' => 'title',
  43 + 'out_attribute' => 'alias',
  44 + 'translit' => true,
  45 + ],
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * @inheritdoc
  51 + */
  52 + public function rules()
  53 + {
  54 + return [
  55 + [
  56 + [ 'title' ],
  57 + 'required',
  58 + ],
  59 + [
  60 + [ 'description' ],
  61 + 'string',
  62 + ],
  63 + [
  64 + [
  65 + 'title',
  66 + 'alias',
  67 + ],
  68 + 'string',
  69 + 'max' => 255,
  70 + ],
  71 + [
  72 + [
  73 + 'project_id',
  74 + 'language_id',
  75 + ],
  76 + 'unique',
  77 + 'targetAttribute' => [
  78 + 'project_id',
  79 + 'language_id',
  80 + ],
  81 + 'message' => 'The combination of Project ID and Language ID has already been taken.',
  82 + ],
  83 + [
  84 + [ 'language_id' ],
  85 + 'exist',
  86 + 'skipOnError' => true,
  87 + 'targetClass' => Language::className(),
  88 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  89 + ],
  90 + [
  91 + [ 'project_id' ],
  92 + 'exist',
  93 + 'skipOnError' => true,
  94 + 'targetClass' => Project::className(),
  95 + 'targetAttribute' => [ 'project_id' => 'project_id' ],
  96 + ],
  97 + ];
  98 + }
  99 +
  100 + /**
  101 + * @inheritdoc
  102 + */
  103 + public function attributeLabels()
  104 + {
  105 + return [
  106 + 'project_id' => Yii::t('app', 'Project ID'),
  107 + 'language_id' => Yii::t('app', 'Language ID'),
  108 + 'title' => Yii::t('app', 'Title'),
  109 + 'description' => Yii::t('app', 'Description'),
  110 + 'alias' => Yii::t('app', 'Alias'),
  111 + ];
  112 + }
  113 +
  114 + /**
  115 + * @return \yii\db\ActiveQuery
  116 + */
  117 + public function getLanguage()
  118 + {
  119 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  120 + }
  121 +
  122 + /**
  123 + * @return \yii\db\ActiveQuery
  124 + */
  125 + public function getProject()
  126 + {
  127 + return $this->hasOne(Project::className(), [ 'project_id' => 'project_id' ]);
  128 + }
80 } 129 }
81 -}  
common/models/ProjectSearch.php
@@ -23,7 +23,6 @@ class ProjectSearch extends Project @@ -23,7 +23,6 @@ class ProjectSearch extends Project
23 { 23 {
24 return [ 24 return [
25 [['project_id', 'date_add'], 'integer'], 25 [['project_id', 'date_add'], 'integer'],
26 - [['title', 'link', 'description'], 'safe'],  
27 ]; 26 ];
28 } 27 }
29 28
@@ -67,10 +66,6 @@ class ProjectSearch extends Project @@ -67,10 +66,6 @@ class ProjectSearch extends Project
67 'date_add' => $this->date_add, 66 'date_add' => $this->date_add,
68 ]); 67 ]);
69 68
70 - $query->andFilterWhere(['like', 'title', $this->title])  
71 - ->andFilterWhere(['like', 'link', $this->link])  
72 - ->andFilterWhere(['like', 'description', $this->description]);  
73 -  
74 return $dataProvider; 69 return $dataProvider;
75 } 70 }
76 } 71 }
common/models/Seo.php
@@ -13,11 +13,6 @@ use yii\web\Request; @@ -13,11 +13,6 @@ use yii\web\Request;
13 * 13 *
14 * @property integer $seo_id 14 * @property integer $seo_id
15 * @property string $url 15 * @property string $url
16 - * @property string $title  
17 - * @property string $meta  
18 - * @property string $description  
19 - * @property string $h1  
20 - * @property string $seo_text  
21 * 16 *
22 * * From language behavior * 17 * * From language behavior *
23 * @property SeoLang $lang 18 * @property SeoLang $lang
@@ -63,8 +58,7 @@ class Seo extends \yii\db\ActiveRecord @@ -63,8 +58,7 @@ class Seo extends \yii\db\ActiveRecord
63 { 58 {
64 return [ 59 return [
65 [['url'], 'required'], 60 [['url'], 'required'],
66 - [['seo_text'], 'string'],  
67 - [['url', 'title', 'meta', 'description', 'h1'], 'string', 'max' => 255], 61 + [['url'], 'string', 'max' => 255],
68 ]; 62 ];
69 } 63 }
70 64
@@ -76,11 +70,6 @@ class Seo extends \yii\db\ActiveRecord @@ -76,11 +70,6 @@ class Seo extends \yii\db\ActiveRecord
76 return [ 70 return [
77 'seo_id' => Yii::t('app', 'seo_id'), 71 'seo_id' => Yii::t('app', 'seo_id'),
78 'url' => Yii::t('app', 'url'), 72 'url' => Yii::t('app', 'url'),
79 - 'title' => Yii::t('app', 'title'),  
80 - 'meta' => Yii::t('app', 'meta_title'),  
81 - 'description' => Yii::t('app', 'description'),  
82 - 'h1' => Yii::t('app', 'h1'),  
83 - 'seo_text' => Yii::t('app', 'seo_text'),  
84 ]; 73 ];
85 } 74 }
86 } 75 }
common/models/SeoCategory.php
@@ -12,7 +12,6 @@ use yii\web\Request; @@ -12,7 +12,6 @@ use yii\web\Request;
12 * This is the model class for table "seo_category". 12 * This is the model class for table "seo_category".
13 * 13 *
14 * @property integer $seo_category_id 14 * @property integer $seo_category_id
15 - * @property string $name  
16 * @property string $controller 15 * @property string $controller
17 * @property integer $status 16 * @property integer $status
18 * 17 *
@@ -62,7 +61,6 @@ class SeoCategory extends \yii\db\ActiveRecord @@ -62,7 +61,6 @@ class SeoCategory extends \yii\db\ActiveRecord
62 { 61 {
63 return [ 62 return [
64 [['status'], 'integer'], 63 [['status'], 'integer'],
65 - [['name'], 'string', 'max' => 255],  
66 [['controller'], 'string', 'max' => 100], 64 [['controller'], 'string', 'max' => 100],
67 ]; 65 ];
68 } 66 }
@@ -74,7 +72,6 @@ class SeoCategory extends \yii\db\ActiveRecord @@ -74,7 +72,6 @@ class SeoCategory extends \yii\db\ActiveRecord
74 { 72 {
75 return [ 73 return [
76 'seo_category_id' => Yii::t('app', 'seo_category_id'), 74 'seo_category_id' => Yii::t('app', 'seo_category_id'),
77 - 'name' => Yii::t('app', 'name'),  
78 'controller' => Yii::t('app', 'controller'), 75 'controller' => Yii::t('app', 'controller'),
79 'status' => Yii::t('app', 'status'), 76 'status' => Yii::t('app', 'status'),
80 ]; 77 ];
common/models/SeoCategorySearch.php
1 <?php 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 2
16 - public function behaviors()  
17 - {  
18 - return [];  
19 - } 3 + namespace common\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
20 7
21 /** 8 /**
22 - * @inheritdoc  
23 - */  
24 - public function rules()  
25 - {  
26 - return [  
27 - [['seo_category_id', 'status'], 'integer'],  
28 - [['name', 'controller'], 'safe'],  
29 - ];  
30 - }  
31 -  
32 - /**  
33 - * @inheritdoc  
34 - */  
35 - public function scenarios()  
36 - {  
37 - // bypass scenarios() implementation in the parent class  
38 - return Model::scenarios();  
39 - }  
40 -  
41 - /**  
42 - * Creates data provider instance with search query applied  
43 - *  
44 - * @param array $params  
45 - *  
46 - * @return ActiveDataProvider 9 + * SeoCategorySearch represents the model behind the search form about
  10 + * `common\models\SeoCategory`.
47 */ 11 */
48 - public function search($params) 12 + class SeoCategorySearch extends SeoCategory
49 { 13 {
50 - $query = SeoCategory::find();  
51 -  
52 - // add conditions that should always apply here  
53 -  
54 - $dataProvider = new ActiveDataProvider([  
55 - 'query' => $query,  
56 - ]);  
57 -  
58 - $this->load($params);  
59 -  
60 - if (!$this->validate()) {  
61 - // uncomment the following line if you do not want to return any records when validation fails  
62 - // $query->where('0=1'); 14 +
  15 + public function behaviors()
  16 + {
  17 + return [];
  18 + }
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function rules()
  24 + {
  25 + return [
  26 + [
  27 + [
  28 + 'seo_category_id',
  29 + 'status',
  30 + ],
  31 + 'integer',
  32 + ],
  33 + [
  34 + [ 'controller' ],
  35 + 'safe',
  36 + ],
  37 + ];
  38 + }
  39 +
  40 + /**
  41 + * @inheritdoc
  42 + */
  43 + public function scenarios()
  44 + {
  45 + // bypass scenarios() implementation in the parent class
  46 + return Model::scenarios();
  47 + }
  48 +
  49 + /**
  50 + * Creates data provider instance with search query applied
  51 + *
  52 + * @param array $params
  53 + *
  54 + * @return ActiveDataProvider
  55 + */
  56 + public function search($params)
  57 + {
  58 + $query = SeoCategory::find();
  59 +
  60 + // add conditions that should always apply here
  61 +
  62 + $dataProvider = new ActiveDataProvider([
  63 + 'query' => $query,
  64 + ]);
  65 +
  66 + $this->load($params);
  67 +
  68 + if(!$this->validate()) {
  69 + // uncomment the following line if you do not want to return any records when validation fails
  70 + // $query->where('0=1');
  71 + return $dataProvider;
  72 + }
  73 +
  74 + // grid filtering conditions
  75 + $query->andFilterWhere([
  76 + 'seo_category_id' => $this->seo_category_id,
  77 + 'status' => $this->status,
  78 + ]);
  79 +
  80 + $query->andFilterWhere([
  81 + 'like',
  82 + 'controller',
  83 + $this->controller,
  84 + ]);
  85 +
63 return $dataProvider; 86 return $dataProvider;
64 } 87 }
65 -  
66 - // grid filtering conditions  
67 - $query->andFilterWhere([  
68 - 'seo_category_id' => $this->seo_category_id,  
69 - 'status' => $this->status,  
70 - ]);  
71 -  
72 - $query->andFilterWhere(['like', 'name', $this->name])  
73 - ->andFilterWhere(['like', 'controller', $this->controller]);  
74 -  
75 - return $dataProvider;  
76 } 88 }
77 -}  
common/models/SeoDynamic.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\behaviors\LanguageBehavior;  
6 -use Yii;  
7 -use yii\db\ActiveQuery;  
8 -use yii\db\ActiveRecord;  
9 -use yii\web\Request;  
10 -/**  
11 - * This is the model class for table "seo_dynamic".  
12 - *  
13 - * @property integer $seo_dynamic_id  
14 - * @property integer $seo_category_id  
15 - * @property string $name  
16 - * @property string $action  
17 - * @property string $fields  
18 - * @property string $title  
19 - * @property string $h1  
20 - * @property string $description  
21 - * @property string $seo_text  
22 - * @property integer $status  
23 - * @property string $param  
24 - * @property string $key  
25 - *  
26 - * * From language behavior *  
27 - * @property SeoDynamicLang $lang  
28 - * @property SeoDynamicLang[] $langs  
29 - * @property SeoDynamicLang $object_lang  
30 - * @property string $ownerKey  
31 - * @property string $langKey  
32 - * @method string getOwnerKey()  
33 - * @method void setOwnerKey(string $value)  
34 - * @method string getLangKey()  
35 - * @method void setLangKey(string $value)  
36 - * @method ActiveQuery getLangs()  
37 - * @method ActiveQuery getLang( integer $language_id )  
38 - * @method SeoDynamicLang[] generateLangs()  
39 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
40 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
41 - * @method bool saveLangs(ActiveRecord[] $model_langs)  
42 - * * End language behavior *  
43 - * @property SeoCategory $seoCategory  
44 - */  
45 -class SeoDynamic extends \yii\db\ActiveRecord  
46 -{  
47 - /**  
48 - * @inheritdoc  
49 - */  
50 - public static function tableName()  
51 - {  
52 - return 'seo_dynamic';  
53 - }  
54 2
55 - public function behaviors()  
56 - {  
57 - return [  
58 - 'language' => [  
59 - 'class' => LanguageBehavior::className(),  
60 - ],  
61 - ];  
62 - } 3 + namespace common\models;
  4 +
  5 + use common\modules\language\behaviors\LanguageBehavior;
  6 + use Yii;
  7 + use yii\db\ActiveQuery;
  8 + use yii\db\ActiveRecord;
  9 + use yii\web\Request;
63 10
64 /** 11 /**
65 - * @inheritdoc  
66 - */  
67 - public function rules()  
68 - {  
69 - return [  
70 - [['seo_category_id', 'status'], 'integer'],  
71 - [['seo_text'], 'string'],  
72 - [['name', 'action'], 'string', 'max' => 200],  
73 - [['fields', 'title', 'meta', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255],  
74 - [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']],  
75 - ];  
76 - }  
77 -  
78 - /**  
79 - * @inheritdoc  
80 - */  
81 - public function attributeLabels()  
82 - {  
83 - return [  
84 - 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),  
85 - 'seo_category_id' => Yii::t('app', 'seo_category_id'),  
86 - 'name' => Yii::t('app', 'name'),  
87 - 'action' => Yii::t('app', 'action'),  
88 - 'fields' => Yii::t('app', 'fields'),  
89 - 'title' => Yii::t('app', 'title'),  
90 - 'meta' => Yii::t('app', 'meta'),  
91 - 'h1' => Yii::t('app', 'h1'),  
92 - 'description' => Yii::t('app', 'description'),  
93 - 'seo_text' => Yii::t('app', 'seo_text'),  
94 - 'status' => Yii::t('app', 'status'),  
95 - 'param' => Yii::t('app', 'param'),  
96 - 'key' => Yii::t('app', 'key'),  
97 - ];  
98 - }  
99 -  
100 - /**  
101 - * @return \yii\db\ActiveQuery 12 + * This is the model class for table "seo_dynamic".
  13 + * @property integer $seo_dynamic_id
  14 + * @property integer $seo_category_id
  15 + * @property string $action
  16 + * @property string $fields
  17 + * @property integer $status
  18 + * @property string $param
  19 + * * From language behavior *
  20 + * @property SeoDynamicLang $lang
  21 + * @property SeoDynamicLang[] $langs
  22 + * @property SeoDynamicLang $object_lang
  23 + * @property string $ownerKey
  24 + * @property string $langKey
  25 + * @method string getOwnerKey()
  26 + * @method void setOwnerKey( string $value )
  27 + * @method string getLangKey()
  28 + * @method void setLangKey( string $value )
  29 + * @method ActiveQuery getLangs()
  30 + * @method ActiveQuery getLang( integer $language_id )
  31 + * @method SeoDynamicLang[] generateLangs()
  32 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  33 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  34 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  35 + * * End language behavior *
  36 + * @property SeoCategory $seoCategory
102 */ 37 */
103 - public function getSeoCategory() 38 + class SeoDynamic extends \yii\db\ActiveRecord
104 { 39 {
105 - return $this->hasOne(SeoCategory::className(), ['seo_category_id' => 'seo_category_id']); 40 +
  41 + /**
  42 + * @inheritdoc
  43 + */
  44 + public static function tableName()
  45 + {
  46 + return 'seo_dynamic';
  47 + }
  48 +
  49 + public function behaviors()
  50 + {
  51 + return [
  52 + 'language' => [
  53 + 'class' => LanguageBehavior::className(),
  54 + ],
  55 + ];
  56 + }
  57 +
  58 + /**
  59 + * @inheritdoc
  60 + */
  61 + public function rules()
  62 + {
  63 + return [
  64 + [
  65 + [
  66 + 'seo_category_id',
  67 + 'status',
  68 + ],
  69 + 'integer',
  70 + ],
  71 + [
  72 + [
  73 + 'action',
  74 + ],
  75 + 'string',
  76 + 'max' => 200,
  77 + ],
  78 + [
  79 + [
  80 + 'fields',
  81 + 'param',
  82 + ],
  83 + 'string',
  84 + 'max' => 255,
  85 + ],
  86 + [
  87 + [ 'seo_category_id' ],
  88 + 'exist',
  89 + 'skipOnError' => true,
  90 + 'targetClass' => SeoCategory::className(),
  91 + 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ],
  92 + ],
  93 + ];
  94 + }
  95 +
  96 + /**
  97 + * @inheritdoc
  98 + */
  99 + public function attributeLabels()
  100 + {
  101 + return [
  102 + 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),
  103 + 'seo_category_id' => Yii::t('app', 'seo_category_id'),
  104 + 'action' => Yii::t('app', 'action'),
  105 + 'fields' => Yii::t('app', 'fields'),
  106 + 'status' => Yii::t('app', 'status'),
  107 + 'param' => Yii::t('app', 'param'),
  108 + ];
  109 + }
  110 +
  111 + /**
  112 + * @return \yii\db\ActiveQuery
  113 + */
  114 + public function getSeoCategory()
  115 + {
  116 + return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]);
  117 + }
106 } 118 }
107 -}  
common/models/SeoDynamicSearch.php
1 <?php 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 2
16 - public function behaviors()  
17 - {  
18 - return [];  
19 - } 3 + namespace common\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
20 7
21 /** 8 /**
22 - * @inheritdoc  
23 - */  
24 - public function rules()  
25 - {  
26 - return [  
27 - [['seo_dynamic_id', 'seo_category_id', 'status'], 'integer'],  
28 - [['name', 'action', 'fields', 'title', 'meta', 'h1', 'description', 'seo_text'], 'safe'],  
29 - ];  
30 - }  
31 -  
32 - /**  
33 - * @inheritdoc  
34 - */  
35 - public function scenarios()  
36 - {  
37 - // bypass scenarios() implementation in the parent class  
38 - return Model::scenarios();  
39 - }  
40 -  
41 - /**  
42 - * Creates data provider instance with search query applied  
43 - *  
44 - * @param array $params  
45 - *  
46 - * @return ActiveDataProvider 9 + * SeoDynamicSearch represents the model behind the search form about
  10 + * `common\models\SeoDynamic`.
47 */ 11 */
48 - public function search($seo_category_id, $params) 12 + class SeoDynamicSearch extends SeoDynamic
49 { 13 {
50 - $query = SeoDynamic::find();  
51 -  
52 - // add conditions that should always apply here  
53 -  
54 - $dataProvider = new ActiveDataProvider([  
55 - 'query' => $query,  
56 - ]);  
57 -  
58 - $this->load($params);  
59 -  
60 - if (!$this->validate()) {  
61 - // uncomment the following line if you do not want to return any records when validation fails  
62 - // $query->where('0=1'); 14 +
  15 + public function behaviors()
  16 + {
  17 + return [];
  18 + }
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function rules()
  24 + {
  25 + return [
  26 + [
  27 + [
  28 + 'seo_dynamic_id',
  29 + 'seo_category_id',
  30 + 'status',
  31 + ],
  32 + 'integer',
  33 + ],
  34 + [
  35 + [
  36 + 'action',
  37 + 'fields',
  38 + ],
  39 + 'safe',
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * @inheritdoc
  46 + */
  47 + public function scenarios()
  48 + {
  49 + // bypass scenarios() implementation in the parent class
  50 + return Model::scenarios();
  51 + }
  52 +
  53 + /**
  54 + * Creates data provider instance with search query applied
  55 + *
  56 + * @param array $params
  57 + *
  58 + * @return ActiveDataProvider
  59 + */
  60 + public function search($seo_category_id, $params)
  61 + {
  62 + $query = SeoDynamic::find();
  63 +
  64 + // add conditions that should always apply here
  65 +
  66 + $dataProvider = new ActiveDataProvider([
  67 + 'query' => $query,
  68 + ]);
  69 +
  70 + $this->load($params);
  71 +
  72 + if(!$this->validate()) {
  73 + // uncomment the following line if you do not want to return any records when validation fails
  74 + // $query->where('0=1');
  75 + return $dataProvider;
  76 + }
  77 +
  78 + // grid filtering conditions
  79 + $query->andFilterWhere([
  80 + 'seo_dynamic_id' => $this->seo_dynamic_id,
  81 + 'seo_category_id' => $seo_category_id,
  82 + 'status' => $this->status,
  83 + ]);
  84 +
  85 + $query->andFilterWhere([
  86 + 'like',
  87 + 'action',
  88 + $this->action,
  89 + ])
  90 + ->andFilterWhere([
  91 + 'like',
  92 + 'fields',
  93 + $this->fields,
  94 + ]);
  95 +
63 return $dataProvider; 96 return $dataProvider;
64 } 97 }
65 -  
66 - // grid filtering conditions  
67 - $query->andFilterWhere([  
68 - 'seo_dynamic_id' => $this->seo_dynamic_id,  
69 - 'seo_category_id' => $seo_category_id,  
70 - 'status' => $this->status,  
71 - ]);  
72 -  
73 - $query->andFilterWhere(['like', 'name', $this->name])  
74 - ->andFilterWhere(['like', 'action', $this->action])  
75 - ->andFilterWhere(['like', 'fields', $this->fields])  
76 - ->andFilterWhere(['like', 'title', $this->title])  
77 - ->andFilterWhere(['like', 'meta', $this->title])  
78 - ->andFilterWhere(['like', 'h1', $this->h1])  
79 - ->andFilterWhere(['like', 'description', $this->description])  
80 - ->andFilterWhere(['like', 'seo_text', $this->seo_text]);  
81 -  
82 - return $dataProvider;  
83 } 98 }
84 -}  
common/models/SeoSearch.php
@@ -2,10 +2,8 @@ @@ -2,10 +2,8 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
5 -use Yii;  
6 use yii\base\Model; 5 use yii\base\Model;
7 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
8 -use common\models\Seo;  
9 7
10 /** 8 /**
11 * SeoSearch represents the model behind the search form about `common\models\Seo`. 9 * SeoSearch represents the model behind the search form about `common\models\Seo`.
@@ -25,7 +23,7 @@ class SeoSearch extends Seo @@ -25,7 +23,7 @@ class SeoSearch extends Seo
25 { 23 {
26 return [ 24 return [
27 [['seo_id'], 'integer'], 25 [['seo_id'], 'integer'],
28 - [['url', 'title', 'meta', 'description', 'h1', 'seo_text'], 'safe'], 26 + [['url'], 'safe'],
29 ]; 27 ];
30 } 28 }
31 29
@@ -68,12 +66,7 @@ class SeoSearch extends Seo @@ -68,12 +66,7 @@ class SeoSearch extends Seo
68 'seo_id' => $this->seo_id, 66 'seo_id' => $this->seo_id,
69 ]); 67 ]);
70 68
71 - $query->andFilterWhere(['like', 'url', $this->url])  
72 - ->andFilterWhere(['like', 'title', $this->title])  
73 - ->andFilterWhere(['like', 'meta', $this->meta])  
74 - ->andFilterWhere(['like', 'description', $this->description])  
75 - ->andFilterWhere(['like', 'h1', $this->h1])  
76 - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); 69 + $query->andFilterWhere(['like', 'url', $this->url]);
77 70
78 return $dataProvider; 71 return $dataProvider;
79 } 72 }
common/models/Service.php
1 <?php 1 <?php
2 -  
3 -namespace common\models;  
4 -  
5 -use common\modules\language\behaviors\LanguageBehavior;  
6 -use Yii;  
7 -use yii\behaviors\TimestampBehavior;  
8 -use yii\db\ActiveQuery;  
9 -use yii\db\ActiveRecord;  
10 -use yii\web\Request;  
11 -  
12 -/**  
13 - * This is the model class for table "service".  
14 - *  
15 - * @property integer $service_id  
16 - * @property string $name  
17 - * @property string $alias  
18 - * @property string $body  
19 - * @property string $image  
20 - * @property string $meta_title  
21 - * @property string $description  
22 - * @property string $h1  
23 - * @property string $seo_text  
24 - * @property integer $created_at  
25 - * @property integer $updated_at  
26 - *  
27 - * * From language behavior *  
28 - * @property ServiceLang $lang  
29 - * @property ServiceLang[] $langs  
30 - * @property ServiceLang $object_lang  
31 - * @property string $ownerKey  
32 - * @property string $langKey  
33 - * @method string getOwnerKey()  
34 - * @method void setOwnerKey(string $value)  
35 - * @method string getLangKey()  
36 - * @method void setLangKey(string $value)  
37 - * @method ActiveQuery getLangs()  
38 - * @method ActiveQuery getLang( integer $language_id )  
39 - * @method ServiceLang[] generateLangs()  
40 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
41 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
42 - * @method bool saveLangs(ActiveRecord[] $model_langs)  
43 - * * End language behavior *  
44 - */  
45 -class Service extends \yii\db\ActiveRecord  
46 -{  
47 - /**  
48 - * @inheritdoc  
49 - */  
50 - public static function tableName()  
51 - {  
52 - return 'service';  
53 - } 2 +
  3 + namespace common\models;
  4 +
  5 + use common\behaviors\SaveImgBehavior;
  6 + use common\modules\language\behaviors\LanguageBehavior;
  7 + use Yii;
  8 + use yii\behaviors\TimestampBehavior;
  9 + use yii\db\ActiveQuery;
  10 + use yii\db\ActiveRecord;
  11 + use yii\web\Request;
54 12
55 /** 13 /**
56 - * @inheritdoc  
57 - */  
58 - public function rules()  
59 - {  
60 - return [  
61 - [['name', 'body'], 'required'],  
62 - [['body', 'seo_text'], 'string'],  
63 - [['created_at', 'updated_at'], 'integer'],  
64 - [['name', 'alias', 'image', 'meta_title', 'description', 'h1'], 'string', 'max' => 255],  
65 - ];  
66 - }  
67 - /**  
68 - * @inheritdoc  
69 - */  
70 - public function behaviors()  
71 - {  
72 - return [  
73 - TimestampBehavior::className(),  
74 - 'slug' => [  
75 - 'class' => 'common\behaviors\Slug',  
76 - 'in_attribute' => 'name',  
77 - 'out_attribute' => 'alias',  
78 - 'translit' => true  
79 - ],  
80 - [  
81 - 'class' => 'common\behaviors\ShowImage',  
82 - ],  
83 - 'language' => [  
84 - 'class' => LanguageBehavior::className(),  
85 - ],  
86 - ];  
87 - }  
88 - /**  
89 - * @inheritdoc 14 + * This is the model class for table "service".
  15 + * @property integer $service_id
  16 + * @property string $image
  17 + * @property integer $created_at
  18 + * @property integer $updated_at
  19 + * * From language behavior *
  20 + * @property ServiceLang $lang
  21 + * @property ServiceLang[] $langs
  22 + * @property ServiceLang $object_lang
  23 + * @property string $ownerKey
  24 + * @property string $langKey
  25 + * @method string getOwnerKey()
  26 + * @method void setOwnerKey( string $value )
  27 + * @method string getLangKey()
  28 + * @method void setLangKey( string $value )
  29 + * @method ActiveQuery getLangs()
  30 + * @method ActiveQuery getLang( integer $language_id )
  31 + * @method ServiceLang[] generateLangs()
  32 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  33 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  34 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  35 + * * End language behavior *
90 */ 36 */
91 - public function attributeLabels() 37 + class Service extends \yii\db\ActiveRecord
92 { 38 {
93 - return [  
94 - 'service_id' => Yii::t('app', 'service_id'),  
95 - 'name' => Yii::t('app', 'name'),  
96 - 'alias' => Yii::t('app', 'alias'),  
97 - 'body' => Yii::t('app', 'body'),  
98 - 'image' => Yii::t('app', 'image'),  
99 - 'meta_title' => Yii::t('app', 'meta_title'),  
100 - 'description' => Yii::t('app', 'description'),  
101 - 'h1' => Yii::t('app', 'h1'),  
102 - 'seo_text' => Yii::t('app', 'seo_text'),  
103 - 'created_at' => Yii::t('app', 'created_at'),  
104 - 'updated_at' => Yii::t('app', 'updated_at'),  
105 - ]; 39 +
  40 + /**
  41 + * @inheritdoc
  42 + */
  43 + public static function tableName()
  44 + {
  45 + return 'service';
  46 + }
  47 +
  48 + /**
  49 + * @inheritdoc
  50 + */
  51 + public function rules()
  52 + {
  53 + return [
  54 + [
  55 + [
  56 + 'created_at',
  57 + 'updated_at',
  58 + ],
  59 + 'integer',
  60 + ],
  61 + ];
  62 + }
  63 +
  64 + /**
  65 + * @inheritdoc
  66 + */
  67 + public function behaviors()
  68 + {
  69 + return [
  70 + [
  71 + 'class' => SaveImgBehavior::className(),
  72 + 'fields' => [
  73 + [
  74 + 'name' => 'image',
  75 + 'directory' => 'service',
  76 + ],
  77 + ],
  78 + ],
  79 + TimestampBehavior::className(),
  80 + [
  81 + 'class' => 'common\behaviors\ShowImage',
  82 + ],
  83 + 'language' => [
  84 + 'class' => LanguageBehavior::className(),
  85 + ],
  86 + ];
  87 + }
  88 +
  89 + /**
  90 + * @inheritdoc
  91 + */
  92 + public function attributeLabels()
  93 + {
  94 + return [
  95 + 'service_id' => Yii::t('app', 'service_id'),
  96 + 'image' => Yii::t('app', 'image'),
  97 + 'created_at' => Yii::t('app', 'created_at'),
  98 + 'updated_at' => Yii::t('app', 'updated_at'),
  99 + ];
  100 + }
106 } 101 }
107 -}  
common/models/ServiceLang.php
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 */ 20 */
21 class ServiceLang extends \yii\db\ActiveRecord 21 class ServiceLang extends \yii\db\ActiveRecord
22 { 22 {
23 - 23 +
24 public static function primaryKey() 24 public static function primaryKey()
25 { 25 {
26 return [ 26 return [
@@ -37,6 +37,18 @@ @@ -37,6 +37,18 @@
37 return 'service_lang'; 37 return 'service_lang';
38 } 38 }
39 39
  40 + public function behaviors()
  41 + {
  42 + return [
  43 + 'slug' => [
  44 + 'class' => 'common\behaviors\Slug',
  45 + 'in_attribute' => 'name',
  46 + 'out_attribute' => 'alias',
  47 + 'translit' => true,
  48 + ],
  49 + ];
  50 + }
  51 +
40 /** 52 /**
41 * @inheritdoc 53 * @inheritdoc
42 */ 54 */
common/models/ServiceSearch.php
1 <?php 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\Service;  
9 -  
10 -/**  
11 - * ServiceSearch represents the model behind the search form about `common\models\Service`.  
12 - */  
13 -class ServiceSearch extends Service  
14 -{  
15 2
16 - public function behaviors()  
17 - {  
18 - return [];  
19 - } 3 + namespace common\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
20 7
21 /** 8 /**
22 - * @inheritdoc  
23 - */  
24 - public function rules()  
25 - {  
26 - return [  
27 - [['service_id', 'created_at', 'updated_at'], 'integer'],  
28 - [['name', 'alias', 'body', 'image', 'meta_title', 'description', 'h1', 'seo_text'], 'safe'],  
29 - ];  
30 - }  
31 -  
32 - /**  
33 - * @inheritdoc  
34 - */  
35 - public function scenarios()  
36 - {  
37 - // bypass scenarios() implementation in the parent class  
38 - return Model::scenarios();  
39 - }  
40 -  
41 - /**  
42 - * Creates data provider instance with search query applied  
43 - *  
44 - * @param array $params  
45 - *  
46 - * @return ActiveDataProvider 9 + * ServiceSearch represents the model behind the search form about `common\models\Service`.
47 */ 10 */
48 - public function search($params) 11 + class ServiceSearch extends Service
49 { 12 {
50 - $query = Service::find();  
51 -  
52 - // add conditions that should always apply here  
53 -  
54 - $dataProvider = new ActiveDataProvider([  
55 - 'query' => $query,  
56 - ]);  
57 -  
58 - $this->load($params);  
59 -  
60 - if (!$this->validate()) {  
61 - // uncomment the following line if you do not want to return any records when validation fails  
62 - // $query->where('0=1'); 13 +
  14 + public function behaviors()
  15 + {
  16 + return [];
  17 + }
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function rules()
  23 + {
  24 + return [
  25 + [
  26 + [
  27 + 'service_id',
  28 + 'created_at',
  29 + 'updated_at',
  30 + ],
  31 + 'integer',
  32 + ],
  33 + ];
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function scenarios()
  40 + {
  41 + // bypass scenarios() implementation in the parent class
  42 + return Model::scenarios();
  43 + }
  44 +
  45 + /**
  46 + * Creates data provider instance with search query applied
  47 + *
  48 + * @param array $params
  49 + *
  50 + * @return ActiveDataProvider
  51 + */
  52 + public function search($params)
  53 + {
  54 + $query = Service::find();
  55 +
  56 + // add conditions that should always apply here
  57 +
  58 + $dataProvider = new ActiveDataProvider([
  59 + 'query' => $query,
  60 + ]);
  61 +
  62 + $this->load($params);
  63 +
  64 + if(!$this->validate()) {
  65 + // uncomment the following line if you do not want to return any records when validation fails
  66 + // $query->where('0=1');
  67 + return $dataProvider;
  68 + }
  69 +
  70 + // grid filtering conditions
  71 + $query->andFilterWhere([
  72 + 'service_id' => $this->service_id,
  73 + 'created_at' => $this->created_at,
  74 + 'updated_at' => $this->updated_at,
  75 + ]);
  76 +
63 return $dataProvider; 77 return $dataProvider;
64 } 78 }
65 -  
66 - // grid filtering conditions  
67 - $query->andFilterWhere([  
68 - 'service_id' => $this->service_id,  
69 - 'created_at' => $this->created_at,  
70 - 'updated_at' => $this->updated_at,  
71 - ]);  
72 -  
73 - $query->andFilterWhere(['like', 'name', $this->name])  
74 - ->andFilterWhere(['like', 'alias', $this->alias])  
75 - ->andFilterWhere(['like', 'body', $this->body])  
76 - ->andFilterWhere(['like', 'image', $this->image])  
77 - ->andFilterWhere(['like', 'meta_title', $this->meta_title])  
78 - ->andFilterWhere(['like', 'description', $this->description])  
79 - ->andFilterWhere(['like', 'h1', $this->h1])  
80 - ->andFilterWhere(['like', 'seo_text', $this->seo_text]);  
81 -  
82 - return $dataProvider;  
83 } 79 }
84 -}  
common/models/SliderImage.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
  5 + use common\behaviors\SaveImgBehavior;
5 use common\modules\language\behaviors\LanguageBehavior; 6 use common\modules\language\behaviors\LanguageBehavior;
6 use Yii; 7 use Yii;
7 use yii\db\ActiveQuery; 8 use yii\db\ActiveQuery;
@@ -13,8 +14,6 @@ @@ -13,8 +14,6 @@
13 * @property integer $slider_image_id 14 * @property integer $slider_image_id
14 * @property integer $slider_id 15 * @property integer $slider_id
15 * @property string $image 16 * @property string $image
16 - * @property string $alt  
17 - * @property string $title  
18 * @property string $url 17 * @property string $url
19 * @property integer $status 18 * @property integer $status
20 * @property integer $sort 19 * @property integer $sort
@@ -64,9 +63,6 @@ @@ -64,9 +63,6 @@
64 ], 63 ],
65 [ 64 [
66 [ 65 [
67 - 'image',  
68 - 'alt',  
69 - 'title',  
70 'url', 66 'url',
71 ], 67 ],
72 'string', 68 'string',
@@ -88,6 +84,15 @@ @@ -88,6 +84,15 @@
88 'language' => [ 84 'language' => [
89 'class' => LanguageBehavior::className(), 85 'class' => LanguageBehavior::className(),
90 ], 86 ],
  87 + [
  88 + 'class' => SaveImgBehavior::className(),
  89 + 'fields' => [
  90 + [
  91 + 'name' => 'image',
  92 + 'directory' => 'slider',
  93 + ],
  94 + ],
  95 + ],
91 ]; 96 ];
92 } 97 }
93 98
@@ -100,8 +105,6 @@ @@ -100,8 +105,6 @@
100 'slider_image_id' => Yii::t('app', 'slider_image_id'), 105 'slider_image_id' => Yii::t('app', 'slider_image_id'),
101 'slider_id' => Yii::t('app', 'slider_id'), 106 'slider_id' => Yii::t('app', 'slider_id'),
102 'image' => Yii::t('app', 'image'), 107 'image' => Yii::t('app', 'image'),
103 - 'alt' => Yii::t('app', 'alt'),  
104 - 'title' => Yii::t('app', 'title'),  
105 'url' => Yii::t('app', 'url'), 108 'url' => Yii::t('app', 'url'),
106 'status' => Yii::t('app', 'status'), 109 'status' => Yii::t('app', 'status'),
107 'sort' => Yii::t('app', 'sort'), 110 'sort' => Yii::t('app', 'sort'),
@@ -116,14 +119,4 @@ @@ -116,14 +119,4 @@
116 return $this->hasOne(Slider::className(), [ 'slider_id' => 'slider_id' ]); 119 return $this->hasOne(Slider::className(), [ 'slider_id' => 'slider_id' ]);
117 } 120 }
118 121
119 - public function getImageFile()  
120 - {  
121 - return empty( $this->image ) ? NULL : '/storage/slider/' . $this->image;  
122 - }  
123 -  
124 - public function getImageUrl()  
125 - {  
126 - return empty( $this->image ) ? NULL : '/storage/slider/' . $this->image;  
127 - }  
128 -  
129 } 122 }
common/models/SliderImageSearch.php
@@ -34,9 +34,6 @@ @@ -34,9 +34,6 @@
34 ], 34 ],
35 [ 35 [
36 [ 36 [
37 - 'image',  
38 - 'alt',  
39 - 'title',  
40 'url', 37 'url',
41 ], 38 ],
42 'safe', 39 'safe',
@@ -88,25 +85,10 @@ @@ -88,25 +85,10 @@
88 ]); 85 ]);
89 86
90 $query->andFilterWhere([ 87 $query->andFilterWhere([
91 - 'like',  
92 - 'image',  
93 - $this->image,  
94 - ])  
95 - ->andFilterWhere([  
96 - 'like',  
97 - 'alt',  
98 - $this->alt,  
99 - ])  
100 - ->andFilterWhere([  
101 - 'like',  
102 - 'title',  
103 - $this->title,  
104 - ])  
105 - ->andFilterWhere([  
106 - 'like',  
107 - 'url',  
108 - $this->url,  
109 - ]); 88 + 'like',
  89 + 'url',
  90 + $this->url,
  91 + ]);
110 92
111 return $dataProvider; 93 return $dataProvider;
112 } 94 }
common/modules/product/models/Brand.php
1 <?php 1 <?php
2 -  
3 -namespace common\modules\product\models;  
4 -  
5 -use common\behaviors\SaveImgBehavior;  
6 -use common\modules\language\behaviors\LanguageBehavior;  
7 -use Yii;  
8 -use yii\db\ActiveQuery;  
9 -use yii\db\ActiveRecord;  
10 -use yii\web\Request;  
11 -  
12 -/**  
13 - * This is the model class for table "brand".  
14 - *  
15 - * @property integer $brand_id  
16 -  
17 - * @property string $alias  
18 - * @property string $image  
19 - * @property string $meta_title  
20 - * @property string $meta_desc  
21 - * @property string $meta_robots  
22 - * @property string $seo_text  
23 - * @property string $name  
24 - *  
25 - * @property Product[] $products  
26 - * * From language behavior *  
27 - * @property BrandLang $lang  
28 - * @property BrandLang[] $langs  
29 - * @property BrandLang $object_lang  
30 - * @property string $ownerKey  
31 - * @property string $langKey  
32 - * @method string getOwnerKey()  
33 - * @method void setOwnerKey(string $value)  
34 - * @method string getLangKey()  
35 - * @method void setLangKey(string $value)  
36 - * @method ActiveQuery getLangs()  
37 - * @method ActiveQuery getLang( integer $language_id )  
38 - * @method BrandLang[] generateLangs()  
39 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
40 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
41 - * @method bool saveLangs(ActiveRecord[] $model_langs)  
42 - * * End language behavior *  
43 - */  
44 -class Brand extends \yii\db\ActiveRecord  
45 -{  
46 - public $_items_count = 0;  
47 - 2 +
  3 + namespace common\modules\product\models;
  4 +
  5 + use common\behaviors\SaveImgBehavior;
  6 + use common\modules\language\behaviors\LanguageBehavior;
  7 + use Yii;
  8 + use yii\db\ActiveQuery;
  9 + use yii\db\ActiveRecord;
  10 + use yii\web\Request;
  11 +
48 /** 12 /**
49 - * @inheritdoc 13 + * This is the model class for table "brand".
  14 + * @property integer $brand_id
  15 + * @property string $image
  16 + * @property bool $in_menu
  17 + * @property Product[] $products
  18 + * * From language behavior *
  19 + * @property BrandLang $lang
  20 + * @property BrandLang[] $langs
  21 + * @property BrandLang $object_lang
  22 + * @property string $ownerKey
  23 + * @property string $langKey
  24 + * @method string getOwnerKey()
  25 + * @method void setOwnerKey( string $value )
  26 + * @method string getLangKey()
  27 + * @method void setLangKey( string $value )
  28 + * @method ActiveQuery getLangs()
  29 + * @method ActiveQuery getLang( integer $language_id )
  30 + * @method BrandLang[] generateLangs()
  31 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  32 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  33 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  34 + * * End language behavior *
50 */ 35 */
51 - public static function tableName() 36 + class Brand extends \yii\db\ActiveRecord
52 { 37 {
53 - return 'brand';  
54 - }  
55 -  
56 -  
57 - public function behaviors()  
58 - {  
59 - return [  
60 - 'slug' => [  
61 - 'class' => 'common\behaviors\Slug',  
62 - 'in_attribute' => 'name',  
63 - 'out_attribute' => 'alias',  
64 - 'translit' => true  
65 - ],  
66 - [  
67 - 'class' => SaveImgBehavior::className(),  
68 - 'fields' => [  
69 - [  
70 - 'name' => 'image',  
71 - 'directory' => 'brand', 38 +
  39 + public $_items_count = 0;
  40 +
  41 + /**
  42 + * @inheritdoc
  43 + */
  44 + public static function tableName()
  45 + {
  46 + return 'brand';
  47 + }
  48 +
  49 + public function behaviors()
  50 + {
  51 + return [
  52 + [
  53 + 'class' => SaveImgBehavior::className(),
  54 + 'fields' => [
  55 + [
  56 + 'name' => 'image',
  57 + 'directory' => 'brand',
  58 + ],
72 ], 59 ],
73 ], 60 ],
74 - ],  
75 - 'language' => [  
76 - 'class' => LanguageBehavior::className(),  
77 - ],  
78 - ];  
79 - }  
80 -  
81 - /**  
82 - * @inheritdoc  
83 - */  
84 - public function rules()  
85 - {  
86 - return [  
87 - [['name'], 'string'],  
88 - [['meta_desc', 'seo_text'], 'string'],  
89 - [['alias', 'name'], 'string', 'max' => 250],  
90 - [['meta_title', 'image'], 'string', 'max' => 255],  
91 - [['meta_robots'], 'string', 'max' => 50],  
92 - ];  
93 - }  
94 -  
95 - /**  
96 - * @inheritdoc  
97 - */  
98 - public function attributeLabels()  
99 - {  
100 - return [  
101 - 'name' => Yii::t('product', 'Name of the brand'),  
102 - 'brand_id' => Yii::t('product', 'Brand ID'),  
103 - 'alias' => Yii::t('product', 'Alias'),  
104 - 'image' => Yii::t('product', 'Image'),  
105 - 'imageUrl' => Yii::t('product', 'Image'),  
106 - 'meta_title' => Yii::t('product', 'Meta Title'),  
107 - 'meta_desc' => Yii::t('product', 'Meta Desc'),  
108 - 'meta_robots' => Yii::t('product', 'Meta Robots'),  
109 - 'seo_text' => Yii::t('product', 'Seo Text'),  
110 - ];  
111 - }  
112 -  
113 -  
114 -  
115 - /**  
116 - * @return \yii\db\ActiveQuery  
117 - */  
118 - public function getProducts()  
119 - {  
120 - return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']); 61 + 'language' => [
  62 + 'class' => LanguageBehavior::className(),
  63 + ],
  64 + ];
  65 + }
  66 +
  67 + /**
  68 + * @inheritdoc
  69 + */
  70 + public function rules()
  71 + {
  72 + return [
  73 + [
  74 + [ 'in_menu' ],
  75 + 'boolean',
  76 + ],
  77 + ];
  78 + }
  79 +
  80 + /**
  81 + * @inheritdoc
  82 + */
  83 + public function attributeLabels()
  84 + {
  85 + return [
  86 + 'brand_id' => Yii::t('product', 'Brand ID'),
  87 + 'image' => Yii::t('product', 'Image'),
  88 + ];
  89 + }
  90 +
  91 + /**
  92 + * @return \yii\db\ActiveQuery
  93 + */
  94 + public function getProducts()
  95 + {
  96 + return $this->hasMany(Product::className(), [ 'brand_id' => 'brand_id' ]);
  97 + }
121 } 98 }
122 -}  
common/modules/product/models/BrandLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\modules\product\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "brand_lang".  
10 - *  
11 - * @property integer $brand_id  
12 - * @property integer $language_id  
13 - * @property string $name  
14 - * @property string $meta_title  
15 - * @property string $meta_robots  
16 - * @property string $meta_desc  
17 - * @property string $seo_text  
18 - *  
19 - * @property Brand $brand  
20 - * @property Language $language  
21 - */  
22 -class BrandLang extends \yii\db\ActiveRecord  
23 -{  
24 2
25 - public static function primaryKey()  
26 - {  
27 - return [  
28 - 'brand_id',  
29 - 'language_id',  
30 - ];  
31 - } 3 + namespace common\modules\product\models;
  4 +
  5 + use common\modules\language\models\Language;
  6 + use Yii;
32 7
33 /** 8 /**
34 - * @inheritdoc  
35 - */  
36 - public static function tableName()  
37 - {  
38 - return 'brand_lang';  
39 - }  
40 -  
41 - /**  
42 - * @inheritdoc  
43 - */  
44 - public function rules()  
45 - {  
46 - return [  
47 - [['name'], 'required'],  
48 - [['seo_text'], 'string'],  
49 - [['name', 'meta_title', 'meta_robots', 'meta_desc'], 'string', 'max' => 255],  
50 - [['brand_id', 'language_id'], 'unique', 'targetAttribute' => ['brand_id', 'language_id'], 'message' => 'The combination of Brand ID and Language ID has already been taken.'],  
51 - [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => Brand::className(), 'targetAttribute' => ['brand_id' => 'brand_id']],  
52 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
53 - ];  
54 - }  
55 -  
56 - /**  
57 - * @inheritdoc  
58 - */  
59 - public function attributeLabels()  
60 - {  
61 - return [  
62 - 'brand_id' => Yii::t('app', 'Brand ID'),  
63 - 'language_id' => Yii::t('app', 'Language ID'),  
64 - 'name' => Yii::t('app', 'Name'),  
65 - 'meta_title' => Yii::t('app', 'Meta Title'),  
66 - 'meta_robots' => Yii::t('app', 'Meta Robots'),  
67 - 'meta_desc' => Yii::t('app', 'Meta Desc'),  
68 - 'seo_text' => Yii::t('app', 'Seo Text'),  
69 - ];  
70 - }  
71 -  
72 - /**  
73 - * @return \yii\db\ActiveQuery  
74 - */  
75 - public function getBrand()  
76 - {  
77 - return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']);  
78 - }  
79 -  
80 - /**  
81 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "brand_lang".
  10 + * @property integer $brand_id
  11 + * @property integer $language_id
  12 + * @property string $name
  13 + * @property string $meta_title
  14 + * @property string $meta_robots
  15 + * @property string $meta_desc
  16 + * @property string $seo_text
  17 + * @property string $alias
  18 + * @property Brand $brand
  19 + * @property Language $language
82 */ 20 */
83 - public function getLanguage() 21 + class BrandLang extends \yii\db\ActiveRecord
84 { 22 {
85 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); 23 +
  24 + public static function primaryKey()
  25 + {
  26 + return [
  27 + 'brand_id',
  28 + 'language_id',
  29 + ];
  30 + }
  31 +
  32 + /**
  33 + * @inheritdoc
  34 + */
  35 + public static function tableName()
  36 + {
  37 + return 'brand_lang';
  38 + }
  39 +
  40 + public function behaviors()
  41 + {
  42 + return [
  43 + 'slug' => [
  44 + 'class' => 'common\behaviors\Slug',
  45 + 'in_attribute' => 'name',
  46 + 'out_attribute' => 'alias',
  47 + 'translit' => true,
  48 + ],
  49 + ];
  50 + }
  51 +
  52 + /**
  53 + * @inheritdoc
  54 + */
  55 + public function rules()
  56 + {
  57 + return [
  58 + [
  59 + [ 'name' ],
  60 + 'required',
  61 + ],
  62 + [
  63 + [ 'seo_text' ],
  64 + 'string',
  65 + ],
  66 + [
  67 + [
  68 + 'name',
  69 + 'meta_title',
  70 + 'meta_robots',
  71 + 'meta_desc',
  72 + 'alias',
  73 + ],
  74 + 'string',
  75 + 'max' => 255,
  76 + ],
  77 + [
  78 + [
  79 + 'brand_id',
  80 + 'language_id',
  81 + ],
  82 + 'unique',
  83 + 'targetAttribute' => [
  84 + 'brand_id',
  85 + 'language_id',
  86 + ],
  87 + 'message' => 'The combination of Brand ID and Language ID has already been taken.',
  88 + ],
  89 + [
  90 + [ 'brand_id' ],
  91 + 'exist',
  92 + 'skipOnError' => true,
  93 + 'targetClass' => Brand::className(),
  94 + 'targetAttribute' => [ 'brand_id' => 'brand_id' ],
  95 + ],
  96 + [
  97 + [ 'language_id' ],
  98 + 'exist',
  99 + 'skipOnError' => true,
  100 + 'targetClass' => Language::className(),
  101 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  102 + ],
  103 + ];
  104 + }
  105 +
  106 + /**
  107 + * @inheritdoc
  108 + */
  109 + public function attributeLabels()
  110 + {
  111 + return [
  112 + 'brand_id' => Yii::t('app', 'Brand ID'),
  113 + 'language_id' => Yii::t('app', 'Language ID'),
  114 + 'name' => Yii::t('app', 'Name'),
  115 + 'meta_title' => Yii::t('app', 'Meta Title'),
  116 + 'meta_robots' => Yii::t('app', 'Meta Robots'),
  117 + 'meta_desc' => Yii::t('app', 'Meta Desc'),
  118 + 'seo_text' => Yii::t('app', 'Seo Text'),
  119 + 'alias' => Yii::t('app', 'Alias'),
  120 + ];
  121 + }
  122 +
  123 + /**
  124 + * @return \yii\db\ActiveQuery
  125 + */
  126 + public function getBrand()
  127 + {
  128 + return $this->hasOne(Brand::className(), [ 'brand_id' => 'brand_id' ]);
  129 + }
  130 +
  131 + /**
  132 + * @return \yii\db\ActiveQuery
  133 + */
  134 + public function getLanguage()
  135 + {
  136 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  137 + }
86 } 138 }
87 -}  
common/modules/product/models/BrandSearch.php
@@ -5,7 +5,6 @@ namespace common\modules\product\models; @@ -5,7 +5,6 @@ namespace common\modules\product\models;
5 use yii\base\Model; 5 use yii\base\Model;
6 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
7 use yii\db\ActiveQuery; 7 use yii\db\ActiveQuery;
8 -use yii\web\NotFoundHttpException;  
9 8
10 /** 9 /**
11 * BrandSearch represents the model behind the search form about `common\modules\product\models\Brand`. 10 * BrandSearch represents the model behind the search form about `common\modules\product\models\Brand`.
@@ -20,7 +19,6 @@ class BrandSearch extends Brand @@ -20,7 +19,6 @@ class BrandSearch extends Brand
20 { 19 {
21 return [ 20 return [
22 [['brand_id'], 'integer'], 21 [['brand_id'], 'integer'],
23 - [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'brand_name'], 'safe'],  
24 ]; 22 ];
25 } 23 }
26 24
@@ -66,8 +64,7 @@ class BrandSearch extends Brand @@ -66,8 +64,7 @@ class BrandSearch extends Brand
66 $dataProvider->setSort([ 64 $dataProvider->setSort([
67 'attributes' => [ 65 'attributes' => [
68 'brand_name', 66 'brand_name',
69 - 'alias'  
70 - ] 67 + ],
71 ]); 68 ]);
72 69
73 // grid filtering conditions 70 // grid filtering conditions
@@ -75,17 +72,6 @@ class BrandSearch extends Brand @@ -75,17 +72,6 @@ class BrandSearch extends Brand
75 'brand_id' => $this->brand_id, 72 'brand_id' => $this->brand_id,
76 ]); 73 ]);
77 74
78 -  
79 - $query->andFilterWhere(['ilike', 'alias', $this->alias])  
80 - ->andFilterWhere(['ilike', 'image', $this->image])  
81 - ->andFilterWhere(['ilike', 'meta_title', $this->meta_title])  
82 - ->andFilterWhere(['ilike', 'meta_desc', $this->meta_desc])  
83 - ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots])  
84 - ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]);  
85 - if (!empty($this->brand_name)) {  
86 - $query->andFilterWhere(['ilike', 'name', $this->brand_name]);  
87 - }  
88 -  
89 $query->orderBy(['brand_id' => SORT_ASC]); 75 $query->orderBy(['brand_id' => SORT_ASC]);
90 76
91 return $dataProvider; 77 return $dataProvider;
@@ -119,15 +105,4 @@ class BrandSearch extends Brand @@ -119,15 +105,4 @@ class BrandSearch extends Brand
119 105
120 return $query; 106 return $query;
121 } 107 }
122 -  
123 - public static function findByAlias($alias) {  
124 - /** @var CategoryQuery $query */  
125 - $query = Brand::find()  
126 - ->andFilterWhere(['alias' => $alias]);  
127 - if (($model = $query->one()) !== null) {  
128 - return $model;  
129 - } else {  
130 - throw new NotFoundHttpException('The requested page does not exist.');  
131 - }  
132 - }  
133 } 108 }
common/modules/product/models/Category.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\modules\product\models; 3 namespace common\modules\product\models;
4 4
  5 + use common\behaviors\SaveImgBehavior;
5 use common\components\artboxtree\ArtboxTreeBehavior; 6 use common\components\artboxtree\ArtboxTreeBehavior;
6 use common\components\artboxtree\ArtboxTreeHelper; 7 use common\components\artboxtree\ArtboxTreeHelper;
7 use common\modules\language\behaviors\LanguageBehavior; 8 use common\modules\language\behaviors\LanguageBehavior;
@@ -20,13 +21,7 @@ @@ -20,13 +21,7 @@
20 * @property string $path 21 * @property string $path
21 * @property integer $depth 22 * @property integer $depth
22 * @property string $image 23 * @property string $image
23 - * @property string $meta_title  
24 - * @property string $meta_desc  
25 - * @property string $meta_robots  
26 - * @property string $seo_text  
27 * @property integer $product_unit_id 24 * @property integer $product_unit_id
28 - * @property string $alias  
29 - * @property boolean $name  
30 * * From language behavior * 25 * * From language behavior *
31 * @property CategoryLang $lang 26 * @property CategoryLang $lang
32 * @property CategoryLang[] $langs 27 * @property CategoryLang[] $langs
@@ -51,8 +46,6 @@ @@ -51,8 +46,6 @@
51 class Category extends \yii\db\ActiveRecord 46 class Category extends \yii\db\ActiveRecord
52 { 47 {
53 48
54 - public $imageUpload;  
55 -  
56 public function behaviors() 49 public function behaviors()
57 { 50 {
58 return [ 51 return [
@@ -61,15 +54,18 @@ @@ -61,15 +54,18 @@
61 'keyNameGroup' => NULL, 54 'keyNameGroup' => NULL,
62 'keyNamePath' => 'path', 55 'keyNamePath' => 'path',
63 ], 56 ],
64 - 'slug' => [  
65 - 'class' => 'common\behaviors\Slug',  
66 - 'in_attribute' => 'name',  
67 - 'out_attribute' => 'alias',  
68 - 'translit' => true,  
69 - ],  
70 'language' => [ 57 'language' => [
71 'class' => LanguageBehavior::className(), 58 'class' => LanguageBehavior::className(),
72 ], 59 ],
  60 + [
  61 + 'class' => SaveImgBehavior::className(),
  62 + 'fields' => [
  63 + [
  64 + 'name' => 'image',
  65 + 'directory' => 'brand',
  66 + ],
  67 + ],
  68 + ],
73 ]; 69 ];
74 } 70 }
75 71
@@ -88,10 +84,6 @@ @@ -88,10 +84,6 @@
88 { 84 {
89 return [ 85 return [
90 [ 86 [
91 - [ 'name' ],  
92 - 'string',  
93 - ],  
94 - [  
95 [ 87 [
96 'parent_id', 88 'parent_id',
97 'depth', 89 'depth',
@@ -102,42 +94,9 @@ @@ -102,42 +94,9 @@
102 [ 94 [
103 [ 95 [
104 'path', 96 'path',
105 - 'meta_desc',  
106 - 'h1',  
107 - 'seo_text',  
108 ], 97 ],
109 'string', 98 'string',
110 ], 99 ],
111 - [  
112 - [  
113 - 'meta_title',  
114 - 'image',  
115 - ],  
116 - 'string',  
117 - 'max' => 255,  
118 - ],  
119 - [  
120 - [ 'meta_robots' ],  
121 - 'string',  
122 - 'max' => 50,  
123 - ],  
124 - [  
125 - [  
126 - 'alias',  
127 - 'name',  
128 - ],  
129 - 'string',  
130 - 'max' => 250,  
131 - ],  
132 - [  
133 - [ 'imageUpload' ],  
134 - 'safe',  
135 - ],  
136 - [  
137 - [ 'imageUpload' ],  
138 - 'file',  
139 - 'extensions' => 'jpg, gif, png',  
140 - ],  
141 ]; 100 ];
142 } 101 }
143 102
@@ -153,14 +112,7 @@ @@ -153,14 +112,7 @@
153 'depth' => Yii::t('product', 'Depth'), 112 'depth' => Yii::t('product', 'Depth'),
154 'image' => Yii::t('product', 'Image'), 113 'image' => Yii::t('product', 'Image'),
155 'imageUrl' => Yii::t('product', 'Image'), 114 'imageUrl' => Yii::t('product', 'Image'),
156 - 'meta_title' => Yii::t('product', 'Meta Title'),  
157 - 'meta_desc' => Yii::t('product', 'Meta Desc'),  
158 - 'meta_robots' => Yii::t('product', 'Meta Robots'),  
159 - 'h1' => Yii::t('product', 'h1'),  
160 - 'seo_text' => Yii::t('product', 'Seo Text'),  
161 'product_unit_id' => Yii::t('product', 'Product Unit ID'), 115 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
162 - 'alias' => Yii::t('product', 'Alias'),  
163 - 'name' => Yii::t('product', 'Name'),  
164 'remote_id' => Yii::t('product', 'Remote ID'), 116 'remote_id' => Yii::t('product', 'Remote ID'),
165 ]; 117 ];
166 } 118 }
@@ -220,16 +172,6 @@ @@ -220,16 +172,6 @@
220 } 172 }
221 } 173 }
222 174
223 - public function getImageFile()  
224 - {  
225 - return empty( $this->image ) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/' . $this->image);  
226 - }  
227 -  
228 - public function getImageUrl()  
229 - {  
230 - return empty( $this->image ) ? '/images/no_photo.png' : Yii::getAlias('@imagesUrl/categories/' . $this->image);  
231 - }  
232 -  
233 public function beforeSave($insert) 175 public function beforeSave($insert)
234 { 176 {
235 if(parent::beforeSave($insert)) { 177 if(parent::beforeSave($insert)) {
common/modules/product/models/CategoryLang.php
@@ -38,6 +38,18 @@ class CategoryLang extends \yii\db\ActiveRecord @@ -38,6 +38,18 @@ class CategoryLang extends \yii\db\ActiveRecord
38 return 'category_lang'; 38 return 'category_lang';
39 } 39 }
40 40
  41 + public function behaviors()
  42 + {
  43 + return [
  44 + 'slug' => [
  45 + 'class' => 'common\behaviors\Slug',
  46 + 'in_attribute' => 'name',
  47 + 'out_attribute' => 'alias',
  48 + 'translit' => true,
  49 + ],
  50 + ];
  51 + }
  52 +
41 /** 53 /**
42 * @inheritdoc 54 * @inheritdoc
43 */ 55 */
common/modules/product/models/CategorySearch.php
@@ -5,7 +5,6 @@ namespace common\modules\product\models; @@ -5,7 +5,6 @@ namespace common\modules\product\models;
5 use common\components\artboxtree\ArtboxTreeHelper; 5 use common\components\artboxtree\ArtboxTreeHelper;
6 use yii\base\Model; 6 use yii\base\Model;
7 use yii\data\ActiveDataProvider; 7 use yii\data\ActiveDataProvider;
8 -use yii\web\NotFoundHttpException;  
9 8
10 /** 9 /**
11 * CategorySearch represents the model behind the search form about `common\modules\product\models\Category`. 10 * CategorySearch represents the model behind the search form about `common\modules\product\models\Category`.
@@ -24,7 +23,6 @@ class CategorySearch extends Category @@ -24,7 +23,6 @@ class CategorySearch extends Category
24 { 23 {
25 return [ 24 return [
26 [['category_id', 'parent_id', 'depth', 'product_unit_id'], 'integer'], 25 [['category_id', 'parent_id', 'depth', 'product_unit_id'], 'integer'],
27 - [['path', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'alias'], 'safe'],  
28 ]; 26 ];
29 } 27 }
30 28
@@ -68,25 +66,12 @@ class CategorySearch extends Category @@ -68,25 +66,12 @@ class CategorySearch extends Category
68 'category.parent_id' => $this->parent_id, 66 'category.parent_id' => $this->parent_id,
69 'category.product_unit_id' => $this->product_unit_id, 67 'category.product_unit_id' => $this->product_unit_id,
70 ]); 68 ]);
71 -  
72 - $query->andFilterWhere(['like', 'category.alias', $this->alias]);  
73 - 69 +
74 $query->orderBy(['category.path' => SORT_ASC, 'category.depth' => SORT_ASC, 'category.category_id' => SORT_ASC]); 70 $query->orderBy(['category.path' => SORT_ASC, 'category.depth' => SORT_ASC, 'category.category_id' => SORT_ASC]);
75 71
76 return $dataProvider; 72 return $dataProvider;
77 } 73 }
78 74
79 - public static function findByAlias($alias) {  
80 - /** @var CategoryQuery $query */  
81 - $query = Category::find()  
82 - ->andFilterWhere(['alias' => $alias]);  
83 - if (($model = $query->one()) !== null) {  
84 - return $model;  
85 - } else {  
86 - throw new NotFoundHttpException('The requested page does not exist.');  
87 - }  
88 - }  
89 -  
90 public static function findByRemoteID($id) { 75 public static function findByRemoteID($id) {
91 /** @var CategoryQuery $query */ 76 /** @var CategoryQuery $query */
92 $query = Category::find() 77 $query = Category::find()
common/modules/product/models/Product.php
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace common\modules\product\models; 3 namespace common\modules\product\models;
4 4
5 - use common\behaviors\Slug;  
6 use common\models\ProductCertificate; 5 use common\models\ProductCertificate;
7 use common\models\ProductSpec; 6 use common\models\ProductSpec;
8 use common\models\ProductToRating; 7 use common\models\ProductToRating;
@@ -19,27 +18,24 @@ @@ -19,27 +18,24 @@
19 18
20 /** 19 /**
21 * This is the model class for table "{{%product}}". 20 * This is the model class for table "{{%product}}".
22 - * @property string $name  
23 * @property integer $brand_id 21 * @property integer $brand_id
24 * @property integer $product_id 22 * @property integer $product_id
25 * @property Category $category 23 * @property Category $category
26 - * @property array $categories  
27 - * @property array of ProductVariant $variants 24 + * @property Category[] $categories
  25 + * @property ProductVariant[] $variants
28 * @property ProductVariant $variant 26 * @property ProductVariant $variant
29 * @property ProductImage $image 27 * @property ProductImage $image
30 - * @property array $images 28 + * @property ProductImage[] $images
31 * @property boolean $is_top 29 * @property boolean $is_top
32 * @property boolean $is_new 30 * @property boolean $is_new
33 * @property boolean $akciya 31 * @property boolean $akciya
34 * @property ProductToRating $averageRating 32 * @property ProductToRating $averageRating
35 * @property array $properties 33 * @property array $properties
36 * @property ProductVariant $enabledVariant 34 * @property ProductVariant $enabledVariant
37 - * @property array $enabledVariants 35 + * @property ProductVariant[] $enabledVariants
38 * @property string $video 36 * @property string $video
39 - * @property string $description  
40 * @property TaxOption[] $options 37 * @property TaxOption[] $options
41 * @property Brand $brand 38 * @property Brand $brand
42 - * @property ProductVariant[] $variants  
43 * @property ProductSpec $productSpec 39 * @property ProductSpec $productSpec
44 * @property ProductCertificate[] $productCertificates 40 * @property ProductCertificate[] $productCertificates
45 * * From language behavior * 41 * * From language behavior *
@@ -80,12 +76,6 @@ @@ -80,12 +76,6 @@
80 [ 76 [
81 'class' => FilterBehavior::className(), 77 'class' => FilterBehavior::className(),
82 ], 78 ],
83 - [  
84 - 'class' => Slug::className(),  
85 - 'in_attribute' => 'name',  
86 - 'out_attribute' => 'alias',  
87 - 'translit' => true,  
88 - ],  
89 'language' => [ 79 'language' => [
90 'class' => LanguageBehavior::className(), 80 'class' => LanguageBehavior::className(),
91 ], 81 ],
@@ -111,16 +101,6 @@ @@ -111,16 +101,6 @@
111 'integer', 101 'integer',
112 ], 102 ],
113 [ 103 [
114 - [ 'name' ],  
115 - 'string',  
116 - 'max' => 150,  
117 - ],  
118 - [  
119 - [ 'alias' ],  
120 - 'string',  
121 - 'max' => 250,  
122 - ],  
123 - [  
124 [ 104 [
125 'categories', 105 'categories',
126 'variants', 106 'variants',
@@ -132,7 +112,6 @@ @@ -132,7 +112,6 @@
132 ], 112 ],
133 [ 113 [
134 [ 114 [
135 - 'description',  
136 'video', 115 'video',
137 ], 116 ],
138 'safe', 117 'safe',
@@ -154,29 +133,22 @@ @@ -154,29 +133,22 @@
154 public function attributeLabels() 133 public function attributeLabels()
155 { 134 {
156 return [ 135 return [
157 - 'product_id' => Yii::t('product', 'ID'),  
158 - 'name' => Yii::t('product', 'Name'),  
159 - 'brand_id' => Yii::t('product', 'Brand'),  
160 - 'categories' => Yii::t('product', 'Categories'), 136 + 'product_id' => Yii::t('product', 'ID'),
  137 + 'brand_id' => Yii::t('product', 'Brand'),
  138 + 'categories' => Yii::t('product', 'Categories'),
161 // relation behavior field 139 // relation behavior field
162 - 'category' => Yii::t('product', 'Category'), 140 + 'category' => Yii::t('product', 'Category'),
163 // relation behavior field 141 // relation behavior field
164 - 'image' => Yii::t('product', 'Image'),  
165 - 'images' => Yii::t('product', 'Images'),  
166 - 'description' => Yii::t('product', 'Description'),  
167 - 'video' => Yii::t('product', 'Video embeded'),  
168 - 'variants' => Yii::t('product', 'Variants'),  
169 - 'is_top' => Yii::t('product', 'Is top'),  
170 - 'is_new' => Yii::t('product', 'Is new'),  
171 - 'akciya' => Yii::t('product', 'Is promo'), 142 + 'image' => Yii::t('product', 'Image'),
  143 + 'images' => Yii::t('product', 'Images'),
  144 + 'video' => Yii::t('product', 'Video embeded'),
  145 + 'variants' => Yii::t('product', 'Variants'),
  146 + 'is_top' => Yii::t('product', 'Is top'),
  147 + 'is_new' => Yii::t('product', 'Is new'),
  148 + 'akciya' => Yii::t('product', 'Is promo'),
172 ]; 149 ];
173 } 150 }
174 151
175 - public function getUrl()  
176 - {  
177 - return '/product/' . $this->alias;  
178 - }  
179 -  
180 /** 152 /**
181 * @return \yii\db\ActiveQuery 153 * @return \yii\db\ActiveQuery
182 */ 154 */
@@ -269,7 +241,7 @@ @@ -269,7 +241,7 @@
269 241
270 public function getFullName() 242 public function getFullName()
271 { 243 {
272 - return empty( $this->brand ) ? $this->name : $this->brand->name . ' ' . $this->name; 244 + return empty( $this->brand ) ? $this->lang->name : $this->brand->lang->name . ' ' . $this->lang->name;
273 } 245 }
274 246
275 public function getCategories() 247 public function getCategories()
@@ -288,7 +260,7 @@ @@ -288,7 +260,7 @@
288 { 260 {
289 $result = []; 261 $result = [];
290 foreach($this->categories as $category) { 262 foreach($this->categories as $category) {
291 - $result[] = $category->name; 263 + $result[] = $category->lang->name;
292 } 264 }
293 return $result; 265 return $result;
294 } 266 }
common/modules/product/models/ProductLang.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\modules\product\models; 3 namespace common\modules\product\models;
4 4
  5 +use common\behaviors\Slug;
5 use common\modules\language\models\Language; 6 use common\modules\language\models\Language;
6 use Yii; 7 use Yii;
7 8
@@ -12,6 +13,7 @@ use Yii; @@ -12,6 +13,7 @@ use Yii;
12 * @property integer $language_id 13 * @property integer $language_id
13 * @property string $name 14 * @property string $name
14 * @property string $description 15 * @property string $description
  16 + * @property string $alias
15 * 17 *
16 * @property Language $language 18 * @property Language $language
17 * @property Product $product 19 * @property Product $product
@@ -35,6 +37,18 @@ class ProductLang extends \yii\db\ActiveRecord @@ -35,6 +37,18 @@ class ProductLang extends \yii\db\ActiveRecord
35 return 'product_lang'; 37 return 'product_lang';
36 } 38 }
37 39
  40 + public function behaviors()
  41 + {
  42 + return [
  43 + 'slug' => [
  44 + 'class' => 'common\behaviors\Slug',
  45 + 'in_attribute' => 'name',
  46 + 'out_attribute' => 'alias',
  47 + 'translit' => true,
  48 + ],
  49 + ];
  50 + }
  51 +
38 /** 52 /**
39 * @inheritdoc 53 * @inheritdoc
40 */ 54 */
@@ -43,7 +57,7 @@ class ProductLang extends \yii\db\ActiveRecord @@ -43,7 +57,7 @@ class ProductLang extends \yii\db\ActiveRecord
43 return [ 57 return [
44 [['name'], 'required'], 58 [['name'], 'required'],
45 [['description'], 'string'], 59 [['description'], 'string'],
46 - [['name'], 'string', 'max' => 255], 60 + [['name', 'alias'], 'string', 'max' => 255],
47 [['product_id', 'language_id'], 'unique', 'targetAttribute' => ['product_id', 'language_id'], 'message' => 'The combination of Product ID and Language ID has already been taken.'], 61 [['product_id', 'language_id'], 'unique', 'targetAttribute' => ['product_id', 'language_id'], 'message' => 'The combination of Product ID and Language ID has already been taken.'],
48 [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], 62 [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
49 [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], 63 [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']],
@@ -60,6 +74,7 @@ class ProductLang extends \yii\db\ActiveRecord @@ -60,6 +74,7 @@ class ProductLang extends \yii\db\ActiveRecord
60 'language_id' => Yii::t('app', 'Language ID'), 74 'language_id' => Yii::t('app', 'Language ID'),
61 'name' => Yii::t('app', 'Name'), 75 'name' => Yii::t('app', 'Name'),
62 'description' => Yii::t('app', 'Description'), 76 'description' => Yii::t('app', 'Description'),
  77 + 'alias' => Yii::t('app', 'Alias'),
63 ]; 78 ];
64 } 79 }
65 80
common/modules/product/models/ProductSearch.php
@@ -4,8 +4,6 @@ namespace common\modules\product\models; @@ -4,8 +4,6 @@ namespace common\modules\product\models;
4 4
5 use yii\base\Model; 5 use yii\base\Model;
6 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
7 -use yii\db\ActiveQuery;  
8 -use yii\web\NotFoundHttpException;  
9 7
10 /** 8 /**
11 * ProductSearch represents the model behind the search form about `common\modules\product\models\Product`. 9 * ProductSearch represents the model behind the search form about `common\modules\product\models\Product`.
@@ -33,7 +31,7 @@ class ProductSearch extends Product @@ -33,7 +31,7 @@ class ProductSearch extends Product
33 public function rules() 31 public function rules()
34 { 32 {
35 return [ 33 return [
36 - [['name', 'brand_name', 'brand_id', 'category_id', 'category_name', 'variant_sku'], 'safe'], 34 + [['brand_name', 'brand_id', 'category_id', 'category_name', 'variant_sku'], 'safe'],
37 [['brand_id', 'product_id'], 'integer'], 35 [['brand_id', 'product_id'], 'integer'],
38 [['is_top', 'is_new', 'akciya'], 'boolean'], 36 [['is_top', 'is_new', 'akciya'], 'boolean'],
39 ]; 37 ];
@@ -60,7 +58,7 @@ class ProductSearch extends Product @@ -60,7 +58,7 @@ class ProductSearch extends Product
60 58
61 $query = Product::find(); 59 $query = Product::find();
62 60
63 - $query->joinWith(['brand', 'categories', 'variant']); 61 +// $query->joinWith(['brand', 'categories', 'variant']);
64 62
65 $query->groupBy(['product.product_id']); 63 $query->groupBy(['product.product_id']);
66 64
@@ -72,19 +70,18 @@ class ProductSearch extends Product @@ -72,19 +70,18 @@ class ProductSearch extends Product
72 return $dataProvider; 70 return $dataProvider;
73 } 71 }
74 72
75 - $dataProvider->setSort([  
76 - 'attributes' => [  
77 - 'name',  
78 - 'brand_name' => [  
79 - 'asc' => ['brand.name' => SORT_ASC],  
80 - 'desc' => ['brand.name' => SORT_DESC],  
81 - 'default' => SORT_DESC,  
82 - 'label' => 'Brand name',  
83 - ],  
84 - 'category_name',  
85 - 'variant_sku',  
86 - ]  
87 - ]); 73 +// $dataProvider->setSort([
  74 +// 'attributes' => [
  75 +// 'brand_name' => [
  76 +// 'asc' => ['brand.name' => SORT_ASC],
  77 +// 'desc' => ['brand.name' => SORT_DESC],
  78 +// 'default' => SORT_DESC,
  79 +// 'label' => 'Brand name',
  80 +// ],
  81 +// 'category_name',
  82 +// 'variant_sku',
  83 +// ]
  84 +// ]);
88 85
89 if (isset($this->is_top)) { 86 if (isset($this->is_top)) {
90 $query->andFilterWhere([ 87 $query->andFilterWhere([
@@ -104,28 +101,16 @@ class ProductSearch extends Product @@ -104,28 +101,16 @@ class ProductSearch extends Product
104 $query->andFilterWhere([ 101 $query->andFilterWhere([
105 'product.brand_id' => $this->brand_id, 102 'product.brand_id' => $this->brand_id,
106 'product.product_id' => $this->product_id, 103 'product.product_id' => $this->product_id,
107 - 'product_category.category_id' => $this->category_id 104 +// 'product_category.category_id' => $this->category_id
108 ]); 105 ]);
109 106
110 - $query->andFilterWhere(['ilike', 'product.name', $this->name]);  
111 - $query->andFilterWhere(['ilike', 'brand.name', $this->brand_name]);  
112 - $query->andFilterWhere(['ilike', 'category.name', $this->category_name]);  
113 - $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]); 107 +// $query->andFilterWhere(['ilike', 'brand.name', $this->brand_name]);
  108 +// $query->andFilterWhere(['ilike', 'category.name', $this->category_name]);
  109 +// $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]);
114 110
115 return $dataProvider; 111 return $dataProvider;
116 } 112 }
117 113
118 - public static function findByAlias($alias) {  
119 - /** @var ActiveQuery $query */  
120 - $query = Product::find();  
121 - $query->andFilterWhere(['alias' => $alias]);  
122 - if (($model = $query->one()) !== null) {  
123 - return $model;  
124 - } else {  
125 - throw new NotFoundHttpException('The requested product does not exist.');  
126 - }  
127 - }  
128 -  
129 public static function findByRemoteID($id) { 114 public static function findByRemoteID($id) {
130 /** @var CategoryQuery $query */ 115 /** @var CategoryQuery $query */
131 $query = Product::find() 116 $query = Product::find()
common/modules/product/models/ProductUnit.php
@@ -12,8 +12,6 @@ use yii\web\Request; @@ -12,8 +12,6 @@ use yii\web\Request;
12 * This is the model class for table "product_unit". 12 * This is the model class for table "product_unit".
13 * 13 *
14 * @property integer $product_unit_id 14 * @property integer $product_unit_id
15 - * @property string $name  
16 - * @property string $code  
17 * @property boolean $is_default 15 * @property boolean $is_default
18 * 16 *
19 * @property Category[] $categories 17 * @property Category[] $categories
@@ -62,10 +60,7 @@ class ProductUnit extends \yii\db\ActiveRecord @@ -62,10 +60,7 @@ class ProductUnit extends \yii\db\ActiveRecord
62 public function rules() 60 public function rules()
63 { 61 {
64 return [ 62 return [
65 - [['name', 'code'], 'required'],  
66 [['is_default'], 'boolean'], 63 [['is_default'], 'boolean'],
67 - [['name'], 'string', 'max' => 255],  
68 - [['code'], 'string', 'max' => 50],  
69 ]; 64 ];
70 } 65 }
71 66
@@ -76,8 +71,6 @@ class ProductUnit extends \yii\db\ActiveRecord @@ -76,8 +71,6 @@ class ProductUnit extends \yii\db\ActiveRecord
76 { 71 {
77 return [ 72 return [
78 'product_unit_id' => Yii::t('product', 'Product Unit ID'), 73 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
79 - 'name' => Yii::t('product', 'Name'),  
80 - 'code' => Yii::t('product', 'Code'),  
81 'is_default' => Yii::t('product', 'Is Default'), 74 'is_default' => Yii::t('product', 'Is Default'),
82 ]; 75 ];
83 } 76 }
common/modules/product/models/ProductUnitSearch.php
@@ -23,7 +23,6 @@ class ProductUnitSearch extends ProductUnit @@ -23,7 +23,6 @@ class ProductUnitSearch extends ProductUnit
23 { 23 {
24 return [ 24 return [
25 [['product_unit_id'], 'integer'], 25 [['product_unit_id'], 'integer'],
26 - [['name', 'code'], 'safe'],  
27 [['is_default'], 'boolean'], 26 [['is_default'], 'boolean'],
28 ]; 27 ];
29 } 28 }
@@ -68,9 +67,6 @@ class ProductUnitSearch extends ProductUnit @@ -68,9 +67,6 @@ class ProductUnitSearch extends ProductUnit
68 'is_default' => $this->is_default, 67 'is_default' => $this->is_default,
69 ]); 68 ]);
70 69
71 - $query->andFilterWhere(['like', 'name', $this->name])  
72 - ->andFilterWhere(['like', 'code', $this->code]);  
73 -  
74 return $dataProvider; 70 return $dataProvider;
75 } 71 }
76 } 72 }
common/modules/product/models/ProductVariant.php
@@ -15,7 +15,6 @@ @@ -15,7 +15,6 @@
15 * This is the model class for table "product_variant". 15 * This is the model class for table "product_variant".
16 * @property integer $product_variant_id 16 * @property integer $product_variant_id
17 * @property integer $product_id 17 * @property integer $product_id
18 - * @property string $name  
19 * @property string $remote_id 18 * @property string $remote_id
20 * @property string $sku 19 * @property string $sku
21 * @property double $price 20 * @property double $price
@@ -26,6 +25,7 @@ @@ -26,6 +25,7 @@
26 * @property array $images 25 * @property array $images
27 * @property TaxOption[] $options 26 * @property TaxOption[] $options
28 * @property ProductUnit $productUnit 27 * @property ProductUnit $productUnit
  28 + * @property Product $product
29 * * From language behavior * 29 * * From language behavior *
30 * @property ProductVariantLang $lang 30 * @property ProductVariantLang $lang
31 * @property ProductVariantLang[] $langs 31 * @property ProductVariantLang[] $langs
@@ -47,20 +47,10 @@ @@ -47,20 +47,10 @@
47 class ProductVariant extends \yii\db\ActiveRecord 47 class ProductVariant extends \yii\db\ActiveRecord
48 { 48 {
49 49
50 - /**just for rukzachok**/  
51 - public $count;  
52 -  
53 public $sum_cost; 50 public $sum_cost;
54 51
55 public $product_name; 52 public $product_name;
56 53
57 - //public $image;  
58 - public $translit;  
59 -  
60 - public $translit_rubric;  
61 -  
62 - private $data;  
63 -  
64 /** @var array $_images */ 54 /** @var array $_images */
65 public $imagesUpload = ''; 55 public $imagesUpload = '';
66 56
@@ -111,7 +101,6 @@ @@ -111,7 +101,6 @@
111 ], 101 ],
112 [ 102 [
113 [ 103 [
114 - 'name',  
115 'sku', 104 'sku',
116 ], 105 ],
117 'string', 106 'string',
@@ -147,7 +136,6 @@ @@ -147,7 +136,6 @@
147 return [ 136 return [
148 'product_variant_id' => Yii::t('product', 'Product Variant ID'), 137 'product_variant_id' => Yii::t('product', 'Product Variant ID'),
149 'product_id' => Yii::t('product', 'Product ID'), 138 'product_id' => Yii::t('product', 'Product ID'),
150 - 'name' => Yii::t('product', 'Name'),  
151 'sku' => Yii::t('product', 'Sku'), 139 'sku' => Yii::t('product', 'Sku'),
152 'price' => Yii::t('product', 'Price'), 140 'price' => Yii::t('product', 'Price'),
153 'price_old' => Yii::t('product', 'Price Old'), 141 'price_old' => Yii::t('product', 'Price Old'),
@@ -234,7 +222,7 @@ @@ -234,7 +222,7 @@
234 222
235 public function getFullname() 223 public function getFullname()
236 { 224 {
237 - return empty( $this->product ) ? NULL : ( $this->product->name . ( empty( $this->name ) ? '' : ' ' . $this->name ) ); 225 + return empty( $this->product ) ? NULL : ( $this->product->lang->name . ( empty( $this->lang->name ) ? '' : ' ' . $this->lang->name ) );
238 } 226 }
239 227
240 public function getImagesHTML() 228 public function getImagesHTML()
common/modules/product/models/ProductVariantListSearch.php
1 <?php 1 <?php
2 -  
3 -namespace common\modules\product\models;  
4 -  
5 -use yii\base\Model;  
6 -use yii\data\ActiveDataProvider;  
7 -  
8 -/**  
9 - * ProductVariantSearch represents the model behind the search form about `backend\models\ProductVariant`.  
10 - */  
11 -class ProductVariantListSearch extends ProductVariant  
12 -{  
13 - public function behaviors()  
14 - {  
15 - return [];  
16 - } 2 +
  3 + namespace common\modules\product\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
17 7
18 /** 8 /**
19 - * @inheritdoc  
20 - */  
21 - public function rules()  
22 - {  
23 - return [  
24 - [['product_variant_id', 'product_id', 'product_unit_id'], 'integer'],  
25 - [['name', 'sku', 'remote_id'], 'safe'],  
26 - [['price', 'price_old', 'stock'], 'number'],  
27 - ];  
28 - }  
29 -  
30 - /**  
31 - * @inheritdoc  
32 - */  
33 - public function scenarios()  
34 - {  
35 - // bypass scenarios() implementation in the parent class  
36 - return Model::scenarios();  
37 - }  
38 -  
39 - /**  
40 - * Creates data provider instance with search query applied  
41 - *  
42 - * @param array $params  
43 - *  
44 - * @return ActiveDataProvider 9 + * ProductVariantSearch represents the model behind the search form about
  10 + * `backend\models\ProductVariant`.
45 */ 11 */
46 - public function search($params, $product_id = false) 12 + class ProductVariantListSearch extends ProductVariant
47 { 13 {
48 - $query = ProductVariant::find();  
49 -  
50 - // add conditions that should always apply here  
51 -  
52 - $dataProvider = new ActiveDataProvider([  
53 - 'query' => $query,  
54 - ]);  
55 -  
56 - $this->load($params);  
57 -  
58 - if (!$this->validate()) {  
59 - // uncomment the following line if you do not want to return any records when validation fails  
60 - // $query->where('0=1');  
61 - return $dataProvider; 14 +
  15 + public function behaviors()
  16 + {
  17 + return [];
  18 + }
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function rules()
  24 + {
  25 + return [
  26 + [
  27 + [
  28 + 'product_variant_id',
  29 + 'product_id',
  30 + 'product_unit_id',
  31 + ],
  32 + 'integer',
  33 + ],
  34 + [
  35 + [
  36 + 'sku',
  37 + 'remote_id',
  38 + ],
  39 + 'safe',
  40 + ],
  41 + [
  42 + [
  43 + 'price',
  44 + 'price_old',
  45 + 'stock',
  46 + ],
  47 + 'number',
  48 + ],
  49 + ];
62 } 50 }
63 -  
64 - if($product_id){ 51 +
  52 + /**
  53 + * @inheritdoc
  54 + */
  55 + public function scenarios()
  56 + {
  57 + // bypass scenarios() implementation in the parent class
  58 + return Model::scenarios();
  59 + }
  60 +
  61 + /**
  62 + * Creates data provider instance with search query applied
  63 + *
  64 + * @param array $params
  65 + *
  66 + * @return ActiveDataProvider
  67 + */
  68 + public function search($params, $product_id = false)
  69 + {
  70 + $query = ProductVariant::find();
  71 +
  72 + // add conditions that should always apply here
  73 +
  74 + $dataProvider = new ActiveDataProvider([
  75 + 'query' => $query,
  76 + ]);
  77 +
  78 + $this->load($params);
  79 +
  80 + if(!$this->validate()) {
  81 + // uncomment the following line if you do not want to return any records when validation fails
  82 + // $query->where('0=1');
  83 + return $dataProvider;
  84 + }
  85 +
  86 + if($product_id) {
  87 + $query->andFilterWhere([
  88 + 'product_id' => $product_id,
  89 + ]);
  90 + }
  91 +
  92 + // grid filtering conditions
65 $query->andFilterWhere([ 93 $query->andFilterWhere([
66 - 'product_id' => $product_id, 94 + 'product_variant_id' => $this->product_variant_id,
  95 + 'price' => $this->price,
  96 + 'price_old' => $this->price_old,
  97 + 'stock' => $this->stock,
  98 + 'product_unit_id' => $this->product_unit_id,
67 ]); 99 ]);
  100 +
  101 + $query->andFilterWhere([
  102 + 'like',
  103 + 'sku',
  104 + $this->sku,
  105 + ])
  106 + ->andFilterWhere([
  107 + 'like',
  108 + 'remote_id',
  109 + $this->remote_id,
  110 + ]);
  111 +
  112 + return $dataProvider;
68 } 113 }
69 -  
70 - // grid filtering conditions  
71 - $query->andFilterWhere([  
72 - 'product_variant_id' => $this->product_variant_id,  
73 - 'price' => $this->price,  
74 - 'price_old' => $this->price_old,  
75 - 'stock' => $this->stock,  
76 - 'product_unit_id' => $this->product_unit_id,  
77 - ]);  
78 -  
79 - $query->andFilterWhere(['like', 'name', $this->name])  
80 - ->andFilterWhere(['like', 'sku', $this->sku])  
81 - ->andFilterWhere(['like', 'remote_id', $this->remote_id]);  
82 -  
83 - return $dataProvider;  
84 } 114 }
85 -}  
common/modules/product/views/manage/_form.php
@@ -29,9 +29,6 @@ @@ -29,9 +29,6 @@
29 'options' => [ 'enctype' => 'multipart/form-data' ], 29 'options' => [ 'enctype' => 'multipart/form-data' ],
30 ]); ?> 30 ]); ?>
31 31
32 - <?= $form->field($model, 'name')  
33 - ->textInput([ 'maxlength' => true ]) ?>  
34 -  
35 <?= $form->field($model, 'is_top') 32 <?= $form->field($model, 'is_top')
36 ->checkbox([ 'label' => 'ТОП' ]) ?> 33 ->checkbox([ 'label' => 'ТОП' ]) ?>
37 <?= $form->field($model, 'is_new') 34 <?= $form->field($model, 'is_new')
@@ -39,25 +36,18 @@ @@ -39,25 +36,18 @@
39 <?= $form->field($model, 'akciya') 36 <?= $form->field($model, 'akciya')
40 ->checkbox([ 'label' => 'Акционный' ]) ?> 37 ->checkbox([ 'label' => 'Акционный' ]) ?>
41 38
42 - <?= $form->field($model, 'description')  
43 - ->widget(\mihaildev\ckeditor\CKEditor::className(), [  
44 - 'editorOptions' => [  
45 - 'preset' => 'full',  
46 - 'inline' => false,  
47 - ],  
48 - ]); ?>  
49 <?= $form->field($model, 'video') 39 <?= $form->field($model, 'video')
50 ->textarea(); ?> 40 ->textarea(); ?>
51 41
52 <?= $form->field($model, 'brand_id') 42 <?= $form->field($model, 'brand_id')
53 ->dropDownList(ArrayHelper::map(ProductHelper::getBrands() 43 ->dropDownList(ArrayHelper::map(ProductHelper::getBrands()
54 - ->all(), 'brand_id', 'name'), [ 44 + ->all(), 'brand_id', 'brand_id'), [
55 'prompt' => Yii::t('product', 'Select brand'), 45 'prompt' => Yii::t('product', 'Select brand'),
56 ]) ?> 46 ]) ?>
57 47
58 <?= $form->field($model, 'categories') 48 <?= $form->field($model, 'categories')
59 ->widget(Select2::className(), [ 49 ->widget(Select2::className(), [
60 - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), 50 + 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'),
61 'language' => 'ru', 51 'language' => 'ru',
62 'options' => [ 52 'options' => [
63 'placeholder' => Yii::t('product', 'Select categories'), 53 'placeholder' => Yii::t('product', 'Select categories'),
@@ -123,25 +113,17 @@ @@ -123,25 +113,17 @@
123 <?php if(isset( $groups )) : ?> 113 <?php if(isset( $groups )) : ?>
124 <?php foreach($groups->all() as $group) : ?> 114 <?php foreach($groups->all() as $group) : ?>
125 <?= $form->field($model, 'options') 115 <?= $form->field($model, 'options')
126 - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ 116 + ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [
127 'multiple' => true, 117 'multiple' => true,
128 'unselect' => NULL, 118 'unselect' => NULL,
129 ]) 119 ])
130 - ->label($group->name); ?> 120 + ->label($group->tax_group_id); ?>
131 <?php endforeach ?> 121 <?php endforeach ?>
132 <?php endif ?> 122 <?php endif ?>
133 123
134 <hr> 124 <hr>
135 125
136 <?php 126 <?php
137 - echo $form->field($product_spec, 'tech_spec_text')  
138 - ->widget(\mihaildev\ckeditor\CKEditor::className(), [  
139 - 'editorOptions' => [  
140 - 'preset' => 'full',  
141 - 'inline' => false,  
142 - ],  
143 - ]);  
144 -  
145 echo $form->field($product_spec, 'techCharFile') 127 echo $form->field($product_spec, 'techCharFile')
146 ->widget(\kartik\file\FileInput::className(), [ 128 ->widget(\kartik\file\FileInput::className(), [
147 'language' => 'ru', 129 'language' => 'ru',
@@ -175,14 +157,6 @@ @@ -175,14 +157,6 @@
175 'previewFileType' => 'image', 157 'previewFileType' => 'image',
176 ], 158 ],
177 ]); 159 ]);
178 -  
179 - echo $form->field($product_spec, 'instruction')  
180 - ->widget(\mihaildev\ckeditor\CKEditor::className(), [  
181 - 'editorOptions' => [  
182 - 'preset' => 'full',  
183 - 'inline' => false,  
184 - ],  
185 - ]);  
186 ?> 160 ?>
187 161
188 <?= LanguageForm::widget([ 162 <?= LanguageForm::widget([
common/modules/product/views/manage/_form_language.php
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 ?> 15 ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 16 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
17 ->textInput([ 'maxlength' => true ]); ?> 17 ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  19 + ->textInput([ 'maxlength' => true ]); ?>
18 <?= $form->field($model_lang, '[' . $language->language_id . ']description') 20 <?= $form->field($model_lang, '[' . $language->language_id . ']description')
19 ->widget(CKEditor::className(), [ 21 ->widget(CKEditor::className(), [
20 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ 22 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
common/modules/product/views/manage/index.php
@@ -17,7 +17,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -17,7 +17,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
17 <div class="product-index"> 17 <div class="product-index">
18 18
19 <h1><?= Html::encode($this->title) ?></h1> 19 <h1><?= Html::encode($this->title) ?></h1>
20 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
21 20
22 <p> 21 <p>
23 <?= Html::a(Yii::t('product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?> 22 <?= Html::a(Yii::t('product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?>
@@ -27,63 +26,63 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -27,63 +26,63 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
27 'filterModel' => $searchModel, 26 'filterModel' => $searchModel,
28 'columns' => [ 27 'columns' => [
29 ['class' => 'yii\grid\SerialColumn'], 28 ['class' => 'yii\grid\SerialColumn'],
30 - 'name',  
31 - [  
32 - 'label' => Yii::t('product', 'Brand'),  
33 - 'attribute' => 'brand_name',  
34 - 'value' => 'brand.name',  
35 - 'format' => 'raw',  
36 - 'filter' => Select2::widget([  
37 - 'model' => $searchModel,  
38 - 'attribute' => 'brand_id',  
39 - 'data' => ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),  
40 - 'language' => 'ru',  
41 - 'options' => [  
42 - 'placeholder' => Yii::t('product', 'Select brand'),  
43 - 'multiple' => false,  
44 - ],  
45 - 'pluginOptions' => [  
46 - 'allowClear' => true  
47 - ],  
48 - ])  
49 - ],  
50 - [  
51 - 'label' => Yii::t('product', 'Category'),  
52 - 'attribute' => 'category_name',  
53 - 'value' => function($model) {  
54 - $categories = [];  
55 - foreach ($model->categories as $category) {  
56 - $categories[] = $category->name;  
57 - }  
58 - return implode(", ", $categories);  
59 - },  
60 - 'format' => 'raw',  
61 - 'filter' => Select2::widget([  
62 - 'model' => $searchModel,  
63 - 'attribute' => 'category_id',  
64 - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),  
65 - 'language' => 'ru',  
66 - 'options' => [  
67 - 'placeholder' => Yii::t('product', 'Select category'),  
68 - 'multiple' => false,  
69 - ],  
70 - 'pluginOptions' => [  
71 - 'allowClear' => true  
72 - ],  
73 - ])  
74 - ],  
75 - [  
76 - 'label' => Yii::t('product', 'SKU'),  
77 - 'attribute' => 'variant_sku',  
78 - 'value' => 'variant.sku',  
79 - ],  
80 - 'variant.price',  
81 - 'variant.price_old',  
82 - [  
83 - 'label' => Yii::t('product', 'Stock'),  
84 - 'attribute' => 'variant_stock',  
85 - 'value' => 'variant.stock_caption',  
86 - ], 29 + 'product_id',
  30 +// [
  31 +// 'label' => Yii::t('product', 'Brand'),
  32 +// 'attribute' => 'brand_name',
  33 +// 'value' => 'brand.name',
  34 +// 'format' => 'raw',
  35 +// 'filter' => Select2::widget([
  36 +// 'model' => $searchModel,
  37 +// 'attribute' => 'brand_id',
  38 +// 'data' => ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),
  39 +// 'language' => 'ru',
  40 +// 'options' => [
  41 +// 'placeholder' => Yii::t('product', 'Select brand'),
  42 +// 'multiple' => false,
  43 +// ],
  44 +// 'pluginOptions' => [
  45 +// 'allowClear' => true
  46 +// ],
  47 +// ])
  48 +// ],
  49 +// [
  50 +// 'label' => Yii::t('product', 'Category'),
  51 +// 'attribute' => 'category_name',
  52 +// 'value' => function($model) {
  53 +// $categories = [];
  54 +// foreach ($model->categories as $category) {
  55 +// $categories[] = $category->name;
  56 +// }
  57 +// return implode(", ", $categories);
  58 +// },
  59 +// 'format' => 'raw',
  60 +// 'filter' => Select2::widget([
  61 +// 'model' => $searchModel,
  62 +// 'attribute' => 'category_id',
  63 +// 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),
  64 +// 'language' => 'ru',
  65 +// 'options' => [
  66 +// 'placeholder' => Yii::t('product', 'Select category'),
  67 +// 'multiple' => false,
  68 +// ],
  69 +// 'pluginOptions' => [
  70 +// 'allowClear' => true
  71 +// ],
  72 +// ])
  73 +// ],
  74 +// [
  75 +// 'label' => Yii::t('product', 'SKU'),
  76 +// 'attribute' => 'variant_sku',
  77 +// 'value' => 'variant.sku',
  78 +// ],
  79 +// 'variant.price',
  80 +// 'variant.price_old',
  81 +// [
  82 +// 'label' => Yii::t('product', 'Stock'),
  83 +// 'attribute' => 'variant_stock',
  84 +// 'value' => 'variant.stock_caption',
  85 +// ],
87 [ 86 [
88 'class' => 'yii\grid\ActionColumn', 87 'class' => 'yii\grid\ActionColumn',
89 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}', 88 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}',
common/modules/product/views/manage/update.php
@@ -8,22 +8,22 @@ @@ -8,22 +8,22 @@
8 use yii\web\View; 8 use yii\web\View;
9 9
10 /** 10 /**
11 - * @var View $this  
12 - * @var Product $model  
13 - * @var ProductLang[] $model_langs  
14 - * @var ProductSpec $product_spec 11 + * @var View $this
  12 + * @var Product $model
  13 + * @var ProductLang[] $model_langs
  14 + * @var ProductSpec $product_spec
15 * @var ProductSpecLang[] $product_spec_langs 15 * @var ProductSpecLang[] $product_spec_langs
16 */ 16 */
17 17
18 $this->title = Yii::t('product', 'Update {modelClass}: ', [ 18 $this->title = Yii::t('product', 'Update {modelClass}: ', [
19 'modelClass' => 'Product', 19 'modelClass' => 'Product',
20 - ]) . ' ' . $model->name; 20 + ]) . ' ' . $model->product_id;
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 'label' => Yii::t('product', 'Products'), 22 'label' => Yii::t('product', 'Products'),
23 'url' => [ 'index' ], 23 'url' => [ 'index' ],
24 ]; 24 ];
25 $this->params[ 'breadcrumbs' ][] = [ 25 $this->params[ 'breadcrumbs' ][] = [
26 - 'label' => $model->name, 26 + 'label' => $model->product_id,
27 'url' => [ 27 'url' => [
28 'view', 28 'view',
29 'id' => $model->product_id, 29 'id' => $model->product_id,
@@ -36,10 +36,10 @@ @@ -36,10 +36,10 @@
36 <h1><?= Html::encode($this->title) ?></h1> 36 <h1><?= Html::encode($this->title) ?></h1>
37 37
38 <?= $this->render('_form', [ 38 <?= $this->render('_form', [
39 - 'model' => $model,  
40 - 'model_langs' => $model_langs,  
41 - 'groups' => $groups,  
42 - 'product_spec' => $product_spec, 39 + 'model' => $model,
  40 + 'model_langs' => $model_langs,
  41 + 'groups' => $groups,
  42 + 'product_spec' => $product_spec,
43 'product_spec_langs' => $product_spec_langs, 43 'product_spec_langs' => $product_spec_langs,
44 ]) ?> 44 ]) ?>
45 45
common/modules/product/views/manage/view.php
@@ -6,7 +6,7 @@ use yii\widgets\DetailView; @@ -6,7 +6,7 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model common\modules\product\models\Product */ 7 /* @var $model common\modules\product\models\Product */
8 8
9 -$this->title = $model->name; 9 +$this->title = $model->product_id;
10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
@@ -29,10 +29,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -29,10 +29,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
29 'model' => $model, 29 'model' => $model,
30 'attributes' => [ 30 'attributes' => [
31 'product_id', 31 'product_id',
32 - 'name',  
33 - 'fullname',  
34 - 'brand.name',  
35 - 'category.name', 32 +// 'brand.name',
  33 +// 'category.name',
36 'image.imageUrl:image' 34 'image.imageUrl:image'
37 ], 35 ],
38 ]) ?> 36 ]) ?>
common/modules/product/views/product-unit/_form.php
@@ -19,12 +19,6 @@ @@ -19,12 +19,6 @@
19 19
20 <?php $form = ActiveForm::begin(); ?> 20 <?php $form = ActiveForm::begin(); ?>
21 21
22 - <?= $form->field($model, 'name')  
23 - ->textInput([ 'maxlength' => true ]) ?>  
24 -  
25 - <?= $form->field($model, 'code')  
26 - ->textInput([ 'maxlength' => true ]) ?>  
27 -  
28 <?= $form->field($model, 'is_default') 22 <?= $form->field($model, 'is_default')
29 ->checkbox() ?> 23 ->checkbox() ?>
30 24
common/modules/product/views/product-unit/index.php
1 <?php 1 <?php
2 -  
3 -use yii\helpers\Html;  
4 -use yii\grid\GridView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $searchModel common\modules\product\models\ProductUnitSearch */  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('product', 'Product Units');  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\grid\GridView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $searchModel common\modules\product\models\ProductUnitSearch */
  8 + /* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 + $this->title = Yii::t('product', 'Product Units');
  11 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 12 ?>
13 <div class="product-unit-index"> 13 <div class="product-unit-index">
14 - 14 +
15 <h1><?= Html::encode($this->title) ?></h1> 15 <h1><?= Html::encode($this->title) ?></h1>
16 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
17 - 16 +
18 <p> 17 <p>
19 - <?= Html::a(Yii::t('product', 'Create Product Unit'), ['create'], ['class' => 'btn btn-success']) ?> 18 + <?= Html::a(Yii::t('product', 'Create Product Unit'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
20 </p> 19 </p>
21 <?= GridView::widget([ 20 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 21 'dataProvider' => $dataProvider,
23 - 'filterModel' => $searchModel,  
24 - 'columns' => [  
25 - ['class' => 'yii\grid\SerialColumn'],  
26 -  
27 - 'name',  
28 - 'code:html', 22 + 'filterModel' => $searchModel,
  23 + 'columns' => [
  24 + [ 'class' => 'yii\grid\SerialColumn' ],
  25 + 'product_unit_id',
29 'is_default:boolean', 26 'is_default:boolean',
30 -  
31 - ['class' => 'yii\grid\ActionColumn'], 27 + [ 'class' => 'yii\grid\ActionColumn' ],
32 ], 28 ],
33 ]); ?> 29 ]); ?>
34 </div> 30 </div>
common/modules/product/views/product-unit/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('product', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('product', 'Update {modelClass}: ', [
15 'modelClass' => 'Product Unit', 15 'modelClass' => 'Product Unit',
16 - ]) . $model->name; 16 + ]) . $model->product_unit_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('product', 'Product Units'), 18 'label' => Yii::t('product', 'Product Units'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->name, 22 + 'label' => $model->product_unit_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->product_unit_id, 25 'id' => $model->product_unit_id,
common/modules/product/views/product-unit/view.php
1 <?php 1 <?php
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\DetailView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\modules\product\models\ProductUnit */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\modules\product\models\ProductUnit */
  8 +
  9 + $this->title = $model->product_unit_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('product', 'Product Units'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="product-unit-view"> 16 <div class="product-unit-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->product_unit_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->product_unit_id], [ 21 + <?= Html::a(Yii::t('product', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->product_unit_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('product', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->product_unit_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 </p> 35 </p>
27 - 36 +
28 <?= DetailView::widget([ 37 <?= DetailView::widget([
29 - 'model' => $model, 38 + 'model' => $model,
30 'attributes' => [ 39 'attributes' => [
31 'product_unit_id', 40 'product_unit_id',
32 - 'name',  
33 - 'code',  
34 'is_default:boolean', 41 'is_default:boolean',
35 ], 42 ],
36 ]) ?> 43 ]) ?>
common/modules/product/views/variant/_form.php
@@ -21,14 +21,6 @@ @@ -21,14 +21,6 @@
21 */ 21 */
22 22
23 $js = ' 23 $js = '
24 -$(".dynamicform_wrapper").on("beforeInsert", function(e, item) {  
25 - console.log("beforeInsert");  
26 -});  
27 -  
28 -$(".dynamicform_wrapper").on("afterInsert", function(e, item) {  
29 - console.log("afterInsert");  
30 -});  
31 -  
32 $(".dynamicform_wrapper").on("beforeDelete", function(e, item) { 24 $(".dynamicform_wrapper").on("beforeDelete", function(e, item) {
33 if (! confirm("Are you sure you want to delete this item?")) { 25 if (! confirm("Are you sure you want to delete this item?")) {
34 return false; 26 return false;
@@ -36,10 +28,6 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;beforeDelete&quot;, function(e, item) { @@ -36,10 +28,6 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;beforeDelete&quot;, function(e, item) {
36 return true; 28 return true;
37 }); 29 });
38 30
39 -$(".dynamicform_wrapper").on("afterDelete", function(e) {  
40 - console.log("Deleted item!");  
41 -});  
42 -  
43 $(".dynamicform_wrapper").on("limitReached", function(e, item) { 31 $(".dynamicform_wrapper").on("limitReached", function(e, item) {
44 alert("Limit reached"); 32 alert("Limit reached");
45 }); 33 });
@@ -54,9 +42,6 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) { @@ -54,9 +42,6 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) {
54 'options' => [ 'enctype' => 'multipart/form-data' ], 42 'options' => [ 'enctype' => 'multipart/form-data' ],
55 ]); ?> 43 ]); ?>
56 44
57 - <?= $form->field($model, 'name')  
58 - ->textInput([ 'maxlength' => true ]) ?>  
59 -  
60 <?= $form->field($model, 'product_id') 45 <?= $form->field($model, 'product_id')
61 ->hiddenInput() 46 ->hiddenInput()
62 ->label(false); ?> 47 ->label(false); ?>
@@ -161,7 +146,7 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) { @@ -161,7 +146,7 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) {
161 146
162 <?= $form->field($model, 'product_unit_id') 147 <?= $form->field($model, 'product_unit_id')
163 ->dropDownList(ArrayHelper::map(\common\modules\product\models\ProductUnit::find() 148 ->dropDownList(ArrayHelper::map(\common\modules\product\models\ProductUnit::find()
164 - ->all(), 'product_unit_id', 'name'), [ 149 + ->all(), 'product_unit_id', 'product_unit_id'), [
165 'prompt' => Yii::t('product', 'Unit'), 150 'prompt' => Yii::t('product', 'Unit'),
166 ]) 151 ])
167 ->label(Yii::t('product', 'Unit')) ?> 152 ->label(Yii::t('product', 'Unit')) ?>
@@ -169,11 +154,11 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) { @@ -169,11 +154,11 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) {
169 <?php if(isset( $groups )) : ?> 154 <?php if(isset( $groups )) : ?>
170 <?php foreach($groups->all() as $group) : ?> 155 <?php foreach($groups->all() as $group) : ?>
171 <?= $form->field($model, 'options') 156 <?= $form->field($model, 'options')
172 - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ 157 + ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [
173 'multiple' => true, 158 'multiple' => true,
174 'unselect' => NULL, 159 'unselect' => NULL,
175 ]) 160 ])
176 - ->label($group->name); ?> 161 + ->label($group->tax_group_id); ?>
177 <?php endforeach ?> 162 <?php endforeach ?>
178 <?php endif ?> 163 <?php endif ?>
179 164
common/modules/product/views/variant/index.php
@@ -22,7 +22,6 @@ if (!empty($product)) { @@ -22,7 +22,6 @@ if (!empty($product)) {
22 <div class="product-index"> 22 <div class="product-index">
23 23
24 <h1><?= Html::encode($this->title) ?></h1> 24 <h1><?= Html::encode($this->title) ?></h1>
25 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
26 25
27 <p> 26 <p>
28 <?= Html::a(Yii::t('product', 'Create Variant'), Url::toRoute(['create','product_id'=> $product_id]), ['class' => 'btn btn-success']) ?> 27 <?= Html::a(Yii::t('product', 'Create Variant'), Url::toRoute(['create','product_id'=> $product_id]), ['class' => 'btn btn-success']) ?>
@@ -32,7 +31,6 @@ if (!empty($product)) { @@ -32,7 +31,6 @@ if (!empty($product)) {
32 'filterModel' => $searchModel, 31 'filterModel' => $searchModel,
33 'columns' => [ 32 'columns' => [
34 ['class' => 'yii\grid\SerialColumn'], 33 ['class' => 'yii\grid\SerialColumn'],
35 -  
36 [ 34 [
37 'attribute' => 'product_id', 35 'attribute' => 'product_id',
38 'value' => 'fullname', 36 'value' => 'fullname',
@@ -40,7 +38,7 @@ if (!empty($product)) { @@ -40,7 +38,7 @@ if (!empty($product)) {
40 'filter' => \kartik\select2\Select2::widget([ 38 'filter' => \kartik\select2\Select2::widget([
41 'model' => $searchModel, 39 'model' => $searchModel,
42 'attribute' => 'product_id', 40 'attribute' => 'product_id',
43 - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\Product::find()->orderBy(['name' => 'ASC'])->all(), 'product_id', 'name'), 41 +// 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\Product::find()->orderBy(['name' => 'ASC'])->all(), 'product_id', 'name'),
44 'language' => 'ru', 42 'language' => 'ru',
45 'options' => [ 43 'options' => [
46 'placeholder' => Yii::t('product', 'Select product'), 44 'placeholder' => Yii::t('product', 'Select product'),
@@ -55,7 +53,6 @@ if (!empty($product)) { @@ -55,7 +53,6 @@ if (!empty($product)) {
55 'price', 53 'price',
56 'price_old', 54 'price_old',
57 'stock', 55 'stock',
58 -  
59 [ 56 [
60 'class' => 'yii\grid\ActionColumn', 57 'class' => 'yii\grid\ActionColumn',
61 'buttons' => [ 58 'buttons' => [
common/modules/product/views/variant/update.php
@@ -17,13 +17,13 @@ @@ -17,13 +17,13 @@
17 */ 17 */
18 $this->title = Yii::t('product', 'Update {modelClass}: ', [ 18 $this->title = Yii::t('product', 'Update {modelClass}: ', [
19 'modelClass' => 'Product', 19 'modelClass' => 'Product',
20 - ]) . ' ' . $model->name; 20 + ]) . ' ' . $model->product_variant_id;
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 'label' => Yii::t('product', 'Products'), 22 'label' => Yii::t('product', 'Products'),
23 'url' => [ 'index' ], 23 'url' => [ 'index' ],
24 ]; 24 ];
25 $this->params[ 'breadcrumbs' ][] = [ 25 $this->params[ 'breadcrumbs' ][] = [
26 - 'label' => $model->product->name, 26 + 'label' => $model->product->product_id,
27 'url' => [ 27 'url' => [
28 'view', 28 'view',
29 'id' => $model->product->product_id, 29 'id' => $model->product->product_id,
common/modules/product/views/variant/view.php
@@ -4,11 +4,11 @@ use yii\helpers\Html; @@ -4,11 +4,11 @@ use yii\helpers\Html;
4 use yii\widgets\DetailView; 4 use yii\widgets\DetailView;
5 5
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 -/* @var $model common\modules\product\models\Product */ 7 +/* @var $model common\modules\product\models\ProductVariant */
8 8
9 -$this->title = $model->name; 9 +$this->title = $model->product_variant_id;
10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']];
11 -$this->params['breadcrumbs'][] = ['label' => $model->product->name, 'url' => ['view', 'id' => $model->product->product_id]]; 11 +$this->params['breadcrumbs'][] = ['label' => $model->product->lang->name, 'url' => ['view', 'id' => $model->product->product_id]];
12 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => ['/product/variant?product_id='. $model->product->product_id]]; 12 $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => ['/product/variant?product_id='. $model->product->product_id]];
13 $this->params['breadcrumbs'][] = $this->title; 13 $this->params['breadcrumbs'][] = $this->title;
14 ?> 14 ?>
@@ -31,10 +31,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -31,10 +31,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
31 'model' => $model, 31 'model' => $model,
32 'attributes' => [ 32 'attributes' => [
33 'product_id', 33 'product_id',
34 - 'name',  
35 'fullname', 34 'fullname',
36 - 'brand.name',  
37 - 'category.name',  
38 'image.imageUrl:image' 35 'image.imageUrl:image'
39 ], 36 ],
40 ]) ?> 37 ]) ?>
common/modules/rubrication/controllers/TaxOptionController.php
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 use yii\web\Controller; 9 use yii\web\Controller;
10 use yii\web\NotFoundHttpException; 10 use yii\web\NotFoundHttpException;
11 use yii\filters\VerbFilter; 11 use yii\filters\VerbFilter;
12 - use yii\web\UploadedFile;  
13 12
14 /** 13 /**
15 * TaxOptionController implements the CRUD actions for TaxOption model. 14 * TaxOptionController implements the CRUD actions for TaxOption model.
@@ -78,23 +77,8 @@ @@ -78,23 +77,8 @@
78 $model_langs = $model->generateLangs(); 77 $model_langs = $model->generateLangs();
79 $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); 78 $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]);
80 79
81 - if($model->load(Yii::$app->request->post())) { 80 + if($model->load(Yii::$app->request->post()) && $model->save()) {
82 $model->loadLangs(\Yii::$app->request, $model_langs); 81 $model->loadLangs(\Yii::$app->request, $model_langs);
83 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
84 - $model->image = $image->name;  
85 - }  
86 - if($model->save() && $image) {  
87 -  
88 - $imgDir = Yii::getAlias('@storage/tax_option/');  
89 -  
90 - if(!is_dir($imgDir)) {  
91 - mkdir($imgDir, 0755, true);  
92 - }  
93 -  
94 - $image->saveAs(Yii::getAlias('@storage/tax_option/' . $image->name));  
95 - }  
96 -  
97 - $model->save();  
98 82
99 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { 83 if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
100 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ 84 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([
@@ -108,17 +92,16 @@ @@ -108,17 +92,16 @@
108 ]); 92 ]);
109 } 93 }
110 94
111 - } else {  
112 - $model->tax_group_id = $group->tax_group_id;  
113 - if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) {  
114 - $model->parent_id = Yii::$app->request->queryParams[ 'parent' ];  
115 - }  
116 - return $this->render('create', [  
117 - 'model' => $model,  
118 - 'model_langs' => $model_langs,  
119 - 'group' => $group,  
120 - ]);  
121 } 95 }
  96 + $model->tax_group_id = $group->tax_group_id;
  97 + if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) {
  98 + $model->parent_id = Yii::$app->request->queryParams[ 'parent' ];
  99 + }
  100 + return $this->render('create', [
  101 + 'model' => $model,
  102 + 'model_langs' => $model_langs,
  103 + 'group' => $group,
  104 + ]);
122 } 105 }
123 106
124 /** 107 /**
@@ -135,21 +118,8 @@ @@ -135,21 +118,8 @@
135 $model_langs = $model->generateLangs(); 118 $model_langs = $model->generateLangs();
136 $group = TaxGroup::findOne($model->tax_group_id); 119 $group = TaxGroup::findOne($model->tax_group_id);
137 120
138 - if($model->load(Yii::$app->request->post())) { 121 + if($model->load(Yii::$app->request->post()) && $model->save()) {
139 $model->loadLangs(\Yii::$app->request, $model_langs); 122 $model->loadLangs(\Yii::$app->request, $model_langs);
140 - if(( $image = UploadedFile::getInstance($model, 'image') )) {  
141 - $model->image = $image->name;  
142 - }  
143 - if($model->save() && $image) {  
144 -  
145 - $imgDir = Yii::getAlias('@storage/tax_option/');  
146 -  
147 - if(!is_dir($imgDir)) {  
148 - mkdir($imgDir, 0755, true);  
149 - }  
150 -  
151 - $image->saveAs(Yii::getAlias('@storage/tax_option/' . $image->name));  
152 - }  
153 123
154 TaxOption::find() 124 TaxOption::find()
155 ->rebuildMP($model->tax_group_id); 125 ->rebuildMP($model->tax_group_id);
common/modules/rubrication/models/TaxGroup.php
@@ -7,43 +7,39 @@ @@ -7,43 +7,39 @@
7 use yii\db\ActiveQuery; 7 use yii\db\ActiveQuery;
8 use yii\db\ActiveRecord; 8 use yii\db\ActiveRecord;
9 use yii\web\Request; 9 use yii\web\Request;
10 - 10 +
11 /** 11 /**
12 * This is the model class for table "{{%tax_group}}". 12 * This is the model class for table "{{%tax_group}}".
13 - * @property integer $tax_group_id  
14 - * @property string $alias  
15 - * @property string $name  
16 - * @property string $description  
17 - * @property boolean $is_filter  
18 - * @property integer $level  
19 - * @property integer $sort  
20 - * @property boolean $display  
21 - * @property boolean $is_menu  
22 - * @property TaxOption[] $taxOptions  
23 - * @property Category[] $categories  
24 - * @property TaxOption[] $options  
25 - * 13 + * @property integer $tax_group_id
  14 + * @property boolean $is_filter
  15 + * @property integer $level
  16 + * @property integer $sort
  17 + * @property boolean $display
  18 + * @property boolean $is_menu
  19 + * @property TaxOption[] $taxOptions
  20 + * @property Category[] $categories
  21 + * @property TaxOption[] $options
26 * * From language behavior * 22 * * From language behavior *
27 - * @property TaxGroupLang $lang  
28 - * @property TaxGroupLang[] $langs  
29 - * @property TaxGroupLang $object_lang 23 + * @property TaxGroupLang $lang
  24 + * @property TaxGroupLang[] $langs
  25 + * @property TaxGroupLang $object_lang
30 * @property string $ownerKey 26 * @property string $ownerKey
31 * @property string $langKey 27 * @property string $langKey
32 * @method string getOwnerKey() 28 * @method string getOwnerKey()
33 - * @method void setOwnerKey(string $value) 29 + * @method void setOwnerKey( string $value )
34 * @method string getLangKey() 30 * @method string getLangKey()
35 - * @method void setLangKey(string $value) 31 + * @method void setLangKey( string $value )
36 * @method ActiveQuery getLangs() 32 * @method ActiveQuery getLangs()
37 * @method ActiveQuery getLang( integer $language_id ) 33 * @method ActiveQuery getLang( integer $language_id )
38 * @method TaxGroupLang[] generateLangs() 34 * @method TaxGroupLang[] generateLangs()
39 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
40 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
41 - * @method bool saveLangs(ActiveRecord[] $model_langs) 35 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  36 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  37 + * @method bool saveLangs( ActiveRecord[] $model_langs )
42 * * End language behavior * 38 * * End language behavior *
43 */ 39 */
44 class TaxGroup extends \yii\db\ActiveRecord 40 class TaxGroup extends \yii\db\ActiveRecord
45 { 41 {
46 - 42 +
47 /** 43 /**
48 * @var TaxOption[] $_options 44 * @var TaxOption[] $_options
49 */ 45 */
@@ -55,12 +51,6 @@ @@ -55,12 +51,6 @@
55 public function behaviors() 51 public function behaviors()
56 { 52 {
57 return [ 53 return [
58 - 'slug' => [  
59 - 'class' => 'common\behaviors\Slug',  
60 - 'in_attribute' => 'name',  
61 - 'out_attribute' => 'alias',  
62 - 'translit' => true,  
63 - ],  
64 'language' => [ 54 'language' => [
65 'class' => LanguageBehavior::className(), 55 'class' => LanguageBehavior::className(),
66 ], 56 ],
@@ -83,18 +73,6 @@ @@ -83,18 +73,6 @@
83 return [ 73 return [
84 [ 74 [
85 [ 75 [
86 - 'name',  
87 - ],  
88 - 'required',  
89 - ],  
90 - [  
91 - [  
92 - 'description',  
93 - ],  
94 - 'string',  
95 - ],  
96 - [  
97 - [  
98 'is_filter', 76 'is_filter',
99 'display', 77 'display',
100 'is_menu', 78 'is_menu',
@@ -109,18 +87,6 @@ @@ -109,18 +87,6 @@
109 'integer', 87 'integer',
110 ], 88 ],
111 [ 89 [
112 - [  
113 - 'alias',  
114 - ],  
115 - 'string',  
116 - 'max' => 50,  
117 - ],  
118 - [  
119 - [ 'name' ],  
120 - 'string',  
121 - 'max' => 255,  
122 - ],  
123 - [  
124 [ 'categories' ], 90 [ 'categories' ],
125 'safe', 91 'safe',
126 ], 92 ],
@@ -134,9 +100,6 @@ @@ -134,9 +100,6 @@
134 { 100 {
135 return [ 101 return [
136 'tax_group_id' => 'Tax Group ID', 102 'tax_group_id' => 'Tax Group ID',
137 - 'alias' => 'Alias',  
138 - 'name' => 'Name',  
139 - 'description' => 'Description',  
140 'is_filter' => 'Use in filter', 103 'is_filter' => 'Use in filter',
141 'sort' => 'Sort', 104 'sort' => 'Sort',
142 'display' => 'Display', 105 'display' => 'Display',
common/modules/rubrication/models/TaxGroupLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\modules\rubrication\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "tax_group_lang".  
10 - *  
11 - * @property integer $tax_group_id  
12 - * @property integer $language_id  
13 - * @property string $name  
14 - * @property string $description  
15 - *  
16 - * @property Language $language  
17 - * @property TaxGroup $taxGroup  
18 - */  
19 -class TaxGroupLang extends \yii\db\ActiveRecord  
20 -{  
21 2
22 - public static function primaryKey()  
23 - {  
24 - return [  
25 - 'tax_group_id',  
26 - 'language_id',  
27 - ];  
28 - } 3 + namespace common\modules\rubrication\models;
  4 +
  5 + use common\modules\language\models\Language;
  6 + use Yii;
29 7
30 /** 8 /**
31 - * @inheritdoc  
32 - */  
33 - public static function tableName()  
34 - {  
35 - return 'tax_group_lang';  
36 - }  
37 -  
38 - /**  
39 - * @inheritdoc  
40 - */  
41 - public function rules()  
42 - {  
43 - return [  
44 - [['name'], 'required'],  
45 - [['description'], 'string'],  
46 - [['name'], 'string', 'max' => 255],  
47 - [['tax_group_id', 'language_id'], 'unique', 'targetAttribute' => ['tax_group_id', 'language_id'], 'message' => 'The combination of Tax Group ID and Language ID has already been taken.'],  
48 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
49 - [['tax_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxGroup::className(), 'targetAttribute' => ['tax_group_id' => 'tax_group_id']],  
50 - ];  
51 - }  
52 -  
53 - /**  
54 - * @inheritdoc  
55 - */  
56 - public function attributeLabels()  
57 - {  
58 - return [  
59 - 'tax_group_id' => Yii::t('app', 'Tax Group ID'),  
60 - 'language_id' => Yii::t('app', 'Language ID'),  
61 - 'name' => Yii::t('app', 'Name'),  
62 - 'description' => Yii::t('app', 'Description'),  
63 - ];  
64 - }  
65 -  
66 - /**  
67 - * @return \yii\db\ActiveQuery  
68 - */  
69 - public function getLanguage()  
70 - {  
71 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);  
72 - }  
73 -  
74 - /**  
75 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "tax_group_lang".
  10 + * @property integer $tax_group_id
  11 + * @property integer $language_id
  12 + * @property string $name
  13 + * @property string $alias
  14 + * @property string $description
  15 + * @property Language $language
  16 + * @property TaxGroup $taxGroup
76 */ 17 */
77 - public function getTaxGroup() 18 + class TaxGroupLang extends \yii\db\ActiveRecord
78 { 19 {
79 - return $this->hasOne(TaxGroup::className(), ['tax_group_id' => 'tax_group_id']); 20 +
  21 + public static function primaryKey()
  22 + {
  23 + return [
  24 + 'tax_group_id',
  25 + 'language_id',
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return 'tax_group_lang';
  35 + }
  36 +
  37 + public function behaviors()
  38 + {
  39 + return [
  40 + 'slug' => [
  41 + 'class' => 'common\behaviors\Slug',
  42 + 'in_attribute' => 'name',
  43 + 'out_attribute' => 'alias',
  44 + 'translit' => true,
  45 + ],
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * @inheritdoc
  51 + */
  52 + public function rules()
  53 + {
  54 + return [
  55 + [
  56 + [ 'name' ],
  57 + 'required',
  58 + ],
  59 + [
  60 + [ 'description' ],
  61 + 'string',
  62 + ],
  63 + [
  64 + [
  65 + 'name',
  66 + 'alias',
  67 + ],
  68 + 'string',
  69 + 'max' => 255,
  70 + ],
  71 + [
  72 + [
  73 + 'tax_group_id',
  74 + 'language_id',
  75 + ],
  76 + 'unique',
  77 + 'targetAttribute' => [
  78 + 'tax_group_id',
  79 + 'language_id',
  80 + ],
  81 + 'message' => 'The combination of Tax Group ID and Language ID has already been taken.',
  82 + ],
  83 + [
  84 + [ 'language_id' ],
  85 + 'exist',
  86 + 'skipOnError' => true,
  87 + 'targetClass' => Language::className(),
  88 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  89 + ],
  90 + [
  91 + [ 'tax_group_id' ],
  92 + 'exist',
  93 + 'skipOnError' => true,
  94 + 'targetClass' => TaxGroup::className(),
  95 + 'targetAttribute' => [ 'tax_group_id' => 'tax_group_id' ],
  96 + ],
  97 + ];
  98 + }
  99 +
  100 + /**
  101 + * @inheritdoc
  102 + */
  103 + public function attributeLabels()
  104 + {
  105 + return [
  106 + 'tax_group_id' => Yii::t('app', 'Tax Group ID'),
  107 + 'language_id' => Yii::t('app', 'Language ID'),
  108 + 'name' => Yii::t('app', 'Name'),
  109 + 'description' => Yii::t('app', 'Description'),
  110 + 'alias' => Yii::t('app', 'Alias'),
  111 + ];
  112 + }
  113 +
  114 + /**
  115 + * @return \yii\db\ActiveQuery
  116 + */
  117 + public function getLanguage()
  118 + {
  119 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  120 + }
  121 +
  122 + /**
  123 + * @return \yii\db\ActiveQuery
  124 + */
  125 + public function getTaxGroup()
  126 + {
  127 + return $this->hasOne(TaxGroup::className(), [ 'tax_group_id' => 'tax_group_id' ]);
  128 + }
80 } 129 }
81 -}  
common/modules/rubrication/models/TaxOption.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\modules\rubrication\models; 3 namespace common\modules\rubrication\models;
4 4
  5 + use common\behaviors\SaveImgBehavior;
5 use common\modules\language\behaviors\LanguageBehavior; 6 use common\modules\language\behaviors\LanguageBehavior;
6 use common\modules\product\models\Product; 7 use common\modules\product\models\Product;
7 use Yii; 8 use Yii;
@@ -9,40 +10,37 @@ @@ -9,40 +10,37 @@
9 use yii\db\ActiveQuery; 10 use yii\db\ActiveQuery;
10 use yii\db\ActiveRecord; 11 use yii\db\ActiveRecord;
11 use yii\web\Request; 12 use yii\web\Request;
12 - 13 +
13 /** 14 /**
14 * This is the model class for table "{{%tax_option}}". 15 * This is the model class for table "{{%tax_option}}".
15 - * @property string $tax_option_id  
16 - * @property integer $tax_group_id  
17 - * @property integer $parent_id  
18 - * @property integer $tree  
19 - * @property string $path_int  
20 - * @property integer $depth  
21 - * @property string $alias  
22 - * @property integer $sort  
23 - * @property integer $value  
24 - * @property array $image  
25 - * @property TaxGroup $taxGroup  
26 - * @property TaxOption $parent  
27 - * @property TaxOption[] $taxOptions  
28 - * @property Product[] $products  
29 - * 16 + * @property string $tax_option_id
  17 + * @property integer $tax_group_id
  18 + * @property integer $parent_id
  19 + * @property integer $tree
  20 + * @property string $path_int
  21 + * @property integer $depth
  22 + * @property integer $sort
  23 + * @property string $image
  24 + * @property TaxGroup $taxGroup
  25 + * @property TaxOption $parent
  26 + * @property TaxOption[] $taxOptions
  27 + * @property Product[] $products
30 * * From language behavior * 28 * * From language behavior *
31 - * @property TaxOptionLang $lang  
32 - * @property TaxOptionLang[] $langs  
33 - * @property TaxOptionLang $object_lang  
34 - * @property string $ownerKey  
35 - * @property string $langKey 29 + * @property TaxOptionLang $lang
  30 + * @property TaxOptionLang[] $langs
  31 + * @property TaxOptionLang $object_lang
  32 + * @property string $ownerKey
  33 + * @property string $langKey
36 * @method string getOwnerKey() 34 * @method string getOwnerKey()
37 - * @method void setOwnerKey(string $value) 35 + * @method void setOwnerKey( string $value )
38 * @method string getLangKey() 36 * @method string getLangKey()
39 - * @method void setLangKey(string $value) 37 + * @method void setLangKey( string $value )
40 * @method ActiveQuery getLangs() 38 * @method ActiveQuery getLangs()
41 * @method ActiveQuery getLang( integer $language_id ) 39 * @method ActiveQuery getLang( integer $language_id )
42 * @method TaxOptionLang[] generateLangs() 40 * @method TaxOptionLang[] generateLangs()
43 - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)  
44 - * @method bool linkLangs(ActiveRecord[] $model_langs)  
45 - * @method bool saveLangs(ActiveRecord[] $model_langs) 41 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  42 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  43 + * @method bool saveLangs( ActiveRecord[] $model_langs )
46 * * End language behavior * 44 * * End language behavior *
47 */ 45 */
48 class TaxOption extends \yii\db\ActiveRecord 46 class TaxOption extends \yii\db\ActiveRecord
@@ -56,17 +54,20 @@ @@ -56,17 +54,20 @@
56 public function behaviors() 54 public function behaviors()
57 { 55 {
58 return [ 56 return [
  57 + [
  58 + 'class' => SaveImgBehavior::className(),
  59 + 'fields' => [
  60 + [
  61 + 'name' => 'image',
  62 + 'directory' => 'tax_option',
  63 + ],
  64 + ],
  65 + ],
59 'artboxtree' => [ 66 'artboxtree' => [
60 'class' => ArtboxTreeBehavior::className(), 67 'class' => ArtboxTreeBehavior::className(),
61 'keyNameGroup' => 'tax_group_id', 68 'keyNameGroup' => 'tax_group_id',
62 ], 69 ],
63 - 'slug' => [  
64 - 'class' => 'common\behaviors\Slug',  
65 - 'in_attribute' => 'value',  
66 - 'out_attribute' => 'alias',  
67 - 'translit' => true,  
68 - ],  
69 - 'language' => [ 70 + 'language' => [
70 'class' => LanguageBehavior::className(), 71 'class' => LanguageBehavior::className(),
71 ], 72 ],
72 ]; 73 ];
@@ -89,7 +90,6 @@ @@ -89,7 +90,6 @@
89 [ 90 [
90 [ 91 [
91 'tax_group_id', 92 'tax_group_id',
92 - 'value',  
93 ], 93 ],
94 'required', 94 'required',
95 ], 95 ],
@@ -102,15 +102,6 @@ @@ -102,15 +102,6 @@
102 'integer', 102 'integer',
103 ], 103 ],
104 [ 104 [
105 - [  
106 - 'image',  
107 - 'alias',  
108 - 'value',  
109 - ],  
110 - 'string',  
111 - 'max' => 255,  
112 - ],  
113 - [  
114 [ 'tax_group_id' ], 105 [ 'tax_group_id' ],
115 'exist', 106 'exist',
116 'skipOnError' => true, 107 'skipOnError' => true,
@@ -129,7 +120,6 @@ @@ -129,7 +120,6 @@
129 'tax_option_id' => Yii::t('app', 'Tax Option ID'), 120 'tax_option_id' => Yii::t('app', 'Tax Option ID'),
130 'tax_group_id' => Yii::t('app', 'Tax Group ID'), 121 'tax_group_id' => Yii::t('app', 'Tax Group ID'),
131 'parent_id' => Yii::t('app', 'Parent ID'), 122 'parent_id' => Yii::t('app', 'Parent ID'),
132 - 'alias' => Yii::t('app', 'Alias'),  
133 'sort' => Yii::t('app', 'Sort'), 123 'sort' => Yii::t('app', 'Sort'),
134 'image' => Yii::t('product', 'Image'), 124 'image' => Yii::t('product', 'Image'),
135 ]; 125 ];
@@ -177,16 +167,6 @@ @@ -177,16 +167,6 @@
177 return false; 167 return false;
178 } 168 }
179 169
180 - public function getImageFile()  
181 - {  
182 - return empty( $this->image ) ? NULL : Yii::getAlias('@imagesDir/tax_option/' . $this->image);  
183 - }  
184 -  
185 - public function getImageUrl()  
186 - {  
187 - return empty( $this->image ) ? NULL : Yii::getAlias('@imagesUrl/tax_option/' . $this->image);  
188 - }  
189 -  
190 public function getProducts() 170 public function getProducts()
191 { 171 {
192 return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ]) 172 return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ])
common/modules/rubrication/models/TaxOptionLang.php
1 <?php 1 <?php
2 -  
3 -namespace common\modules\rubrication\models;  
4 -  
5 -use common\modules\language\models\Language;  
6 -use Yii;  
7 -  
8 -/**  
9 - * This is the model class for table "tax_option_lang".  
10 - *  
11 - * @property integer $tax_option_id  
12 - * @property integer $language_id  
13 - * @property string $value  
14 - *  
15 - * @property Language $language  
16 - * @property TaxOption $taxOption  
17 - */  
18 -class TaxOptionLang extends \yii\db\ActiveRecord  
19 -{  
20 2
21 - public static function primaryKey()  
22 - {  
23 - return [  
24 - 'tax_option_id',  
25 - 'language_id',  
26 - ];  
27 - } 3 + namespace common\modules\rubrication\models;
  4 +
  5 + use common\modules\language\models\Language;
  6 + use Yii;
28 7
29 /** 8 /**
30 - * @inheritdoc  
31 - */  
32 - public static function tableName()  
33 - {  
34 - return 'tax_option_lang';  
35 - }  
36 -  
37 - /**  
38 - * @inheritdoc  
39 - */  
40 - public function rules()  
41 - {  
42 - return [  
43 - [['value'], 'required'],  
44 - [['value'], 'string', 'max' => 255],  
45 - [['tax_option_id', 'language_id'], 'unique', 'targetAttribute' => ['tax_option_id', 'language_id'], 'message' => 'The combination of Tax Option ID and Language ID has already been taken.'],  
46 - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],  
47 - [['tax_option_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxOption::className(), 'targetAttribute' => ['tax_option_id' => 'tax_option_id']],  
48 - ];  
49 - }  
50 -  
51 - /**  
52 - * @inheritdoc  
53 - */  
54 - public function attributeLabels()  
55 - {  
56 - return [  
57 - 'tax_option_id' => Yii::t('app', 'Tax Option ID'),  
58 - 'language_id' => Yii::t('app', 'Language ID'),  
59 - 'value' => Yii::t('app', 'Value'),  
60 - ];  
61 - }  
62 -  
63 - /**  
64 - * @return \yii\db\ActiveQuery  
65 - */  
66 - public function getLanguage()  
67 - {  
68 - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);  
69 - }  
70 -  
71 - /**  
72 - * @return \yii\db\ActiveQuery 9 + * This is the model class for table "tax_option_lang".
  10 + * @property integer $tax_option_id
  11 + * @property integer $language_id
  12 + * @property string $value
  13 + * @property string $alias
  14 + * @property Language $language
  15 + * @property TaxOption $taxOption
73 */ 16 */
74 - public function getTaxOption() 17 + class TaxOptionLang extends \yii\db\ActiveRecord
75 { 18 {
76 - return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'tax_option_id']); 19 +
  20 + public static function primaryKey()
  21 + {
  22 + return [
  23 + 'tax_option_id',
  24 + 'language_id',
  25 + ];
  26 + }
  27 +
  28 + /**
  29 + * @inheritdoc
  30 + */
  31 + public static function tableName()
  32 + {
  33 + return 'tax_option_lang';
  34 + }
  35 +
  36 + public function behaviors()
  37 + {
  38 + return [
  39 + 'slug' => [
  40 + 'class' => 'common\behaviors\Slug',
  41 + 'in_attribute' => 'value',
  42 + 'out_attribute' => 'alias',
  43 + 'translit' => true,
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + /**
  49 + * @inheritdoc
  50 + */
  51 + public function rules()
  52 + {
  53 + return [
  54 + [
  55 + [ 'value' ],
  56 + 'required',
  57 + ],
  58 + [
  59 + [
  60 + 'value',
  61 + 'alias',
  62 + ],
  63 + 'string',
  64 + 'max' => 255,
  65 + ],
  66 + [
  67 + [
  68 + 'tax_option_id',
  69 + 'language_id',
  70 + ],
  71 + 'unique',
  72 + 'targetAttribute' => [
  73 + 'tax_option_id',
  74 + 'language_id',
  75 + ],
  76 + 'message' => 'The combination of Tax Option ID and Language ID has already been taken.',
  77 + ],
  78 + [
  79 + [ 'language_id' ],
  80 + 'exist',
  81 + 'skipOnError' => true,
  82 + 'targetClass' => Language::className(),
  83 + 'targetAttribute' => [ 'language_id' => 'language_id' ],
  84 + ],
  85 + [
  86 + [ 'tax_option_id' ],
  87 + 'exist',
  88 + 'skipOnError' => true,
  89 + 'targetClass' => TaxOption::className(),
  90 + 'targetAttribute' => [ 'tax_option_id' => 'tax_option_id' ],
  91 + ],
  92 + ];
  93 + }
  94 +
  95 + /**
  96 + * @inheritdoc
  97 + */
  98 + public function attributeLabels()
  99 + {
  100 + return [
  101 + 'tax_option_id' => Yii::t('app', 'Tax Option ID'),
  102 + 'language_id' => Yii::t('app', 'Language ID'),
  103 + 'value' => Yii::t('app', 'Value'),
  104 + 'alias' => Yii::t('app', 'Alias'),
  105 + ];
  106 + }
  107 +
  108 + /**
  109 + * @return \yii\db\ActiveQuery
  110 + */
  111 + public function getLanguage()
  112 + {
  113 + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]);
  114 + }
  115 +
  116 + /**
  117 + * @return \yii\db\ActiveQuery
  118 + */
  119 + public function getTaxOption()
  120 + {
  121 + return $this->hasOne(TaxOption::className(), [ 'tax_option_id' => 'tax_option_id' ]);
  122 + }
77 } 123 }
78 -}  
common/modules/rubrication/models/TaxOptionSearch.php
@@ -27,7 +27,6 @@ class TaxOptionSearch extends TaxOption @@ -27,7 +27,6 @@ class TaxOptionSearch extends TaxOption
27 { 27 {
28 return [ 28 return [
29 [['tax_option_id', 'tax_group_id', 'parent_id', 'sort'], 'integer'], 29 [['tax_option_id', 'tax_group_id', 'parent_id', 'sort'], 'integer'],
30 - [['alias', 'value'], 'safe'],  
31 ]; 30 ];
32 } 31 }
33 32
@@ -73,9 +72,7 @@ class TaxOptionSearch extends TaxOption @@ -73,9 +72,7 @@ class TaxOptionSearch extends TaxOption
73 'parent_id' => $this->parent_id, 72 'parent_id' => $this->parent_id,
74 'sort' => $this->sort, 73 'sort' => $this->sort,
75 ]); 74 ]);
76 -  
77 - $query->andFilterWhere(['like', 'alias', $this->alias]);  
78 - 75 +
79 $query->orderBy(['path_int' => SORT_ASC, 'depth' => SORT_ASC, 'sort' => SORT_ASC]); 76 $query->orderBy(['path_int' => SORT_ASC, 'depth' => SORT_ASC, 'sort' => SORT_ASC]);
80 77
81 return $dataProvider; 78 return $dataProvider;
common/modules/rubrication/views/tax-group/_form.php
@@ -21,17 +21,8 @@ @@ -21,17 +21,8 @@
21 21
22 <?php $form = ActiveForm::begin([ 'options' => [ 'enctype' => 'multipart/form-data' ] ]); ?> 22 <?php $form = ActiveForm::begin([ 'options' => [ 'enctype' => 'multipart/form-data' ] ]); ?>
23 23
24 - <?= $form->field($model, 'name')  
25 - ->textInput([ 'maxlength' => true ]) ?>  
26 -  
27 - <?= $form->field($model, 'alias')  
28 - ->textInput([ 'maxlength' => true ]) ?>  
29 -  
30 - <?= $form->field($model, 'description')  
31 - ->textarea([ 'rows' => 6 ]) ?>  
32 -  
33 <?= $form->field($model, 'categories') 24 <?= $form->field($model, 'categories')
34 - ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), [ 25 + ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'), [
35 'multiple' => true, 26 'multiple' => true,
36 ]) 27 ])
37 ->label('Use in the following categories') ?> 28 ->label('Use in the following categories') ?>
common/modules/rubrication/views/tax-group/_form_language.php
@@ -13,5 +13,7 @@ @@ -13,5 +13,7 @@
13 ?> 13 ?>
14 <?= $form->field($model_lang, '[' . $language->language_id . ']name') 14 <?= $form->field($model_lang, '[' . $language->language_id . ']name')
15 ->textInput([ 'maxlength' => true ]); ?> 15 ->textInput([ 'maxlength' => true ]); ?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  17 + ->textInput([ 'maxlength' => true ]); ?>
16 <?= $form->field($model_lang, '[' . $language->language_id . ']description') 18 <?= $form->field($model_lang, '[' . $language->language_id . ']description')
17 ->textarea([ 'rows' => 6 ]) ?> 19 ->textarea([ 'rows' => 6 ]) ?>
18 \ No newline at end of file 20 \ No newline at end of file
common/modules/rubrication/views/tax-group/index.php
1 <?php 1 <?php
2 -use yii\helpers\Html;  
3 -use yii\grid\GridView;  
4 -use yii\helpers\Url;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $level integer  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('rubrication', 'Groups');  
11 -$this->params['breadcrumbs'][] = $this->title; 2 + use yii\helpers\Html;
  3 + use yii\grid\GridView;
  4 + use yii\helpers\Url;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $level integer
  8 + /* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 + $this->title = Yii::t('rubrication', 'Groups');
  11 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 12 ?>
13 13
14 <div class="tax-group-index"> 14 <div class="tax-group-index">
15 - 15 +
16 <h1><?= Html::encode($this->title) ?></h1> 16 <h1><?= Html::encode($this->title) ?></h1>
17 <p> 17 <p>
18 - <?= Html::a(Yii::t('rubrication', 'Create Group'), Url::to(['/rubrication/tax-group/create', 'level'=> $level]), ['class' => 'btn btn-success']) ?> 18 + <?= Html::a(Yii::t('rubrication', 'Create Group'), Url::to([
  19 + '/rubrication/tax-group/create',
  20 + 'level' => $level,
  21 + ]), [ 'class' => 'btn btn-success' ]) ?>
19 </p> 22 </p>
20 - 23 +
21 <?= GridView::widget([ 24 <?= GridView::widget([
22 'dataProvider' => $dataProvider, 25 'dataProvider' => $dataProvider,
23 - 'columns' => [  
24 - ['class' => 'yii\grid\SerialColumn'],  
25 -  
26 - 'name',  
27 - 'alias',  
28 - 'description:ntext',  
29 - 'is_filter:boolean',  
30 - 26 + 'columns' => [
  27 + [ 'class' => 'yii\grid\SerialColumn' ],
  28 + 'tax_group_id',
  29 + 'is_filter:boolean',
  30 +
31 [ 31 [
32 - 'class' => 'yii\grid\ActionColumn',  
33 - 'template' => '{update} {options} {relations} {delete} {rebuild}',  
34 - 'buttons' => [  
35 - 'options' => function ($url, $model) { 32 + 'class' => 'yii\grid\ActionColumn',
  33 + 'template' => '{update} {options} {relations} {delete} {rebuild}',
  34 + 'buttons' => [
  35 + 'options' => function($url, $model) {
36 return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [ 36 return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [
37 'title' => Yii::t('rubrication', 'Options'), 37 'title' => Yii::t('rubrication', 'Options'),
38 ]); 38 ]);
39 }, 39 },
40 - 'relations' => function ($url, $model) { 40 + 'relations' => function($url, $model) {
41 return Html::a('<!--span class="glyphicon glyphicon-random"></span-->', $url, [ 41 return Html::a('<!--span class="glyphicon glyphicon-random"></span-->', $url, [
42 'title' => Yii::t('rubrication', 'Relations'), 42 'title' => Yii::t('rubrication', 'Relations'),
43 ]); 43 ]);
44 }, 44 },
45 - 'rebuild' => function ($url, $model) { 45 + 'rebuild' => function($url, $model) {
46 return Html::a('<!--span class="glyphicon glyphicon-refresh"></span-->', $url, [ 46 return Html::a('<!--span class="glyphicon glyphicon-refresh"></span-->', $url, [
47 'title' => Yii::t('rubrication', 'Rebuild cache'), 47 'title' => Yii::t('rubrication', 'Rebuild cache'),
48 ]); 48 ]);
49 - } 49 + },
50 ], 50 ],
51 - 'urlCreator' => function ($action, $model, $key, $index) use ($level) {  
52 - if ($action === 'options') {  
53 - $url ='/admin/rubrication/tax-option?group='.$model->tax_group_id; 51 + 'urlCreator' => function($action, $model, $key, $index) use ($level) {
  52 + if($action === 'options') {
  53 + $url = '/admin/rubrication/tax-option?group=' . $model->tax_group_id;
54 return $url; 54 return $url;
55 - } elseif ($action === 'relations') {  
56 - $url ='/admin/rubrication/tax-group/relation&id='.$model->tax_group_id; 55 + } elseif($action === 'relations') {
  56 + $url = '/admin/rubrication/tax-group/relation&id=' . $model->tax_group_id;
57 return $url; 57 return $url;
58 - } elseif ($action === 'update') {  
59 - $url =Url::to(['/rubrication/tax-group/update', 'level'=> $level,'id' =>$model->tax_group_id]); 58 + } elseif($action === 'update') {
  59 + $url = Url::to([
  60 + '/rubrication/tax-group/update',
  61 + 'level' => $level,
  62 + 'id' => $model->tax_group_id,
  63 + ]);
60 return $url; 64 return $url;
61 - } elseif ($action === 'delete') {  
62 - $url =Url::to(['/rubrication/tax-group/delete', 'level'=> $level,'id' =>$model->tax_group_id]); 65 + } elseif($action === 'delete') {
  66 + $url = Url::to([
  67 + '/rubrication/tax-group/delete',
  68 + 'level' => $level,
  69 + 'id' => $model->tax_group_id,
  70 + ]);
63 return $url; 71 return $url;
64 - } elseif ($action === 'rebuild') {  
65 - $url ='/admin/rubrication/tax-group/rebuild?id='.$model->tax_group_id; 72 + } elseif($action === 'rebuild') {
  73 + $url = '/admin/rubrication/tax-group/rebuild?id=' . $model->tax_group_id;
66 return $url; 74 return $url;
67 } 75 }
68 - } 76 + return '';
  77 + },
69 ], 78 ],
70 ], 79 ],
71 ]); ?> 80 ]); ?>
common/modules/rubrication/views/tax-group/update.php
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 13
14 $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ 14 $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [
15 'modelClass' => 'Tax Group', 15 'modelClass' => 'Tax Group',
16 - ]) . ' ' . $model->name; 16 + ]) . ' ' . $model->tax_group_id;
17 $this->params[ 'breadcrumbs' ][] = [ 17 $this->params[ 'breadcrumbs' ][] = [
18 'label' => Yii::t('rubrication', 'Groups'), 18 'label' => Yii::t('rubrication', 'Groups'),
19 'url' => [ 'index' ], 19 'url' => [ 'index' ],
20 ]; 20 ];
21 $this->params[ 'breadcrumbs' ][] = [ 21 $this->params[ 'breadcrumbs' ][] = [
22 - 'label' => $model->name, 22 + 'label' => $model->tax_group_id,
23 'url' => [ 23 'url' => [
24 'view', 24 'view',
25 'id' => $model->tax_group_id, 25 'id' => $model->tax_group_id,
common/modules/rubrication/views/tax-group/view.php
1 <?php 1 <?php
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\DetailView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\modules\rubrication\models\TaxGroup */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', 'Tax Groups'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\modules\rubrication\models\TaxGroup */
  8 +
  9 + $this->title = $model->tax_group_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('rubrication', 'Tax Groups'),
  12 + 'url' => [ 'index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 ?> 15 ?>
13 <div class="tax-group-view"> 16 <div class="tax-group-view">
14 - 17 +
15 <h1><?= Html::encode($this->title) ?></h1> 18 <h1><?= Html::encode($this->title) ?></h1>
16 - 19 +
17 <p> 20 <p>
18 - <?= Html::a(Yii::t('rubrication', 'Update'), ['update', 'id' => $model->tax_group_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('rubrication', 'Delete'), ['delete', 'id' => $model->tax_group_id], [ 21 + <?= Html::a(Yii::t('rubrication', 'Update'), [
  22 + 'update',
  23 + 'id' => $model->tax_group_id,
  24 + ], [ 'class' => 'btn btn-primary' ]) ?>
  25 + <?= Html::a(Yii::t('rubrication', 'Delete'), [
  26 + 'delete',
  27 + 'id' => $model->tax_group_id,
  28 + ], [
20 'class' => 'btn btn-danger', 29 'class' => 'btn btn-danger',
21 - 'data' => [ 30 + 'data' => [
22 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'), 31 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'),
23 - 'method' => 'post', 32 + 'method' => 'post',
24 ], 33 ],
25 ]) ?> 34 ]) ?>
26 - <?= Html::a(Yii::t('rubrication', 'Create Option'), ['tax-option/create?group='. $model->tax_group_id], ['class' => 'btn btn-success']) ?> 35 + <?= Html::a(Yii::t('rubrication', 'Create Option'), [ 'tax-option/create?group=' . $model->tax_group_id ], [ 'class' => 'btn btn-success' ]) ?>
27 </p> 36 </p>
28 - 37 +
29 <?= DetailView::widget([ 38 <?= DetailView::widget([
30 'model' => $model, 39 'model' => $model,
31 'attributes' => [ 40 'attributes' => [
32 'tax_group_id', 41 'tax_group_id',
33 - 'alias',  
34 - 'name',  
35 - 'description:ntext',  
36 'is_filter:boolean', 42 'is_filter:boolean',
37 ], 43 ],
38 ]) ?> 44 ]) ?>
common/modules/rubrication/views/tax-option/_form.php
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <?php if(empty( $group->tax_group_id )) : ?> 24 <?php if(empty( $group->tax_group_id )) : ?>
25 <?= $form->field($model, 'tax_group_id') 25 <?= $form->field($model, 'tax_group_id')
26 ->dropDownList(ArrayHelper::map(TaxOption::find() 26 ->dropDownList(ArrayHelper::map(TaxOption::find()
27 - ->all(), 'tax_group_id', 'value'), [ 27 + ->all(), 'tax_group_id', 'tax_group_id'), [
28 'prompt' => Yii::t('rubrication', 'Select group'), 28 'prompt' => Yii::t('rubrication', 'Select group'),
29 ]) ?> 29 ]) ?>
30 <?php else : ?> 30 <?php else : ?>
@@ -33,15 +33,8 @@ @@ -33,15 +33,8 @@
33 ->label('') ?> 33 ->label('') ?>
34 <?php endif ?> 34 <?php endif ?>
35 35
36 -  
37 - <?= $form->field($model, 'value')  
38 - ->textInput([ 'maxlength' => true ]) ?>  
39 -  
40 - <?= $form->field($model, 'alias')  
41 - ->textInput([ 'maxlength' => true ]) ?>  
42 -  
43 <?= $form->field($model, 'image') 36 <?= $form->field($model, 'image')
44 - ->widget(\kartik\file\FileInput::classname(), [ 37 + ->widget(\kartik\file\FileInput::className(), [
45 'language' => 'ru', 38 'language' => 'ru',
46 'options' => [ 39 'options' => [
47 'accept' => 'image/*', 40 'accept' => 'image/*',
common/modules/rubrication/views/tax-option/_form_language.php
@@ -12,4 +12,6 @@ @@ -12,4 +12,6 @@
12 */ 12 */
13 ?> 13 ?>
14 <?= $form->field($model_lang, '[' . $language->language_id . ']value') 14 <?= $form->field($model_lang, '[' . $language->language_id . ']value')
15 - ->textInput([ 'maxlength' => true ]); ?>  
16 \ No newline at end of file 15 \ No newline at end of file
  16 + ->textInput([ 'maxlength' => true ]); ?>
  17 +<?= $form->field($model_lang, '[' . $language->language_id . ']alias')
  18 + ->textInput([ 'maxlength' => true ]); ?>
common/modules/rubrication/views/tax-option/create.php
@@ -16,14 +16,14 @@ @@ -16,14 +16,14 @@
16 'url' => [ 'tax-group/index' ], 16 'url' => [ 'tax-group/index' ],
17 ]; 17 ];
18 $this->params[ 'breadcrumbs' ][] = [ 18 $this->params[ 'breadcrumbs' ][] = [
19 - 'label' => Yii::t('rubrication', $group->name), 19 + 'label' => Yii::t('rubrication', $group->tax_group_id),
20 'url' => [ 20 'url' => [
21 'index', 21 'index',
22 'group' => $group->tax_group_id, 22 'group' => $group->tax_group_id,
23 ], 23 ],
24 ]; 24 ];
25 $this->params[ 'breadcrumbs' ][] = [ 25 $this->params[ 'breadcrumbs' ][] = [
26 - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->name ])), 26 + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])),
27 'url' => [ 27 'url' => [
28 'index', 28 'index',
29 'group' => $group->tax_group_id, 29 'group' => $group->tax_group_id,
common/modules/rubrication/views/tax-option/index.php
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 * @var TaxGroup $group 11 * @var TaxGroup $group
12 */ 12 */
13 13
14 - $this->title = Yii::t('rubrication', 'Options for group "{group}"', [ 'group' => $group->name ]); 14 + $this->title = Yii::t('rubrication', 'Options for group "{group}"', [ 'group' => $group->tax_group_id ]);
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
16 'label' => Yii::t('rubrication', 'Groups'), 16 'label' => Yii::t('rubrication', 'Groups'),
17 'url' => [ 'tax-group/index' ], 17 'url' => [ 'tax-group/index' ],
@@ -30,8 +30,7 @@ @@ -30,8 +30,7 @@
30 'dataProvider' => $dataProvider, 30 'dataProvider' => $dataProvider,
31 'columns' => [ 31 'columns' => [
32 [ 'class' => 'yii\grid\SerialColumn' ], 32 [ 'class' => 'yii\grid\SerialColumn' ],
33 - 'value',  
34 - 'alias', 33 + 'tax_option_id',
35 [ 34 [
36 'class' => 'yii\grid\ActionColumn', 35 'class' => 'yii\grid\ActionColumn',
37 'template' => '{update} {delete}', 36 'template' => '{update} {delete}',
common/modules/rubrication/views/tax-option/update.php
@@ -18,14 +18,14 @@ @@ -18,14 +18,14 @@
18 'url' => [ 'tax-group/index' ], 18 'url' => [ 'tax-group/index' ],
19 ]; 19 ];
20 $this->params[ 'breadcrumbs' ][] = [ 20 $this->params[ 'breadcrumbs' ][] = [
21 - 'label' => $group->name, 21 + 'label' => $group->tax_group_id,
22 'url' => [ 22 'url' => [
23 'view', 23 'view',
24 'id' => $group->tax_group_id, 24 'id' => $group->tax_group_id,
25 ], 25 ],
26 ]; 26 ];
27 $this->params[ 'breadcrumbs' ][] = [ 27 $this->params[ 'breadcrumbs' ][] = [
28 - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->name ])), 28 + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])),
29 'url' => [ 29 'url' => [
30 'index', 30 'index',
31 'group' => $group->tax_group_id, 31 'group' => $group->tax_group_id,
common/modules/rubrication/views/tax-option/view.php
1 <?php 1 <?php
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\DetailView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\modules\rubrication\models\TaxOption */  
8 -  
9 -$this->title = $model->value;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', 'Groups'), 'url' => ['tax-group/index']];  
11 -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', $group->name), 'url' => ['index', 'group' => $group->tax_group_id]];  
12 -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', ['name' => $group->name])), 'url' => ['index', 'group' => $group->tax_group_id]];  
13 -$this->params['breadcrumbs'][] = $this->title; 2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\DetailView;
  5 +
  6 + /* @var $this yii\web\View */
  7 + /* @var $model common\modules\rubrication\models\TaxOption */
  8 +
  9 + $this->title = $model->tax_option_id;
  10 + $this->params[ 'breadcrumbs' ][] = [
  11 + 'label' => Yii::t('rubrication', 'Groups'),
  12 + 'url' => [ 'tax-group/index' ],
  13 + ];
  14 + $this->params[ 'breadcrumbs' ][] = [
  15 + 'label' => Yii::t('rubrication', $group->tax_group_id),
  16 + 'url' => [
  17 + 'index',
  18 + 'group' => $group->tax_group_id,
  19 + ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])),
  23 + 'url' => [
  24 + 'index',
  25 + 'group' => $group->tax_group_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = $this->title;
14 ?> 29 ?>
15 <div class="tax-option-view"> 30 <div class="tax-option-view">
16 - 31 +
17 <h1><?= Html::encode($this->title) ?></h1> 32 <h1><?= Html::encode($this->title) ?></h1>
18 - 33 +
19 <p> 34 <p>
20 - <?= Html::a(Yii::t('rubrication', 'Update'), ['update', 'id' => $model->tax_option_id], ['class' => 'btn btn-primary']) ?>  
21 - <?= Html::a(Yii::t('rubrication', 'Delete'), ['delete', 'id' => $model->tax_option_id], [ 35 + <?= Html::a(Yii::t('rubrication', 'Update'), [
  36 + 'update',
  37 + 'id' => $model->tax_option_id,
  38 + ], [ 'class' => 'btn btn-primary' ]) ?>
  39 + <?= Html::a(Yii::t('rubrication', 'Delete'), [
  40 + 'delete',
  41 + 'id' => $model->tax_option_id,
  42 + ], [
22 'class' => 'btn btn-danger', 43 'class' => 'btn btn-danger',
23 - 'data' => [ 44 + 'data' => [
24 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'), 45 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'),
25 - 'method' => 'post', 46 + 'method' => 'post',
26 ], 47 ],
27 ]) ?> 48 ]) ?>
28 - <?= Html::a(Yii::t('rubrication', 'Create Option'), ['tax-option/create?group='. $model->tax_group_id], ['class' => 'btn btn-success']) ?>  
29 - <?php if (!empty($model->parent_id)) :?>  
30 - <?= Html::a(Yii::t('rubrication', 'Create Option By {name}', ['name' => $model->parent->value]), ['tax-option/create?group='. $model->tax_group_id .'&parent='. $model->parent->tax_option_id], ['class' => 'btn btn-success']) ?>  
31 - <?php endif?> 49 + <?= Html::a(Yii::t('rubrication', 'Create Option'), [ 'tax-option/create?group=' . $model->tax_group_id ], [ 'class' => 'btn btn-success' ]) ?>
  50 + <?php if(!empty( $model->parent_id )) : ?>
  51 + <?= Html::a(Yii::t('rubrication', 'Create Option By {name}', [ 'name' => $model->parent->tax_option_id ]), [ 'tax-option/create?group=' . $model->tax_group_id . '&parent=' . $model->parent->tax_option_id ], [ 'class' => 'btn btn-success' ]) ?>
  52 + <?php endif ?>
32 </p> 53 </p>
33 - 54 +
34 <?= DetailView::widget([ 55 <?= DetailView::widget([
35 'model' => $model, 56 'model' => $model,
36 'attributes' => [ 57 'attributes' => [
37 'tax_option_id', 58 'tax_option_id',
38 - 'value',  
39 - 'alias',  
40 - 'parent.value',  
41 - 'group.name', 59 + 'parent.tax_option_id',
  60 + 'group.tax_group_id',
42 'sort', 61 'sort',
43 ], 62 ],
44 ]) ?> 63 ]) ?>
console/migrations/m161004_102751_add_lang_column.php 0 → 100644
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161004_102751_add_lang_column extends Migration
  6 + {
  7 +
  8 + public function up()
  9 + {
  10 + $this->addColumn('articles_lang', 'alias', $this->string(255));
  11 + $this->addColumn('brand_lang', 'alias', $this->string(255));
  12 + $this->addColumn('category_lang', 'alias', $this->string(255));
  13 + $this->addColumn('event_lang', 'alias', $this->string(255));
  14 + $this->addColumn('page_lang', 'alias', $this->string(255));
  15 + $this->addColumn('product_lang', 'alias', $this->string(255));
  16 + $this->addColumn('project_lang', 'alias', $this->string(255));
  17 + $this->addColumn('service_lang', 'alias', $this->string(255));
  18 + $this->addColumn('tax_group_lang', 'alias', $this->string(255));
  19 + $this->addColumn('tax_option_lang', 'alias', $this->string(255));
  20 + $this->createIndex('articles_lang_alias', 'articles_lang', 'alias', true);
  21 + $this->createIndex('brand_lang_alias', 'brand_lang', 'alias', true);
  22 + $this->createIndex('category_lang_alias', 'category_lang', 'alias', true);
  23 + $this->createIndex('event_lang_alias', 'event_lang', 'alias', true);
  24 + $this->createIndex('page_lang_alias', 'page_lang', 'alias', true);
  25 + $this->createIndex('product_lang_alias', 'product_lang', 'alias', true);
  26 + $this->createIndex('project_lang_alias', 'project_lang', 'alias', true);
  27 + $this->createIndex('service_lang_alias', 'service_lang', 'alias', true);
  28 + $this->createIndex('tax_group_lang_alias', 'tax_group_lang', 'alias', true);
  29 + $this->createIndex('tax_option_lang_alias', 'tax_option_lang', 'alias', true);
  30 + }
  31 +
  32 + public function down()
  33 + {
  34 + $this->dropIndex('articles_lang_alias', 'articles_lang');
  35 + $this->dropIndex('brand_lang_alias', 'brand_lang');
  36 + $this->dropIndex('category_lang_alias', 'category_lang');
  37 + $this->dropIndex('event_lang_alias', 'event_lang');
  38 + $this->dropIndex('page_lang_alias', 'page_lang');
  39 + $this->dropIndex('product_lang_alias', 'product_lang');
  40 + $this->dropIndex('project_lang_alias', 'project_lang');
  41 + $this->dropIndex('service_lang_alias', 'service_lang');
  42 + $this->dropIndex('tax_group_lang_alias', 'tax_group_lang');
  43 + $this->dropIndex('tax_option_lang_alias', 'tax_option_lang');
  44 + $this->dropColumn('articles_lang', 'alias');
  45 + $this->dropColumn('brand_lang', 'alias');
  46 + $this->dropColumn('category_lang', 'alias');
  47 + $this->dropColumn('event_lang', 'alias');
  48 + $this->dropColumn('page_lang', 'alias');
  49 + $this->dropColumn('product_lang', 'alias');
  50 + $this->dropColumn('project_lang', 'alias');
  51 + $this->dropColumn('service_lang', 'alias');
  52 + $this->dropColumn('tax_group_lang', 'alias');
  53 + $this->dropColumn('tax_option_lang', 'alias');
  54 + }
  55 + }
1 -1. OrdersDelivery - добавить возможность добавления.  
2 -2. Переименовать все id в table_id.  
3 -3. Переименовать все table!s! в table.  
4 -4. Пересмотреть структура таблицы orders_products.  
5 -5. Посмотреть разницу ProductVariantSearch и ProductVariantListSearch.  
6 -6. Wishlist  
7 -7. Lookbook (типа коллекций)? 1 +1. Написать стандарты.
  2 +1.1. Таблицы и колонки. (0.25 час Ярик, Виталик)
  3 +1.2. Классы. (0.25 час Ярик, Виталик) (http://svyatoslav.biz/misc/psr_translation/)
  4 +1.3. Написать как пользоваться GIT. (1 час Виталик)
  5 +1.4. Стандарты по JS (pure, jQuery). (1 час Ярик) (https://learn.javascript.ru/coding-style)
  6 +
  7 +2. База данных.
  8 +2.1. Удалить поля, которые перешли в мультиязычность. (1 час Ярик)
  9 +2.2. Привести наименование колонок и таблиц к одному стилю. (1 час Ярик)
  10 +2.3. Написать миграциию. (15 мин на таблицу 71 таблица) (20 часа Женя, 1 час Ярик)
  11 +
  12 +3. Классы
  13 +3.1. Пофиксить после изменений в базе + формы. (8 часов Ярик)
  14 +3.2. SlugBeahvior перенести на классы языков где требуется. (1 час Ярик)
  15 +
  16 +4. Админка
  17 +4.1. Почистить админку.
  18 +4.2. Перевести все поля. (3 час Женя)
  19 +4.3. Пофиксить крошки и другие баги. (3 часа Леша)
  20 +4.4. Настроить везде одинаковую загрузку картинок (1 час Ярик)
  21 +4.4.1. Написать behavior для множественной загрузки картинок. (4 час Виталик)
  22 +4.5. Добавить страницы добавления OrdersDelivery, OrdersLabel. (2 час Леша)
  23 +4.6. Вывод информации на главную страницу админки. (∞ Леша)
  24 +
  25 +5. Подготовка под Composer (∞) (https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/structure-extensions.md#Создание-расширений-)
  26 +5.1. Свести все зависимости в одну директорию.
  27 +5.2. Свести все ключевые правки в один проект.
  28 +5.2.1. Импорт с линии света (∞ Виталик)
  29 +5.2.2. Акции с рюкзака (1 час Виталик)
  30 +5.2.3. Мультиязычность с витекса (1 часа Ярик)
  31 +5.2.4. Блог на бакаре (Леша)
  32 +5.2.5. Загрузка картинок с витекса (0.25 часа Ярик)
  33 +
  34 +6. Модуль заказов
  35 +6.1. Доставка
  36 +6.1.1. Бесплатная
  37 +6.1.2. Доставка новая почта
  38 +6.2. Оплата онлайн
  39 +
  40 +7. Wishlist
  41 +
8 8. Compare 42 8. Compare
9 -9. Tags для блога  
10 -10. Social integration  
11 \ No newline at end of file 43 \ No newline at end of file
  44 +
  45 +9. Blog (Леша делает)
  46 +9.1. Рубрики
  47 +9.2. Теги
  48 +
  49 +10. Сторонние сервисы
  50 +10.1. Доставка
  51 +10.2. Оплата
  52 +10.3. Интеграция с 1С (baucenter) (3 часа Виталик)
  53 +
  54 +11. Базовая верстка
  55 +
  56 +12. Фильтры (8 часа Ярик, Виталик)
  57 +12.1. Чтобы исчезали
  58 +
  59 +13. Пофиксить Product Stock (1 час Ярик)
  60 +
  61 +14. Настройка продакшн сервера (2 часа Виталик, Леша)
  62 +
  63 +15. Узнать о снижении цены
  64 +
  65 +16. Блок просмотренные товары
  66 +
  67 +17. Блок похожие товары
  68 +
  69 +18. Валюты
  70 +
  71 +19. Промокоды
  72 +
  73 +Осталось Ярик:
  74 +- Посмотреть разницу ProductVariantSearch и ProductVariantListSearch.
  75 +- Social integration
  76 +
  77 +Fix по существующему:
  78 +1. Product - разобратсья с картинками
  79 +2. Product->getCategories = Product->getCategoriesWithNames