diff --git a/Module.php b/Module.php new file mode 100644 index 0000000..5b3ab70 --- /dev/null +++ b/Module.php @@ -0,0 +1,24 @@ +=7.0", + "yiisoft/yii2": "*", + "developeruz/yii2-db-rbac": "*" + }, + "autoload": { + "psr-4": { + "artweb\\artbox\\blog\\": "" + } + } +} \ No newline at end of file diff --git a/controllers/BlogArticleController.php b/controllers/BlogArticleController.php new file mode 100644 index 0000000..c5628f8 --- /dev/null +++ b/controllers/BlogArticleController.php @@ -0,0 +1,391 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all BlogArticle models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogArticleSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single BlogArticle model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogArticle model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogArticle(); + $model->generateLangs(); + + $categories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.title' + ); + + $tags = ArrayHelper::map( + BlogTag::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.label' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { + if ($category = BlogCategory::findOne($item)) { + $model->link('blogCategories', $category); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { + if ($category = BlogTag::findOne($item)) { + $model->link('blogTags', $category); + } + } + } + + 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', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'categories' => $categories, + 'tags' => $tags, + 'products' => [], + 'articles' => [], + ] + ); + + } + + /** + * Updates an existing BlogArticle model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + $categories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.title' + ); + + $tags = ArrayHelper::map( + BlogTag::find() + ->joinWith('lang') + ->all(), + 'id', + 'lang.label' + ); + + $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) { + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] )) { + $model->unlinkAll('blogCategories', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogCategories' ] as $item) { + if ($category = BlogCategory::findOne($item)) { + $model->link('blogCategories', $category); + } + } + } + + if (!empty( \Yii::$app->request->post('BlogArticle')[ 'blogTags' ] )) { + $model->unlinkAll('blogTags', true); + foreach (\Yii::$app->request->post('BlogArticle')[ 'blogTags' ] as $item) { + if ($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); + } + } + } + + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'categories' => $categories, + 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, + ] + ); + + } + + /** + * Deletes an existing BlogArticle model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogArticle model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogArticle the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogArticle::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + /** + * @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/controllers/BlogCategoryController.php b/controllers/BlogCategoryController.php new file mode 100644 index 0000000..9629c7e --- /dev/null +++ b/controllers/BlogCategoryController.php @@ -0,0 +1,201 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all BlogCategory models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single BlogCategory model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogCategory(); + $model->generateLangs(); + $parentCategories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->where( + [ + 'parent_id' => 0, + ] + ) + ->all(), + 'id', + 'lang.title' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'parentCategories' => $parentCategories, + ] + ); + + } + + /** + * Updates an existing BlogCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + $parentCategories = ArrayHelper::map( + BlogCategory::find() + ->joinWith('lang') + ->where( + [ + 'parent_id' => 0, + ] + ) + ->andWhere( + [ + '!=', + BlogCategory::tableName() . '_id', + $model->id, + ] + ) + ->all(), + 'id', + 'lang.title' + ); + + if ($model->load(Yii::$app->request->post())) { + $model->loadLangs(\Yii::$app->request); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'parentCategories' => $parentCategories, + ] + ); + + } + + /** + * Deletes an existing BlogCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogCategory::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/controllers/BlogTagController.php b/controllers/BlogTagController.php new file mode 100644 index 0000000..8e7aeeb --- /dev/null +++ b/controllers/BlogTagController.php @@ -0,0 +1,169 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all BlogTag models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogTagSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single BlogTag model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new BlogTag model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new BlogTag(); + $model->generateLangs(); + + if (\Yii::$app->request->isPost) { + $model->loadLangs(\Yii::$app->request); + $model->markAttributeDirty('id'); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + + } + + /** + * Updates an existing BlogTag model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + if (Yii::$app->request->isPost) { + $model->loadLangs(\Yii::$app->request); + $model->markAttributeDirty('id'); + if ($model->save() && $model->transactionStatus) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + + } + + /** + * Deletes an existing BlogTag model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BlogTag model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BlogTag the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = BlogTag::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php new file mode 100644 index 0000000..fd66593 --- /dev/null +++ b/controllers/DefaultController.php @@ -0,0 +1,20 @@ +render('index'); + } +} diff --git a/models/BlogArticle.php b/models/BlogArticle.php new file mode 100644 index 0000000..2ad15f4 --- /dev/null +++ b/models/BlogArticle.php @@ -0,0 +1,195 @@ + 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 getBlogArticleLangs() + { + return $this->hasMany(BlogArticleLang::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('blog_article_lang', [ 'blog_article_id' => '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 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 new file mode 100644 index 0000000..3e2af5c --- /dev/null +++ b/models/BlogArticleLang.php @@ -0,0 +1,151 @@ + [ + '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/models/BlogArticleSearch.php b/models/BlogArticleSearch.php new file mode 100644 index 0000000..c49f2d8 --- /dev/null +++ b/models/BlogArticleSearch.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/BlogCategory.php b/models/BlogCategory.php new file mode 100644 index 0000000..d03e35b --- /dev/null +++ b/models/BlogCategory.php @@ -0,0 +1,159 @@ + SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'blog/category', + ], + ], + ], + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + 'Slug' => [ + 'class' => 'common\behaviors\Slug', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'sort', + 'parent_id', + ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'image' ], + 'string', + 'max' => 255, + ], + [ + [ 'parent_id' ], + 'default', + 'value' => 0, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'sort' => 'Sort', + 'image' => 'Image', + 'parent_id' => 'Parent ID', + 'status' => 'Status', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_category', [ 'blog_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategoryLangs() + { + return $this->hasMany(BlogCategoryLang::className(), [ 'blog_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + 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/models/BlogCategoryLang.php b/models/BlogCategoryLang.php new file mode 100644 index 0000000..53368b7 --- /dev/null +++ b/models/BlogCategoryLang.php @@ -0,0 +1,146 @@ + [ + '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/models/BlogCategorySearch.php b/models/BlogCategorySearch.php new file mode 100644 index 0000000..25c4957 --- /dev/null +++ b/models/BlogCategorySearch.php @@ -0,0 +1,128 @@ +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; + } + } diff --git a/models/BlogTag.php b/models/BlogTag.php new file mode 100644 index 0000000..5cf4c27 --- /dev/null +++ b/models/BlogTag.php @@ -0,0 +1,109 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'id' ], + 'integer', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_tag', [ 'blog_tag_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTagLangs() + { + return $this->hasMany(BlogTagLang::className(), [ 'blog_tag_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('blog_tag_lang', [ 'blog_tag_id' => 'id' ]); + } + } diff --git a/models/BlogTagLang.php b/models/BlogTagLang.php new file mode 100644 index 0000000..dd14be8 --- /dev/null +++ b/models/BlogTagLang.php @@ -0,0 +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' ]); + } + } diff --git a/models/BlogTagSearch.php b/models/BlogTagSearch.php new file mode 100644 index 0000000..7e5a184 --- /dev/null +++ b/models/BlogTagSearch.php @@ -0,0 +1,106 @@ +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; + } + } diff --git a/views/blog-article/_form.php b/views/blog-article/_form.php new file mode 100644 index 0000000..4fcd766 --- /dev/null +++ b/views/blog-article/_form.php @@ -0,0 +1,187 @@ + + +
+ + [ 'enctype' => 'multipart/form-data' ], + ] + ); ?> + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-article/_form_language', + 'form' => $form, + ] + ); + ?> + + field($model, 'blogCategories') + ->widget( + Select2::className(), + [ + 'data' => $categories, + 'theme' => Select2::THEME_BOOTSTRAP, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select category'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> + + field($model, 'blogTags') + ->widget( + Select2::className(), + [ + 'data' => $tags, + 'theme' => Select2::THEME_BOOTSTRAP, + 'options' => [ + 'placeholder' => \Yii::t('blog', 'Select tag'), + 'multiple' => true, + ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + + field($model, '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() ?> + + field($model, 'status') + ->checkbox() ?> + + field($model, 'author_id') + ->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/views/blog-article/_form_language.php b/views/blog-article/_form_language.php new file mode 100644 index 0000000..cd5583e --- /dev/null +++ b/views/blog-article/_form_language.php @@ -0,0 +1,55 @@ + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']body') + ->widget( + CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions( + 'elfinder', + [ + 'preset' => 'full', + 'inline' => false, + 'filebrowserUploadUrl' => Yii::$app->getUrlManager() + ->createUrl('file/uploader/images-upload'), + ] + ), + ] + ) ?> + +field($model_lang, '[' . $language->id . ']body_preview') + ->textarea( + [ + 'rows' => '10', + ] + ) ?> + +field($model_lang, '[' . $language->id . ']meta_title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']meta_description') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']seo_text') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']h1') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/views/blog-article/_search.php b/views/blog-article/_search.php new file mode 100644 index 0000000..83f7b5e --- /dev/null +++ b/views/blog-article/_search.php @@ -0,0 +1,43 @@ + + +
+ + [ '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' ]) ?> +
+ + + +
diff --git a/views/blog-article/create.php b/views/blog-article/create.php new file mode 100644 index 0000000..ad5d97b --- /dev/null +++ b/views/blog-article/create.php @@ -0,0 +1,43 @@ +title = \Yii::t('blog', 'Create Blog Article'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Articles'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'categories' => $categories, + 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, + ] + ) ?> + +
diff --git a/views/blog-article/index.php b/views/blog-article/index.php new file mode 100644 index 0000000..d37c03c --- /dev/null +++ b/views/blog-article/index.php @@ -0,0 +1,57 @@ +title = \Yii::t('blog', 'Blog Articles'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $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/views/blog-article/update.php b/views/blog-article/update.php new file mode 100644 index 0000000..97ad490 --- /dev/null +++ b/views/blog-article/update.php @@ -0,0 +1,50 @@ +title = \Yii::t('blog', 'Update Blog Article: ') . $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Articles'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->lang->title, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'categories' => $categories, + 'tags' => $tags, + 'products' => $products, + 'articles' => $articles, + ] + ) ?> + +
diff --git a/views/blog-article/view.php b/views/blog-article/view.php new file mode 100644 index 0000000..90f8d6a --- /dev/null +++ b/views/blog-article/view.php @@ -0,0 +1,67 @@ +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, + '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/views/blog-category/_form.php b/views/blog-category/_form.php new file mode 100644 index 0000000..7d9595f --- /dev/null +++ b/views/blog-category/_form.php @@ -0,0 +1,94 @@ + + +
+ + [ 'enctype' => 'multipart/form-data' ], + + ] + ); ?> + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-category/_form_language', + 'form' => $form, + ] + ); + ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + + field($model, 'sort') + ->textInput() ?> + + field($model, 'parent_id') + ->widget( + Select2::className(), + [ + 'data' => $parentCategories, + 'options' => [ 'placeholder' => \Yii::t('blog', 'Has no parent rubric') ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ] + ); + ?> + + field($model, 'status') + ->checkbox() ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/views/blog-category/_form_language.php b/views/blog-category/_form_language.php new file mode 100644 index 0000000..7da5d86 --- /dev/null +++ b/views/blog-category/_form_language.php @@ -0,0 +1,37 @@ + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']description') + ->textarea( + [ + 'rows' => '10', + ] + ) ?> + +field($model_lang, '[' . $language->id . ']meta_title') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']meta_description') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']seo_text') + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']h1') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/views/blog-category/_search.php b/views/blog-category/_search.php new file mode 100644 index 0000000..ff95c1c --- /dev/null +++ b/views/blog-category/_search.php @@ -0,0 +1,35 @@ + + + diff --git a/views/blog-category/create.php b/views/blog-category/create.php new file mode 100644 index 0000000..81bfa8d --- /dev/null +++ b/views/blog-category/create.php @@ -0,0 +1,35 @@ +title = \Yii::t('blog', 'Create Blog Category'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Categories'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'parentCategories' => $parentCategories, + ] + ) ?> + +
diff --git a/views/blog-category/index.php b/views/blog-category/index.php new file mode 100644 index 0000000..960a553 --- /dev/null +++ b/views/blog-category/index.php @@ -0,0 +1,68 @@ +title = \Yii::t('blog', 'Blog Categories'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $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/views/blog-category/update.php b/views/blog-category/update.php new file mode 100644 index 0000000..6818f17 --- /dev/null +++ b/views/blog-category/update.php @@ -0,0 +1,42 @@ +title = \Yii::t('blog', 'Update Blog Category: ') . $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Categories'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->lang->title, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'parentCategories' => $parentCategories, + ] + ) ?> + +
diff --git a/views/blog-category/view.php b/views/blog-category/view.php new file mode 100644 index 0000000..34ef334 --- /dev/null +++ b/views/blog-category/view.php @@ -0,0 +1,70 @@ +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, + '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/views/blog-tag/_form.php b/views/blog-tag/_form.php new file mode 100644 index 0000000..5c18d1e --- /dev/null +++ b/views/blog-tag/_form.php @@ -0,0 +1,41 @@ + + +
+ + + + $modelLangs, + 'formView' => '@common/modules/blog/views/blog-tag/_form_language', + 'form' => $form, + ] + ); + ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/views/blog-tag/_form_language.php b/views/blog-tag/_form_language.php new file mode 100644 index 0000000..d1fc0a1 --- /dev/null +++ b/views/blog-tag/_form_language.php @@ -0,0 +1,15 @@ + +field($model_lang, '[' . $language->id . ']label') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/views/blog-tag/_search.php b/views/blog-tag/_search.php new file mode 100644 index 0000000..8a133ba --- /dev/null +++ b/views/blog-tag/_search.php @@ -0,0 +1,27 @@ + + + diff --git a/views/blog-tag/create.php b/views/blog-tag/create.php new file mode 100644 index 0000000..caddd30 --- /dev/null +++ b/views/blog-tag/create.php @@ -0,0 +1,33 @@ +title = \Yii::t('blog', 'Create Blog Tag'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Tags'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + +
diff --git a/views/blog-tag/index.php b/views/blog-tag/index.php new file mode 100644 index 0000000..086fb34 --- /dev/null +++ b/views/blog-tag/index.php @@ -0,0 +1,42 @@ +title = \Yii::t('blog', 'Blog Tags'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'label', + 'value' => 'lang.label', + ], + [ + 'class' => 'yii\grid\ActionColumn', + ], + ], + ] + ); ?> +
diff --git a/views/blog-tag/update.php b/views/blog-tag/update.php new file mode 100644 index 0000000..90d8c9a --- /dev/null +++ b/views/blog-tag/update.php @@ -0,0 +1,40 @@ +title = \Yii::t('blog', 'Update Blog Tag: ') . $model->lang->label; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('blog', 'Blog Tags'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->lang->label, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('blog', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + +
diff --git a/views/blog-tag/view.php b/views/blog-tag/view.php new file mode 100644 index 0000000..f11884b --- /dev/null +++ b/views/blog-tag/view.php @@ -0,0 +1,59 @@ +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, + 'attributes' => [ + 'id', + 'lang.label', + ], + ] + ) ?> + +
diff --git a/views/default/index.php b/views/default/index.php new file mode 100644 index 0000000..650b9c5 --- /dev/null +++ b/views/default/index.php @@ -0,0 +1,12 @@ +
+

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