Commit 593851ec8ae0e48445981e8623003543d91a296b
0 parents
First commit
Showing
39 changed files
with
3225 additions
and
0 deletions
Show diff stats
1 | +++ a/CHANGELOG.md | ||
1 | +# Change Log | ||
2 | +All notable changes to this project will be documented in this file. | ||
3 | + | ||
4 | +## 1.0.0 - 2017-03-21 | ||
5 | +### Added | ||
6 | +- This CHANGELOG file to hopefully serve as an evolving example of a standardized open source project CHANGELOG. | ||
7 | +- Added Gentelella XPanel widget. | ||
0 | \ No newline at end of file | 8 | \ No newline at end of file |
1 | +++ a/LICENSE.md | ||
1 | +The Yii framework is free software. It is released under the terms of | ||
2 | +the following BSD License. | ||
3 | + | ||
4 | +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) | ||
5 | +All rights reserved. | ||
6 | + | ||
7 | +Redistribution and use in source and binary forms, with or without | ||
8 | +modification, are permitted provided that the following conditions | ||
9 | +are met: | ||
10 | + | ||
11 | + * Redistributions of source code must retain the above copyright | ||
12 | + notice, this list of conditions and the following disclaimer. | ||
13 | + * Redistributions in binary form must reproduce the above copyright | ||
14 | + notice, this list of conditions and the following disclaimer in | ||
15 | + the documentation and/or other materials provided with the | ||
16 | + distribution. | ||
17 | + * Neither the name of Yii Software LLC nor the names of its | ||
18 | + contributors may be used to endorse or promote products derived | ||
19 | + from this software without specific prior written permission. | ||
20 | + | ||
21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
24 | +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
25 | +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
26 | +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
27 | +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
28 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
29 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
31 | +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
32 | +POSSIBILITY OF SUCH DAMAGE. |
1 | +++ a/README.md | ||
1 | +Artbox Gentelella | ||
2 | +=============================== | ||
3 | + | ||
4 | +**Artbox Gentelella** extension provide support for [Gentelella](https://colorlib.com/polygon/gentelella/) | ||
5 | +library. It consists of different widgets to improve and beautify UI. | ||
6 | + | ||
7 | +DIRECTORY STRUCTURE | ||
8 | +------------------- | ||
9 | + | ||
10 | +``` | ||
11 | +common contains widgets | ||
12 | +``` |
1 | +++ a/composer.json | ||
1 | +{ | ||
2 | + "name": "artweb/artbox-gentelella", | ||
3 | + "description": "Artbox Gentelella support extension", | ||
4 | + "license": "BSD-3-Clause", | ||
5 | + "minimum-stability": "dev", | ||
6 | + "type": "yii2-extension", | ||
7 | + "require": { | ||
8 | + "php": ">=7.0", | ||
9 | + "yiisoft/yii2": "~2.0", | ||
10 | + "yiisoft/yii2-bootstrap": "~2.0" | ||
11 | + }, | ||
12 | + "autoload": { | ||
13 | + "psr-4": { | ||
14 | + "artbox\\gentelella\\": "" | ||
15 | + } | ||
16 | + } | ||
17 | +} | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
1 | +++ a/controllers/ArticleController.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artbox\weblog\controllers; | ||
4 | + | ||
5 | + use artbox\weblog\models\BlogCategory; | ||
6 | + use artbox\weblog\models\BlogTag; | ||
7 | + use Yii; | ||
8 | + use artbox\weblog\models\BlogArticle; | ||
9 | + use artbox\weblog\models\BlogArticleSearch; | ||
10 | + use yii\helpers\ArrayHelper; | ||
11 | + use yii\web\Controller; | ||
12 | + use yii\web\NotFoundHttpException; | ||
13 | + use yii\filters\VerbFilter; | ||
14 | + use yii\web\Response; | ||
15 | + | ||
16 | + /** | ||
17 | + * BlogArticleController implements the CRUD actions for BlogArticle model. | ||
18 | + */ | ||
19 | + class BlogArticleController extends Controller | ||
20 | + { | ||
21 | + /** | ||
22 | + * @inheritdoc | ||
23 | + */ | ||
24 | + public function behaviors() | ||
25 | + { | ||
26 | + return [ | ||
27 | + 'verbs' => [ | ||
28 | + 'class' => VerbFilter::className(), | ||
29 | + 'actions' => [ | ||
30 | + 'delete' => [ 'POST' ], | ||
31 | + ], | ||
32 | + ], | ||
33 | + ]; | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * Lists all BlogArticle models. | ||
38 | + * | ||
39 | + * @return mixed | ||
40 | + */ | ||
41 | + public function actionIndex() | ||
42 | + { | ||
43 | + $searchModel = new BlogArticleSearch(); | ||
44 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
45 | + | ||
46 | + return $this->render( | ||
47 | + 'index', | ||
48 | + [ | ||
49 | + 'searchModel' => $searchModel, | ||
50 | + 'dataProvider' => $dataProvider, | ||
51 | + ] | ||
52 | + ); | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Displays a single BlogArticle model. | ||
57 | + * | ||
58 | + * @param integer $id | ||
59 | + * | ||
60 | + * @return mixed | ||
61 | + */ | ||
62 | + public function actionView($id) | ||
63 | + { | ||
64 | + return $this->render( | ||
65 | + 'view', | ||
66 | + [ | ||
67 | + 'model' => $this->findModel($id), | ||
68 | + ] | ||
69 | + ); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Creates a new BlogArticle model. | ||
74 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
75 | + * | ||
76 | + * @return mixed | ||
77 | + */ | ||
78 | + public function actionCreate() | ||
79 | + { | ||
80 | + $model = new BlogArticle(); | ||
81 | + $model->generateLangs(); | ||
82 | + | ||
83 | + $categories = ArrayHelper::map( | ||
84 | + BlogCategory::find() | ||
85 | + ->joinWith('lang') | ||
86 | + ->all(), | ||
87 | + 'id', | ||
88 | + 'lang.title' | ||
89 | + ); | ||
90 | + | ||
91 | + $tags = ArrayHelper::map( | ||
92 | + BlogTag::find() | ||
93 | + ->joinWith('lang') | ||
94 | + ->all(), | ||
95 | + 'id', | ||
96 | + 'lang.label' | ||
97 | + ); | ||
98 | + | ||
99 | + if ($model->load(Yii::$app->request->post())) { | ||
100 | + $model->loadLangs(\Yii::$app->request); | ||
101 | + if ($model->save() && $model->transactionStatus) { | ||
102 | + | ||
103 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { | ||
104 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { | ||
105 | + if ($category = BlogCategory::findOne($item)) { | ||
106 | + $model->link('blogCategories', $category); | ||
107 | + } | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { | ||
112 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { | ||
113 | + if ($category = BlogTag::findOne($item)) { | ||
114 | + $model->link('blogTags', $category); | ||
115 | + } | ||
116 | + } | ||
117 | + } | ||
118 | + | ||
119 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'products' ] )) { | ||
120 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'products' ] as $item) { | ||
121 | + if ($product = Product::findOne($item)) { | ||
122 | + $model->link('products', $product); | ||
123 | + } | ||
124 | + } | ||
125 | + } | ||
126 | + | ||
127 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] )) { | ||
128 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] as $item) { | ||
129 | + if ($article = Product::findOne($item)) { | ||
130 | + $model->link('blogArticles', $article); | ||
131 | + } | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
135 | + return $this->redirect( | ||
136 | + [ | ||
137 | + 'view', | ||
138 | + 'id' => $model->id, | ||
139 | + ] | ||
140 | + ); | ||
141 | + } | ||
142 | + } | ||
143 | + return $this->render( | ||
144 | + 'create', | ||
145 | + [ | ||
146 | + 'model' => $model, | ||
147 | + 'modelLangs' => $model->modelLangs, | ||
148 | + 'categories' => $categories, | ||
149 | + 'tags' => $tags, | ||
150 | + 'products' => [], | ||
151 | + 'articles' => [], | ||
152 | + ] | ||
153 | + ); | ||
154 | + | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * Updates an existing BlogArticle model. | ||
159 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
160 | + * | ||
161 | + * @param integer $id | ||
162 | + * | ||
163 | + * @return mixed | ||
164 | + */ | ||
165 | + public function actionUpdate($id) | ||
166 | + { | ||
167 | + $model = $this->findModel($id); | ||
168 | + $model->generateLangs(); | ||
169 | + | ||
170 | + $categories = ArrayHelper::map( | ||
171 | + BlogCategory::find() | ||
172 | + ->joinWith('lang') | ||
173 | + ->all(), | ||
174 | + 'id', | ||
175 | + 'lang.title' | ||
176 | + ); | ||
177 | + | ||
178 | + $tags = ArrayHelper::map( | ||
179 | + BlogTag::find() | ||
180 | + ->joinWith('lang') | ||
181 | + ->all(), | ||
182 | + 'id', | ||
183 | + 'lang.label' | ||
184 | + ); | ||
185 | + | ||
186 | + $products = ArrayHelper::map( | ||
187 | + $model->getProducts() | ||
188 | + ->joinWith('lang') | ||
189 | + ->asArray() | ||
190 | + ->all(), | ||
191 | + 'id', | ||
192 | + 'lang.title' | ||
193 | + ); | ||
194 | + | ||
195 | + $articles = ArrayHelper::map( | ||
196 | + $model->getBlogArticles() | ||
197 | + ->joinWith('lang') | ||
198 | + ->asArray() | ||
199 | + ->all(), | ||
200 | + 'id', | ||
201 | + 'lang.title' | ||
202 | + ); | ||
203 | + | ||
204 | + if ($model->load(Yii::$app->request->post())) { | ||
205 | + $model->loadLangs(\Yii::$app->request); | ||
206 | + if ($model->save() && $model->transactionStatus) { | ||
207 | + | ||
208 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { | ||
209 | + $model->unlinkAll('blogCategories', true); | ||
210 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { | ||
211 | + if ($category = BlogCategory::findOne($item)) { | ||
212 | + $model->link('blogCategories', $category); | ||
213 | + } | ||
214 | + } | ||
215 | + } | ||
216 | + | ||
217 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { | ||
218 | + $model->unlinkAll('blogTags', true); | ||
219 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { | ||
220 | + if ($tag = BlogTag::findOne($item)) { | ||
221 | + $model->link('blogTags', $tag); | ||
222 | + } | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'products' ] )) { | ||
227 | + $model->unlinkAll('products', true); | ||
228 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'products' ] as $item) { | ||
229 | + if ($product = Product::findOne($item)) { | ||
230 | + $model->link('products', $product); | ||
231 | + } | ||
232 | + } | ||
233 | + } | ||
234 | + | ||
235 | + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] )) { | ||
236 | + $model->unlinkAll('blogArticles', true); | ||
237 | + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] as $item) { | ||
238 | + if ($article = BlogArticle::findOne($item)) { | ||
239 | + $model->link('blogArticles', $article); | ||
240 | + } | ||
241 | + } | ||
242 | + } | ||
243 | + | ||
244 | + return $this->redirect( | ||
245 | + [ | ||
246 | + 'view', | ||
247 | + 'id' => $model->id, | ||
248 | + ] | ||
249 | + ); | ||
250 | + } | ||
251 | + } | ||
252 | + return $this->render( | ||
253 | + 'update', | ||
254 | + [ | ||
255 | + 'model' => $model, | ||
256 | + 'modelLangs' => $model->modelLangs, | ||
257 | + 'categories' => $categories, | ||
258 | + 'tags' => $tags, | ||
259 | + 'products' => $products, | ||
260 | + 'articles' => $articles, | ||
261 | + ] | ||
262 | + ); | ||
263 | + | ||
264 | + } | ||
265 | + | ||
266 | + /** | ||
267 | + * Deletes an existing BlogArticle model. | ||
268 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
269 | + * | ||
270 | + * @param integer $id | ||
271 | + * | ||
272 | + * @return mixed | ||
273 | + */ | ||
274 | + public function actionDelete($id) | ||
275 | + { | ||
276 | + $this->findModel($id) | ||
277 | + ->delete(); | ||
278 | + | ||
279 | + return $this->redirect([ 'index' ]); | ||
280 | + } | ||
281 | + | ||
282 | + public function actionDeleteImage($id) | ||
283 | + { | ||
284 | + $model = $this->findModel($id); | ||
285 | + $model->image = null; | ||
286 | + $model->updateAttributes(['image']); | ||
287 | + return true; | ||
288 | + } | ||
289 | + | ||
290 | + /** | ||
291 | + * Finds the BlogArticle model based on its primary key value. | ||
292 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
293 | + * | ||
294 | + * @param integer $id | ||
295 | + * | ||
296 | + * @return BlogArticle the loaded model | ||
297 | + * @throws NotFoundHttpException if the model cannot be found | ||
298 | + */ | ||
299 | + protected function findModel($id) | ||
300 | + { | ||
301 | + if (( $model = BlogArticle::findOne($id) ) !== NULL) { | ||
302 | + return $model; | ||
303 | + } else { | ||
304 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
308 | + /** | ||
309 | + * @param string $q | ||
310 | + * @param null $id | ||
311 | + * | ||
312 | + * @return array | ||
313 | + */ | ||
314 | + public function actionProductList($q = NULL, $id = NULL) | ||
315 | + { | ||
316 | + \Yii::$app->response->format = Response::FORMAT_JSON; | ||
317 | + $out = [ | ||
318 | + 'results' => [ | ||
319 | + 'id' => '', | ||
320 | + 'text' => '', | ||
321 | + ], | ||
322 | + ]; | ||
323 | + if (!is_null($q)) { | ||
324 | + $out[ 'results' ] = Product::find() | ||
325 | + ->joinWith('lang') | ||
326 | + ->select( | ||
327 | + [ | ||
328 | + 'id', | ||
329 | + 'product_lang.title as text', | ||
330 | + ] | ||
331 | + ) | ||
332 | + ->where( | ||
333 | + [ | ||
334 | + 'like', | ||
335 | + 'product_lang.title', | ||
336 | + $q, | ||
337 | + ] | ||
338 | + ) | ||
339 | + ->limit(20) | ||
340 | + ->asArray() | ||
341 | + ->all(); | ||
342 | + } elseif ($id > 0) { | ||
343 | + $out[ 'results' ] = [ | ||
344 | + 'id' => $id, | ||
345 | + 'text' => Product::find() | ||
346 | + ->joinWith('lang') | ||
347 | + ->where([ 'id' => $id ]) | ||
348 | + ->one()->title, | ||
349 | + ]; | ||
350 | + } | ||
351 | + return $out; | ||
352 | + } | ||
353 | + | ||
354 | + /** | ||
355 | + * @param string $q | ||
356 | + * @param integer $id | ||
357 | + * | ||
358 | + * @return array | ||
359 | + */ | ||
360 | + public function actionArticleList($q = NULL, $id = NULL) | ||
361 | + { | ||
362 | + \Yii::$app->response->format = Response::FORMAT_JSON; | ||
363 | + $out = [ | ||
364 | + 'results' => [ | ||
365 | + 'id' => '', | ||
366 | + 'text' => '', | ||
367 | + ], | ||
368 | + ]; | ||
369 | + if (!is_null($q)) { | ||
370 | + $out[ 'results' ] = BlogArticle::find() | ||
371 | + ->joinWith('lang') | ||
372 | + ->select( | ||
373 | + [ | ||
374 | + 'blog_article.id as id', | ||
375 | + 'blog_article_lang.title as text', | ||
376 | + ] | ||
377 | + ) | ||
378 | + ->where( | ||
379 | + [ | ||
380 | + 'like', | ||
381 | + 'blog_article_lang.title', | ||
382 | + $q, | ||
383 | + ] | ||
384 | + ) | ||
385 | + ->andWhere( | ||
386 | + [ | ||
387 | + '!=', | ||
388 | + 'blog_article.id', | ||
389 | + $id, | ||
390 | + ] | ||
391 | + ) | ||
392 | + ->limit(20) | ||
393 | + ->asArray() | ||
394 | + ->all(); | ||
395 | + } | ||
396 | + return $out; | ||
397 | + } | ||
398 | + } |
1 | +++ a/controllers/BlogCategoryController.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\controllers; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use artweb\artbox\blog\models\BlogCategory; | ||
7 | + use artweb\artbox\blog\models\BlogCategorySearch; | ||
8 | + use yii\helpers\ArrayHelper; | ||
9 | + use yii\web\Controller; | ||
10 | + use yii\web\NotFoundHttpException; | ||
11 | + use yii\filters\VerbFilter; | ||
12 | + | ||
13 | + /** | ||
14 | + * BlogCategoryController implements the CRUD actions for BlogCategory model. | ||
15 | + */ | ||
16 | + class BlogCategoryController extends Controller | ||
17 | + { | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public function behaviors() | ||
22 | + { | ||
23 | + return [ | ||
24 | + 'verbs' => [ | ||
25 | + 'class' => VerbFilter::className(), | ||
26 | + 'actions' => [ | ||
27 | + 'delete' => [ 'POST' ], | ||
28 | + ], | ||
29 | + ], | ||
30 | + ]; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * Lists all BlogCategory models. | ||
35 | + * | ||
36 | + * @return mixed | ||
37 | + */ | ||
38 | + public function actionIndex() | ||
39 | + { | ||
40 | + $searchModel = new BlogCategorySearch(); | ||
41 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
42 | + | ||
43 | + return $this->render( | ||
44 | + 'index', | ||
45 | + [ | ||
46 | + 'searchModel' => $searchModel, | ||
47 | + 'dataProvider' => $dataProvider, | ||
48 | + ] | ||
49 | + ); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Displays a single BlogCategory model. | ||
54 | + * | ||
55 | + * @param integer $id | ||
56 | + * | ||
57 | + * @return mixed | ||
58 | + */ | ||
59 | + public function actionView($id) | ||
60 | + { | ||
61 | + return $this->render( | ||
62 | + 'view', | ||
63 | + [ | ||
64 | + 'model' => $this->findModel($id), | ||
65 | + ] | ||
66 | + ); | ||
67 | + } | ||
68 | + | ||
69 | + /** | ||
70 | + * Creates a new BlogCategory model. | ||
71 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
72 | + * | ||
73 | + * @return mixed | ||
74 | + */ | ||
75 | + public function actionCreate() | ||
76 | + { | ||
77 | + $model = new BlogCategory(); | ||
78 | + $model->generateLangs(); | ||
79 | + $parentCategories = ArrayHelper::map( | ||
80 | + BlogCategory::find() | ||
81 | + ->joinWith('lang') | ||
82 | + ->where( | ||
83 | + [ | ||
84 | + 'parent_id' => 0, | ||
85 | + ] | ||
86 | + ) | ||
87 | + ->all(), | ||
88 | + 'id', | ||
89 | + 'lang.title' | ||
90 | + ); | ||
91 | + | ||
92 | + if ($model->load(Yii::$app->request->post())) { | ||
93 | + $model->loadLangs(\Yii::$app->request); | ||
94 | + if ($model->save() && $model->transactionStatus) { | ||
95 | + return $this->redirect( | ||
96 | + [ | ||
97 | + 'view', | ||
98 | + 'id' => $model->id, | ||
99 | + ] | ||
100 | + ); | ||
101 | + } | ||
102 | + } | ||
103 | + return $this->render( | ||
104 | + 'create', | ||
105 | + [ | ||
106 | + 'model' => $model, | ||
107 | + 'modelLangs' => $model->modelLangs, | ||
108 | + 'parentCategories' => $parentCategories, | ||
109 | + ] | ||
110 | + ); | ||
111 | + | ||
112 | + } | ||
113 | + | ||
114 | + /** | ||
115 | + * Updates an existing BlogCategory model. | ||
116 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
117 | + * | ||
118 | + * @param integer $id | ||
119 | + * | ||
120 | + * @return mixed | ||
121 | + */ | ||
122 | + public function actionUpdate($id) | ||
123 | + { | ||
124 | + $model = $this->findModel($id); | ||
125 | + $model->generateLangs(); | ||
126 | + $parentCategories = ArrayHelper::map( | ||
127 | + BlogCategory::find() | ||
128 | + ->joinWith('lang') | ||
129 | + ->where( | ||
130 | + [ | ||
131 | + 'parent_id' => 0, | ||
132 | + ] | ||
133 | + ) | ||
134 | + ->andWhere( | ||
135 | + [ | ||
136 | + '!=', | ||
137 | + BlogCategory::tableName() . '_id', | ||
138 | + $model->id, | ||
139 | + ] | ||
140 | + ) | ||
141 | + ->all(), | ||
142 | + 'id', | ||
143 | + 'lang.title' | ||
144 | + ); | ||
145 | + | ||
146 | + if ($model->load(Yii::$app->request->post())) { | ||
147 | + $model->loadLangs(\Yii::$app->request); | ||
148 | + if ($model->save() && $model->transactionStatus) { | ||
149 | + return $this->redirect( | ||
150 | + [ | ||
151 | + 'view', | ||
152 | + 'id' => $model->id, | ||
153 | + ] | ||
154 | + ); | ||
155 | + } | ||
156 | + } | ||
157 | + return $this->render( | ||
158 | + 'update', | ||
159 | + [ | ||
160 | + 'model' => $model, | ||
161 | + 'modelLangs' => $model->modelLangs, | ||
162 | + 'parentCategories' => $parentCategories, | ||
163 | + ] | ||
164 | + ); | ||
165 | + | ||
166 | + } | ||
167 | + | ||
168 | + /** | ||
169 | + * Deletes an existing BlogCategory model. | ||
170 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
171 | + * | ||
172 | + * @param integer $id | ||
173 | + * | ||
174 | + * @return mixed | ||
175 | + */ | ||
176 | + public function actionDelete($id) | ||
177 | + { | ||
178 | + $this->findModel($id) | ||
179 | + ->delete(); | ||
180 | + | ||
181 | + return $this->redirect([ 'index' ]); | ||
182 | + } | ||
183 | + | ||
184 | + public function actionDeleteImage($id) | ||
185 | + { | ||
186 | + $model = $this->findModel($id); | ||
187 | + $model->image = null; | ||
188 | + $model->updateAttributes(['image']); | ||
189 | + return true; | ||
190 | + } | ||
191 | + | ||
192 | + /** | ||
193 | + * Finds the BlogCategory model based on its primary key value. | ||
194 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
195 | + * | ||
196 | + * @param integer $id | ||
197 | + * | ||
198 | + * @return BlogCategory the loaded model | ||
199 | + * @throws NotFoundHttpException if the model cannot be found | ||
200 | + */ | ||
201 | + protected function findModel($id) | ||
202 | + { | ||
203 | + if (( $model = BlogCategory::findOne($id) ) !== NULL) { | ||
204 | + return $model; | ||
205 | + } else { | ||
206 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
207 | + } | ||
208 | + } | ||
209 | + } |
1 | +++ a/controllers/BlogTagController.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\controllers; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use artweb\artbox\blog\models\BlogTag; | ||
7 | + use artweb\artbox\blog\models\BlogTagSearch; | ||
8 | + use yii\web\Controller; | ||
9 | + use yii\web\NotFoundHttpException; | ||
10 | + use yii\filters\VerbFilter; | ||
11 | + | ||
12 | + /** | ||
13 | + * BlogTagController implements the CRUD actions for BlogTag model. | ||
14 | + */ | ||
15 | + class BlogTagController extends Controller | ||
16 | + { | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public function behaviors() | ||
21 | + { | ||
22 | + return [ | ||
23 | + 'verbs' => [ | ||
24 | + 'class' => VerbFilter::className(), | ||
25 | + 'actions' => [ | ||
26 | + 'delete' => [ 'POST' ], | ||
27 | + ], | ||
28 | + ], | ||
29 | + ]; | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * Lists all BlogTag models. | ||
34 | + * | ||
35 | + * @return mixed | ||
36 | + */ | ||
37 | + public function actionIndex() | ||
38 | + { | ||
39 | + $searchModel = new BlogTagSearch(); | ||
40 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
41 | + | ||
42 | + return $this->render( | ||
43 | + 'index', | ||
44 | + [ | ||
45 | + 'searchModel' => $searchModel, | ||
46 | + 'dataProvider' => $dataProvider, | ||
47 | + ] | ||
48 | + ); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * Displays a single BlogTag model. | ||
53 | + * | ||
54 | + * @param integer $id | ||
55 | + * | ||
56 | + * @return mixed | ||
57 | + */ | ||
58 | + public function actionView($id) | ||
59 | + { | ||
60 | + return $this->render( | ||
61 | + 'view', | ||
62 | + [ | ||
63 | + 'model' => $this->findModel($id), | ||
64 | + ] | ||
65 | + ); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Creates a new BlogTag model. | ||
70 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
71 | + * | ||
72 | + * @return mixed | ||
73 | + */ | ||
74 | + public function actionCreate() | ||
75 | + { | ||
76 | + $model = new BlogTag(); | ||
77 | + $model->generateLangs(); | ||
78 | + | ||
79 | + if (\Yii::$app->request->isPost) { | ||
80 | + $model->loadLangs(\Yii::$app->request); | ||
81 | + $model->markAttributeDirty('id'); | ||
82 | + if ($model->save() && $model->transactionStatus) { | ||
83 | + return $this->redirect( | ||
84 | + [ | ||
85 | + 'view', | ||
86 | + 'id' => $model->id, | ||
87 | + ] | ||
88 | + ); | ||
89 | + } | ||
90 | + } | ||
91 | + return $this->render( | ||
92 | + 'create', | ||
93 | + [ | ||
94 | + 'model' => $model, | ||
95 | + 'modelLangs' => $model->modelLangs, | ||
96 | + ] | ||
97 | + ); | ||
98 | + | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Updates an existing BlogTag model. | ||
103 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
104 | + * | ||
105 | + * @param integer $id | ||
106 | + * | ||
107 | + * @return mixed | ||
108 | + */ | ||
109 | + public function actionUpdate($id) | ||
110 | + { | ||
111 | + $model = $this->findModel($id); | ||
112 | + $model->generateLangs(); | ||
113 | + | ||
114 | + if (Yii::$app->request->isPost) { | ||
115 | + $model->loadLangs(\Yii::$app->request); | ||
116 | + $model->markAttributeDirty('id'); | ||
117 | + if ($model->save() && $model->transactionStatus) { | ||
118 | + return $this->redirect( | ||
119 | + [ | ||
120 | + 'view', | ||
121 | + 'id' => $model->id, | ||
122 | + ] | ||
123 | + ); | ||
124 | + } | ||
125 | + } | ||
126 | + return $this->render( | ||
127 | + 'update', | ||
128 | + [ | ||
129 | + 'model' => $model, | ||
130 | + 'modelLangs' => $model->modelLangs, | ||
131 | + ] | ||
132 | + ); | ||
133 | + | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Deletes an existing BlogTag 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 BlogTag 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 BlogTag the loaded model | ||
159 | + * @throws NotFoundHttpException if the model cannot be found | ||
160 | + */ | ||
161 | + protected function findModel($id) | ||
162 | + { | ||
163 | + if (( $model = BlogTag::findOne($id) ) !== NULL) { | ||
164 | + return $model; | ||
165 | + } else { | ||
166 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
167 | + } | ||
168 | + } | ||
169 | + } |
1 | +++ a/controllers/DefaultController.php | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace artweb\artbox\blog\controllers; | ||
4 | + | ||
5 | +use yii\web\Controller; | ||
6 | + | ||
7 | +/** | ||
8 | + * Default controller for the `blog` module | ||
9 | + */ | ||
10 | +class DefaultController extends Controller | ||
11 | +{ | ||
12 | + /** | ||
13 | + * Renders the index view for the module | ||
14 | + * @return string | ||
15 | + */ | ||
16 | + public function actionIndex() | ||
17 | + { | ||
18 | + return $this->render('index'); | ||
19 | + } | ||
20 | +} |
1 | +++ a/models/BlogArticle.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use artweb\artbox\behaviors\SaveImgBehavior; | ||
6 | + use yii\behaviors\TimestampBehavior; | ||
7 | + use yii\db\ActiveRecord; | ||
8 | + use artweb\artbox\language\behaviors\LanguageBehavior; | ||
9 | + use artweb\artbox\language\models\Language; | ||
10 | + use artweb\artbox\ecommerce\models\Product; | ||
11 | + use yii\db\ActiveQuery; | ||
12 | + use yii\web\Request; | ||
13 | + | ||
14 | + /** | ||
15 | + * This is the model class for table "blog_article". | ||
16 | + * | ||
17 | + * @property integer $id | ||
18 | + * @property string $image | ||
19 | + * @property integer $created_at | ||
20 | + * @property integer $updated_at | ||
21 | + * @property integer $deleted_at | ||
22 | + * @property integer $sort | ||
23 | + * @property boolean $status | ||
24 | + * @property integer $author_id | ||
25 | + * @property BlogArticleLang[] $blogArticleLangs | ||
26 | + * @property Language[] $languages | ||
27 | + * @property BlogArticle[] $relatedBlogArticles | ||
28 | + * @property BlogArticle[] $blogArticles | ||
29 | + * @property BlogCategory[] $blogCategories | ||
30 | + * @property BlogCategory $blogCategory | ||
31 | + * @property Product[] $products | ||
32 | + * @property BlogTag[] $blogTags | ||
33 | + * * * From language behavior * | ||
34 | + * @property BlogArticleLang $lang | ||
35 | + * @property BlogArticleLang[] $langs | ||
36 | + * @property BlogArticleLang $objectLang | ||
37 | + * @property string $ownerKey | ||
38 | + * @property string $langKey | ||
39 | + * @property BlogArticleLang[] $modelLangs | ||
40 | + * @property bool $transactionStatus | ||
41 | + * @method string getOwnerKey() | ||
42 | + * @method void setOwnerKey( string $value ) | ||
43 | + * @method string getLangKey() | ||
44 | + * @method void setLangKey( string $value ) | ||
45 | + * @method ActiveQuery getLangs() | ||
46 | + * @method ActiveQuery getLang( integer $language_id ) | ||
47 | + * @method BlogArticleLang[] generateLangs() | ||
48 | + * @method void loadLangs( Request $request ) | ||
49 | + * @method bool linkLangs() | ||
50 | + * @method bool saveLangs() | ||
51 | + * @method bool getTransactionStatus() | ||
52 | + * * End language behavior * | ||
53 | + * * From SaveImgBehavior | ||
54 | + * @property string|null $imageFile | ||
55 | + * @property string|null $imageUrl | ||
56 | + * @method string|null getImageFile( int $field ) | ||
57 | + * @method string|null getImageUrl( int $field ) | ||
58 | + * * End SaveImgBehavior | ||
59 | + */ | ||
60 | + class BlogArticle extends ActiveRecord | ||
61 | + { | ||
62 | + /** | ||
63 | + * @inheritdoc | ||
64 | + */ | ||
65 | + public static function tableName() | ||
66 | + { | ||
67 | + return 'blog_article'; | ||
68 | + } | ||
69 | + | ||
70 | + public function behaviors() | ||
71 | + { | ||
72 | + return [ | ||
73 | + [ | ||
74 | + 'class' => TimestampBehavior::className(), | ||
75 | + ], | ||
76 | + [ | ||
77 | + 'class' => SaveImgBehavior::className(), | ||
78 | + 'fields' => [ | ||
79 | + [ | ||
80 | + 'name' => 'image', | ||
81 | + 'directory' => 'blog/article', | ||
82 | + ], | ||
83 | + ], | ||
84 | + ], | ||
85 | + 'language' => [ | ||
86 | + 'class' => LanguageBehavior::className(), | ||
87 | + ], | ||
88 | + ]; | ||
89 | + } | ||
90 | + /** | ||
91 | + * @inheritdoc | ||
92 | + */ | ||
93 | + public function rules() | ||
94 | + { | ||
95 | + return [ | ||
96 | + [ | ||
97 | + [ | ||
98 | + 'created_at', | ||
99 | + 'updated_at', | ||
100 | + 'deleted_at', | ||
101 | + 'sort', | ||
102 | + 'author_id', | ||
103 | + ], | ||
104 | + 'integer', | ||
105 | + ], | ||
106 | + [ | ||
107 | + [ 'status' ], | ||
108 | + 'boolean', | ||
109 | + ], | ||
110 | + [ | ||
111 | + [ 'image' ], | ||
112 | + 'string', | ||
113 | + 'max' => 255, | ||
114 | + ], | ||
115 | + ]; | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * @inheritdoc | ||
120 | + */ | ||
121 | + public function attributeLabels() | ||
122 | + { | ||
123 | + return [ | ||
124 | + 'id' => 'ID', | ||
125 | + 'image' => 'Image', | ||
126 | + 'created_at' => 'Created At', | ||
127 | + 'updated_at' => 'Updated At', | ||
128 | + 'deleted_at' => 'Deleted At', | ||
129 | + 'sort' => 'Sort', | ||
130 | + 'status' => 'Status', | ||
131 | + 'author_id' => 'Author ID', | ||
132 | + ]; | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * @return \yii\db\ActiveQuery | ||
137 | + */ | ||
138 | + public function getRelatedBlogArticles() | ||
139 | + { | ||
140 | + return $this->hasMany(BlogArticle::className(), [ 'id' => 'related_blog_article_id' ]) | ||
141 | + ->viaTable('blog_article_to_article', [ 'blog_article_id' => 'id' ]); | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * @return \yii\db\ActiveQuery | ||
146 | + */ | ||
147 | + public function getBlogArticles() | ||
148 | + { | ||
149 | + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) | ||
150 | + ->viaTable('blog_article_to_article', [ 'related_blog_article_id' => 'id' ]); | ||
151 | + } | ||
152 | + | ||
153 | + /** | ||
154 | + * @return \yii\db\ActiveQuery | ||
155 | + */ | ||
156 | + public function getBlogCategories() | ||
157 | + { | ||
158 | + return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) | ||
159 | + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); | ||
160 | + } | ||
161 | + | ||
162 | + /** | ||
163 | + * @return \yii\db\ActiveQuery | ||
164 | + */ | ||
165 | + public function getBlogCategory() | ||
166 | + { | ||
167 | + return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) | ||
168 | + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); | ||
169 | + } | ||
170 | + | ||
171 | + /** | ||
172 | + * @return \yii\db\ActiveQuery | ||
173 | + */ | ||
174 | + public function getProducts() | ||
175 | + { | ||
176 | + return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) | ||
177 | + ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]); | ||
178 | + } | ||
179 | + | ||
180 | + /** | ||
181 | + * @return \yii\db\ActiveQuery | ||
182 | + */ | ||
183 | + public function getBlogTags() | ||
184 | + { | ||
185 | + return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ]) | ||
186 | + ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]); | ||
187 | + } | ||
188 | + } |
1 | +++ a/models/BlogArticleLang.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use artweb\artbox\language\models\Language; | ||
6 | + use yii\db\ActiveRecord; | ||
7 | + | ||
8 | + /** | ||
9 | + * This is the model class for table "blog_article_lang". | ||
10 | + * | ||
11 | + * @property integer $id | ||
12 | + * @property integer $blog_article_id | ||
13 | + * @property integer $language_id | ||
14 | + * @property string $title | ||
15 | + * @property string $body | ||
16 | + * @property string $body_preview | ||
17 | + * @property string $alias | ||
18 | + * @property string $meta_title | ||
19 | + * @property string $meta_description | ||
20 | + * @property string $h1 | ||
21 | + * @property string $seo_text | ||
22 | + * @property BlogArticle $blogArticle | ||
23 | + * @property Language $language | ||
24 | + */ | ||
25 | + class BlogArticleLang extends ActiveRecord | ||
26 | + { | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public static function tableName() | ||
31 | + { | ||
32 | + return 'blog_article_lang'; | ||
33 | + } | ||
34 | + | ||
35 | + public function behaviors() | ||
36 | + { | ||
37 | + return [ | ||
38 | + 'slug' => [ | ||
39 | + 'class' => 'artweb\artbox\behaviors\Slug', | ||
40 | + ], | ||
41 | + ]; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * @inheritdoc | ||
46 | + */ | ||
47 | + public function rules() | ||
48 | + { | ||
49 | + return [ | ||
50 | + [ | ||
51 | + [ | ||
52 | + 'blog_article_id', | ||
53 | + 'language_id', | ||
54 | + 'title', | ||
55 | + ], | ||
56 | + 'required', | ||
57 | + ], | ||
58 | + [ | ||
59 | + [ | ||
60 | + 'blog_article_id', | ||
61 | + 'language_id', | ||
62 | + ], | ||
63 | + 'integer', | ||
64 | + ], | ||
65 | + [ | ||
66 | + [ | ||
67 | + 'body', | ||
68 | + 'body_preview', | ||
69 | + ], | ||
70 | + 'string', | ||
71 | + ], | ||
72 | + [ | ||
73 | + [ | ||
74 | + 'title', | ||
75 | + 'alias', | ||
76 | + 'meta_title', | ||
77 | + 'meta_description', | ||
78 | + 'h1', | ||
79 | + 'seo_text', | ||
80 | + ], | ||
81 | + 'string', | ||
82 | + 'max' => 255, | ||
83 | + ], | ||
84 | + [ | ||
85 | + [ 'alias' ], | ||
86 | + 'unique', | ||
87 | + ], | ||
88 | + [ | ||
89 | + [ | ||
90 | + 'blog_article_id', | ||
91 | + 'language_id', | ||
92 | + ], | ||
93 | + 'unique', | ||
94 | + 'targetAttribute' => [ | ||
95 | + 'blog_article_id', | ||
96 | + 'language_id', | ||
97 | + ], | ||
98 | + 'message' => 'The combination of Blog Article ID and Language ID has already been taken.', | ||
99 | + ], | ||
100 | + [ | ||
101 | + [ 'blog_article_id' ], | ||
102 | + 'exist', | ||
103 | + 'skipOnError' => true, | ||
104 | + 'targetClass' => BlogArticle::className(), | ||
105 | + 'targetAttribute' => [ 'blog_article_id' => 'id' ], | ||
106 | + ], | ||
107 | + [ | ||
108 | + [ 'language_id' ], | ||
109 | + 'exist', | ||
110 | + 'skipOnError' => true, | ||
111 | + 'targetClass' => Language::className(), | ||
112 | + 'targetAttribute' => [ 'language_id' => 'id' ], | ||
113 | + ], | ||
114 | + ]; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * @inheritdoc | ||
119 | + */ | ||
120 | + public function attributeLabels() | ||
121 | + { | ||
122 | + return [ | ||
123 | + 'id' => 'ID', | ||
124 | + 'blog_article_id' => 'Blog Article ID', | ||
125 | + 'language_id' => 'Language ID', | ||
126 | + 'title' => 'Title', | ||
127 | + 'body' => 'Body', | ||
128 | + 'body_preview' => 'Body Preview', | ||
129 | + 'alias' => 'Alias', | ||
130 | + 'meta_title' => 'Meta Title', | ||
131 | + 'meta_description' => 'Meta Description', | ||
132 | + 'h1' => 'H1', | ||
133 | + 'seo_text' => 'Seo Text', | ||
134 | + ]; | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * @return \yii\db\ActiveQuery | ||
139 | + */ | ||
140 | + public function getBlogArticle() | ||
141 | + { | ||
142 | + return $this->hasOne(BlogArticle::className(), [ 'id' => 'blog_article_id' ]); | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * @return \yii\db\ActiveQuery | ||
147 | + */ | ||
148 | + public function getLanguage() | ||
149 | + { | ||
150 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
151 | + } | ||
152 | + } |
1 | +++ a/models/BlogArticleSearch.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
7 | + | ||
8 | + /** | ||
9 | + * BlogArticleSearch represents the model behind the search form about `artweb\artbox\blog\models\BlogArticle`. | ||
10 | + */ | ||
11 | + class BlogArticleSearch extends BlogArticle | ||
12 | + { | ||
13 | + /** | ||
14 | + * @var string | ||
15 | + */ | ||
16 | + public $title; | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public function rules() | ||
21 | + { | ||
22 | + return [ | ||
23 | + [ | ||
24 | + [ | ||
25 | + 'id', | ||
26 | + 'deleted_at', | ||
27 | + 'sort', | ||
28 | + 'author_id', | ||
29 | + ], | ||
30 | + 'integer', | ||
31 | + ], | ||
32 | + [ | ||
33 | + [ 'image' ], | ||
34 | + 'safe', | ||
35 | + ], | ||
36 | + [ | ||
37 | + [ 'status' ], | ||
38 | + 'boolean', | ||
39 | + ], | ||
40 | + [ | ||
41 | + [ 'title' ], | ||
42 | + 'string', | ||
43 | + ], | ||
44 | + ]; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * @inheritdoc | ||
49 | + */ | ||
50 | + public function behaviors() | ||
51 | + { | ||
52 | + return []; | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * @inheritdoc | ||
57 | + */ | ||
58 | + public function scenarios() | ||
59 | + { | ||
60 | + // bypass scenarios() implementation in the parent class | ||
61 | + return Model::scenarios(); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Creates data provider instance with search query applied | ||
66 | + * | ||
67 | + * @param array $params | ||
68 | + * | ||
69 | + * @return ActiveDataProvider | ||
70 | + */ | ||
71 | + public function search($params) | ||
72 | + { | ||
73 | + $query = BlogArticle::find() | ||
74 | + ->joinWith('lang'); | ||
75 | + | ||
76 | + // add conditions that should always apply here | ||
77 | + | ||
78 | + $dataProvider = new ActiveDataProvider( | ||
79 | + [ | ||
80 | + 'query' => $query, | ||
81 | + 'sort' => [ | ||
82 | + 'attributes' => [ | ||
83 | + 'id', | ||
84 | + 'created_at', | ||
85 | + 'updated_at', | ||
86 | + 'title' => [ | ||
87 | + 'asc' => [ 'blog_article_lang.title' => SORT_ASC ], | ||
88 | + 'desc' => [ 'blog_article_lang.title' => SORT_DESC ], | ||
89 | + ], | ||
90 | + ], | ||
91 | + ], | ||
92 | + ] | ||
93 | + ); | ||
94 | + | ||
95 | + $this->load($params); | ||
96 | + | ||
97 | + if (!$this->validate()) { | ||
98 | + // uncomment the following line if you do not want to return any records when validation fails | ||
99 | + // $query->where('0=1'); | ||
100 | + return $dataProvider; | ||
101 | + } | ||
102 | + | ||
103 | + // grid filtering conditions | ||
104 | + $query->andFilterWhere( | ||
105 | + [ | ||
106 | + 'id' => $this->id, | ||
107 | + 'status' => $this->status, | ||
108 | + 'author_id' => $this->author_id, | ||
109 | + ] | ||
110 | + ); | ||
111 | + | ||
112 | + $query->andFilterWhere( | ||
113 | + [ | ||
114 | + 'like', | ||
115 | + 'image', | ||
116 | + $this->image, | ||
117 | + ] | ||
118 | + ); | ||
119 | + | ||
120 | + $query->andFilterWhere( | ||
121 | + [ | ||
122 | + 'like', | ||
123 | + 'blog_article_lang.title', | ||
124 | + $this->title, | ||
125 | + ] | ||
126 | + ); | ||
127 | + | ||
128 | + return $dataProvider; | ||
129 | + } | ||
130 | + } |
1 | +++ a/models/BlogCategory.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\db\ActiveRecord; | ||
6 | + use artweb\artbox\language\behaviors\LanguageBehavior; | ||
7 | + use artweb\artbox\behaviors\SaveImgBehavior; | ||
8 | + use artweb\artbox\language\models\Language; | ||
9 | + use yii\db\ActiveQuery; | ||
10 | + use yii\web\Request; | ||
11 | + | ||
12 | + /** | ||
13 | + * This is the model class for table "blog_category". | ||
14 | + * | ||
15 | + * @property integer $id | ||
16 | + * @property integer $sort | ||
17 | + * @property string $image | ||
18 | + * @property integer $parent_id | ||
19 | + * @property boolean $status | ||
20 | + * @property BlogArticle[] $blogArticles | ||
21 | + * @property BlogCategoryLang[] $blogCategoryLangs | ||
22 | + * @property Language[] $languages | ||
23 | + * @property BlogCategory $parent | ||
24 | + * * From language behavior * | ||
25 | + * @property BlogCategoryLang $lang | ||
26 | + * @property BlogCategoryLang[] $langs | ||
27 | + * @property BlogCategoryLang $objectLang | ||
28 | + * @property string $ownerKey | ||
29 | + * @property string $langKey | ||
30 | + * @property BlogCategoryLang[] $modelLangs | ||
31 | + * @property bool $transactionStatus | ||
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 BlogCategoryLang[] generateLangs() | ||
39 | + * @method void loadLangs( Request $request ) | ||
40 | + * @method bool linkLangs() | ||
41 | + * @method bool saveLangs() | ||
42 | + * @method bool getTransactionStatus() | ||
43 | + * * End language behavior * | ||
44 | + * * From SaveImgBehavior * | ||
45 | + * @property string|null $imageFile | ||
46 | + * @property string|null $imageUrl | ||
47 | + * @method string|null getImageFile( int $field ) | ||
48 | + * @method string|null getImageUrl( int $field ) | ||
49 | + * * End SaveImgBehavior | ||
50 | + */ | ||
51 | + class BlogCategory extends ActiveRecord | ||
52 | + { | ||
53 | + /** | ||
54 | + * @inheritdoc | ||
55 | + */ | ||
56 | + public static function tableName() | ||
57 | + { | ||
58 | + return 'blog_category'; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * @inheritdoc | ||
63 | + */ | ||
64 | + public function behaviors() | ||
65 | + { | ||
66 | + return [ | ||
67 | + [ | ||
68 | + 'class' => SaveImgBehavior::className(), | ||
69 | + 'fields' => [ | ||
70 | + [ | ||
71 | + 'name' => 'image', | ||
72 | + 'directory' => 'blog/category', | ||
73 | + ], | ||
74 | + ], | ||
75 | + ], | ||
76 | + 'language' => [ | ||
77 | + 'class' => LanguageBehavior::className(), | ||
78 | + ], | ||
79 | + 'Slug' => [ | ||
80 | + 'class' => 'artweb\artbox\behaviors\Slug', | ||
81 | + ], | ||
82 | + ]; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * @inheritdoc | ||
87 | + */ | ||
88 | + public function rules() | ||
89 | + { | ||
90 | + return [ | ||
91 | + [ | ||
92 | + [ | ||
93 | + 'sort', | ||
94 | + 'parent_id', | ||
95 | + ], | ||
96 | + 'integer', | ||
97 | + ], | ||
98 | + [ | ||
99 | + [ 'status' ], | ||
100 | + 'boolean', | ||
101 | + ], | ||
102 | + [ | ||
103 | + [ 'image' ], | ||
104 | + 'string', | ||
105 | + 'max' => 255, | ||
106 | + ], | ||
107 | + [ | ||
108 | + [ 'parent_id' ], | ||
109 | + 'default', | ||
110 | + 'value' => 0, | ||
111 | + ], | ||
112 | + ]; | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * @inheritdoc | ||
117 | + */ | ||
118 | + public function attributeLabels() | ||
119 | + { | ||
120 | + return [ | ||
121 | + 'id' => 'ID', | ||
122 | + 'sort' => 'Sort', | ||
123 | + 'image' => 'Image', | ||
124 | + 'parent_id' => 'Parent ID', | ||
125 | + 'status' => 'Status', | ||
126 | + ]; | ||
127 | + } | ||
128 | + | ||
129 | + /** | ||
130 | + * @return \yii\db\ActiveQuery | ||
131 | + */ | ||
132 | + public function getBlogArticles() | ||
133 | + { | ||
134 | + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) | ||
135 | + ->viaTable('blog_article_to_category', [ 'blog_category_id' => 'id' ]); | ||
136 | + } | ||
137 | + | ||
138 | + public function getParent() | ||
139 | + { | ||
140 | + return $this->hasOne(BlogCategory::className(), [ 'id' => 'parent_id' ]); | ||
141 | + } | ||
142 | + } |
1 | +++ a/models/BlogCategoryLang.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\db\ActiveRecord; | ||
6 | + use artweb\artbox\language\models\Language; | ||
7 | + | ||
8 | + /** | ||
9 | + * This is the model class for table "blog_category_lang". | ||
10 | + * | ||
11 | + * @property integer $id | ||
12 | + * @property integer $blog_category_id | ||
13 | + * @property integer $language_id | ||
14 | + * @property string $title | ||
15 | + * @property string $alias | ||
16 | + * @property string $description | ||
17 | + * @property string $meta_title | ||
18 | + * @property string $meta_description | ||
19 | + * @property string $h1 | ||
20 | + * @property string $seo_text | ||
21 | + * @property BlogCategory $blogCategory | ||
22 | + * @property Language $language | ||
23 | + */ | ||
24 | + class BlogCategoryLang extends ActiveRecord | ||
25 | + { | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public static function tableName() | ||
30 | + { | ||
31 | + return 'blog_category_lang'; | ||
32 | + } | ||
33 | + | ||
34 | + public function behaviors() | ||
35 | + { | ||
36 | + return [ | ||
37 | + 'slug' => [ | ||
38 | + 'class' => 'artweb\artbox\behaviors\Slug', | ||
39 | + ], | ||
40 | + ]; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * @inheritdoc | ||
45 | + */ | ||
46 | + public function rules() | ||
47 | + { | ||
48 | + return [ | ||
49 | + [ | ||
50 | + [ | ||
51 | + 'blog_category_id', | ||
52 | + 'language_id', | ||
53 | + ], | ||
54 | + 'required', | ||
55 | + ], | ||
56 | + [ | ||
57 | + [ | ||
58 | + 'blog_category_id', | ||
59 | + 'language_id', | ||
60 | + ], | ||
61 | + 'integer', | ||
62 | + ], | ||
63 | + [ | ||
64 | + [ 'description' ], | ||
65 | + 'string', | ||
66 | + ], | ||
67 | + [ | ||
68 | + [ | ||
69 | + 'title', | ||
70 | + 'alias', | ||
71 | + 'meta_title', | ||
72 | + 'meta_description', | ||
73 | + 'h1', | ||
74 | + 'seo_text', | ||
75 | + ], | ||
76 | + 'string', | ||
77 | + 'max' => 255, | ||
78 | + ], | ||
79 | + [ | ||
80 | + [ 'alias' ], | ||
81 | + 'unique', | ||
82 | + ], | ||
83 | + [ | ||
84 | + [ | ||
85 | + 'blog_category_id', | ||
86 | + 'language_id', | ||
87 | + ], | ||
88 | + 'unique', | ||
89 | + 'targetAttribute' => [ | ||
90 | + 'blog_category_id', | ||
91 | + 'language_id', | ||
92 | + ], | ||
93 | + 'message' => 'The combination of Blog Category ID and Language ID has already been taken.', | ||
94 | + ], | ||
95 | + [ | ||
96 | + [ 'blog_category_id' ], | ||
97 | + 'exist', | ||
98 | + 'skipOnError' => true, | ||
99 | + 'targetClass' => BlogCategory::className(), | ||
100 | + 'targetAttribute' => [ 'blog_category_id' => 'id' ], | ||
101 | + ], | ||
102 | + [ | ||
103 | + [ 'language_id' ], | ||
104 | + 'exist', | ||
105 | + 'skipOnError' => true, | ||
106 | + 'targetClass' => Language::className(), | ||
107 | + 'targetAttribute' => [ 'language_id' => 'id' ], | ||
108 | + ], | ||
109 | + ]; | ||
110 | + } | ||
111 | + | ||
112 | + /** | ||
113 | + * @inheritdoc | ||
114 | + */ | ||
115 | + public function attributeLabels() | ||
116 | + { | ||
117 | + return [ | ||
118 | + 'id' => 'ID', | ||
119 | + 'blog_category_id' => 'Blog Category ID', | ||
120 | + 'language_id' => 'Language ID', | ||
121 | + 'title' => 'Title', | ||
122 | + 'alias' => 'Alias', | ||
123 | + 'description' => 'Description', | ||
124 | + 'meta_title' => 'Meta Title', | ||
125 | + 'meta_description' => 'Meta Description', | ||
126 | + 'h1' => 'H1', | ||
127 | + 'seo_text' => 'Seo Text', | ||
128 | + ]; | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * @return \yii\db\ActiveQuery | ||
133 | + */ | ||
134 | + public function getBlogCategory() | ||
135 | + { | ||
136 | + return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ]); | ||
137 | + } | ||
138 | + | ||
139 | + /** | ||
140 | + * @return \yii\db\ActiveQuery | ||
141 | + */ | ||
142 | + public function getLanguage() | ||
143 | + { | ||
144 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
145 | + } | ||
146 | + } |
1 | +++ a/models/BlogCategorySearch.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
7 | + | ||
8 | + /** | ||
9 | + * BlogCategorySearch represents the model behind the search form about `artweb\artbox\blog\models\BlogCategory`. | ||
10 | + */ | ||
11 | + class BlogCategorySearch extends BlogCategory | ||
12 | + { | ||
13 | + /** | ||
14 | + * @var string | ||
15 | + */ | ||
16 | + public $title; | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public function rules() | ||
21 | + { | ||
22 | + return [ | ||
23 | + [ | ||
24 | + [ | ||
25 | + 'id', | ||
26 | + 'sort', | ||
27 | + 'parent_id', | ||
28 | + ], | ||
29 | + 'integer', | ||
30 | + ], | ||
31 | + [ | ||
32 | + [ 'image' ], | ||
33 | + 'safe', | ||
34 | + ], | ||
35 | + [ | ||
36 | + [ 'status' ], | ||
37 | + 'boolean', | ||
38 | + ], | ||
39 | + [ | ||
40 | + [ 'title' ], | ||
41 | + 'string', | ||
42 | + ], | ||
43 | + ]; | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * @inheritdoc | ||
48 | + */ | ||
49 | + public function behaviors() | ||
50 | + { | ||
51 | + return []; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * @inheritdoc | ||
56 | + */ | ||
57 | + public function scenarios() | ||
58 | + { | ||
59 | + // bypass scenarios() implementation in the parent class | ||
60 | + return Model::scenarios(); | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Creates data provider instance with search query applied | ||
65 | + * | ||
66 | + * @param array $params | ||
67 | + * | ||
68 | + * @return ActiveDataProvider | ||
69 | + */ | ||
70 | + public function search($params) | ||
71 | + { | ||
72 | + $query = BlogCategory::find() | ||
73 | + ->joinWith('lang', 'parent.lang'); | ||
74 | + | ||
75 | + // add conditions that should always apply here | ||
76 | + | ||
77 | + $dataProvider = new ActiveDataProvider( | ||
78 | + [ | ||
79 | + 'query' => $query, | ||
80 | + 'sort' => [ | ||
81 | + 'attributes' => [ | ||
82 | + 'title' => [ | ||
83 | + 'asc' => [ 'blog_category_lang.title' => SORT_ASC ], | ||
84 | + 'desc' => [ 'blog_category_lang.title' => SORT_DESC ], | ||
85 | + ], | ||
86 | + 'id', | ||
87 | + ], | ||
88 | + ], | ||
89 | + ] | ||
90 | + ); | ||
91 | + | ||
92 | + $this->load($params); | ||
93 | + | ||
94 | + if (!$this->validate()) { | ||
95 | + // uncomment the following line if you do not want to return any records when validation fails | ||
96 | + // $query->where('0=1'); | ||
97 | + return $dataProvider; | ||
98 | + } | ||
99 | + | ||
100 | + // grid filtering conditions | ||
101 | + $query->andFilterWhere( | ||
102 | + [ | ||
103 | + 'id' => $this->id, | ||
104 | + 'sort' => $this->sort, | ||
105 | + 'parent_id' => $this->parent_id, | ||
106 | + 'status' => $this->status, | ||
107 | + ] | ||
108 | + ); | ||
109 | + | ||
110 | + $query->andFilterWhere( | ||
111 | + [ | ||
112 | + 'like', | ||
113 | + 'image', | ||
114 | + $this->image, | ||
115 | + ] | ||
116 | + ); | ||
117 | + | ||
118 | + $query->andFilterWhere( | ||
119 | + [ | ||
120 | + 'like', | ||
121 | + 'blog_category_lang.title', | ||
122 | + $this->title, | ||
123 | + ] | ||
124 | + ); | ||
125 | + | ||
126 | + return $dataProvider; | ||
127 | + } | ||
128 | + } |
1 | +++ a/models/BlogTag.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\db\ActiveRecord; | ||
6 | + use artweb\artbox\language\behaviors\LanguageBehavior; | ||
7 | + use artweb\artbox\language\models\Language; | ||
8 | + use yii\db\ActiveQuery; | ||
9 | + use yii\web\Request; | ||
10 | + | ||
11 | + /** | ||
12 | + * This is the model class for table "blog_tag". | ||
13 | + * | ||
14 | + * @property integer $id | ||
15 | + * @property BlogArticle[] $blogArticles | ||
16 | + * @property BlogTagLang[] $blogTagLangs | ||
17 | + * @property Language[] $languages | ||
18 | + * * From language behavior * | ||
19 | + * @property BlogTagLang $lang | ||
20 | + * @property BlogTagLang[] $langs | ||
21 | + * @property BlogTagLang $objectLang | ||
22 | + * @property string $ownerKey | ||
23 | + * @property string $langKey | ||
24 | + * @property BlogTagLang[] $modelLangs | ||
25 | + * @property bool $transactionStatus | ||
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 BlogTagLang[] generateLangs() | ||
33 | + * @method void loadLangs( Request $request ) | ||
34 | + * @method bool linkLangs() | ||
35 | + * @method bool saveLangs() | ||
36 | + * @method bool getTransactionStatus() | ||
37 | + * * End language behavior * | ||
38 | + */ | ||
39 | + class BlogTag extends ActiveRecord | ||
40 | + { | ||
41 | + /** | ||
42 | + * @inheritdoc | ||
43 | + */ | ||
44 | + public static function tableName() | ||
45 | + { | ||
46 | + return 'blog_tag'; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * @inheritdoc | ||
51 | + */ | ||
52 | + public function behaviors() | ||
53 | + { | ||
54 | + return [ | ||
55 | + 'language' => [ | ||
56 | + 'class' => LanguageBehavior::className(), | ||
57 | + ], | ||
58 | + ]; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * @inheritdoc | ||
63 | + */ | ||
64 | + public function rules() | ||
65 | + { | ||
66 | + return [ | ||
67 | + [ | ||
68 | + [ 'id' ], | ||
69 | + 'integer', | ||
70 | + ], | ||
71 | + ]; | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * @inheritdoc | ||
76 | + */ | ||
77 | + public function attributeLabels() | ||
78 | + { | ||
79 | + return [ | ||
80 | + 'id' => 'ID', | ||
81 | + ]; | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * @return \yii\db\ActiveQuery | ||
86 | + */ | ||
87 | + public function getBlogArticles() | ||
88 | + { | ||
89 | + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) | ||
90 | + ->viaTable('blog_article_to_tag', [ 'blog_tag_id' => 'id' ]); | ||
91 | + } | ||
92 | + } |
1 | +++ a/models/BlogTagLang.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use artweb\artbox\language\models\Language; | ||
6 | + use yii\db\ActiveRecord; | ||
7 | + | ||
8 | + /** | ||
9 | + * This is the model class for table "blog_tag_lang". | ||
10 | + * | ||
11 | + * @property integer $id | ||
12 | + * @property integer $blog_tag_id | ||
13 | + * @property integer $language_id | ||
14 | + * @property string $label | ||
15 | + * @property BlogTag $blogTag | ||
16 | + * @property Language $language | ||
17 | + */ | ||
18 | + class BlogTagLang extends ActiveRecord | ||
19 | + { | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + */ | ||
23 | + public static function tableName() | ||
24 | + { | ||
25 | + return 'blog_tag_lang'; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public function rules() | ||
32 | + { | ||
33 | + return [ | ||
34 | + [ | ||
35 | + [ | ||
36 | + 'blog_tag_id', | ||
37 | + 'language_id', | ||
38 | + ], | ||
39 | + 'required', | ||
40 | + ], | ||
41 | + [ | ||
42 | + [ | ||
43 | + 'blog_tag_id', | ||
44 | + 'language_id', | ||
45 | + ], | ||
46 | + 'integer', | ||
47 | + ], | ||
48 | + [ | ||
49 | + [ 'label' ], | ||
50 | + 'string', | ||
51 | + 'max' => 255, | ||
52 | + ], | ||
53 | + [ | ||
54 | + [ | ||
55 | + 'blog_tag_id', | ||
56 | + 'language_id', | ||
57 | + ], | ||
58 | + 'unique', | ||
59 | + 'targetAttribute' => [ | ||
60 | + 'blog_tag_id', | ||
61 | + 'language_id', | ||
62 | + ], | ||
63 | + 'message' => 'The combination of Blog Tag ID and Language ID has already been taken.', | ||
64 | + ], | ||
65 | + [ | ||
66 | + [ 'blog_tag_id' ], | ||
67 | + 'exist', | ||
68 | + 'skipOnError' => true, | ||
69 | + 'targetClass' => BlogTag::className(), | ||
70 | + 'targetAttribute' => [ 'blog_tag_id' => 'id' ], | ||
71 | + ], | ||
72 | + [ | ||
73 | + [ 'language_id' ], | ||
74 | + 'exist', | ||
75 | + 'skipOnError' => true, | ||
76 | + 'targetClass' => Language::className(), | ||
77 | + 'targetAttribute' => [ 'language_id' => 'id' ], | ||
78 | + ], | ||
79 | + ]; | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * @inheritdoc | ||
84 | + */ | ||
85 | + public function attributeLabels() | ||
86 | + { | ||
87 | + return [ | ||
88 | + 'id' => 'ID', | ||
89 | + 'blog_tag_id' => 'Blog Tag ID', | ||
90 | + 'language_id' => 'Language ID', | ||
91 | + 'label' => 'Label', | ||
92 | + ]; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * @return \yii\db\ActiveQuery | ||
97 | + */ | ||
98 | + public function getBlogTag() | ||
99 | + { | ||
100 | + return $this->hasOne(BlogTag::className(), [ 'id' => 'blog_tag_id' ]); | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * @return \yii\db\ActiveQuery | ||
105 | + */ | ||
106 | + public function getLanguage() | ||
107 | + { | ||
108 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
109 | + } | ||
110 | + } |
1 | +++ a/models/BlogTagSearch.php | ||
1 | +<?php | ||
2 | + | ||
3 | + namespace artweb\artbox\blog\models; | ||
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
7 | + | ||
8 | + /** | ||
9 | + * BlogTagSearch represents the model behind the search form about `artweb\artbox\blog\models\BlogTag`. | ||
10 | + */ | ||
11 | + class BlogTagSearch extends BlogTag | ||
12 | + { | ||
13 | + /** | ||
14 | + * @var string | ||
15 | + */ | ||
16 | + public $label; | ||
17 | + | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public function rules() | ||
22 | + { | ||
23 | + return [ | ||
24 | + [ | ||
25 | + [ 'id' ], | ||
26 | + 'integer', | ||
27 | + ], | ||
28 | + [ | ||
29 | + [ 'label' ], | ||
30 | + 'string', | ||
31 | + ], | ||
32 | + ]; | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * @inheritdoc | ||
37 | + */ | ||
38 | + public function behaviors() | ||
39 | + { | ||
40 | + return []; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * @inheritdoc | ||
45 | + */ | ||
46 | + public function scenarios() | ||
47 | + { | ||
48 | + // bypass scenarios() implementation in the parent class | ||
49 | + return Model::scenarios(); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Creates data provider instance with search query applied | ||
54 | + * | ||
55 | + * @param array $params | ||
56 | + * | ||
57 | + * @return ActiveDataProvider | ||
58 | + */ | ||
59 | + public function search($params) | ||
60 | + { | ||
61 | + $query = BlogTag::find() | ||
62 | + ->joinWith('lang'); | ||
63 | + | ||
64 | + // add conditions that should always apply here | ||
65 | + | ||
66 | + $dataProvider = new ActiveDataProvider( | ||
67 | + [ | ||
68 | + 'query' => $query, | ||
69 | + 'sort' => [ | ||
70 | + 'attributes' => [ | ||
71 | + 'id', | ||
72 | + 'label' => [ | ||
73 | + 'asc' => [ 'blog_tag_lang.label' => SORT_ASC ], | ||
74 | + 'desc' => [ 'blog_tag_lang.label' => SORT_DESC ], | ||
75 | + ], | ||
76 | + ], | ||
77 | + ], | ||
78 | + ] | ||
79 | + ); | ||
80 | + | ||
81 | + $this->load($params); | ||
82 | + | ||
83 | + if (!$this->validate()) { | ||
84 | + // uncomment the following line if you do not want to return any records when validation fails | ||
85 | + // $query->where('0=1'); | ||
86 | + return $dataProvider; | ||
87 | + } | ||
88 | + | ||
89 | + // grid filtering conditions | ||
90 | + $query->andFilterWhere( | ||
91 | + [ | ||
92 | + 'id' => $this->id, | ||
93 | + ] | ||
94 | + ); | ||
95 | + | ||
96 | + $query->andFilterWhere( | ||
97 | + [ | ||
98 | + 'like', | ||
99 | + 'blog_tag_lang.label', | ||
100 | + $this->label, | ||
101 | + ] | ||
102 | + ); | ||
103 | + | ||
104 | + return $dataProvider; | ||
105 | + } | ||
106 | + } |
1 | +++ a/views/blog-article/_form.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticle; | ||
4 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
5 | + use artweb\artbox\blog\models\BlogCategory; | ||
6 | + use artweb\artbox\blog\models\BlogTag; | ||
7 | + use kartik\select2\Select2; | ||
8 | + use yii\helpers\Html; | ||
9 | + use yii\helpers\Url; | ||
10 | + use yii\web\View; | ||
11 | + use yii\widgets\ActiveForm; | ||
12 | + use artweb\artbox\language\widgets\LanguageForm; | ||
13 | + use yii\web\JsExpression; | ||
14 | + | ||
15 | + /** | ||
16 | + * @var View $this | ||
17 | + * @var BlogArticle $model | ||
18 | + * @var ActiveForm $form | ||
19 | + * @var BlogArticleLang[] $modelLangs | ||
20 | + * @var BlogCategory[] $categories | ||
21 | + * @var BlogTag[] $tags | ||
22 | + * @var array $products | ||
23 | + * @var array $articles | ||
24 | + */ | ||
25 | +?> | ||
26 | + | ||
27 | +<div class="blog-article-form"> | ||
28 | + | ||
29 | + <?php $form = ActiveForm::begin( | ||
30 | + [ | ||
31 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | ||
32 | + ] | ||
33 | + ); ?> | ||
34 | + | ||
35 | + <?php | ||
36 | + echo LanguageForm::widget( | ||
37 | + [ | ||
38 | + 'modelLangs' => $modelLangs, | ||
39 | + 'formView' => '@artweb/artbox/blog/views/blog-article/_form_language', | ||
40 | + 'form' => $form, | ||
41 | + ] | ||
42 | + ); | ||
43 | + ?> | ||
44 | + | ||
45 | + <?php | ||
46 | + echo $form->field($model, 'blogCategories') | ||
47 | + ->widget( | ||
48 | + Select2::className(), | ||
49 | + [ | ||
50 | + 'data' => $categories, | ||
51 | + 'theme' => Select2::THEME_BOOTSTRAP, | ||
52 | + 'options' => [ | ||
53 | + 'placeholder' => \Yii::t('blog', 'Select category'), | ||
54 | + 'multiple' => true, | ||
55 | + ], | ||
56 | + 'pluginOptions' => [ | ||
57 | + 'allowClear' => true, | ||
58 | + ], | ||
59 | + ] | ||
60 | + ); | ||
61 | + ?> | ||
62 | + | ||
63 | + <?php | ||
64 | + echo $form->field($model, 'blogTags') | ||
65 | + ->widget( | ||
66 | + Select2::className(), | ||
67 | + [ | ||
68 | + 'data' => $tags, | ||
69 | + 'theme' => Select2::THEME_BOOTSTRAP, | ||
70 | + 'options' => [ | ||
71 | + 'placeholder' => \Yii::t('blog', 'Select tag'), | ||
72 | + 'multiple' => true, | ||
73 | + ], | ||
74 | + 'pluginOptions' => [ | ||
75 | + 'allowClear' => true, | ||
76 | + ], | ||
77 | + ] | ||
78 | + ); | ||
79 | + ?> | ||
80 | + | ||
81 | + <?= $form->field($model, 'image') | ||
82 | + ->widget( | ||
83 | + \kartik\file\FileInput::className(), | ||
84 | + [ | ||
85 | + 'language' => 'ru', | ||
86 | + 'options' => [ | ||
87 | + 'accept' => 'image/*', | ||
88 | + 'multiple' => false, | ||
89 | + 'deleteurl' => $model->isNewRecord?false:Url::to(['/blog/blog-article/delete-image', 'id' => $model->id]), | ||
90 | + 'class' => $model->isNewRecord?'':'artbox-delete-file', | ||
91 | + ], | ||
92 | + 'pluginOptions' => [ | ||
93 | + 'allowedFileExtensions' => [ | ||
94 | + 'jpg', | ||
95 | + 'gif', | ||
96 | + 'png', | ||
97 | + ], | ||
98 | + 'initialPreview' => !empty( $model->getImageUrl(0, false) ) ? \artweb\artbox\components\artboximage\ArtboxImageHelper::getImage( | ||
99 | + $model->imageUrl, | ||
100 | + 'list' | ||
101 | + ) : '', | ||
102 | + 'initialPreviewShowDelete' => false, | ||
103 | + 'overwriteInitial' => true, | ||
104 | + 'showRemove' => true, | ||
105 | + 'showUpload' => false, | ||
106 | + 'showClose' => false, | ||
107 | + 'previewFileType' => 'image', | ||
108 | + ], | ||
109 | + ] | ||
110 | + ); ?> | ||
111 | + | ||
112 | + <?php | ||
113 | + echo $form->field($model, 'products') | ||
114 | + ->widget( | ||
115 | + Select2::className(), | ||
116 | + [ | ||
117 | + 'data' => $products, | ||
118 | + 'options' => [ | ||
119 | + 'placeholder' => \Yii::t('blog', 'Select related products'), | ||
120 | + 'multiple' => true, | ||
121 | + ], | ||
122 | + 'pluginOptions' => [ | ||
123 | + 'allowClear' => true, | ||
124 | + 'minimumInputLength' => 3, | ||
125 | + 'language' => [ | ||
126 | + 'errorLoading' => new JsExpression( | ||
127 | + "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }" | ||
128 | + ), | ||
129 | + ], | ||
130 | + 'ajax' => [ | ||
131 | + 'url' => yii\helpers\Url::to([ '/blog/blog-article/product-list' ]), | ||
132 | + 'dataType' => 'json', | ||
133 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | ||
134 | + ], | ||
135 | + 'templateResult' => new JsExpression('function(product) { return product.text; }'), | ||
136 | + 'templateSelection' => new JsExpression('function (product) { return product.text; }'), | ||
137 | + ], | ||
138 | + ] | ||
139 | + ); | ||
140 | + ?> | ||
141 | + | ||
142 | + <?php | ||
143 | + if (empty( $model->id )) { | ||
144 | + $data = 'function(params) { return {q:params.term}; }'; | ||
145 | + } else { | ||
146 | + $data = 'function(params) { return {q:params.term, id:' . $model->id . '}; }'; | ||
147 | + } | ||
148 | + echo $form->field($model, 'blogArticles') | ||
149 | + ->widget( | ||
150 | + Select2::className(), | ||
151 | + [ | ||
152 | + 'data' => $articles, | ||
153 | + 'options' => [ | ||
154 | + 'placeholder' => \Yii::t('blog', 'Select related articles'), | ||
155 | + 'multiple' => true, | ||
156 | + ], | ||
157 | + 'pluginOptions' => [ | ||
158 | + 'allowClear' => true, | ||
159 | + 'minimumInputLength' => 3, | ||
160 | + 'language' => [ | ||
161 | + 'errorLoading' => new JsExpression( | ||
162 | + "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }" | ||
163 | + ), | ||
164 | + ], | ||
165 | + 'ajax' => [ | ||
166 | + 'url' => yii\helpers\Url::to([ '/blog/blog-article/article-list' ]), | ||
167 | + 'dataType' => 'json', | ||
168 | + 'data' => new JsExpression( | ||
169 | + $data | ||
170 | + ), | ||
171 | + ], | ||
172 | + 'templateResult' => new JsExpression('function(article) { return article.text; }'), | ||
173 | + 'templateSelection' => new JsExpression('function (article) { return article.text; }'), | ||
174 | + ], | ||
175 | + ] | ||
176 | + ); | ||
177 | + ?> | ||
178 | + | ||
179 | + <?= $form->field($model, 'sort') | ||
180 | + ->textInput() ?> | ||
181 | + | ||
182 | + <?= $form->field($model, 'status') | ||
183 | + ->checkbox() ?> | ||
184 | + | ||
185 | + <?= $form->field($model, 'author_id') | ||
186 | + ->textInput() ?> | ||
187 | + | ||
188 | + <div class="form-group"> | ||
189 | + <?= Html::submitButton( | ||
190 | + $model->isNewRecord ? 'Create' : 'Update', | ||
191 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
192 | + ) ?> | ||
193 | + </div> | ||
194 | + | ||
195 | + <?php ActiveForm::end(); ?> | ||
196 | + | ||
197 | +</div> |
1 | +++ a/views/blog-article/_form_language.php | ||
1 | +<?php | ||
2 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
3 | + use artweb\artbox\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 BlogArticleLang $model_lang | ||
11 | + * @var Language $language | ||
12 | + * @var ActiveForm $form | ||
13 | + * @var View $this | ||
14 | + */ | ||
15 | +?> | ||
16 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
17 | + ->textInput([ 'maxlength' => true ]); ?> | ||
18 | + | ||
19 | +<?= $form->field($model_lang, '[' . $language->id . ']alias') | ||
20 | + ->textInput([ 'maxlength' => true ]); ?> | ||
21 | + | ||
22 | +<?= $form->field($model_lang, '[' . $language->id . ']body') | ||
23 | + ->widget( | ||
24 | + CKEditor::className(), | ||
25 | + [ | ||
26 | + 'editorOptions' => ElFinder::ckeditorOptions( | ||
27 | + 'elfinder', | ||
28 | + [ | ||
29 | + 'preset' => 'full', | ||
30 | + 'inline' => false, | ||
31 | + 'filebrowserUploadUrl' => Yii::$app->getUrlManager() | ||
32 | + ->createUrl('file/uploader/images-upload'), | ||
33 | + ] | ||
34 | + ), | ||
35 | + ] | ||
36 | + ) ?> | ||
37 | + | ||
38 | +<?= $form->field($model_lang, '[' . $language->id . ']body_preview') | ||
39 | + ->textarea( | ||
40 | + [ | ||
41 | + 'rows' => '10', | ||
42 | + ] | ||
43 | + ) ?> | ||
44 | + | ||
45 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_title') | ||
46 | + ->textInput([ 'maxlength' => true ]); ?> | ||
47 | + | ||
48 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_description') | ||
49 | + ->textInput([ 'maxlength' => true ]); ?> | ||
50 | + | ||
51 | +<?= $form->field($model_lang, '[' . $language->id . ']seo_text') | ||
52 | + ->textInput([ 'maxlength' => true ]); ?> | ||
53 | + | ||
54 | +<?= $form->field($model_lang, '[' . $language->id . ']h1') | ||
55 | + ->textInput([ 'maxlength' => true ]); ?> |
1 | +++ a/views/blog-article/_search.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use yii\helpers\Html; | ||
4 | + use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | + /* @var $this yii\web\View */ | ||
7 | + /* @var $model artweb\artbox\blog\models\BlogArticleSearch */ | ||
8 | + /* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="blog-article-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin( | ||
14 | + [ | ||
15 | + 'action' => [ 'index' ], | ||
16 | + 'method' => 'get', | ||
17 | + ] | ||
18 | + ); ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'id') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'image') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'created_at') ?> | ||
25 | + | ||
26 | + <?= $form->field($model, 'updated_at') ?> | ||
27 | + | ||
28 | + <?= $form->field($model, 'deleted_at') ?> | ||
29 | + | ||
30 | + <?php // echo $form->field($model, 'sort') ?> | ||
31 | + | ||
32 | + <?php // echo $form->field($model, 'status')->checkbox() ?> | ||
33 | + | ||
34 | + <?php // echo $form->field($model, 'author_id') ?> | ||
35 | + | ||
36 | + <div class="form-group"> | ||
37 | + <?= Html::submitButton('Search', [ 'class' => 'btn btn-primary' ]) ?> | ||
38 | + <?= Html::resetButton('Reset', [ 'class' => 'btn btn-default' ]) ?> | ||
39 | + </div> | ||
40 | + | ||
41 | + <?php ActiveForm::end(); ?> | ||
42 | + | ||
43 | +</div> |
1 | +++ a/views/blog-article/create.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticle; | ||
4 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
5 | + use artweb\artbox\blog\models\BlogCategory; | ||
6 | + use artweb\artbox\blog\models\BlogTag; | ||
7 | + use yii\helpers\Html; | ||
8 | + use yii\web\View; | ||
9 | + | ||
10 | + /** | ||
11 | + * @var View $this | ||
12 | + * @var BlogArticle $model | ||
13 | + * @var BlogArticleLang[] $modelLangs | ||
14 | + * @var BlogCategory[] $categories | ||
15 | + * @var BlogTag[] $tags | ||
16 | + * @var array $products | ||
17 | + * @var array $articles | ||
18 | + */ | ||
19 | + | ||
20 | + $this->title = \Yii::t('blog', 'Create Blog Article'); | ||
21 | + $this->params[ 'breadcrumbs' ][] = [ | ||
22 | + 'label' => \Yii::t('blog', 'Blog Articles'), | ||
23 | + 'url' => [ 'index' ], | ||
24 | + ]; | ||
25 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
26 | +?> | ||
27 | +<div class="blog-article-create"> | ||
28 | + | ||
29 | + <h1><?= Html::encode($this->title) ?></h1> | ||
30 | + | ||
31 | + <?= $this->render( | ||
32 | + '_form', | ||
33 | + [ | ||
34 | + 'model' => $model, | ||
35 | + 'modelLangs' => $modelLangs, | ||
36 | + 'categories' => $categories, | ||
37 | + 'tags' => $tags, | ||
38 | + 'products' => $products, | ||
39 | + 'articles' => $articles, | ||
40 | + ] | ||
41 | + ) ?> | ||
42 | + | ||
43 | +</div> |
1 | +++ a/views/blog-article/index.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticle; | ||
4 | + use artweb\artbox\blog\models\BlogArticleSearch; | ||
5 | + use yii\data\ActiveDataProvider; | ||
6 | + use yii\helpers\Html; | ||
7 | + use yii\grid\GridView; | ||
8 | + use yii\web\View; | ||
9 | + | ||
10 | + /** | ||
11 | + * @var View $this | ||
12 | + * @var BlogArticleSearch $searchModel | ||
13 | + * @var ActiveDataProvider $dataProvider | ||
14 | + */ | ||
15 | + | ||
16 | + $this->title = \Yii::t('blog', 'Blog Articles'); | ||
17 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
18 | +?> | ||
19 | +<div class="blog-article-index"> | ||
20 | + | ||
21 | + <h1><?= Html::encode($this->title) ?></h1> | ||
22 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a(\Yii::t('app', 'create_item',['item'=>'Blog Article']), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
26 | + </p> | ||
27 | + <?= GridView::widget( | ||
28 | + [ | ||
29 | + 'dataProvider' => $dataProvider, | ||
30 | + 'filterModel' => $searchModel, | ||
31 | + 'columns' => [ | ||
32 | + 'id', | ||
33 | + [ | ||
34 | + 'attribute' => 'title', | ||
35 | + 'value' => 'lang.title', | ||
36 | + ], | ||
37 | + 'imageUrl:image', | ||
38 | + [ | ||
39 | + 'attribute' => 'status', | ||
40 | + 'value' => function($model) { | ||
41 | + /** | ||
42 | + * @var BlogArticle $model | ||
43 | + */ | ||
44 | + return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'); | ||
45 | + }, | ||
46 | + 'filter' => [ | ||
47 | + 0 => \Yii::t('blog', 'Not active'), | ||
48 | + 1 => \Yii::t('blog', 'Active'), | ||
49 | + ], | ||
50 | + ], | ||
51 | + 'created_at:date', | ||
52 | + 'updated_at:date', | ||
53 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
54 | + ], | ||
55 | + ] | ||
56 | + ); ?> | ||
57 | +</div> |
1 | +++ a/views/blog-article/update.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticle; | ||
4 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
5 | + use artweb\artbox\blog\models\BlogCategory; | ||
6 | + use artweb\artbox\blog\models\BlogTag; | ||
7 | + use yii\helpers\Html; | ||
8 | + use yii\web\View; | ||
9 | + | ||
10 | + /** | ||
11 | + * @var View $this | ||
12 | + * @var BlogArticle $model | ||
13 | + * @var BlogArticleLang[] $modelLangs | ||
14 | + * @var BlogCategory[] $categories | ||
15 | + * @var BlogTag[] $tags | ||
16 | + * @var array $products | ||
17 | + * @var array $articles | ||
18 | + */ | ||
19 | + | ||
20 | + $this->title = \Yii::t('blog', 'Update Blog Article: ') . $model->lang->title; | ||
21 | + $this->params[ 'breadcrumbs' ][] = [ | ||
22 | + 'label' => \Yii::t('blog', 'Blog Articles'), | ||
23 | + 'url' => [ 'index' ], | ||
24 | + ]; | ||
25 | + $this->params[ 'breadcrumbs' ][] = [ | ||
26 | + 'label' => $model->lang->title, | ||
27 | + 'url' => [ | ||
28 | + 'view', | ||
29 | + 'id' => $model->id, | ||
30 | + ], | ||
31 | + ]; | ||
32 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); | ||
33 | +?> | ||
34 | +<div class="blog-article-update"> | ||
35 | + | ||
36 | + <h1><?= Html::encode($this->title) ?></h1> | ||
37 | + | ||
38 | + <?= $this->render( | ||
39 | + '_form', | ||
40 | + [ | ||
41 | + 'model' => $model, | ||
42 | + 'modelLangs' => $modelLangs, | ||
43 | + 'categories' => $categories, | ||
44 | + 'tags' => $tags, | ||
45 | + 'products' => $products, | ||
46 | + 'articles' => $articles, | ||
47 | + ] | ||
48 | + ) ?> | ||
49 | + | ||
50 | +</div> |
1 | +++ a/views/blog-article/view.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticle; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\web\View; | ||
6 | + use yii\widgets\DetailView; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogArticle $model | ||
11 | + */ | ||
12 | + | ||
13 | + $this->title = $model->lang->title; | ||
14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
15 | + 'label' => \Yii::t('blog', 'Blog Articles'), | ||
16 | + 'url' => [ 'index' ], | ||
17 | + ]; | ||
18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
19 | +?> | ||
20 | +<div class="blog-article-view"> | ||
21 | + | ||
22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a( | ||
26 | + 'Update', | ||
27 | + [ | ||
28 | + 'update', | ||
29 | + 'id' => $model->id, | ||
30 | + ], | ||
31 | + [ 'class' => 'btn btn-primary' ] | ||
32 | + ) ?> | ||
33 | + <?= Html::a( | ||
34 | + 'Delete', | ||
35 | + [ | ||
36 | + 'delete', | ||
37 | + 'id' => $model->id, | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'class' => 'btn btn-danger', | ||
41 | + 'data' => [ | ||
42 | + 'confirm' => 'Are you sure you want to delete this item?', | ||
43 | + 'method' => 'post', | ||
44 | + ], | ||
45 | + ] | ||
46 | + ) ?> | ||
47 | + </p> | ||
48 | + | ||
49 | + <?= DetailView::widget( | ||
50 | + [ | ||
51 | + 'model' => $model, | ||
52 | + 'attributes' => [ | ||
53 | + 'id', | ||
54 | + 'imageUrl:image', | ||
55 | + 'created_at:date', | ||
56 | + 'updated_at:date', | ||
57 | + [ | ||
58 | + 'attribute' => 'status', | ||
59 | + 'value' => ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'), | ||
60 | + ], | ||
61 | + 'lang.alias', | ||
62 | + 'lang.body:html', | ||
63 | + ], | ||
64 | + ] | ||
65 | + ) ?> | ||
66 | + | ||
67 | +</div> |
1 | +++ a/views/blog-category/_form.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogCategory; | ||
4 | + use artweb\artbox\blog\models\BlogCategoryLang; | ||
5 | + use kartik\select2\Select2; | ||
6 | + use yii\helpers\Html; | ||
7 | + use yii\helpers\Url; | ||
8 | + use yii\web\View; | ||
9 | + use yii\widgets\ActiveForm; | ||
10 | + use artweb\artbox\language\widgets\LanguageForm; | ||
11 | + | ||
12 | + /** | ||
13 | + * @var View $this | ||
14 | + * @var BlogCategory $model | ||
15 | + * @var ActiveForm $form | ||
16 | + * @var BlogCategoryLang[] $modelLangs | ||
17 | + * @var array $parentCategories | ||
18 | + */ | ||
19 | +?> | ||
20 | + | ||
21 | +<div class="blog-category-form"> | ||
22 | + | ||
23 | + <?php $form = ActiveForm::begin( | ||
24 | + [ | ||
25 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | ||
26 | + | ||
27 | + ] | ||
28 | + ); ?> | ||
29 | + | ||
30 | + <?php | ||
31 | + echo LanguageForm::widget( | ||
32 | + [ | ||
33 | + 'modelLangs' => $modelLangs, | ||
34 | + 'formView' => '@artweb/artbox/blog/views/blog-category/_form_language', | ||
35 | + 'form' => $form, | ||
36 | + ] | ||
37 | + ); | ||
38 | + ?> | ||
39 | + | ||
40 | + <?= $form->field($model, 'image') | ||
41 | + ->widget( | ||
42 | + \kartik\file\FileInput::className(), | ||
43 | + [ | ||
44 | + 'language' => 'ru', | ||
45 | + 'options' => [ | ||
46 | + 'accept' => 'image/*', | ||
47 | + 'multiple' => false, | ||
48 | + 'deleteurl' => $model->isNewRecord?false:Url::to(['/blog/blog-category/delete-image', 'id' => $model->id]), | ||
49 | + 'class' => $model->isNewRecord?'':'artbox-delete-file', | ||
50 | + ], | ||
51 | + 'pluginOptions' => [ | ||
52 | + 'allowedFileExtensions' => [ | ||
53 | + 'jpg', | ||
54 | + 'gif', | ||
55 | + 'png', | ||
56 | + ], | ||
57 | + 'initialPreview' => !empty( $model->getImageUrl(0, false) ) ? \artweb\artbox\components\artboximage\ArtboxImageHelper::getImage( | ||
58 | + $model->imageUrl, | ||
59 | + 'list' | ||
60 | + ) : '', | ||
61 | + 'initialPreviewShowDelete' => false, | ||
62 | + 'overwriteInitial' => true, | ||
63 | + 'showRemove' => true, | ||
64 | + 'showUpload' => false, | ||
65 | + 'showClose' => false, | ||
66 | + 'previewFileType' => 'image', | ||
67 | + ], | ||
68 | + ] | ||
69 | + ); ?> | ||
70 | + | ||
71 | + <?= $form->field($model, 'sort') | ||
72 | + ->textInput() ?> | ||
73 | + | ||
74 | + <?php echo $form->field($model, 'parent_id') | ||
75 | + ->widget( | ||
76 | + Select2::className(), | ||
77 | + [ | ||
78 | + 'data' => $parentCategories, | ||
79 | + 'options' => [ 'placeholder' => \Yii::t('blog', 'Has no parent rubric') ], | ||
80 | + 'pluginOptions' => [ | ||
81 | + 'allowClear' => true, | ||
82 | + ], | ||
83 | + ] | ||
84 | + ); | ||
85 | + ?> | ||
86 | + | ||
87 | + <?= $form->field($model, 'status') | ||
88 | + ->checkbox() ?> | ||
89 | + | ||
90 | + <div class="form-group"> | ||
91 | + <?= Html::submitButton( | ||
92 | + $model->isNewRecord ? 'Create' : 'Update', | ||
93 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
94 | + ) ?> | ||
95 | + </div> | ||
96 | + | ||
97 | + <?php ActiveForm::end(); ?> | ||
98 | + | ||
99 | +</div> |
1 | +++ a/views/blog-category/_form_language.php | ||
1 | +<?php | ||
2 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
3 | + use artweb\artbox\language\models\Language; | ||
4 | + use yii\web\View; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /** | ||
8 | + * @var BlogArticleLang $model_lang | ||
9 | + * @var Language $language | ||
10 | + * @var ActiveForm $form | ||
11 | + * @var View $this | ||
12 | + */ | ||
13 | +?> | ||
14 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
15 | + ->textInput([ 'maxlength' => true ]); ?> | ||
16 | + | ||
17 | +<?= $form->field($model_lang, '[' . $language->id . ']alias') | ||
18 | + ->textInput([ 'maxlength' => true ]); ?> | ||
19 | + | ||
20 | +<?= $form->field($model_lang, '[' . $language->id . ']description') | ||
21 | + ->textarea( | ||
22 | + [ | ||
23 | + 'rows' => '10', | ||
24 | + ] | ||
25 | + ) ?> | ||
26 | + | ||
27 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_title') | ||
28 | + ->textInput([ 'maxlength' => true ]); ?> | ||
29 | + | ||
30 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_description') | ||
31 | + ->textInput([ 'maxlength' => true ]); ?> | ||
32 | + | ||
33 | +<?= $form->field($model_lang, '[' . $language->id . ']seo_text') | ||
34 | + ->textInput([ 'maxlength' => true ]); ?> | ||
35 | + | ||
36 | +<?= $form->field($model_lang, '[' . $language->id . ']h1') | ||
37 | + ->textInput([ 'maxlength' => true ]); ?> |
1 | +++ a/views/blog-category/_search.php | ||
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model artweb\artbox\blog\models\BlogCategorySearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="blog-category-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'sort') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'image') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'parent_id') ?> | ||
25 | + | ||
26 | + <?= $form->field($model, 'status')->checkbox() ?> | ||
27 | + | ||
28 | + <div class="form-group"> | ||
29 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | ||
30 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | ||
31 | + </div> | ||
32 | + | ||
33 | + <?php ActiveForm::end(); ?> | ||
34 | + | ||
35 | +</div> |
1 | +++ a/views/blog-category/create.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
4 | + use artweb\artbox\blog\models\BlogCategory; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogCategory $model | ||
11 | + * @var BlogArticleLang[] $modelLangs | ||
12 | + * @var array $parentCategories | ||
13 | + */ | ||
14 | + | ||
15 | + $this->title = \Yii::t('blog', 'Create Blog Category'); | ||
16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
17 | + 'label' => \Yii::t('blog', 'Blog Categories'), | ||
18 | + 'url' => [ 'index' ], | ||
19 | + ]; | ||
20 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
21 | +?> | ||
22 | +<div class="blog-category-create"> | ||
23 | + | ||
24 | + <h1><?= Html::encode($this->title) ?></h1> | ||
25 | + | ||
26 | + <?= $this->render( | ||
27 | + '_form', | ||
28 | + [ | ||
29 | + 'model' => $model, | ||
30 | + 'modelLangs' => $modelLangs, | ||
31 | + 'parentCategories' => $parentCategories, | ||
32 | + ] | ||
33 | + ) ?> | ||
34 | + | ||
35 | +</div> |
1 | +++ a/views/blog-category/index.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogCategory; | ||
4 | + use artweb\artbox\blog\models\BlogCategorySearch; | ||
5 | + use yii\data\ActiveDataProvider; | ||
6 | + use yii\helpers\Html; | ||
7 | + use yii\grid\GridView; | ||
8 | + use yii\web\View; | ||
9 | + | ||
10 | + /** | ||
11 | + * @var View $this | ||
12 | + * @var BlogCategorySearch $searchModel | ||
13 | + * @var ActiveDataProvider $dataProvider | ||
14 | + */ | ||
15 | + | ||
16 | + $this->title = \Yii::t('blog', 'Blog Categories'); | ||
17 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
18 | +?> | ||
19 | +<div class="blog-category-index"> | ||
20 | + | ||
21 | + <h1><?= Html::encode($this->title) ?></h1> | ||
22 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a(\Yii::t('blog', 'Create Blog Category'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
26 | + </p> | ||
27 | + <?= GridView::widget( | ||
28 | + [ | ||
29 | + 'dataProvider' => $dataProvider, | ||
30 | + 'filterModel' => $searchModel, | ||
31 | + 'columns' => [ | ||
32 | + 'id', | ||
33 | + [ | ||
34 | + 'attribute' => 'title', | ||
35 | + 'value' => 'lang.title', | ||
36 | + ], | ||
37 | + 'imageUrl:image', | ||
38 | + [ | ||
39 | + 'label' => \Yii::t('blog', 'Parent category'), | ||
40 | + 'value' => function($model) { | ||
41 | + /** | ||
42 | + * @var BlogCategory $model | ||
43 | + */ | ||
44 | + if (!empty( $model->parent )) { | ||
45 | + return $model->parent->lang->title; | ||
46 | + } else { | ||
47 | + return false; | ||
48 | + }; | ||
49 | + }, | ||
50 | + ], | ||
51 | + [ | ||
52 | + 'attribute' => 'status', | ||
53 | + 'value' => function($model) { | ||
54 | + /** | ||
55 | + * @var BlogCategory $model | ||
56 | + */ | ||
57 | + return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'); | ||
58 | + }, | ||
59 | + 'filter' => [ | ||
60 | + 0 => \Yii::t('blog', 'Not active'), | ||
61 | + 1 => \Yii::t('blog', 'Active'), | ||
62 | + ], | ||
63 | + ], | ||
64 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
65 | + ], | ||
66 | + ] | ||
67 | + ); ?> | ||
68 | +</div> |
1 | +++ a/views/blog-category/update.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogCategory; | ||
4 | + use artweb\artbox\blog\models\BlogCategoryLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogCategory $model | ||
11 | + * @var BlogCategoryLang $modelLangs | ||
12 | + * @var array $parentCategories | ||
13 | + */ | ||
14 | + | ||
15 | + $this->title = \Yii::t('blog', 'Update Blog Category: ') . $model->lang->title; | ||
16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
17 | + 'label' => \Yii::t('blog', 'Blog Categories'), | ||
18 | + 'url' => [ 'index' ], | ||
19 | + ]; | ||
20 | + $this->params[ 'breadcrumbs' ][] = [ | ||
21 | + 'label' => $model->lang->title, | ||
22 | + 'url' => [ | ||
23 | + 'view', | ||
24 | + 'id' => $model->id, | ||
25 | + ], | ||
26 | + ]; | ||
27 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); | ||
28 | +?> | ||
29 | +<div class="blog-category-update"> | ||
30 | + | ||
31 | + <h1><?= Html::encode($this->title) ?></h1> | ||
32 | + | ||
33 | + <?= $this->render( | ||
34 | + '_form', | ||
35 | + [ | ||
36 | + 'model' => $model, | ||
37 | + 'modelLangs' => $modelLangs, | ||
38 | + 'parentCategories' => $parentCategories, | ||
39 | + ] | ||
40 | + ) ?> | ||
41 | + | ||
42 | +</div> |
1 | +++ a/views/blog-category/view.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogCategory; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\web\View; | ||
6 | + use yii\widgets\DetailView; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogCategory $model | ||
11 | + */ | ||
12 | + | ||
13 | + $this->title = $model->lang->title; | ||
14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
15 | + 'label' => \Yii::t('blog', 'Blog Categories'), | ||
16 | + 'url' => [ 'index' ], | ||
17 | + ]; | ||
18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
19 | +?> | ||
20 | +<div class="blog-category-view"> | ||
21 | + | ||
22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a( | ||
26 | + 'Update', | ||
27 | + [ | ||
28 | + 'update', | ||
29 | + 'id' => $model->id, | ||
30 | + ], | ||
31 | + [ 'class' => 'btn btn-primary' ] | ||
32 | + ) ?> | ||
33 | + <?= Html::a( | ||
34 | + 'Delete', | ||
35 | + [ | ||
36 | + 'delete', | ||
37 | + 'id' => $model->id, | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'class' => 'btn btn-danger', | ||
41 | + 'data' => [ | ||
42 | + 'confirm' => 'Are you sure you want to delete this item?', | ||
43 | + 'method' => 'post', | ||
44 | + ], | ||
45 | + ] | ||
46 | + ) ?> | ||
47 | + </p> | ||
48 | + | ||
49 | + <?= DetailView::widget( | ||
50 | + [ | ||
51 | + 'model' => $model, | ||
52 | + 'attributes' => [ | ||
53 | + 'id', | ||
54 | + 'sort', | ||
55 | + 'imageUrl:image', | ||
56 | + [ | ||
57 | + 'attribute' => 'parent_id', | ||
58 | + 'value' => ( !empty( $model->parent ) ) ? $model->parent->lang->title : '', | ||
59 | + ], | ||
60 | + 'lang.alias', | ||
61 | + 'lang.description:text', | ||
62 | + [ | ||
63 | + 'attribute' => 'status', | ||
64 | + 'value' => ( $model->status ) ? \Yii::t('blog', 'Active') : \Yii::t('blog', 'Not active'), | ||
65 | + ], | ||
66 | + ], | ||
67 | + ] | ||
68 | + ) ?> | ||
69 | + | ||
70 | +</div> |
1 | +++ a/views/blog-tag/_form.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogTag; | ||
4 | + use artweb\artbox\blog\models\BlogTagLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + use yii\widgets\ActiveForm; | ||
8 | + use artweb\artbox\language\widgets\LanguageForm; | ||
9 | + | ||
10 | + /** | ||
11 | + * @var View $this | ||
12 | + * @var BlogTag $model | ||
13 | + * @var ActiveForm $form | ||
14 | + * @var BlogTagLang[] $modelLangs | ||
15 | + */ | ||
16 | +?> | ||
17 | + | ||
18 | +<div class="blog-tag-form"> | ||
19 | + | ||
20 | + <?php $form = ActiveForm::begin(); ?> | ||
21 | + | ||
22 | + <?php | ||
23 | + echo LanguageForm::widget( | ||
24 | + [ | ||
25 | + 'modelLangs' => $modelLangs, | ||
26 | + 'formView' => '@artweb/artbox/blog/views/blog-tag/_form_language', | ||
27 | + 'form' => $form, | ||
28 | + ] | ||
29 | + ); | ||
30 | + ?> | ||
31 | + | ||
32 | + <div class="form-group"> | ||
33 | + <?= Html::submitButton( | ||
34 | + $model->isNewRecord ? 'Create' : 'Update', | ||
35 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
36 | + ) ?> | ||
37 | + </div> | ||
38 | + | ||
39 | + <?php ActiveForm::end(); ?> | ||
40 | + | ||
41 | +</div> |
1 | +++ a/views/blog-tag/_form_language.php | ||
1 | +<?php | ||
2 | + use artweb\artbox\blog\models\BlogArticleLang; | ||
3 | + use artweb\artbox\language\models\Language; | ||
4 | + use yii\web\View; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /** | ||
8 | + * @var BlogArticleLang $model_lang | ||
9 | + * @var Language $language | ||
10 | + * @var ActiveForm $form | ||
11 | + * @var View $this | ||
12 | + */ | ||
13 | +?> | ||
14 | +<?= $form->field($model_lang, '[' . $language->id . ']label') | ||
15 | + ->textInput([ 'maxlength' => true ]); ?> |
1 | +++ a/views/blog-tag/_search.php | ||
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model artweb\artbox\blog\models\BlogTagSearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="blog-tag-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'id') ?> | ||
19 | + | ||
20 | + <div class="form-group"> | ||
21 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | ||
22 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | ||
23 | + </div> | ||
24 | + | ||
25 | + <?php ActiveForm::end(); ?> | ||
26 | + | ||
27 | +</div> |
1 | +++ a/views/blog-tag/create.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogTag; | ||
4 | + use artweb\artbox\blog\models\BlogTagLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogTagLang[] $modelLangs | ||
11 | + * @var BlogTag $model | ||
12 | + */ | ||
13 | + | ||
14 | + $this->title = \Yii::t('blog', 'Create Blog Tag'); | ||
15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
16 | + 'label' => \Yii::t('blog', 'Blog Tags'), | ||
17 | + 'url' => [ 'index' ], | ||
18 | + ]; | ||
19 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
20 | +?> | ||
21 | +<div class="blog-tag-create"> | ||
22 | + | ||
23 | + <h1><?= Html::encode($this->title) ?></h1> | ||
24 | + | ||
25 | + <?= $this->render( | ||
26 | + '_form', | ||
27 | + [ | ||
28 | + 'model' => $model, | ||
29 | + 'modelLangs' => $modelLangs, | ||
30 | + ] | ||
31 | + ) ?> | ||
32 | + | ||
33 | +</div> |
1 | +++ a/views/blog-tag/index.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogTagSearch; | ||
4 | + use yii\data\ActiveDataProvider; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\grid\GridView; | ||
7 | + use yii\web\View; | ||
8 | + | ||
9 | + /** | ||
10 | + * @var View $this | ||
11 | + * @var BlogTagSearch $searchModel | ||
12 | + * @var ActiveDataProvider $dataProvider | ||
13 | + */ | ||
14 | + | ||
15 | + $this->title = \Yii::t('blog', 'Blog Tags'); | ||
16 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
17 | +?> | ||
18 | +<div class="blog-tag-index"> | ||
19 | + | ||
20 | + <h1><?= Html::encode($this->title) ?></h1> | ||
21 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
22 | + | ||
23 | + <p> | ||
24 | + <?= Html::a(\Yii::t('blog', 'Create Blog Tag'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
25 | + </p> | ||
26 | + <?= GridView::widget( | ||
27 | + [ | ||
28 | + 'dataProvider' => $dataProvider, | ||
29 | + 'filterModel' => $searchModel, | ||
30 | + 'columns' => [ | ||
31 | + 'id', | ||
32 | + [ | ||
33 | + 'attribute' => 'label', | ||
34 | + 'value' => 'lang.label', | ||
35 | + ], | ||
36 | + [ | ||
37 | + 'class' => 'yii\grid\ActionColumn', | ||
38 | + ], | ||
39 | + ], | ||
40 | + ] | ||
41 | + ); ?> | ||
42 | +</div> |
1 | +++ a/views/blog-tag/update.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogTag; | ||
4 | + use artweb\artbox\blog\models\BlogTagLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogTagLang[] $modelLangs | ||
11 | + * @var BlogTag $model | ||
12 | + */ | ||
13 | + | ||
14 | + $this->title = \Yii::t('blog', 'Update Blog Tag: ') . $model->lang->label; | ||
15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
16 | + 'label' => \Yii::t('blog', 'Blog Tags'), | ||
17 | + 'url' => [ 'index' ], | ||
18 | + ]; | ||
19 | + $this->params[ 'breadcrumbs' ][] = [ | ||
20 | + 'label' => $model->lang->label, | ||
21 | + 'url' => [ | ||
22 | + 'view', | ||
23 | + 'id' => $model->id, | ||
24 | + ], | ||
25 | + ]; | ||
26 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); | ||
27 | +?> | ||
28 | +<div class="blog-tag-update"> | ||
29 | + | ||
30 | + <h1><?= Html::encode($this->title) ?></h1> | ||
31 | + | ||
32 | + <?= $this->render( | ||
33 | + '_form', | ||
34 | + [ | ||
35 | + 'model' => $model, | ||
36 | + 'modelLangs' => $modelLangs, | ||
37 | + ] | ||
38 | + ) ?> | ||
39 | + | ||
40 | +</div> |
1 | +++ a/views/blog-tag/view.php | ||
1 | +<?php | ||
2 | + | ||
3 | + use artweb\artbox\blog\models\BlogTag; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\web\View; | ||
6 | + use yii\widgets\DetailView; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var BlogTag $model | ||
11 | + */ | ||
12 | + | ||
13 | + $this->title = $model->lang->label; | ||
14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
15 | + 'label' => \Yii::t('blog', 'Blog Tags'), | ||
16 | + 'url' => [ 'index' ], | ||
17 | + ]; | ||
18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
19 | +?> | ||
20 | +<div class="blog-tag-view"> | ||
21 | + | ||
22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a( | ||
26 | + 'Update', | ||
27 | + [ | ||
28 | + 'update', | ||
29 | + 'id' => $model->id, | ||
30 | + ], | ||
31 | + [ 'class' => 'btn btn-primary' ] | ||
32 | + ) ?> | ||
33 | + <?= Html::a( | ||
34 | + 'Delete', | ||
35 | + [ | ||
36 | + 'delete', | ||
37 | + 'id' => $model->id, | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'class' => 'btn btn-danger', | ||
41 | + 'data' => [ | ||
42 | + 'confirm' => 'Are you sure you want to delete this item?', | ||
43 | + 'method' => 'post', | ||
44 | + ], | ||
45 | + ] | ||
46 | + ) ?> | ||
47 | + </p> | ||
48 | + | ||
49 | + <?= DetailView::widget( | ||
50 | + [ | ||
51 | + 'model' => $model, | ||
52 | + 'attributes' => [ | ||
53 | + 'id', | ||
54 | + 'lang.label', | ||
55 | + ], | ||
56 | + ] | ||
57 | + ) ?> | ||
58 | + | ||
59 | +</div> |
1 | +++ a/views/default/index.php | ||
1 | +<div class="blog-default-index"> | ||
2 | + <h1><?= $this->context->action->uniqueId ?></h1> | ||
3 | + <p> | ||
4 | + This is the view content for action "<?= $this->context->action->id ?>". | ||
5 | + The action belongs to the controller "<?= get_class($this->context) ?>" | ||
6 | + in the "<?= $this->context->module->id ?>" module. | ||
7 | + </p> | ||
8 | + <p> | ||
9 | + You may customize this page by editing the following file:<br> | ||
10 | + <code><?= __FILE__ ?></code> | ||
11 | + </p> | ||
12 | +</div> |