コード例 #1
0
ファイル: Model.php プロジェクト: nbaiwan/yav
 public function updateAction($id)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['Model']) || !is_array($_POST['Model'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存采集模型信息错误', self::MSG_ERROR, true);
         }
         if ($_POST['Model']['collect_model_name'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('采集模型名称不能为空', self::MSG_ERROR, true);
         }
         if ($_POST['Model']['collect_model_identify'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('采集模型标识不能为空', self::MSG_ERROR, true);
         }
         if (preg_match("/^[0-9]+.*/", $_POST['Model']['collect_model_identify'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('采集模型标识不能以数字开头', self::MSG_ERROR, true);
         }
         $old_collect_model_identify = CollectModelModel::inst()->getModelIdentifyById($id);
         $sql = "SELECT `collect_model_identify` FROM `{{collect_model}}` WHERE `collect_model_id`!=:collect_model_id AND collect_model_identify=:collect_model_identify";
         $params = array(':collect_model_id' => $id, ':collect_model_identify' => $_POST['Model']['collect_model_identify']);
         if ($this->db->queryScalar($sql, $params)) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('采集模型标识不能重复', self::MSG_ERROR, true);
         }
         $flag = $this->db->update('{{collect_model}}', array('collect_model_name' => $_POST['Model']['collect_model_name'], 'collect_model_identify' => $_POST['Model']['collect_model_identify'], 'collect_model_rank' => $_POST['Model']['collect_model_rank'] ? intval($_POST['Model']['collect_model_rank']) : 255, 'collect_model_lasttime' => $_SERVER['REQUEST_TIME'], 'content_model_id' => $_POST['Model']['content_model_id']), 'collect_model_id=:collect_model_id', array(':collect_model_id' => $id));
         if ($old_collect_model_identify != $_POST['Model']['collect_model_identify']) {
             $sql = "RENAME TABLE `collect_model_addons{$old_collect_model_identify}` TO `collect_model_addons" . $_POST['Model']['collect_model_identify'] . "` ;";
             $this->db->execute($sql);
         }
         if ($flag) {
             $collect_model_id = $this->db->getLastInsertID();
             $collect_model_name = $_POST['Model']['collect_model_name'];
             //更新缓存
             CollectModelModel::inst()->updateCache();
             //记录操作日志
             $message = '{user_name}修改了采集模型{collect_model_name}';
             $data = array('collect_model_name' => $collect_model_name, 'addons_data' => array('collect_model_id' => $collect_model_id));
             UserLogsModel::inst()->add('Collect/Model', $collect_model_id, 'Insert', 'success', $message, $data);
             if (!isset($_GET['ajax'])) {
                 $this->redirect[] = array('text' => '', 'href' => '/collect/model/index');
                 $this->message('保存采集模型成功', self::MSG_SUCCESS, true);
             }
         } else {
             //记录操作日志
             $message = '{user_name}修改采集模型({collect_model_name})信息失败';
             $data = array('collect_model_name' => $collect_model_name, 'addons_data' => array('model' => $_POST['Model']));
             UserLogsModel::inst()->add('Collect/Model', $collect_model_id, 'Modify', 'failure', $message, $data);
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存采集模型信息失败', self::MSG_ERROR, true);
         }
     }
     $model = CollectModelModel::inst()->getModelById($id, false);
     if (empty($model)) {
         $this->redirect[] = array('text' => '', 'href' => '/collect/model/index');
         $this->message('采集模型不存在或已被删除', self::MSG_ERROR, true);
     }
     //print_r($model);
     $this->getView()->assign(array('model' => $model, 'content_model' => ContentModelModel::inst()->getModelsByCache()));
 }
コード例 #2
0
ファイル: Model.php プロジェクト: nbaiwan/yav
 /**
  * 内容模型管理
  */
 public function indexAction($page = null)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['Model']['content_model_rank'])) {
             $_POST['Model']['content_model_rank'] = array();
         }
         foreach ($_POST['Model']['content_model_rank'] as $_k => $_v) {
             $flag = Yii::app()->db->createCommand()->update('{{content_model}}', array('content_model_rank' => $_POST['Model']['content_model_rank'][$_k] ? intval($_POST['Model']['content_model_rank'][$_k]) : 255, 'content_model_lasttime' => $_SERVER['REQUEST_TIME']), 'content_model_id=:content_model_id', array(':content_model_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了内容模型({model_name})排序';
                 $data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'model_name' => ContentModel::get_model_name_by_id($_k), 'addons_data' => $_POST);
                 AdminLogs::add(Yii::app()->user->id, 'Content/Model', $_k, 'Modify', 'success', $message, $data);
             }
         }
         ContentModel::update_cache();
         //$this->refresh();
         $this->redirect[] = array('text' => '', 'href' => '/content/model/index');
         $this->message('修改内容模型完成', self::MSG_SUCCESS, true);
     }
     $this->getView()->assign(array('models' => ContentModelModel::inst()->getModelsByCache()));
 }
コード例 #3
0
ファイル: Class.php プロジェクト: nbaiwan/yav
 /**
  * 档案栏目管理
  */
 public function indexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['class_name'])) {
             $_POST['class_name'] = array();
         }
         foreach ($_POST['class_name'] as $_k => $_v) {
             $flag = $this->db->update('{{content_archives_classes}}', array('class_name' => $_v, 'class_identify' => $_POST['class_identify'][$_k], 'content_model_id' => $_POST['content_model_id'][$_k], 'class_is_show' => $_POST['class_is_show'][$_k], 'class_rank' => $_POST['class_rank'][$_k], 'class_lasttime' => $_SERVER['REQUEST_TIME']), 'class_id=:class_id', array(':class_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了档案栏目{classes_name}';
                 $data = array('classes_name' => $_v, 'data' => $_POST);
                 AdminLogs::add('Content/Class', $_k, 'Modify', 'success', $message, $data);
             }
         }
         //添加新记录
         if (!is_array($_POST['class_name_new'])) {
             $_POST['class_name_new'] = array();
         }
         foreach ($_POST['class_name_new'] as $_k => $_v) {
             if (is_array($_v)) {
                 foreach ($_v as $__k => $__v) {
                     $flag = $this->db->insert('{{content_archives_classes}}', array('class_id' => 0, 'class_parent_id' => $_k, 'class_name' => $__v, 'content_model_id' => $_POST['content_model_id_new'][$_k][$__k], 'class_identify' => $_POST['class_identify_new'][$_k][$__k], 'class_is_default' => 0, 'class_default' => 'index.html', 'class_is_part' => ContentArchivesClass::STAT_PART_COVER_CLASS, 'class_tempindex' => '', 'class_templist' => '', 'class_temparticle' => '', 'class_seo_keywords' => '', 'class_seo_description' => '', 'class_status' => ContentArchivesClass::STAT_STATUS_NORMAL, 'class_is_show' => isset($_POST['class_is_show_new'][$_k][$__k]) ? $_POST['class_is_show_new'][$_k][$__k] : 0, 'class_rank' => $_POST['class_rank_new'][$_k][$__k], 'class_lasttime' => $_SERVER['REQUEST_TIME'], 'class_dateline' => $_SERVER['REQUEST_TIME']));
                     if ($flag) {
                         //记录操作日志
                         $message = '{user_name}添加了游戏子栏目{classes_name}';
                         $data = array('classes_name' => $__v, 'data' => $_POST);
                         AdminLogs::add('Content/Class', $this->db->getLastInsertID(), 'Insert', 'success', $message, $data);
                     }
                 }
             } else {
                 $flag = $this->db->insert('{{content_archives_classes}}', array('class_id' => 0, 'class_parent_id' => 0, 'class_name' => $_v, 'content_model_id' => $_POST['content_model_id_new'][$_k], 'class_identify' => $_POST['class_identify_new'][$_k], 'class_is_default' => 0, 'class_default' => 'index.html', 'class_is_part' => ContentArchivesClass::STAT_PART_COVER_CLASS, 'class_tempindex' => '', 'class_templist' => '', 'class_temparticle' => '', 'class_seo_keywords' => '', 'class_seo_description' => '', 'class_status' => ContentArchivesClass::STAT_STATUS_NORMAL, 'class_is_show' => isset($_POST['class_is_show_new'][$_k]) ? $_POST['class_is_show_new'][$_k] : 0, 'class_rank' => $_POST['class_rank_new'][$_k], 'class_lasttime' => $_SERVER['REQUEST_TIME'], 'class_dateline' => $_SERVER['REQUEST_TIME']));
                 if ($flag) {
                     //记录操作日志
                     $message = '{user_name}添加了档案栏目{classes_name}';
                     $data = array('classes_name' => $_v, 'data' => $_POST);
                     AdminLogs::add('Content/Class', $this->db->getLastInsertID(), 'Insert', 'success', $message, $data);
                 }
             }
         }
         ContentArchivesClassModel::updateCache();
         $this->refresh();
     }
     //
     $classes = ContentArchivesClassModel::inst()->getClassesByCache();
     //
     $models = ContentModelModel::inst()->getModelsByCache();
     $this->getView()->assign(array('classes' => $classes, 'models' => $models));
 }
コード例 #4
0
ファイル: ContentModel.php プロジェクト: nbaiwan/yav
 /**
  * 强制更新缓存
  */
 public function updateCache()
 {
     //
     self::$__models = null;
     //
     if (isset($this->cache)) {
         self::$__models = $this->readModelsArray();
         $this->cache->set('content.models', self::$__models);
     }
     return true;
 }