Exemplo n.º 1
0
 public function actionBindCategories()
 {
     $binder = new Binder();
     if ($binder->load(Yii::$app->request->post(), 'Binder')) {
         if (PostService::bindCategories($binder)) {
             // Trigger Ajax Success
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REQUEST));
         }
     }
     // Trigger Ajax Failure
     return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST));
 }
Exemplo n.º 2
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));
 }