diff --git a/common/modules/blog/Module.php b/common/modules/blog/Module.php index cd85726..29fee28 100755 --- a/common/modules/blog/Module.php +++ b/common/modules/blog/Module.php @@ -1,24 +1,24 @@ request->post('BlogArticle')[ 'blogTags' ] )) { foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { if ($category = BlogTag::findOne($item)) { @@ -117,6 +117,22 @@ } } + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'products' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'products' ] as $item) { + if ($product = Product::findOne($item)) { + $model->link('products', $product); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] as $item) { + if ($article = Product::findOne($item)) { + $model->link('blogArticles', $article); + } + } + } + return $this->redirect( [ 'view', @@ -132,6 +148,8 @@ 'modelLangs' => $model->modelLangs, 'categories' => $categories, 'tags' => $tags, + 'products' => [], + 'articles' => [], ] ); @@ -166,6 +184,24 @@ 'lang.label' ); + $products = ArrayHelper::map( + $model->getProducts() + ->joinWith('lang') + ->asArray() + ->all(), + 'id', + 'lang.title' + ); + + $articles = ArrayHelper::map( + $model->getBlogArticles() + ->joinWith('lang') + ->asArray() + ->all(), + 'id', + 'lang.title' + ); + if ($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request); if ($model->save() && $model->transactionStatus) { @@ -178,12 +214,30 @@ } } } - + 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); + if ($tag = BlogTag::findOne($item)) { + $model->link('blogTags', $tag); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'products' ] )) { + $model->unlinkAll('products', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'products' ] as $item) { + if ($product = Product::findOne($item)) { + $model->link('products', $product); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] )) { + $model->unlinkAll('blogArticles', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogArticles' ] as $item) { + if ($article = BlogArticle::findOne($item)) { + $model->link('blogArticles', $article); } } } @@ -203,6 +257,8 @@ 'modelLangs' => $model->modelLangs, 'categories' => $categories, 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, ] ); @@ -241,4 +297,95 @@ throw new NotFoundHttpException('The requested page does not exist.'); } } + + /** + * @param string $q + * @param null $id + * + * @return array + */ + public function actionProductList($q = NULL, $id = NULL) + { + \Yii::$app->response->format = Response::FORMAT_JSON; + $out = [ + 'results' => [ + 'id' => '', + 'text' => '', + ], + ]; + if (!is_null($q)) { + $out[ 'results' ] = Product::find() + ->joinWith('lang') + ->select( + [ + 'id', + 'product_lang.title as text', + ] + ) + ->where( + [ + 'like', + 'product_lang.title', + $q, + ] + ) + ->limit(20) + ->asArray() + ->all(); + } elseif ($id > 0) { + $out[ 'results' ] = [ + 'id' => $id, + 'text' => Product::find() + ->joinWith('lang') + ->where([ 'id' => $id ]) + ->one()->title, + ]; + } + return $out; + } + + /** + * @param string $q + * @param integer $id + * + * @return array + */ + public function actionArticleList($q = NULL, $id = NULL) + { + \Yii::$app->response->format = Response::FORMAT_JSON; + $out = [ + 'results' => [ + 'id' => '', + 'text' => '', + ], + ]; + if (!is_null($q)) { + $out[ 'results' ] = BlogArticle::find() + ->joinWith('lang') + ->select( + [ + 'blog_article.id as id', + 'blog_article_lang.title as text', + ] + ) + ->where( + [ + 'like', + 'blog_article_lang.title', + $q, + ] + ) + ->andWhere( + [ + '!=', + 'blog_article.id', + $id, + ] + ) + ->limit(20) + ->asArray() + ->all(); + } + return $out; + } } diff --git a/common/modules/blog/models/BlogArticle.php b/common/modules/blog/models/BlogArticle.php index 2070668..7f22431 100755 --- a/common/modules/blog/models/BlogArticle.php +++ b/common/modules/blog/models/BlogArticle.php @@ -14,34 +14,29 @@ /** * This is the model class for table "blog_article". * - * @property integer $id - * @property string $image - * @property integer $created_at - * @property integer $updated_at - * @property integer $deleted_at - * @property integer $sort - * @property boolean $status - * @property integer $author_id - * @property BlogArticleLang[] $blogArticleLangs - * @property Language[] $languages - * @property BlogArticleToArticle[] $blogArticleToArticles - * @property BlogArticleToArticle[] $blogArticleToArticles0 - * @property BlogArticle[] $relatedBlogArticles - * @property BlogArticle[] $blogArticles - * @property BlogArticleToCategory[] $blogArticleToCategories - * @property BlogCategory[] $blogCategories - * @property BlogArticleToProduct[] $blogArticleToProducts - * @property Product[] $products - * @property BlogArticleToTag[] $blogArticleToTags - * @property BlogTag[] $blogTags + * @property integer $id + * @property string $image + * @property integer $created_at + * @property integer $updated_at + * @property integer $deleted_at + * @property integer $sort + * @property boolean $status + * @property integer $author_id + * @property BlogArticleLang[] $blogArticleLangs + * @property Language[] $languages + * @property BlogArticle[] $relatedBlogArticles + * @property BlogArticle[] $blogArticles + * @property BlogCategory[] $blogCategories + * @property Product[] $products + * @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 + * @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() @@ -55,8 +50,8 @@ * @method bool getTransactionStatus() * * End language behavior * * * From SaveImgBehavior - * @property string|null $imageFile - * @property string|null $imageUrl + * @property string|null $imageFile + * @property string|null $imageUrl * @method string|null getImageFile( int $field ) * @method string|null getImageUrl( int $field ) * * End SaveImgBehavior @@ -156,22 +151,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToArticles() - { - return $this->hasMany(BlogArticleToArticle::className(), [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogArticleToArticles0() - { - return $this->hasMany(BlogArticleToArticle::className(), [ 'related_blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getRelatedBlogArticles() { return $this->hasMany(BlogArticle::className(), [ 'id' => 'related_blog_article_id' ]) @@ -190,14 +169,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToCategories() - { - return $this->hasMany(BlogArticleToCategory::className(), [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getBlogCategories() { return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) @@ -207,14 +178,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToProducts() - { - return $this->hasMany(BlogArticleToProduct::className(), [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getProducts() { return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) @@ -224,14 +187,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToTags() - { - return $this->hasMany(BlogArticleToTag::className(), [ 'blog_article_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getBlogTags() { return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ]) diff --git a/common/modules/blog/models/BlogArticleLang.php b/common/modules/blog/models/BlogArticleLang.php index 29e8047..3dad78e 100755 --- a/common/modules/blog/models/BlogArticleLang.php +++ b/common/modules/blog/models/BlogArticleLang.php @@ -1,97 +1,151 @@ [ - 'class' => 'common\behaviors\Slug', - ], - ]; - } + namespace common\modules\blog\models; + + use common\modules\language\models\Language; + use yii\db\ActiveRecord; /** - * @inheritdoc - */ - public function rules() - { - return [ - [['blog_article_id', 'language_id'], '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 + * This is the model class for table "blog_article_lang". + * + * @property integer $id + * @property integer $blog_article_id + * @property integer $language_id + * @property string $title + * @property string $body + * @property string $body_preview + * @property string $alias + * @property string $meta_title + * @property string $meta_description + * @property string $h1 + * @property string $seo_text + * @property BlogArticle $blogArticle + * @property Language $language */ - public function getLanguage() + class BlogArticleLang extends ActiveRecord { - return $this->hasOne(Language::className(), ['id' => 'language_id']); + /** + * @inheritdoc + */ + public static function tableName() + { + return 'blog_article_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'blog_article_id', + 'language_id', + ], + '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/common/modules/blog/models/BlogArticleSearch.php b/common/modules/blog/models/BlogArticleSearch.php index 1cb352e..7e9c0c2 100755 --- a/common/modules/blog/models/BlogArticleSearch.php +++ b/common/modules/blog/models/BlogArticleSearch.php @@ -1,84 +1,130 @@ $query, - ]); - - $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'); + /** + * @var string + */ + public $title; + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'id', + 'deleted_at', + 'sort', + 'author_id', + ], + 'integer', + ], + [ + [ 'image' ], + 'safe', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'title' ], + 'string', + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = BlogArticle::find() + ->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; } - - // grid filtering conditions - $query->andFilterWhere([ - 'id' => $this->id, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, - 'deleted_at' => $this->deleted_at, - 'sort' => $this->sort, - 'status' => $this->status, - 'author_id' => $this->author_id, - ]); - - $query->andFilterWhere(['like', 'image', $this->image]); - - return $dataProvider; } -} diff --git a/common/modules/blog/models/BlogCategory.php b/common/modules/blog/models/BlogCategory.php index a8a29b5..7463d49 100755 --- a/common/modules/blog/models/BlogCategory.php +++ b/common/modules/blog/models/BlogCategory.php @@ -12,23 +12,23 @@ /** * This is the model class for table "blog_category". * - * @property integer $id - * @property integer $sort - * @property string $image - * @property integer $parent_id - * @property boolean $status - * @property BlogArticleToCategory[] $blogArticleToCategories - * @property BlogArticle[] $blogArticles - * @property BlogCategoryLang[] $blogCategoryLangs - * @property Language[] $languages + * @property integer $id + * @property integer $sort + * @property string $image + * @property integer $parent_id + * @property boolean $status + * @property BlogArticle[] $blogArticles + * @property BlogCategoryLang[] $blogCategoryLangs + * @property Language[] $languages + * @property BlogCategory $parent * * From language behavior * - * @property BlogCategoryLang $lang - * @property BlogCategoryLang[] $langs - * @property BlogCategoryLang $objectLang - * @property string $ownerKey - * @property string $langKey - * @property BlogCategoryLang[] $modelLangs - * @property bool $transactionStatus + * @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() @@ -42,8 +42,8 @@ * @method bool getTransactionStatus() * * End language behavior * * * From SaveImgBehavior * - * @property string|null $imageFile - * @property string|null $imageUrl + * @property string|null $imageFile + * @property string|null $imageUrl * @method string|null getImageFile( int $field ) * @method string|null getImageUrl( int $field ) * * End SaveImgBehavior @@ -76,7 +76,7 @@ 'language' => [ 'class' => LanguageBehavior::className(), ], - 'Slug' => [ + 'Slug' => [ 'class' => 'common\behaviors\Slug', ], ]; @@ -105,7 +105,7 @@ 'max' => 255, ], [ - ['parent_id'], + [ 'parent_id' ], 'default', 'value' => 0, ], @@ -129,14 +129,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToCategories() - { - return $this->hasMany(BlogArticleToCategory::className(), [ 'blog_category_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getBlogArticles() { return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) @@ -159,4 +151,9 @@ return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) ->viaTable('blog_category_lang', [ 'blog_category_id' => 'id' ]); } + + public function getParent() + { + return $this->hasOne(BlogCategory::className(), [ 'id' => 'parent_id' ]); + } } diff --git a/common/modules/blog/models/BlogCategoryLang.php b/common/modules/blog/models/BlogCategoryLang.php index 4b98c1b..09a58b8 100755 --- a/common/modules/blog/models/BlogCategoryLang.php +++ b/common/modules/blog/models/BlogCategoryLang.php @@ -1,95 +1,146 @@ [ - 'class' => 'common\behaviors\Slug', - ], - ]; - } + + namespace common\modules\blog\models; + + use yii\db\ActiveRecord; + use common\modules\language\models\Language; /** - * @inheritdoc - */ - public function rules() - { - return [ - [['blog_category_id', 'language_id'], 'required'], - [['blog_category_id', 'language_id'], 'integer'], - [['description'], 'string'], - [['title', 'alias', 'meta_title', 'meta_description', 'h1', 'seo_text'], 'string', 'max' => 255], - [['alias'], 'unique'], - [['blog_category_id', 'language_id'], 'unique', 'targetAttribute' => ['blog_category_id', 'language_id'], 'message' => 'The combination of Blog Category ID and Language ID has already been taken.'], - [['blog_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => BlogCategory::className(), 'targetAttribute' => ['blog_category_id' => 'id']], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'blog_category_id' => 'Blog Category ID', - 'language_id' => 'Language ID', - 'title' => 'Title', - 'alias' => 'Alias', - 'description' => 'Description', - 'meta_title' => 'Meta Title', - 'meta_description' => 'Meta Description', - 'h1' => 'H1', - 'seo_text' => 'Seo Text', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogCategory() - { - return $this->hasOne(BlogCategory::className(), ['id' => 'blog_category_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "blog_category_lang". + * + * @property integer $id + * @property integer $blog_category_id + * @property integer $language_id + * @property string $title + * @property string $alias + * @property string $description + * @property string $meta_title + * @property string $meta_description + * @property string $h1 + * @property string $seo_text + * @property BlogCategory $blogCategory + * @property Language $language */ - public function getLanguage() + class BlogCategoryLang extends ActiveRecord { - return $this->hasOne(Language::className(), ['id' => 'language_id']); + /** + * @inheritdoc + */ + public static function tableName() + { + return 'blog_category_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'blog_category_id', + 'language_id', + ], + 'required', + ], + [ + [ + 'blog_category_id', + 'language_id', + ], + 'integer', + ], + [ + [ 'description' ], + 'string', + ], + [ + [ + 'title', + 'alias', + 'meta_title', + 'meta_description', + 'h1', + 'seo_text', + ], + 'string', + 'max' => 255, + ], + [ + [ 'alias' ], + 'unique', + ], + [ + [ + 'blog_category_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'blog_category_id', + 'language_id', + ], + 'message' => 'The combination of Blog Category ID and Language ID has already been taken.', + ], + [ + [ 'blog_category_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => BlogCategory::className(), + 'targetAttribute' => [ 'blog_category_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_category_id' => 'Blog Category ID', + 'language_id' => 'Language ID', + 'title' => 'Title', + 'alias' => 'Alias', + 'description' => 'Description', + 'meta_title' => 'Meta Title', + 'meta_description' => 'Meta Description', + 'h1' => 'H1', + 'seo_text' => 'Seo Text', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategory() + { + return $this->hasOne(BlogCategory::className(), [ 'id' => 'blog_category_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } } -} diff --git a/common/modules/blog/models/BlogCategorySearch.php b/common/modules/blog/models/BlogCategorySearch.php index a674c7a..5fc5d92 100755 --- a/common/modules/blog/models/BlogCategorySearch.php +++ b/common/modules/blog/models/BlogCategorySearch.php @@ -1,81 +1,128 @@ $query, - ]); - - $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'); + /** + * @var string + */ + public $title; + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'id', + 'sort', + 'parent_id', + ], + 'integer', + ], + [ + [ 'image' ], + 'safe', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'title' ], + 'string', + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = BlogCategory::find() + ->joinWith('lang', 'parent.lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => [ + 'attributes' => [ + 'title' => [ + 'asc' => [ 'blog_category_lang.title' => SORT_ASC ], + 'desc' => [ 'blog_category_lang.title' => SORT_DESC ], + ], + 'id', + ], + ], + ] + ); + + $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, + 'sort' => $this->sort, + 'parent_id' => $this->parent_id, + 'status' => $this->status, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'image', + $this->image, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'blog_category_lang.title', + $this->title, + ] + ); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'id' => $this->id, - 'sort' => $this->sort, - 'parent_id' => $this->parent_id, - 'status' => $this->status, - ]); - - $query->andFilterWhere(['like', 'image', $this->image]); - - return $dataProvider; } -} diff --git a/common/modules/blog/models/BlogTag.php b/common/modules/blog/models/BlogTag.php index 035ac5c..d65d43e 100755 --- a/common/modules/blog/models/BlogTag.php +++ b/common/modules/blog/models/BlogTag.php @@ -11,27 +11,26 @@ /** * This is the model class for table "blog_tag". * - * @property integer $id - * @property BlogArticleToTag[] $blogArticleToTags + * @property integer $id * @property BlogArticle[] $blogArticles * @property BlogTagLang[] $blogTagLangs - * @property Language[] $languages + * @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 + * @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 void setOwnerKey( string $value ) * @method string getLangKey() - * @method void setLangKey(string $value) + * @method void setLangKey( string $value ) * @method ActiveQuery getLangs() * @method ActiveQuery getLang( integer $language_id ) * @method BlogTagLang[] generateLangs() - * @method void loadLangs(Request $request) + * @method void loadLangs( Request $request ) * @method bool linkLangs() * @method bool saveLangs() * @method bool getTransactionStatus() @@ -46,7 +45,7 @@ { return 'blog_tag'; } - + /** * @inheritdoc */ @@ -85,14 +84,6 @@ /** * @return \yii\db\ActiveQuery */ - public function getBlogArticleToTags() - { - return $this->hasMany(BlogArticleToTag::className(), [ 'blog_tag_id' => 'id' ]); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getBlogArticles() { return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) diff --git a/common/modules/blog/models/BlogTagLang.php b/common/modules/blog/models/BlogTagLang.php index 55c4559..a894712 100755 --- a/common/modules/blog/models/BlogTagLang.php +++ b/common/modules/blog/models/BlogTagLang.php @@ -1,72 +1,110 @@ 255, + ], + [ + [ + 'blog_tag_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'blog_tag_id', + 'language_id', + ], + 'message' => 'The combination of Blog Tag ID and Language ID has already been taken.', + ], + [ + [ 'blog_tag_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => BlogTag::className(), + 'targetAttribute' => [ 'blog_tag_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_tag_id' => 'Blog Tag ID', + 'language_id' => 'Language ID', + 'label' => 'Label', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTag() + { + return $this->hasOne(BlogTag::className(), [ 'id' => 'blog_tag_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['blog_tag_id', 'language_id'], 'required'], - [['blog_tag_id', 'language_id'], 'integer'], - [['label'], 'string', 'max' => 255], - [['blog_tag_id', 'language_id'], 'unique', 'targetAttribute' => ['blog_tag_id', 'language_id'], 'message' => 'The combination of Blog Tag ID and Language ID has already been taken.'], - [['blog_tag_id'], 'exist', 'skipOnError' => true, 'targetClass' => BlogTag::className(), 'targetAttribute' => ['blog_tag_id' => 'id']], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'blog_tag_id' => 'Blog Tag ID', - 'language_id' => 'Language ID', - 'label' => 'Label', - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBlogTag() - { - return $this->hasOne(BlogTag::className(), ['id' => 'blog_tag_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['id' => 'language_id']); - } -} diff --git a/common/modules/blog/models/BlogTagSearch.php b/common/modules/blog/models/BlogTagSearch.php index 1380599..758fd70 100755 --- a/common/modules/blog/models/BlogTagSearch.php +++ b/common/modules/blog/models/BlogTagSearch.php @@ -1,74 +1,106 @@ $query, - ]); - - $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'); + /** + * @var string + */ + public $label; + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'id' ], + 'integer', + ], + [ + [ 'label' ], + 'string', + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = BlogTag::find() + ->joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => [ + 'attributes' => [ + 'id', + 'label' => [ + 'asc' => [ 'blog_tag_lang.label' => SORT_ASC ], + 'desc' => [ 'blog_tag_lang.label' => 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, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'blog_tag_lang.label', + $this->label, + ] + ); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'id' => $this->id, - ]); - - return $dataProvider; } -} diff --git a/common/modules/blog/views/blog-article/_form.php b/common/modules/blog/views/blog-article/_form.php index de57743..d9e8b35 100755 --- a/common/modules/blog/views/blog-article/_form.php +++ b/common/modules/blog/views/blog-article/_form.php @@ -9,6 +9,7 @@ use yii\web\View; use yii\widgets\ActiveForm; use common\modules\language\widgets\LanguageForm; + use yii\web\JsExpression; /** * @var View $this @@ -17,6 +18,8 @@ * @var BlogArticleLang[] $modelLangs * @var BlogCategory[] $categories * @var BlogTag[] $tags + * @var array $products + * @var array $articles */ ?> @@ -101,6 +104,68 @@ ] ); ?> + field($model, 'products') + ->widget( + Select2::className(), + [ + 'data' => $products, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select related products'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'language' => [ + 'errorLoading' => new JsExpression( + "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }" + ), + ], + 'ajax' => [ + 'url' => yii\helpers\Url::to([ '/blog/blog-article/product-list' ]), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), + ], + 'templateResult' => new JsExpression('function(product) { return product.text; }'), + 'templateSelection' => new JsExpression('function (product) { return product.text; }'), + ], + ] + ); + ?> + + field($model, 'blogArticles') + ->widget( + Select2::className(), + [ + 'data' => $articles, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select related articles'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'language' => [ + 'errorLoading' => new JsExpression( + "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }" + ), + ], + 'ajax' => [ + 'url' => yii\helpers\Url::to([ '/blog/blog-article/article-list' ]), + 'dataType' => 'json', + 'data' => new JsExpression( + 'function(params) { return {q:params.term, id:' . $model->id . '}; }' + ), + ], + 'templateResult' => new JsExpression('function(article) { return article.text; }'), + 'templateSelection' => new JsExpression('function (article) { return article.text; }'), + ], + ] + ); + ?> + field($model, 'sort') ->textInput() ?> diff --git a/common/modules/blog/views/blog-article/_search.php b/common/modules/blog/views/blog-article/_search.php index b644a88..dd2dc78 100755 --- a/common/modules/blog/views/blog-article/_search.php +++ b/common/modules/blog/views/blog-article/_search.php @@ -1,41 +1,43 @@
- - ['index'], - 'method' => 'get', - ]); ?> - + + [ 'index' ], + 'method' => 'get', + ] + ); ?> + field($model, 'id') ?> - + field($model, 'image') ?> - + field($model, 'created_at') ?> - + field($model, 'updated_at') ?> - + field($model, 'deleted_at') ?> - + field($model, 'sort') ?> - + field($model, 'status')->checkbox() ?> - + field($model, 'author_id') ?> - +
- 'btn btn-primary']) ?> - 'btn btn-default']) ?> + 'btn btn-primary' ]) ?> + 'btn btn-default' ]) ?>
- +
diff --git a/common/modules/blog/views/blog-article/create.php b/common/modules/blog/views/blog-article/create.php index 82025e3..0211f70 100755 --- a/common/modules/blog/views/blog-article/create.php +++ b/common/modules/blog/views/blog-article/create.php @@ -13,11 +13,13 @@ * @var BlogArticleLang[] $modelLangs * @var BlogCategory[] $categories * @var BlogTag[] $tags + * @var array $products + * @var array $articles */ - $this->title = 'Create Blog Article'; + $this->title = \Yii::t('blog', 'Create Blog Article'); $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Articles', + 'label' => \Yii::t('blog', 'Blog Articles'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -33,6 +35,8 @@ 'modelLangs' => $modelLangs, 'categories' => $categories, 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, ] ) ?> diff --git a/common/modules/blog/views/blog-article/index.php b/common/modules/blog/views/blog-article/index.php index b86118b..57564c2 100755 --- a/common/modules/blog/views/blog-article/index.php +++ b/common/modules/blog/views/blog-article/index.php @@ -1,39 +1,57 @@ title = 'Blog Articles'; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogArticle; + use common\modules\blog\models\BlogArticleSearch; + use yii\data\ActiveDataProvider; + use yii\helpers\Html; + use yii\grid\GridView; + use yii\web\View; + + /** + * @var View $this + * @var BlogArticleSearch $searchModel + * @var ActiveDataProvider $dataProvider + */ + + $this->title = \Yii::t('blog', 'Blog Articles'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

render('_search', ['model' => $searchModel]); ?> - +

- 'btn btn-success']) ?> + 'btn btn-success' ]) ?>

- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id', - 'image', - 'created_at', - 'updated_at', - 'deleted_at', - // 'sort', - // 'status:boolean', - // 'author_id', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'title', + 'value' => 'lang.title', + ], + 'imageUrl:image', + [ + 'attribute' => 'status', + 'value' => function($model) { + /** + * @var BlogArticle $model + */ + return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'); + }, + 'filter' => [ + 0 => \Yii::t('blog', 'Not active'), + 1 => \Yii::t('blog', 'Active'), + ], + ], + 'created_at:date', + 'updated_at:date', + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?>
diff --git a/common/modules/blog/views/blog-article/update.php b/common/modules/blog/views/blog-article/update.php index ac146d8..a7c0632 100755 --- a/common/modules/blog/views/blog-article/update.php +++ b/common/modules/blog/views/blog-article/update.php @@ -13,21 +13,23 @@ * @var BlogArticleLang[] $modelLangs * @var BlogCategory[] $categories * @var BlogTag[] $tags + * @var array $products + * @var array $articles */ - $this->title = 'Update Blog Article: ' . $model->id; + $this->title = \Yii::t('blog', 'Update Blog Article: ') . $model->lang->title; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Articles', + 'label' => \Yii::t('blog', 'Blog Articles'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->id, + 'label' => $model->lang->title, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); ?>
@@ -40,6 +42,8 @@ 'modelLangs' => $modelLangs, 'categories' => $categories, 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, ] ) ?> diff --git a/common/modules/blog/views/blog-article/view.php b/common/modules/blog/views/blog-article/view.php index 3433737..c96e500 100755 --- a/common/modules/blog/views/blog-article/view.php +++ b/common/modules/blog/views/blog-article/view.php @@ -1,42 +1,67 @@ title = $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogArticle; + use yii\helpers\Html; + use yii\web\View; + use yii\widgets\DetailView; + + /** + * @var View $this + * @var BlogArticle $model + */ + + $this->title = $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Articles'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- +

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', + $model->id, + ], + [ 'class' => 'btn btn-primary' ] + ) ?> + $model->id, ], - ]) ?> + [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ] + ) ?>

- - $model, - 'attributes' => [ - 'id', - 'image', - 'created_at', - 'updated_at', - 'deleted_at', - 'sort', - 'status:boolean', - 'author_id', - ], - ]) ?> + + $model, + 'attributes' => [ + 'id', + 'imageUrl:image', + 'created_at:date', + 'updated_at:date', + [ + 'attribute' => 'status', + 'value' => ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'), + ], + 'lang.alias', + 'lang.body:html', + ], + ] + ) ?>
diff --git a/common/modules/blog/views/blog-category/_form.php b/common/modules/blog/views/blog-category/_form.php index f8534b7..b9f0a21 100755 --- a/common/modules/blog/views/blog-category/_form.php +++ b/common/modules/blog/views/blog-category/_form.php @@ -2,7 +2,7 @@ use common\modules\blog\models\BlogCategory; use common\modules\blog\models\BlogCategoryLang; - use yii\bootstrap\Dropdown; + use kartik\select2\Select2; use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; @@ -66,10 +66,18 @@ field($model, 'sort') ->textInput() ?> - field($model, 'parent_id') - ->dropDownList($parentCategories, [ - 'prompt' => \Yii::t('blog', 'Has no parent rubric'), - ]) ?> + field($model, 'parent_id') + ->widget( + Select2::className(), + [ + 'data' => $parentCategories, + 'options' => [ 'placeholder' => \Yii::t('blog', 'Has no parent rubric') ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> field($model, 'status') ->checkbox() ?> diff --git a/common/modules/blog/views/blog-category/create.php b/common/modules/blog/views/blog-category/create.php index 8959883..aa403d3 100755 --- a/common/modules/blog/views/blog-category/create.php +++ b/common/modules/blog/views/blog-category/create.php @@ -12,9 +12,9 @@ * @var array $parentCategories */ - $this->title = 'Create Blog Category'; + $this->title = \Yii::t('blog', 'Create Blog Category'); $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Categories', + 'label' => \Yii::t('blog', 'Blog Categories'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; diff --git a/common/modules/blog/views/blog-category/index.php b/common/modules/blog/views/blog-category/index.php index 35009ba..4223172 100755 --- a/common/modules/blog/views/blog-category/index.php +++ b/common/modules/blog/views/blog-category/index.php @@ -1,36 +1,68 @@ title = 'Blog Categories'; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogCategory; + use common\modules\blog\models\BlogCategorySearch; + use yii\data\ActiveDataProvider; + use yii\helpers\Html; + use yii\grid\GridView; + use yii\web\View; + + /** + * @var View $this + * @var BlogCategorySearch $searchModel + * @var ActiveDataProvider $dataProvider + */ + + $this->title = \Yii::t('blog', 'Blog Categories'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

render('_search', ['model' => $searchModel]); ?> - +

- 'btn btn-success']) ?> + 'btn btn-success' ]) ?>

- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id', - 'sort', - 'image', - 'parent_id', - 'status:boolean', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'title', + 'value' => 'lang.title', + ], + 'imageUrl:image', + [ + 'label' => \Yii::t('blog', 'Parent category'), + 'value' => function($model) { + /** + * @var BlogCategory $model + */ + if (!empty( $model->parent )) { + return $model->parent->lang->title; + } else { + return false; + }; + }, + ], + [ + 'attribute' => 'status', + 'value' => function($model) { + /** + * @var BlogCategory $model + */ + return ( !$model->status ) ? \Yii::t('blog', 'Not active') : \Yii::t('blog', 'Active'); + }, + 'filter' => [ + 0 => \Yii::t('blog', 'Not active'), + 1 => \Yii::t('blog', 'Active'), + ], + ], + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?>
diff --git a/common/modules/blog/views/blog-category/update.php b/common/modules/blog/views/blog-category/update.php index f17da1c..1663cc0 100755 --- a/common/modules/blog/views/blog-category/update.php +++ b/common/modules/blog/views/blog-category/update.php @@ -12,19 +12,19 @@ * @var array $parentCategories */ - $this->title = 'Update Blog Category: ' . $model->id; + $this->title = \Yii::t('blog', 'Update Blog Category: ') . $model->lang->title; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Categories', + 'label' => \Yii::t('blog', 'Blog Categories'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->id, + 'label' => $model->lang->title, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); ?>
diff --git a/common/modules/blog/views/blog-category/view.php b/common/modules/blog/views/blog-category/view.php index 512bb4c..fc61c9d 100755 --- a/common/modules/blog/views/blog-category/view.php +++ b/common/modules/blog/views/blog-category/view.php @@ -1,39 +1,70 @@ title = $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogCategory; + use yii\helpers\Html; + use yii\web\View; + use yii\widgets\DetailView; + + /** + * @var View $this + * @var BlogCategory $model + */ + + $this->title = $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Categories'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- +

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', + $model->id, + ], + [ 'class' => 'btn btn-primary' ] + ) ?> + $model->id, ], - ]) ?> + [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ] + ) ?>

- - $model, - 'attributes' => [ - 'id', - 'sort', - 'image', - 'parent_id', - 'status:boolean', - ], - ]) ?> + + $model, + 'attributes' => [ + 'id', + 'sort', + 'imageUrl:image', + [ + 'attribute' => 'parent_id', + 'value' => ( !empty( $model->parent ) ) ? $model->parent->lang->title : '', + ], + 'lang.alias', + 'lang.description:text', + [ + 'attribute' => 'status', + 'value' => ( $model->status ) ? \Yii::t('blog', 'Active') : \Yii::t('blog', 'Not active'), + ], + ], + ] + ) ?>
diff --git a/common/modules/blog/views/blog-tag/create.php b/common/modules/blog/views/blog-tag/create.php index e57e010..4c515e1 100755 --- a/common/modules/blog/views/blog-tag/create.php +++ b/common/modules/blog/views/blog-tag/create.php @@ -11,9 +11,9 @@ * @var BlogTag $model */ - $this->title = 'Create Blog Tag'; + $this->title = \Yii::t('blog', 'Create Blog Tag'); $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Tags', + 'label' => \Yii::t('blog', 'Blog Tags'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; diff --git a/common/modules/blog/views/blog-tag/index.php b/common/modules/blog/views/blog-tag/index.php index 8ebb5c6..408174b 100755 --- a/common/modules/blog/views/blog-tag/index.php +++ b/common/modules/blog/views/blog-tag/index.php @@ -1,32 +1,42 @@ title = 'Blog Tags'; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogTagSearch; + use yii\data\ActiveDataProvider; + use yii\helpers\Html; + use yii\grid\GridView; + use yii\web\View; + + /** + * @var View $this + * @var BlogTagSearch $searchModel + * @var ActiveDataProvider $dataProvider + */ + + $this->title = \Yii::t('blog', 'Blog Tags'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

render('_search', ['model' => $searchModel]); ?> - +

- 'btn btn-success']) ?> + 'btn btn-success' ]) ?>

- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'label', + 'value' => 'lang.label', + ], + [ + 'class' => 'yii\grid\ActionColumn', + ], + ], + ] + ); ?>
diff --git a/common/modules/blog/views/blog-tag/update.php b/common/modules/blog/views/blog-tag/update.php index 539bd6f..564a089 100755 --- a/common/modules/blog/views/blog-tag/update.php +++ b/common/modules/blog/views/blog-tag/update.php @@ -11,19 +11,19 @@ * @var BlogTag $model */ - $this->title = 'Update Blog Tag: ' . $model->id; + $this->title = \Yii::t('blog', 'Update Blog Tag: ') . $model->lang->label; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Blog Tags', + 'label' => \Yii::t('blog', 'Blog Tags'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->id, + 'label' => $model->lang->label, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); ?>
diff --git a/common/modules/blog/views/blog-tag/view.php b/common/modules/blog/views/blog-tag/view.php index 28c02c8..897be1c 100755 --- a/common/modules/blog/views/blog-tag/view.php +++ b/common/modules/blog/views/blog-tag/view.php @@ -1,35 +1,59 @@ title = $model->id; -$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\blog\models\BlogTag; + use yii\helpers\Html; + use yii\web\View; + use yii\widgets\DetailView; + + /** + * @var View $this + * @var BlogTag $model + */ + + $this->title = $model->lang->label; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Tags'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- +

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', + $model->id, + ], + [ 'class' => 'btn btn-primary' ] + ) ?> + $model->id, ], - ]) ?> + [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ] + ) ?>

- - $model, - 'attributes' => [ - 'id', - ], - ]) ?> + + $model, + 'attributes' => [ + 'id', + 'lang.label', + ], + ] + ) ?>
diff --git a/common/translation/ru/blog.php b/common/translation/ru/blog.php index 506124e..936138e 100644 --- a/common/translation/ru/blog.php +++ b/common/translation/ru/blog.php @@ -1,6 +1,22 @@ 'Выберите категорию ...', - 'Select tag' => 'Выберите тэг ...', - 'Has no parent rubric' => 'Без категории', + 'Select category' => 'Выберите категорию ...', + 'Select tag' => 'Выберите тэг ...', + 'Has no parent rubric' => 'Без категории', + 'Waiting for results' => 'Загрузка ...', + 'Select related products' => 'Выберите сопутствующие товары', + 'Select related articles' => 'Выберите статьи', + 'Blog Articles' => 'Статьи блога', + 'Create Blog Article' => 'Создать статью', + 'Update Blog Article: ' => 'Обновить статью: ', + 'Not active' => 'Не активна', + 'Active' => 'Активна', + 'Are you sure you want to delete this item?' => 'Вы точно хотите это удалить ?', + 'Update' => 'Обновить', + 'Blog Categories' => 'Рубрики', + 'Create Blog Category' => 'Создать рубрику', + 'Update Blog Category: ' => 'Обновить рубрику: ', + 'Blog Tags' => 'Тэги', + 'Create Blog Tag' => 'Создать тэг', + 'Update Blog Tag: ' => 'Обновить тэг: ', ]; \ No newline at end of file -- libgit2 0.21.4