From 3b1725bf8dbf19c5b1f027d6b021c9f11cbe6d35 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 4 May 2017 16:42:08 +0300 Subject: [PATCH] -Bug with fill resize fixed --- controllers/ArticleController.php | 16 ++++++++++++---- controllers/DefaultController.php | 20 -------------------- messages/en/blog.php | 3 +++ messages/ru/blog.php | 3 +++ migrations/m161101_142334_blog_article.php | 31 +++++++++++++++++++++++++++++++ migrations/m161101_142752_blog_article_lang.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_143033_blog_category.php | 29 +++++++++++++++++++++++++++++ migrations/m161101_143259_blog_category_lang.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_143541_blog_article_to_category.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_143734_blog_tag.php | 24 ++++++++++++++++++++++++ migrations/m161101_143939_blog_tag_lang.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_144140_blog_article_to_tag.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_144312_blog_article_to_article.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migrations/m161101_144434_blog_article_to_product.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/Article.php | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/ArticleLang.php | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/ArticleSearch.php | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/BlogArticle.php | 186 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ models/BlogArticleLang.php | 152 -------------------------------------------------------------------------------------------------------------------------------------------------------- models/BlogArticleSearch.php | 130 ---------------------------------------------------------------------------------------------------------------------------------- views/blog-article/index.php | 8 ++++---- views/default/index.php | 12 ------------ 22 files changed, 1042 insertions(+), 508 deletions(-) delete mode 100755 controllers/DefaultController.php create mode 100644 messages/en/blog.php create mode 100644 messages/ru/blog.php create mode 100755 migrations/m161101_142334_blog_article.php create mode 100755 migrations/m161101_142752_blog_article_lang.php create mode 100755 migrations/m161101_143033_blog_category.php create mode 100755 migrations/m161101_143259_blog_category_lang.php create mode 100755 migrations/m161101_143541_blog_article_to_category.php create mode 100755 migrations/m161101_143734_blog_tag.php create mode 100755 migrations/m161101_143939_blog_tag_lang.php create mode 100755 migrations/m161101_144140_blog_article_to_tag.php create mode 100755 migrations/m161101_144312_blog_article_to_article.php create mode 100755 migrations/m161101_144434_blog_article_to_product.php create mode 100755 models/Article.php create mode 100755 models/ArticleLang.php create mode 100755 models/ArticleSearch.php delete mode 100755 models/BlogArticle.php delete mode 100755 models/BlogArticleLang.php delete mode 100755 models/BlogArticleSearch.php delete mode 100755 views/default/index.php diff --git a/controllers/ArticleController.php b/controllers/ArticleController.php index f0c71f7..96c542f 100755 --- a/controllers/ArticleController.php +++ b/controllers/ArticleController.php @@ -5,8 +5,8 @@ use artbox\weblog\models\BlogCategory; use artbox\weblog\models\BlogTag; use Yii; - use artbox\weblog\models\BlogArticle; - use artbox\weblog\models\BlogArticleSearch; + use artbox\weblog\models\Article; + use artbox\weblog\models\ArticleSearch; use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -21,6 +21,14 @@ /** * @inheritdoc */ + public function getViewPath() + { + return '@artbox/weblog/views/blog-article'; + } + + /** + * @inheritdoc + */ public function behaviors() { return [ @@ -40,7 +48,7 @@ */ public function actionIndex() { - $searchModel = new BlogArticleSearch(); + $searchModel = new ArticleSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render( @@ -77,7 +85,7 @@ */ public function actionCreate() { - $model = new BlogArticle(); + $model = new Article(); $model->generateLangs(); $categories = ArrayHelper::map( diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php deleted file mode 100755 index 436ff86..0000000 --- a/controllers/DefaultController.php +++ /dev/null @@ -1,20 +0,0 @@ -render('index'); - } -} diff --git a/messages/en/blog.php b/messages/en/blog.php new file mode 100644 index 0000000..21f2be0 --- /dev/null +++ b/messages/en/blog.php @@ -0,0 +1,3 @@ +createTable( + 'blog_article', + [ + 'id' => $this->primaryKey(), + 'image' => $this->string(255), + 'created_at' => $this->integer(), + 'updated_at' => $this->integer(), + 'deleted_at' => $this->integer(), + 'sort' => $this->integer(), + 'status' => $this->boolean(), + 'author_id' => $this->integer(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_article'); + } + } diff --git a/migrations/m161101_142752_blog_article_lang.php b/migrations/m161101_142752_blog_article_lang.php new file mode 100755 index 0000000..9fb8b9f --- /dev/null +++ b/migrations/m161101_142752_blog_article_lang.php @@ -0,0 +1,83 @@ +createTable( + 'blog_article_lang', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'title' => $this->string(255), + 'body' => $this->text(), + 'body_preview' => $this->text(), + 'alias' => $this->string(255), + 'meta_title' => $this->string(255), + 'meta_description' => $this->string(255), + 'h1' => $this->string(255), + 'seo_text' => $this->string(255), + ] + ); + + /** + * Creating indexes for unique fields (field pairs) + */ + $this->createIndex( + 'blog_article_lang_uk', + 'blog_article_lang', + [ + 'blog_article_id', + 'language_id', + ], + true + ); + + $this->createIndex( + 'blog_article_alias_uk', + 'blog_article_lang', + 'alias', + true + ); + + /** + * Add foreign keys in blog_articles and language tables + */ + $this->addForeignKey( + 'blog_article_fk', + 'blog_article_lang', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_lang_fk', + 'blog_article_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_lang_fk', 'blog_article_lang'); + $this->dropForeignKey('blog_article_fk', 'blog_article_lang'); + $this->dropIndex('blog_article_alias_uk', 'blog_article_lang'); + $this->dropIndex('blog_article_lang_uk', 'blog_article_lang'); + $this->dropTable('blog_article_lang'); + } + } diff --git a/migrations/m161101_143033_blog_category.php b/migrations/m161101_143033_blog_category.php new file mode 100755 index 0000000..ff1c560 --- /dev/null +++ b/migrations/m161101_143033_blog_category.php @@ -0,0 +1,29 @@ +createTable( + 'blog_category', + [ + 'id' => $this->primaryKey(), + 'sort' => $this->integer(), + 'image' => $this->string(255), + 'parent_id' => $this->integer() + ->defaultValue(0), + 'status' => $this->boolean(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_category'); + } + } diff --git a/migrations/m161101_143259_blog_category_lang.php b/migrations/m161101_143259_blog_category_lang.php new file mode 100755 index 0000000..31ea407 --- /dev/null +++ b/migrations/m161101_143259_blog_category_lang.php @@ -0,0 +1,82 @@ +createTable( + 'blog_category_lang', + [ + 'id' => $this->primaryKey(), + 'blog_category_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'title' => $this->string(255), + 'alias' => $this->string(255), + 'description' => $this->text(), + 'meta_title' => $this->string(255), + 'meta_description' => $this->string(255), + 'h1' => $this->string(255), + 'seo_text' => $this->string(255), + ] + ); + + /** + * Create unique indexes for language and alias + */ + $this->createIndex( + 'blog_category_lang_uk', + 'blog_category_lang', + [ + 'blog_category_id', + 'language_id', + ], + true + ); + + $this->createIndex( + 'blog_category_alias_uk', + 'blog_category_lang', + 'alias', + true + ); + + /** + * Add foreign keys for language tables + */ + $this->addForeignKey( + 'blog_category_fk', + 'blog_category_lang', + 'blog_category_id', + 'blog_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_category_lang_fk', + 'blog_category_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_category_lang_fk', 'blog_category_lang'); + $this->dropForeignKey('blog_category_fk', 'blog_category_lang'); + $this->dropIndex('blog_category_alias_uk', 'blog_category_lang'); + $this->dropIndex('blog_category_lang_uk', 'blog_category_lang'); + $this->dropTable('blog_category_lang'); + } + } diff --git a/migrations/m161101_143541_blog_article_to_category.php b/migrations/m161101_143541_blog_article_to_category.php new file mode 100755 index 0000000..f492ecb --- /dev/null +++ b/migrations/m161101_143541_blog_article_to_category.php @@ -0,0 +1,64 @@ +createTable( + 'blog_article_to_category', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'blog_category_id' => $this->integer() + ->notNull(), + ] + ); + + /** + * Add foreign keys and indexes for junction table + */ + $this->createIndex( + 'blog_article_to_category_uk', + 'blog_article_to_category', + [ + 'blog_article_id', + 'blog_category_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_category_art_fk', + 'blog_article_to_category', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_category_cat_fk', + 'blog_article_to_category', + 'blog_category_id', + 'blog_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_category_cat_fk', 'blog_article_to_category'); + $this->dropForeignKey('blog_article_to_category_art_fk', 'blog_article_to_category'); + $this->dropIndex('blog_article_to_category_uk', 'blog_article_to_category'); + $this->dropTable('blog_article_to_category'); + } + } diff --git a/migrations/m161101_143734_blog_tag.php b/migrations/m161101_143734_blog_tag.php new file mode 100755 index 0000000..05d575b --- /dev/null +++ b/migrations/m161101_143734_blog_tag.php @@ -0,0 +1,24 @@ +createTable( + 'blog_tag', + [ + 'id' => $this->primaryKey(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_tag'); + } + } diff --git a/migrations/m161101_143939_blog_tag_lang.php b/migrations/m161101_143939_blog_tag_lang.php new file mode 100755 index 0000000..fbf0575 --- /dev/null +++ b/migrations/m161101_143939_blog_tag_lang.php @@ -0,0 +1,65 @@ +createTable( + 'blog_tag_lang', + [ + 'id' => $this->primaryKey(), + 'blog_tag_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'label' => $this->string(255), + ] + ); + + /** + * Creating indexes and foreign keys for language table + */ + $this->createIndex( + 'blog_tag_lang_uk', + 'blog_tag_lang', + [ + 'blog_tag_id', + 'language_id', + ], + true + ); + + $this->addForeignKey( + 'blog_tag_lang_fk', + 'blog_tag_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_tag_fk', + 'blog_tag_lang', + 'blog_tag_id', + 'blog_tag', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_tag_fk', 'blog_tag_lang'); + $this->dropForeignKey('blog_tag_lang_fk', 'blog_tag_lang'); + $this->dropIndex('blog_tag_lang_uk', 'blog_tag_lang'); + $this->dropTable('blog_tag_lang'); + } + } diff --git a/migrations/m161101_144140_blog_article_to_tag.php b/migrations/m161101_144140_blog_article_to_tag.php new file mode 100755 index 0000000..da13061 --- /dev/null +++ b/migrations/m161101_144140_blog_article_to_tag.php @@ -0,0 +1,64 @@ +createTable( + 'blog_article_to_tag', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'blog_tag_id' => $this->integer() + ->notNull(), + ] + ); + + /** + * Create indexes and foreign keys for junction table + */ + $this->createIndex( + 'blog_article_to_tag_uk', + 'blog_article_to_tag', + [ + 'blog_article_id', + 'blog_tag_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_tag_tag_fk', + 'blog_article_to_tag', + 'blog_tag_id', + 'blog_tag', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_tag_art_fk', + 'blog_article_to_tag', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_tag_art_fk', 'blog_article_to_tag'); + $this->dropForeignKey('blog_article_to_tag_tag_fk', 'blog_article_to_tag'); + $this->dropIndex('blog_article_to_tag_uk', 'blog_article_to_tag'); + $this->dropTable('blog_article_to_tag'); + } + } diff --git a/migrations/m161101_144312_blog_article_to_article.php b/migrations/m161101_144312_blog_article_to_article.php new file mode 100755 index 0000000..39f1691 --- /dev/null +++ b/migrations/m161101_144312_blog_article_to_article.php @@ -0,0 +1,61 @@ +createTable( + 'blog_article_to_article', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'related_blog_article_id' => $this->integer() + ->notNull(), + ] + ); + + $this->createIndex( + 'blog_article_to_article_uk', + 'blog_article_to_article', + [ + 'blog_article_id', + 'related_blog_article_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_article_art_fk', + 'blog_article_to_article', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_article_rel_fk', + 'blog_article_to_article', + 'related_blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_article_rel_fk', 'blog_article_to_article'); + $this->dropForeignKey('blog_article_to_article_art_fk', 'blog_article_to_article'); + $this->dropIndex('blog_article_to_article_uk', 'blog_article_to_article'); + $this->dropTable('blog_article_to_article'); + } + } diff --git a/migrations/m161101_144434_blog_article_to_product.php b/migrations/m161101_144434_blog_article_to_product.php new file mode 100755 index 0000000..671ab08 --- /dev/null +++ b/migrations/m161101_144434_blog_article_to_product.php @@ -0,0 +1,61 @@ +createTable( + 'blog_article_to_product', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'product_id' => $this->integer() + ->notNull(), + ] + ); + + $this->createIndex( + 'blog_article_to_product_uk', + 'blog_article_to_product', + [ + 'blog_article_id', + 'product_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_product_art_fk', + 'blog_article_to_product', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_product_prod_fk', + 'blog_article_to_product', + 'product_id', + 'product', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_product_prod_fk', 'blog_article_to_product'); + $this->dropForeignKey('blog_article_to_product_art_fk', 'blog_article_to_product'); + $this->dropIndex('blog_article_to_product_uk', 'blog_article_to_product'); + $this->dropTable('blog_article_to_product'); + } + } diff --git a/models/Article.php b/models/Article.php new file mode 100755 index 0000000..562a9f2 --- /dev/null +++ b/models/Article.php @@ -0,0 +1,178 @@ + TimestampBehavior::className(), + ], + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'created_at', + 'updated_at', + 'deleted_at', + 'sort', + 'author_id', + ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'image' ], + 'string', + 'max' => 255, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'image' => 'Image', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + 'deleted_at' => 'Deleted At', + 'sort' => 'Sort', + 'status' => 'Status', + 'author_id' => 'Author ID', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRelatedBlogArticles() + { + return $this->hasMany(Article::className(), [ 'id' => 'related_blog_article_id' ]) + ->viaTable('blog_article_to_article', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getArticles() + { + return $this->hasMany(Article::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_article', [ 'related_blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategories() + { + return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategory() + { + return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProducts() + { + return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) + ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTags() + { + return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ]) + ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]); + } + } diff --git a/models/ArticleLang.php b/models/ArticleLang.php new file mode 100755 index 0000000..f3b1410 --- /dev/null +++ b/models/ArticleLang.php @@ -0,0 +1,148 @@ + 255, + ], + [ + [ 'alias' ], + 'unique', + ], + [ + [ + 'blog_article_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'blog_article_id', + 'language_id', + ], + 'message' => 'The combination of Blog Article ID and Language ID has already been taken.', + ], + [ + [ 'blog_article_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Article::className(), + 'targetAttribute' => [ 'blog_article_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_article_id' => 'Blog Article ID', + 'language_id' => 'Language ID', + 'title' => 'Title', + 'body' => 'Body', + 'body_preview' => 'Body Preview', + 'alias' => 'Alias', + 'meta_title' => 'Meta Title', + 'meta_description' => 'Meta Description', + 'h1' => 'H1', + 'seo_text' => 'Seo Text', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getArticle() + { + return $this->hasOne(Article::className(), [ 'id' => 'blog_article_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + } diff --git a/models/ArticleSearch.php b/models/ArticleSearch.php new file mode 100755 index 0000000..09f6fad --- /dev/null +++ b/models/ArticleSearch.php @@ -0,0 +1,130 @@ +joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => [ + 'attributes' => [ + 'id', + 'created_at', + 'updated_at', + 'title' => [ + 'asc' => [ 'blog_article_lang.title' => SORT_ASC ], + 'desc' => [ 'blog_article_lang.title' => SORT_DESC ], + ], + ], + ], + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'status' => $this->status, + 'author_id' => $this->author_id, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'image', + $this->image, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'blog_article_lang.title', + $this->title, + ] + ); + + return $dataProvider; + } + } diff --git a/models/BlogArticle.php b/models/BlogArticle.php deleted file mode 100755 index aae1a59..0000000 --- a/models/BlogArticle.php +++ /dev/null @@ -1,186 +0,0 @@ - TimestampBehavior::className(), - ], - [ - 'class' => SaveImgBehavior::className(), - 'fields' => [ - [ - 'name' => 'image', - 'directory' => 'blog/article', - ], - ], - ], - 'language' => [ - 'class' => LanguageBehavior::className(), - ], - ]; - } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - [ - 'created_at', - 'updated_at', - 'deleted_at', - 'sort', - 'author_id', - ], - 'integer', - ], - [ - [ 'status' ], - 'boolean', - ], - [ - [ 'image' ], - 'string', - 'max' => 255, - ], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'image' => 'Image', - 'created_at' => 'Created At', - 'updated_at' => 'Updated At', - 'deleted_at' => 'Deleted At', - 'sort' => 'Sort', - 'status' => 'Status', - 'author_id' => 'Author ID', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getRelatedBlogArticles() - { - return $this->hasMany(BlogArticle::className(), [ 'id' => 'related_blog_article_id' ]) - ->viaTable('blog_article_to_article', [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogArticles() - { - return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) - ->viaTable('blog_article_to_article', [ 'related_blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogCategories() - { - return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) - ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogCategory() - { - return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) - ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getProducts() - { - return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) - ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogTags() - { - return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ]) - ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]); - } - } diff --git a/models/BlogArticleLang.php b/models/BlogArticleLang.php deleted file mode 100755 index 6a1a4aa..0000000 --- a/models/BlogArticleLang.php +++ /dev/null @@ -1,152 +0,0 @@ - [ - 'class' => 'artweb\artbox\behaviors\Slug', - ], - ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - [ - 'blog_article_id', - 'language_id', - 'title', - ], - 'required', - ], - [ - [ - 'blog_article_id', - 'language_id', - ], - 'integer', - ], - [ - [ - 'body', - 'body_preview', - ], - 'string', - ], - [ - [ - 'title', - 'alias', - 'meta_title', - 'meta_description', - 'h1', - 'seo_text', - ], - 'string', - 'max' => 255, - ], - [ - [ 'alias' ], - 'unique', - ], - [ - [ - 'blog_article_id', - 'language_id', - ], - 'unique', - 'targetAttribute' => [ - 'blog_article_id', - 'language_id', - ], - 'message' => 'The combination of Blog Article ID and Language ID has already been taken.', - ], - [ - [ 'blog_article_id' ], - 'exist', - 'skipOnError' => true, - 'targetClass' => BlogArticle::className(), - 'targetAttribute' => [ 'blog_article_id' => 'id' ], - ], - [ - [ 'language_id' ], - 'exist', - 'skipOnError' => true, - 'targetClass' => Language::className(), - 'targetAttribute' => [ 'language_id' => 'id' ], - ], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'blog_article_id' => 'Blog Article ID', - 'language_id' => 'Language ID', - 'title' => 'Title', - 'body' => 'Body', - 'body_preview' => 'Body Preview', - 'alias' => 'Alias', - 'meta_title' => 'Meta Title', - 'meta_description' => 'Meta Description', - 'h1' => 'H1', - 'seo_text' => 'Seo Text', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogArticle() - { - return $this->hasOne(BlogArticle::className(), [ 'id' => 'blog_article_id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); - } - } diff --git a/models/BlogArticleSearch.php b/models/BlogArticleSearch.php deleted file mode 100755 index a2f2915..0000000 --- a/models/BlogArticleSearch.php +++ /dev/null @@ -1,130 +0,0 @@ -joinWith('lang'); - - // add conditions that should always apply here - - $dataProvider = new ActiveDataProvider( - [ - 'query' => $query, - 'sort' => [ - 'attributes' => [ - 'id', - 'created_at', - 'updated_at', - 'title' => [ - 'asc' => [ 'blog_article_lang.title' => SORT_ASC ], - 'desc' => [ 'blog_article_lang.title' => SORT_DESC ], - ], - ], - ], - ] - ); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - return $dataProvider; - } - - // grid filtering conditions - $query->andFilterWhere( - [ - 'id' => $this->id, - 'status' => $this->status, - 'author_id' => $this->author_id, - ] - ); - - $query->andFilterWhere( - [ - 'like', - 'image', - $this->image, - ] - ); - - $query->andFilterWhere( - [ - 'like', - 'blog_article_lang.title', - $this->title, - ] - ); - - return $dataProvider; - } - } diff --git a/views/blog-article/index.php b/views/blog-article/index.php index 73583bc..c5e301b 100755 --- a/views/blog-article/index.php +++ b/views/blog-article/index.php @@ -1,7 +1,7 @@ 'status', 'value' => function($model) { /** - * @var BlogArticle $model + * @var Article $model */ return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'); }, diff --git a/views/default/index.php b/views/default/index.php deleted file mode 100755 index 650b9c5..0000000 --- a/views/default/index.php +++ /dev/null @@ -1,12 +0,0 @@ -
-

context->action->uniqueId ?>

-

- This is the view content for action "context->action->id ?>". - The action belongs to the controller "context) ?>" - in the "context->module->id ?>" module. -

-

- You may customize this page by editing the following file:
- -

-
-- libgit2 0.21.4