Commit 52190232b988d3a26c9b2f67b81d1f1ffdf1f24d

Authored by Alexey Boroda
1 parent c5a6465c

-Blog almost done

Showing 40 changed files with 1275 additions and 506 deletions   Show diff stats
backend/views/layouts/main-sidebar.php
... ... @@ -122,7 +122,7 @@ use yii\widgets\Menu;
122 122 ],
123 123 [
124 124 'label' => 'Блог',
125   - 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-picture"></i> <span>{label}</span></a>',
  125 + 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-edit"></i> <span>{label}</span></a>',
126 126 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'],
127 127 'active' => preg_match('/^blog.*$/', $this->context->id) ? true : false,
128 128 'items' => [
... ... @@ -130,16 +130,19 @@ use yii\widgets\Menu;
130 130 'label' => 'Статьи',
131 131 'url' => ['/blog/blog-article'],
132 132 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'],
  133 + 'active' => preg_match('/.*blog-article.*$/', $this->context->id),
133 134 ],
134 135 [
135 136 'label' => 'Рубрики',
136 137 'url' => ['/blog/blog-category'],
137 138 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'],
  139 + 'active' => preg_match('/.*blog-category.*$/', $this->context->id),
138 140 ],
139 141 [
140 142 'label' => 'Тэги',
141 143 'url' => ['/blog/blog-tag'],
142 144 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'],
  145 + 'active' => preg_match('/.*blog-tag.*$/', $this->context->id),
143 146 ],
144 147 ]
145 148 ],
... ...
common/config/main.php
... ... @@ -43,6 +43,12 @@
43 43 'master' => NULL,
44 44 ],
45 45 ],
  46 + 'list' => [
  47 + 'resize' => [
  48 + 'width' => 360,
  49 + 'height' => 360,
  50 + ],
  51 + ],
46 52 ],
47 53 ],
48 54 'basket' => [
... ... @@ -53,8 +59,8 @@
53 59 'artbox-comment' => [
54 60 'class' => 'common\modules\comment\Module',
55 61 ],
56   - 'blog' => [
57   - 'class' => 'common\modules\blog\Module'
  62 + 'blog' => [
  63 + 'class' => 'common\modules\blog\Module',
58 64 ],
59 65 ],
60 66 ];
... ...
common/modules/blog/Module.php 100644 → 100755
common/modules/blog/controllers/BlogArticleController.php 100644 → 100755
1 1 <?php
2   -
3   -namespace common\modules\blog\controllers;
4   -
5   -use Yii;
6   -use common\modules\blog\models\BlogArticle;
7   -use common\modules\blog\models\BlogArticleSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -
12   -/**
13   - * BlogArticleController implements the CRUD actions for BlogArticle model.
14   - */
15   -class BlogArticleController extends Controller
16   -{
  2 +
  3 + namespace common\modules\blog\controllers;
  4 +
  5 + use common\modules\blog\models\BlogCategory;
  6 + use common\modules\blog\models\BlogCategoryLang;
  7 + use common\modules\blog\models\BlogTag;
  8 + use Yii;
  9 + use common\modules\blog\models\BlogArticle;
  10 + use common\modules\blog\models\BlogArticleSearch;
  11 + use yii\helpers\ArrayHelper;
  12 + use yii\helpers\VarDumper;
  13 + use yii\web\Controller;
  14 + use yii\web\NotFoundHttpException;
  15 + use yii\filters\VerbFilter;
  16 +
17 17 /**
18   - * @inheritdoc
  18 + * BlogArticleController implements the CRUD actions for BlogArticle model.
19 19 */
20   - public function behaviors()
  20 + class BlogArticleController extends Controller
21 21 {
22   - return [
23   - 'verbs' => [
24   - 'class' => VerbFilter::className(),
25   - 'actions' => [
26   - 'delete' => ['POST'],
  22 + /**
  23 + * @inheritdoc
  24 + */
  25 + public function behaviors()
  26 + {
  27 + return [
  28 + 'verbs' => [
  29 + 'class' => VerbFilter::className(),
  30 + 'actions' => [
  31 + 'delete' => [ 'POST' ],
  32 + ],
27 33 ],
28   - ],
29   - ];
30   - }
31   -
32   - /**
33   - * Lists all BlogArticle models.
34   - * @return mixed
35   - */
36   - public function actionIndex()
37   - {
38   - $searchModel = new BlogArticleSearch();
39   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
40   -
41   - return $this->render('index', [
42   - 'searchModel' => $searchModel,
43   - 'dataProvider' => $dataProvider,
44   - ]);
45   - }
46   -
47   - /**
48   - * Displays a single BlogArticle model.
49   - * @param integer $id
50   - * @return mixed
51   - */
52   - public function actionView($id)
53   - {
54   - return $this->render('view', [
55   - 'model' => $this->findModel($id),
56   - ]);
57   - }
58   -
59   - /**
60   - * Creates a new BlogArticle model.
61   - * If creation is successful, the browser will be redirected to the 'view' page.
62   - * @return mixed
63   - */
64   - public function actionCreate()
65   - {
66   - $model = new BlogArticle();
67   -
68   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
69   - return $this->redirect(['view', 'id' => $model->id]);
70   - } else {
71   - return $this->render('create', [
72   - 'model' => $model,
73   - ]);
  34 + ];
74 35 }
75   - }
76   -
77   - /**
78   - * Updates an existing BlogArticle model.
79   - * If update is successful, the browser will be redirected to the 'view' page.
80   - * @param integer $id
81   - * @return mixed
82   - */
83   - public function actionUpdate($id)
84   - {
85   - $model = $this->findModel($id);
86   -
87   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
88   - return $this->redirect(['view', 'id' => $model->id]);
89   - } else {
90   - return $this->render('update', [
91   - 'model' => $model,
92   - ]);
  36 +
  37 + /**
  38 + * Lists all BlogArticle models.
  39 + *
  40 + * @return mixed
  41 + */
  42 + public function actionIndex()
  43 + {
  44 + $searchModel = new BlogArticleSearch();
  45 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  46 +
  47 + return $this->render(
  48 + 'index',
  49 + [
  50 + 'searchModel' => $searchModel,
  51 + 'dataProvider' => $dataProvider,
  52 + ]
  53 + );
93 54 }
94   - }
95   -
96   - /**
97   - * Deletes an existing BlogArticle model.
98   - * If deletion is successful, the browser will be redirected to the 'index' page.
99   - * @param integer $id
100   - * @return mixed
101   - */
102   - public function actionDelete($id)
103   - {
104   - $this->findModel($id)->delete();
105   -
106   - return $this->redirect(['index']);
107   - }
108   -
109   - /**
110   - * Finds the BlogArticle model based on its primary key value.
111   - * If the model is not found, a 404 HTTP exception will be thrown.
112   - * @param integer $id
113   - * @return BlogArticle the loaded model
114   - * @throws NotFoundHttpException if the model cannot be found
115   - */
116   - protected function findModel($id)
117   - {
118   - if (($model = BlogArticle::findOne($id)) !== null) {
119   - return $model;
120   - } else {
121   - throw new NotFoundHttpException('The requested page does not exist.');
  55 +
  56 + /**
  57 + * Displays a single BlogArticle model.
  58 + *
  59 + * @param integer $id
  60 + *
  61 + * @return mixed
  62 + */
  63 + public function actionView($id)
  64 + {
  65 + return $this->render(
  66 + 'view',
  67 + [
  68 + 'model' => $this->findModel($id),
  69 + ]
  70 + );
  71 + }
  72 +
  73 + /**
  74 + * Creates a new BlogArticle model.
  75 + * If creation is successful, the browser will be redirected to the 'view' page.
  76 + *
  77 + * @return mixed
  78 + */
  79 + public function actionCreate()
  80 + {
  81 + $model = new BlogArticle();
  82 + $model->generateLangs();
  83 +
  84 + $categories = ArrayHelper::map(
  85 + BlogCategory::find()
  86 + ->joinWith('lang')
  87 + ->all(),
  88 + 'id',
  89 + 'lang.title'
  90 + );
  91 +
  92 + $tags = ArrayHelper::map(
  93 + BlogTag::find()
  94 + ->joinWith('lang')
  95 + ->all(),
  96 + 'id',
  97 + 'lang.label'
  98 + );
  99 +
  100 + if ($model->load(Yii::$app->request->post())) {
  101 + $model->loadLangs(\Yii::$app->request);
  102 + if ($model->save() && $model->transactionStatus) {
  103 +
  104 + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) {
  105 + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) {
  106 + if ($category = BlogCategory::findOne($item)) {
  107 + $model->link('blogCategories', $category);
  108 + }
  109 + }
  110 + }
  111 +
  112 + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) {
  113 + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) {
  114 + if ($category = BlogTag::findOne($item)) {
  115 + $model->link('blogTags', $category);
  116 + }
  117 + }
  118 + }
  119 +
  120 + return $this->redirect(
  121 + [
  122 + 'view',
  123 + 'id' => $model->id,
  124 + ]
  125 + );
  126 + }
  127 + }
  128 + return $this->render(
  129 + 'create',
  130 + [
  131 + 'model' => $model,
  132 + 'modelLangs' => $model->modelLangs,
  133 + 'categories' => $categories,
  134 + 'tags' => $tags,
  135 + ]
  136 + );
  137 +
  138 + }
  139 +
  140 + /**
  141 + * Updates an existing BlogArticle model.
  142 + * If update is successful, the browser will be redirected to the 'view' page.
  143 + *
  144 + * @param integer $id
  145 + *
  146 + * @return mixed
  147 + */
  148 + public function actionUpdate($id)
  149 + {
  150 + $model = $this->findModel($id);
  151 + $model->generateLangs();
  152 +
  153 + $categories = ArrayHelper::map(
  154 + BlogCategory::find()
  155 + ->joinWith('lang')
  156 + ->all(),
  157 + 'id',
  158 + 'lang.title'
  159 + );
  160 +
  161 + $tags = ArrayHelper::map(
  162 + BlogTag::find()
  163 + ->joinWith('lang')
  164 + ->all(),
  165 + 'id',
  166 + 'lang.label'
  167 + );
  168 +
  169 + if ($model->load(Yii::$app->request->post())) {
  170 + $model->loadLangs(\Yii::$app->request);
  171 + if ($model->save() && $model->transactionStatus) {
  172 +
  173 + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) {
  174 + $model->unlinkAll('blogCategories', true);
  175 + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) {
  176 + if ($category = BlogCategory::findOne($item)) {
  177 + $model->link('blogCategories', $category);
  178 + }
  179 + }
  180 + }
  181 +
  182 + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) {
  183 + $model->unlinkAll('blogTags', true);
  184 + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) {
  185 + if ($category = BlogTag::findOne($item)) {
  186 + $model->link('blogTags', $category);
  187 + }
  188 + }
  189 + }
  190 +
  191 + return $this->redirect(
  192 + [
  193 + 'view',
  194 + 'id' => $model->id,
  195 + ]
  196 + );
  197 + }
  198 + }
  199 + return $this->render(
  200 + 'update',
  201 + [
  202 + 'model' => $model,
  203 + 'modelLangs' => $model->modelLangs,
  204 + 'categories' => $categories,
  205 + 'tags' => $tags,
  206 + ]
  207 + );
  208 +
  209 + }
  210 +
  211 + /**
  212 + * Deletes an existing BlogArticle model.
  213 + * If deletion is successful, the browser will be redirected to the 'index' page.
  214 + *
  215 + * @param integer $id
  216 + *
  217 + * @return mixed
  218 + */
  219 + public function actionDelete($id)
  220 + {
  221 + $this->findModel($id)
  222 + ->delete();
  223 +
  224 + return $this->redirect([ 'index' ]);
  225 + }
  226 +
  227 + /**
  228 + * Finds the BlogArticle model based on its primary key value.
  229 + * If the model is not found, a 404 HTTP exception will be thrown.
  230 + *
  231 + * @param integer $id
  232 + *
  233 + * @return BlogArticle the loaded model
  234 + * @throws NotFoundHttpException if the model cannot be found
  235 + */
  236 + protected function findModel($id)
  237 + {
  238 + if (( $model = BlogArticle::findOne($id) ) !== NULL) {
  239 + return $model;
  240 + } else {
  241 + throw new NotFoundHttpException('The requested page does not exist.');
  242 + }
122 243 }
123 244 }
124   -}
... ...
common/modules/blog/controllers/BlogCategoryController.php 100644 → 100755
1 1 <?php
2   -
3   -namespace common\modules\blog\controllers;
4   -
5   -use Yii;
6   -use common\modules\blog\models\BlogCategory;
7   -use common\modules\blog\models\BlogCategorySearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -
12   -/**
13   - * BlogCategoryController implements the CRUD actions for BlogCategory model.
14   - */
15   -class BlogCategoryController extends Controller
16   -{
  2 +
  3 + namespace common\modules\blog\controllers;
  4 +
  5 + use Yii;
  6 + use common\modules\blog\models\BlogCategory;
  7 + use common\modules\blog\models\BlogCategorySearch;
  8 + use yii\helpers\ArrayHelper;
  9 + use yii\web\Controller;
  10 + use yii\web\NotFoundHttpException;
  11 + use yii\filters\VerbFilter;
  12 +
17 13 /**
18   - * @inheritdoc
  14 + * BlogCategoryController implements the CRUD actions for BlogCategory model.
19 15 */
20   - public function behaviors()
  16 + class BlogCategoryController extends Controller
21 17 {
22   - return [
23   - 'verbs' => [
24   - 'class' => VerbFilter::className(),
25   - 'actions' => [
26   - 'delete' => ['POST'],
  18 + /**
  19 + * @inheritdoc
  20 + */
  21 + public function behaviors()
  22 + {
  23 + return [
  24 + 'verbs' => [
  25 + 'class' => VerbFilter::className(),
  26 + 'actions' => [
  27 + 'delete' => [ 'POST' ],
  28 + ],
27 29 ],
28   - ],
29   - ];
30   - }
31   -
32   - /**
33   - * Lists all BlogCategory models.
34   - * @return mixed
35   - */
36   - public function actionIndex()
37   - {
38   - $searchModel = new BlogCategorySearch();
39   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
40   -
41   - return $this->render('index', [
42   - 'searchModel' => $searchModel,
43   - 'dataProvider' => $dataProvider,
44   - ]);
45   - }
46   -
47   - /**
48   - * Displays a single BlogCategory model.
49   - * @param integer $id
50   - * @return mixed
51   - */
52   - public function actionView($id)
53   - {
54   - return $this->render('view', [
55   - 'model' => $this->findModel($id),
56   - ]);
57   - }
58   -
59   - /**
60   - * Creates a new BlogCategory model.
61   - * If creation is successful, the browser will be redirected to the 'view' page.
62   - * @return mixed
63   - */
64   - public function actionCreate()
65   - {
66   - $model = new BlogCategory();
67   -
68   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
69   - return $this->redirect(['view', 'id' => $model->id]);
70   - } else {
71   - return $this->render('create', [
72   - 'model' => $model,
73   - ]);
  30 + ];
74 31 }
75   - }
76   -
77   - /**
78   - * Updates an existing BlogCategory model.
79   - * If update is successful, the browser will be redirected to the 'view' page.
80   - * @param integer $id
81   - * @return mixed
82   - */
83   - public function actionUpdate($id)
84   - {
85   - $model = $this->findModel($id);
86   -
87   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
88   - return $this->redirect(['view', 'id' => $model->id]);
89   - } else {
90   - return $this->render('update', [
91   - 'model' => $model,
92   - ]);
  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 + );
93 50 }
94   - }
95   -
96   - /**
97   - * Deletes an existing BlogCategory model.
98   - * If deletion is successful, the browser will be redirected to the 'index' page.
99   - * @param integer $id
100   - * @return mixed
101   - */
102   - public function actionDelete($id)
103   - {
104   - $this->findModel($id)->delete();
105   -
106   - return $this->redirect(['index']);
107   - }
108   -
109   - /**
110   - * Finds the BlogCategory model based on its primary key value.
111   - * If the model is not found, a 404 HTTP exception will be thrown.
112   - * @param integer $id
113   - * @return BlogCategory the loaded model
114   - * @throws NotFoundHttpException if the model cannot be found
115   - */
116   - protected function findModel($id)
117   - {
118   - if (($model = BlogCategory::findOne($id)) !== null) {
119   - return $model;
120   - } else {
121   - throw new NotFoundHttpException('The requested page does not exist.');
  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 + /**
  185 + * Finds the BlogCategory model based on its primary key value.
  186 + * If the model is not found, a 404 HTTP exception will be thrown.
  187 + *
  188 + * @param integer $id
  189 + *
  190 + * @return BlogCategory the loaded model
  191 + * @throws NotFoundHttpException if the model cannot be found
  192 + */
  193 + protected function findModel($id)
  194 + {
  195 + if (( $model = BlogCategory::findOne($id) ) !== NULL) {
  196 + return $model;
  197 + } else {
  198 + throw new NotFoundHttpException('The requested page does not exist.');
  199 + }
122 200 }
123 201 }
124   -}
... ...
common/modules/blog/controllers/BlogTagController.php 100644 → 100755
1 1 <?php
2   -
3   -namespace common\modules\blog\controllers;
4   -
5   -use Yii;
6   -use common\modules\blog\models\BlogTag;
7   -use common\modules\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   -{
  2 +
  3 + namespace common\modules\blog\controllers;
  4 +
  5 + use Yii;
  6 + use common\modules\blog\models\BlogTag;
  7 + use common\modules\blog\models\BlogTagSearch;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 + use yii\filters\VerbFilter;
  11 +
17 12 /**
18   - * @inheritdoc
  13 + * BlogTagController implements the CRUD actions for BlogTag model.
19 14 */
20   - public function behaviors()
  15 + class BlogTagController extends Controller
21 16 {
22   - return [
23   - 'verbs' => [
24   - 'class' => VerbFilter::className(),
25   - 'actions' => [
26   - 'delete' => ['POST'],
  17 + /**
  18 + * @inheritdoc
  19 + */
  20 + public function behaviors()
  21 + {
  22 + return [
  23 + 'verbs' => [
  24 + 'class' => VerbFilter::className(),
  25 + 'actions' => [
  26 + 'delete' => [ 'POST' ],
  27 + ],
27 28 ],
28   - ],
29   - ];
30   - }
31   -
32   - /**
33   - * Lists all BlogTag models.
34   - * @return mixed
35   - */
36   - public function actionIndex()
37   - {
38   - $searchModel = new BlogTagSearch();
39   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
40   -
41   - return $this->render('index', [
42   - 'searchModel' => $searchModel,
43   - 'dataProvider' => $dataProvider,
44   - ]);
45   - }
46   -
47   - /**
48   - * Displays a single BlogTag model.
49   - * @param integer $id
50   - * @return mixed
51   - */
52   - public function actionView($id)
53   - {
54   - return $this->render('view', [
55   - 'model' => $this->findModel($id),
56   - ]);
57   - }
58   -
59   - /**
60   - * Creates a new BlogTag model.
61   - * If creation is successful, the browser will be redirected to the 'view' page.
62   - * @return mixed
63   - */
64   - public function actionCreate()
65   - {
66   - $model = new BlogTag();
67   -
68   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
69   - return $this->redirect(['view', 'id' => $model->id]);
70   - } else {
71   - return $this->render('create', [
72   - 'model' => $model,
73   - ]);
  29 + ];
74 30 }
75   - }
76   -
77   - /**
78   - * Updates an existing BlogTag model.
79   - * If update is successful, the browser will be redirected to the 'view' page.
80   - * @param integer $id
81   - * @return mixed
82   - */
83   - public function actionUpdate($id)
84   - {
85   - $model = $this->findModel($id);
86   -
87   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
88   - return $this->redirect(['view', 'id' => $model->id]);
89   - } else {
90   - return $this->render('update', [
91   - 'model' => $model,
92   - ]);
  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 + );
93 49 }
94   - }
95   -
96   - /**
97   - * Deletes an existing BlogTag model.
98   - * If deletion is successful, the browser will be redirected to the 'index' page.
99   - * @param integer $id
100   - * @return mixed
101   - */
102   - public function actionDelete($id)
103   - {
104   - $this->findModel($id)->delete();
105   -
106   - return $this->redirect(['index']);
107   - }
108   -
109   - /**
110   - * Finds the BlogTag model based on its primary key value.
111   - * If the model is not found, a 404 HTTP exception will be thrown.
112   - * @param integer $id
113   - * @return BlogTag the loaded model
114   - * @throws NotFoundHttpException if the model cannot be found
115   - */
116   - protected function findModel($id)
117   - {
118   - if (($model = BlogTag::findOne($id)) !== null) {
119   - return $model;
120   - } else {
121   - throw new NotFoundHttpException('The requested page does not exist.');
  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 + }
122 168 }
123 169 }
124   -}
... ...
common/modules/blog/controllers/DefaultController.php 100644 → 100755
common/modules/blog/models/BlogArticle.php 100644 → 100755
... ... @@ -2,8 +2,14 @@
2 2  
3 3 namespace common\modules\blog\models;
4 4  
  5 + use common\behaviors\SaveImgBehavior;
  6 + use yii\behaviors\TimestampBehavior;
5 7 use yii\db\ActiveRecord;
6 8 use common\modules\language\behaviors\LanguageBehavior;
  9 + use common\modules\language\models\Language;
  10 + use common\modules\product\models\Product;
  11 + use yii\db\ActiveQuery;
  12 + use yii\web\Request;
7 13  
8 14 /**
9 15 * This is the model class for table "blog_article".
... ... @@ -28,6 +34,32 @@
28 34 * @property Product[] $products
29 35 * @property BlogArticleToTag[] $blogArticleToTags
30 36 * @property BlogTag[] $blogTags
  37 + * * * From language behavior *
  38 + * @property BlogArticleLang $lang
  39 + * @property BlogArticleLang[] $langs
  40 + * @property BlogArticleLang $objectLang
  41 + * @property string $ownerKey
  42 + * @property string $langKey
  43 + * @property BlogArticleLang[] $modelLangs
  44 + * @property bool $transactionStatus
  45 + * @method string getOwnerKey()
  46 + * @method void setOwnerKey( string $value )
  47 + * @method string getLangKey()
  48 + * @method void setLangKey( string $value )
  49 + * @method ActiveQuery getLangs()
  50 + * @method ActiveQuery getLang( integer $language_id )
  51 + * @method BlogArticleLang[] generateLangs()
  52 + * @method void loadLangs( Request $request )
  53 + * @method bool linkLangs()
  54 + * @method bool saveLangs()
  55 + * @method bool getTransactionStatus()
  56 + * * End language behavior *
  57 + * * From SaveImgBehavior
  58 + * @property string|null $imageFile
  59 + * @property string|null $imageUrl
  60 + * @method string|null getImageFile( int $field )
  61 + * @method string|null getImageUrl( int $field )
  62 + * * End SaveImgBehavior
31 63 */
32 64 class BlogArticle extends ActiveRecord
33 65 {
... ... @@ -42,8 +74,20 @@
42 74 public function behaviors()
43 75 {
44 76 return [
  77 + [
  78 + 'class' => TimestampBehavior::className(),
  79 + ],
  80 + [
  81 + 'class' => SaveImgBehavior::className(),
  82 + 'fields' => [
  83 + [
  84 + 'name' => 'image',
  85 + 'directory' => 'blog/article',
  86 + ],
  87 + ],
  88 + ],
45 89 'language' => [
46   - 'class' => LanguageBehavior::className(),
  90 + 'class' => LanguageBehavior::className(),
47 91 ],
48 92 ];
49 93 }
... ...
common/modules/blog/models/BlogArticleLang.php 100644 → 100755
... ... @@ -32,7 +32,16 @@ class BlogArticleLang extends ActiveRecord
32 32 {
33 33 return 'blog_article_lang';
34 34 }
35   -
  35 +
  36 + public function behaviors()
  37 + {
  38 + return [
  39 + 'slug' => [
  40 + 'class' => 'common\behaviors\Slug',
  41 + ],
  42 + ];
  43 + }
  44 +
36 45 /**
37 46 * @inheritdoc
38 47 */
... ...
common/modules/blog/models/BlogArticleSearch.php 100644 → 100755
common/modules/blog/models/BlogCategory.php 100644 → 100755
... ... @@ -4,6 +4,10 @@
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use common\modules\language\behaviors\LanguageBehavior;
  7 + use common\behaviors\SaveImgBehavior;
  8 + use common\modules\language\models\Language;
  9 + use yii\db\ActiveQuery;
  10 + use yii\web\Request;
7 11  
8 12 /**
9 13 * This is the model class for table "blog_category".
... ... @@ -17,6 +21,32 @@
17 21 * @property BlogArticle[] $blogArticles
18 22 * @property BlogCategoryLang[] $blogCategoryLangs
19 23 * @property Language[] $languages
  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
20 50 */
21 51 class BlogCategory extends ActiveRecord
22 52 {
... ... @@ -27,16 +57,28 @@
27 57 {
28 58 return 'blog_category';
29 59 }
30   -
  60 +
31 61 /**
32 62 * @inheritdoc
33 63 */
34 64 public function behaviors()
35 65 {
36 66 return [
  67 + [
  68 + 'class' => SaveImgBehavior::className(),
  69 + 'fields' => [
  70 + [
  71 + 'name' => 'image',
  72 + 'directory' => 'blog/category',
  73 + ],
  74 + ],
  75 + ],
37 76 'language' => [
38 77 'class' => LanguageBehavior::className(),
39 78 ],
  79 + 'Slug' => [
  80 + 'class' => 'common\behaviors\Slug',
  81 + ],
40 82 ];
41 83 }
42 84  
... ... @@ -62,6 +104,11 @@
62 104 'string',
63 105 'max' => 255,
64 106 ],
  107 + [
  108 + ['parent_id'],
  109 + 'default',
  110 + 'value' => 0,
  111 + ],
65 112 ];
66 113 }
67 114  
... ...
common/modules/blog/models/BlogCategoryLang.php 100644 → 100755
... ... @@ -2,7 +2,8 @@
2 2  
3 3 namespace common\modules\blog\models;
4 4  
5   -use Yii;
  5 +use yii\db\ActiveRecord;
  6 +use common\modules\language\models\Language;
6 7  
7 8 /**
8 9 * This is the model class for table "blog_category_lang".
... ... @@ -21,7 +22,7 @@ use Yii;
21 22 * @property BlogCategory $blogCategory
22 23 * @property Language $language
23 24 */
24   -class BlogCategoryLang extends \yii\db\ActiveRecord
  25 +class BlogCategoryLang extends ActiveRecord
25 26 {
26 27 /**
27 28 * @inheritdoc
... ... @@ -31,6 +32,15 @@ class BlogCategoryLang extends \yii\db\ActiveRecord
31 32 return 'blog_category_lang';
32 33 }
33 34  
  35 + public function behaviors()
  36 + {
  37 + return [
  38 + 'slug' => [
  39 + 'class' => 'common\behaviors\Slug',
  40 + ],
  41 + ];
  42 + }
  43 +
34 44 /**
35 45 * @inheritdoc
36 46 */
... ...
common/modules/blog/models/BlogCategorySearch.php 100644 → 100755
common/modules/blog/models/BlogTag.php 100644 → 100755
... ... @@ -4,6 +4,9 @@
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use common\modules\language\behaviors\LanguageBehavior;
  7 + use common\modules\language\models\Language;
  8 + use yii\db\ActiveQuery;
  9 + use yii\web\Request;
7 10  
8 11 /**
9 12 * This is the model class for table "blog_tag".
... ... @@ -13,8 +16,28 @@
13 16 * @property BlogArticle[] $blogArticles
14 17 * @property BlogTagLang[] $blogTagLangs
15 18 * @property Language[] $languages
  19 + * * From language behavior *
  20 + * @property BlogTagLang $lang
  21 + * @property BlogTagLang[] $langs
  22 + * @property BlogTagLang $objectLang
  23 + * @property string $ownerKey
  24 + * @property string $langKey
  25 + * @property BlogTagLang[] $modelLangs
  26 + * @property bool $transactionStatus
  27 + * @method string getOwnerKey()
  28 + * @method void setOwnerKey(string $value)
  29 + * @method string getLangKey()
  30 + * @method void setLangKey(string $value)
  31 + * @method ActiveQuery getLangs()
  32 + * @method ActiveQuery getLang( integer $language_id )
  33 + * @method BlogTagLang[] generateLangs()
  34 + * @method void loadLangs(Request $request)
  35 + * @method bool linkLangs()
  36 + * @method bool saveLangs()
  37 + * @method bool getTransactionStatus()
  38 + * * End language behavior *
16 39 */
17   - class BlogTag extends \yii\db\ActiveRecord
  40 + class BlogTag extends ActiveRecord
18 41 {
19 42 /**
20 43 * @inheritdoc
... ...
common/modules/blog/models/BlogTagLang.php 100644 → 100755
... ... @@ -2,7 +2,8 @@
2 2  
3 3 namespace common\modules\blog\models;
4 4  
5   -use Yii;
  5 +use common\modules\language\models\Language;
  6 +use yii\db\ActiveRecord;
6 7  
7 8 /**
8 9 * This is the model class for table "blog_tag_lang".
... ... @@ -15,7 +16,7 @@ use Yii;
15 16 * @property BlogTag $blogTag
16 17 * @property Language $language
17 18 */
18   -class BlogTagLang extends \yii\db\ActiveRecord
  19 +class BlogTagLang extends ActiveRecord
19 20 {
20 21 /**
21 22 * @inheritdoc
... ...
common/modules/blog/models/BlogTagSearch.php 100644 → 100755
common/modules/blog/views/blog-article/_form.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogArticle */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\modules\blog\models\BlogArticle;
  4 + use common\modules\blog\models\BlogArticleLang;
  5 + use common\modules\blog\models\BlogCategory;
  6 + use common\modules\blog\models\BlogTag;
  7 + use kartik\select2\Select2;
  8 + use yii\helpers\Html;
  9 + use yii\web\View;
  10 + use yii\widgets\ActiveForm;
  11 + use common\modules\language\widgets\LanguageForm;
  12 +
  13 + /**
  14 + * @var View $this
  15 + * @var BlogArticle $model
  16 + * @var ActiveForm $form
  17 + * @var BlogArticleLang[] $modelLangs
  18 + * @var BlogCategory[] $categories
  19 + * @var BlogTag[] $tags
  20 + */
9 21 ?>
10 22  
11 23 <div class="blog-article-form">
12   -
13   - <?php $form = ActiveForm::begin(); ?>
14   -
15   - <?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
16   -
17   - <?= $form->field($model, 'created_at')->textInput() ?>
18   -
19   - <?= $form->field($model, 'updated_at')->textInput() ?>
20   -
21   - <?= $form->field($model, 'deleted_at')->textInput() ?>
22   -
23   - <?= $form->field($model, 'sort')->textInput() ?>
24   -
25   - <?= $form->field($model, 'status')->checkbox() ?>
26   -
27   - <?= $form->field($model, 'author_id')->textInput() ?>
28   -
  24 +
  25 + <?php $form = ActiveForm::begin(
  26 + [
  27 + 'options' => [ 'enctype' => 'multipart/form-data' ],
  28 + ]
  29 + ); ?>
  30 +
  31 + <?php
  32 + echo LanguageForm::widget(
  33 + [
  34 + 'modelLangs' => $modelLangs,
  35 + 'formView' => '@common/modules/blog/views/blog-article/_form_language',
  36 + 'form' => $form,
  37 + ]
  38 + );
  39 + ?>
  40 +
  41 + <?php
  42 + echo $form->field($model, 'blogCategories')
  43 + ->widget(
  44 + Select2::className(),
  45 + [
  46 + 'data' => $categories,
  47 + 'theme' => Select2::THEME_BOOTSTRAP,
  48 + 'options' => [
  49 + 'placeholder' => \Yii::t('blog', 'Select category'),
  50 + 'multiple' => true,
  51 + ],
  52 + 'pluginOptions' => [
  53 + 'allowClear' => true,
  54 + ],
  55 + ]
  56 + );
  57 + ?>
  58 +
  59 + <?php
  60 + echo $form->field($model, 'blogTags')
  61 + ->widget(
  62 + Select2::className(),
  63 + [
  64 + 'data' => $tags,
  65 + 'theme' => Select2::THEME_BOOTSTRAP,
  66 + 'options' => [
  67 + 'placeholder' => \Yii::t('blog', 'Select tag'),
  68 + 'multiple' => true,
  69 + ],
  70 + 'pluginOptions' => [
  71 + 'allowClear' => true,
  72 + ],
  73 + ]
  74 + );
  75 + ?>
  76 +
  77 + <?= $form->field($model, 'image')
  78 + ->widget(
  79 + \kartik\file\FileInput::className(),
  80 + [
  81 + 'language' => 'ru',
  82 + 'options' => [
  83 + 'accept' => 'image/*',
  84 + 'multiple' => false,
  85 + ],
  86 + 'pluginOptions' => [
  87 + 'allowedFileExtensions' => [
  88 + 'jpg',
  89 + 'gif',
  90 + 'png',
  91 + ],
  92 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage(
  93 + $model->imageUrl,
  94 + 'list'
  95 + ) : '',
  96 + 'overwriteInitial' => true,
  97 + 'showRemove' => false,
  98 + 'showUpload' => false,
  99 + 'previewFileType' => 'image',
  100 + ],
  101 + ]
  102 + ); ?>
  103 +
  104 + <?= $form->field($model, 'sort')
  105 + ->textInput() ?>
  106 +
  107 + <?= $form->field($model, 'status')
  108 + ->checkbox() ?>
  109 +
  110 + <?= $form->field($model, 'author_id')
  111 + ->textInput() ?>
  112 +
29 113 <div class="form-group">
30   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  114 + <?= Html::submitButton(
  115 + $model->isNewRecord ? 'Create' : 'Update',
  116 + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
  117 + ) ?>
31 118 </div>
32   -
  119 +
33 120 <?php ActiveForm::end(); ?>
34 121  
35 122 </div>
... ...
common/modules/blog/views/blog-article/_form_language.php 0 → 100755
  1 +<?php
  2 + use common\models\ArticleLang;
  3 + use common\modules\language\models\Language;
  4 + use mihaildev\ckeditor\CKEditor;
  5 + use mihaildev\elfinder\ElFinder;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 +
  9 + /**
  10 + * @var ArticleLang $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 ]); ?>
... ...
common/modules/blog/views/blog-article/_search.php 100644 → 100755
common/modules/blog/views/blog-article/create.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogArticle */
8   -
9   -$this->title = 'Create Blog Article';
10   -$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\modules\blog\models\BlogArticle;
  4 + use common\modules\blog\models\BlogArticleLang;
  5 + use common\modules\blog\models\BlogCategory;
  6 + use common\modules\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 + */
  17 +
  18 + $this->title = 'Create Blog Article';
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => 'Blog Articles',
  21 + 'url' => [ 'index' ],
  22 + ];
  23 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 24 ?>
13 25 <div class="blog-article-create">
14   -
  26 +
15 27 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  28 +
  29 + <?= $this->render(
  30 + '_form',
  31 + [
  32 + 'model' => $model,
  33 + 'modelLangs' => $modelLangs,
  34 + 'categories' => $categories,
  35 + 'tags' => $tags,
  36 + ]
  37 + ) ?>
20 38  
21 39 </div>
... ...
common/modules/blog/views/blog-article/index.php 100644 → 100755
common/modules/blog/views/blog-article/update.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\blog\models\BlogArticle */
7   -
8   -$this->title = 'Update Blog Article: ' . $model->id;
9   -$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\modules\blog\models\BlogArticle;
  4 + use common\modules\blog\models\BlogArticleLang;
  5 + use common\modules\blog\models\BlogCategory;
  6 + use common\modules\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 + */
  17 +
  18 + $this->title = 'Update Blog Article: ' . $model->id;
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => 'Blog Articles',
  21 + 'url' => [ 'index' ],
  22 + ];
  23 + $this->params[ 'breadcrumbs' ][] = [
  24 + 'label' => $model->id,
  25 + 'url' => [
  26 + 'view',
  27 + 'id' => $model->id,
  28 + ],
  29 + ];
  30 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 31 ?>
13 32 <div class="blog-article-update">
14   -
  33 +
15 34 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  35 +
  36 + <?= $this->render(
  37 + '_form',
  38 + [
  39 + 'model' => $model,
  40 + 'modelLangs' => $modelLangs,
  41 + 'categories' => $categories,
  42 + 'tags' => $tags,
  43 + ]
  44 + ) ?>
20 45  
21 46 </div>
... ...
common/modules/blog/views/blog-article/view.php 100644 → 100755
common/modules/blog/views/blog-category/_form.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogCategory */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\modules\blog\models\BlogCategory;
  4 + use common\modules\blog\models\BlogCategoryLang;
  5 + use yii\bootstrap\Dropdown;
  6 + use yii\helpers\Html;
  7 + use yii\web\View;
  8 + use yii\widgets\ActiveForm;
  9 + use common\modules\language\widgets\LanguageForm;
  10 +
  11 + /**
  12 + * @var View $this
  13 + * @var BlogCategory $model
  14 + * @var ActiveForm $form
  15 + * @var BlogCategoryLang[] $modelLangs
  16 + * @var array $parentCategories
  17 + */
9 18 ?>
10 19  
11 20 <div class="blog-category-form">
12   -
13   - <?php $form = ActiveForm::begin(); ?>
14   -
15   - <?= $form->field($model, 'sort')->textInput() ?>
16   -
17   - <?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
18   -
19   - <?= $form->field($model, 'parent_id')->textInput() ?>
20   -
21   - <?= $form->field($model, 'status')->checkbox() ?>
22   -
  21 +
  22 + <?php $form = ActiveForm::begin(
  23 + [
  24 + 'options' => [ 'enctype' => 'multipart/form-data' ],
  25 +
  26 + ]
  27 + ); ?>
  28 +
  29 + <?php
  30 + echo LanguageForm::widget(
  31 + [
  32 + 'modelLangs' => $modelLangs,
  33 + 'formView' => '@common/modules/blog/views/blog-category/_form_language',
  34 + 'form' => $form,
  35 + ]
  36 + );
  37 + ?>
  38 +
  39 + <?= $form->field($model, 'image')
  40 + ->widget(
  41 + \kartik\file\FileInput::className(),
  42 + [
  43 + 'language' => 'ru',
  44 + 'options' => [
  45 + 'accept' => 'image/*',
  46 + 'multiple' => false,
  47 + ],
  48 + 'pluginOptions' => [
  49 + 'allowedFileExtensions' => [
  50 + 'jpg',
  51 + 'gif',
  52 + 'png',
  53 + ],
  54 + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage(
  55 + $model->imageUrl,
  56 + 'list'
  57 + ) : '',
  58 + 'overwriteInitial' => true,
  59 + 'showRemove' => false,
  60 + 'showUpload' => false,
  61 + 'previewFileType' => 'image',
  62 + ],
  63 + ]
  64 + ); ?>
  65 +
  66 + <?= $form->field($model, 'sort')
  67 + ->textInput() ?>
  68 +
  69 + <?= $form->field($model, 'parent_id')
  70 + ->dropDownList($parentCategories, [
  71 + 'prompt' => \Yii::t('blog', 'Has no parent rubric'),
  72 + ]) ?>
  73 +
  74 + <?= $form->field($model, 'status')
  75 + ->checkbox() ?>
  76 +
23 77 <div class="form-group">
24   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  78 + <?= Html::submitButton(
  79 + $model->isNewRecord ? 'Create' : 'Update',
  80 + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
  81 + ) ?>
25 82 </div>
26   -
  83 +
27 84 <?php ActiveForm::end(); ?>
28 85  
29 86 </div>
... ...
common/modules/blog/views/blog-category/_form_language.php 0 → 100755
  1 +<?php
  2 + use common\models\ArticleLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var ArticleLang $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 ]); ?>
... ...
common/modules/blog/views/blog-category/_search.php 100644 → 100755
common/modules/blog/views/blog-category/create.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogCategory */
8   -
9   -$this->title = 'Create Blog Category';
10   -$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\modules\blog\models\BlogArticleLang;
  4 + use common\modules\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 = 'Create Blog Category';
  16 + $this->params[ 'breadcrumbs' ][] = [
  17 + 'label' => 'Blog Categories',
  18 + 'url' => [ 'index' ],
  19 + ];
  20 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 21 ?>
13 22 <div class="blog-category-create">
14   -
  23 +
15 24 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  25 +
  26 + <?= $this->render(
  27 + '_form',
  28 + [
  29 + 'model' => $model,
  30 + 'modelLangs' => $modelLangs,
  31 + 'parentCategories' => $parentCategories,
  32 + ]
  33 + ) ?>
20 34  
21 35 </div>
... ...
common/modules/blog/views/blog-category/index.php 100644 → 100755
common/modules/blog/views/blog-category/update.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\blog\models\BlogCategory */
7   -
8   -$this->title = 'Update Blog Category: ' . $model->id;
9   -$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\modules\blog\models\BlogCategory;
  4 + use common\modules\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 = 'Update Blog Category: ' . $model->id;
  16 + $this->params[ 'breadcrumbs' ][] = [
  17 + 'label' => 'Blog Categories',
  18 + 'url' => [ 'index' ],
  19 + ];
  20 + $this->params[ 'breadcrumbs' ][] = [
  21 + 'label' => $model->id,
  22 + 'url' => [
  23 + 'view',
  24 + 'id' => $model->id,
  25 + ],
  26 + ];
  27 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 28 ?>
13 29 <div class="blog-category-update">
14   -
  30 +
15 31 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  32 +
  33 + <?= $this->render(
  34 + '_form',
  35 + [
  36 + 'model' => $model,
  37 + 'modelLangs' => $modelLangs,
  38 + 'parentCategories' => $parentCategories,
  39 + ]
  40 + ) ?>
20 41  
21 42 </div>
... ...
common/modules/blog/views/blog-category/view.php 100644 → 100755
common/modules/blog/views/blog-tag/_form.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogTag */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use common\modules\blog\models\BlogTag;
  4 + use common\modules\blog\models\BlogTagLang;
  5 + use yii\helpers\Html;
  6 + use yii\web\View;
  7 + use yii\widgets\ActiveForm;
  8 + use common\modules\language\widgets\LanguageForm;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var BlogTag $model
  13 + * @var ActiveForm $form
  14 + * @var BlogTagLang[] $modelLangs
  15 + */
9 16 ?>
10 17  
11 18 <div class="blog-tag-form">
12   -
  19 +
13 20 <?php $form = ActiveForm::begin(); ?>
14   -
15   - <?= $form->field($model, 'id')->textInput() ?>
16   -
  21 +
  22 + <?php
  23 + echo LanguageForm::widget(
  24 + [
  25 + 'modelLangs' => $modelLangs,
  26 + 'formView' => '@common/modules/blog/views/blog-tag/_form_language',
  27 + 'form' => $form,
  28 + ]
  29 + );
  30 + ?>
  31 +
17 32 <div class="form-group">
18   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  33 + <?= Html::submitButton(
  34 + $model->isNewRecord ? 'Create' : 'Update',
  35 + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
  36 + ) ?>
19 37 </div>
20   -
  38 +
21 39 <?php ActiveForm::end(); ?>
22 40  
23 41 </div>
... ...
common/modules/blog/views/blog-tag/_form_language.php 0 → 100755
  1 +<?php
  2 + use common\models\ArticleLang;
  3 + use common\modules\language\models\Language;
  4 + use yii\web\View;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /**
  8 + * @var ArticleLang $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 ]); ?>
... ...
common/modules/blog/views/blog-tag/_search.php 100644 → 100755
common/modules/blog/views/blog-tag/create.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\blog\models\BlogTag */
8   -
9   -$this->title = 'Create Blog Tag';
10   -$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use common\modules\blog\models\BlogTag;
  4 + use common\modules\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 = 'Create Blog Tag';
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Blog Tags',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 20 ?>
13 21 <div class="blog-tag-create">
14   -
  22 +
15 23 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  24 +
  25 + <?= $this->render(
  26 + '_form',
  27 + [
  28 + 'model' => $model,
  29 + 'modelLangs' => $modelLangs,
  30 + ]
  31 + ) ?>
20 32  
21 33 </div>
... ...
common/modules/blog/views/blog-tag/index.php 100644 → 100755
common/modules/blog/views/blog-tag/update.php 100644 → 100755
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\blog\models\BlogTag */
7   -
8   -$this->title = 'Update Blog Tag: ' . $model->id;
9   -$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
11   -$this->params['breadcrumbs'][] = 'Update';
  2 +
  3 + use common\modules\blog\models\BlogTag;
  4 + use common\modules\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 = 'Update Blog Tag: ' . $model->id;
  15 + $this->params[ 'breadcrumbs' ][] = [
  16 + 'label' => 'Blog Tags',
  17 + 'url' => [ 'index' ],
  18 + ];
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => $model->id,
  21 + 'url' => [
  22 + 'view',
  23 + 'id' => $model->id,
  24 + ],
  25 + ];
  26 + $this->params[ 'breadcrumbs' ][] = 'Update';
12 27 ?>
13 28 <div class="blog-tag-update">
14   -
  29 +
15 30 <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
  31 +
  32 + <?= $this->render(
  33 + '_form',
  34 + [
  35 + 'model' => $model,
  36 + 'modelLangs' => $modelLangs,
  37 + ]
  38 + ) ?>
20 39  
21 40 </div>
... ...
common/modules/blog/views/blog-tag/view.php 100644 → 100755
common/modules/blog/views/default/index.php 100644 → 100755
common/translation/ru/blog.php 0 → 100644
  1 +<?php
  2 + return [
  3 + 'Select category' => 'Выберите категорию ...',
  4 + 'Select tag' => 'Выберите тэг ...',
  5 + 'Has no parent rubric' => 'Без категории',
  6 + ];
0 7 \ No newline at end of file
... ...
storage/.htaccess
... ... @@ -3,4 +3,4 @@ RewriteBase /
3 3 RewriteCond %{REQUEST_FILENAME} !-f
4 4 RewriteCond %{REQUEST_FILENAME} !-d
5 5  
6   -RewriteRule . index.php
  6 +
... ...