コード例 #1
0
 /**
  * 添加/编辑内容
  */
 public function action()
 {
     $field = \Model\Field::fieldList($this->model['model_id'], '1');
     $id = $this->g('id');
     if (empty($id)) {
         $this->assign('method', 'POST');
         $this->assign('title', "{$GLOBALS['_LANG']['CONTENT']['ADD']} - {$this->model['lang_key']}");
     } else {
         $content = \Model\Content::findContent($this->table, $id, "{$this->fieldPrefix}id");
         if (empty($content)) {
             $this->error($GLOBALS['_LANG']['CONTENT']['NOT_EXIST_CONTENT']);
         }
         $this->assign($content);
         $this->assign('method', 'PUT');
         $this->assign('id', $id);
         $this->assign('title', "{$GLOBALS['_LANG']['CONTENT']['EDIT']} - {$this->model['lang_key']}");
         foreach ($field as $key => $value) {
             $field[$key] = $value;
             $field[$key]['value'] = $content["{$this->fieldPrefix}{$value['field_name']}"];
         }
     }
     $this->assign('field', $field);
     $this->assign('form', new \Expand\Form\Form());
     $this->layout(is_file(THEME . '/' . GROUP . "/{$this->theme['value']}/" . MODULE . "_action.php") ? MODULE . "_action" : 'Content_action');
 }
コード例 #2
0
ファイル: Content.class.php プロジェクト: qlau/PESCMS-DOC
 /**
  * 添加/编辑内容
  */
 public function action()
 {
     $field = \Model\Field::fieldList($this->model['model_id'], array('field_status' => '1'));
     $id = $this->g('id');
     if (empty($id)) {
         $this->assign('method', 'POST');
         $this->assign('title', "添加 - {$this->model['lang_key']}");
     } else {
         $content = \Model\Content::findContent($this->table, $id, "{$this->fieldPrefix}id");
         if (empty($content)) {
             $this->error('不存在的内容');
         }
         $this->assign($content);
         $this->assign('method', 'PUT');
         $this->assign('id', $id);
         $this->assign('title', "编辑 - {$this->model['lang_key']}");
         foreach ($field as $key => $value) {
             $field[$key] = $value;
             $field[$key]['value'] = $content["{$this->fieldPrefix}{$value['field_name']}"];
         }
     }
     $this->assign('field', $field);
     $this->assign('form', new \Expand\Form\Form());
     $this->display(is_file(THEME . '/' . GROUP . "/{$this->theme}/" . MODULE . '/' . MODULE . "_action.php") ? MODULE . "_action" : 'Content_action');
 }
コード例 #3
0
ファイル: Model.class.php プロジェクト: hurricanetx/PESCMS2
 /**
  * 模型字段管理
  */
 public function fieldList()
 {
     $modelId = $this->isG('id', '请选择模型');
     $model = \Model\ModelManage::findModel($modelId);
     $this->assign('title', "字段管理 - {$model['lang_key']}");
     $this->assign('list', \Model\Field::fieldList($modelId));
     $this->assign('modelId', $modelId);
     $this->layout();
 }
コード例 #4
0
 /**
  * 模型字段管理
  */
 public function fieldList()
 {
     $modelId = $this->isG('id', $GLOBALS['_LANG']['MODEL']['SELECT_MODEL_ID']);
     $model = \Model\Model::findModel($modelId);
     $this->assign('title', "{$GLOBALS['_LANG']['MODEL']['FIELD_MANAGE']} - {$model['lang_key']}");
     $this->assign('list', \Model\Field::fieldList($modelId));
     $this->assign('modelId', $modelId);
     $this->layout();
 }
コード例 #5
0
ファイル: Content.class.php プロジェクト: Myazure/PESCMS2
 public function __init()
 {
     parent::__init();
     //表名
     $this->table = strtolower(MODULE);
     //表前缀
     $this->fieldPrefix = $this->table . "_";
     $this->assign('fieldPrefix', $this->fieldPrefix);
     //验证模型是否存在
     $this->model = \Model\ModelManage::findModel($this->table, 'model_name');
     if (empty($this->model)) {
         $this->error('不存在的模型');
     }
     $this->modelThemePrefixPath = THEME_PATH . '/' . MODULE . '/' . MODULE;
     //获取模型的字段列表
     $fieldShowType = ACTION == 'index' ? 'field_list' : 'field_form';
     $this->field = \Model\Field::fieldList($this->model['model_id'], ['field_status' => '1', $fieldShowType => '1']);
 }
コード例 #6
0
ファイル: Content.class.php プロジェクト: Myazure/PESCMS2
 /**
  * 内容列表
  */
 public function _list()
 {
     $catid = $this->isG('id', '请选择分类');
     $catid = $this->categorys[$catid]['category_child'];
     $orderBy = "{$this->model}_id DESC";
     $field = \Model\Field::fieldList($this->modelInfo['model_id'], array('field_status' => '1', 'field_list' => '1'));
     $condition = "{$this->model}_catid in ({$catid}) AND {$this->model}_status = 1";
     foreach ($field as $key => $value) {
         if (!empty($_GET)) {
             foreach ($_GET as $gk => $gv) {
                 if ($gk == $value['field_name']) {
                     $condition .= " AND {$this->model}_{$value['field_name']} = :{$value['field_name']} ";
                     $data[$value['field_name']] = "{$gv}";
                 }
             }
         }
         //判断是否存在排序字段
         if ($value['field_name'] == 'listsort') {
             $orderBy = "{$this->model}_listsort ASC, {$orderBy}";
         }
     }
     $page = new \Expand\Page();
     $total = count($this->db($this->model)->where($condition)->select($data));
     $count = $page->total($total);
     $page->handle();
     $list = $this->db($this->model)->where($condition)->order($orderBy)->limit("{$page->firstRow}, {$page->listRows}")->select($data);
     $show = $page->show();
     $this->assign('title', $this->categorys[$catid]['category_name']);
     $this->assign('keyword', $this->categorys[$catid]['category_keyword']);
     $this->assign('description', $this->categorys[$catid]['category_description']);
     $this->assign('page', $show);
     $this->assign('list', $list);
     if (empty($this->categorys[$catid]['theme'])) {
         $theme = MODULE . "_list";
         $themeFunc = 'layout';
     } else {
         $theme = $this->categorys[$catid]['theme'];
         $themeFunc = 'display';
     }
     $this->layout(is_file(THEME . '/' . GROUP . "/{$this->theme}/" . MODULE . "/{$theme}.php") ? $theme : 'Content_list');
 }
コード例 #7
0
ファイル: Content.class.php プロジェクト: Myazure/PESCMS2
 /**
  * 基础表单
  */
 public static function baseFrom()
 {
     self::$table = strtolower(MODULE);
     self::$fieldPrefix = self::$table . "_";
     self::$model = \Model\ModelManage::findModel(self::$table, 'model_name');
     $field = \Model\Field::fieldList(self::$model['model_id'], array('field_status' => '1'));
     if (self::p('method') == 'PUT') {
         $data['noset'][self::$fieldPrefix . 'id'] = self::isP('id', '丢失模型ID');
         if (!self::findContent(self::$table, $data['noset'][self::$fieldPrefix . 'id'], self::$fieldPrefix . 'id')) {
             self::error('不存在的模型');
         }
     }
     foreach ($field as $value) {
         /**
          * 判断提交的字段是否为数组
          */
         if (is_array($_POST[$value['field_name']])) {
             $_POST[$value['field_name']] = (string) implode(',', $_POST[$value['field_name']]);
         }
         /**
          * 时间转换为时间戳
          */
         if ($value['field_type'] == 'date') {
             $_POST[$value['field_name']] = (string) strtotime($_POST[$value['field_name']]);
         }
         if ($value['field_required'] == '1') {
             if (!($data[self::$fieldPrefix . $value['field_name']] = self::p($value['field_name'])) && !is_numeric($data[self::$fieldPrefix . $value['field_name']])) {
                 self::error($value['field_display_name'] . '为必填选项');
             }
         } else {
             if (!($data[self::$fieldPrefix . $value['field_name']] = self::p($value['field_name']))) {
                 $data[self::$fieldPrefix . $value['field_name']] = $value['field_default'];
             }
         }
     }
     return $data;
 }
コード例 #8
0
 /**
  * 基础表单
  */
 public static function baseFrom()
 {
     self::$table = strtolower(MODULE);
     self::$fieldPrefix = self::$table . "_";
     self::$model = \Model\Model::findModel(self::$table, 'model_name');
     $field = \Model\Field::fieldList(self::$model['model_id'], '1');
     if (self::p('method') == 'PUT') {
         if (!($data['noset'][self::$fieldPrefix . 'id'] = self::isP('id'))) {
             return self::error($GLOBALS['_LANG']['MODEL']['LOST_MODEL_ID']);
         }
         if (!self::findContent(self::$table, $data['noset'][self::$fieldPrefix . 'id'], self::$fieldPrefix . 'id')) {
             return self::error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_MODEL']);
         }
     }
     foreach ($field as $value) {
         /**
          * 判断提交的字段是否为数组
          */
         if (is_array($_POST[$value['field_name']])) {
             $_POST[$value['field_name']] = (string) implode(',', $_POST[$value['field_name']]);
         }
         /**
          * 时间转换为时间戳
          */
         if ($value['field_type'] == 'date') {
             $_POST[$value['field_name']] = (string) strtotime($_POST[$value['field_name']]);
         }
         if ($value['field_required'] == '1') {
             if (!($data[self::$fieldPrefix . $value['field_name']] = self::isP($value['field_name'])) && !is_numeric($data[self::$fieldPrefix . $value['field_name']])) {
                 return self::error($value['display_name'] . $GLOBALS['_LANG']['COMMON']['REQUIRED']);
             }
         } else {
             if (!($data[self::$fieldPrefix . $value['field_name']] = self::p($value['field_name']))) {
                 $data[self::$fieldPrefix . $value['field_name']] = $value['field_default'];
             }
         }
     }
     return self::success($data);
 }
コード例 #9
0
ファイル: User.class.php プロジェクト: tarscoding/PESCMS-TEAM
 /**
  * 菜单基础表单
  */
 public static function baseFrom()
 {
     $fieldPrefix = "user_";
     $model = \Model\Model::findModel('user', 'model_name');
     $field = \Model\Field::fieldList($model['model_id'], '1');
     if (self::p('method') == 'PUT') {
         if (!($data['noset']['user_id'] = self::isP('user_id'))) {
             return self::error($GLOBALS['_LANG']['USER']['LOST_USER_ID']);
         }
         if (!self::findUser($data['noset']['user_id'])) {
             return self::error($GLOBALS['_LANG']['USER']['NOT_EXITS_USER']);
         }
     } elseif (self::p('method') == 'POST') {
         $data['user_createtime'] = time();
     }
     foreach ($field as $value) {
         /**
          * 判断提交的字段是否为数组
          */
         if (is_array($_POST[$value['field_name']])) {
             $_POST[$fieldPrefix . $value['field_name']] = implode(',', $_POST[$fieldPrefix . $value['field_name']]);
         }
         /**
          * 时间转换为时间戳
          */
         if ($value['field_type'] == 'date') {
             $_POST[$fieldPrefix . $value['field_name']] = strtotime($_POST[$fieldPrefix . $value['field_name']]);
         }
         if ($value['field_required'] == '1') {
             if (!($data[$fieldPrefix . $value['field_name']] = self::isP($fieldPrefix . $value['field_name'])) && !is_numeric($data[$fieldPrefix . $value['field_name']])) {
                 return self::error($value['display_name'] . $GLOBALS['_LANG']['COMMON']['REQUIRED']);
             }
         } else {
             if (!($data[$fieldPrefix . $value['field_name']] = self::p($fieldPrefix . $value['field_name']))) {
                 $data[$fieldPrefix . $value['field_name']] = $value['field_default'];
             }
         }
     }
     /**
      * 先移除密码
      */
     unset($data['user_password']);
     if (self::p('user_password')) {
         $password = self::p('user_password');
         if ($password != self::p('confirm_password')) {
             return self::error($GLOBALS['_LANG']['USER']['CONFIRM_PASSWORD_ERROR']);
         }
         $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $password, 'PRIVATE_KEY');
     } elseif (self::p('method') == 'POST' && !self::p('user_password')) {
         return self::error($GLOBALS['_LANG']['USER']['ENTER_PASSWORD']);
     }
     return self::success($data);
 }