Exemplo n.º 1
0
 /**
  * 内容模型管理
  */
 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()));
 }
Exemplo n.º 2
0
 /**
  * 
  * @param unknown_type $content_model_id
  */
 public function actionIndex($content_model_id)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['Field']['content_model_field_rank'])) {
             $_POST['Field']['content_model_field_rank'] = array();
         }
         foreach ($_POST['Field']['content_model_field_rank'] as $_k => $_v) {
             $flag = Yii::app()->db->createCommand()->update('{{content_model_fields}}', array('content_model_field_rank' => $_POST['Field']['content_model_field_rank'][$_k] ? intval($_POST['Field']['content_model_field_rank'][$_k]) : 255), 'content_model_field_id=:content_model_field_id', array(':content_model_field_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了内容模型({model_name})字段({field_name})排序';
                 $data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'model_name' => ContentModel::get_model_name_by_id($content_model_id), 'field_name' => ContentModelField::get_field_name_by_id($_v), 'addons_data' => $_POST);
                 AdminLogs::add(Yii::app()->user->id, 'Content/Model/Field', $_k, 'Modify', 'success', $message, $data);
             }
         }
         ContentModelField::update_cache();
         //$this->refresh();
         $this->redirect[] = array('text' => '', 'href' => url($this->module->id . "/Content/Model/{$content_model_id}/Field/Index"));
         $this->message('修改字段排序完成', self::MSG_SUCCESS, true);
     }
     $fields = ContentModelField::get_fields_by_cache($content_model_id);
     $this->render('index', array('fields' => $fields, "content_model_id" => $content_model_id));
 }