예제 #1
0
 public function actionUpdate($id)
 {
     // Find Model
     $model = PageService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $content = $model->content;
         $banner = CmgFile::loadFile($content->banner, 'File');
         $model->setScenario('update');
         if ($model->load(Yii::$app->request->post(), 'Page') && $content->load(Yii::$app->request->post(), 'ModelContent') && $model->validate() && $content->validate()) {
             $page = PageService::update($model);
             if (isset($page)) {
                 // Update Content
                 ModelContentService::update($content, $page->isPublished(), $banner);
                 $this->redirect(['all']);
             }
         }
         $visibilityMap = Page::$visibilityMap;
         $statusMap = Page::$statusMap;
         $templatesMap = TemplateService::getIdNameMapByType(CmsGlobal::TYPE_PAGE);
         $templatesMap = ArrayHelper::merge(['0' => 'Choose Template'], $templatesMap);
         return $this->render('update', ['model' => $model, 'content' => $content, 'banner' => $banner, 'visibilityMap' => $visibilityMap, 'statusMap' => $statusMap, 'templatesMap' => $templatesMap]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
예제 #2
0
 public function actionUpdate($id, $roleType = null, $roleSlug = null)
 {
     // Find Model
     $model = UserService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $siteMember = $model->siteMember;
         $avatar = CmgFile::loadFile($model->avatar, 'File');
         $model->setScenario('update');
         UserService::checkNewsletterMember($model);
         if ($model->load(Yii::$app->request->post(), 'User') && $siteMember->load(Yii::$app->request->post(), 'SiteMember') && $model->validate()) {
             // Update User and Site Member
             if (UserService::update($model, $avatar) && SiteMemberService::update($siteMember)) {
                 $this->redirect($this->returnUrl);
             }
         }
         if (isset($roleSlug)) {
             return $this->render('@cmsgears/module-core/admin/views/user/update', ['model' => $model, 'siteMember' => $siteMember, 'avatar' => $avatar, 'status' => User::$statusMapUpdate]);
         } else {
             $roleMap = RoleService::getIdNameMapByType($roleType);
             return $this->render('@cmsgears/module-core/admin/views/user/update', ['model' => $model, 'siteMember' => $siteMember, 'avatar' => $avatar, 'roleMap' => $roleMap, 'status' => User::$statusMapUpdate]);
         }
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
예제 #3
0
 public function actionUpdate($id)
 {
     // Find Model
     $model = SiteService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $avatar = CmgFile::loadFile($model->avatar, 'Avatar');
         $banner = CmgFile::loadFile($model->banner, 'Banner');
         $model->setScenario('update');
         if ($model->load(Yii::$app->request->post(), 'Site') && $model->validate()) {
             if (SiteService::update($model, $avatar)) {
                 return $this->redirect('all');
             }
         }
         return $this->render('update', ['model' => $model, 'avatar' => $avatar, 'banner' => $banner]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
예제 #4
0
 public function actionUpdate($id, $type = null, $dropDown = false)
 {
     // Find Model
     $model = CategoryService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $model->type = $type;
         $avatar = CmgFile::loadFile($model->avatar, 'Avatar');
         $model->setScenario('update');
         if ($model->load(Yii::$app->request->post(), 'Category') && $model->validate()) {
             if (CategoryService::update($model, $avatar)) {
                 return $this->redirect($this->returnUrl);
             }
         }
         $avatar = $model->avatar;
         return $this->render('@cmsgears/module-core/admin/views/category/update', ['model' => $model, 'avatar' => $avatar, 'dropDown' => $dropDown]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
예제 #5
0
 public function actionUpdate($id)
 {
     // Find Model
     $model = BlockService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $banner = CmgFile::loadFile($model->banner, 'Banner');
         $video = CmgFile::loadFile($model->video, 'Video');
         $texture = CmgFile::loadFile($model->texture, 'Texture');
         $model->setScenario('update');
         if ($model->load(Yii::$app->request->post(), 'Block') && $model->validate()) {
             if (BlockService::update($model, $banner, $video, $texture)) {
                 $this->redirect(['all']);
             }
         }
         $templatesMap = TemplateService::getIdNameMap(['conditions' => ['type' => CmsGlobal::TYPE_BLOCK], 'prepend' => [['name' => '0', 'value' => 'Choose Template']]]);
         return $this->render('update', ['model' => $model, 'banner' => $banner, 'video' => $video, 'texture' => $texture, 'templatesMap' => $templatesMap]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }