public function actionAll($id)
 {
     Url::remember(["all?id={$id}"], 'options');
     $dataProvider = OptionService::getPagination(['conditions' => ['categoryId' => $id]]);
     $category = CategoryService::findById($id);
     return $this->render('@cmsgears/module-core/admin/views/category/option/all', ['dataProvider' => $dataProvider, 'category' => $category]);
 }
 public function actionDelete($id)
 {
     // Find Model
     $model = CategoryService::findById($id);
     if (isset($_POST) && count($_POST) > 0) {
         if (CategoryService::delete($model)) {
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REQUEST), $model);
         }
     } else {
         // Generate Errors
         $errors = AjaxUtil::generateErrorMessage($model);
         // Trigger Ajax Failure
         return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST), $errors);
     }
 }
 public function actionDelete($id, $type = null, $dropDown = false)
 {
     // Find Model
     $model = CategoryService::findById($id);
     // Delete/Render if exist
     if (isset($model)) {
         $model->type = $type;
         if ($model->load(Yii::$app->request->post(), 'Category') && $model->validate()) {
             $categoryOptions = OptionService::findByCategoryId($id);
             if (isset($categoryOptions)) {
                 foreach ($categoryOptions as $option) {
                     try {
                         OptionService::delete($option);
                     } catch (Exception $e) {
                         throw new HttpException(409, Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_DEPENDENCY));
                     }
                 }
             }
             if (CategoryService::delete($model, $avatar)) {
                 return $this->redirect($this->returnUrl);
             }
         }
         $avatar = $model->avatar;
         return $this->render('@cmsgears/module-core/admin/views/category/delete', ['model' => $model, 'avatar' => $model->avatar, 'dropDown' => $dropDown]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
Beispiel #4
0
 public function actionDelete($id)
 {
     // Find Model
     $model = PostService::findById($id);
     $banner = new CmgFile();
     // Delete/Render if exist
     if (isset($model)) {
         $content = $model->content;
         if ($model->load(Yii::$app->request->post(), 'Post')) {
             if (PostService::delete($model)) {
                 ModelContentService::delete($content);
                 $this->redirect(['all']);
             }
         }
         $categories = CategoryService::getIdNameListByType(CmsGlobal::TYPE_POST);
         $visibilityMap = Page::$visibilityMap;
         $statusMap = Page::$statusMap;
         $banner = $content->banner;
         $templatesMap = TemplateService::getIdNameMapByType(CmsGlobal::TYPE_POST);
         $templatesMap = ArrayHelper::merge(['0' => 'Choose Template'], $templatesMap);
         return $this->render('delete', ['model' => $model, 'content' => $content, 'banner' => $banner, 'categories' => $categories, 'visibilityMap' => $visibilityMap, 'statusMap' => $statusMap, 'templatesMap' => $templatesMap]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }