Exemplo n.º 1
0
 /**
  * 新增数据
  *
  */
 public function actionCreate()
 {
     $model = new Special();
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->_thumb_width = '500';
             $upload->_thumb_height = '400';
             $upload->uploadFile($_FILES['attach'], true);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $upload->deleteFile($upload->_thumb_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->attach_thumb = $upload->_thumb_name;
         }
         $model->create_time = time();
         if ($model->save()) {
             $this->redirect(array('special/index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 2
0
 public function run()
 {
     $model = new Special();
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         //封面、图标、 文件
         $model->img_cover = isset($_POST['img_cover']) ? $_POST['img_cover'] : '';
         $model->img_banner = isset($_POST['img_banner']) ? $_POST['img_banner'] : '';
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('update', array('model' => $model));
 }
Exemplo n.º 3
0
 /**
  * 专题录入
  */
 public function actionSpecialCreate()
 {
     parent::_acl('post_special_create');
     $model = new Special();
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(500, 400)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
         }
         if ($model->save()) {
             self::_adminiLogger(array('catalog' => 'update', 'intro' => '专题录入:' . $this->id . ',ID:' . $id));
             $this->redirect(array('special'));
         }
     }
     $this->render('special_create', array('model' => $model));
 }