예제 #1
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')));
 }
예제 #2
0
 /**
  * 自定义字段
  */
 public function actionCustom()
 {
     parent::_acl();
     if (XUtils::method() == 'POST') {
         foreach ((array) $_POST['attr'] as $key => $row) {
             $val = is_array($row['val']) ? implode(',', $row['val']) : $row['val'];
             $var = $row["name"];
             $config = Config::model()->find('scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var));
             if ($config) {
                 Config::model()->updateAll(array('value' => $val), 'scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var));
             } else {
                 $config = new Config();
                 $config->scope = 'custom';
                 $config->variable = $var;
                 $config->value = $val;
                 $config->save();
             }
         }
         XXcache::refresh('_config', 3600);
         AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id));
         XUtils::message('success', '更新完成', $this->createUrl($this->action->id));
     }
     $attrModel = Attr::lists(0, 'config');
     $this->render('custom', array('attrData' => self::loadData(), 'attrModel' => $attrModel));
 }