From 52190232b988d3a26c9b2f67b81d1f1ffdf1f24d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 2 Nov 2016 19:45:33 +0200 Subject: [PATCH] -Blog almost done --- backend/views/layouts/main-sidebar.php | 5 ++++- common/config/main.php | 10 ++++++++-- common/modules/blog/Module.php | 0 common/modules/blog/controllers/BlogArticleController.php | 350 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------- common/modules/blog/controllers/BlogCategoryController.php | 307 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------- common/modules/blog/controllers/BlogTagController.php | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------- common/modules/blog/controllers/DefaultController.php | 0 common/modules/blog/models/BlogArticle.php | 46 +++++++++++++++++++++++++++++++++++++++++++++- common/modules/blog/models/BlogArticleLang.php | 11 ++++++++++- common/modules/blog/models/BlogArticleSearch.php | 0 common/modules/blog/models/BlogCategory.php | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- common/modules/blog/models/BlogCategoryLang.php | 14 ++++++++++++-- common/modules/blog/models/BlogCategorySearch.php | 0 common/modules/blog/models/BlogTag.php | 25 ++++++++++++++++++++++++- common/modules/blog/models/BlogTagLang.php | 5 +++-- common/modules/blog/models/BlogTagSearch.php | 0 common/modules/blog/views/blog-article/_form.php | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- common/modules/blog/views/blog-article/_form_language.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-article/_search.php | 0 common/modules/blog/views/blog-article/create.php | 48 +++++++++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-article/index.php | 0 common/modules/blog/views/blog-article/update.php | 55 ++++++++++++++++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-article/view.php | 0 common/modules/blog/views/blog-category/_form.php | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- common/modules/blog/views/blog-category/_form_language.php | 37 +++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-category/_search.php | 0 common/modules/blog/views/blog-category/create.php | 44 +++++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-category/index.php | 0 common/modules/blog/views/blog-category/update.php | 51 ++++++++++++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-category/view.php | 0 common/modules/blog/views/blog-tag/_form.php | 44 +++++++++++++++++++++++++++++++------------- common/modules/blog/views/blog-tag/_form_language.php | 15 +++++++++++++++ common/modules/blog/views/blog-tag/_search.php | 0 common/modules/blog/views/blog-tag/create.php | 42 +++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-tag/index.php | 0 common/modules/blog/views/blog-tag/update.php | 49 ++++++++++++++++++++++++++++++++++--------------- common/modules/blog/views/blog-tag/view.php | 0 common/modules/blog/views/default/index.php | 0 common/translation/ru/blog.php | 6 ++++++ storage/.htaccess | 2 +- 40 files changed, 1275 insertions(+), 506 deletions(-) mode change 100644 => 100755 common/modules/blog/Module.php mode change 100644 => 100755 common/modules/blog/controllers/BlogArticleController.php mode change 100644 => 100755 common/modules/blog/controllers/BlogCategoryController.php mode change 100644 => 100755 common/modules/blog/controllers/BlogTagController.php mode change 100644 => 100755 common/modules/blog/controllers/DefaultController.php mode change 100644 => 100755 common/modules/blog/models/BlogArticle.php mode change 100644 => 100755 common/modules/blog/models/BlogArticleLang.php mode change 100644 => 100755 common/modules/blog/models/BlogArticleSearch.php mode change 100644 => 100755 common/modules/blog/models/BlogCategory.php mode change 100644 => 100755 common/modules/blog/models/BlogCategoryLang.php mode change 100644 => 100755 common/modules/blog/models/BlogCategorySearch.php mode change 100644 => 100755 common/modules/blog/models/BlogTag.php mode change 100644 => 100755 common/modules/blog/models/BlogTagLang.php mode change 100644 => 100755 common/modules/blog/models/BlogTagSearch.php mode change 100644 => 100755 common/modules/blog/views/blog-article/_form.php create mode 100755 common/modules/blog/views/blog-article/_form_language.php mode change 100644 => 100755 common/modules/blog/views/blog-article/_search.php mode change 100644 => 100755 common/modules/blog/views/blog-article/create.php mode change 100644 => 100755 common/modules/blog/views/blog-article/index.php mode change 100644 => 100755 common/modules/blog/views/blog-article/update.php mode change 100644 => 100755 common/modules/blog/views/blog-article/view.php mode change 100644 => 100755 common/modules/blog/views/blog-category/_form.php create mode 100755 common/modules/blog/views/blog-category/_form_language.php mode change 100644 => 100755 common/modules/blog/views/blog-category/_search.php mode change 100644 => 100755 common/modules/blog/views/blog-category/create.php mode change 100644 => 100755 common/modules/blog/views/blog-category/index.php mode change 100644 => 100755 common/modules/blog/views/blog-category/update.php mode change 100644 => 100755 common/modules/blog/views/blog-category/view.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/_form.php create mode 100755 common/modules/blog/views/blog-tag/_form_language.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/_search.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/create.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/index.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/update.php mode change 100644 => 100755 common/modules/blog/views/blog-tag/view.php mode change 100644 => 100755 common/modules/blog/views/default/index.php create mode 100644 common/translation/ru/blog.php diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index 0bb4414..a37cf74 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -122,7 +122,7 @@ use yii\widgets\Menu; ], [ 'label' => 'Блог', - 'template'=>' {label}', + 'template'=>' {label}', 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], 'active' => preg_match('/^blog.*$/', $this->context->id) ? true : false, 'items' => [ @@ -130,16 +130,19 @@ use yii\widgets\Menu; 'label' => 'Статьи', 'url' => ['/blog/blog-article'], 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + 'active' => preg_match('/.*blog-article.*$/', $this->context->id), ], [ 'label' => 'Рубрики', 'url' => ['/blog/blog-category'], 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + 'active' => preg_match('/.*blog-category.*$/', $this->context->id), ], [ 'label' => 'Тэги', 'url' => ['/blog/blog-tag'], 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + 'active' => preg_match('/.*blog-tag.*$/', $this->context->id), ], ] ], diff --git a/common/config/main.php b/common/config/main.php index a420928..b539e83 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -43,6 +43,12 @@ 'master' => NULL, ], ], + 'list' => [ + 'resize' => [ + 'width' => 360, + 'height' => 360, + ], + ], ], ], 'basket' => [ @@ -53,8 +59,8 @@ 'artbox-comment' => [ 'class' => 'common\modules\comment\Module', ], - 'blog' => [ - 'class' => 'common\modules\blog\Module' + 'blog' => [ + 'class' => 'common\modules\blog\Module', ], ], ]; diff --git a/common/modules/blog/Module.php b/common/modules/blog/Module.php old mode 100644 new mode 100755 index cd85726..cd85726 --- a/common/modules/blog/Module.php +++ b/common/modules/blog/Module.php diff --git a/common/modules/blog/controllers/BlogArticleController.php b/common/modules/blog/controllers/BlogArticleController.php old mode 100644 new mode 100755 index 8c0976b..6564bb0 --- a/common/modules/blog/controllers/BlogArticleController.php +++ b/common/modules/blog/controllers/BlogArticleController.php @@ -1,124 +1,244 @@ [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], ], - ], - ]; - } - - /** - * Lists all BlogArticle models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new BlogArticleSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single BlogArticle model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new BlogArticle model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new BlogArticle(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); + ]; } - } - - /** - * Updates an existing BlogArticle model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Lists all BlogArticle models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogArticleSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); } - } - - /** - * Deletes an existing BlogArticle model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the BlogArticle model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return BlogArticle the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = BlogArticle::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + /** + * Displays a single BlogArticle model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogArticle model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogArticle(); + $model->generateLangs(); + + $categories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.title' + ); + + $tags = ArrayHelper::map( + BlogTag::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.label' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { + if ($category = BlogCategory::findOne($item)) { + $model->link('blogCategories', $category); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { + if ($category = BlogTag::findOne($item)) { + $model->link('blogTags', $category); + } + } + } + + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'categories' => $categories, + 'tags' => $tags, + ] + ); + + } + + /** + * Updates an existing BlogArticle model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + $categories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.title' + ); + + $tags = ArrayHelper::map( + BlogTag::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.label' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { + $model->unlinkAll('blogCategories', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { + if ($category = BlogCategory::findOne($item)) { + $model->link('blogCategories', $category); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { + $model->unlinkAll('blogTags', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { + if ($category = BlogTag::findOne($item)) { + $model->link('blogTags', $category); + } + } + } + + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'categories' => $categories, + 'tags' => $tags, + ] + ); + + } + + /** + * Deletes an existing BlogArticle model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogArticle model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogArticle the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogArticle::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } } -} diff --git a/common/modules/blog/controllers/BlogCategoryController.php b/common/modules/blog/controllers/BlogCategoryController.php old mode 100644 new mode 100755 index c1cddee..a210985 --- a/common/modules/blog/controllers/BlogCategoryController.php +++ b/common/modules/blog/controllers/BlogCategoryController.php @@ -1,124 +1,201 @@ [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], ], - ], - ]; - } - - /** - * Lists all BlogCategory models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new BlogCategorySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single BlogCategory model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new BlogCategory model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new BlogCategory(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); + ]; } - } - - /** - * Updates an existing BlogCategory model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Lists all BlogCategory models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); } - } - - /** - * Deletes an existing BlogCategory model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the BlogCategory model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return BlogCategory the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = BlogCategory::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + /** + * Displays a single BlogCategory model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogCategory(); + $model->generateLangs(); + $parentCategories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->where( + [ + 'parent_id' => 0, + ] + ) + ->all(), + 'id', + 'lang.title' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'parentCategories' => $parentCategories, + ] + ); + + } + + /** + * Updates an existing BlogCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + $parentCategories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->where( + [ + 'parent_id' => 0, + ] + ) + ->andWhere( + [ + '!=', + BlogCategory::tableName() . '_id', + $model->id, + ] + ) + ->all(), + 'id', + 'lang.title' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'parentCategories' => $parentCategories, + ] + ); + + } + + /** + * Deletes an existing BlogCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogCategory::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } } -} diff --git a/common/modules/blog/controllers/BlogTagController.php b/common/modules/blog/controllers/BlogTagController.php old mode 100644 new mode 100755 index 48020a0..365b626 --- a/common/modules/blog/controllers/BlogTagController.php +++ b/common/modules/blog/controllers/BlogTagController.php @@ -1,124 +1,169 @@ [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], ], - ], - ]; - } - - /** - * Lists all BlogTag models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new BlogTagSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single BlogTag model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new BlogTag model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new BlogTag(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); + ]; } - } - - /** - * Updates an existing BlogTag model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); + + /** + * Lists all BlogTag models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogTagSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); } - } - - /** - * Deletes an existing BlogTag model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the BlogTag model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return BlogTag the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = BlogTag::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + /** + * Displays a single BlogTag model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogTag model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogTag(); + $model->generateLangs(); + + if (\Yii::$app->request->isPost) { + $model->loadLangs(\Yii::$app->request); + $model->markAttributeDirty('id'); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + + } + + /** + * Updates an existing BlogTag model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + if (Yii::$app->request->isPost) { + $model->loadLangs(\Yii::$app->request); + $model->markAttributeDirty('id'); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + + } + + /** + * Deletes an existing BlogTag model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogTag model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogTag the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogTag::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } } -} diff --git a/common/modules/blog/controllers/DefaultController.php b/common/modules/blog/controllers/DefaultController.php old mode 100644 new mode 100755 index 7cad6b8..7cad6b8 --- a/common/modules/blog/controllers/DefaultController.php +++ b/common/modules/blog/controllers/DefaultController.php diff --git a/common/modules/blog/models/BlogArticle.php b/common/modules/blog/models/BlogArticle.php old mode 100644 new mode 100755 index 4a5b2be..2070668 --- a/common/modules/blog/models/BlogArticle.php +++ b/common/modules/blog/models/BlogArticle.php @@ -2,8 +2,14 @@ namespace common\modules\blog\models; + use common\behaviors\SaveImgBehavior; + use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; use common\modules\language\behaviors\LanguageBehavior; + use common\modules\language\models\Language; + use common\modules\product\models\Product; + use yii\db\ActiveQuery; + use yii\web\Request; /** * This is the model class for table "blog_article". @@ -28,6 +34,32 @@ * @property Product[] $products * @property BlogArticleToTag[] $blogArticleToTags * @property BlogTag[] $blogTags + * * * From language behavior * + * @property BlogArticleLang $lang + * @property BlogArticleLang[] $langs + * @property BlogArticleLang $objectLang + * @property string $ownerKey + * @property string $langKey + * @property BlogArticleLang[] $modelLangs + * @property bool $transactionStatus + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method BlogArticleLang[] generateLangs() + * @method void loadLangs( Request $request ) + * @method bool linkLangs() + * @method bool saveLangs() + * @method bool getTransactionStatus() + * * End language behavior * + * * From SaveImgBehavior + * @property string|null $imageFile + * @property string|null $imageUrl + * @method string|null getImageFile( int $field ) + * @method string|null getImageUrl( int $field ) + * * End SaveImgBehavior */ class BlogArticle extends ActiveRecord { @@ -42,8 +74,20 @@ public function behaviors() { return [ + [ + 'class' => TimestampBehavior::className(), + ], + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'blog/article', + ], + ], + ], 'language' => [ - 'class' => LanguageBehavior::className(), + 'class' => LanguageBehavior::className(), ], ]; } diff --git a/common/modules/blog/models/BlogArticleLang.php b/common/modules/blog/models/BlogArticleLang.php old mode 100644 new mode 100755 index f366f0e..29e8047 --- a/common/modules/blog/models/BlogArticleLang.php +++ b/common/modules/blog/models/BlogArticleLang.php @@ -32,7 +32,16 @@ class BlogArticleLang extends ActiveRecord { return 'blog_article_lang'; } - + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + ], + ]; + } + /** * @inheritdoc */ diff --git a/common/modules/blog/models/BlogArticleSearch.php b/common/modules/blog/models/BlogArticleSearch.php old mode 100644 new mode 100755 index 1cb352e..1cb352e --- a/common/modules/blog/models/BlogArticleSearch.php +++ b/common/modules/blog/models/BlogArticleSearch.php diff --git a/common/modules/blog/models/BlogCategory.php b/common/modules/blog/models/BlogCategory.php old mode 100644 new mode 100755 index 7b2dfa1..a8a29b5 --- a/common/modules/blog/models/BlogCategory.php +++ b/common/modules/blog/models/BlogCategory.php @@ -4,6 +4,10 @@ use yii\db\ActiveRecord; use common\modules\language\behaviors\LanguageBehavior; + use common\behaviors\SaveImgBehavior; + use common\modules\language\models\Language; + use yii\db\ActiveQuery; + use yii\web\Request; /** * This is the model class for table "blog_category". @@ -17,6 +21,32 @@ * @property BlogArticle[] $blogArticles * @property BlogCategoryLang[] $blogCategoryLangs * @property Language[] $languages + * * From language behavior * + * @property BlogCategoryLang $lang + * @property BlogCategoryLang[] $langs + * @property BlogCategoryLang $objectLang + * @property string $ownerKey + * @property string $langKey + * @property BlogCategoryLang[] $modelLangs + * @property bool $transactionStatus + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method BlogCategoryLang[] generateLangs() + * @method void loadLangs( Request $request ) + * @method bool linkLangs() + * @method bool saveLangs() + * @method bool getTransactionStatus() + * * End language behavior * + * * From SaveImgBehavior * + * @property string|null $imageFile + * @property string|null $imageUrl + * @method string|null getImageFile( int $field ) + * @method string|null getImageUrl( int $field ) + * * End SaveImgBehavior */ class BlogCategory extends ActiveRecord { @@ -27,16 +57,28 @@ { return 'blog_category'; } - + /** * @inheritdoc */ public function behaviors() { return [ + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'blog/category', + ], + ], + ], 'language' => [ 'class' => LanguageBehavior::className(), ], + 'Slug' => [ + 'class' => 'common\behaviors\Slug', + ], ]; } @@ -62,6 +104,11 @@ 'string', 'max' => 255, ], + [ + ['parent_id'], + 'default', + 'value' => 0, + ], ]; } diff --git a/common/modules/blog/models/BlogCategoryLang.php b/common/modules/blog/models/BlogCategoryLang.php old mode 100644 new mode 100755 index 0bf559a..4b98c1b --- a/common/modules/blog/models/BlogCategoryLang.php +++ b/common/modules/blog/models/BlogCategoryLang.php @@ -2,7 +2,8 @@ namespace common\modules\blog\models; -use Yii; +use yii\db\ActiveRecord; +use common\modules\language\models\Language; /** * This is the model class for table "blog_category_lang". @@ -21,7 +22,7 @@ use Yii; * @property BlogCategory $blogCategory * @property Language $language */ -class BlogCategoryLang extends \yii\db\ActiveRecord +class BlogCategoryLang extends ActiveRecord { /** * @inheritdoc @@ -31,6 +32,15 @@ class BlogCategoryLang extends \yii\db\ActiveRecord return 'blog_category_lang'; } + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + ], + ]; + } + /** * @inheritdoc */ diff --git a/common/modules/blog/models/BlogCategorySearch.php b/common/modules/blog/models/BlogCategorySearch.php old mode 100644 new mode 100755 index a674c7a..a674c7a --- a/common/modules/blog/models/BlogCategorySearch.php +++ b/common/modules/blog/models/BlogCategorySearch.php diff --git a/common/modules/blog/models/BlogTag.php b/common/modules/blog/models/BlogTag.php old mode 100644 new mode 100755 index 6a3a0be..035ac5c --- a/common/modules/blog/models/BlogTag.php +++ b/common/modules/blog/models/BlogTag.php @@ -4,6 +4,9 @@ use yii\db\ActiveRecord; use common\modules\language\behaviors\LanguageBehavior; + use common\modules\language\models\Language; + use yii\db\ActiveQuery; + use yii\web\Request; /** * This is the model class for table "blog_tag". @@ -13,8 +16,28 @@ * @property BlogArticle[] $blogArticles * @property BlogTagLang[] $blogTagLangs * @property Language[] $languages + * * From language behavior * + * @property BlogTagLang $lang + * @property BlogTagLang[] $langs + * @property BlogTagLang $objectLang + * @property string $ownerKey + * @property string $langKey + * @property BlogTagLang[] $modelLangs + * @property bool $transactionStatus + * @method string getOwnerKey() + * @method void setOwnerKey(string $value) + * @method string getLangKey() + * @method void setLangKey(string $value) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method BlogTagLang[] generateLangs() + * @method void loadLangs(Request $request) + * @method bool linkLangs() + * @method bool saveLangs() + * @method bool getTransactionStatus() + * * End language behavior * */ - class BlogTag extends \yii\db\ActiveRecord + class BlogTag extends ActiveRecord { /** * @inheritdoc diff --git a/common/modules/blog/models/BlogTagLang.php b/common/modules/blog/models/BlogTagLang.php old mode 100644 new mode 100755 index 26de932..55c4559 --- a/common/modules/blog/models/BlogTagLang.php +++ b/common/modules/blog/models/BlogTagLang.php @@ -2,7 +2,8 @@ namespace common\modules\blog\models; -use Yii; +use common\modules\language\models\Language; +use yii\db\ActiveRecord; /** * This is the model class for table "blog_tag_lang". @@ -15,7 +16,7 @@ use Yii; * @property BlogTag $blogTag * @property Language $language */ -class BlogTagLang extends \yii\db\ActiveRecord +class BlogTagLang extends ActiveRecord { /** * @inheritdoc diff --git a/common/modules/blog/models/BlogTagSearch.php b/common/modules/blog/models/BlogTagSearch.php old mode 100644 new mode 100755 index 1380599..1380599 --- a/common/modules/blog/models/BlogTagSearch.php +++ b/common/modules/blog/models/BlogTagSearch.php diff --git a/common/modules/blog/views/blog-article/_form.php b/common/modules/blog/views/blog-article/_form.php old mode 100644 new mode 100755 index 31fce7b..de57743 --- a/common/modules/blog/views/blog-article/_form.php +++ b/common/modules/blog/views/blog-article/_form.php @@ -1,35 +1,122 @@
- - - - field($model, 'image')->textInput(['maxlength' => true]) ?> - - field($model, 'created_at')->textInput() ?> - - field($model, 'updated_at')->textInput() ?> - - field($model, 'deleted_at')->textInput() ?> - - field($model, 'sort')->textInput() ?> - - field($model, 'status')->checkbox() ?> - - field($model, 'author_id')->textInput() ?> - + + [ 'enctype' => 'multipart/form-data' ], + ] + ); ?> + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-article/_form_language', + 'form' => $form, + ] + ); + ?> + + field($model, 'blogCategories') + ->widget( + Select2::className(), + [ + 'data' => $categories, + 'theme' => Select2::THEME_BOOTSTRAP, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select category'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> + + field($model, 'blogTags') + ->widget( + Select2::className(), + [ + 'data' => $tags, + 'theme' => Select2::THEME_BOOTSTRAP, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select tag'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + + field($model, 'sort') + ->textInput() ?> + + field($model, 'status') + ->checkbox() ?> + + field($model, 'author_id') + ->textInput() ?> +
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?>
- +
diff --git a/common/modules/blog/views/blog-article/_form_language.php b/common/modules/blog/views/blog-article/_form_language.php new file mode 100755 index 0000000..cd5583e --- /dev/null +++ b/common/modules/blog/views/blog-article/_form_language.php @@ -0,0 +1,55 @@ + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']body') + ->widget( + CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions( + 'elfinder', + [ + 'preset' => 'full', + 'inline' => false, + 'filebrowserUploadUrl' => Yii::$app->getUrlManager() + ->createUrl('file/uploader/images-upload'), + ] + ), + ] + ) ?> + +field($model_lang, '[' . $language->id . ']body_preview') + ->textarea( + [ + 'rows' => '10', + ] + ) ?> + +field($model_lang, '[' . $language->id . ']meta_title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']meta_description') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']seo_text') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']h1') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/common/modules/blog/views/blog-article/_search.php b/common/modules/blog/views/blog-article/_search.php old mode 100644 new mode 100755 index b644a88..b644a88 --- a/common/modules/blog/views/blog-article/_search.php +++ b/common/modules/blog/views/blog-article/_search.php diff --git a/common/modules/blog/views/blog-article/create.php b/common/modules/blog/views/blog-article/create.php old mode 100644 new mode 100755 index a1daa8b..82025e3 --- a/common/modules/blog/views/blog-article/create.php +++ b/common/modules/blog/views/blog-article/create.php @@ -1,21 +1,39 @@ title = 'Create Blog Article'; -$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogArticle; + use common\modules\blog\models\BlogArticleLang; + use common\modules\blog\models\BlogCategory; + use common\modules\blog\models\BlogTag; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogArticle $model + * @var BlogArticleLang[] $modelLangs + * @var BlogCategory[] $categories + * @var BlogTag[] $tags + */ + + $this->title = 'Create Blog Article'; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Articles', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'categories' => $categories, + 'tags' => $tags, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-article/index.php b/common/modules/blog/views/blog-article/index.php old mode 100644 new mode 100755 index b86118b..b86118b --- a/common/modules/blog/views/blog-article/index.php +++ b/common/modules/blog/views/blog-article/index.php diff --git a/common/modules/blog/views/blog-article/update.php b/common/modules/blog/views/blog-article/update.php old mode 100644 new mode 100755 index bc50d0e..ac146d8 --- a/common/modules/blog/views/blog-article/update.php +++ b/common/modules/blog/views/blog-article/update.php @@ -1,21 +1,46 @@ title = 'Update Blog Article: ' . $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update'; + + use common\modules\blog\models\BlogArticle; + use common\modules\blog\models\BlogArticleLang; + use common\modules\blog\models\BlogCategory; + use common\modules\blog\models\BlogTag; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogArticle $model + * @var BlogArticleLang[] $modelLangs + * @var BlogCategory[] $categories + * @var BlogTag[] $tags + */ + + $this->title = 'Update Blog Article: ' . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Articles', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = 'Update'; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'categories' => $categories, + 'tags' => $tags, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-article/view.php b/common/modules/blog/views/blog-article/view.php old mode 100644 new mode 100755 index 3433737..3433737 --- a/common/modules/blog/views/blog-article/view.php +++ b/common/modules/blog/views/blog-article/view.php diff --git a/common/modules/blog/views/blog-category/_form.php b/common/modules/blog/views/blog-category/_form.php old mode 100644 new mode 100755 index 7d39dc4..f8534b7 --- a/common/modules/blog/views/blog-category/_form.php +++ b/common/modules/blog/views/blog-category/_form.php @@ -1,29 +1,86 @@
- - - - field($model, 'sort')->textInput() ?> - - field($model, 'image')->textInput(['maxlength' => true]) ?> - - field($model, 'parent_id')->textInput() ?> - - field($model, 'status')->checkbox() ?> - + + [ 'enctype' => 'multipart/form-data' ], + + ] + ); ?> + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-category/_form_language', + 'form' => $form, + ] + ); + ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + + field($model, 'sort') + ->textInput() ?> + + field($model, 'parent_id') + ->dropDownList($parentCategories, [ + 'prompt' => \Yii::t('blog', 'Has no parent rubric'), + ]) ?> + + field($model, 'status') + ->checkbox() ?> +
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?>
- +
diff --git a/common/modules/blog/views/blog-category/_form_language.php b/common/modules/blog/views/blog-category/_form_language.php new file mode 100755 index 0000000..7da5d86 --- /dev/null +++ b/common/modules/blog/views/blog-category/_form_language.php @@ -0,0 +1,37 @@ + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']description') + ->textarea( + [ + 'rows' => '10', + ] + ) ?> + +field($model_lang, '[' . $language->id . ']meta_title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']meta_description') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']seo_text') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']h1') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/common/modules/blog/views/blog-category/_search.php b/common/modules/blog/views/blog-category/_search.php old mode 100644 new mode 100755 index b79d09d..b79d09d --- a/common/modules/blog/views/blog-category/_search.php +++ b/common/modules/blog/views/blog-category/_search.php diff --git a/common/modules/blog/views/blog-category/create.php b/common/modules/blog/views/blog-category/create.php old mode 100644 new mode 100755 index 7aaa171..8959883 --- a/common/modules/blog/views/blog-category/create.php +++ b/common/modules/blog/views/blog-category/create.php @@ -1,21 +1,35 @@ title = 'Create Blog Category'; -$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogArticleLang; + use common\modules\blog\models\BlogCategory; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogCategory $model + * @var BlogArticleLang[] $modelLangs + * @var array $parentCategories + */ + + $this->title = 'Create Blog Category'; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Categories', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'parentCategories' => $parentCategories, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-category/index.php b/common/modules/blog/views/blog-category/index.php old mode 100644 new mode 100755 index 35009ba..35009ba --- a/common/modules/blog/views/blog-category/index.php +++ b/common/modules/blog/views/blog-category/index.php diff --git a/common/modules/blog/views/blog-category/update.php b/common/modules/blog/views/blog-category/update.php old mode 100644 new mode 100755 index 517b140..f17da1c --- a/common/modules/blog/views/blog-category/update.php +++ b/common/modules/blog/views/blog-category/update.php @@ -1,21 +1,42 @@ title = 'Update Blog Category: ' . $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update'; + + use common\modules\blog\models\BlogCategory; + use common\modules\blog\models\BlogCategoryLang; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogCategory $model + * @var BlogCategoryLang $modelLangs + * @var array $parentCategories + */ + + $this->title = 'Update Blog Category: ' . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Categories', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = 'Update'; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'parentCategories' => $parentCategories, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-category/view.php b/common/modules/blog/views/blog-category/view.php old mode 100644 new mode 100755 index 512bb4c..512bb4c --- a/common/modules/blog/views/blog-category/view.php +++ b/common/modules/blog/views/blog-category/view.php diff --git a/common/modules/blog/views/blog-tag/_form.php b/common/modules/blog/views/blog-tag/_form.php old mode 100644 new mode 100755 index 0fde157..e257df5 --- a/common/modules/blog/views/blog-tag/_form.php +++ b/common/modules/blog/views/blog-tag/_form.php @@ -1,23 +1,41 @@
- + - - field($model, 'id')->textInput() ?> - + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-tag/_form_language', + 'form' => $form, + ] + ); + ?> +
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?>
- +
diff --git a/common/modules/blog/views/blog-tag/_form_language.php b/common/modules/blog/views/blog-tag/_form_language.php new file mode 100755 index 0000000..d1fc0a1 --- /dev/null +++ b/common/modules/blog/views/blog-tag/_form_language.php @@ -0,0 +1,15 @@ + +field($model_lang, '[' . $language->id . ']label') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/common/modules/blog/views/blog-tag/_search.php b/common/modules/blog/views/blog-tag/_search.php old mode 100644 new mode 100755 index 32b4064..32b4064 --- a/common/modules/blog/views/blog-tag/_search.php +++ b/common/modules/blog/views/blog-tag/_search.php diff --git a/common/modules/blog/views/blog-tag/create.php b/common/modules/blog/views/blog-tag/create.php old mode 100644 new mode 100755 index d6ef692..e57e010 --- a/common/modules/blog/views/blog-tag/create.php +++ b/common/modules/blog/views/blog-tag/create.php @@ -1,21 +1,33 @@ title = 'Create Blog Tag'; -$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogTag; + use common\modules\blog\models\BlogTagLang; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogTagLang[] $modelLangs + * @var BlogTag $model + */ + + $this->title = 'Create Blog Tag'; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Tags', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-tag/index.php b/common/modules/blog/views/blog-tag/index.php old mode 100644 new mode 100755 index 8ebb5c6..8ebb5c6 --- a/common/modules/blog/views/blog-tag/index.php +++ b/common/modules/blog/views/blog-tag/index.php diff --git a/common/modules/blog/views/blog-tag/update.php b/common/modules/blog/views/blog-tag/update.php old mode 100644 new mode 100755 index a327332..539bd6f --- a/common/modules/blog/views/blog-tag/update.php +++ b/common/modules/blog/views/blog-tag/update.php @@ -1,21 +1,40 @@ title = 'Update Blog Tag: ' . $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update'; + + use common\modules\blog\models\BlogTag; + use common\modules\blog\models\BlogTagLang; + use yii\helpers\Html; + use yii\web\View; + + /** + * @var View $this + * @var BlogTagLang[] $modelLangs + * @var BlogTag $model + */ + + $this->title = 'Update Blog Tag: ' . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Blog Tags', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = 'Update'; ?>
- +

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?>
diff --git a/common/modules/blog/views/blog-tag/view.php b/common/modules/blog/views/blog-tag/view.php old mode 100644 new mode 100755 index 28c02c8..28c02c8 --- a/common/modules/blog/views/blog-tag/view.php +++ b/common/modules/blog/views/blog-tag/view.php diff --git a/common/modules/blog/views/default/index.php b/common/modules/blog/views/default/index.php old mode 100644 new mode 100755 index 650b9c5..650b9c5 --- a/common/modules/blog/views/default/index.php +++ b/common/modules/blog/views/default/index.php diff --git a/common/translation/ru/blog.php b/common/translation/ru/blog.php new file mode 100644 index 0000000..506124e --- /dev/null +++ b/common/translation/ru/blog.php @@ -0,0 +1,6 @@ + 'Выберите категорию ...', + 'Select tag' => 'Выберите тэг ...', + 'Has no parent rubric' => 'Без категории', + ]; \ No newline at end of file diff --git a/storage/.htaccess b/storage/.htaccess index 0a379a4..277e2f6 100755 --- a/storage/.htaccess +++ b/storage/.htaccess @@ -3,4 +3,4 @@ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . index.php + -- libgit2 0.21.4