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 @@