/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { //获取原node $model = $this->loadModel($id); //获取catalog表单 $model = $this->loadModel($id); $model->scenario = 'update'; $beforeModel = $model; $beforeParent = NULL; $beforeParent = $model->getParent()->id; $model->parent = $beforeParent; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Catalog'])) { $model->attributes = $_POST['Catalog']; $thumbUpload = CUploadedFile::getInstance($model, 'thumb_file'); if (!empty($thumbUpload)) { $model->thumb = Fircms::createFile($thumbUpload, 'thumb', 'update', $model->thumb, array(Yii::app()->config->get('thumbWidth'), Yii::app()->config->get('thumbHeight'))); } // 不等于自身id 不等于当前父节点 if ($model->parent != $model->id && $model->parent != $beforeParent) { //不允许是自身的子节点 if (!$this->loadModel($model->parent)->isDescendantOf($beforeModel)) { @$model->moveAsLast($this->loadModel($model->parent)); } } if ($model->saveNode()) { $this->redirect(array('admin')); } } $this->render('update', array('model' => $model)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Page'])) { $model->attributes = $_POST['Page']; $thumbUpload = CUploadedFile::getInstance($model, 'thumb_file'); if (!empty($thumbUpload)) { $model->thumb = Fircms::createFile($thumbUpload, 'thumb', 'update', $model->thumb, array(Yii::app()->config->get('thumbWidth'), Yii::app()->config->get('thumbHeight'))); } if ($model->save()) { $this->redirect(array('admin')); } } $this->render('update', array('model' => $model)); }