/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Illust(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Illust'])) { $model->attributes = $_POST['Illust']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionCreateIllust($mode) { /* validate all query string param */ $model = new Illust('create'); $model->categorize($mode); //this will throw new CHttpException(404,'test'); /*define the required variable for the controller base on the query string param */ $fileModel = new FileUploadFormModel(); $view; $scen; if ($model->Illust_cat_title == Illust::ILLUST_CAT_TITLE) { $scen = FileUploadFormModel::FILE_UPLOAD_MODE_SINGLE; $view = 'createIllust'; } else { $scen = FileUploadFormModel::FILE_UPLOAD_MODE_MULTI; $view = 'createManga'; } if (isset($_POST['Illust'])) { $model->setAttributes($_POST['Illust']); //$fileHandler->LoadUploadedeImageToModel(); //$model->photos = $fileHandler->photos; //$model->photos = CUploadedFile::getInstancesByName(BSMultiFileUploadWidget::fieldName); if ($model->validate()) { $fileModel->LoadUploadedeImage(); $fileModel->setScenario($scen); if ($fileModel->validate()) { if ($model->save()) { $ips = new ImageProcessService($fileModel, get_class($model), Yii::app()->user->user_name, $model->id); $ips->saveImage(150, 150); $SavedFileRelativePaths = $ips->getOriginalImageVirtualPath(); $SavedThumbnailFileRelativePaths = $ips->getThumbnailImageVirtualPath(); //$SavedFileRelativePaths = $fileModel->processImage(get_class($model),Yii::app()->user->user_name,$model->id); $model->save_img_src($SavedFileRelativePaths, $SavedThumbnailFileRelativePaths); $model->addOwnerUserId(Yii::app()->user->id); Yii::app()->user->setFlash(FlashMsg::SUCCESS, "投稿作品成功"); $this->redirect(SeoHelper::illustViewSEORouteArray($model)); } else { Yii::app()->user->setFlash(FlashMsg::ERROR, "投稿作品失敗"); } } } } $this->render($view, array('model' => $model, 'fileModel' => $fileModel)); }