Пример #1
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Place(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['Place'])) {
         $model->attributes = $_POST['Place'];
         $model->pic_other = $imageListSerialize['dataSerialize'];
         $data = $_POST['Place'];
         $model->rank = $data['rank'];
         $file = XUpload::upload($_FILES['attach']);
         $adr = XUpload::upload($_FILES['pic_adr']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if (is_array($adr)) {
             $model->pic_adr = $adr['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate() && $model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     }
     $this->render('place_update', array('model' => $model));
 }
Пример #2
0
 public function actionView($id)
 {
     $lesson = $this->loadModel($id);
     $userId = $this->_cookiesGet('userId');
     $userType = $this->_cookiesGet('userType');
     $this->_seoTitle = '课程 - ' . $lesson->name;
     //取报名人数
     $actual_students_criteria = new CDbCriteria();
     $actual_students = StudentLesson::model()->count($actual_students_criteria->addCondition("lesson_id =" . $id));
     $lesson->actual_students = $actual_students;
     $teacher = Teacher::model()->findByPk($lesson->teacher_id);
     $place = Place::model()->findByPk($lesson->place_id);
     //教学环境图片显示
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     //判断学员已收藏的课程
     if ($userType === 'student') {
         $is_focus = StudentLesson::model()->findByAttributes(array('student_id' => $userId, 'lesson_id' => $id, 'is_collection' => 1));
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($place->pic_other) {
         $imageList = unserialize($place->pic_other);
     }
     $this->render('view', array('is_focus' => $is_focus, 'isJoin' => $this->isJoin($userId, $id, 1), 'userType' => $userType, 'lesson' => $lesson, 'place' => $place, 'teacher' => $teacher, 'imageList' => $imageList));
 }
Пример #3
0
 public function actionUpdatePlace()
 {
     $model = Place::model()->findByPk($_GET['id']);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['Place'])) {
         $model->attributes = $_POST['Place'];
         $model->pic_other = $imageListSerialize['dataSerialize'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(192, 470)));
         $adr = XUpload::upload($_FILES['pic_adr'], array('thumb' => true, 'thumbSize' => array(498, 364)));
         if (is_array($file)) {
             $model->pic = $file['paththumbname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if (is_array($adr)) {
             $model->pic_adr = $adr['paththumbname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate() && $model->save()) {
             $this->redirect(array('/host/default/myplace'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->pic_other) {
         $imageList = unserialize($model->pic_other);
     }
     $this->render('addplace', array('model' => $model, 'imageList' => $imageList));
 }
Пример #4
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Family(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['Family'])) {
         $model->attributes = $_POST['Family'];
         $model->pic_other = $imageListSerialize['dataSerialize'];
         if ($model->validate() && $model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->pic_other) {
         $imageList = unserialize($model->pic_other);
     }
     $this->render('family_update', array('model' => $model, 'imageList' => $imageList));
 }
Пример #5
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('subject_update');
     $model = parent::_dataLoad(new Subject(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $layoutList = $this->_gets->getParam('layoutList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     $layoutListSerialize = XUtils::imageListSerialize($layoutList);
     if (isset($_POST['Subject'])) {
         $model->attributes = $_POST['Subject'];
         $model->date = strtotime($_POST['Subject']['date']);
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->room_type_image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->image_list = $imageListSerialize['dataSerialize'];
         $model->layout_list = $layoutListSerialize['dataSerialize'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑项目,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->image_list) {
         $imageList = unserialize($model->image_list);
     }
     if ($layoutList) {
         $layoutList = $layoutListSerialize['data'];
     } elseif ($model->layout_list) {
         $layoutList = unserialize($model->layout_list);
     }
     $this->city_list = parent::_groupList('city');
     $this->render('update', array('model' => $model, 'imageList' => $imageList, 'layoutList' => $layoutList));
 }
Пример #6
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $attr = $this->_gets->getParam('attr');
     $model = parent::_dataLoad(new Post(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['Post'])) {
         $style = $this->_gets->getParam('style');
         $acl = $this->_gets->getParam('acl');
         $styleFormat = XUtils::titleStyle($style);
         $model->attributes = $_POST['Post'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(400, 250)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
             $model->attach_status = 'Y';
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         $model->title_style = $styleFormat['text'];
         $model->title_style_serialize = $styleFormat['serialize'];
         $model->acl = is_array($acl) ? implode(',', $acl) : '';
         $model->image_list = $imageListSerialize['dataSerialize'];
         if ($model->save()) {
             Attr::xupdate($model->id, $attr);
             Post2tags::build('update', $_POST['Post']['tags'], $model->id, $model->catalog_id);
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $attrModel = Attr::lists($model->catalog_id, 'post');
     if ($attr) {
         $attrData = Attr::dataReset($attr);
     } else {
         $attrData = Attr::datas($model->id);
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->image_list) {
         $imageList = unserialize($model->image_list);
     }
     $this->render('update', array('model' => $model, 'imageList' => $imageList, 'attrModel' => $attrModel, 'attrData' => $attrData, 'groupList' => $this->_groupList('user')));
 }
Пример #7
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('house_update');
     $original = Yii::app()->request->getQuery('original');
     $model = parent::_dataLoad(new House(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['House'])) {
         $model->attributes = $_POST['House'];
         $model->accessDate = strtotime($_POST['House']['accessDate']);
         $model->match = implode(',', $_POST['House']['match']);
         $file = XUpload::upload($_FILES['house_image']);
         if (is_array($file)) {
             $model->house_image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->image_list = $imageListSerialize['dataSerialize'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑房源信息,ID:' . $id));
             if (!empty($original)) {
                 $this->redirect($original);
             } else {
                 $this->redirect(array('index'));
             }
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->image_list) {
         $imageList = unserialize($model->image_list);
     }
     $this->subject_list = parent::_groupList('subject');
     $this->city_list = parent::_groupList('city');
     $this->district_list = parent::_groupList('district');
     $this->investType_list = parent::_groupList('investType');
     $this->propertyType_list = parent::_groupList('propertyType');
     $this->match_list = parent::_groupList('match');
     $this->render('update', array('model' => $model, 'imageList' => $imageList, 'original' => $original));
 }