request->getIsAjax()) { //throw new ForbiddenHttpException('Permission denied'); } if(!parent::beforeAction($action)) { return false; } return true; } public function actionCategoryForm($lang_id, $widget_id) { $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); if(!$model) { throw new NotFoundHttpException('Language not found'); } $category_lang = new ArticleCategoryLang(); return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]); } public function actionArticleForm($lang_id, $widget_id) { $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); if(!$model) { throw new NotFoundHttpException('Language not found'); } $article_lang = new ArticleLang(); return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]); } public function actionArticleMediaForm($lang_id, $widget_id, $type) { $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); if(!$model) { throw new NotFoundHttpException('Language not found'); } if(!in_array($type, ['full', 'preview'])) { throw new InvalidParamException('Type must only be full/preview'); } $article_lang = new ArticleMedia(); return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); } public function actionArticleCategoryMediaForm($lang_id, $widget_id, $type) { $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); if(!$model) { throw new NotFoundHttpException('Language not found'); } if(!in_array($type, ['full', 'preview'])) { throw new InvalidParamException('Type must only be full/preview'); } $article_lang = new ArticleCategoryMedia(); return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); } public function actionRemoveImage() { $post = \Yii::$app->request->post(); if(!empty($post['article_media_id'])) { $article_media = ArticleMedia::findOne($post['article_media_id']); if($post['remove_media']) { $media = $article_media->media->delete(); } if(!empty($article_media)) { $article_media->delete(); } return true; } else { return false; } } public function actionRemoveCategoryImage() { $post = \Yii::$app->request->post(); if(!empty($post['category_media_id'])) { $category_media = ArticleCategoryMedia::findOne($post['category_media_id']); if($post['remove_media']) { $media = $category_media->media->delete(); } if(!empty($category_media)) { $category_media->delete(); } return true; } else { return false; } } public function actionRemoveImageCategory() { $post = \Yii::$app->request->post(); if(!empty($post['category_media_id'])) { $category_media = ArticleCategoryMedia::findOne($post['category_media_id']); if($post['remove_media']) { $media = $category_media->media->delete(); } if(!empty($category_media)) { $category_media->delete(); } return true; } else { return false; } } }