Commit 3b1725bf8dbf19c5b1f027d6b021c9f11cbe6d35

Authored by Alexey Boroda
1 parent d311541c

-Bug with fill resize fixed

controllers/ArticleController.php
... ... @@ -5,8 +5,8 @@
5 5 use artbox\weblog\models\BlogCategory;
6 6 use artbox\weblog\models\BlogTag;
7 7 use Yii;
8   - use artbox\weblog\models\BlogArticle;
9   - use artbox\weblog\models\BlogArticleSearch;
  8 + use artbox\weblog\models\Article;
  9 + use artbox\weblog\models\ArticleSearch;
10 10 use yii\helpers\ArrayHelper;
11 11 use yii\web\Controller;
12 12 use yii\web\NotFoundHttpException;
... ... @@ -21,6 +21,14 @@
21 21 /**
22 22 * @inheritdoc
23 23 */
  24 + public function getViewPath()
  25 + {
  26 + return '@artbox/weblog/views/blog-article';
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
24 32 public function behaviors()
25 33 {
26 34 return [
... ... @@ -40,7 +48,7 @@
40 48 */
41 49 public function actionIndex()
42 50 {
43   - $searchModel = new BlogArticleSearch();
  51 + $searchModel = new ArticleSearch();
44 52 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
45 53  
46 54 return $this->render(
... ... @@ -77,7 +85,7 @@
77 85 */
78 86 public function actionCreate()
79 87 {
80   - $model = new BlogArticle();
  88 + $model = new Article();
81 89 $model->generateLangs();
82 90  
83 91 $categories = ArrayHelper::map(
... ...
controllers/DefaultController.php deleted
1   -<?php
2   -
3   - namespace artweb\artbox\weblog\controllers;
4   -
5   -use yii\web\Controller;
6   -
7   -/**
8   - * Default controller for the `blog` module
9   - */
10   -class DefaultController extends Controller
11   -{
12   - /**
13   - * Renders the index view for the module
14   - * @return string
15   - */
16   - public function actionIndex()
17   - {
18   - return $this->render('index');
19   - }
20   -}
messages/en/blog.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 + return [];
0 4 \ No newline at end of file
... ...
messages/ru/blog.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 + return [];
0 4 \ No newline at end of file
... ...
migrations/m161101_142334_blog_article.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_142334_blog_article extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create main table with blog's articles
  11 + */
  12 + $this->createTable(
  13 + 'blog_article',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'image' => $this->string(255),
  17 + 'created_at' => $this->integer(),
  18 + 'updated_at' => $this->integer(),
  19 + 'deleted_at' => $this->integer(),
  20 + 'sort' => $this->integer(),
  21 + 'status' => $this->boolean(),
  22 + 'author_id' => $this->integer(),
  23 + ]
  24 + );
  25 + }
  26 +
  27 + public function down()
  28 + {
  29 + $this->dropTable('blog_article');
  30 + }
  31 + }
... ...
migrations/m161101_142752_blog_article_lang.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_142752_blog_article_lang extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create table with language fields of blog articles
  11 + */
  12 + $this->createTable(
  13 + 'blog_article_lang',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_article_id' => $this->integer()
  17 + ->notNull(),
  18 + 'language_id' => $this->integer()
  19 + ->notNull(),
  20 + 'title' => $this->string(255),
  21 + 'body' => $this->text(),
  22 + 'body_preview' => $this->text(),
  23 + 'alias' => $this->string(255),
  24 + 'meta_title' => $this->string(255),
  25 + 'meta_description' => $this->string(255),
  26 + 'h1' => $this->string(255),
  27 + 'seo_text' => $this->string(255),
  28 + ]
  29 + );
  30 +
  31 + /**
  32 + * Creating indexes for unique fields (field pairs)
  33 + */
  34 + $this->createIndex(
  35 + 'blog_article_lang_uk',
  36 + 'blog_article_lang',
  37 + [
  38 + 'blog_article_id',
  39 + 'language_id',
  40 + ],
  41 + true
  42 + );
  43 +
  44 + $this->createIndex(
  45 + 'blog_article_alias_uk',
  46 + 'blog_article_lang',
  47 + 'alias',
  48 + true
  49 + );
  50 +
  51 + /**
  52 + * Add foreign keys in blog_articles and language tables
  53 + */
  54 + $this->addForeignKey(
  55 + 'blog_article_fk',
  56 + 'blog_article_lang',
  57 + 'blog_article_id',
  58 + 'blog_article',
  59 + 'id',
  60 + 'CASCADE',
  61 + 'CASCADE'
  62 + );
  63 +
  64 + $this->addForeignKey(
  65 + 'blog_article_lang_fk',
  66 + 'blog_article_lang',
  67 + 'language_id',
  68 + 'language',
  69 + 'id',
  70 + 'RESTRICT',
  71 + 'CASCADE'
  72 + );
  73 + }
  74 +
  75 + public function down()
  76 + {
  77 + $this->dropForeignKey('blog_article_lang_fk', 'blog_article_lang');
  78 + $this->dropForeignKey('blog_article_fk', 'blog_article_lang');
  79 + $this->dropIndex('blog_article_alias_uk', 'blog_article_lang');
  80 + $this->dropIndex('blog_article_lang_uk', 'blog_article_lang');
  81 + $this->dropTable('blog_article_lang');
  82 + }
  83 + }
... ...
migrations/m161101_143033_blog_category.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_143033_blog_category extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create table for blog's categories
  11 + */
  12 + $this->createTable(
  13 + 'blog_category',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'sort' => $this->integer(),
  17 + 'image' => $this->string(255),
  18 + 'parent_id' => $this->integer()
  19 + ->defaultValue(0),
  20 + 'status' => $this->boolean(),
  21 + ]
  22 + );
  23 + }
  24 +
  25 + public function down()
  26 + {
  27 + $this->dropTable('blog_category');
  28 + }
  29 + }
... ...
migrations/m161101_143259_blog_category_lang.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_143259_blog_category_lang extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Table for category languages
  11 + */
  12 + $this->createTable(
  13 + 'blog_category_lang',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_category_id' => $this->integer()
  17 + ->notNull(),
  18 + 'language_id' => $this->integer()
  19 + ->notNull(),
  20 + 'title' => $this->string(255),
  21 + 'alias' => $this->string(255),
  22 + 'description' => $this->text(),
  23 + 'meta_title' => $this->string(255),
  24 + 'meta_description' => $this->string(255),
  25 + 'h1' => $this->string(255),
  26 + 'seo_text' => $this->string(255),
  27 + ]
  28 + );
  29 +
  30 + /**
  31 + * Create unique indexes for language and alias
  32 + */
  33 + $this->createIndex(
  34 + 'blog_category_lang_uk',
  35 + 'blog_category_lang',
  36 + [
  37 + 'blog_category_id',
  38 + 'language_id',
  39 + ],
  40 + true
  41 + );
  42 +
  43 + $this->createIndex(
  44 + 'blog_category_alias_uk',
  45 + 'blog_category_lang',
  46 + 'alias',
  47 + true
  48 + );
  49 +
  50 + /**
  51 + * Add foreign keys for language tables
  52 + */
  53 + $this->addForeignKey(
  54 + 'blog_category_fk',
  55 + 'blog_category_lang',
  56 + 'blog_category_id',
  57 + 'blog_category',
  58 + 'id',
  59 + 'CASCADE',
  60 + 'CASCADE'
  61 + );
  62 +
  63 + $this->addForeignKey(
  64 + 'blog_category_lang_fk',
  65 + 'blog_category_lang',
  66 + 'language_id',
  67 + 'language',
  68 + 'id',
  69 + 'RESTRICT',
  70 + 'CASCADE'
  71 + );
  72 + }
  73 +
  74 + public function down()
  75 + {
  76 + $this->dropForeignKey('blog_category_lang_fk', 'blog_category_lang');
  77 + $this->dropForeignKey('blog_category_fk', 'blog_category_lang');
  78 + $this->dropIndex('blog_category_alias_uk', 'blog_category_lang');
  79 + $this->dropIndex('blog_category_lang_uk', 'blog_category_lang');
  80 + $this->dropTable('blog_category_lang');
  81 + }
  82 + }
... ...
migrations/m161101_143541_blog_article_to_category.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_143541_blog_article_to_category extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create junction table to connect articles with categories
  11 + */
  12 + $this->createTable(
  13 + 'blog_article_to_category',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_article_id' => $this->integer()
  17 + ->notNull(),
  18 + 'blog_category_id' => $this->integer()
  19 + ->notNull(),
  20 + ]
  21 + );
  22 +
  23 + /**
  24 + * Add foreign keys and indexes for junction table
  25 + */
  26 + $this->createIndex(
  27 + 'blog_article_to_category_uk',
  28 + 'blog_article_to_category',
  29 + [
  30 + 'blog_article_id',
  31 + 'blog_category_id',
  32 + ],
  33 + true
  34 + );
  35 +
  36 + $this->addForeignKey(
  37 + 'blog_article_to_category_art_fk',
  38 + 'blog_article_to_category',
  39 + 'blog_article_id',
  40 + 'blog_article',
  41 + 'id',
  42 + 'CASCADE',
  43 + 'CASCADE'
  44 + );
  45 +
  46 + $this->addForeignKey(
  47 + 'blog_article_to_category_cat_fk',
  48 + 'blog_article_to_category',
  49 + 'blog_category_id',
  50 + 'blog_category',
  51 + 'id',
  52 + 'CASCADE',
  53 + 'CASCADE'
  54 + );
  55 + }
  56 +
  57 + public function down()
  58 + {
  59 + $this->dropForeignKey('blog_article_to_category_cat_fk', 'blog_article_to_category');
  60 + $this->dropForeignKey('blog_article_to_category_art_fk', 'blog_article_to_category');
  61 + $this->dropIndex('blog_article_to_category_uk', 'blog_article_to_category');
  62 + $this->dropTable('blog_article_to_category');
  63 + }
  64 + }
... ...
migrations/m161101_143734_blog_tag.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_143734_blog_tag extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create table for tags
  11 + */
  12 + $this->createTable(
  13 + 'blog_tag',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + ]
  17 + );
  18 + }
  19 +
  20 + public function down()
  21 + {
  22 + $this->dropTable('blog_tag');
  23 + }
  24 + }
... ...
migrations/m161101_143939_blog_tag_lang.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_143939_blog_tag_lang extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Tags can be in different languages
  11 + */
  12 + $this->createTable(
  13 + 'blog_tag_lang',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_tag_id' => $this->integer()
  17 + ->notNull(),
  18 + 'language_id' => $this->integer()
  19 + ->notNull(),
  20 + 'label' => $this->string(255),
  21 + ]
  22 + );
  23 +
  24 + /**
  25 + * Creating indexes and foreign keys for language table
  26 + */
  27 + $this->createIndex(
  28 + 'blog_tag_lang_uk',
  29 + 'blog_tag_lang',
  30 + [
  31 + 'blog_tag_id',
  32 + 'language_id',
  33 + ],
  34 + true
  35 + );
  36 +
  37 + $this->addForeignKey(
  38 + 'blog_tag_lang_fk',
  39 + 'blog_tag_lang',
  40 + 'language_id',
  41 + 'language',
  42 + 'id',
  43 + 'RESTRICT',
  44 + 'CASCADE'
  45 + );
  46 +
  47 + $this->addForeignKey(
  48 + 'blog_tag_fk',
  49 + 'blog_tag_lang',
  50 + 'blog_tag_id',
  51 + 'blog_tag',
  52 + 'id',
  53 + 'CASCADE',
  54 + 'CASCADE'
  55 + );
  56 + }
  57 +
  58 + public function down()
  59 + {
  60 + $this->dropForeignKey('blog_tag_fk', 'blog_tag_lang');
  61 + $this->dropForeignKey('blog_tag_lang_fk', 'blog_tag_lang');
  62 + $this->dropIndex('blog_tag_lang_uk', 'blog_tag_lang');
  63 + $this->dropTable('blog_tag_lang');
  64 + }
  65 + }
... ...
migrations/m161101_144140_blog_article_to_tag.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_144140_blog_article_to_tag extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create junction table to connect articles with tags
  11 + */
  12 + $this->createTable(
  13 + 'blog_article_to_tag',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_article_id' => $this->integer()
  17 + ->notNull(),
  18 + 'blog_tag_id' => $this->integer()
  19 + ->notNull(),
  20 + ]
  21 + );
  22 +
  23 + /**
  24 + * Create indexes and foreign keys for junction table
  25 + */
  26 + $this->createIndex(
  27 + 'blog_article_to_tag_uk',
  28 + 'blog_article_to_tag',
  29 + [
  30 + 'blog_article_id',
  31 + 'blog_tag_id',
  32 + ],
  33 + true
  34 + );
  35 +
  36 + $this->addForeignKey(
  37 + 'blog_article_to_tag_tag_fk',
  38 + 'blog_article_to_tag',
  39 + 'blog_tag_id',
  40 + 'blog_tag',
  41 + 'id',
  42 + 'CASCADE',
  43 + 'CASCADE'
  44 + );
  45 +
  46 + $this->addForeignKey(
  47 + 'blog_article_to_tag_art_fk',
  48 + 'blog_article_to_tag',
  49 + 'blog_article_id',
  50 + 'blog_article',
  51 + 'id',
  52 + 'CASCADE',
  53 + 'CASCADE'
  54 + );
  55 + }
  56 +
  57 + public function down()
  58 + {
  59 + $this->dropForeignKey('blog_article_to_tag_art_fk', 'blog_article_to_tag');
  60 + $this->dropForeignKey('blog_article_to_tag_tag_fk', 'blog_article_to_tag');
  61 + $this->dropIndex('blog_article_to_tag_uk', 'blog_article_to_tag');
  62 + $this->dropTable('blog_article_to_tag');
  63 + }
  64 + }
... ...
migrations/m161101_144312_blog_article_to_article.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_144312_blog_article_to_article extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Create table and all relations for related articles functionality
  11 + */
  12 + $this->createTable(
  13 + 'blog_article_to_article',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_article_id' => $this->integer()
  17 + ->notNull(),
  18 + 'related_blog_article_id' => $this->integer()
  19 + ->notNull(),
  20 + ]
  21 + );
  22 +
  23 + $this->createIndex(
  24 + 'blog_article_to_article_uk',
  25 + 'blog_article_to_article',
  26 + [
  27 + 'blog_article_id',
  28 + 'related_blog_article_id',
  29 + ],
  30 + true
  31 + );
  32 +
  33 + $this->addForeignKey(
  34 + 'blog_article_to_article_art_fk',
  35 + 'blog_article_to_article',
  36 + 'blog_article_id',
  37 + 'blog_article',
  38 + 'id',
  39 + 'CASCADE',
  40 + 'CASCADE'
  41 + );
  42 +
  43 + $this->addForeignKey(
  44 + 'blog_article_to_article_rel_fk',
  45 + 'blog_article_to_article',
  46 + 'related_blog_article_id',
  47 + 'blog_article',
  48 + 'id',
  49 + 'CASCADE',
  50 + 'CASCADE'
  51 + );
  52 + }
  53 +
  54 + public function down()
  55 + {
  56 + $this->dropForeignKey('blog_article_to_article_rel_fk', 'blog_article_to_article');
  57 + $this->dropForeignKey('blog_article_to_article_art_fk', 'blog_article_to_article');
  58 + $this->dropIndex('blog_article_to_article_uk', 'blog_article_to_article');
  59 + $this->dropTable('blog_article_to_article');
  60 + }
  61 + }
... ...
migrations/m161101_144434_blog_article_to_product.php 0 โ†’ 100755
  1 +<?php
  2 +
  3 + use yii\db\Migration;
  4 +
  5 + class m161101_144434_blog_article_to_product extends Migration
  6 + {
  7 + public function up()
  8 + {
  9 + /**
  10 + * Creates junction table and all stuff for adding related products to articles
  11 + */
  12 + $this->createTable(
  13 + 'blog_article_to_product',
  14 + [
  15 + 'id' => $this->primaryKey(),
  16 + 'blog_article_id' => $this->integer()
  17 + ->notNull(),
  18 + 'product_id' => $this->integer()
  19 + ->notNull(),
  20 + ]
  21 + );
  22 +
  23 + $this->createIndex(
  24 + 'blog_article_to_product_uk',
  25 + 'blog_article_to_product',
  26 + [
  27 + 'blog_article_id',
  28 + 'product_id',
  29 + ],
  30 + true
  31 + );
  32 +
  33 + $this->addForeignKey(
  34 + 'blog_article_to_product_art_fk',
  35 + 'blog_article_to_product',
  36 + 'blog_article_id',
  37 + 'blog_article',
  38 + 'id',
  39 + 'CASCADE',
  40 + 'CASCADE'
  41 + );
  42 +
  43 + $this->addForeignKey(
  44 + 'blog_article_to_product_prod_fk',
  45 + 'blog_article_to_product',
  46 + 'product_id',
  47 + 'product',
  48 + 'id',
  49 + 'CASCADE',
  50 + 'CASCADE'
  51 + );
  52 + }
  53 +
  54 + public function down()
  55 + {
  56 + $this->dropForeignKey('blog_article_to_product_prod_fk', 'blog_article_to_product');
  57 + $this->dropForeignKey('blog_article_to_product_art_fk', 'blog_article_to_product');
  58 + $this->dropIndex('blog_article_to_product_uk', 'blog_article_to_product');
  59 + $this->dropTable('blog_article_to_product');
  60 + }
  61 + }
... ...
models/BlogArticle.php renamed to models/Article.php
1 1 <?php
2 2  
3 3 namespace artbox\weblog\models;
4   -
  4 +
  5 + use artbox\catalog\models\Product;
5 6 use yii\behaviors\TimestampBehavior;
6 7 use yii\db\ActiveRecord;
7 8 use artbox\core\behaviors\LanguageBehavior;
8 9 use artbox\core\models\Language;
9 10 use yii\db\ActiveQuery;
10 11 use yii\web\Request;
11   -
  12 +
12 13 /**
13 14 * This is the model class for table "blog_article".
14 15 *
15   - * @property integer $id
16   - * @property string $image
17   - * @property integer $created_at
18   - * @property integer $updated_at
19   - * @property integer $deleted_at
20   - * @property integer $sort
21   - * @property boolean $status
22   - * @property integer $author_id
23   - * @property BlogArticleLang[] $blogArticleLangs
24   - * @property Language[] $languages
25   - * @property BlogArticle[] $relatedBlogArticles
26   - * @property BlogArticle[] $blogArticles
27   - * @property BlogCategory[] $blogCategories
28   - * @property BlogCategory $blogCategory
29   - * @property Product[] $products
30   - * @property BlogTag[] $blogTags
  16 +*@property integer $id
  17 + * @property string $image
  18 + * @property integer $created_at
  19 + * @property integer $updated_at
  20 + * @property integer $deleted_at
  21 + * @property integer $sort
  22 + * @property boolean $status
  23 + * @property integer $author_id
  24 + * @property ArticleLang[] $blogArticleLangs
  25 + * @property Language[] $languages
  26 + * @property Article[] $relatedBlogArticles
  27 + * @property Article[] $blogArticles
  28 + * @property BlogCategory[] $blogCategories
  29 + * @property BlogCategory $blogCategory
  30 + * @property Product[] $products
  31 + * @property BlogTag[] $blogTags
31 32 * * * From language behavior *
32   - * @property BlogArticleLang $lang
33   - * @property BlogArticleLang[] $langs
34   - * @property BlogArticleLang $objectLang
35   - * @property string $ownerKey
36   - * @property string $langKey
37   - * @property BlogArticleLang[] $modelLangs
38   - * @property bool $transactionStatus
  33 + * @property ArticleLang $lang
  34 + * @property ArticleLang[] $langs
  35 + * @property ArticleLang $objectLang
  36 + * @property string $ownerKey
  37 + * @property string $langKey
  38 + * @property ArticleLang[] $modelLangs
  39 + * @property bool $transactionStatus
39 40 * @method string getOwnerKey()
40 41 * @method void setOwnerKey( string $value )
41 42 * @method string getLangKey()
42 43 * @method void setLangKey( string $value )
43 44 * @method ActiveQuery getLangs()
44 45 * @method ActiveQuery getLang( integer $language_id )
45   - * @method BlogArticleLang[] generateLangs()
  46 + * @method ArticleLang[] generateLangs()
46 47 * @method void loadLangs( Request $request )
47 48 * @method bool linkLangs()
48 49 * @method bool saveLangs()
49 50 * @method bool getTransactionStatus()
50 51 * * End language behavior *
51 52 * * From SaveImgBehavior
52   - * @property string|null $imageFile
53   - * @property string|null $imageUrl
  53 + * @property string|null $imageFile
  54 + * @property string|null $imageUrl
54 55 * @method string|null getImageFile( int $field )
55 56 * @method string|null getImageUrl( int $field )
56 57 * * End SaveImgBehavior
57 58 */
58   - class BlogArticle extends ActiveRecord
  59 + class Article extends ActiveRecord
59 60 {
60 61 /**
61 62 * @inheritdoc
... ... @@ -64,22 +65,13 @@
64 65 {
65 66 return 'blog_article';
66 67 }
67   -
  68 +
68 69 public function behaviors()
69 70 {
70 71 return [
71 72 [
72 73 'class' => TimestampBehavior::className(),
73 74 ],
74   - [
75   - 'class' => SaveImgBehavior::className(),
76   - 'fields' => [
77   - [
78   - 'name' => 'image',
79   - 'directory' => 'blog/article',
80   - ],
81   - ],
82   - ],
83 75 'language' => [
84 76 'class' => LanguageBehavior::className(),
85 77 ],
... ... @@ -112,7 +104,7 @@
112 104 ],
113 105 ];
114 106 }
115   -
  107 +
116 108 /**
117 109 * @inheritdoc
118 110 */
... ... @@ -129,25 +121,25 @@
129 121 'author_id' => 'Author ID',
130 122 ];
131 123 }
132   -
  124 +
133 125 /**
134 126 * @return \yii\db\ActiveQuery
135 127 */
136 128 public function getRelatedBlogArticles()
137 129 {
138   - return $this->hasMany(BlogArticle::className(), [ 'id' => 'related_blog_article_id' ])
  130 + return $this->hasMany(Article::className(), [ 'id' => 'related_blog_article_id' ])
139 131 ->viaTable('blog_article_to_article', [ 'blog_article_id' => 'id' ]);
140 132 }
141   -
  133 +
142 134 /**
143 135 * @return \yii\db\ActiveQuery
144 136 */
145   - public function getBlogArticles()
  137 + public function getArticles()
146 138 {
147   - return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ])
  139 + return $this->hasMany(Article::className(), [ 'id' => 'blog_article_id' ])
148 140 ->viaTable('blog_article_to_article', [ 'related_blog_article_id' => 'id' ]);
149 141 }
150   -
  142 +
151 143 /**
152 144 * @return \yii\db\ActiveQuery
153 145 */
... ... @@ -156,31 +148,31 @@
156 148 return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ])
157 149 ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]);
158 150 }
159   -
  151 +
160 152 /**
161 153 * @return \yii\db\ActiveQuery
162 154 */
163 155 public function getBlogCategory()
164 156 {
165 157 return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ])
166   - ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]);
  158 + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]);
167 159 }
168   -
  160 +
169 161 /**
170 162 * @return \yii\db\ActiveQuery
171 163 */
172 164 public function getProducts()
173 165 {
174 166 return $this->hasMany(Product::className(), [ 'id' => 'product_id' ])
175   - ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]);
  167 + ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]);
176 168 }
177   -
  169 +
178 170 /**
179 171 * @return \yii\db\ActiveQuery
180 172 */
181 173 public function getBlogTags()
182 174 {
183 175 return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ])
184   - ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]);
  176 + ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]);
185 177 }
186 178 }
... ...
models/BlogArticleLang.php renamed to models/ArticleLang.php
... ... @@ -8,21 +8,21 @@
8 8 /**
9 9 * This is the model class for table "blog_article_lang".
10 10 *
11   - * @property integer $id
12   - * @property integer $blog_article_id
13   - * @property integer $language_id
14   - * @property string $title
15   - * @property string $body
16   - * @property string $body_preview
17   - * @property string $alias
18   - * @property string $meta_title
19   - * @property string $meta_description
20   - * @property string $h1
21   - * @property string $seo_text
22   - * @property BlogArticle $blogArticle
23   - * @property Language $language
  11 + * @property integer $id
  12 + * @property integer $blog_article_id
  13 + * @property integer $language_id
  14 + * @property string $title
  15 + * @property string $body
  16 + * @property string $body_preview
  17 + * @property string $alias
  18 + * @property string $meta_title
  19 + * @property string $meta_description
  20 + * @property string $h1
  21 + * @property string $seo_text
  22 + * @property Article $article
  23 + * @property Language $language
24 24 */
25   - class BlogArticleLang extends ActiveRecord
  25 + class ArticleLang extends ActiveRecord
26 26 {
27 27 /**
28 28 * @inheritdoc
... ... @@ -34,11 +34,7 @@
34 34  
35 35 public function behaviors()
36 36 {
37   - return [
38   - 'slug' => [
39   - 'class' => 'artweb\artbox\behaviors\Slug',
40   - ],
41   - ];
  37 + return [];
42 38 }
43 39  
44 40 /**
... ... @@ -101,7 +97,7 @@
101 97 [ 'blog_article_id' ],
102 98 'exist',
103 99 'skipOnError' => true,
104   - 'targetClass' => BlogArticle::className(),
  100 + 'targetClass' => Article::className(),
105 101 'targetAttribute' => [ 'blog_article_id' => 'id' ],
106 102 ],
107 103 [
... ... @@ -137,9 +133,9 @@
137 133 /**
138 134 * @return \yii\db\ActiveQuery
139 135 */
140   - public function getBlogArticle()
  136 + public function getArticle()
141 137 {
142   - return $this->hasOne(BlogArticle::className(), [ 'id' => 'blog_article_id' ]);
  138 + return $this->hasOne(Article::className(), [ 'id' => 'blog_article_id' ]);
143 139 }
144 140  
145 141 /**
... ...
models/BlogArticleSearch.php renamed to models/ArticleSearch.php
... ... @@ -8,7 +8,7 @@
8 8 /**
9 9 * BlogArticleSearch represents the model behind the search form about `artweb\artbox\blog\models\BlogArticle`.
10 10 */
11   - class BlogArticleSearch extends BlogArticle
  11 + class ArticleSearch extends Article
12 12 {
13 13 /**
14 14 * @var string
... ... @@ -70,8 +70,8 @@
70 70 */
71 71 public function search($params)
72 72 {
73   - $query = BlogArticle::find()
74   - ->joinWith('lang');
  73 + $query = Article::find()
  74 + ->joinWith('lang');
75 75  
76 76 // add conditions that should always apply here
77 77  
... ...
views/blog-article/index.php
1 1 <?php
2 2  
3   - use artweb\artbox\blog\models\BlogArticle;
4   - use artweb\artbox\blog\models\BlogArticleSearch;
  3 + use artbox\weblog\models\Article;
  4 + use artbox\weblog\models\ArticleSearch;
5 5 use yii\data\ActiveDataProvider;
6 6 use yii\helpers\Html;
7 7 use yii\grid\GridView;
... ... @@ -9,7 +9,7 @@
9 9  
10 10 /**
11 11 * @var View $this
12   - * @var BlogArticleSearch $searchModel
  12 + * @var ArticleSearch $searchModel
13 13 * @var ActiveDataProvider $dataProvider
14 14 */
15 15  
... ... @@ -39,7 +39,7 @@
39 39 'attribute' => 'status',
40 40 'value' => function($model) {
41 41 /**
42   - * @var BlogArticle $model
  42 + * @var Article $model
43 43 */
44 44 return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active');
45 45 },
... ...
views/default/index.php deleted
1   -<div class="blog-default-index">
2   - <h1><?= $this->context->action->uniqueId ?></h1>
3   - <p>
4   - This is the view content for action "<?= $this->context->action->id ?>".
5   - The action belongs to the controller "<?= get_class($this->context) ?>"
6   - in the "<?= $this->context->module->id ?>" module.
7   - </p>
8   - <p>
9   - You may customize this page by editing the following file:<br>
10   - <code><?= __FILE__ ?></code>
11   - </p>
12   -</div>