Commit d55d2fe0ccafc1c4be375e610f068eeefd50deb9

Authored by Yarik
1 parent a5333f15

Multilanguage

Showing 206 changed files with 10430 additions and 4576 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 206 files are displayed.

backend/assets/AppAsset.php
... ... @@ -21,11 +21,10 @@ class AppAsset extends AssetBundle
21 21 'css/site.css',
22 22 ];
23 23 public $js = [
24   - 'js/fieldWidget.js',
25 24 'js/site.js',
26 25 ];
27 26 public $depends = [
28 27 'yii\web\YiiAsset',
29   - 'yii\bootstrap\BootstrapAsset',
  28 + 'yii\bootstrap\BootstrapPluginAsset',
30 29 ];
31 30 }
... ...
backend/controllers/ArticlesController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Articles;
7   -use common\models\ArticlesSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -use yii\web\UploadedFile;
13   -
14   -/**
15   - * ArticlesController implements the CRUD actions for Articles model.
16   - */
17   -class ArticlesController extends Controller
18   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Articles;
  7 + use common\models\ArticlesSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 + use yii\web\UploadedFile;
  13 +
19 14 /**
20   - * @inheritdoc
  15 + * ArticlesController implements the CRUD actions for Articles model.
21 16 */
22   - public function behaviors()
  17 + class ArticlesController extends Controller
23 18 {
24   - return [
25   - 'access'=>[
26   - 'class' => AccessBehavior::className(),
27   - 'rules' =>
28   - ['site' =>
29   - [
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function behaviors()
  24 + {
  25 + return [
  26 + 'access' => [
  27 + 'class' => AccessBehavior::className(),
  28 + 'rules' => [
  29 + 'site' => [
30 30 [
31   - 'actions' => ['login', 'error'],
32   - 'allow' => true,
33   - ]
34   - ]
35   - ]
36   - ],
37   - 'verbs' => [
38   - 'class' => VerbFilter::className(),
39   - 'actions' => [
40   - 'delete' => ['POST'],
  31 + 'actions' => [
  32 + 'login',
  33 + 'error',
  34 + ],
  35 + 'allow' => true,
  36 + ],
  37 + ],
  38 + ],
41 39 ],
42   - ],
43   - ];
44   - }
45   -
46   - /**
47   - * Lists all Articles models.
48   - * @return mixed
49   - */
50   - public function actionIndex()
51   - {
52   - $searchModel = new ArticlesSearch();
53   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
54   -
55   - return $this->render('index', [
56   - 'searchModel' => $searchModel,
57   - 'dataProvider' => $dataProvider,
58   - ]);
59   - }
60   -
61   - /**
62   - * Displays a single Articles model.
63   - * @param integer $id
64   - * @return mixed
65   - */
66   - public function actionView($id)
67   - {
68   - return $this->render('view', [
69   - 'model' => $this->findModel($id),
70   - ]);
71   - }
72   -
73   - /**
74   - * Creates a new Articles model.
75   - * If creation is successful, the browser will be redirected to the 'view' page.
76   - * @return mixed
77   - */
78   - public function actionCreate()
79   - {
80   - $model = new Articles();
81   -
82   - if ($model->load(Yii::$app->request->post())) {
83   -
84   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
85   - $model->image = $image->name;
86   - }
87   -
88   - $imgDir = Yii::getAlias('@storage/articles/');
89   -
90   - if(!is_dir($imgDir)) {
91   - mkdir($imgDir, 0755, true);
92   - }
93   - if ($model->save() && $image) {
94   - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));
  40 + 'verbs' => [
  41 + 'class' => VerbFilter::className(),
  42 + 'actions' => [
  43 + 'delete' => [ 'POST' ],
  44 + ],
  45 + ],
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * Lists all Articles models.
  51 + * @return mixed
  52 + */
  53 + public function actionIndex()
  54 + {
  55 + $searchModel = new ArticlesSearch();
  56 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  57 +
  58 + return $this->render('index', [
  59 + 'searchModel' => $searchModel,
  60 + 'dataProvider' => $dataProvider,
  61 + ]);
  62 + }
  63 +
  64 + /**
  65 + * Displays a single Articles model.
  66 + *
  67 + * @param integer $id
  68 + *
  69 + * @return mixed
  70 + */
  71 + public function actionView($id)
  72 + {
  73 + return $this->render('view', [
  74 + 'model' => $this->findModel($id),
  75 + ]);
  76 + }
  77 +
  78 + /**
  79 + * Creates a new Articles model.
  80 + * If creation is successful, the browser will be redirected to the 'view' page.
  81 + * @return mixed
  82 + */
  83 + public function actionCreate()
  84 + {
  85 + $model = new Articles();
  86 + $model_langs = $model->generateLangs();
  87 + if($model->load(Yii::$app->request->post())) {
  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()) {
  97 + if($image) {
  98 + $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));
  99 + }
  100 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  101 + return $this->redirect([
  102 + 'view',
  103 + 'id' => $model->id,
  104 + ]);
  105 + } else {
  106 + return $this->redirect([
  107 + 'update',
  108 + 'id' => $model->id,
  109 + ]);
  110 + }
  111 + }
95 112 }
96   -
97   - return $this->redirect(['view', 'id' => $model->id]);
98   - } else {
99 113 return $this->render('create', [
100   - 'model' => $model,
  114 + 'model' => $model,
  115 + 'model_langs' => $model_langs,
101 116 ]);
102 117 }
103   - }
104   -
105   - /**
106   - * Updates an existing Articles model.
107   - * If update is successful, the browser will be redirected to the 'view' page.
108   - * @param integer $id
109   - * @return mixed
110   - */
111   - public function actionUpdate($id)
112   - {
113   - $model = $this->findModel($id);
114   -
115   - if ($model->load(Yii::$app->request->post())) {
116 118  
117   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
118   - $model->image = $image->name;
119   - }
120   -
121   - $imgDir = Yii::getAlias('@storage/articles/');
122   -
123   - if(!is_dir($imgDir)) {
124   - mkdir($imgDir, 0755, true);
125   - }
126   - if ($model->save() && $image) {
127   - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));
  119 + /**
  120 + * Updates an existing Articles model.
  121 + * If update is successful, the browser will be redirected to the 'view' page.
  122 + *
  123 + * @param integer $id
  124 + *
  125 + * @return mixed
  126 + */
  127 + public function actionUpdate($id)
  128 + {
  129 + $model = $this->findModel($id);
  130 + $model_langs = $model->generateLangs();
  131 + if($model->load(Yii::$app->request->post())) {
  132 + $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()) {
  141 + if($image) {
  142 + $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));
  143 + }
  144 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  145 + return $this->redirect([
  146 + 'view',
  147 + 'id' => $model->id,
  148 + ]);
  149 + }
  150 + }
128 151 }
129   -
130   - return $this->redirect(['view', 'id' => $model->id]);
131   - } else {
132 152 return $this->render('update', [
133   - 'model' => $model,
  153 + 'model' => $model,
  154 + 'model_langs' => $model_langs,
134 155 ]);
135 156 }
136   - }
137   -
138   - /**
139   - * Deletes an existing Articles model.
140   - * If deletion is successful, the browser will be redirected to the 'index' page.
141   - * @param integer $id
142   - * @return mixed
143   - */
144   - public function actionDelete($id)
145   - {
146   - $this->findModel($id)->delete();
147   -
148   - return $this->redirect(['index']);
149   - }
150   -
151   - /**
152   - * Finds the Articles model based on its primary key value.
153   - * If the model is not found, a 404 HTTP exception will be thrown.
154   - * @param integer $id
155   - * @return Articles the loaded model
156   - * @throws NotFoundHttpException if the model cannot be found
157   - */
158   - protected function findModel($id)
159   - {
160   - if (($model = Articles::findOne($id)) !== null) {
161   - return $model;
162   - } else {
163   - throw new NotFoundHttpException('The requested page does not exist.');
  157 +
  158 + /**
  159 + * Deletes an existing Articles model.
  160 + * If deletion is successful, the browser will be redirected to the 'index' page.
  161 + *
  162 + * @param integer $id
  163 + *
  164 + * @return mixed
  165 + */
  166 + public function actionDelete($id)
  167 + {
  168 + $this->findModel($id)
  169 + ->delete();
  170 +
  171 + return $this->redirect([ 'index' ]);
  172 + }
  173 +
  174 + /**
  175 + * Finds the Articles model based on its primary key value.
  176 + * If the model is not found, a 404 HTTP exception will be thrown.
  177 + *
  178 + * @param integer $id
  179 + *
  180 + * @return Articles the loaded model
  181 + * @throws NotFoundHttpException if the model cannot be found
  182 + */
  183 + protected function findModel($id)
  184 + {
  185 + if(( $model = Articles::findOne($id) ) !== NULL) {
  186 + return $model;
  187 + } else {
  188 + throw new NotFoundHttpException('The requested page does not exist.');
  189 + }
164 190 }
165 191 }
166   -}
... ...
backend/controllers/BannerController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use common\modules\file\widgets\ImageUploader;
6   -use Yii;
7   -use common\models\Banner;
8   -use common\models\BannerSearch;
9   -use yii\web\Controller;
10   -use yii\web\NotFoundHttpException;
11   -use yii\filters\VerbFilter;
12   -use developeruz\db_rbac\behaviors\AccessBehavior;
13   -/**
14   - * BannerController implements the CRUD actions for Banner model.
15   - */
16   -class BannerController extends Controller
17   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use common\modules\file\widgets\ImageUploader;
  6 + use Yii;
  7 + use common\models\Banner;
  8 + use common\models\BannerSearch;
  9 + use yii\web\Controller;
  10 + use yii\web\NotFoundHttpException;
  11 + use yii\filters\VerbFilter;
  12 + use developeruz\db_rbac\behaviors\AccessBehavior;
  13 +
18 14 /**
19   - * @inheritdoc
  15 + * BannerController implements the CRUD actions for Banner model.
20 16 */
21   - public function behaviors()
  17 + class BannerController extends Controller
22 18 {
23   - return [
24   - 'access'=>[
25   - 'class' => AccessBehavior::className(),
26   - 'rules' =>
27   - ['site' =>
28   - [
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function behaviors()
  24 + {
  25 + return [
  26 + 'access' => [
  27 + 'class' => AccessBehavior::className(),
  28 + 'rules' => [
  29 + 'site' => [
29 30 [
30   - 'actions' => ['login', 'error'],
31   - 'allow' => true,
32   - ]
33   - ]
34   - ]
35   - ],
36   - 'verbs' => [
37   - 'class' => VerbFilter::className(),
38   - 'actions' => [
39   - 'delete' => ['POST'],
  31 + 'actions' => [
  32 + 'login',
  33 + 'error',
  34 + ],
  35 + 'allow' => true,
  36 + ],
  37 + ],
  38 + ],
40 39 ],
41   - ],
42   - ];
43   - }
44   -
45   - /**
46   - * Lists all Banner models.
47   - * @return mixed
48   - */
49   - public function actionIndex()
50   - {
51   - $searchModel = new BannerSearch();
52   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
53   -
54   - return $this->render('index', [
55   - 'searchModel' => $searchModel,
56   - 'dataProvider' => $dataProvider,
57   - ]);
58   - }
59   -
60   - public function actionSaveImageSettings(){
61   - \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
62   - $width = Yii::$app->request->post('width');
63   - $height = Yii::$app->request->post('height');
64   -
65   - $html = ImageUploader::widget([
66   - 'model'=> new Banner(),
67   - 'field'=>'image',
68   - 'size' => [
69   - [
70   - 'width'=>$width,
71   - 'height'=>$height,
  40 + 'verbs' => [
  41 + 'class' => VerbFilter::className(),
  42 + 'actions' => [
  43 + 'delete' => [ 'POST' ],
  44 + ],
72 45 ],
73   - ],
74   - 'name' => "ะ—ะฐะณั€ัƒะทะธั‚ัŒ ะฑะฐะฝะฝะตั€"
75   - ]);
76   -
77   - return ['html'=>$html];
78   - }
79   -
80   - /**
81   - * Displays a single Banner model.
82   - * @param integer $id
83   - * @return mixed
84   - */
85   - public function actionView($id)
86   - {
87   - return $this->render('view', [
88   - 'model' => $this->findModel($id),
89   - ]);
90   - }
91   -
92   - /**
93   - * Creates a new Banner model.
94   - * If creation is successful, the browser will be redirected to the 'view' page.
95   - * @return mixed
96   - */
97   - public function actionCreate()
98   - {
99   - $model = new Banner();
100   -
101   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
102   - return $this->redirect(['view', 'id' => $model->banner_id]);
103   - } else {
104   - return $this->render('create', [
105   - 'model' => $model,
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * Lists all Banner models.
  51 + * @return mixed
  52 + */
  53 + public function actionIndex()
  54 + {
  55 + $searchModel = new BannerSearch();
  56 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  57 +
  58 + return $this->render('index', [
  59 + 'searchModel' => $searchModel,
  60 + 'dataProvider' => $dataProvider,
106 61 ]);
107 62 }
108   - }
109   -
110   - /**
111   - * Updates an existing Banner model.
112   - * If update is successful, the browser will be redirected to the 'view' page.
113   - * @param integer $id
114   - * @return mixed
115   - */
116   - public function actionUpdate($id)
117   - {
118   - $model = $this->findModel($id);
119   -
120   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
121   - return $this->redirect(['view', 'id' => $model->banner_id]);
122   - } else {
  63 +
  64 + /**
  65 + * Displays a single Banner model.
  66 + *
  67 + * @param integer $id
  68 + *
  69 + * @return mixed
  70 + */
  71 + public function actionView($id)
  72 + {
  73 + return $this->render('view', [
  74 + 'model' => $this->findModel($id),
  75 + ]);
  76 + }
  77 +
  78 + /**
  79 + * Creates a new Banner model.
  80 + * If creation is successful, the browser will be redirected to the 'view' page.
  81 + * @return mixed
  82 + */
  83 + public function actionCreate()
  84 + {
  85 + $model = new Banner();
  86 + $model_langs = $model->generateLangs();
  87 +
  88 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  89 + $model->loadLangs(\Yii::$app->request, $model_langs);
  90 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  91 + return $this->redirect([
  92 + 'view',
  93 + 'id' => $model->banner_id,
  94 + ]);
  95 + } else {
  96 + return $this->redirect('update', [
  97 + 'id' => $model->banner_id,
  98 + ]);
  99 + }
  100 + } else {
  101 + return $this->render('create', [
  102 + 'model' => $model,
  103 + 'model_langs' => $model_langs,
  104 + ]);
  105 + }
  106 + }
  107 +
  108 + /**
  109 + * Updates an existing Banner model.
  110 + * If update is successful, the browser will be redirected to the 'view' page.
  111 + *
  112 + * @param integer $id
  113 + *
  114 + * @return mixed
  115 + */
  116 + public function actionUpdate($id)
  117 + {
  118 + $model = $this->findModel($id);
  119 + $model_langs = $model->generateLangs();
  120 +
  121 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  122 + $model->loadLangs(\Yii::$app->request, $model_langs);
  123 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  124 + return $this->redirect([
  125 + 'view',
  126 + 'id' => $model->banner_id,
  127 + ]);
  128 + }
  129 + }
123 130 return $this->render('update', [
124   - 'model' => $model,
  131 + 'model' => $model,
  132 + 'model_langs' => $model_langs,
125 133 ]);
126 134 }
127   - }
128   -
129   - /**
130   - * Deletes an existing Banner model.
131   - * If deletion is successful, the browser will be redirected to the 'index' page.
132   - * @param integer $id
133   - * @return mixed
134   - */
135   - public function actionDelete($id)
136   - {
137   - $this->findModel($id)->delete();
138   -
139   - return $this->redirect(['index']);
140   - }
141   -
142   - /**
143   - * Finds the Banner model based on its primary key value.
144   - * If the model is not found, a 404 HTTP exception will be thrown.
145   - * @param integer $id
146   - * @return Banner the loaded model
147   - * @throws NotFoundHttpException if the model cannot be found
148   - */
149   - protected function findModel($id)
150   - {
151   - if (($model = Banner::findOne($id)) !== null) {
152   - return $model;
153   - } else {
154   - throw new NotFoundHttpException('The requested page does not exist.');
  135 +
  136 + /**
  137 + * Deletes an existing Banner model.
  138 + * If deletion is successful, the browser will be redirected to the 'index' page.
  139 + *
  140 + * @param integer $id
  141 + *
  142 + * @return mixed
  143 + */
  144 + public function actionDelete($id)
  145 + {
  146 + $this->findModel($id)
  147 + ->delete();
  148 +
  149 + return $this->redirect([ 'index' ]);
  150 + }
  151 +
  152 + /**
  153 + * Finds the Banner model based on its primary key value.
  154 + * If the model is not found, a 404 HTTP exception will be thrown.
  155 + *
  156 + * @param integer $id
  157 + *
  158 + * @return Banner the loaded model
  159 + * @throws NotFoundHttpException if the model cannot be found
  160 + */
  161 + protected function findModel($id)
  162 + {
  163 + if(( $model = Banner::findOne($id) ) !== NULL) {
  164 + return $model;
  165 + } else {
  166 + throw new NotFoundHttpException('The requested page does not exist.');
  167 + }
155 168 }
156 169 }
157   -}
... ...
backend/controllers/BgController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Bg;
7   -use common\models\BgSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * BgController implements the CRUD actions for Bg model.
14   - */
15   -class BgController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Bg;
  7 + use common\models\BgSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * BgController implements the CRUD actions for Bg model.
19 15 */
20   - public function behaviors()
  16 + class BgController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   - 'actions' => [
38   - 'delete' => ['POST'],
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
39 38 ],
40   - ],
41   - ];
42   - }
43   -
44   - /**
45   - * Lists all Bg models.
46   - * @return mixed
47   - */
48   - public function actionIndex()
49   - {
50   - $searchModel = new BgSearch();
51   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
52   -
53   - return $this->render('index', [
54   - 'searchModel' => $searchModel,
55   - 'dataProvider' => $dataProvider,
56   - ]);
57   - }
58   -
59   - /**
60   - * Displays a single Bg model.
61   - * @param integer $id
62   - * @return mixed
63   - */
64   - public function actionView($id)
65   - {
66   - return $this->render('view', [
67   - 'model' => $this->findModel($id),
68   - ]);
69   - }
70   -
71   - /**
72   - * Creates a new Bg model.
73   - * If creation is successful, the browser will be redirected to the 'view' page.
74   - * @return mixed
75   - */
76   - public function actionCreate()
77   - {
78   - $model = new Bg();
79   -
80   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
81   - return $this->redirect(['view', 'id' => $model->id]);
82   - } else {
83   - return $this->render('create', [
84   - 'model' => $model,
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 + 'actions' => [
  42 + 'delete' => [ 'POST' ],
  43 + ],
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + /**
  49 + * Lists all Bg models.
  50 + * @return mixed
  51 + */
  52 + public function actionIndex()
  53 + {
  54 + $searchModel = new BgSearch();
  55 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  56 +
  57 + return $this->render('index', [
  58 + 'searchModel' => $searchModel,
  59 + 'dataProvider' => $dataProvider,
85 60 ]);
86 61 }
87   - }
88   -
89   - /**
90   - * Updates an existing Bg model.
91   - * If update is successful, the browser will be redirected to the 'view' page.
92   - * @param integer $id
93   - * @return mixed
94   - */
95   - public function actionUpdate($id)
96   - {
97   - $model = $this->findModel($id);
98   -
99   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
100   - return $this->redirect(['view', 'id' => $model->id]);
101   - } else {
  62 +
  63 + /**
  64 + * Displays a single Bg model.
  65 + *
  66 + * @param integer $id
  67 + *
  68 + * @return mixed
  69 + */
  70 + public function actionView($id)
  71 + {
  72 + return $this->render('view', [
  73 + 'model' => $this->findModel($id),
  74 + ]);
  75 + }
  76 +
  77 + /**
  78 + * Creates a new Bg model.
  79 + * If creation is successful, the browser will be redirected to the 'view' page.
  80 + * @return mixed
  81 + */
  82 + public function actionCreate()
  83 + {
  84 + $model = new Bg();
  85 + $model_langs = $model->generateLangs();
  86 +
  87 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  88 + $model->loadLangs(\Yii::$app->request, $model_langs);
  89 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  90 + return $this->redirect([
  91 + 'view',
  92 + 'id' => $model->id,
  93 + ]);
  94 + } else {
  95 + return $this->redirect([
  96 + 'update',
  97 + 'id' => $model->id,
  98 + ]);
  99 + }
  100 + } else {
  101 + return $this->render('create', [
  102 + 'model' => $model,
  103 + 'model_langs' => $model_langs,
  104 + ]);
  105 + }
  106 + }
  107 +
  108 + /**
  109 + * Updates an existing Bg model.
  110 + * If update is successful, the browser will be redirected to the 'view' page.
  111 + *
  112 + * @param integer $id
  113 + *
  114 + * @return mixed
  115 + */
  116 + public function actionUpdate($id)
  117 + {
  118 + $model = $this->findModel($id);
  119 + $model_langs = $model->generateLangs();
  120 +
  121 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  122 + $model->loadLangs(\Yii::$app->request);
  123 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  124 + return $this->redirect([
  125 + 'view',
  126 + 'id' => $model->id,
  127 + ]);
  128 + }
  129 + }
102 130 return $this->render('update', [
103   - 'model' => $model,
  131 + 'model' => $model,
  132 + 'model_langs' => $model_langs,
104 133 ]);
105 134 }
106   - }
107   -
108   - /**
109   - * Deletes an existing Bg model.
110   - * If deletion is successful, the browser will be redirected to the 'index' page.
111   - * @param integer $id
112   - * @return mixed
113   - */
114   - public function actionDelete($id)
115   - {
116   - $this->findModel($id)->delete();
117   -
118   - return $this->redirect(['index']);
119   - }
120   -
121   - /**
122   - * Finds the Bg model based on its primary key value.
123   - * If the model is not found, a 404 HTTP exception will be thrown.
124   - * @param integer $id
125   - * @return Bg the loaded model
126   - * @throws NotFoundHttpException if the model cannot be found
127   - */
128   - protected function findModel($id)
129   - {
130   - if (($model = Bg::findOne($id)) !== null) {
131   - return $model;
132   - } else {
133   - throw new NotFoundHttpException('The requested page does not exist.');
  135 +
  136 + /**
  137 + * Deletes an existing Bg model.
  138 + * If deletion is successful, the browser will be redirected to the 'index' page.
  139 + *
  140 + * @param integer $id
  141 + *
  142 + * @return mixed
  143 + */
  144 + public function actionDelete($id)
  145 + {
  146 + $this->findModel($id)
  147 + ->delete();
  148 +
  149 + return $this->redirect([ 'index' ]);
  150 + }
  151 +
  152 + /**
  153 + * Finds the Bg model based on its primary key value.
  154 + * If the model is not found, a 404 HTTP exception will be thrown.
  155 + *
  156 + * @param integer $id
  157 + *
  158 + * @return Bg the loaded model
  159 + * @throws NotFoundHttpException if the model cannot be found
  160 + */
  161 + protected function findModel($id)
  162 + {
  163 + if(( $model = Bg::findOne($id) ) !== NULL) {
  164 + return $model;
  165 + } else {
  166 + throw new NotFoundHttpException('The requested page does not exist.');
  167 + }
134 168 }
135 169 }
136   -}
... ...
backend/controllers/BrandController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\modules\product\models\Brand;
7   -use common\modules\product\models\BrandSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use yii\filters\AccessControl;
12   -use yii\web\UploadedFile;
13   -
14   -/**
15   - * BrandController implements the CRUD actions for Brand model.
16   - */
17   -class BrandController extends Controller
18   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\modules\product\models\Brand;
  7 + use common\modules\product\models\BrandSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use yii\filters\AccessControl;
  12 + use yii\web\UploadedFile;
  13 +
19 14 /**
20   - * @inheritdoc
  15 + * BrandController implements the CRUD actions for Brand model.
21 16 */
22   - public function behaviors()
  17 + class BrandController extends Controller
23 18 {
24   - return [
25   - 'access' => [
26   - 'class' => AccessControl::className(),
27   - 'rules' => [
28   - [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ],
32   - [
33   - 'actions' => ['logout', 'index', 'create', 'update', 'view', 'delete'],
34   - 'allow' => true,
35   - 'roles' => ['@'],
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function behaviors()
  24 + {
  25 + return [
  26 + 'access' => [
  27 + 'class' => AccessControl::className(),
  28 + 'rules' => [
  29 + [
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + [
  37 + 'actions' => [
  38 + 'logout',
  39 + 'index',
  40 + 'create',
  41 + 'update',
  42 + 'view',
  43 + 'delete',
  44 + ],
  45 + 'allow' => true,
  46 + 'roles' => [ '@' ],
  47 + ],
36 48 ],
37 49 ],
38   - ],
39   - 'verbs' => [
40   - 'class' => VerbFilter::className(),
41   - 'actions' => [
42   - 'logout' => ['post'],
  50 + 'verbs' => [
  51 + 'class' => VerbFilter::className(),
  52 + 'actions' => [
  53 + 'logout' => [ 'post' ],
  54 + ],
43 55 ],
44   - ],
45   - ];
46   - }
47   -
48   - /**
49   - * Lists all Brand models.
50   - * @return mixed
51   - */
52   - public function actionIndex()
53   - {
54   - $searchModel = new BrandSearch();
55   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
56   -
57   - return $this->render('index', [
58   - 'searchModel' => $searchModel,
59   - 'dataProvider' => $dataProvider,
60   - ]);
61   - }
62   -
63   - /**
64   - * Displays a single Brand model.
65   - * @param integer $id
66   - * @return mixed
67   - */
68   - public function actionView($id)
69   - {
70   - return $this->render('view', [
71   - 'model' => $this->findModel($id),
72   - ]);
73   - }
74   -
75   - /**
76   - * Creates a new Brand model.
77   - * If creation is successful, the browser will be redirected to the 'view' page.
78   - * @return mixed
79   - */
80   - public function actionCreate()
81   - {
82   - $model = new Brand();
83   - if ($model->load(Yii::$app->request->post())) {
84   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
85   - $model->image = $image->name;
86   - }
87   - if ($model->save() && $image) {
88   -
89   - $imgDir = Yii::getAlias('@storage/brand/');
90   -
91   - if(!is_dir($imgDir)) {
92   - mkdir($imgDir, 0755, true);
  56 + ];
  57 + }
  58 +
  59 + /**
  60 + * Lists all Brand models.
  61 + * @return mixed
  62 + */
  63 + public function actionIndex()
  64 + {
  65 + $searchModel = new BrandSearch();
  66 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  67 +
  68 + return $this->render('index', [
  69 + 'searchModel' => $searchModel,
  70 + 'dataProvider' => $dataProvider,
  71 + ]);
  72 + }
  73 +
  74 + /**
  75 + * Displays a single Brand model.
  76 + *
  77 + * @param integer $id
  78 + *
  79 + * @return mixed
  80 + */
  81 + public function actionView($id)
  82 + {
  83 + return $this->render('view', [
  84 + 'model' => $this->findModel($id),
  85 + ]);
  86 + }
  87 +
  88 + /**
  89 + * Creates a new Brand model.
  90 + * If creation is successful, the browser will be redirected to the 'view' page.
  91 + * @return mixed
  92 + */
  93 + public function actionCreate()
  94 + {
  95 + $model = new Brand();
  96 + $model_langs = $model->generateLangs();
  97 + if($model->load(Yii::$app->request->post())) {
  98 + $model->loadLangs(\Yii::$app->request, $model_langs);
  99 + if($model->save()) {
  100 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  101 + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([
  102 + 'view',
  103 + 'id' => $model->brand_id,
  104 + ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams));
  105 + }
  106 + } else {
  107 + return $this->redirect('update', [
  108 + 'id' => $model->brand_id,
  109 + ]);
93 110 }
94   -
95   - $image->saveAs(Yii::getAlias('@storage/brand/' . $image->name));
96 111 }
97   -
98   - return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->brand_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams));
99   - } else {
100 112 return $this->render('create', [
101   - 'model' => $model,
  113 + 'model' => $model,
  114 + 'model_langs' => $model_langs,
102 115 ]);
103 116 }
104   - }
105   -
106   - /**
107   - * Updates an existing Brand model.
108   - * If update is successful, the browser will be redirected to the 'view' page.
109   - * @param integer $id
110   - * @return mixed
111   - */
112   - public function actionUpdate($id)
113   - {
114   - $model = $this->findModel($id);
115   -
116   - if ($model->load(Yii::$app->request->post())) {
117   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
118   - $model->image = $image->name;
119   - }
120   - if ($model->save() && $image) {
121   -
122   - $imgDir = Yii::getAlias('@storage/brands/');
123   -
124   - if(!is_dir($imgDir)) {
125   - mkdir($imgDir, 0755, true);
  117 +
  118 + /**
  119 + * Updates an existing Brand model.
  120 + * If update is successful, the browser will be redirected to the 'view' page.
  121 + *
  122 + * @param integer $id
  123 + *
  124 + * @return mixed
  125 + */
  126 + public function actionUpdate($id)
  127 + {
  128 + $model = $this->findModel($id);
  129 + $model_langs = $model->generateLangs();
  130 +
  131 + if($model->load(Yii::$app->request->post())) {
  132 + $model->loadLangs(\Yii::$app->request, $model_langs);
  133 + if($model->save()) {
  134 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  135 + return $this->redirect([
  136 + 'view',
  137 + 'id' => $model->brand_id,
  138 + ]);
  139 + }
126 140 }
127   -
128   - $image->saveAs(Yii::getAlias('@storage/brands/' . $image->name));
129 141 }
130   -
131   - return $this->redirect(['view', 'id' => $model->brand_id]);
132   - } else {
133 142 return $this->render('update', [
134   - 'model' => $model,
  143 + 'model' => $model,
  144 + 'model_langs' => $model_langs,
135 145 ]);
136 146 }
137   - }
138   -
139   - /**
140   - * Deletes an existing Brand model.
141   - * If deletion is successful, the browser will be redirected to the 'index' page.
142   - * @param integer $id
143   - * @return mixed
144   - */
145   - public function actionDelete($id)
146   - {
147   - $this->findModel($id)->delete();
148   -
149   - return $this->redirect(['index']);
150   - }
151   -
152   - /**
153   - * Finds the Brand model based on its primary key value.
154   - * If the model is not found, a 404 HTTP exception will be thrown.
155   - * @param integer $id
156   - * @return Brand the loaded model
157   - * @throws NotFoundHttpException if the model cannot be found
158   - */
159   - protected function findModel($id)
160   - {
161   - if (($model = Brand::findOne($id)) !== null) {
162   - return $model;
163   - } else {
164   - throw new NotFoundHttpException('The requested page does not exist.');
  147 +
  148 + /**
  149 + * Deletes an existing Brand model.
  150 + * If deletion is successful, the browser will be redirected to the 'index' page.
  151 + *
  152 + * @param integer $id
  153 + *
  154 + * @return mixed
  155 + */
  156 + public function actionDelete($id)
  157 + {
  158 + $this->findModel($id)
  159 + ->delete();
  160 +
  161 + return $this->redirect([ 'index' ]);
  162 + }
  163 +
  164 + /**
  165 + * Finds the Brand model based on its primary key value.
  166 + * If the model is not found, a 404 HTTP exception will be thrown.
  167 + *
  168 + * @param integer $id
  169 + *
  170 + * @return Brand the loaded model
  171 + * @throws NotFoundHttpException if the model cannot be found
  172 + */
  173 + protected function findModel($id)
  174 + {
  175 + if(( $model = Brand::findOne($id) ) !== NULL) {
  176 + return $model;
  177 + } else {
  178 + throw new NotFoundHttpException('The requested page does not exist.');
  179 + }
165 180 }
166 181 }
167   -}
... ...
backend/controllers/CategoryController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -use developeruz\db_rbac\behaviors\AccessBehavior;
5   -use common\components\artboxtree\ArtboxTreeHelper;
6   -use Yii;
7   -use common\modules\product\models\Category;
8   -use common\modules\product\models\CategorySearch;
9   -use yii\helpers\ArrayHelper;
10   -use yii\web\Controller;
11   -use yii\web\NotFoundHttpException;
12   -use yii\filters\VerbFilter;
13   -use yii\filters\AccessControl;
14   -use yii\web\UploadedFile;
15   -
16   -/**
17   - * CategoryController implements the CRUD actions for Category model.
18   - */
19   -class CategoryController extends Controller
20   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use developeruz\db_rbac\behaviors\AccessBehavior;
  6 + use common\components\artboxtree\ArtboxTreeHelper;
  7 + use Yii;
  8 + use common\modules\product\models\Category;
  9 + use common\modules\product\models\CategorySearch;
  10 + use yii\web\Controller;
  11 + use yii\web\NotFoundHttpException;
  12 + use yii\filters\VerbFilter;
  13 + use yii\web\UploadedFile;
  14 +
21 15 /**
22   - * @inheritdoc
  16 + * CategoryController implements the CRUD actions for Category model.
23 17 */
24   - public function behaviors()
  18 + class CategoryController extends Controller
25 19 {
26   - return [
27   - 'access'=>[
28   - 'class' => AccessBehavior::className(),
29   - 'rules' =>
30   - ['site' =>
31   - [
  20 +
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public function behaviors()
  25 + {
  26 + return [
  27 + 'access' => [
  28 + 'class' => AccessBehavior::className(),
  29 + 'rules' => [
  30 + 'site' => [
32 31 [
33   - 'actions' => ['login', 'error'],
34   - 'allow' => true,
35   - ]
36   - ]
37   - ]
38   - ],
39   - 'verbs' => [
40   - 'class' => VerbFilter::className(),
41   - 'actions' => [
42   - 'logout' => ['post'],
  32 + 'actions' => [
  33 + 'login',
  34 + 'error',
  35 + ],
  36 + 'allow' => true,
  37 + ],
  38 + ],
  39 + ],
43 40 ],
44   - ],
45   - ];
46   - }
47   -
48   - /**
49   - * Lists all Category models.
50   - * @return mixed
51   - */
52   - public function actionIndex()
53   - {
54   - $searchModel = new CategorySearch();
55   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
56   -
57   - return $this->render('index', [
58   - 'searchModel' => $searchModel,
59   - 'dataProvider' => $dataProvider,
60   - ]);
61   - }
62   -
63   - /**
64   - * Displays a single Category model.
65   - * @param integer $id
66   - * @return mixed
67   - */
68   - public function actionView($id)
69   - {
70   - return $this->render('view', [
71   - 'model' => $this->findModel($id),
72   - ]);
73   - }
74   -
75   - /**
76   - * Creates a new Category model.
77   - * If creation is successful, the browser will be redirected to the 'view' page.
78   - * @return mixed
79   - */
80   - public function actionCreate()
81   - {
82   - $model = new Category();
83   -
84   - if ($model->load(Yii::$app->request->post())) {
85   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
86   - $model->image = $image->name;
87   - }
88   -
89   - if ($model->save() && $image) {
90   - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));
  41 + 'verbs' => [
  42 + 'class' => VerbFilter::className(),
  43 + 'actions' => [
  44 + 'logout' => [ 'post' ],
  45 + ],
  46 + ],
  47 + ];
  48 + }
  49 +
  50 + /**
  51 + * Lists all Category models.
  52 + * @return mixed
  53 + */
  54 + public function actionIndex()
  55 + {
  56 + $searchModel = new CategorySearch();
  57 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  58 +
  59 + return $this->render('index', [
  60 + 'searchModel' => $searchModel,
  61 + 'dataProvider' => $dataProvider,
  62 + ]);
  63 + }
  64 +
  65 + /**
  66 + * Displays a single Category model.
  67 + *
  68 + * @param integer $id
  69 + *
  70 + * @return mixed
  71 + */
  72 + public function actionView($id)
  73 + {
  74 + return $this->render('view', [
  75 + 'model' => $this->findModel($id),
  76 + ]);
  77 + }
  78 +
  79 + /**
  80 + * Creates a new Category model.
  81 + * If creation is successful, the browser will be redirected to the 'view' page.
  82 + * @return mixed
  83 + */
  84 + public function actionCreate()
  85 + {
  86 + $model = new Category();
  87 + $model_langs = $model->generateLangs();
  88 +
  89 + if($model->load(Yii::$app->request->post())) {
  90 + $model->loadLangs(\Yii::$app->request, $model_langs);
  91 + if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {
  92 + $model->image = $image->name;
  93 + }
  94 +
  95 + if($model->save()) {
  96 + if($image) {
  97 + $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));
  98 + }
  99 +
  100 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  101 + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([
  102 + 'view',
  103 + 'id' => $model->category_id,
  104 + ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams));
  105 + } else {
  106 + return $this->redirect('update', [
  107 + 'id' => $model->category_id,
  108 + ]);
  109 + }
  110 + }
  111 +
91 112 }
92   -
93   - return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->category_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams));
94   - } else {
95   - if (!empty(Yii::$app->request->queryParams['parent'])) {
96   - $model->parent_id = Yii::$app->request->queryParams['parent'];
  113 + if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) {
  114 + $model->parent_id = Yii::$app->request->queryParams[ 'parent' ];
97 115 }
98 116 return $this->render('create', [
99   - 'model' => $model,
100   - 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
  117 + 'model' => $model,
  118 + 'model_langs' => $model_langs,
  119 + 'categories' => ArtboxTreeHelper::treeMap(Category::find()
  120 + ->getTree(), 'category_id', 'name', '.'),
101 121 ]);
102 122 }
103   - }
104   -
105   - /**
106   - * Updates an existing Category model.
107   - * If update is successful, the browser will be redirected to the 'view' page.
108   - * @param integer $id
109   - * @return mixed
110   - */
111   - public function actionUpdate($id)
112   - {
113   - $model = $this->findModel($id);
114   -
115   - if ($model->load(Yii::$app->request->post())) {
116   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
117   - $model->image = $image->name;
118   - }
119   -
120   - if ($model->save() && $image) {
121   - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));
  123 +
  124 + /**
  125 + * Updates an existing Category model.
  126 + * If update is successful, the browser will be redirected to the 'view' page.
  127 + *
  128 + * @param integer $id
  129 + *
  130 + * @return mixed
  131 + */
  132 + public function actionUpdate($id)
  133 + {
  134 + $model = $this->findModel($id);
  135 +
  136 + $model_langs = $model->generateLangs();
  137 +
  138 + 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);
  143 + 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)) {
  148 + return $this->redirect([
  149 + 'view',
  150 + 'id' => $model->category_id,
  151 + ]);
  152 + }
  153 + }
122 154 }
123   -
124   - return $this->redirect(['view', 'id' => $model->category_id]);
125   - } else {
126 155 return $this->render('update', [
127   - 'model' => $model,
128   - 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
  156 + 'model' => $model,
  157 + 'model_langs' => $model_langs,
  158 + 'categories' => ArtboxTreeHelper::treeMap(Category::find()
  159 + ->getTree(), 'category_id', 'name', '.'),
129 160 ]);
130 161 }
131   - }
132   -
133   - /**
134   - * Deletes an existing Category model.
135   - * If deletion is successful, the browser will be redirected to the 'index' page.
136   - * @param integer $id
137   - * @return mixed
138   - */
139   - public function actionDelete($id)
140   - {
141   - $this->findModel($id)->delete();
142   -
143   - return $this->redirect(['index']);
144   - }
145   -
146   - /**
147   - * Finds the Category model based on its primary key value.
148   - * If the model is not found, a 404 HTTP exception will be thrown.
149   - * @param integer $id
150   - * @return Category the loaded model
151   - * @throws NotFoundHttpException if the model cannot be found
152   - */
153   - protected function findModel($id)
154   - {
155   - if (($model = Category::findOne($id)) !== null) {
156   - return $model;
157   - } else {
158   - throw new NotFoundHttpException('The requested page does not exist.');
  162 +
  163 + /**
  164 + * Deletes an existing Category model.
  165 + * If deletion is successful, the browser will be redirected to the 'index' page.
  166 + *
  167 + * @param integer $id
  168 + *
  169 + * @return mixed
  170 + */
  171 + public function actionDelete($id)
  172 + {
  173 + $this->findModel($id)
  174 + ->delete();
  175 +
  176 + return $this->redirect([ 'index' ]);
  177 + }
  178 +
  179 + /**
  180 + * Finds the Category model based on its primary key value.
  181 + * If the model is not found, a 404 HTTP exception will be thrown.
  182 + *
  183 + * @param integer $id
  184 + *
  185 + * @return Category the loaded model
  186 + * @throws NotFoundHttpException if the model cannot be found
  187 + */
  188 + protected function findModel($id)
  189 + {
  190 + if(( $model = Category::findOne($id) ) !== NULL) {
  191 + return $model;
  192 + } else {
  193 + throw new NotFoundHttpException('The requested page does not exist.');
  194 + }
159 195 }
160 196 }
161   -}
... ...
backend/controllers/EventController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Event;
7   -use common\models\EventSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -use yii\web\UploadedFile;
13   -
14   -/**
15   - * EventController implements the CRUD actions for Event model.
16   - */
17   -class EventController extends Controller
18   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Event;
  7 + use common\models\EventSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 + use yii\web\UploadedFile;
  13 +
19 14 /**
20   - * @inheritdoc
  15 + * EventController implements the CRUD actions for Event model.
21 16 */
22   - public function behaviors()
  17 + class EventController extends Controller
23 18 {
24   - return [
25   - 'access'=>[
26   - 'class' => AccessBehavior::className(),
27   - 'rules' =>
28   - ['site' =>
29   - [
  19 +
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function behaviors()
  24 + {
  25 + return [
  26 + 'access' => [
  27 + 'class' => AccessBehavior::className(),
  28 + 'rules' => [
  29 + 'site' => [
30 30 [
31   - 'actions' => ['login', 'error'],
32   - 'allow' => true,
33   - ]
34   - ]
35   - ]
36   - ],
37   - 'verbs' => [
38   - 'class' => VerbFilter::className(),
39   - 'actions' => [
40   - 'delete' => ['POST'],
  31 + 'actions' => [
  32 + 'login',
  33 + 'error',
  34 + ],
  35 + 'allow' => true,
  36 + ],
  37 + ],
  38 + ],
41 39 ],
42   - ],
43   - ];
44   - }
45   -
46   - /**
47   - * Lists all Event models.
48   - * @return mixed
49   - */
50   - public function actionIndex()
51   - {
52   - $searchModel = new EventSearch();
53   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
54   -
55   - return $this->render('index', [
56   - 'searchModel' => $searchModel,
57   - 'dataProvider' => $dataProvider,
58   - ]);
59   - }
60   -
61   - /**
62   - * Displays a single Event model.
63   - * @param integer $id
64   - * @return mixed
65   - */
66   - public function actionView($id)
67   - {
68   - return $this->render('view', [
69   - 'model' => $this->findModel($id),
70   - ]);
71   - }
72   -
73   - /**
74   - * Creates a new Event model.
75   - * If creation is successful, the browser will be redirected to the 'view' page.
76   - * @return mixed
77   - */
78   - public function actionCreate()
79   - {
80   - $model = new Event();
81   -
82   - if ($model->load(Yii::$app->request->post())) {
83   -
84   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
85   - $model->image = $image->name;
86   - }
87   -
88   - if ($model->save() && $image) {
89   - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  40 + 'verbs' => [
  41 + 'class' => VerbFilter::className(),
  42 + 'actions' => [
  43 + 'delete' => [ 'POST' ],
  44 + ],
  45 + ],
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * Lists all Event models.
  51 + * @return mixed
  52 + */
  53 + public function actionIndex()
  54 + {
  55 + $searchModel = new EventSearch();
  56 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  57 +
  58 + return $this->render('index', [
  59 + 'searchModel' => $searchModel,
  60 + 'dataProvider' => $dataProvider,
  61 + ]);
  62 + }
  63 +
  64 + /**
  65 + * Displays a single Event model.
  66 + *
  67 + * @param integer $id
  68 + *
  69 + * @return mixed
  70 + */
  71 + public function actionView($id)
  72 + {
  73 + return $this->render('view', [
  74 + 'model' => $this->findModel($id),
  75 + ]);
  76 + }
  77 +
  78 + /**
  79 + * Creates a new Event model.
  80 + * If creation is successful, the browser will be redirected to the 'view' page.
  81 + * @return mixed
  82 + */
  83 + public function actionCreate()
  84 + {
  85 + $model = new Event();
  86 + $model_langs = $model->generateLangs();
  87 +
  88 + if($model->load(Yii::$app->request->post())) {
  89 +
  90 + $model->loadLangs(\Yii::$app->request, $model_langs);
  91 +
  92 + if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {
  93 + $model->image = $image->name;
  94 + }
  95 +
  96 + 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)) {
  101 + return $this->redirect([
  102 + 'view',
  103 + 'id' => $model->event_id,
  104 + ]);
  105 + } else {
  106 + return $this->redirect([
  107 + 'update',
  108 + 'id' => $model->event_id,
  109 + ]);
  110 + }
  111 + }
90 112 }
91   -
92   - return $this->redirect(['view', 'id' => $model->event_id]);
93   - } else {
94 113 return $this->render('create', [
95   - 'model' => $model,
  114 + 'model' => $model,
  115 + 'model_langs' => $model_langs,
96 116 ]);
97 117 }
98   - }
99   -
100   - /**
101   - * Updates an existing Event model.
102   - * If update is successful, the browser will be redirected to the 'view' page.
103   - * @param integer $id
104   - * @return mixed
105   - */
106   - public function actionUpdate($id)
107   - {
108   - $model = $this->findModel($id);
109   -
110   - if ($model->load(Yii::$app->request->post())) {
111   -
112   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
113   - $model->image = $image->name;
114   - }
115   -
116   - if ($model->save() && $image) {
117   - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  118 +
  119 + /**
  120 + * Updates an existing Event model.
  121 + * If update is successful, the browser will be redirected to the 'view' page.
  122 + *
  123 + * @param integer $id
  124 + *
  125 + * @return mixed
  126 + */
  127 + public function actionUpdate($id)
  128 + {
  129 + $model = $this->findModel($id);
  130 + $model_langs = $model->generateLangs();
  131 +
  132 + if($model->load(Yii::$app->request->post())) {
  133 +
  134 + $model->loadLangs(\Yii::$app->request, $model_langs);
  135 +
  136 + if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) {
  137 + $model->image = $image->name;
  138 + }
  139 +
  140 + 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)) {
  145 + return $this->redirect([
  146 + 'view',
  147 + 'id' => $model->event_id,
  148 + ]);
  149 + }
  150 + }
118 151 }
119   -
120   - return $this->redirect(['view', 'id' => $model->event_id]);
121   - } else {
122 152 return $this->render('update', [
123   - 'model' => $model,
  153 + 'model' => $model,
  154 + 'model_langs' => $model_langs,
124 155 ]);
125 156 }
126   - }
127   -
128   - /**
129   - * Deletes an existing Event model.
130   - * If deletion is successful, the browser will be redirected to the 'index' page.
131   - * @param integer $id
132   - * @return mixed
133   - */
134   - public function actionDelete($id)
135   - {
136   - $this->findModel($id)->delete();
137   -
138   - return $this->redirect(['index']);
139   - }
140   -
141   - /**
142   - * Finds the Event model based on its primary key value.
143   - * If the model is not found, a 404 HTTP exception will be thrown.
144   - * @param integer $id
145   - * @return Event the loaded model
146   - * @throws NotFoundHttpException if the model cannot be found
147   - */
148   - protected function findModel($id)
149   - {
150   - if (($model = Event::findOne($id)) !== null) {
151   - return $model;
152   - } else {
153   - throw new NotFoundHttpException('The requested page does not exist.');
  157 +
  158 + /**
  159 + * Deletes an existing Event model.
  160 + * If deletion is successful, the browser will be redirected to the 'index' page.
  161 + *
  162 + * @param integer $id
  163 + *
  164 + * @return mixed
  165 + */
  166 + public function actionDelete($id)
  167 + {
  168 + $this->findModel($id)
  169 + ->delete();
  170 +
  171 + return $this->redirect([ 'index' ]);
  172 + }
  173 +
  174 + /**
  175 + * Finds the Event model based on its primary key value.
  176 + * If the model is not found, a 404 HTTP exception will be thrown.
  177 + *
  178 + * @param integer $id
  179 + *
  180 + * @return Event the loaded model
  181 + * @throws NotFoundHttpException if the model cannot be found
  182 + */
  183 + protected function findModel($id)
  184 + {
  185 + if(( $model = Event::findOne($id) ) !== NULL) {
  186 + return $model;
  187 + } else {
  188 + throw new NotFoundHttpException('The requested page does not exist.');
  189 + }
154 190 }
155 191 }
156   -}
... ...
backend/controllers/PageController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Page;
7   -use common\models\PageSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * PageController implements the CRUD actions for Page model.
14   - */
15   -class PageController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Page;
  7 + use common\models\PageSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * PageController implements the CRUD actions for Page model.
19 15 */
20   - public function behaviors()
  16 + class PageController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   - 'actions' => [
38   - 'delete' => ['POST'],
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
39 38 ],
40   - ],
41   - ];
42   - }
43   -
44   - /**
45   - * Lists all Page models.
46   - * @return mixed
47   - */
48   - public function actionIndex()
49   - {
50   - $searchModel = new PageSearch();
51   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
52   -
53   - return $this->render('index', [
54   - 'searchModel' => $searchModel,
55   - 'dataProvider' => $dataProvider,
56   - ]);
57   - }
58   -
59   - /**
60   - * Displays a single Page model.
61   - * @param integer $id
62   - * @return mixed
63   - */
64   - public function actionView($id)
65   - {
66   - return $this->render('view', [
67   - 'model' => $this->findModel($id),
68   - ]);
69   - }
70   -
71   - /**
72   - * Creates a new Page model.
73   - * If creation is successful, the browser will be redirected to the 'view' page.
74   - * @return mixed
75   - */
76   - public function actionCreate()
77   - {
78   - $model = new Page();
79   -
80   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
81   - return $this->redirect(['view', 'id' => $model->id]);
82   - } else {
83   - return $this->render('create', [
84   - 'model' => $model,
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 + 'actions' => [
  42 + 'delete' => [ 'POST' ],
  43 + ],
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + /**
  49 + * Lists all Page models.
  50 + * @return mixed
  51 + */
  52 + public function actionIndex()
  53 + {
  54 + $searchModel = new PageSearch();
  55 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  56 +
  57 + return $this->render('index', [
  58 + 'searchModel' => $searchModel,
  59 + 'dataProvider' => $dataProvider,
85 60 ]);
86 61 }
87   - }
88   -
89   - /**
90   - * Updates an existing Page model.
91   - * If update is successful, the browser will be redirected to the 'view' page.
92   - * @param integer $id
93   - * @return mixed
94   - */
95   - public function actionUpdate($id)
96   - {
97   - $model = $this->findModel($id);
98   -
99   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
100   - return $this->redirect(['view', 'id' => $model->id]);
101   - } else {
  62 +
  63 + /**
  64 + * Displays a single Page model.
  65 + *
  66 + * @param integer $id
  67 + *
  68 + * @return mixed
  69 + */
  70 + public function actionView($id)
  71 + {
  72 + return $this->render('view', [
  73 + 'model' => $this->findModel($id),
  74 + ]);
  75 + }
  76 +
  77 + /**
  78 + * Creates a new Page model.
  79 + * If creation is successful, the browser will be redirected to the 'view' page.
  80 + * @return mixed
  81 + */
  82 + public function actionCreate()
  83 + {
  84 + $model = new Page();
  85 + $model_langs = $model->generateLangs();
  86 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  87 + $model->loadLangs(\Yii::$app->request, $model_langs);
  88 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  89 + return $this->redirect([
  90 + 'view',
  91 + 'id' => $model->id,
  92 + ]);
  93 + } else {
  94 + return $this->redirect([
  95 + 'update',
  96 + 'id' => $model->id,
  97 + ]);
  98 + }
  99 + } else {
  100 + return $this->render('create', [
  101 + 'model' => $model,
  102 + 'model_langs' => $model_langs,
  103 + ]);
  104 + }
  105 + }
  106 +
  107 + /**
  108 + * Updates an existing Page model.
  109 + * If update is successful, the browser will be redirected to the 'view' page.
  110 + *
  111 + * @param integer $id
  112 + *
  113 + * @return mixed
  114 + */
  115 + public function actionUpdate($id)
  116 + {
  117 + $model = $this->findModel($id);
  118 + $model_langs = $model->generateLangs();
  119 +
  120 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  121 + $model->loadLangs(\Yii::$app->request, $model_langs);
  122 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  123 + return $this->redirect([
  124 + 'view',
  125 + 'id' => $model->id,
  126 + ]);
  127 + }
  128 + }
102 129 return $this->render('update', [
103   - 'model' => $model,
  130 + 'model' => $model,
  131 + 'model_langs' => $model_langs,
104 132 ]);
105 133 }
106   - }
107   -
108   - /**
109   - * Deletes an existing Page model.
110   - * If deletion is successful, the browser will be redirected to the 'index' page.
111   - * @param integer $id
112   - * @return mixed
113   - */
114   - public function actionDelete($id)
115   - {
116   - $this->findModel($id)->delete();
117   -
118   - return $this->redirect(['index']);
119   - }
120   -
121   - /**
122   - * Finds the Page model based on its primary key value.
123   - * If the model is not found, a 404 HTTP exception will be thrown.
124   - * @param integer $id
125   - * @return Page the loaded model
126   - * @throws NotFoundHttpException if the model cannot be found
127   - */
128   - protected function findModel($id)
129   - {
130   - if (($model = Page::findOne($id)) !== null) {
131   - return $model;
132   - } else {
133   - throw new NotFoundHttpException('The requested page does not exist.');
  134 +
  135 + /**
  136 + * Deletes an existing Page model.
  137 + * If deletion is successful, the browser will be redirected to the 'index' page.
  138 + *
  139 + * @param integer $id
  140 + *
  141 + * @return mixed
  142 + */
  143 + public function actionDelete($id)
  144 + {
  145 + $this->findModel($id)
  146 + ->delete();
  147 +
  148 + return $this->redirect([ 'index' ]);
  149 + }
  150 +
  151 + /**
  152 + * Finds the Page model based on its primary key value.
  153 + * If the model is not found, a 404 HTTP exception will be thrown.
  154 + *
  155 + * @param integer $id
  156 + *
  157 + * @return Page the loaded model
  158 + * @throws NotFoundHttpException if the model cannot be found
  159 + */
  160 + protected function findModel($id)
  161 + {
  162 + if(( $model = Page::findOne($id) ) !== NULL) {
  163 + return $model;
  164 + } else {
  165 + throw new NotFoundHttpException('The requested page does not exist.');
  166 + }
134 167 }
135 168 }
136   -}
... ...
backend/controllers/ProjectController.php
... ... @@ -88,7 +88,9 @@
88 88 public function actionCreate()
89 89 {
90 90 $model = new Project();
  91 + $model_langs = $model->generateLangs();
91 92 if($model->load(Yii::$app->request->post())) {
  93 + $model->loadLangs(\Yii::$app->request, $model_langs);
92 94 $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
93 95 if($model->save()) {
94 96 if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) {
... ... @@ -99,14 +101,22 @@
99 101 $imageModel->save();
100 102 }
101 103 }
102   - return $this->redirect([
103   - 'view',
104   - 'id' => $model->project_id,
105   - ]);
  104 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  105 + return $this->redirect([
  106 + 'view',
  107 + 'id' => $model->project_id,
  108 + ]);
  109 + } else {
  110 + return $this->redirect([
  111 + 'update',
  112 + 'id' => $model->project_id,
  113 + ]);
  114 + }
106 115 }
107 116 }
108 117 return $this->render('create', [
109   - 'model' => $model,
  118 + 'model' => $model,
  119 + 'model_langs' => $model_langs,
110 120 ]);
111 121 }
112 122  
... ... @@ -121,7 +131,9 @@
121 131 public function actionUpdate($id)
122 132 {
123 133 $model = $this->findModel($id);
  134 + $model_langs = $model->generateLangs();
124 135 if($model->load(Yii::$app->request->post())) {
  136 + $model->loadLangs(\Yii::$app->request, $model_langs);
125 137 $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
126 138 if($model->save()) {
127 139 if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) {
... ... @@ -132,14 +144,17 @@
132 144 $imageModel->save();
133 145 }
134 146 }
135   - return $this->redirect([
136   - 'view',
137   - 'id' => $model->project_id,
138   - ]);
  147 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  148 + return $this->redirect([
  149 + 'view',
  150 + 'id' => $model->project_id,
  151 + ]);
  152 + }
139 153 }
140 154 }
141 155 return $this->render('update', [
142   - 'model' => $model,
  156 + 'model' => $model,
  157 + 'model_langs' => $model_langs,
143 158 ]);
144 159 }
145 160  
... ... @@ -275,13 +290,18 @@
275 290  
276 291 public function actionProductDelete($product_to_project_id)
277 292 {
278   - $model = ProductToProject::find()->where(['product_to_project_id' => $product_to_project_id])->one();
279   - if(empty($model)) {
  293 + $model = ProductToProject::find()
  294 + ->where([ 'product_to_project_id' => $product_to_project_id ])
  295 + ->one();
  296 + if(empty( $model )) {
280 297 throw new NotFoundHttpException();
281 298 }
282 299 $project_id = $model->project_id;
283 300 $model->delete();
284   - return $this->redirect(['project/product', 'id' => $project_id]);
  301 + return $this->redirect([
  302 + 'project/product',
  303 + 'id' => $project_id,
  304 + ]);
285 305 }
286 306  
287 307 public function actionGetVariants($product_id)
... ...
backend/controllers/SeoCategoryController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\SeoCategory;
7   -use common\models\SeoCategorySearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * SeoCategoryController implements the CRUD actions for SeoCategory model.
14   - */
15   -class SeoCategoryController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\SeoCategory;
  7 + use common\models\SeoCategorySearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * SeoCategoryController implements the CRUD actions for SeoCategory model.
19 15 */
20   - public function behaviors()
  16 + class SeoCategoryController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   -
38   - ],
39   - ];
40   - }
41   -
42   - /**
43   - * Lists all SeoCategory models.
44   - * @return mixed
45   - */
46   - public function actionIndex()
47   - {
48   - $searchModel = new SeoCategorySearch();
49   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
50   -
51   - return $this->render('index', [
52   - 'searchModel' => $searchModel,
53   - 'dataProvider' => $dataProvider,
54   - ]);
55   - }
56   -
57   - /**
58   - * Displays a single SeoCategory model.
59   - * @param integer $id
60   - * @return mixed
61   - */
62   - public function actionView($id)
63   - {
64   - return $this->render('view', [
65   - 'model' => $this->findModel($id),
66   - ]);
67   - }
68   -
69   - /**
70   - * Creates a new SeoCategory model.
71   - * If creation is successful, the browser will be redirected to the 'view' page.
72   - * @return mixed
73   - */
74   - public function actionCreate()
75   - {
76   - $model = new SeoCategory();
77   -
78   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
79   - return $this->redirect(['view', 'id' => $model->seo_category_id]);
80   - } else {
81   - return $this->render('create', [
82   - 'model' => $model,
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
  38 + ],
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 +
  42 + ],
  43 + ];
  44 + }
  45 +
  46 + /**
  47 + * Lists all SeoCategory models.
  48 + * @return mixed
  49 + */
  50 + public function actionIndex()
  51 + {
  52 + $searchModel = new SeoCategorySearch();
  53 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  54 +
  55 + return $this->render('index', [
  56 + 'searchModel' => $searchModel,
  57 + 'dataProvider' => $dataProvider,
83 58 ]);
84 59 }
85   - }
86   -
87   - /**
88   - * Updates an existing SeoCategory model.
89   - * If update is successful, the browser will be redirected to the 'view' page.
90   - * @param integer $id
91   - * @return mixed
92   - */
93   - public function actionUpdate($id)
94   - {
95   - $model = $this->findModel($id);
96   -
97   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
98   - return $this->redirect(['view', 'id' => $model->seo_category_id]);
99   - } else {
  60 +
  61 + /**
  62 + * Displays a single SeoCategory model.
  63 + *
  64 + * @param integer $id
  65 + *
  66 + * @return mixed
  67 + */
  68 + public function actionView($id)
  69 + {
  70 + return $this->render('view', [
  71 + 'model' => $this->findModel($id),
  72 + ]);
  73 + }
  74 +
  75 + /**
  76 + * Creates a new SeoCategory model.
  77 + * If creation is successful, the browser will be redirected to the 'view' page.
  78 + * @return mixed
  79 + */
  80 + public function actionCreate()
  81 + {
  82 + $model = new SeoCategory();
  83 + $model_langs = $model->generateLangs();
  84 +
  85 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  86 + $model->loadLangs(\Yii::$app->request, $model_langs);
  87 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  88 + return $this->redirect([
  89 + 'view',
  90 + 'id' => $model->seo_category_id,
  91 + ]);
  92 + } else {
  93 + return $this->redirect([
  94 + 'update',
  95 + 'id' => $model->seo_category_id,
  96 + ]);
  97 + }
  98 + } else {
  99 + return $this->render('create', [
  100 + 'model' => $model,
  101 + 'model_langs' => $model_langs,
  102 + ]);
  103 + }
  104 + }
  105 +
  106 + /**
  107 + * Updates an existing SeoCategory model.
  108 + * If update is successful, the browser will be redirected to the 'view' page.
  109 + *
  110 + * @param integer $id
  111 + *
  112 + * @return mixed
  113 + */
  114 + public function actionUpdate($id)
  115 + {
  116 + $model = $this->findModel($id);
  117 + $model_langs = $model->generateLangs();
  118 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  119 + $model->loadLangs(\Yii::$app->request, $model_langs);
  120 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  121 + return $this->redirect([
  122 + 'view',
  123 + 'id' => $model->seo_category_id,
  124 + ]);
  125 + }
  126 + }
100 127 return $this->render('update', [
101   - 'model' => $model,
  128 + 'model' => $model,
  129 + 'model_langs' => $model_langs,
102 130 ]);
103 131 }
104   - }
105   -
106   - /**
107   - * Deletes an existing SeoCategory model.
108   - * If deletion is successful, the browser will be redirected to the 'index' page.
109   - * @param integer $id
110   - * @return mixed
111   - */
112   - public function actionDelete($id)
113   - {
114   - $this->findModel($id)->delete();
115   -
116   - return $this->redirect(['index']);
117   - }
118   -
119   - /**
120   - * Finds the SeoCategory model based on its primary key value.
121   - * If the model is not found, a 404 HTTP exception will be thrown.
122   - * @param integer $id
123   - * @return SeoCategory the loaded model
124   - * @throws NotFoundHttpException if the model cannot be found
125   - */
126   - protected function findModel($id)
127   - {
128   - if (($model = SeoCategory::findOne($id)) !== null) {
129   - return $model;
130   - } else {
131   - throw new NotFoundHttpException('The requested page does not exist.');
  132 +
  133 + /**
  134 + * Deletes an existing SeoCategory model.
  135 + * If deletion is successful, the browser will be redirected to the 'index' page.
  136 + *
  137 + * @param integer $id
  138 + *
  139 + * @return mixed
  140 + */
  141 + public function actionDelete($id)
  142 + {
  143 + $this->findModel($id)
  144 + ->delete();
  145 +
  146 + return $this->redirect([ 'index' ]);
  147 + }
  148 +
  149 + /**
  150 + * Finds the SeoCategory model based on its primary key value.
  151 + * If the model is not found, a 404 HTTP exception will be thrown.
  152 + *
  153 + * @param integer $id
  154 + *
  155 + * @return SeoCategory the loaded model
  156 + * @throws NotFoundHttpException if the model cannot be found
  157 + */
  158 + protected function findModel($id)
  159 + {
  160 + if(( $model = SeoCategory::findOne($id) ) !== NULL) {
  161 + return $model;
  162 + } else {
  163 + throw new NotFoundHttpException('The requested page does not exist.');
  164 + }
132 165 }
133 166 }
134   -}
... ...
backend/controllers/SeoController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Seo;
7   -use common\models\SeoSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * SeoController implements the CRUD actions for Seo model.
14   - */
15   -class SeoController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Seo;
  7 + use common\models\SeoSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * SeoController implements the CRUD actions for Seo model.
19 15 */
20   - public function behaviors()
  16 + class SeoController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   -
38   - ],
39   - ];
40   - }
41   -
42   - /**
43   - * Lists all Seo models.
44   - * @return mixed
45   - */
46   - public function actionIndex()
47   - {
48   - $searchModel = new SeoSearch();
49   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
50   -
51   - return $this->render('index', [
52   - 'searchModel' => $searchModel,
53   - 'dataProvider' => $dataProvider,
54   - ]);
55   - }
56   -
57   - /**
58   - * Displays a single Seo model.
59   - * @param integer $id
60   - * @return mixed
61   - */
62   - public function actionView($id)
63   - {
64   - return $this->render('view', [
65   - 'model' => $this->findModel($id),
66   - ]);
67   - }
68   -
69   - /**
70   - * Creates a new Seo model.
71   - * If creation is successful, the browser will be redirected to the 'view' page.
72   - * @return mixed
73   - */
74   - public function actionCreate()
75   - {
76   - $model = new Seo();
77   -
78   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
79   - return $this->redirect(['view', 'id' => $model->seo_id]);
80   - } else {
81   - return $this->render('create', [
82   - 'model' => $model,
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
  38 + ],
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 +
  42 + ],
  43 + ];
  44 + }
  45 +
  46 + /**
  47 + * Lists all Seo models.
  48 + * @return mixed
  49 + */
  50 + public function actionIndex()
  51 + {
  52 + $searchModel = new SeoSearch();
  53 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  54 +
  55 + return $this->render('index', [
  56 + 'searchModel' => $searchModel,
  57 + 'dataProvider' => $dataProvider,
83 58 ]);
84 59 }
85   - }
86   -
87   - /**
88   - * Updates an existing Seo model.
89   - * If update is successful, the browser will be redirected to the 'view' page.
90   - * @param integer $id
91   - * @return mixed
92   - */
93   - public function actionUpdate($id)
94   - {
95   - $model = $this->findModel($id);
96   -
97   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
98   - return $this->redirect(['view', 'id' => $model->seo_id]);
99   - } else {
  60 +
  61 + /**
  62 + * Displays a single Seo model.
  63 + *
  64 + * @param integer $id
  65 + *
  66 + * @return mixed
  67 + */
  68 + public function actionView($id)
  69 + {
  70 + return $this->render('view', [
  71 + 'model' => $this->findModel($id),
  72 + ]);
  73 + }
  74 +
  75 + /**
  76 + * Creates a new Seo model.
  77 + * If creation is successful, the browser will be redirected to the 'view' page.
  78 + * @return mixed
  79 + */
  80 + public function actionCreate()
  81 + {
  82 + $model = new Seo();
  83 + $model_langs = $model->generateLangs();
  84 +
  85 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  86 + $model->loadLangs(\Yii::$app->request, $model_langs);
  87 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  88 + return $this->redirect([
  89 + 'view',
  90 + 'id' => $model->seo_id,
  91 + ]);
  92 + } else {
  93 + return $this->redirect([
  94 + 'update',
  95 + 'id' => $model->seo_id,
  96 + ]);
  97 + }
  98 + } else {
  99 + return $this->render('create', [
  100 + 'model' => $model,
  101 + 'model_langs' => $model_langs,
  102 + ]);
  103 + }
  104 + }
  105 +
  106 + /**
  107 + * Updates an existing Seo model.
  108 + * If update is successful, the browser will be redirected to the 'view' page.
  109 + *
  110 + * @param integer $id
  111 + *
  112 + * @return mixed
  113 + */
  114 + public function actionUpdate($id)
  115 + {
  116 + $model = $this->findModel($id);
  117 + $model_langs = $model->generateLangs();
  118 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  119 + $model->loadLangs(\Yii::$app->request, $model_langs);
  120 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  121 + return $this->redirect([
  122 + 'view',
  123 + 'id' => $model->seo_id,
  124 + ]);
  125 + }
  126 + }
100 127 return $this->render('update', [
101   - 'model' => $model,
  128 + 'model' => $model,
  129 + 'model_langs' => $model_langs,
102 130 ]);
103 131 }
104   - }
105   -
106   - /**
107   - * Deletes an existing Seo model.
108   - * If deletion is successful, the browser will be redirected to the 'index' page.
109   - * @param integer $id
110   - * @return mixed
111   - */
112   - public function actionDelete($id)
113   - {
114   - $this->findModel($id)->delete();
115   -
116   - return $this->redirect(['index']);
117   - }
118   -
119   - /**
120   - * Finds the Seo model based on its primary key value.
121   - * If the model is not found, a 404 HTTP exception will be thrown.
122   - * @param integer $id
123   - * @return Seo the loaded model
124   - * @throws NotFoundHttpException if the model cannot be found
125   - */
126   - protected function findModel($id)
127   - {
128   - if (($model = Seo::findOne($id)) !== null) {
129   - return $model;
130   - } else {
131   - throw new NotFoundHttpException('The requested page does not exist.');
  132 +
  133 + /**
  134 + * Deletes an existing Seo model.
  135 + * If deletion is successful, the browser will be redirected to the 'index' page.
  136 + *
  137 + * @param integer $id
  138 + *
  139 + * @return mixed
  140 + */
  141 + public function actionDelete($id)
  142 + {
  143 + $this->findModel($id)
  144 + ->delete();
  145 +
  146 + return $this->redirect([ 'index' ]);
  147 + }
  148 +
  149 + /**
  150 + * Finds the Seo model based on its primary key value.
  151 + * If the model is not found, a 404 HTTP exception will be thrown.
  152 + *
  153 + * @param integer $id
  154 + *
  155 + * @return Seo the loaded model
  156 + * @throws NotFoundHttpException if the model cannot be found
  157 + */
  158 + protected function findModel($id)
  159 + {
  160 + if(( $model = Seo::findOne($id) ) !== NULL) {
  161 + return $model;
  162 + } else {
  163 + throw new NotFoundHttpException('The requested page does not exist.');
  164 + }
132 165 }
133 166 }
134   -}
... ...
backend/controllers/SeoDynamicController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\SeoDynamic;
7   -use common\models\SeoDynamicSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * SeoDynamicController implements the CRUD actions for SeoDynamic model.
14   - */
15   -class SeoDynamicController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\SeoDynamic;
  7 + use common\models\SeoDynamicSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * SeoDynamicController implements the CRUD actions for SeoDynamic model.
19 15 */
20   - public function behaviors()
  16 + class SeoDynamicController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   -
38   - ],
39   - ];
40   - }
41   -
42   - /**
43   - * Lists all SeoDynamic models.
44   - * @return mixed
45   - */
46   - public function actionIndex($seo_category_id)
47   - {
48   - $searchModel = new SeoDynamicSearch();
49   - $dataProvider = $searchModel->search($seo_category_id,Yii::$app->request->queryParams);
50   -
51   - return $this->render('index', [
52   - 'searchModel' => $searchModel,
53   - 'dataProvider' => $dataProvider,
54   - 'seo_category_id' => $seo_category_id
55   - ]);
56   - }
57   -
58   - /**
59   - * Displays a single SeoDynamic model.
60   - * @param integer $id
61   - * @return mixed
62   - */
63   - public function actionView($seo_category_id, $id)
64   - {
65   - return $this->render('view', [
66   - 'model' => $this->findModel($id),
67   - 'seo_category_id' => $seo_category_id
68   - ]);
69   - }
70   -
71   - /**
72   - * Creates a new SeoDynamic model.
73   - * If creation is successful, the browser will be redirected to the 'view' page.
74   - * @return mixed
75   - */
76   - public function actionCreate($seo_category_id)
77   - {
78   - $model = new SeoDynamic();
79   -
80   - if ($model->load(Yii::$app->request->post())) {
81   - $model->seo_category_id = $seo_category_id;
82   - $model->save();
83   - return $this->redirect(['index', 'seo_category_id' => $model->seo_category_id]);
84   - } else {
85   - return $this->render('create', [
86   - 'model' => $model,
87   - 'seo_category_id' => $seo_category_id
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
  38 + ],
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 +
  42 + ],
  43 + ];
  44 + }
  45 +
  46 + /**
  47 + * Lists all SeoDynamic models.
  48 + * @return mixed
  49 + */
  50 + public function actionIndex($seo_category_id)
  51 + {
  52 + $searchModel = new SeoDynamicSearch();
  53 + $dataProvider = $searchModel->search($seo_category_id, Yii::$app->request->queryParams);
  54 +
  55 + return $this->render('index', [
  56 + 'searchModel' => $searchModel,
  57 + 'dataProvider' => $dataProvider,
  58 + 'seo_category_id' => $seo_category_id,
88 59 ]);
89 60 }
90   - }
91   -
92   - /**
93   - * Updates an existing SeoDynamic model.
94   - * If update is successful, the browser will be redirected to the 'view' page.
95   - * @param integer $id
96   - * @return mixed
97   - */
98   - public function actionUpdate($seo_category_id,$id)
99   - {
100   - $model = $this->findModel($id);
101   -
102   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
103   - return $this->redirect(['index', 'seo_category_id' => $model->seo_category_id]);
104   - } else {
  61 +
  62 + /**
  63 + * Displays a single SeoDynamic model.
  64 + *
  65 + * @param integer $id
  66 + *
  67 + * @return mixed
  68 + */
  69 + public function actionView($seo_category_id, $id)
  70 + {
  71 + return $this->render('view', [
  72 + 'model' => $this->findModel($id),
  73 + 'seo_category_id' => $seo_category_id,
  74 + ]);
  75 + }
  76 +
  77 + /**
  78 + * Creates a new SeoDynamic model.
  79 + * If creation is successful, the browser will be redirected to the 'view' page.
  80 + * @return mixed
  81 + */
  82 + public function actionCreate($seo_category_id)
  83 + {
  84 + $model = new SeoDynamic();
  85 + $model_langs = $model->generateLangs();
  86 +
  87 + if($model->load(Yii::$app->request->post())) {
  88 + $model->loadLangs(\Yii::$app->request, $model_langs);
  89 + $model->seo_category_id = $seo_category_id;
  90 + $model->save();
  91 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  92 + return $this->redirect([
  93 + 'index',
  94 + 'seo_category_id' => $model->seo_category_id,
  95 + ]);
  96 + } else {
  97 + return $this->redirect([
  98 + 'update',
  99 + 'seo_category_id' => $model->seo_category_id,
  100 + 'id' => $model->seo_dynamic_id,
  101 + ]);
  102 + }
  103 + } else {
  104 + return $this->render('create', [
  105 + 'model' => $model,
  106 + 'model_langs' => $model_langs,
  107 + 'seo_category_id' => $seo_category_id,
  108 + ]);
  109 + }
  110 + }
  111 +
  112 + /**
  113 + * Updates an existing SeoDynamic model.
  114 + * If update is successful, the browser will be redirected to the 'view' page.
  115 + *
  116 + * @param integer $id
  117 + *
  118 + * @return mixed
  119 + */
  120 + public function actionUpdate($seo_category_id, $id)
  121 + {
  122 + $model = $this->findModel($id);
  123 + $model_langs = $model->generateLangs();
  124 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  125 + $model->loadLangs(\Yii::$app->request, $model_langs);
  126 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  127 + return $this->redirect([
  128 + 'index',
  129 + 'seo_category_id' => $model->seo_category_id,
  130 + ]);
  131 + }
  132 + }
105 133 return $this->render('update', [
106   - 'model' => $model,
107   - 'seo_category_id' => $seo_category_id
  134 + 'model' => $model,
  135 + 'model_langs' => $model_langs,
  136 + 'seo_category_id' => $seo_category_id,
108 137 ]);
109 138 }
110   - }
111   -
112   - /**
113   - * Deletes an existing SeoDynamic model.
114   - * If deletion is successful, the browser will be redirected to the 'index' page.
115   - * @param integer $id
116   - * @return mixed
117   - */
118   - public function actionDelete($seo_category_id,$id)
119   - {
120   - $this->findModel($id)->delete();
121   -
122   - return $this->redirect(['index','seo_category_id'=> $seo_category_id]);
123   - }
124   -
125   - /**
126   - * Finds the SeoDynamic model based on its primary key value.
127   - * If the model is not found, a 404 HTTP exception will be thrown.
128   - * @param integer $id
129   - * @return SeoDynamic the loaded model
130   - * @throws NotFoundHttpException if the model cannot be found
131   - */
132   - protected function findModel($id)
133   - {
134   - if (($model = SeoDynamic::findOne($id)) !== null) {
135   - return $model;
136   - } else {
137   - throw new NotFoundHttpException('The requested page does not exist.');
  139 +
  140 + /**
  141 + * Deletes an existing SeoDynamic model.
  142 + * If deletion is successful, the browser will be redirected to the 'index' page.
  143 + *
  144 + * @param integer $id
  145 + *
  146 + * @return mixed
  147 + */
  148 + public function actionDelete($seo_category_id, $id)
  149 + {
  150 + $this->findModel($id)
  151 + ->delete();
  152 +
  153 + return $this->redirect([
  154 + 'index',
  155 + 'seo_category_id' => $seo_category_id,
  156 + ]);
  157 + }
  158 +
  159 + /**
  160 + * Finds the SeoDynamic model based on its primary key value.
  161 + * If the model is not found, a 404 HTTP exception will be thrown.
  162 + *
  163 + * @param integer $id
  164 + *
  165 + * @return SeoDynamic the loaded model
  166 + * @throws NotFoundHttpException if the model cannot be found
  167 + */
  168 + protected function findModel($id)
  169 + {
  170 + if(( $model = SeoDynamic::findOne($id) ) !== NULL) {
  171 + return $model;
  172 + } else {
  173 + throw new NotFoundHttpException('The requested page does not exist.');
  174 + }
138 175 }
139 176 }
140   -}
... ...
backend/controllers/ServiceController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -
5   -use Yii;
6   -use common\models\Service;
7   -use common\models\ServiceSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -use developeruz\db_rbac\behaviors\AccessBehavior;
12   -/**
13   - * ServiceController implements the CRUD actions for Service model.
14   - */
15   -class ServiceController extends Controller
16   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use Yii;
  6 + use common\models\Service;
  7 + use common\models\ServiceSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 + use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * ServiceController implements the CRUD actions for Service model.
19 15 */
20   - public function behaviors()
  16 + class ServiceController extends Controller
21 17 {
22   - return [
23   - 'access'=>[
24   - 'class' => AccessBehavior::className(),
25   - 'rules' =>
26   - ['site' =>
27   - [
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'access' => [
  26 + 'class' => AccessBehavior::className(),
  27 + 'rules' => [
  28 + 'site' => [
28 29 [
29   - 'actions' => ['login', 'error'],
30   - 'allow' => true,
31   - ]
32   - ]
33   - ]
34   - ],
35   - 'verbs' => [
36   - 'class' => VerbFilter::className(),
37   - 'actions' => [
38   - 'delete' => ['POST'],
  30 + 'actions' => [
  31 + 'login',
  32 + 'error',
  33 + ],
  34 + 'allow' => true,
  35 + ],
  36 + ],
  37 + ],
39 38 ],
40   - ],
41   - ];
42   - }
43   -
44   - /**
45   - * Lists all Service models.
46   - * @return mixed
47   - */
48   - public function actionIndex()
49   - {
50   - $searchModel = new ServiceSearch();
51   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
52   -
53   - return $this->render('index', [
54   - 'searchModel' => $searchModel,
55   - 'dataProvider' => $dataProvider,
56   - ]);
57   - }
58   -
59   - /**
60   - * Displays a single Service model.
61   - * @param integer $id
62   - * @return mixed
63   - */
64   - public function actionView($id)
65   - {
66   - return $this->render('view', [
67   - 'model' => $this->findModel($id),
68   - ]);
69   - }
70   -
71   - /**
72   - * Creates a new Service model.
73   - * If creation is successful, the browser will be redirected to the 'view' page.
74   - * @return mixed
75   - */
76   - public function actionCreate()
77   - {
78   - $model = new Service();
79   -
80   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
81   - return $this->redirect(['view', 'id' => $model->service_id]);
82   - } else {
83   - return $this->render('create', [
84   - 'model' => $model,
  39 + 'verbs' => [
  40 + 'class' => VerbFilter::className(),
  41 + 'actions' => [
  42 + 'delete' => [ 'POST' ],
  43 + ],
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + /**
  49 + * Lists all Service models.
  50 + * @return mixed
  51 + */
  52 + public function actionIndex()
  53 + {
  54 + $searchModel = new ServiceSearch();
  55 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  56 +
  57 + return $this->render('index', [
  58 + 'searchModel' => $searchModel,
  59 + 'dataProvider' => $dataProvider,
85 60 ]);
86 61 }
87   - }
88   -
89   - /**
90   - * Updates an existing Service model.
91   - * If update is successful, the browser will be redirected to the 'view' page.
92   - * @param integer $id
93   - * @return mixed
94   - */
95   - public function actionUpdate($id)
96   - {
97   - $model = $this->findModel($id);
98   -
99   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
100   - return $this->redirect(['view', 'id' => $model->service_id]);
101   - } else {
  62 +
  63 + /**
  64 + * Displays a single Service model.
  65 + *
  66 + * @param integer $id
  67 + *
  68 + * @return mixed
  69 + */
  70 + public function actionView($id)
  71 + {
  72 + return $this->render('view', [
  73 + 'model' => $this->findModel($id),
  74 + ]);
  75 + }
  76 +
  77 + /**
  78 + * Creates a new Service model.
  79 + * If creation is successful, the browser will be redirected to the 'view' page.
  80 + * @return mixed
  81 + */
  82 + public function actionCreate()
  83 + {
  84 + $model = new Service();
  85 + $model_langs = $model->generateLangs();
  86 +
  87 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  88 + $model->loadLangs(\Yii::$app->request, $model_langs);
  89 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  90 + return $this->redirect([
  91 + 'view',
  92 + 'id' => $model->service_id,
  93 + ]);
  94 + } else {
  95 + return $this->redirect([
  96 + 'update',
  97 + 'id' => $model->service_id,
  98 + ]);
  99 + }
  100 + } else {
  101 + return $this->render('create', [
  102 + 'model' => $model,
  103 + 'model_langs' => $model_langs,
  104 + ]);
  105 + }
  106 + }
  107 +
  108 + /**
  109 + * Updates an existing Service model.
  110 + * If update is successful, the browser will be redirected to the 'view' page.
  111 + *
  112 + * @param integer $id
  113 + *
  114 + * @return mixed
  115 + */
  116 + public function actionUpdate($id)
  117 + {
  118 + $model = $this->findModel($id);
  119 + $model_langs = $model->generateLangs();
  120 +
  121 + if($model->load(Yii::$app->request->post()) && $model->save()) {
  122 + $model->loadLangs(\Yii::$app->request, $model_langs);
  123 + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) {
  124 + return $this->redirect([
  125 + 'view',
  126 + 'id' => $model->service_id,
  127 + ]);
  128 + }
  129 + }
102 130 return $this->render('update', [
103 131 'model' => $model,
  132 + 'model_langs' => $model_langs,
104 133 ]);
105 134 }
106   - }
107   -
108   - /**
109   - * Deletes an existing Service model.
110   - * If deletion is successful, the browser will be redirected to the 'index' page.
111   - * @param integer $id
112   - * @return mixed
113   - */
114   - public function actionDelete($id)
115   - {
116   - $this->findModel($id)->delete();
117   -
118   - return $this->redirect(['index']);
119   - }
120   -
121   - /**
122   - * Finds the Service model based on its primary key value.
123   - * If the model is not found, a 404 HTTP exception will be thrown.
124   - * @param integer $id
125   - * @return Service the loaded model
126   - * @throws NotFoundHttpException if the model cannot be found
127   - */
128   - protected function findModel($id)
129   - {
130   - if (($model = Service::findOne($id)) !== null) {
131   - return $model;
132   - } else {
133   - throw new NotFoundHttpException('The requested page does not exist.');
  135 +
  136 + /**
  137 + * Deletes an existing Service model.
  138 + * If deletion is successful, the browser will be redirected to the 'index' page.
  139 + *
  140 + * @param integer $id
  141 + *
  142 + * @return mixed
  143 + */
  144 + public function actionDelete($id)
  145 + {
  146 + $this->findModel($id)
  147 + ->delete();
  148 +
  149 + return $this->redirect([ 'index' ]);
  150 + }
  151 +
  152 + /**
  153 + * Finds the Service model based on its primary key value.
  154 + * If the model is not found, a 404 HTTP exception will be thrown.
  155 + *
  156 + * @param integer $id
  157 + *
  158 + * @return Service the loaded model
  159 + * @throws NotFoundHttpException if the model cannot be found
  160 + */
  161 + protected function findModel($id)
  162 + {
  163 + if(( $model = Service::findOne($id) ) !== NULL) {
  164 + return $model;
  165 + } else {
  166 + throw new NotFoundHttpException('The requested page does not exist.');
  167 + }
134 168 }
135 169 }
136   -}
... ...
backend/controllers/SliderImageController.php
1 1 <?php
2   -
3   -namespace backend\controllers;
4   -use developeruz\db_rbac\behaviors\AccessBehavior;
5   -use common\models\Slider;
6   -use Yii;
7   -use common\models\SliderImage;
8   -use common\models\SliderImageSearch;
9   -use yii\web\Controller;
10   -use yii\web\NotFoundHttpException;
11   -use yii\filters\VerbFilter;
12   -use yii\web\UploadedFile;
13   -/**
14   - * SliderImageController implements the CRUD actions for SliderImage model.
15   - */
16   -class SliderImageController extends Controller
17   -{
  2 +
  3 + namespace backend\controllers;
  4 +
  5 + use developeruz\db_rbac\behaviors\AccessBehavior;
  6 + use common\models\Slider;
  7 + use Yii;
  8 + use common\models\SliderImage;
  9 + use common\models\SliderImageSearch;
  10 + use yii\web\Controller;
  11 + use yii\web\NotFoundHttpException;
  12 + use yii\filters\VerbFilter;
  13 + use yii\web\UploadedFile;
  14 +
18 15 /**
19   - * @inheritdoc
  16 + * SliderImageController implements the CRUD actions for SliderImage model.
20 17 */
21   - public function behaviors()
  18 + class SliderImageController extends Controller
22 19 {
23   - return [
24   - 'access'=>[
25   - 'class' => AccessBehavior::className(),
26   - 'rules' =>
27   - ['site' =>
28   - [
  20 +
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public function behaviors()
  25 + {
  26 + return [
  27 + 'access' => [
  28 + 'class' => AccessBehavior::className(),
  29 + 'rules' => [
  30 + 'site' => [
29 31 [
30   - 'actions' => ['login', 'error'],
31   - 'allow' => true,
32   - ]
33   - ]
34   - ]
35   - ],
36   - 'verbs' => [
37   - 'class' => VerbFilter::className(),
38   - 'actions' => [
39   - 'delete' => ['POST'],
  32 + 'actions' => [
  33 + 'login',
  34 + 'error',
  35 + ],
  36 + 'allow' => true,
  37 + ],
  38 + ],
  39 + ],
40 40 ],
41   - ],
42   - ];
43   - }
44   -
45   - /**
46   - * Lists all SliderImage models.
47   - * @param $slider_id Slider id
48   - * @return mixed
49   - */
50   - public function actionIndex($slider_id)
51   - {
52   - $searchModel = new SliderImageSearch();
53   - $dataProvider = $searchModel->search($slider_id, Yii::$app->request->queryParams);
54   -
55   - return $this->render('index', [
56   - 'slider_id' => $slider_id,
57   - 'searchModel' => $searchModel,
58   - 'dataProvider' => $dataProvider,
59   - ]);
60   - }
61   -
62   - /**
63   - * Displays a single SliderImage model.
64   - * @param integer $id
65   - * @param $slider_id Slider id
66   - * @return mixed
67   - */
68   - public function actionView($slider_id, $id)
69   - {
70   - return $this->render('view', [
71   - 'slider_id' => $slider_id,
72   - 'model' => $this->findModel($slider_id, $id),
73   - ]);
74   - }
75   -
76   - /**
77   - * Creates a new SliderImage model.
78   - * If creation is successful, the browser will be redirected to the 'view' page.
79   - * @param $slider_id Slider id
80   - * @return mixed
81   - */
82   - public function actionCreate($slider_id)
83   - {
84   - $model = new SliderImage();
85   - if ($model->load(Yii::$app->request->post())) {
86   - $model->slider_id = $slider_id;
87   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
88   - $model->image = $image->name;
89   - }
90   - if ($model->save() && $image) {
91   - $imgDir = Yii::getAlias('@storage/slider/');
92   - if(!is_dir($imgDir)) {
93   - mkdir($imgDir, 0755, true);
94   - }
95   - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));
96   - }
97   - return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]);
98   - } else {
99   - $slider = Slider::findOne($slider_id);
100   - return $this->render('create', [
  41 + 'verbs' => [
  42 + 'class' => VerbFilter::className(),
  43 + 'actions' => [
  44 + 'delete' => [ 'POST' ],
  45 + ],
  46 + ],
  47 + ];
  48 + }
  49 +
  50 + /**
  51 + * Lists all SliderImage models.
  52 + *
  53 + * @param $slider_id Slider id
  54 + *
  55 + * @return mixed
  56 + */
  57 + public function actionIndex($slider_id)
  58 + {
  59 + $searchModel = new SliderImageSearch();
  60 + $dataProvider = $searchModel->search($slider_id, Yii::$app->request->queryParams);
  61 +
  62 + return $this->render('index', [
  63 + 'slider_id' => $slider_id,
  64 + 'searchModel' => $searchModel,
  65 + 'dataProvider' => $dataProvider,
  66 + ]);
  67 + }
  68 +
  69 + /**
  70 + * Displays a single SliderImage model.
  71 + *
  72 + * @param integer $id
  73 + * @param $slider_id Slider id
  74 + *
  75 + * @return mixed
  76 + */
  77 + public function actionView($slider_id, $id)
  78 + {
  79 + return $this->render('view', [
101 80 'slider_id' => $slider_id,
102   - 'model' => $model,
103   - 'slider' => $slider,
  81 + 'model' => $this->findModel($slider_id, $id),
104 82 ]);
105 83 }
106   - }
107   -
108   - /**
109   - * Updates an existing SliderImage model.
110   - * If update is successful, the browser will be redirected to the 'view' page.
111   - * @param $slider_id Slider id
112   - * @param integer $id
113   - * @return mixed
114   - */
115   - public function actionUpdate($slider_id, $id)
116   - {
117   - $model = $this->findModel($slider_id, $id);
118   - if ($model->load(Yii::$app->request->post())) {
119   - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
120   - $model->image = $image->name;
121   - }
122   - if(!$model->image){
123   - $model->image = $model->getOldAttribute('image');
  84 +
  85 + /**
  86 + * Creates a new SliderImage model.
  87 + * If creation is successful, the browser will be redirected to the 'view' page.
  88 + *
  89 + * @param $slider_id Slider id
  90 + *
  91 + * @return mixed
  92 + */
  93 + public function actionCreate($slider_id)
  94 + {
  95 + $model = new SliderImage();
  96 + $model_langs = $model->generateLangs();
  97 + if($model->load(Yii::$app->request->post())) {
  98 + $model->loadLangs(\Yii::$app->request, $model_langs);
  99 + $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);
  107 + }
  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 + }
  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 + ]);
124 131 }
125   - if ($model->save() && $image) {
126   - $imgDir = Yii::getAlias('@storage/slider/');
127   - if(!is_dir($imgDir)) {
128   - mkdir($imgDir, 0755, true);
  132 + }
  133 +
  134 + /**
  135 + * Updates an existing SliderImage model.
  136 + * If update is successful, the browser will be redirected to the 'view' page.
  137 + *
  138 + * @param $slider_id Slider id
  139 + * @param integer $id
  140 + *
  141 + * @return mixed
  142 + */
  143 + public function actionUpdate($slider_id, $id)
  144 + {
  145 + $model = $this->findModel($slider_id, $id);
  146 + $model_langs = $model->generateLangs();
  147 + if($model->load(Yii::$app->request->post())) {
  148 + $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)) {
  163 + return $this->redirect([
  164 + 'view',
  165 + 'slider_id' => $slider_id,
  166 + 'id' => $model->slider_image_id,
  167 + ]);
129 168 }
130   - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));
131 169 }
132   - return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]);
133   - } else {
134 170 $slider = Slider::findOne($slider_id);
135 171 return $this->render('update', [
136   - 'model' => $model,
  172 + 'model' => $model,
  173 + 'model_langs' => $model_langs,
  174 + 'slider_id' => $slider_id,
  175 + 'slider' => $slider,
  176 + ]);
  177 + }
  178 +
  179 + /**
  180 + * Deletes an existing SliderImage model.
  181 + * If deletion is successful, the browser will be redirected to the 'index' page.
  182 + *
  183 + * @param $slider_id Slider id
  184 + * @param integer $id
  185 + *
  186 + * @return mixed
  187 + */
  188 + public function actionDelete($slider_id, $id)
  189 + {
  190 + $this->findModel($slider_id, $id)
  191 + ->delete();
  192 +
  193 + return $this->redirect([
  194 + 'index',
137 195 'slider_id' => $slider_id,
138   - 'slider' => $slider,
139 196 ]);
140 197 }
141   - }
142   -
143   - /**
144   - * Deletes an existing SliderImage model.
145   - * If deletion is successful, the browser will be redirected to the 'index' page.
146   - * @param $slider_id Slider id
147   - * @param integer $id
148   - * @return mixed
149   - */
150   - public function actionDelete($slider_id, $id)
151   - {
152   - $this->findModel($slider_id, $id)->delete();
153   -
154   - return $this->redirect(['index','slider_id'=>$slider_id]);
155   - }
156   -
157   - /**
158   - * Finds the SliderImage model based on its primary key value.
159   - * If the model is not found, a 404 HTTP exception will be thrown.
160   - * @param $slider_id Slider id
161   - * @param integer $id
162   - * @return SliderImage the loaded model
163   - * @throws NotFoundHttpException if the model cannot be found
164   - */
165   - protected function findModel($slider_id,$id)
166   - {
167   - if (($model = SliderImage::find()->where(['slider_image_id'=> $id, 'slider_id'=>$slider_id])->one()) !== null) {
168   - return $model;
169   - } else {
170   - throw new NotFoundHttpException('The requested page does not exist.');
  198 +
  199 + /**
  200 + * Finds the SliderImage model based on its primary key value.
  201 + * If the model is not found, a 404 HTTP exception will be thrown.
  202 + *
  203 + * @param $slider_id Slider id
  204 + * @param integer $id
  205 + *
  206 + * @return SliderImage the loaded model
  207 + * @throws NotFoundHttpException if the model cannot be found
  208 + */
  209 + protected function findModel($slider_id, $id)
  210 + {
  211 + /**
  212 + * @var SliderImage $model
  213 + */
  214 + if(( $model = SliderImage::find()
  215 + ->where([
  216 + 'slider_image_id' => $id,
  217 + 'slider_id' => $slider_id,
  218 + ])
  219 + ->one() ) !== NULL
  220 + ) {
  221 + return $model;
  222 + } else {
  223 + throw new NotFoundHttpException('The requested page does not exist.');
  224 + }
171 225 }
172 226 }
173   -}
... ...
backend/models/Label.php
... ... @@ -2,6 +2,32 @@
2 2  
3 3 namespace backend\models;
4 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 Label
  12 + *
  13 + * * From language behavior *
  14 + * @property {TableLang} $lang
  15 + * @property {TableLang}[] $langs
  16 + * @property {TableLang} $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 {TableLang}[] 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 + */
5 31 class Label extends \yii\db\ActiveRecord
6 32 {
7 33  
... ... @@ -10,7 +36,16 @@ class Label extends \yii\db\ActiveRecord
10 36 return 'orders_label';
11 37 }
12 38  
13   - public function getNl(){
  39 + public function behaviors()
  40 + {
  41 + return [
  42 + 'language' => [
  43 + 'class' => LanguageBehavior::className(),
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + public function getNl(){
14 49 return $this->name;
15 50 }
16 51 }
... ...
backend/models/OrdersLabelLang.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use common\modules\language\models\Language;
  6 +use Yii;
  7 +
  8 +/**
  9 + * This is the model class for table "orders_label_lang".
  10 + *
  11 + * @property integer $orders_label_id
  12 + * @property integer $language_id
  13 + * @property string $name
  14 + *
  15 + * @property Language $language
  16 + * @property Label $label
  17 + */
  18 +class OrdersLabelLang extends \yii\db\ActiveRecord
  19 +{
  20 +
  21 + public static function primaryKey()
  22 + {
  23 + return [
  24 + 'orders_label_id',
  25 + 'language_id',
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return 'orders_label_lang';
  35 + }
  36 +
  37 + /**
  38 + * @inheritdoc
  39 + */
  40 + public function rules()
  41 + {
  42 + return [
  43 + [['name'], 'required'],
  44 + [['name'], 'string', 'max' => 255],
  45 + [['orders_label_id', 'language_id'], 'unique', 'targetAttribute' => ['orders_label_id', 'language_id'], 'message' => 'The combination of Orders Label ID and Language ID has already been taken.'],
  46 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  47 + [['orders_label_id'], 'exist', 'skipOnError' => true, 'targetClass' => OrdersLabel::className(), 'targetAttribute' => ['orders_label_id' => 'id']],
  48 + ];
  49 + }
  50 +
  51 + /**
  52 + * @inheritdoc
  53 + */
  54 + public function attributeLabels()
  55 + {
  56 + return [
  57 + 'orders_label_id' => Yii::t('app', 'Orders Label ID'),
  58 + 'language_id' => Yii::t('app', 'Language ID'),
  59 + 'name' => Yii::t('app', 'Name'),
  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
  73 + */
  74 + public function getLabel()
  75 + {
  76 + return $this->hasOne(Label::className(), ['id' => 'orders_label_id']);
  77 + }
  78 +}
... ...
backend/views/articles/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use common\modules\file\widgets\ImageUploader;
6   -use mihaildev\ckeditor\CKEditor;
7   -use mihaildev\elfinder\ElFinder;
8   -use yii\jui\DatePicker;
9   -/* @var $this yii\web\View */
10   -/* @var $model common\models\Articles */
11   -/* @var $form yii\widgets\ActiveForm */
  2 + use common\models\Articles;
  3 + use common\models\ArticlesLang;
  4 + use common\modules\language\widgets\LanguageForm;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 + use mihaildev\ckeditor\CKEditor;
  9 + use mihaildev\elfinder\ElFinder;
  10 + use yii\jui\DatePicker;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Articles $model
  15 + * @var ArticlesLang[] $model_langs
  16 + * @var ActiveForm $form
  17 + */
12 18 ?>
13 19  
14 20 <div class="articles-form">
15   -
  21 +
16 22 <?php $form = ActiveForm::begin([
17 23 'enableClientValidation' => false,
18   - 'options' => ['enctype' => 'multipart/form-data']
  24 + 'options' => [ 'enctype' => 'multipart/form-data' ],
19 25 ]); ?>
20   -
21   -
  26 +
  27 +
22 28 <?= $form->field($model, 'date')
23   - ->widget(DatePicker::className(), [
24   - 'dateFormat' => 'dd-MM-yyyy',
25   - ]) ?>
26   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
27   -
28   - <?= $form->field($model, 'body')->widget(CKEditor::className(),
29   - [
30   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
31   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
32   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
33   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
34   - ]
35   - )
36   - ]) ?>
37   -
38   - <?= $form->field($model, 'body_preview')->widget(CKEditor::className(),
39   - [
40   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
41   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
42   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
43   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
44   - ]
45   - )
46   - ]) ?>
47   -
48   - <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
49   - 'language' => 'ru',
50   - 'options' => [
51   - 'accept' => 'image/*',
52   - 'multiple' => false,
53   - ],
54   - 'pluginOptions' => [
55   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
56   - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
57   - 'overwriteInitial' => true,
58   - 'showRemove' => false,
59   - 'showUpload' => false,
60   - 'previewFileType' => 'image',
61   - ],
62   - ]); ?>
63   -
64   - <?= $form->field($model, 'translit')->textInput(['maxlength' => true]) ?>
65   -
66   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
67   -
68   - <?= $form->field($model, 'meta_keywords')->textInput(['maxlength' => true]) ?>
69   -
70   - <?= $form->field($model, 'meta_description')->textInput(['maxlength' => true]) ?>
71   -
72   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
73   -
74   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
75   -
  29 + ->widget(DatePicker::className(), [
  30 + 'dateFormat' => 'dd-MM-yyyy',
  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 +
  55 + <?= $form->field($model, 'image')
  56 + ->widget(\kartik\file\FileInput::classname(), [
  57 + 'language' => 'ru',
  58 + 'options' => [
  59 + 'accept' => 'image/*',
  60 + 'multiple' => false,
  61 + ],
  62 + 'pluginOptions' => [
  63 + 'allowedFileExtensions' => [
  64 + 'jpg',
  65 + 'gif',
  66 + 'png',
  67 + ],
  68 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  69 + 'overwriteInitial' => true,
  70 + 'showRemove' => false,
  71 + 'showUpload' => false,
  72 + 'previewFileType' => 'image',
  73 + ],
  74 + ]); ?>
  75 +
  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
  95 + echo LanguageForm::widget([
  96 + 'model_langs' => $model_langs,
  97 + 'formView' => '@backend/views/articles/_form_language',
  98 + 'form' => $form,
  99 + ]);
  100 + ?>
  101 +
76 102 <div class="form-group">
77   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  103 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
78 104 </div>
79   -
  105 +
80 106 <?php ActiveForm::end(); ?>
81 107  
82 108 </div>
... ...
backend/views/articles/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\ArticlesLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var ArticlesLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']body')
  19 + ->widget(CKEditor::className(), [
  20 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  21 + 'preset' => 'full',
  22 + 'inline' => false,
  23 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  24 + ->createUrl('file/uploader/images-upload'),
  25 + ]),
  26 + ]) ?>
  27 +
  28 +<?= $form->field($model_lang, '[' . $language->language_id . ']body_preview')
  29 + ->widget(CKEditor::className(), [
  30 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  31 + 'preset' => 'full',
  32 + 'inline' => false,
  33 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  34 + ->createUrl('file/uploader/images-upload'),
  35 + ]),
  36 + ]) ?>
  37 +
  38 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  39 + ->textInput([ 'maxlength' => true ]) ?>
  40 +
  41 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_keywords')
  42 + ->textInput([ 'maxlength' => true ]) ?>
  43 +
  44 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_description')
  45 + ->textInput([ 'maxlength' => true ]) ?>
  46 +
  47 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  48 + ->textarea([ 'rows' => 6 ]) ?>
  49 +
  50 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  51 + ->textInput([ 'maxlength' => true ]) ?>
... ...
backend/views/articles/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Articles */
8   -
9   -$this->title = 'Create Articles';
10   -$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 + use common\models\Articles;
  3 + use common\models\ArticlesLang;
  4 + use yii\helpers\Html;
  5 + use yii\web\View;
  6 +
  7 + /**
  8 + * @var View $this
  9 + * @var Articles $model
  10 + * @var ArticlesLang[] $model_langs
  11 + */
  12 + $this->title = 'Create Articles';
  13 + $this->params[ 'breadcrumbs' ][] = [
  14 + 'label' => 'Articles',
  15 + 'url' => [ 'index' ],
  16 + ];
  17 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 18 ?>
13 19 <div class="articles-create">
14   -
  20 +
15 21 <h1><?= Html::encode($this->title) ?></h1>
16   -
  22 +
17 23 <?= $this->render('_form', [
18   - 'model' => $model,
  24 + 'model' => $model,
  25 + 'model_langs' => $model_langs,
19 26 ]) ?>
20 27  
21 28 </div>
... ...
backend/views/articles/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Articles */
7   -
8   -$this->title = 'Update Articles: ' . $model->title;
9   -$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 + use common\models\Articles;
  3 + use common\models\ArticlesLang;
  4 + use yii\helpers\Html;
  5 + use yii\web\View;
  6 +
  7 + /**
  8 + * @var View $this
  9 + * @var Articles $model
  10 + * @var ArticlesLang[] $model_langs
  11 + */
  12 + $this->title = 'Update Articles: ' . $model->title;
  13 + $this->params[ 'breadcrumbs' ][] = [
  14 + 'label' => 'Articles',
  15 + 'url' => [ 'index' ],
  16 + ];
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => $model->title,
  19 + 'url' => [
  20 + 'view',
  21 + 'id' => $model->id,
  22 + ],
  23 + ];
  24 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 25 ?>
13 26 <div class="articles-update">
14   -
  27 +
15 28 <h1><?= Html::encode($this->title) ?></h1>
16   -
  29 +
17 30 <?= $this->render('_form', [
18   - 'model' => $model,
  31 + 'model' => $model,
  32 + 'model_langs' => $model_langs,
19 33 ]) ?>
20 34  
21 35 </div>
... ...
backend/views/banner/_form.php
1 1 <?php
2   -
3   -use common\modules\file\widgets\ImageUploader;
4   -use kartik\select2\Select2;
5   -use yii\helpers\Html;
6   -use yii\widgets\ActiveForm;
7   -
8   -/* @var $this yii\web\View */
9   -/* @var $model common\models\Banner */
10   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Banner;
  4 + use common\models\BannerLang;
  5 + use common\modules\file\widgets\ImageUploader;
  6 + use common\modules\language\widgets\LanguageForm;
  7 + use kartik\select2\Select2;
  8 + use yii\helpers\Html;
  9 + use yii\web\View;
  10 + use yii\widgets\ActiveForm;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Banner $model
  15 + * @var ActiveForm $form
  16 + * @var BannerLang[] $model_langs
  17 + */
11 18 ?>
12 19  
13 20 <div class="banner-form">
14   -
15   - <?php $form = ActiveForm::begin(); ?>
16   -
17   -
18   - <?= $form->field($model, 'alt')->textInput(['maxlength' => true]) ?>
19   -
20   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
21   -
22   - <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
23   -
24   - <?= $form->field($model, 'status')->widget(Select2::className(),([
25   - 'name' => 'status',
26   - 'hideSearch' => true,
27   - 'data' => [1 => 'Active', 2 => 'Inactive'],
28   - 'options' => ['placeholder' => 'Select status...'],
29   - 'pluginOptions' => [
30   - 'allowClear' => true
31   - ]
32   - ])) ?>
33   -
34   - <?= $form->field($model, 'width')->textInput(['maxlength' => true]) ?>
35   -
36   - <?= $form->field($model, 'height')->textInput(['maxlength' => true]) ?>
37   -
38   - <p id="save_image_widget_settings" class = "btn btn-primary" >ะŸั€ะธะผะตะฝะธั‚ัŒ ะฝะฐัั‚ั€ะพะนะบะธ</p>
39   -
40   - <div id="image_widget_block">
41   - <?php if(!empty($model->image)){
42   - echo ImageUploader::widget([
43   - 'model'=> $model,
44   - 'field'=>'image',
45   - 'size' => [
46   - [
47   - 'width'=>$model->width,
48   - 'height'=>$model->height,
49   - ],
50   - ],
51   - 'gallery' =>$model->image,
52   - 'name' => "ะ—ะฐะณั€ัƒะทะธั‚ัŒ ะฑะฐะฝะฝะตั€"
53   - ]);
54   - }?>
55   - </div>
56   -
  21 +
  22 + <?php $form = ActiveForm::begin([
  23 + 'options' => [
  24 + 'enctype' => 'multipart/form-data',
  25 + ],
  26 + ]); ?>
  27 +
  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')
  35 + ->textInput([ 'maxlength' => true ]) ?>
  36 +
  37 + <?= $form->field($model, 'status')
  38 + ->widget(Select2::className(), ( [
  39 + 'name' => 'status',
  40 + 'hideSearch' => true,
  41 + 'data' => [
  42 + 1 => 'Active',
  43 + 2 => 'Inactive',
  44 + ],
  45 + 'options' => [ 'placeholder' => 'Select status...' ],
  46 + 'pluginOptions' => [
  47 + 'allowClear' => true,
  48 + ],
  49 + ] )) ?>
  50 +
  51 + <?= LanguageForm::widget([
  52 + 'model_langs' => $model_langs,
  53 + 'formView' => '@backend/views/banner/_form_language',
  54 + 'form' => $form,
  55 + ]) ?>
  56 +
57 57 <div class="form-group">
58   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  58 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
59 59 </div>
60   -
  60 +
61 61 <?php ActiveForm::end(); ?>
62 62  
63 63 </div>
64   -<script>
65   - $('#save_image_widget_settings').click(function(){
66   - var width = $('#banner-width').val();
67   - var height = $('#banner-height').val();
68   - save_image_widget_settings( width, height, function(data){
69   - $('#image_widget_block').html = '';
70   - $('#image_widget_block').html(data.html);
71   - });
72   - });
73   - function save_image_widget_settings( width, height, callback )
74   - {
75   - $.ajax({
76   - url: '/admin/banner/save-image-settings',
77   - data :
78   - {
79   - 'width' : width,
80   - 'height' : height
81   - },
82   - type : 'POST',
83   - dataType: 'json',
84   - success: function (data)
85   - {
86   - if(callback)
87   - callback(data);
88   - },
89   - error: function()
90   - {
91   - console.info('error');
92   - }
93   - });
94   - }
95   -</script>
... ...
backend/views/banner/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\BannerLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var BannerLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  15 + ->textInput([ 'maxlength' => true ]); ?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']alt')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +
  19 +<?= $form->field($model_lang, '['.$language->language_id.']image')->widget(\kartik\file\FileInput::className(), [
  20 + 'model' => $model_lang,
  21 + 'attribute' => 'image',
  22 + 'options' => [
  23 + 'accept' => 'image/*',
  24 + 'multiple' => false
  25 + ],
  26 + 'pluginOptions' => [
  27 + 'allowedFileExtensions' => ['jpg','gif','png'],
  28 + 'initialPreview' => $model_lang->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($model_lang->imageUrl, 'slider') : '',
  29 + 'showRemove' => false,
  30 + 'overwriteInitial' => true,
  31 + 'showUpload' => false,
  32 + 'showClose' => false,
  33 + ],
  34 +]); ?>
0 35 \ No newline at end of file
... ...
backend/views/banner/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Banner */
8   -
9   -$this->title = Yii::t('app', 'Create Banner');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Banners'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Banner;
  4 + use common\models\BannerLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Banner $model
  11 + * @var BannerLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Create Banner');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('app', 'Banners'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="banner-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/banner/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Banner */
7   -
8   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Banner',
10   -]) . $model->title;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Banners'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->banner_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\Banner;
  4 + use common\models\BannerLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Banner $model
  11 + * @var BannerLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Banner',
  16 + ]) . $model->title;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Banners'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->title,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->banner_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
14 29 ?>
15 30 <div class="banner-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/bg/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Bg */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Bg;
  4 + use common\models\BgLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var Bg $model
  13 + * @var BgLang[] $model_langs
  14 + * @var ActiveForm $form
  15 + */
9 16 ?>
10 17  
11 18 <div class="bg-form">
12   -
  19 +
13 20 <?php $form = ActiveForm::begin(); ?>
14   -
15   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
16   -
17   - <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
18   -
19   - <?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
20   -
  21 +
  22 + <?= $form->field($model, 'title')
  23 + ->textInput([ 'maxlength' => true ]) ?>
  24 +
  25 + <?= $form->field($model, 'url')
  26 + ->textInput([ 'maxlength' => true ]) ?>
  27 +
  28 + <?= $form->field($model, 'image')
  29 + ->textInput([ 'maxlength' => true ]) ?>
  30 +
  31 + <?= LanguageForm::widget([
  32 + 'model_langs' => $model_langs,
  33 + 'form' => $form,
  34 + 'formView' => '@backend/views/bg/_form_language',
  35 + ]) ?>
  36 +
21 37 <div class="form-group">
22   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  38 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
23 39 </div>
24   -
  40 +
25 41 <?php ActiveForm::end(); ?>
26 42  
27 43 </div>
... ...
backend/views/bg/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\BgLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var BgLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  15 + ->textInput([ 'maxlength' => true ]); ?>
0 16 \ No newline at end of file
... ...
backend/views/bg/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Bg */
8   -
9   -$this->title = 'Create Bg';
10   -$this->params['breadcrumbs'][] = ['label' => 'Bgs', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Bg;
  4 + use common\models\BgLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Bg $model
  11 + * @var BgLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = 'Create Bg';
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Bgs',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="bg-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/bg/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Bg */
7   -
8   -$this->title = 'Update Bg: ' . $model->title;
9   -$this->params['breadcrumbs'][] = ['label' => 'Bgs', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\models\Bg;
  4 + use common\models\BgLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Bg $model
  11 + * @var BgLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = 'Update Bg: ' . $model->title;
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Bgs',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => $model->title,
  21 + 'url' => [
  22 + 'view',
  23 + 'id' => $model->id,
  24 + ],
  25 + ];
  26 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 27 ?>
13 28 <div class="bg-update">
14   -
  29 +
15 30 <h1><?= Html::encode($this->title) ?></h1>
16   -
  31 +
17 32 <?= $this->render('_form', [
18   - 'model' => $model,
  33 + 'model' => $model,
  34 + 'model_langs' => $model_langs,
19 35 ]) ?>
20 36  
21 37 </div>
... ...
backend/views/brand/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\product\models\Brand */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\modules\language\widgets\LanguageForm;
  4 + use common\modules\product\models\Brand;
  5 + use common\modules\product\models\BrandLang;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var Brand $model
  13 + * @var ActiveForm $form
  14 + * @var BrandLang[] $model_langs
  15 + */
9 16 ?>
10 17  
11 18 <div class="brand-form">
12   -
  19 +
13 20 <?php $form = ActiveForm::begin([
14 21 'enableClientValidation' => false,
15   - 'options' => ['enctype' => 'multipart/form-data']
16   - ]); ?>
17   -
18   - <?= $form->field($model, 'name')->textInput() ?>
19   -
20   - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
21   -
22   - <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
23   - 'language' => 'ru',
24   - 'options' => [
25   - 'accept' => 'image/*',
26   - 'multiple' => false,
27   - ],
28   - 'pluginOptions' => [
29   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
30   - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
31   - 'overwriteInitial' => true,
32   - 'showRemove' => false,
33   - 'showUpload' => false,
34   - 'previewFileType' => 'image',
35   - ],
  22 + 'options' => [ 'enctype' => 'multipart/form-data' ],
36 23 ]); ?>
37   -
38   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
39   -
40   - <?= $form->field($model, 'meta_desc')->textarea(['rows' => 6]) ?>
41   -
42   - <?= $form->field($model, 'meta_robots')->textInput(['maxlength' => true]) ?>
43   -
44   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
45   -
  24 +
  25 + <?= $form->field($model, 'name')
  26 + ->textInput() ?>
  27 +
  28 + <?= $form->field($model, 'alias')
  29 + ->textInput([ 'maxlength' => true ]) ?>
  30 +
  31 + <?= $form->field($model, 'image')
  32 + ->widget(\kartik\file\FileInput::classname(), [
  33 + 'language' => 'ru',
  34 + 'options' => [
  35 + 'accept' => 'image/*',
  36 + 'multiple' => false,
  37 + ],
  38 + 'pluginOptions' => [
  39 + 'allowedFileExtensions' => [
  40 + 'jpg',
  41 + 'gif',
  42 + 'png',
  43 + ],
  44 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  45 + 'overwriteInitial' => true,
  46 + 'showRemove' => false,
  47 + 'showUpload' => false,
  48 + 'previewFileType' => 'image',
  49 + ],
  50 + ]); ?>
  51 +
  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([
  65 + 'model_langs' => $model_langs,
  66 + 'formView' => '@backend/views/brand/_form_language',
  67 + 'form' => $form,
  68 + ]) ?>
  69 +
46 70 <div class="form-group">
47   - <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
48   - <?php if ($model->isNewRecord) :?>
49   - <?= Html::submitButton(Yii::t('product', 'Create and continue'), ['name' => 'create_and_new', 'class' => 'btn btn-primary']) ?>
50   - <?php endif?>
  71 + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
  72 + <?php if($model->isNewRecord) : ?>
  73 + <?= Html::submitButton(Yii::t('product', 'Create and continue'), [
  74 + 'name' => 'create_and_new',
  75 + 'class' => 'btn btn-primary',
  76 + ]) ?>
  77 + <?php endif ?>
51 78 </div>
52   -
  79 +
53 80 <?php ActiveForm::end(); ?>
54 81  
55 82 </div>
... ...
backend/views/brand/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\modules\language\models\Language;
  3 + use common\modules\product\models\BrandLang;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var BrandLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  15 + ->textInput([ 'maxlength' => true ]); ?>
  16 +
  17 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  18 + ->textInput([ 'maxlength' => true ]) ?>
  19 +
  20 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_robots')
  21 + ->textInput([ 'maxlength' => true ]) ?>
  22 +
  23 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_desc')
  24 + ->textInput([ 'maxlength' => true ]) ?>
  25 +
  26 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  27 + ->textarea([ 'rows' => 6 ]) ?>
... ...
backend/views/brand/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\product\models\Brand */
8   -
9   -$this->title = Yii::t('product', 'Create Brand');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\modules\product\models\Brand;
  4 + use common\modules\product\models\BrandLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Brand $model
  11 + * @var BrandLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('product', 'Create Brand');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('product', 'Brands'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="brand-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/brand/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\product\models\Brand */
7   -
8   -$this->title = Yii::t('product', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Brand',
10   -]) . ' ' . $model->brand_id;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->brand_id, 'url' => ['view', 'id' => $model->brand_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('product', 'Update');
  2 +
  3 + use common\modules\product\models\Brand;
  4 + use common\modules\product\models\BrandLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Brand $model
  11 + * @var BrandLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('product', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Brand',
  16 + ]) . ' ' . $model->brand_id;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('product', 'Brands'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->brand_id,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->brand_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update');
14 29 ?>
15 30 <div class="brand-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/category/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use mihaildev\ckeditor\CKEditor;
6   -use mihaildev\elfinder\ElFinder;
7   -use common\modules\file\widgets\ImageUploader;
8   -use kartik\select2\Select2;
9   -
10   -/* @var $this yii\web\View */
11   -/* @var $model common\modules\product\models\Category */
12   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\modules\language\widgets\LanguageForm;
  4 + use common\modules\product\models\Category;
  5 + use common\modules\product\models\CategoryLang;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use mihaildev\ckeditor\CKEditor;
  10 + use mihaildev\elfinder\ElFinder;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Category $model
  15 + * @var CategoryLang[] $model_langs
  16 + * @var string[] $categories
  17 + * @var ActiveForm $form
  18 + */
13 19 ?>
14 20  
15 21 <div class="category-form">
16   -
  22 +
17 23 <?php $form = ActiveForm::begin([
18 24 'enableClientValidation' => false,
19   - 'options' => ['enctype' => 'multipart/form-data']
  25 + 'options' => [ 'enctype' => 'multipart/form-data' ],
20 26 ]); ?>
21   -
22   - <?= $form->field($model, 'name')->textInput() ?>
23   -
24   - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
25   -
26   - <?= $form->field($model, 'parent_id')->dropDownList($categories, [
27   - 'prompt' => Yii::t('rubrication', 'Root category'),
28   - 'options' => [
29   - $model->category_id => ['disabled' => true]
30   - ]
31   - ])->label(Yii::t('product', 'Parent category')) ?>
32   -
  27 +
  28 + <?= $form->field($model, 'name')
  29 + ->textInput() ?>
  30 +
  31 + <?= $form->field($model, 'alias')
  32 + ->textInput([ 'maxlength' => true ]) ?>
  33 +
  34 + <?= $form->field($model, 'parent_id')
  35 + ->dropDownList($categories, [
  36 + 'prompt' => Yii::t('rubrication', 'Root category'),
  37 + 'options' => [
  38 + $model->category_id => [ 'disabled' => true ],
  39 + ],
  40 + ])
  41 + ->label(Yii::t('product', 'Parent category')) ?>
  42 +
33 43 <?php
34   - /* Tax group - add to controller
  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 + */
35 59 ?>
36   - <?= $form->field($model, 'taxGroup')->widget(Select2::className(), [
37   - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'),
38   - 'language' => 'ru',
39   - 'options' => [
40   - 'placeholder' => 'Linked options',
41   - 'multiple' => true,
42   - ],
43   - 'pluginOptions' => [
44   - 'allowClear' => true
45   - ],
46   - ]
47   - ) ?>
48   - */
49   - ?>
50   -
51   - <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
52   - 'language' => 'ru',
53   - 'options' => [
54   - 'accept' => 'image/*',
55   - 'multiple' => false,
56   - ],
57   - 'pluginOptions' => [
58   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
59   - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
60   - 'overwriteInitial' => true,
61   - 'showRemove' => false,
62   - 'showUpload' => false,
63   - 'previewFileType' => 'image',
64   - ],
65   - ])->hint('ะ”ะปั ะบะพั€ั€ะตะบั‚ะฝะพะณะพ ะพั‚ะพะฑั€ะฐะถะตะฝะธั ะฝะฐ ัะฐะนั‚ะต, ั€ะฐะทะผะตั€ ะธะทะพะฑั€ะฐะถะตะฝะธั ะดะพะปะถะตะฝ ะฑั‹ั‚ัŒ 262x144 ะปะธะฑะพ ัะพะฑะปัŽะดะฐั‚ัŒ ัะพะพั‚ะฝะพัˆะตะฝะธะต ัั‚ะพั€ะพะฝ ะฟั€ะธะผะตั€ะฝะพ 2:1'); ?>
66   -
67   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
68   -
69   - <?= $form->field($model, 'meta_desc')->textarea(['rows' => 6]) ?>
70   -
71   - <?= $form->field($model, 'meta_robots')->textInput(['maxlength' => true]) ?>
72   -
73   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
74   -
75   - <?= $form->field($model, 'seo_text')->widget(CKEditor::className(),
76   - [
77   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
78   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
79   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
80   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
81   - ]
82   - )
83   - ]) ?>
84   -
  60 +
  61 + <?= $form->field($model, 'imageUpload')
  62 + ->widget(\kartik\file\FileInput::classname(), [
  63 + 'language' => 'ru',
  64 + 'options' => [
  65 + 'accept' => 'image/*',
  66 + 'multiple' => false,
  67 + ],
  68 + 'pluginOptions' => [
  69 + 'allowedFileExtensions' => [
  70 + 'jpg',
  71 + 'gif',
  72 + 'png',
  73 + ],
  74 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  75 + 'overwriteInitial' => true,
  76 + 'showRemove' => false,
  77 + 'showUpload' => false,
  78 + 'previewFileType' => 'image',
  79 + ],
  80 + ])
  81 + ->hint('ะ”ะปั ะบะพั€ั€ะตะบั‚ะฝะพะณะพ ะพั‚ะพะฑั€ะฐะถะตะฝะธั ะฝะฐ ัะฐะนั‚ะต, ั€ะฐะทะผะตั€ ะธะทะพะฑั€ะฐะถะตะฝะธั ะดะพะปะถะตะฝ ะฑั‹ั‚ัŒ 262x144 ะปะธะฑะพ ัะพะฑะปัŽะดะฐั‚ัŒ ัะพะพั‚ะฝะพัˆะตะฝะธะต ัั‚ะพั€ะพะฝ ะฟั€ะธะผะตั€ะฝะพ 2:1'); ?>
  82 +
  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([
  108 + 'model_langs' => $model_langs,
  109 + 'formView' => '@backend/views/category/_form_language',
  110 + 'form' => $form,
  111 + ]) ?>
  112 +
85 113 <div class="form-group">
86   - <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
87   - <?php if ($model->isNewRecord) :?>
88   - <?= Html::submitButton(Yii::t('product', 'Create and continue'), ['name' => 'create_and_new', 'class' => 'btn btn-primary']) ?>
89   - <?php endif?>
  114 + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
  115 + <?php if($model->isNewRecord) : ?>
  116 + <?= Html::submitButton(Yii::t('product', 'Create and continue'), [
  117 + 'name' => 'create_and_new',
  118 + 'class' => 'btn btn-primary',
  119 + ]) ?>
  120 + <?php endif ?>
90 121 </div>
91   -
  122 +
92 123 <?php ActiveForm::end(); ?>
93 124  
94 125 </div>
... ...
backend/views/category/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\modules\language\models\Language;
  3 + use common\modules\product\models\CategoryLang;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var CategoryLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  15 + ->textInput([ 'maxlength' => true ]); ?>
  16 +
  17 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  18 + ->textInput([ 'maxlength' => true ]) ?>
  19 +
  20 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_robots')
  21 + ->textInput([ 'maxlength' => true ]) ?>
  22 +
  23 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_desc')
  24 + ->textInput([ 'maxlength' => true ]) ?>
  25 +
  26 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  27 + ->textarea([ 'rows' => 6 ]) ?>
  28 +
  29 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  30 + ->textInput([ 'maxlength' => true ]) ?>
0 31 \ No newline at end of file
... ...
backend/views/category/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\product\models\Category */
8   -
9   -$this->title = Yii::t('product', 'Create Category');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\modules\product\models\Category;
  4 + use common\modules\product\models\CategoryLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Category $model
  11 + * @var CategoryLang[] $model_langs
  12 + * @var string[] $categories
  13 + */
  14 +
  15 + $this->title = Yii::t('product', 'Create Category');
  16 + $this->params[ 'breadcrumbs' ][] = [
  17 + 'label' => Yii::t('product', 'Categories'),
  18 + 'url' => [ 'index' ],
  19 + ];
  20 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 21 ?>
13 22 <div class="category-create">
14   -
  23 +
15 24 <h1><?= Html::encode($this->title) ?></h1>
16   -
  25 +
17 26 <?= $this->render('_form', [
18   - 'model' => $model,
19   - 'categories' => $categories
  27 + 'model' => $model,
  28 + 'model_langs' => $model_langs,
  29 + 'categories' => $categories,
20 30 ]) ?>
21 31  
22 32 </div>
... ...
backend/views/category/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\product\models\Category */
7   -
8   -$this->title = Yii::t('product', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Category',
10   -]) . ' ' . $model->name;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->category_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('product', 'Update');
  2 +
  3 + use common\modules\product\models\Category;
  4 + use common\modules\product\models\CategoryLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Category $model
  11 + * @var CategoryLang[] $model_langs
  12 + * @var string[] $categories
  13 + */
  14 +
  15 + $this->title = Yii::t('product', 'Update {modelClass}: ', [
  16 + 'modelClass' => 'Category',
  17 + ]) . ' ' . $model->name;
  18 + $this->params[ 'breadcrumbs' ][] = [
  19 + 'label' => Yii::t('product', 'Categories'),
  20 + 'url' => [ 'index' ],
  21 + ];
  22 + $this->params[ 'breadcrumbs' ][] = [
  23 + 'label' => $model->name,
  24 + 'url' => [
  25 + 'view',
  26 + 'id' => $model->category_id,
  27 + ],
  28 + ];
  29 + $this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update');
14 30 ?>
15 31 <div class="category-update">
16   -
  32 +
17 33 <h1><?= Html::encode($this->title) ?></h1>
18   -
  34 +
19 35 <?= $this->render('_form', [
20   - 'model' => $model,
21   - 'categories' => $categories
  36 + 'model' => $model,
  37 + 'model_langs' => $model_langs,
  38 + 'categories' => $categories,
22 39 ]) ?>
23 40  
24 41 </div>
... ...
backend/views/event/_form.php
1 1 <?php
2   -
3   -use kartik\date\DatePicker;
4   -use yii\helpers\Html;
5   -use yii\widgets\ActiveForm;
6   -use mihaildev\ckeditor\CKEditor;
7   -use mihaildev\elfinder\ElFinder;
8   -/* @var $this yii\web\View */
9   -/* @var $model common\models\Event */
10   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Event;
  4 + use common\models\EventLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use kartik\date\DatePicker;
  7 + use yii\helpers\Html;
  8 + use yii\web\View;
  9 + use yii\widgets\ActiveForm;
  10 + use mihaildev\ckeditor\CKEditor;
  11 + use mihaildev\elfinder\ElFinder;
  12 +
  13 + /**
  14 + * @var View $this
  15 + * @var Event $model
  16 + * @var EventLang[] $model_langs
  17 + * @var ActiveForm $form
  18 + */
11 19 ?>
12 20  
13 21 <div class="event-form">
14   -
  22 +
15 23 <?php $form = ActiveForm::begin([
16 24 'enableClientValidation' => false,
17   - 'options' => ['enctype' => 'multipart/form-data']
  25 + 'options' => [ 'enctype' => 'multipart/form-data' ],
18 26 ]); ?>
19   -
20   - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
21   -
22   - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
23   -
24   - <?= $form->field($model, 'body')->widget(CKEditor::className(),
25   - [
26   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
27   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
28   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
29   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
30   - ]
31   - )
32   - ]) ?>
33   -
34   -
  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 +
35 47 <?= $form->field($model, 'end_at')
36   - ->widget(DatePicker::className(), [
37   - 'pluginOptions' => [
38   - 'format' => 'dd-mm-yyyy',
39   - 'todayHighlight' => true
40   - ]]) ?>
41   -
42   -
43   - <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
44   - 'language' => 'ru',
45   - 'options' => [
46   - 'accept' => 'image/*',
47   - 'multiple' => false,
48   - ],
49   - 'pluginOptions' => [
50   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
51   - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
52   - 'overwriteInitial' => true,
53   - 'showRemove' => false,
54   - 'showUpload' => false,
55   - 'previewFileType' => 'image',
56   - ],
57   - ]); ?>
58   -
59   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
60   -
61   - <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
62   -
63   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
64   -
65   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
66   -
67   -
68   -
  48 + ->widget(DatePicker::className(), [
  49 + 'pluginOptions' => [
  50 + 'format' => 'dd-mm-yyyy',
  51 + 'todayHighlight' => true,
  52 + ],
  53 + ]) ?>
  54 +
  55 +
  56 + <?= $form->field($model, 'imageUpload')
  57 + ->widget(\kartik\file\FileInput::className(), [
  58 + 'language' => 'ru',
  59 + 'options' => [
  60 + 'accept' => 'image/*',
  61 + 'multiple' => false,
  62 + ],
  63 + 'pluginOptions' => [
  64 + 'allowedFileExtensions' => [
  65 + 'jpg',
  66 + 'gif',
  67 + 'png',
  68 + ],
  69 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  70 + 'overwriteInitial' => true,
  71 + 'showRemove' => false,
  72 + 'showUpload' => false,
  73 + 'previewFileType' => 'image',
  74 + ],
  75 + ]); ?>
  76 +
  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([
  90 + 'model_langs' => $model_langs,
  91 + 'formView' => '@backend/views/event/_form_language',
  92 + 'form' => $form,
  93 + ]) ?>
  94 +
69 95 <div class="form-group">
70   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  96 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
71 97 </div>
72   -
  98 +
73 99 <?php ActiveForm::end(); ?>
74 100  
75 101 </div>
... ...
backend/views/event/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\EventLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var EventLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']body')
  19 + ->widget(CKEditor::className(), [
  20 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  21 + 'preset' => 'full',
  22 + 'inline' => false,
  23 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  24 + ->createUrl('file/uploader/images-upload'),
  25 + ]),
  26 + ]) ?>
  27 +
  28 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  29 + ->textInput([ 'maxlength' => true ]) ?>
  30 +
  31 +<?= $form->field($model_lang, '[' . $language->language_id . ']description')
  32 + ->textInput([ 'maxlength' => true ]) ?>
  33 +
  34 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  35 + ->textarea([ 'rows' => 6 ]) ?>
  36 +
  37 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  38 + ->textInput([ 'maxlength' => true ]) ?>
0 39 \ No newline at end of file
... ...
backend/views/event/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Event */
8   -
9   -$this->title = Yii::t('app', 'Create Event');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Events'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Event;
  4 + use common\models\EventLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Event $model
  11 + * @var EventLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Create Event');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('app', 'Events'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="event-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/event/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Event */
7   -
8   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Event',
10   -]) . $model->name;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Events'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->event_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\Event;
  4 + use common\models\EventLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Event $model
  11 + * @var EventLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Event',
  16 + ]) . $model->name;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Events'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->name,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->event_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
14 29 ?>
15 30 <div class="event-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/layouts/header.php
1 1 <?php
2 2  
3 3 /* @var $this \yii\web\View */
4   -/* @var $content string */
5   -
6   -use yii\helpers\Html;
7   -use yii\bootstrap\Nav;
8   -use yii\bootstrap\NavBar;
9   -use yii\helpers\Url;
10   -use yii\widgets\Breadcrumbs;
11   -use frontend\assets\AppAsset;
12   -use common\widgets\Alert;
13   -use yii\widgets\Menu;
14   -
  4 + use backend\assets\AppAsset;
  5 +
  6 + /* @var $content string */
  7 +
15 8 AppAsset::register($this);
16 9 ?>
17 10 <header class="main-header">
... ...
backend/views/page/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use mihaildev\ckeditor\CKEditor;
6   -use mihaildev\elfinder\ElFinder;
7   -/* @var $this yii\web\View */
8   -/* @var $model common\models\Page */
9   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Page;
  4 + use common\models\PageLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use mihaildev\ckeditor\CKEditor;
  10 + use mihaildev\elfinder\ElFinder;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Page $model
  15 + * @var ActiveForm $form
  16 + * @var PageLang[] $model_langs
  17 + */
10 18 ?>
11 19  
12 20 <div class="page-form">
13   -
  21 +
14 22 <?php $form = ActiveForm::begin(); ?>
15   -
16   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
17   -
18   - <?= $form->field($model, 'translit')->textInput(['maxlength' => true]) ?>
19   -
20   - <?= $form->field($model, 'body')->widget(CKEditor::className(),
21   - [
22   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
23   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
24   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
25   - 'allowedContent' => true,
26   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
27   - ]
28   - )
29   - ]) ?>
30   -
31   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
32   -
33   - <?= $form->field($model, 'meta_keywords')->textInput(['maxlength' => true]) ?>
34   -
35   - <?= $form->field($model, 'meta_description')->textInput(['maxlength' => true]) ?>
36   -
37   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
38   -
39   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
40 23  
41   - <?= $form->field($model, 'in_menu')->checkbox() ?>
42   -
  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([
  62 + 'model_langs' => $model_langs,
  63 + 'formView' => '@backend/views/page/_form_language',
  64 + 'form' => $form,
  65 + ]) ?>
  66 +
43 67 <div class="form-group">
44   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  68 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
45 69 </div>
46   -
  70 +
47 71 <?php ActiveForm::end(); ?>
48 72  
49 73 </div>
... ...
backend/views/page/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\PageLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var PageLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +
  19 +<?= $form->field($model_lang, '[' . $language->language_id . ']body')
  20 + ->widget(CKEditor::className(), [
  21 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  22 + 'preset' => 'full',
  23 + 'inline' => false,
  24 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  25 + ->createUrl('file/uploader/images-upload'),
  26 + ]),
  27 + ]) ?>
  28 +
  29 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  30 + ->textInput([ 'maxlength' => true ]) ?>
  31 +
  32 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_keywords')
  33 + ->textInput([ 'maxlength' => true ]) ?>
  34 +
  35 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_description')
  36 + ->textInput([ 'maxlength' => true ]) ?>
  37 +
  38 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  39 + ->textarea([ 'rows' => 6 ]) ?>
  40 +
  41 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  42 + ->textInput([ 'maxlength' => true ]) ?>
... ...
backend/views/page/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Page */
8   -
9   -$this->title = 'Create Page';
10   -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Page;
  4 + use common\models\PageLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Page $model
  11 + * @var PageLang[] $model_langs
  12 + */
  13 + $this->title = 'Create Page';
  14 + $this->params[ 'breadcrumbs' ][] = [
  15 + 'label' => 'Pages',
  16 + 'url' => [ 'index' ],
  17 + ];
  18 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 19 ?>
13 20 <div class="page-create">
14   -
  21 +
15 22 <h1><?= Html::encode($this->title) ?></h1>
16   -
  23 +
17 24 <?= $this->render('_form', [
18   - 'model' => $model,
  25 + 'model' => $model,
  26 + 'model_langs' => $model_langs,
19 27 ]) ?>
20 28  
21 29 </div>
... ...
backend/views/page/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Page */
7   -
8   -$this->title = 'Update Page: ' . $model->title;
9   -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\models\Page;
  4 + use common\models\PageLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Page $model
  11 + * @var PageLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = 'Update Page: ' . $model->title;
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Pages',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => $model->title,
  21 + 'url' => [
  22 + 'view',
  23 + 'id' => $model->id,
  24 + ],
  25 + ];
  26 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 27 ?>
13 28 <div class="page-update">
14   -
  29 +
15 30 <h1><?= Html::encode($this->title) ?></h1>
16   -
  31 +
17 32 <?= $this->render('_form', [
18   - 'model' => $model,
  33 + 'model' => $model,
  34 + 'model_langs' => $model_langs,
19 35 ]) ?>
20 36  
21 37 </div>
... ...
backend/views/project/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use mihaildev\ckeditor\CKEditor;
6   -use mihaildev\elfinder\ElFinder;
7   -use yii\jui\DatePicker;
8   -/* @var $this yii\web\View */
9   -/* @var $model common\models\Project */
10   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Project;
  4 + use common\models\ProjectLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use mihaildev\ckeditor\CKEditor;
  10 + use mihaildev\elfinder\ElFinder;
  11 + use yii\jui\DatePicker;
  12 +
  13 + /**
  14 + * @var View $this
  15 + * @var Project $model
  16 + * @var ProjectLang $model_langs
  17 + * @var ActiveForm $form
  18 + */
11 19 ?>
12 20  
13 21 <div class="articles-form">
14   -
  22 +
15 23 <?php $form = ActiveForm::begin([
16   - 'options' => ['enctype' => 'multipart/form-data']
  24 + 'options' => [ 'enctype' => 'multipart/form-data' ],
17 25 ]); ?>
18   -
19   -
  26 +
  27 +
20 28 <?= $form->field($model, 'date_add')
21   - ->widget(DatePicker::className(), [
22   - 'dateFormat' => 'dd-MM-yyyy',
23   - ]) ?>
24   -
25   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
26   -
27   - <?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
28   -
29   - <?= $form->field($model, 'description')->widget(CKEditor::className(),
30   - [
31   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
32   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
33   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
34   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
35   - ]
36   - )
37   - ]) ?>
38   -
39   - <?= $form->field($model, 'imagesUpload[]')->widget(\kartik\file\FileInput::className(), [
40   - 'language' => 'ru',
41   - 'options' => [
42   - 'accept' => 'image/*',
43   - 'multiple' => true,
44   - ],
45   - 'pluginOptions' => [
46   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
47   - 'initialPreview' => !empty($model->imagesHTML) ? $model->imagesHTML : [],
48   - 'initialPreviewConfig' => $model->imagesConfig,
49   - 'overwriteInitial' => false,
50   - 'showRemove' => false,
51   - 'showUpload' => false,
52   - 'uploadAsync' => !empty($model->project_id),
53   - 'previewFileType' => 'image',
54   - ],
55   - ]); ?>
56   -
  29 + ->widget(DatePicker::className(), [
  30 + 'dateFormat' => 'dd-MM-yyyy',
  31 + ]) ?>
  32 +
  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[]')
  52 + ->widget(\kartik\file\FileInput::className(), [
  53 + 'language' => 'ru',
  54 + 'options' => [
  55 + 'accept' => 'image/*',
  56 + 'multiple' => true,
  57 + ],
  58 + 'pluginOptions' => [
  59 + 'allowedFileExtensions' => [
  60 + 'jpg',
  61 + 'gif',
  62 + 'png',
  63 + ],
  64 + 'initialPreview' => !empty( $model->imagesHTML ) ? $model->imagesHTML : [],
  65 + 'initialPreviewConfig' => $model->imagesConfig,
  66 + 'overwriteInitial' => false,
  67 + 'showRemove' => false,
  68 + 'showUpload' => false,
  69 + 'uploadAsync' => !empty( $model->project_id ),
  70 + 'previewFileType' => 'image',
  71 + ],
  72 + ]); ?>
  73 +
  74 + <?= LanguageForm::widget([
  75 + 'model_langs' => $model_langs,
  76 + 'formView' => '@backend/views/project/_form_language',
  77 + 'form' => $form,
  78 + ]) ?>
  79 +
57 80 <div class="form-group">
58   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  81 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
59 82 </div>
60   -
  83 +
61 84 <?php ActiveForm::end(); ?>
62 85  
63 86 </div>
... ...
backend/views/project/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\ProjectLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var ProjectLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']description')
  19 + ->widget(CKEditor::className(), [
  20 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  21 + 'preset' => 'full',
  22 + 'inline' => false,
  23 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  24 + ->createUrl('file/uploader/images-upload'),
  25 + ]),
  26 + ]) ?>
0 27 \ No newline at end of file
... ...
backend/views/project/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Articles */
8   -
9   -$this->title = 'Create Project';
10   -$this->params['breadcrumbs'][] = ['label' => 'Projects', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Project;
  4 + use common\models\ProjectLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Project $model
  11 + * @var ProjectLang $model_langs
  12 + */
  13 +
  14 + $this->title = 'Create Project';
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Projects',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="articles-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/project/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Project */
7   -
8   -$this->title = 'Update Project: ' . $model->title;
9   -$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->project_id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\models\Project;
  4 + use common\models\ProjectLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Project $model
  11 + * @var ProjectLang $model_langs
  12 + */
  13 + $this->title = 'Update Project: ' . $model->title;
  14 + $this->params[ 'breadcrumbs' ][] = [
  15 + 'label' => 'Project',
  16 + 'url' => [ 'index' ],
  17 + ];
  18 + $this->params[ 'breadcrumbs' ][] = [
  19 + 'label' => $model->title,
  20 + 'url' => [
  21 + 'view',
  22 + 'id' => $model->project_id,
  23 + ],
  24 + ];
  25 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 26 ?>
13 27 <div class="articles-update">
14   -
  28 +
15 29 <h1><?= Html::encode($this->title) ?></h1>
16   -
  30 +
17 31 <?= $this->render('_form', [
18   - 'model' => $model,
  32 + 'model' => $model,
  33 + 'model_langs' => $model_langs,
19 34 ]) ?>
20 35  
21 36 </div>
... ...
backend/views/seo-category/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\SeoCategory */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\SeoCategory;
  4 + use common\models\SeoCategoryLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var SeoCategory $model
  13 + * @var SeoCategoryLang[] $model_langs
  14 + * @var ActiveForm $form
  15 + */
9 16 ?>
10 17  
11 18 <div class="seo-category-form">
12   -
  19 +
13 20 <?php $form = ActiveForm::begin(); ?>
14   -
15   - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
16   -
17   - <?= $form->field($model, 'controller')->textInput(['maxlength' => true]) ?>
18   -
19   - <?= $form->field($model, 'status')->textInput() ?>
20   -
  21 +
  22 + <?= $form->field($model, 'name')
  23 + ->textInput([ 'maxlength' => true ]) ?>
  24 +
  25 + <?= $form->field($model, 'controller')
  26 + ->textInput([ 'maxlength' => true ]) ?>
  27 +
  28 + <?= $form->field($model, 'status')
  29 + ->textInput() ?>
  30 +
  31 + <?= LanguageForm::widget([
  32 + 'model_langs' => $model_langs,
  33 + 'formView' => '@backend/views/seo-category/_form_language',
  34 + 'form' => $form,
  35 + ]) ?>
  36 +
21 37 <div class="form-group">
22   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  38 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
23 39 </div>
24   -
  40 +
25 41 <?php ActiveForm::end(); ?>
26 42  
27 43 </div>
... ...
backend/views/seo-category/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\SeoCategoryLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var SeoCategoryLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  15 + ->textInput([ 'maxlength' => true ]); ?>
0 16 \ No newline at end of file
... ...
backend/views/seo-category/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\SeoCategory */
8   -
9   -$this->title = Yii::t('app', 'Create Seo Category');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\SeoCategory;
  4 + use common\models\SeoCategoryLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var SeoCategory $model
  11 + * @var SeoCategoryLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Create Seo Category');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('app', 'Seo Categories'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="seo-category-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/seo-category/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\SeoCategory */
7   -
8   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Seo Category',
10   -]) . $model->name;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->seo_category_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\SeoCategory;
  4 + use common\models\SeoCategoryLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var SeoCategory $model
  11 + * @var SeoCategoryLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Seo Category',
  16 + ]) . $model->name;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Seo Categories'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->name,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->seo_category_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
14 29 ?>
15 30 <div class="seo-category-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/seo-dynamic/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\SeoDynamic */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\SeoDynamic;
  4 + use common\models\SeoDynamicLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var SeoDynamic $model
  13 + * @var SeoDynamicLang[] $model_langs
  14 + * @var int $seo_category_id
  15 + * @var ActiveForm $form
  16 + */
9 17 ?>
10 18 <style>
11 19 #seodynamic-filter_mod {
... ... @@ -13,47 +21,51 @@ use yii\widgets\ActiveForm;
13 21 }
14 22 </style>
15 23 <div class="seo-dynamic-form">
16   -
  24 +
17 25 <?php $form = ActiveForm::begin(); ?>
18   -
19   - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
20   -
21   - <?= $form->field($model, 'action')->textInput(['maxlength' => true]) ?>
22   -
23   - <?= $form->field($model, 'param')->textInput(['maxlength' => true]) ?>
24   -
25   - <?= $form->field($model, 'key')->textInput(['maxlength' => true]) ?>
26   -
27   - <?= $form->field($model, 'fields')->textInput(['maxlength' => true]) ?>
28   -
29   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
30   -
31   - <?= $form->field($model, 'meta')->textInput(['maxlength' => true]) ?>
32   -
33   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
34   -
35   - <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
36   -
37   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
38   -
39   - <?= $form->field($model, 'status')->textInput() ?>
40   -
  26 +
  27 + <?= $form->field($model, 'name')
  28 + ->textInput([ 'maxlength' => true ]) ?>
  29 +
  30 + <?= $form->field($model, 'action')
  31 + ->textInput([ 'maxlength' => true ]) ?>
  32 +
  33 + <?= $form->field($model, 'param')
  34 + ->textInput([ 'maxlength' => true ]) ?>
  35 +
  36 + <?= $form->field($model, 'key')
  37 + ->textInput([ 'maxlength' => true ]) ?>
  38 +
  39 + <?= $form->field($model, 'fields')
  40 + ->textInput([ 'maxlength' => true ]) ?>
  41 +
  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')
  58 + ->textInput() ?>
  59 +
  60 + <?= LanguageForm::widget([
  61 + 'model_langs' => $model_langs,
  62 + 'formView' => '@backend/views/seo-dynamic/_form_language',
  63 + 'form' => $form,
  64 + ]) ?>
  65 +
41 66 <div class="form-group">
42   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  67 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
43 68 </div>
44   -
  69 +
45 70 <?php ActiveForm::end(); ?>
46   -<!--<script>-->
47   -<!-- $('#seodynamic-param').on('change',function(){-->
48   -<!---->
49   -<!-- if($(this).val() == 'filter') {-->
50   -<!-- $('#seodynamic-filter_mod').show();-->
51   -<!-- alert('ok');-->
52   -<!-- } else {-->
53   -<!---->
54   -<!-- $('#seodynamic-filter_mod').hide();-->
55   -<!-- }-->
56   -<!-- });-->
57   -<!---->
58   -<!--</script>-->
59 71 </div>
... ...
backend/views/seo-dynamic/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\SeoDynamicLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var SeoDynamicLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  19 + ->textInput(); ?>
  20 +<?= $form->field($model_lang, '[' . $language->language_id . ']description')
  21 + ->widget(CKEditor::className(), [
  22 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  23 + 'preset' => 'full',
  24 + 'inline' => false,
  25 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  26 + ->createUrl('file/uploader/images-upload'),
  27 + ]),
  28 + ]) ?>
  29 +
  30 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  31 + ->widget(CKEditor::className(), [
  32 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  33 + 'preset' => 'full',
  34 + 'inline' => false,
  35 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  36 + ->createUrl('file/uploader/images-upload'),
  37 + ]),
  38 + ]) ?>
  39 +<?= $form->field($model_lang, '[' . $language->language_id . ']key')
  40 + ->textInput([ 'maxlength' => true ]) ?>
  41 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  42 + ->textInput([ 'maxlength' => true ]) ?>
  43 +
  44 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta')
  45 + ->textInput([ 'maxlength' => true ]) ?>
0 46 \ No newline at end of file
... ...
backend/views/seo-dynamic/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\helpers\Url;
5   -
6   -
7   -/* @var $this yii\web\View */
8   -/* @var $model common\models\SeoDynamic */
9   -
10   -$this->title = Yii::t('app', 'Create Seo Dynamic');
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => Url::toRoute(['index','seo_category_id'=>$seo_category_id])];
12   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\SeoDynamic;
  4 + use common\models\SeoDynamicLang;
  5 + use yii\helpers\Html;
  6 + use yii\helpers\Url;
  7 + use yii\web\View;
  8 +
  9 + /**
  10 + * @var View $this
  11 + * @var SeoDynamic $model
  12 + * @var SeoDynamicLang[] $model_langs
  13 + * @var int $seo_category_id
  14 + */
  15 +
  16 + $this->title = Yii::t('app', 'Create Seo Dynamic');
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Seo Dynamics'),
  19 + 'url' => Url::toRoute([
  20 + 'index',
  21 + 'seo_category_id' => $seo_category_id,
  22 + ]),
  23 + ];
  24 + $this->params[ 'breadcrumbs' ][] = $this->title;
13 25 ?>
14 26 <div class="seo-dynamic-create">
15   -
  27 +
16 28 <h1><?= Html::encode($this->title) ?></h1>
17   -
  29 +
18 30 <?= $this->render('_form', [
19   - 'model' => $model,
  31 + 'model' => $model,
  32 + 'model_langs' => $model_langs,
20 33 ]) ?>
21 34  
22 35 </div>
... ...
backend/views/seo-dynamic/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\helpers\Url;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\SeoDynamic */
8   -
9   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
10   - 'modelClass' => 'Seo Dynamic',
11   -]) . $model->name;
12   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => Url::toRoute(['index','seo_category_id'=>$seo_category_id])];
13   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => Url::toRoute(['view', 'seo_category_id'=>$seo_category_id, 'id' => $model->seo_dynamic_id])];
14   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\SeoDynamic;
  4 + use common\models\SeoDynamicLang;
  5 + use yii\helpers\Html;
  6 + use yii\helpers\Url;
  7 + use yii\web\View;
  8 +
  9 + /**
  10 + * @var View $this
  11 + * @var SeoDynamic $model
  12 + * @var SeoDynamicLang[] $model_langs
  13 + * @var int $seo_category_id
  14 + */
  15 +
  16 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  17 + 'modelClass' => 'Seo Dynamic',
  18 + ]) . $model->name;
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => Yii::t('app', 'Seo Dynamics'),
  21 + 'url' => Url::toRoute([
  22 + 'index',
  23 + 'seo_category_id' => $seo_category_id,
  24 + ]),
  25 + ];
  26 + $this->params[ 'breadcrumbs' ][] = [
  27 + 'label' => $model->name,
  28 + 'url' => Url::toRoute([
  29 + 'view',
  30 + 'seo_category_id' => $seo_category_id,
  31 + 'id' => $model->seo_dynamic_id,
  32 + ]),
  33 + ];
  34 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
15 35 ?>
16 36 <div class="seo-dynamic-update">
17   -
  37 +
18 38 <h1><?= Html::encode($this->title) ?></h1>
19   -
  39 +
20 40 <?= $this->render('_form', [
21   - 'model' => $model,
  41 + 'model' => $model,
  42 + 'model_langs' => $model_langs,
22 43 ]) ?>
23 44  
24 45 </div>
... ...
backend/views/seo/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use mihaildev\ckeditor\CKEditor;
6   -use mihaildev\elfinder\ElFinder;
7   -/* @var $this yii\web\View */
8   -/* @var $model common\models\Seo */
9   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Seo;
  4 + use common\models\SeoLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use mihaildev\ckeditor\CKEditor;
  10 + use mihaildev\elfinder\ElFinder;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Seo $model
  15 + * @var SeoLang[] $model_langs
  16 + * @var ActiveForm $form
  17 + */
10 18 ?>
11 19  
12 20 <div class="seo-form">
13   -
  21 +
14 22 <?php $form = ActiveForm::begin(); ?>
15   -
16   - <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
17   -
18   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
19   -
20   - <?= $form->field($model, 'meta')->textInput(['maxlength' => true]) ?>
21   -
22   - <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
23   -
24   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
25   - <?= $form->field($model, 'seo_text')->widget(CKEditor::className(),
26   - [
27   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
28   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
29   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
30   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
31   - ]
32   - )
33   - ]) ?>
34   -
  23 +
  24 + <?= $form->field($model, 'url')
  25 + ->textInput([ 'maxlength' => true ]) ?>
  26 +
  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([
  51 + 'model_langs' => $model_langs,
  52 + 'formView' => '@backend/views/seo/_form_language',
  53 + 'form' => $form,
  54 + ]) ?>
  55 +
35 56 <div class="form-group">
36   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  57 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
37 58 </div>
38   -
  59 +
39 60 <?php ActiveForm::end(); ?>
40 61  
41 62 </div>
... ...
backend/views/seo/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\SeoLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var SeoLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']description')
  19 + ->widget(CKEditor::className(), [
  20 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  21 + 'preset' => 'full',
  22 + 'inline' => false,
  23 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  24 + ->createUrl('file/uploader/images-upload'),
  25 + ]),
  26 + ]) ?>
  27 +
  28 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  29 + ->widget(CKEditor::className(), [
  30 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  31 + 'preset' => 'full',
  32 + 'inline' => false,
  33 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  34 + ->createUrl('file/uploader/images-upload'),
  35 + ]),
  36 + ]) ?>
  37 +
  38 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  39 + ->textInput([ 'maxlength' => true ]) ?>
  40 +
  41 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta')
  42 + ->textInput([ 'maxlength' => true ]) ?>
0 43 \ No newline at end of file
... ...
backend/views/seo/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Seo */
8   -
9   -$this->title = Yii::t('app', 'Create Seo');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Seo;
  4 + use common\models\SeoLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Seo $model
  11 + * @var SeoLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Create Seo');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('app', 'Seos'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="seo-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/seo/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Seo */
7   -
8   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Seo',
10   -]) . $model->title;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->seo_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\Seo;
  4 + use common\models\SeoLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Seo $model
  11 + * @var SeoLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Seo',
  16 + ]) . $model->title;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Seos'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->title,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->seo_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
14 29 ?>
15 30 <div class="seo-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/service/_form.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -use mihaildev\ckeditor\CKEditor;
6   -use mihaildev\elfinder\ElFinder;
7   -use yii\jui\DatePicker;
8   -/* @var $this yii\web\View */
9   -/* @var $model common\models\Service */
10   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\models\Service;
  4 + use common\models\ServiceLang;
  5 + use common\modules\language\widgets\LanguageForm;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use mihaildev\ckeditor\CKEditor;
  10 + use mihaildev\elfinder\ElFinder;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var Service $model
  15 + * @var ServiceLang[] $model_langs
  16 + * @var ActiveForm $form
  17 + */
11 18 ?>
12 19  
13 20 <div class="service-form">
14   -
  21 +
15 22 <?php $form = ActiveForm::begin(); ?>
16   -
17   - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
18   -
19   - <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
20   -
21   - <?= $form->field($model, 'body')->widget(CKEditor::className(),
22   - [
23   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
24   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
25   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
26   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
27   - ]
28   - )
29   - ]) ?>
30   -
31   -
  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 +
32 43 <?= \common\modules\file\widgets\ImageUploader::widget([
33   - 'model'=> $model,
34   - 'field'=>'image',
35   - 'size' => [
  44 + 'model' => $model,
  45 + 'field' => 'image',
  46 + 'size' => [
36 47 [
37   - 'width'=>200,
38   - 'height'=>200,
  48 + 'width' => 200,
  49 + 'height' => 200,
39 50 ],
40 51 [
41   - 'width'=>940,
42   - 'height'=>480,
43   - ]
  52 + 'width' => 940,
  53 + 'height' => 480,
  54 + ],
44 55 ],
45   - 'multi'=>false,
  56 + 'multi' => false,
46 57 'gallery' => $model->image,
47   - 'name' => 'ะ—ะฐะณั€ัƒะทะธั‚ัŒ ะธะทะพะฑั€ะฐะถะตะฝะธะต'
48   - ]);
49   - ?>
50   -
51   - <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
52   -
53   - <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
54   -
55   - <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
56   -
57   - <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
58   -
59   -
  58 + 'name' => 'ะ—ะฐะณั€ัƒะทะธั‚ัŒ ะธะทะพะฑั€ะฐะถะตะฝะธะต',
  59 + ]); ?>
  60 +
  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 ]) ?>
  72 +
  73 + <?= LanguageForm::widget([
  74 + 'model_langs' => $model_langs,
  75 + 'formView' => '@backend/views/service/_form_language',
  76 + 'form' => $form,
  77 + ]) ?>
  78 +
60 79 <div class="form-group">
61   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  80 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
62 81 </div>
63   -
  82 +
64 83 <?php ActiveForm::end(); ?>
65 84  
66 85 </div>
... ...
backend/views/service/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\ServiceLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var ServiceLang $model_lang
  11 + * @var Language $language
  12 + * @var ActiveForm $form
  13 + * @var View $this
  14 + */
  15 +?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']name')
  17 + ->textInput([ 'maxlength' => true ]); ?>
  18 +<?= $form->field($model_lang, '[' . $language->language_id . ']body')
  19 + ->widget(CKEditor::className(), [
  20 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  21 + 'preset' => 'full',
  22 + 'inline' => false,
  23 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  24 + ->createUrl('file/uploader/images-upload'),
  25 + ]),
  26 + ]) ?>
  27 +
  28 +<?= $form->field($model_lang, '[' . $language->language_id . ']seo_text')
  29 + ->widget(CKEditor::className(), [
  30 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [
  31 + 'preset' => 'full',
  32 + 'inline' => false,
  33 + 'filebrowserUploadUrl' => Yii::$app->getUrlManager()
  34 + ->createUrl('file/uploader/images-upload'),
  35 + ]),
  36 + ]) ?>
  37 +
  38 +<?= $form->field($model_lang, '[' . $language->language_id . ']meta_title')
  39 + ->textInput([ 'maxlength' => true ]) ?>
  40 +
  41 +<?= $form->field($model_lang, '[' . $language->language_id . ']description')
  42 + ->textInput([ 'maxlength' => true ]) ?>
  43 +
  44 +<?= $form->field($model_lang, '[' . $language->language_id . ']h1')
  45 + ->textInput([ 'maxlength' => true ]) ?>
0 46 \ No newline at end of file
... ...
backend/views/service/create.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Service */
8   -
9   -$this->title = Yii::t('app', 'Create Service');
10   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Services'), 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Service;
  4 + use common\models\ServiceLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Service $model
  11 + * @var ServiceLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Create Service');
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => Yii::t('app', 'Services'),
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="service-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
  24 +
17 25 <?= $this->render('_form', [
18   - 'model' => $model,
  26 + 'model' => $model,
  27 + 'model_langs' => $model_langs,
19 28 ]) ?>
20 29  
21 30 </div>
... ...
backend/views/service/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Service */
7   -
8   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
9   - 'modelClass' => 'Service',
10   -]) . $model->name;
11   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Services'), 'url' => ['index']];
12   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->service_id]];
13   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\Service;
  4 + use common\models\ServiceLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Service $model
  11 + * @var ServiceLang[] $model_langs
  12 + */
  13 +
  14 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  15 + 'modelClass' => 'Service',
  16 + ]) . $model->name;
  17 + $this->params[ 'breadcrumbs' ][] = [
  18 + 'label' => Yii::t('app', 'Services'),
  19 + 'url' => [ 'index' ],
  20 + ];
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => $model->name,
  23 + 'url' => [
  24 + 'view',
  25 + 'id' => $model->service_id,
  26 + ],
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
14 29 ?>
15 30 <div class="service-update">
16   -
  31 +
17 32 <h1><?= Html::encode($this->title) ?></h1>
18   -
  33 +
19 34 <?= $this->render('_form', [
20   - 'model' => $model,
  35 + 'model' => $model,
  36 + 'model_langs' => $model_langs,
21 37 ]) ?>
22 38  
23 39 </div>
... ...
backend/views/slider-image/_form.php
1 1 <?php
  2 +
  3 + use common\models\Slider;
  4 + use common\models\SliderImage;
  5 + use common\models\SliderImageLang;
  6 + use common\modules\language\widgets\LanguageForm;
  7 + use kartik\select2\Select2;
  8 + use yii\helpers\Html;
  9 + use yii\web\View;
  10 + use yii\widgets\ActiveForm;
  11 +
  12 + /**
  13 + * @var View $this
  14 + * @var SliderImage $model
  15 + * @var SliderImageLang[] $model_langs
  16 + * @var Slider $slider
  17 + * @var ActiveForm $form
  18 + */
2 19  
3   -use common\models\Slider;
4   -use common\modules\file\widgets\ImageUploader;
5   -use kartik\select2\Select2;
6   -use yii\helpers\Html;
7   -use yii\widgets\ActiveForm;
8   -
9   -/* @var $this yii\web\View */
10   -/* @var $slider Slider*/
11   -/* @var $model common\models\SliderImage */
12   -/* @var $form yii\widgets\ActiveForm */
13 20 ?>
14 21  
15 22 <div class="slider-image-form">
16   -
17   - <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
18   -
19   - <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
20   - 'model' => $model,
21   - 'attribute' => 'image',
22   - 'options' => [
23   - 'accept' => 'image/*',
24   - 'multiple' => true
25   - ],
26   - 'pluginOptions' => [
27   - 'allowedFileExtensions' => ['jpg','gif','png'],
28   - 'initialPreview' => $model->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'slider') : '',
29   - 'overwriteInitial' => true,
30   - 'showRemove' => true,
31   - 'showUpload' => false,
32   - ],
33   - ]); ?>
34   -
35   -
36   - <?= $form->field($model, 'alt')->textInput(['maxlength' => true]) ?>
37   -
38   - <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
39   -
40   - <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
41   -
42   - <?= $form->field($model, 'status')->widget(Select2::className(),([
43   - 'name' => 'status',
44   - 'hideSearch' => true,
45   - 'data' => [1 => 'Active', 2 => 'Inactive'],
46   - 'options' => ['placeholder' => 'Select status...'],
47   - 'pluginOptions' => [
48   - 'allowClear' => true
49   - ]
50   - ])) ?>
51   -
52   - <?= $form->field($model, 'sort')->textInput() ?>
53   -
  23 +
  24 + <?php $form = ActiveForm::begin([ 'options' => [ 'enctype' => 'multipart/form-data' ] ]); ?>
  25 +
  26 + <?= $form->field($model, 'image')
  27 + ->widget(\kartik\file\FileInput::className(), [
  28 + 'model' => $model,
  29 + 'attribute' => 'image',
  30 + 'options' => [
  31 + 'accept' => 'image/*',
  32 + 'multiple' => true,
  33 + ],
  34 + 'pluginOptions' => [
  35 + 'allowedFileExtensions' => [
  36 + 'jpg',
  37 + 'gif',
  38 + 'png',
  39 + ],
  40 + 'initialPreview' => $model->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'slider') : '',
  41 + 'overwriteInitial' => true,
  42 + 'showRemove' => true,
  43 + 'showUpload' => false,
  44 + ],
  45 + ]); ?>
  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')
  55 + ->textInput([ 'maxlength' => true ]) ?>
  56 +
  57 + <?= $form->field($model, 'status')
  58 + ->widget(Select2::className(), ( [
  59 + 'name' => 'status',
  60 + 'hideSearch' => true,
  61 + 'data' => [
  62 + 1 => 'Active',
  63 + 2 => 'Inactive',
  64 + ],
  65 + 'options' => [ 'placeholder' => 'Select status...' ],
  66 + 'pluginOptions' => [
  67 + 'allowClear' => true,
  68 + ],
  69 + ] )) ?>
  70 +
  71 + <?= $form->field($model, 'sort')
  72 + ->textInput() ?>
  73 +
  74 + <?php
  75 + echo LanguageForm::widget([
  76 + 'model_langs' => $model_langs,
  77 + 'formView' => '@backend/views/slider-image/_form_language',
  78 + 'form' => $form,
  79 + ]);
  80 + ?>
  81 +
54 82 <div class="form-group">
55   - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  83 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
56 84 </div>
57   -
  85 +
58 86 <?php ActiveForm::end(); ?>
59 87  
60 88 </div>
... ...
backend/views/slider-image/_form_language.php 0 โ†’ 100644
  1 +<?php
  2 + use common\models\SliderImageLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var SliderImageLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +?>
  14 +<?= $form->field($model_lang, '[' . $language->language_id . ']title')
  15 + ->textInput([ 'maxlength' => true ]); ?>
  16 +<?= $form->field($model_lang, '[' . $language->language_id . ']alt')
  17 + ->textInput([ 'maxlength' => true ]); ?>
0 18 \ No newline at end of file
... ...
backend/views/slider-image/create.php
1 1 <?php
2   -
3   -use common\models\Slider;
4   -use yii\helpers\Html;
5   -use yii\helpers\Url;
6   -
7   -
8   -/* @var $this yii\web\View */
9   -/* @var $slider Slider*/
10   -/* @var $model common\models\SliderImage */
11   -
12   -$this->title = Yii::t('app', 'Create Slider Image');
13   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Slider Images'), 'url' => Url::toRoute(['index','slider_id'=>$slider_id])];
14   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\models\Slider;
  4 + use common\models\SliderImage;
  5 + use common\models\SliderImageLang;
  6 + use yii\helpers\Html;
  7 + use yii\helpers\Url;
  8 + use yii\web\View;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var SliderImage $model
  13 + * @var SliderImageLang[] $model_langs
  14 + * @var Slider $slider
  15 + */
  16 +
  17 + $this->title = Yii::t('app', 'Create Slider Image');
  18 + $this->params[ 'breadcrumbs' ][] = [
  19 + 'label' => Yii::t('app', 'Slider Images'),
  20 + 'url' => Url::toRoute([
  21 + 'index',
  22 + 'slider_id' => $slider_id,
  23 + ]),
  24 + ];
  25 + $this->params[ 'breadcrumbs' ][] = $this->title;
15 26 ?>
16 27 <div class="slider-image-create">
17   -
  28 +
18 29 <h1><?= Html::encode($this->title) ?></h1>
19   -
  30 +
20 31 <?= $this->render('_form', [
21   - 'model' => $model,
22   - 'slider' => $slider,
  32 + 'model' => $model,
  33 + 'model_langs' => $model_langs,
  34 + 'slider' => $slider,
23 35 ]) ?>
24 36  
25 37 </div>
... ...
backend/views/slider-image/update.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use common\models\Slider;
5   -use yii\helpers\Url;
6   -
7   -/* @var $this yii\web\View */
8   -/* @var $slider Slider*/
9   -/* @var $model common\models\SliderImage */
10   -
11   -$this->title = Yii::t('app', 'Update {modelClass}: ', [
12   - 'modelClass' => 'Slider Image',
13   -]) . $model->title;
14   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Slider Images'), 'url' => Url::toRoute(['index','slider_id'=>$slider_id])];
15   -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => Url::toRoute(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id])];
16   -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  2 +
  3 + use common\models\SliderImage;
  4 + use common\models\SliderImageLang;
  5 + use yii\helpers\Html;
  6 + use common\models\Slider;
  7 + use yii\helpers\Url;
  8 + use yii\web\View;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var SliderImage $model
  13 + * @var SliderImageLang[] $model_langs
  14 + * @var Slider $slider
  15 + * @var int $slider_id
  16 + */
  17 +
  18 + $this->title = Yii::t('app', 'Update {modelClass}: ', [
  19 + 'modelClass' => 'Slider Image',
  20 + ]) . $model->title;
  21 + $this->params[ 'breadcrumbs' ][] = [
  22 + 'label' => Yii::t('app', 'Slider Images'),
  23 + 'url' => Url::toRoute([
  24 + 'index',
  25 + 'slider_id' => $slider_id,
  26 + ]),
  27 + ];
  28 + $this->params[ 'breadcrumbs' ][] = [
  29 + 'label' => $model->title,
  30 + 'url' => Url::toRoute([
  31 + 'view',
  32 + 'slider_id' => $slider_id,
  33 + 'id' => $model->slider_image_id,
  34 + ]),
  35 + ];
  36 + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
17 37 ?>
18 38 <div class="slider-image-update">
19   -
  39 +
20 40 <h1><?= Html::encode($this->title) ?></h1>
21   -
  41 +
22 42 <?= $this->render('_form', [
23   - 'model' => $model,
24   - 'slider' => $slider,
  43 + 'model' => $model,
  44 + 'model_langs' => $model_langs,
  45 + 'slider' => $slider,
25 46 ]) ?>
26 47  
27 48 </div>
... ...
common/behaviors/SaveImgBehavior.php
1 1 <?php
2   -
3   -namespace common\behaviors;
4   -
5   -use common\modules\comment\models\CommentModel;
6   -use yii\base\Behavior;
7   -use yii\db\ActiveRecord;
8   -use yii\web\UploadedFile;
9   -/**
10   - * Class RatingBehavior
11   - * @property CommentModel $owner
12   - * @package common\behaviors
13   - */
14   -class SaveImgBehavior extends Behavior
15   -{
16   -
17   -
18   - public $directory;
19   -
20   - public function events()
  2 +
  3 + namespace common\behaviors;
  4 +
  5 + use yii\base\Behavior;
  6 + use yii\base\ModelEvent;
  7 + use yii\db\ActiveRecord;
  8 + use yii\web\UploadedFile;
  9 + /**
  10 + * Class Save Image Behavior
  11 + * @property ActiveRecord $owner
  12 + * @package common\behaviors
  13 + */
  14 + class SaveImgBehavior extends Behavior
21 15 {
22   - return [
23   - ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeUpdate',
24   - ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert',
25   - ];
26   - }
27   -
28   - public function beforeUpdate($event)
29   - {
30   -
31   -
32   - if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
33   - $this->owner->image = $image->name;
34   - }
35   -
36   - if(!$this->owner->image){
37   - $this->owner->image = $this->owner->getOldAttribute('image');
  16 +
  17 + public $fields;
  18 + public $is_language = false;
  19 +
  20 + public function events()
  21 + {
  22 + return [
  23 + ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeSave',
  24 + ActiveRecord::EVENT_BEFORE_INSERT => 'beforeSave',
  25 + ];
38 26 }
39   -
40   -
41   - if ($image) {
42   - $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
43   -
44   - if(!is_dir($imgDir)) {
45   - mkdir($imgDir, 0755, true);
  27 +
  28 + /**
  29 + * @param ModelEvent $event
  30 + */
  31 + public function beforeSave($event) {
  32 + foreach($this->fields as $field){
  33 + $field_name = $field['name'];
  34 + $name = $field_name;
  35 + if($this->is_language) {
  36 + $name = '['.$this->owner->language_id.']'.$name;
  37 + }
  38 +
  39 + $image = UploadedFile::getInstance($this->owner, $name);
  40 +
  41 + if(empty($image) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) {
  42 + $this->owner->$field_name = $this->owner->getOldAttribute($field_name);
  43 + } else {
  44 + $imgDir = \Yii::getAlias('@storage/'.$field['directory'].'/');
  45 +
  46 + if(!is_dir($imgDir)) {
  47 + mkdir($imgDir, 0755, true);
  48 + }
  49 +
  50 + $baseName = $image->baseName;
  51 +
  52 + $iteration = 0;
  53 + $file_name = $imgDir.$baseName.'.'.$image->extension;
  54 + while(file_exists($file_name)) {
  55 + $baseName = $image->baseName.'_'.++$iteration;
  56 + $file_name = $imgDir.$baseName.'.'.$image->extension;
  57 + }
  58 + unset($iteration);
  59 +
  60 + $this->owner->$field_name = $baseName.'.'.$image->extension;
  61 +
  62 + $image->saveAs($file_name);
  63 + }
46 64 }
47   -
48   - $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
49 65 }
50   - }
51   -
52   -
53   - public function beforeInsert($event)
54   - {
55   -
56   -
57   - if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
58   - $this->owner->image = $image->name;
  66 +
  67 + public function getImageFile($image = 'image') {
  68 + return empty($this->owner->$image) ? null : '/storage/'.$this->fields[0]['directory'].'/'. $this->owner->$image;
59 69 }
60   -
61   -
62   -
63   - if ($image) {
64   - $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
65   -
66   - if(!is_dir($imgDir)) {
67   - mkdir($imgDir, 0755, true);
68   - }
69   -
70   - $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
  70 +
  71 + public function getImageUrl($image = 'image') {
  72 + return empty($this->owner->$image) ? null : '/storage/'.$this->fields[0]['directory'].'/'. $this->owner->$image;
71 73 }
72   - }
73   -
74   -
75   -
76   - public function getImageFile() {
77   - return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
78   - }
79   -
80   - public function getImageUrl() {
81   - return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
82   - }
83   -}
84 74 \ No newline at end of file
  75 +
  76 +
  77 +
  78 + }
85 79 \ No newline at end of file
... ...
common/models/Articles.php
1 1 <?php
2   -
3   -namespace common\models;
4   -
5   -use common\behaviors\SaveImgBehavior;
6   -use common\modules\comment\models\CommentModel;
7   -use Yii;
8   -
9   -/**
10   - * This is the model class for table "articles".
11   - *
12   - * @property integer $id
13   - * @property integer $date
14   - * @property string $title
15   - * @property string $body
16   - * @property string $image
17   - * @property string $translit
18   - * @property string $meta_title
19   - * @property string $meta_keywords
20   - * @property string $meta_description
21   - * @property string $seo_text
22   - * @property string $h1
23   - * @property string $body_preview
24   - */
25   -class Articles extends \yii\db\ActiveRecord
26   -{
27   - public $imageUpload;
28   -
29   - /**
30   - * @inheritdoc
31   - */
32   - public static function tableName()
33   - {
34   - return 'articles';
35   - }
36   -
37   - /**
38   - * @inheritdoc
39   - */
40   - public function behaviors()
41   - {
42   - return [
43   - 'slug' => [
44   - 'class' => 'common\behaviors\Slug',
45   - 'in_attribute' => 'title',
46   - 'out_attribute' => 'translit',
47   - 'translit' => true
48   - ],
49   - [
50   - 'class' => SaveImgBehavior::className(),
51   - ],
52   - ];
53   - }
54   -
55   - /**
56   - * @inheritdoc
57   - */
58   - public function rules()
59   - {
60   - return [
61   - [['date'], 'default', 'value' => function() {
62   - return time();
63   - }],
64   - [['date'], 'safe'],
65   - [['title', 'body'], 'required'],
66   - [['body', 'body_preview', 'seo_text'], 'string'],
67   - [['title', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
68   - [['imageUpload'], 'safe'],
69   - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
70   - [['date'], 'filter', 'filter' => function($value) {
71   - return strtotime($value)?:time();
72   - }],
73   - ];
74   - }
75   -
  2 +
  3 + namespace common\models;
  4 +
  5 + use common\modules\language\behaviors\LanguageBehavior;
  6 + use common\behaviors\SaveImgBehavior;
  7 + use common\modules\comment\models\CommentModel;
  8 + use Yii;
  9 + use yii\db\ActiveQuery;
  10 + use yii\db\ActiveRecord;
  11 + use yii\web\Request;
  12 +
76 13 /**
77   - * @inheritdoc
  14 + * This is the model class for table "articles".
  15 + * @property integer $id
  16 + * @property integer $date
  17 + * @property string $title
  18 + * @property string $body
  19 + * @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 *
  28 + * @property ArticlesLang $lang
  29 + * @property ArticlesLang[] $langs
  30 + * @property ArticlesLang $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 ArticlesLang[] 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 *
78 44 */
79   - public function attributeLabels()
80   - {
81   - return [
82   - 'id' => 'ID',
83   - 'date' => 'Date',
84   - 'title' => 'Title',
85   - 'body' => 'Body',
86   - 'body_preview' => 'Body preview',
87   - 'image' => 'Image',
88   - 'imageUrl' => Yii::t('app', 'Image'),
89   - 'translit' => 'Translit',
90   - 'meta_title' => 'Meta Title',
91   - 'meta_keywords' => 'Meta Keywords',
92   - 'meta_description' => 'Meta Description',
93   - 'seo_text' => 'Seo Text',
94   - 'h1' => 'H1',
95   - ];
96   - }
97   -
98   - public function getImageFile() {
99   - return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);
100   - }
101   -
102   - public function getImageUrl()
  45 + class Articles extends \yii\db\ActiveRecord
103 46 {
104   - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);
105   - }
106   -
107   - public function recalculateRating() {
  47 + public $imageUpload;
  48 +
108 49 /**
109   - * @var ArticleToRating $averageRating
  50 + * @inheritdoc
110 51 */
111   - $average = $this->getComments()->joinWith('rating')->select(['average' => 'avg(artbox_comment_rating.value)::float'])->scalar();
112   - if(!$average) {
113   - $average = 0;
  52 + public static function tableName()
  53 + {
  54 + return 'articles';
114 55 }
115   - $averageRating = $this->averageRating;
116   - if(!empty($averageRating)) {
117   - $averageRating->value = $average;
118   - } else {
119   - $averageRating = new ArticleToRating(['articles_id' => $this->id, 'value' => $average]);
  56 +
  57 + /**
  58 + * @inheritdoc
  59 + */
  60 + public function behaviors()
  61 + {
  62 + return [
  63 + 'slug' => [
  64 + 'class' => 'common\behaviors\Slug',
  65 + 'in_attribute' => 'title',
  66 + 'out_attribute' => 'translit',
  67 + 'translit' => true,
  68 + ],
  69 + [
  70 + 'class' => SaveImgBehavior::className(),
  71 + ],
  72 + 'language' => [
  73 + 'class' => LanguageBehavior::className(),
  74 + ],
  75 + ];
120 76 }
121   - if($averageRating->save()) {
122   - return true;
123   - } else {
124   - return false;
  77 +
  78 + /**
  79 + * @inheritdoc
  80 + */
  81 + public function rules()
  82 + {
  83 + return [
  84 + [
  85 + [ 'date' ],
  86 + 'default',
  87 + 'value' => function() {
  88 + return time();
  89 + },
  90 + ],
  91 + [
  92 + [ 'date' ],
  93 + 'safe',
  94 + ],
  95 + [
  96 + [
  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',
  114 + 'translit',
  115 + 'meta_title',
  116 + 'meta_keywords',
  117 + 'meta_description',
  118 + 'h1',
  119 + ],
  120 + 'string',
  121 + 'max' => 255,
  122 + ],
  123 + [
  124 + [ 'imageUpload' ],
  125 + 'safe',
  126 + ],
  127 + [
  128 + [ 'imageUpload' ],
  129 + 'file',
  130 + 'extensions' => 'jpg, gif, png',
  131 + ],
  132 + [
  133 + [ 'date' ],
  134 + 'filter',
  135 + 'filter' => function($value) {
  136 + return strtotime($value) ? : time();
  137 + },
  138 + ],
  139 + ];
  140 + }
  141 +
  142 + /**
  143 + * @inheritdoc
  144 + */
  145 + public function attributeLabels()
  146 + {
  147 + return [
  148 + 'id' => 'ID',
  149 + 'date' => 'Date',
  150 + 'title' => 'Title',
  151 + 'body' => 'Body',
  152 + 'body_preview' => 'Body preview',
  153 + 'image' => 'Image',
  154 + '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 + ];
  162 + }
  163 +
  164 + public function getImageFile()
  165 + {
  166 + return empty( $this->image ) ? NULL : Yii::getAlias('@imagesDir/articles/' . $this->image);
  167 + }
  168 +
  169 + public function getImageUrl()
  170 + {
  171 + return empty( $this->image ) ? NULL : Yii::getAlias('@imagesUrl/articles/' . $this->image);
  172 + }
  173 +
  174 + public function recalculateRating()
  175 + {
  176 + /**
  177 + * @var ArticleToRating $averageRating
  178 + */
  179 + $average = $this->getComments()
  180 + ->joinWith('rating')
  181 + ->select([ 'average' => 'avg(artbox_comment_rating.value)::float' ])
  182 + ->scalar();
  183 + if(!$average) {
  184 + $average = 0;
  185 + }
  186 + $averageRating = $this->averageRating;
  187 + if(!empty( $averageRating )) {
  188 + $averageRating->value = $average;
  189 + } else {
  190 + $averageRating = new ArticleToRating([
  191 + 'articles_id' => $this->id,
  192 + 'value' => $average,
  193 + ]);
  194 + }
  195 + if($averageRating->save()) {
  196 + return true;
  197 + } else {
  198 + return false;
  199 + }
  200 + }
  201 +
  202 + public function getComments()
  203 + {
  204 + return $this->hasMany(CommentModel::className(), [ 'entity_id' => 'id' ])
  205 + ->where([
  206 + 'artbox_comment.entity' => self::className(),
  207 + 'artbox_comment.status' => CommentModel::STATUS_ACTIVE,
  208 + 'artbox_comment.artbox_comment_pid' => NULL,
  209 + ]);
  210 + }
  211 +
  212 + public function getAverageRating()
  213 + {
  214 + return $this->hasOne(ArticleToRating::className(), [ 'articles_id' => 'id' ]);
125 215 }
126 216 }
127   -
128   - public function getComments() {
129   - return $this->hasMany(CommentModel::className(), ['entity_id' => 'id'])->where(['artbox_comment.entity' => self::className(), 'artbox_comment.status' => CommentModel::STATUS_ACTIVE, 'artbox_comment.artbox_comment_pid' => NULL]);
130   - }
131   -
132   - public function getAverageRating() {
133   - return $this->hasOne(ArticleToRating::className(), ['articles_id' => 'id']);
134   - }
135   -}
... ...
common/models/ArticlesLang.php 0 โ†’ 100644
  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 "articles_lang".
  10 + *
  11 + * @property integer $articles_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 + * @property string $body_preview
  21 + *
  22 + * @property Articles $articles
  23 + * @property Language $language
  24 + */
  25 +class ArticlesLang extends \yii\db\ActiveRecord
  26 +{
  27 + public static function primaryKey()
  28 + {
  29 + return [
  30 + 'articles_id',
  31 + 'language_id',
  32 + ];
  33 + }
  34 +
  35 + /**
  36 + * @inheritdoc
  37 + */
  38 + public static function tableName()
  39 + {
  40 + return 'articles_lang';
  41 + }
  42 +
  43 + /**
  44 + * @inheritdoc
  45 + */
  46 + public function rules()
  47 + {
  48 + return [
  49 + [['title', 'body'], 'required'],
  50 + [['body', 'seo_text', 'body_preview'], 'string'],
  51 + [['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.'],
  53 + [['articles_id'], 'exist', 'skipOnError' => true, 'targetClass' => Articles::className(), 'targetAttribute' => ['articles_id' => 'id']],
  54 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  55 + ];
  56 + }
  57 +
  58 + /**
  59 + * @inheritdoc
  60 + */
  61 + public function attributeLabels()
  62 + {
  63 + return [
  64 + 'articles_id' => Yii::t('app', 'Articles 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 + 'body_preview' => Yii::t('app', 'Body Preview'),
  74 + ];
  75 + }
  76 +
  77 + /**
  78 + * @return \yii\db\ActiveQuery
  79 + */
  80 + public function getArticles()
  81 + {
  82 + return $this->hasOne(Articles::className(), ['id' => 'articles_id'])->inverseOf('langs');
  83 + }
  84 +
  85 + /**
  86 + * @return \yii\db\ActiveQuery
  87 + */
  88 + public function getLanguage()
  89 + {
  90 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  91 + }
  92 +}
... ...
common/models/ArticlesSearch.php
... ... @@ -22,7 +22,12 @@ class ArticlesSearch extends Articles
22 22 [['title', 'body', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'],
23 23 ];
24 24 }
25   -
  25 +
  26 + public function behaviors()
  27 + {
  28 + return [];
  29 + }
  30 +
26 31 /**
27 32 * @inheritdoc
28 33 */
... ...
common/models/Banner.php
... ... @@ -2,7 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 +use common\modules\language\behaviors\LanguageBehavior;
5 6 use Yii;
  7 +use yii\db\ActiveQuery;
  8 +use yii\db\ActiveRecord;
  9 +use yii\web\Request;
6 10  
7 11 /**
8 12 * This is the model class for table "banner".
... ... @@ -13,8 +17,23 @@ use Yii;
13 17 * @property string $title
14 18 * @property string $url
15 19 * @property integer $status
16   - * @property integer $width
17   - * @property integer $height
  20 + * * From language behavior *
  21 + * @property BannerLang $lang
  22 + * @property BannerLang[] $langs
  23 + * @property BannerLang $object_lang
  24 + * @property string $ownerKey
  25 + * @property string $langKey
  26 + * @method string getOwnerKey()
  27 + * @method void setOwnerKey(string $value)
  28 + * @method string getLangKey()
  29 + * @method void setLangKey(string $value)
  30 + * @method ActiveQuery getLangs()
  31 + * @method ActiveQuery getLang( integer $language_id )
  32 + * @method BannerLang[] generateLangs()
  33 + * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
  34 + * @method bool linkLangs(ActiveRecord[] $model_langs)
  35 + * @method bool saveLangs(ActiveRecord[] $model_langs)
  36 + * * End language behavior *
18 37 */
19 38 class Banner extends \yii\db\ActiveRecord
20 39 {
... ... @@ -25,16 +44,24 @@ class Banner extends \yii\db\ActiveRecord
25 44 {
26 45 return 'banner';
27 46 }
28   -
  47 +
  48 + public function behaviors()
  49 + {
  50 + return [
  51 + 'language' => [
  52 + 'class' => LanguageBehavior::className(),
  53 + ],
  54 + ];
  55 + }
  56 +
29 57 /**
30 58 * @inheritdoc
31 59 */
32 60 public function rules()
33 61 {
34 62 return [
35   - [['status', 'width', 'height'], 'integer'],
  63 + [['status'], 'integer'],
36 64 [['image', 'alt', 'title', 'url'], 'string', 'max' => 255],
37   - [['width', 'height'], 'required'],
38 65 ['title', 'unique', 'targetClass' => '\common\models\Slider', 'message' => Yii::t('app','message',[
39 66 'field' => 'Title'
40 67 ])],
... ... @@ -53,15 +80,6 @@ class Banner extends \yii\db\ActiveRecord
53 80 'title' => Yii::t('app', 'title'),
54 81 'url' => Yii::t('app', 'url'),
55 82 'status' => Yii::t('app', 'status'),
56   - 'width' => Yii::t('app', 'width'),
57   - 'height' => Yii::t('app', 'height'),
58 83 ];
59 84 }
60   -
61   - static function getFileExtension ($filename)
62   - {
63   - $ext = explode ('.', $filename);
64   -
65   - return end ($ext);
66   - }
67 85 }
... ...
common/models/BannerLang.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use common\behaviors\SaveImgBehavior;
  6 +use common\modules\language\models\Language;
  7 +use Yii;
  8 +
  9 +/**
  10 + * This is the model class for table "banner_lang".
  11 + *
  12 + * @property integer $banner_id
  13 + * @property integer $language_id
  14 + * @property string $alt
  15 + * @property string $title
  16 + * @property string $image
  17 + *
  18 + * @property Banner $banner
  19 + * @property Language $language
  20 + */
  21 +class BannerLang extends \yii\db\ActiveRecord
  22 +{
  23 +
  24 + public static function primaryKey()
  25 + {
  26 + return [
  27 + 'banner_id',
  28 + 'language_id',
  29 + ];
  30 + }
  31 +
  32 + /**
  33 + * @inheritdoc
  34 + */
  35 + public static function tableName()
  36 + {
  37 + return 'banner_lang';
  38 + }
  39 +
  40 + public function behaviors()
  41 + {
  42 + return [
  43 + [
  44 + 'class' => SaveImgBehavior::className(),
  45 + 'is_language' => true,
  46 + 'fields' => [
  47 + [
  48 + 'name' => 'image',
  49 + 'directory' => 'banner',
  50 + ],
  51 + ],
  52 + ]
  53 + ];
  54 + }
  55 +
  56 + /**
  57 + * @inheritdoc
  58 + */
  59 + public function rules()
  60 + {
  61 + return [
  62 + [['alt', 'title', 'image'], 'string', 'max' => 255],
  63 + [['banner_id', 'language_id'], 'unique', 'targetAttribute' => ['banner_id', 'language_id'], 'message' => 'The combination of Banner ID and Language ID has already been taken.'],
  64 + [['banner_id'], 'exist', 'skipOnError' => true, 'targetClass' => Banner::className(), 'targetAttribute' => ['banner_id' => 'banner_id']],
  65 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  66 + ];
  67 + }
  68 +
  69 + /**
  70 + * @inheritdoc
  71 + */
  72 + public function attributeLabels()
  73 + {
  74 + return [
  75 + 'banner_id' => Yii::t('app', 'Banner ID'),
  76 + 'language_id' => Yii::t('app', 'Language ID'),
  77 + 'alt' => Yii::t('app', 'Alt'),
  78 + 'title' => Yii::t('app', 'Title'),
  79 + ];
  80 + }
  81 +
  82 + /**
  83 + * @return \yii\db\ActiveQuery
  84 + */
  85 + public function getBanner()
  86 + {
  87 + return $this->hasOne(Banner::className(), ['banner_id' => 'banner_id']);
  88 + }
  89 +
  90 + /**
  91 + * @return \yii\db\ActiveQuery
  92 + */
  93 + public function getLanguage()
  94 + {
  95 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  96 + }
  97 +}
... ...
common/models/BannerSearch.php
... ... @@ -23,6 +23,11 @@ class BannerSearch extends Banner
23 23 ];
24 24 }
25 25  
  26 + public function behaviors()
  27 + {
  28 + return [];
  29 + }
  30 +
26 31 /**
27 32 * @inheritdoc
28 33 */
... ...
common/models/Basket.php
... ... @@ -11,11 +11,11 @@
11 11  
12 12 public $session;
13 13  
14   - public function __construct(array $config = [ ])
  14 + public function __construct(array $config = [])
15 15 {
16 16 $this->session = \Yii::$app->session;
17 17 if(!$this->session->has('basket')) {
18   - $this->session->set('basket', [ ]);
  18 + $this->session->set('basket', []);
19 19 }
20 20 parent::__construct($config);
21 21 }
... ... @@ -25,8 +25,8 @@
25 25 $data = $this->getData();
26 26 if(array_key_exists($product_variant_id, $data)) {
27 27 $data[ $product_variant_id ][ 'count' ] = 1;
28   - if($data[$product_variant_id]['count'] <= 0) {
29   - unset($data[$product_variant_id]);
  28 + if($data[ $product_variant_id ][ 'count' ] <= 0) {
  29 + unset( $data[ $product_variant_id ] );
30 30 }
31 31 } else {
32 32 if($this->findModel($product_variant_id)) {
... ... @@ -37,14 +37,14 @@
37 37 }
38 38 $this->setData($data);
39 39 }
40   -
  40 +
41 41 private function set(int $product_variant_id, int $count)
42 42 {
43 43 $data = $this->getData();
44 44 if(array_key_exists($product_variant_id, $data)) {
45 45 $data[ $product_variant_id ][ 'count' ] = $count;
46   - if($data[$product_variant_id]['count'] <= 0) {
47   - unset($data[$product_variant_id]);
  46 + if($data[ $product_variant_id ][ 'count' ] <= 0) {
  47 + unset( $data[ $product_variant_id ] );
48 48 }
49 49 } elseif($count > 0) {
50 50 if($this->findModel($product_variant_id)) {
... ... @@ -56,7 +56,8 @@
56 56 $this->setData($data);
57 57 }
58 58  
59   - public function delete(int $product_variant_id) {
  59 + public function delete(int $product_variant_id)
  60 + {
60 61 $this->set($product_variant_id, 0);
61 62 }
62 63  
... ... @@ -65,10 +66,11 @@
65 66 return $this->session->get('basket');
66 67 }
67 68  
68   - public function getItem(int $product_variant_id) {
  69 + public function getItem(int $product_variant_id)
  70 + {
69 71 $data = $this->getData();
70   - if(!empty($data[$product_variant_id])) {
71   - return $data[$product_variant_id];
  72 + if(!empty( $data[ $product_variant_id ] )) {
  73 + return $data[ $product_variant_id ];
72 74 } else {
73 75 return false;
74 76 }
... ... @@ -79,7 +81,8 @@
79 81 $this->session->set('basket', $data);
80 82 }
81 83  
82   - public function getCount(): int {
  84 + public function getCount(): int
  85 + {
83 86 $data = $this->getData();
84 87 return count($data);
85 88 }
... ... @@ -90,10 +93,11 @@
90 93 * @var ProductVariant $model
91 94 */
92 95 $model = ProductVariant::find()
93   - ->where([ 'product_variant_id' => $product_variant_id ])
  96 + ->where([ 'product_variant.product_variant_id' => $product_variant_id ])
  97 + ->joinWith('lang', true, 'INNER JOIN')
94 98 ->one();
95 99 if(empty( $model )) {
96   - throw new NotFoundHttpException('Product not found');
  100 + throw new NotFoundHttpException(\Yii::t('app', 'Product not found'));
97 101 } else {
98 102 return $model;
99 103 }
... ... @@ -102,7 +106,8 @@
102 106 public function findModels(array $product_variant_ids)
103 107 {
104 108 return ProductVariant::find()
105   - ->where([ 'product_variant_id' => $product_variant_ids ])
  109 + ->where([ 'product_variant.product_variant_id' => $product_variant_ids ])
  110 + ->joinWith('lang', true, 'INNER JOIN')
106 111 ->with([
107 112 'product',
108 113 'image',
... ...
common/models/Bg.php
... ... @@ -2,6 +2,31 @@
2 2  
3 3 namespace common\models;
4 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 + */
5 30 class Bg extends \yii\db\ActiveRecord
6 31 {
7 32 public $old_image;
... ... @@ -10,8 +35,17 @@ class Bg extends \yii\db\ActiveRecord
10 35 {
11 36 return 'bg';
12 37 }
13   -
14   - public function rules()
  38 +
  39 + public function behaviors()
  40 + {
  41 + return [
  42 + 'language' => [
  43 + 'class' => LanguageBehavior::className(),
  44 + ],
  45 + ];
  46 + }
  47 +
  48 + public function rules()
15 49 {
16 50 return [
17 51 [['title'], 'required'],
... ...
common/models/BgLang.php 0 โ†’ 100644
  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 "bg_lang".
  10 + *
  11 + * @property integer $bg_id
  12 + * @property integer $language_id
  13 + * @property string $title
  14 + *
  15 + * @property Bg $bg
  16 + * @property Language $language
  17 + */
  18 +class BgLang extends \yii\db\ActiveRecord
  19 +{
  20 +
  21 + public static function primaryKey()
  22 + {
  23 + return [
  24 + 'bg_id',
  25 + 'language_id',
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return 'bg_lang';
  35 + }
  36 +
  37 + /**
  38 + * @inheritdoc
  39 + */
  40 + public function rules()
  41 + {
  42 + return [
  43 + [['title'], 'required'],
  44 + [['title'], 'string', 'max' => 255],
  45 + [['bg_id', 'language_id'], 'unique', 'targetAttribute' => ['bg_id', 'language_id'], 'message' => 'The combination of Bg ID and Language ID has already been taken.'],
  46 + [['bg_id'], 'exist', 'skipOnError' => true, 'targetClass' => Bg::className(), 'targetAttribute' => ['bg_id' => 'id']],
  47 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  48 + ];
  49 + }
  50 +
  51 + /**
  52 + * @inheritdoc
  53 + */
  54 + public function attributeLabels()
  55 + {
  56 + return [
  57 + 'bg_id' => Yii::t('app', 'Bg ID'),
  58 + 'language_id' => Yii::t('app', 'Language ID'),
  59 + 'title' => Yii::t('app', 'Title'),
  60 + ];
  61 + }
  62 +
  63 + /**
  64 + * @return \yii\db\ActiveQuery
  65 + */
  66 + public function getBg()
  67 + {
  68 + return $this->hasOne(Bg::className(), ['id' => 'bg_id']);
  69 + }
  70 +
  71 + /**
  72 + * @return \yii\db\ActiveQuery
  73 + */
  74 + public function getLanguage()
  75 + {
  76 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  77 + }
  78 +}
... ...
common/models/BgSearch.php
... ... @@ -22,7 +22,12 @@ class BgSearch extends Bg
22 22 [['title', 'url', 'image'], 'safe'],
23 23 ];
24 24 }
25   -
  25 +
  26 + public function behaviors()
  27 + {
  28 + return [];
  29 + }
  30 +
26 31 /**
27 32 * @inheritdoc
28 33 */
... ...
common/models/Delivery.php
... ... @@ -2,8 +2,44 @@
2 2  
3 3 namespace common\models;
4 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 + */
5 31 class Delivery extends \yii\db\ActiveRecord
6 32 {
  33 +
  34 + public function behaviors()
  35 + {
  36 + return [
  37 + 'language' => [
  38 + 'class' => LanguageBehavior::className(),
  39 + ],
  40 + ];
  41 + }
  42 +
7 43 public static function tableName()
8 44 {
9 45 return 'orders_delivery';
... ...
common/models/Event.php
... ... @@ -2,8 +2,13 @@
2 2  
3 3 namespace common\models;
4 4  
  5 +use common\modules\language\behaviors\LanguageBehavior;
5 6 use Yii;
6 7 use yii\behaviors\TimestampBehavior;
  8 +use yii\db\ActiveQuery;
  9 +use yii\db\ActiveRecord;
  10 +use yii\web\Request;
  11 +
7 12 /**
8 13 * This is the model class for table "event".
9 14 *
... ... @@ -19,6 +24,24 @@ use yii\behaviors\TimestampBehavior;
19 24 * @property integer $created_at
20 25 * @property integer $updated_at
21 26 * @property integer $end_at
  27 + *
  28 + * *From language behavior *
  29 + * @property EventLang $lang
  30 + * @property EventLang[] $langs
  31 + * @property EventLang $object_lang
  32 + * @property string $ownerKey
  33 + * @property string $langKey
  34 + * @method string getOwnerKey()
  35 + * @method void setOwnerKey(string $value)
  36 + * @method string getLangKey()
  37 + * @method void setLangKey(string $value)
  38 + * @method ActiveQuery getLangs()
  39 + * @method ActiveQuery getLang( integer $language_id )
  40 + * @method EventLang[] generateLangs()
  41 + * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
  42 + * @method bool linkLangs(ActiveRecord[] $model_langs)
  43 + * @method bool saveLangs(ActiveRecord[] $model_langs)
  44 + * * End language behavior *
22 45 */
23 46 class Event extends \yii\db\ActiveRecord
24 47 {
... ... @@ -48,6 +71,9 @@ class Event extends \yii\db\ActiveRecord
48 71 [
49 72 'class' => 'common\behaviors\ShowImage',
50 73 ],
  74 + 'language' => [
  75 + 'class' => LanguageBehavior::className(),
  76 + ],
51 77 ];
52 78 }
53 79  
... ...
common/models/EventLang.php 0 โ†’ 100644
  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 +
  26 + public static function primaryKey()
  27 + {
  28 + return [
  29 + 'event_id',
  30 + 'language_id',
  31 + ];
  32 + }
  33 +
  34 + /**
  35 + * @inheritdoc
  36 + */
  37 + public static function tableName()
  38 + {
  39 + return 'event_lang';
  40 + }
  41 +
  42 + /**
  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
  84 + */
  85 + public function getLanguage()
  86 + {
  87 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  88 + }
  89 +}
... ...
common/models/EventSearch.php
... ... @@ -2,10 +2,8 @@
2 2  
3 3 namespace common\models;
4 4  
5   -use Yii;
6 5 use yii\base\Model;
7 6 use yii\data\ActiveDataProvider;
8   -use common\models\Event;
9 7  
10 8 /**
11 9 * EventSearch represents the model behind the search form about `common\models\Event`.
... ... @@ -22,9 +20,12 @@ class EventSearch extends Event
22 20 [['name', 'alias', 'body', 'image', 'meta_title', 'description', 'h1', 'seo_text'], 'safe'],
23 21 ];
24 22 }
25   -
26   -
27   -
  23 +
  24 + public function behaviors()
  25 + {
  26 + return [];
  27 + }
  28 +
28 29 /**
29 30 * @inheritdoc
30 31 */
... ...
common/models/OrdersDeliveryLang.php 0 โ†’ 100644
  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 "orders_delivery_lang".
  10 + *
  11 + * @property integer $orders_delivery_id
  12 + * @property integer $language_id
  13 + * @property string $title
  14 + * @property string $text
  15 + *
  16 + * @property Language $language
  17 + * @property Delivery $delivery
  18 + */
  19 +class OrdersDeliveryLang extends \yii\db\ActiveRecord
  20 +{
  21 +
  22 + public static function primaryKey()
  23 + {
  24 + return [
  25 + 'orders_delivery_id',
  26 + 'language_id',
  27 + ];
  28 + }
  29 +
  30 + /**
  31 + * @inheritdoc
  32 + */
  33 + public static function tableName()
  34 + {
  35 + return 'orders_delivery_lang';
  36 + }
  37 +
  38 + /**
  39 + * @inheritdoc
  40 + */
  41 + public function rules()
  42 + {
  43 + return [
  44 + [['title', 'text'], 'required'],
  45 + [['text'], 'string'],
  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.'],
  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']],
  50 + ];
  51 + }
  52 +
  53 + /**
  54 + * @inheritdoc
  55 + */
  56 + public function attributeLabels()
  57 + {
  58 + return [
  59 + 'orders_delivery_id' => Yii::t('app', 'Orders Delivery ID'),
  60 + 'language_id' => Yii::t('app', 'Language ID'),
  61 + 'title' => Yii::t('app', 'Title'),
  62 + 'text' => Yii::t('app', 'Text'),
  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
  76 + */
  77 + public function getDelivery()
  78 + {
  79 + return $this->hasOne(Delivery::className(), ['id' => 'orders_delivery_id']);
  80 + }
  81 +}
... ...
common/models/Page.php
1 1 <?php
2 2  
3 3 namespace common\models;
4   -
  4 +
  5 + use common\modules\language\behaviors\LanguageBehavior;
  6 + use yii\db\ActiveQuery;
  7 + use yii\db\ActiveRecord;
  8 + use yii\web\Request;
5 9 /**
6 10 * This is the model class for table "page".
7 11 * @property integer $id
... ... @@ -14,6 +18,23 @@
14 18 * @property string $seo_text
15 19 * @property string $h1
16 20 * @property bool $in_menu
  21 + * * From language behavior *
  22 + * @property PageLang $lang
  23 + * @property PageLang[] $langs
  24 + * @property PageLang $object_lang
  25 + * @property string $ownerKey
  26 + * @property string $langKey
  27 + * @method string getOwnerKey()
  28 + * @method void setOwnerKey(string $value)
  29 + * @method string getLangKey()
  30 + * @method void setLangKey(string $value)
  31 + * @method ActiveQuery getLangs()
  32 + * @method ActiveQuery getLang( integer $language_id )
  33 + * @method PageLang[] generateLangs()
  34 + * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
  35 + * @method bool linkLangs(ActiveRecord[] $model_langs)
  36 + * @method bool saveLangs(ActiveRecord[] $model_langs)
  37 + * * End language behavior *
17 38 */
18 39 class Page extends \yii\db\ActiveRecord
19 40 {
... ... @@ -38,6 +59,9 @@
38 59 'out_attribute' => 'translit',
39 60 'translit' => true,
40 61 ],
  62 + 'language' => [
  63 + 'class' => LanguageBehavior::className(),
  64 + ],
41 65 ];
42 66 }
43 67  
... ...
common/models/PageLang.php 0 โ†’ 100644
  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 +
  27 + public static function primaryKey()
  28 + {
  29 + return [
  30 + 'page_id',
  31 + 'language_id',
  32 + ];
  33 + }
  34 +
  35 + /**
  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
  86 + */
  87 + public function getPage()
  88 + {
  89 + return $this->hasOne(Page::className(), ['id' => 'page_id']);
  90 + }
  91 +}
... ...
common/models/PageSearch.php
... ... @@ -29,7 +29,12 @@ class PageSearch extends Page
29 29 // bypass scenarios() implementation in the parent class
30 30 return Model::scenarios();
31 31 }
32   -
  32 +
  33 + public function behaviors()
  34 + {
  35 + return [];
  36 + }
  37 +
33 38 /**
34 39 * Creates data provider instance with search query applied
35 40 *
... ...
common/models/ProductSpec.php
... ... @@ -2,7 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 + use common\modules\language\behaviors\LanguageBehavior;
5 6 use common\modules\product\models\Product;
  7 + use yii\db\ActiveQuery;
  8 + use yii\db\ActiveRecord;
  9 + use yii\web\Request;
6 10 use yii\web\UploadedFile;
7 11  
8 12 /**
... ... @@ -14,6 +18,24 @@
14 18 * @property string $tech_char_link
15 19 * @property string $instruction
16 20 * @property Product $product
  21 + *
  22 + * * From language behavior *
  23 + * @property ProductSpecLang $lang
  24 + * @property ProductSpecLang[] $langs
  25 + * @property ProductSpecLang $object_lang
  26 + * @property string $ownerKey
  27 + * @property string $langKey
  28 + * @method string getOwnerKey()
  29 + * @method void setOwnerKey(string $value)
  30 + * @method string getLangKey()
  31 + * @method void setLangKey(string $value)
  32 + * @method ActiveQuery getLangs()
  33 + * @method ActiveQuery getLang( integer $language_id )
  34 + * @method ProductSpecLang[] generateLangs()
  35 + * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
  36 + * @method bool linkLangs(ActiveRecord[] $model_langs)
  37 + * @method bool saveLangs(ActiveRecord[] $model_langs)
  38 + * * End language behavior *
17 39 */
18 40 class ProductSpec extends \yii\db\ActiveRecord
19 41 {
... ... @@ -36,6 +58,15 @@
36 58 return 'product_spec';
37 59 }
38 60  
  61 + public function behaviors()
  62 + {
  63 + return [
  64 + 'language' => [
  65 + 'class' => LanguageBehavior::className(),
  66 + ],
  67 + ];
  68 + }
  69 +
39 70 /**
40 71 * @inheritdoc
41 72 */
... ... @@ -49,13 +80,6 @@
49 80 ],
50 81 'string',
51 82 ],
52   -// [
53   -// [ 'product_id' ],
54   -// 'exist',
55   -// 'skipOnError' => true,
56   -// 'targetClass' => Product::className(),
57   -// 'targetAttribute' => [ 'product_id' => 'product_id' ],
58   -// ],
59 83 [
60 84 [
61 85 'techSpecFile',
... ...
common/models/ProductSpecLang.php 0 โ†’ 100644
  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 "product_spec_lang".
  10 + *
  11 + * @property integer $product_spec_id
  12 + * @property integer $language_id
  13 + * @property string $tech_spec_text
  14 + * @property string $instruction
  15 + *
  16 + * @property Language $language
  17 + * @property ProductSpec $productSpec
  18 + */
  19 +class ProductSpecLang extends \yii\db\ActiveRecord
  20 +{
  21 +
  22 + public static function primaryKey()
  23 + {
  24 + return [
  25 + 'product_spec_id',
  26 + 'language_id',
  27 + ];
  28 + }
  29 +
  30 + /**
  31 + * @inheritdoc
  32 + */
  33 + public static function tableName()
  34 + {
  35 + return 'product_spec_lang';
  36 + }
  37 +
  38 + /**
  39 + * @inheritdoc
  40 + */
  41 + public function rules()
  42 + {
  43 + return [
  44 + [['tech_spec_text', 'instruction'], 'string'],
  45 + [['product_spec_id', 'language_id'], 'unique', 'targetAttribute' => ['product_spec_id', 'language_id'], 'message' => 'The combination of Product Spec ID and Language ID has already been taken.'],
  46 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  47 + [['product_spec_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductSpec::className(), 'targetAttribute' => ['product_spec_id' => 'product_spec_id']],
  48 + ];
  49 + }
  50 +
  51 + /**
  52 + * @inheritdoc
  53 + */
  54 + public function attributeLabels()
  55 + {
  56 + return [
  57 + 'product_spec_id' => Yii::t('app', 'Product Spec ID'),
  58 + 'language_id' => Yii::t('app', 'Language ID'),
  59 + 'tech_spec_text' => Yii::t('app', 'Tech Spec Text'),
  60 + 'instruction' => Yii::t('app', 'Instruction'),
  61 + ];
  62 + }
  63 +
  64 + /**
  65 + * @return \yii\db\ActiveQuery
  66 + */
  67 + public function getLanguage()
  68 + {
  69 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  70 + }
  71 +
  72 + /**
  73 + * @return \yii\db\ActiveQuery
  74 + */
  75 + public function getProductSpec()
  76 + {
  77 + return $this->hasOne(ProductSpec::className(), ['product_spec_id' => 'product_spec_id']);
  78 + }
  79 +}
... ...
common/models/Project.php
... ... @@ -2,7 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 + use common\modules\language\behaviors\LanguageBehavior;
5 6 use common\modules\product\models\ProductVariant;
  7 + use yii\db\ActiveQuery;
  8 + use yii\db\ActiveRecord;
  9 + use yii\web\Request;
6 10  
7 11 /**
8 12 * This is the model class for table "project".
... ... @@ -16,6 +20,23 @@
16 20 * @property array $imagesConfig
17 21 * @property ProductVariant[] $variants
18 22 * @property ProductToProject[] $productToProject
  23 + * * From language behavior *
  24 + * @property ProjectLang $lang
  25 + * @property ProjectLang[] $langs
  26 + * @property ProjectLang $object_lang
  27 + * @property string $ownerKey
  28 + * @property string $langKey
  29 + * @method string getOwnerKey()
  30 + * @method void setOwnerKey( string $value )
  31 + * @method string getLangKey()
  32 + * @method void setLangKey( string $value )
  33 + * @method ActiveQuery getLangs()
  34 + * @method ActiveQuery getLang( integer $language_id )
  35 + * @method ProjectLang[] generateLangs()
  36 + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs )
  37 + * @method bool linkLangs( ActiveRecord[] $model_langs )
  38 + * @method bool saveLangs( ActiveRecord[] $model_langs )
  39 + * * End language behavior *
19 40 */
20 41 class Project extends \yii\db\ActiveRecord
21 42 {
... ... @@ -36,12 +57,15 @@
36 57 public function behaviors()
37 58 {
38 59 return [
39   - 'slug' => [
  60 + 'slug' => [
40 61 'class' => 'common\behaviors\Slug',
41 62 'in_attribute' => 'title',
42 63 'out_attribute' => 'link',
43 64 'translit' => true,
44 65 ],
  66 + 'language' => [
  67 + 'class' => LanguageBehavior::className(),
  68 + ],
45 69 ];
46 70 }
47 71  
... ...
common/models/ProjectLang.php 0 โ†’ 100644
  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 +
  22 + public static function primaryKey()
  23 + {
  24 + return [
  25 + 'project_id',
  26 + 'language_id',
  27 + ];
  28 + }
  29 +
  30 + /**
  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
  76 + */
  77 + public function getProject()
  78 + {
  79 + return $this->hasOne(Project::className(), ['project_id' => 'project_id']);
  80 + }
  81 +}
... ...
common/models/ProjectSearch.php
... ... @@ -2,16 +2,20 @@
2 2  
3 3 namespace common\models;
4 4  
5   -use Yii;
6 5 use yii\base\Model;
7 6 use yii\data\ActiveDataProvider;
8   -use common\models\Project;
9 7  
10 8 /**
11 9 * ProjectSearch represents the model behind the search form about `common\models\Project`.
12 10 */
13 11 class ProjectSearch extends Project
14 12 {
  13 +
  14 + public function behaviors()
  15 + {
  16 + return [];
  17 + }
  18 +
15 19 /**
16 20 * @inheritdoc
17 21 */
... ...
common/models/Seo.php
... ... @@ -2,7 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 +use common\modules\language\behaviors\LanguageBehavior;
5 6 use Yii;
  7 +use yii\db\ActiveQuery;
  8 +use yii\db\ActiveRecord;
  9 +use yii\web\Request;
6 10  
7 11 /**
8 12 * This is the model class for table "seo".
... ... @@ -14,6 +18,24 @@ use Yii;
14 18 * @property string $description
15 19 * @property string $h1
16 20 * @property string $seo_text
  21 + *
  22 + * * From language behavior *
  23 + * @property SeoLang $lang
  24 + * @property SeoLang[] $langs
  25 + * @property SeoLang $object_lang
  26 + * @property string $ownerKey
  27 + * @property string $langKey
  28 + * @method string getOwnerKey()
  29 + * @method void setOwnerKey(string $value)
  30 + * @method string getLangKey()
  31 + * @method void setLangKey(string $value)
  32 + * @method ActiveQuery getLangs()
  33 + * @method ActiveQuery getLang( integer $language_id )
  34 + * @method SeoLang[] generateLangs()
  35 + * @method void loadLangs(Request $request, ActiveRecord[] $model_langs)
  36 + * @method bool linkLangs(ActiveRecord[] $model_langs)
  37 + * @method bool saveLangs(ActiveRecord[] $model_langs)
  38 + * * End language behavior *
17 39 */
18 40 class Seo extends \yii\db\ActiveRecord
19 41 {
... ... @@ -25,6 +47,15 @@ class Seo extends \yii\db\ActiveRecord
25 47 return 'seo';
26 48 }
27 49  
  50 + public function behaviors()
  51 + {
  52 + return [
  53 + 'language' => [
  54 + 'class' => LanguageBehavior::className(),
  55 + ],
  56 + ];
  57 + }
  58 +
28 59 /**
29 60 * @inheritdoc
30 61 */
... ...
common/models/SeoCategory.php
... ... @@ -2,7 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 +use common\modules\language\behaviors\LanguageBehavior;
5 6 use Yii;
  7 +use yii\db\ActiveQuery;
  8 +use yii\db\ActiveRecord;
  9 +use yii\web\Request;
6 10  
7 11 /**
8 12 * This is the model class for table "seo_category".
... ... @@ -12,6 +16,24 @@ use Yii;
12 16 * @property string $controller
13 17 * @property integer $status
14 18 *
  19 + * * From language behavior *
  20 + * @property SeoCategoryLang $lang
  21 + * @property SeoCategoryLang[] $langs
  22 + * @property SeoCategoryLang $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 SeoCategoryLang[] 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 + *
15 37 * @property SeoDynamic[] $seoDynamics
16 38 */
17 39 class SeoCategory extends \yii\db\ActiveRecord
... ... @@ -23,7 +45,16 @@ class SeoCategory extends \yii\db\ActiveRecord
23 45 {
24 46 return 'seo_category';
25 47 }
26   -
  48 +
  49 + public function behaviors()
  50 + {
  51 + return [
  52 + 'language' => [
  53 + 'class' => LanguageBehavior::className(),
  54 + ],
  55 + ];
  56 + }
  57 +
27 58 /**
28 59 * @inheritdoc
29 60 */
... ...
common/models/SeoCategoryLang.php 0 โ†’ 100644
  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 "seo_category_lang".
  10 + *
  11 + * @property integer $seo_category_id
  12 + * @property integer $language_id
  13 + * @property string $name
  14 + *
  15 + * @property Language $language
  16 + * @property SeoCategory $seoCategory
  17 + */
  18 +class SeoCategoryLang extends \yii\db\ActiveRecord
  19 +{
  20 +
  21 + public static function primaryKey()
  22 + {
  23 + return [
  24 + 'seo_category_id',
  25 + 'language_id',
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return 'seo_category_lang';
  35 + }
  36 +
  37 + /**
  38 + * @inheritdoc
  39 + */
  40 + public function rules()
  41 + {
  42 + return [
  43 + [['name'], 'string', 'max' => 255],
  44 + [['seo_category_id', 'language_id'], 'unique', 'targetAttribute' => ['seo_category_id', 'language_id'], 'message' => 'The combination of Seo Category ID and Language ID has already been taken.'],
  45 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  46 + [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']],
  47 + ];
  48 + }
  49 +
  50 + /**
  51 + * @inheritdoc
  52 + */
  53 + public function attributeLabels()
  54 + {
  55 + return [
  56 + 'seo_category_id' => Yii::t('app', 'Seo Category ID'),
  57 + 'language_id' => Yii::t('app', 'Language ID'),
  58 + 'name' => Yii::t('app', 'Name'),
  59 + ];
  60 + }
  61 +
  62 + /**
  63 + * @return \yii\db\ActiveQuery
  64 + */
  65 + public function getLanguage()
  66 + {
  67 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  68 + }
  69 +
  70 + /**
  71 + * @return \yii\db\ActiveQuery
  72 + */
  73 + public function getSeoCategory()
  74 + {
  75 + return $this->hasOne(SeoCategory::className(), ['seo_category_id' => 'seo_category_id']);
  76 + }
  77 +}
... ...
common/models/SeoCategorySearch.php
... ... @@ -12,6 +12,12 @@ use common\models\SeoCategory;
12 12 */
13 13 class SeoCategorySearch extends SeoCategory
14 14 {
  15 +
  16 + public function behaviors()
  17 + {
  18 + return [];
  19 + }
  20 +
15 21 /**
16 22 * @inheritdoc
17 23 */
... ...
common/models/SeoDynamic.php
... ... @@ -2,8 +2,11 @@
2 2  
3 3 namespace common\models;
4 4  
  5 +use common\modules\language\behaviors\LanguageBehavior;
5 6 use Yii;
6   -
  7 +use yii\db\ActiveQuery;
  8 +use yii\db\ActiveRecord;
  9 +use yii\web\Request;
7 10 /**
8 11 * This is the model class for table "seo_dynamic".
9 12 *
... ... @@ -20,6 +23,23 @@ use Yii;
20 23 * @property string $param
21 24 * @property string $key
22 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 *
23 43 * @property SeoCategory $seoCategory
24 44 */
25 45 class SeoDynamic extends \yii\db\ActiveRecord
... ... @@ -31,7 +51,16 @@ class SeoDynamic extends \yii\db\ActiveRecord
31 51 {
32 52 return 'seo_dynamic';
33 53 }
34   -
  54 +
  55 + public function behaviors()
  56 + {
  57 + return [
  58 + 'language' => [
  59 + 'class' => LanguageBehavior::className(),
  60 + ],
  61 + ];
  62 + }
  63 +
35 64 /**
36 65 * @inheritdoc
37 66 */
... ...
common/models/SeoDynamicLang.php 0 โ†’ 100644
  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 "seo_dynamic_lang".
  10 + *
  11 + * @property integer $seo_dynamic_id
  12 + * @property integer $language_id
  13 + * @property string $name
  14 + * @property string $title
  15 + * @property string $h1
  16 + * @property string $key
  17 + * @property string $meta
  18 + * @property string $description
  19 + * @property string $seo_text
  20 + *
  21 + * @property Language $language
  22 + * @property SeoDynamic $seoDynamic
  23 + */
  24 +class SeoDynamicLang extends \yii\db\ActiveRecord
  25 +{
  26 +
  27 + public static function primaryKey()
  28 + {
  29 + return [
  30 + 'seo_dynamic_id',
  31 + 'language_id',
  32 + ];
  33 + }
  34 +
  35 + /**
  36 + * @inheritdoc
  37 + */
  38 + public static function tableName()
  39 + {
  40 + return 'seo_dynamic_lang';
  41 + }
  42 +
  43 + /**
  44 + * @inheritdoc
  45 + */
  46 + public function rules()
  47 + {
  48 + return [
  49 + [['title', 'description', 'seo_text'], 'string'],
  50 + [['name', 'h1', 'key', 'meta'], 'string', 'max' => 255],
  51 + [['seo_dynamic_id', 'language_id'], 'unique', 'targetAttribute' => ['seo_dynamic_id', 'language_id'], 'message' => 'The combination of Seo Dynamic ID and Language ID has already been taken.'],
  52 + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']],
  53 + [['seo_dynamic_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoDynamic::className(), 'targetAttribute' => ['seo_dynamic_id' => 'seo_dynamic_id']],
  54 + ];
  55 + }
  56 +
  57 + /**
  58 + * @inheritdoc
  59 + */
  60 + public function attributeLabels()
  61 + {
  62 + return [
  63 + 'seo_dynamic_id' => Yii::t('app', 'Seo Dynamic ID'),
  64 + 'language_id' => Yii::t('app', 'Language ID'),
  65 + 'name' => Yii::t('app', 'Name'),
  66 + 'title' => Yii::t('app', 'Title'),
  67 + 'h1' => Yii::t('app', 'H1'),
  68 + 'key' => Yii::t('app', 'Key'),
  69 + 'meta' => Yii::t('app', 'Meta'),
  70 + 'description' => Yii::t('app', 'Description'),
  71 + 'seo_text' => Yii::t('app', 'Seo Text'),
  72 + ];
  73 + }
  74 +
  75 + /**
  76 + * @return \yii\db\ActiveQuery
  77 + */
  78 + public function getLanguage()
  79 + {
  80 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
  81 + }
  82 +
  83 + /**
  84 + * @return \yii\db\ActiveQuery
  85 + */
  86 + public function getSeoDynamic()
  87 + {
  88 + return $this->hasOne(SeoDynamic::className(), ['seo_dynamic_id' => 'seo_dynamic_id']);
  89 + }
  90 +}
... ...
common/models/SeoDynamicSearch.php
... ... @@ -12,6 +12,12 @@ use common\models\SeoDynamic;
12 12 */
13 13 class SeoDynamicSearch extends SeoDynamic
14 14 {
  15 +
  16 + public function behaviors()
  17 + {
  18 + return [];
  19 + }
  20 +
15 21 /**
16 22 * @inheritdoc
17 23 */
... ...