/** * 编辑导航 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { // 如果值是数组则转换成字符串,适用于复选框等类型 if (is_array($_POST['module'])) { $_POST['module'] = implode(',', $_POST['module']); } $theme_object = D('Theme'); $data = $theme_object->create(); if ($data) { if ($theme_object->save($data)) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($theme_object->getError()); } } else { $con['is_system'] = 0; $module_list = D('Module')->where($con)->getField('name', true); foreach ($module_list as $val) { $module_name_list[$val] = $val; } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑主题')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('module', 'checkbox', '启用该主题的模块', '未勾选的将使用系统默认主题', $module_name_list)->setFormData(D('Theme')->find($id))->display(); } }
/** * 编辑菜单 */ public function edit($id) { if (IS_POST) { $this->add_or_edit(); } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('新增菜单')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('pid', 'select', '上级菜单', '所属的上级菜单', $this->selectListAsTree('SystemMenu', null, '顶级菜单'))->addItem('title', 'text', '标题', '菜单标题')->addItem('url', 'text', '链接', 'U函数解析的URL或者外链')->addItem('icon', 'icon', '图标', '菜单图标')->addItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('SystemMenu')->find($id))->display(); } }
/** * 获取某个分组的配置参数 */ public function group($tab = 1) { //根据分组获取配置 $map['status'] = array('egt', 0); //禁用和正常状态 $map['group'] = array('eq', $tab); $data_list = D('SystemConfig')->where($map)->order('sort asc,id asc')->select(); //构造表单名、解析options foreach ($data_list as &$data) { $data['name'] = 'config[' . $data['name'] . ']'; $data['options'] = parse_attr($data['options']); } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('系统设置')->setTablist(C('CONFIG_GROUP_LIST'))->setCurrentTab($tab)->setUrl(U('groupSave'))->setExtraItems($data_list)->display(); }
/** * 用户修改信息 * @author jry <*****@*****.**> */ public function profile() { if (IS_POST) { $user_object = D('User'); $_POST['id'] = $this->is_login(); $result = $user_object->update($_POST); if ($result) { $this->success('信息修改成功'); } else { $this->error($user_object->getError()); } } else { $user_object = D('User'); $user_info = $user_object->find($this->is_login()); //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('修改' . $user_info['username'] . '的信息')->setPostUrl(U(''))->addFormItem('username', 'text', '用户名', '')->addFormItem('avatar', 'picture', '头像', '')->addFormItem('sex', 'radio', '性别', '', $user_object->user_sex())->addFormItem('age', 'num', '年龄', '')->addFormItem('birthday', 'date', '生日', '生日')->addFormItem('summary', 'text', '签名', '一句话介绍')->setFormData($user_info)->setTemplate('_Builder/formbuilder_user')->display(); } }
/** * 编辑消息 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $user_message_object = D('UserMessage'); $data = $user_message_object->create(); if ($data) { if ($user_message_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($user_message_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑消息')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('title', 'textarea', '消息标题', '消息标题')->addFormItem('content', 'kindeditor', '消息内容', '消息内容')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('UserMessage')->find($id))->display(); } }
/** * 编辑评论 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $user_comment_object = D('UserComment'); $data = $user_comment_object->create(); if ($data) { if ($user_comment_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($user_comment_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑评论')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('table', 'radio', '数据表', '数据表ID', C('TABLE_LIST'))->addFormItem('data_id', 'num', '数据ID', '数据ID')->addFormItem('content', 'textarea', '评论内容', '评论内容')->addFormItem('pictures', 'pictures', '图片列表', '图片列表')->addFormItem('rate', 'num', '评分', '评分')->addFormItem('pid', 'num', '父评论ID', '父评论ID')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('UserComment')->find($id))->display(); } }
/** * 编辑标签 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $tag_object = D('PublicTag'); $data = $tag_object->create(); if ($data) { if ($tag_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($tag_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑标签')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('title', 'text', '标签名称', '标签名称')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('PublicTag')->find($id))->display(); } }
/** * 编辑菜单 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $menu_object = D('SystemMenu'); $data = $menu_object->create(); if ($data) { if ($menu_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($menu_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('新增菜单')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('pid', 'select', '上级菜单', '所属的上级菜单', select_list_as_tree('SystemMenu', null, '顶级菜单'))->addFormItem('title', 'text', '标题', '菜单标题')->addFormItem('url', 'text', '链接', 'U函数解析的URL或者外链')->addFormItem('icon', 'icon', '图标', '菜单图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('SystemMenu')->find($id))->display(); } }
/** * 编辑链接 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $link_object = D('Link'); $data = $link_object->create(); if ($data) { if ($link_object->save($data)) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($link_object->getError()); } } else { $info = D('Link')->find($id); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑链接')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('pid', 'select', '上级链接', '上级链接', select_list_as_tree('Link', null, '顶级链接'))->addFormItem('title', 'text', '链接标题', '链接前台显示标题')->addFormItem('url', 'text', '请填写外链URL地址', '支持http://格式或者TP的U函数解析格式')->addFormItem('icon', 'icon', '图标', '链接图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData($info)->setExtraHtml($this->extra_html)->display(); } }
/** * 卸载模块之前 * @author jry <*****@*****.**> */ public function uninstall_before($id) { // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('准备卸载模块')->setPostUrl(U('uninstall'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('clear', 'radio', '是否清除数据', '是否清除数据', array('1' => '是', '0' => '否'))->setFormData(array('id' => $id))->display(); }
/** * 编辑文章 * @author jry <*****@*****.**> */ public function edit($id) { $this->is_login(); //获取文档信息 $document_info = D('Document')->detail($id); //获取当前分类 $category_info = D('Category')->find($document_info['cid']); if (!$category_info['post_auth']) { $this->error('该分类禁止投稿'); } $doc_type = D('DocumentType')->find($category_info['doc_type']); $field_sort = json_decode($doc_type['field_sort'], true); $field_group = parse_attr($doc_type['field_group']); //获取文档字段 $map = array(); $map['status'] = array('eq', '1'); $map['show'] = array('eq', '1'); $map['doc_type'] = array('in', '0,' . $category_info['doc_type']); $attribute_list = D('DocumentAttribute')->where($map)->select(); //解析字段options $new_attribute_list = array(); foreach ($attribute_list as $attr) { if ($attr['name'] == 'cid') { $con = array(); $con['group'] = $category_info['group']; $con['doc_type'] = $category_info['doc_type']; $attr['options'] = select_list_as_tree('Category', $con); } else { $attr['options'] = parse_attr($attr['options']); } $new_attribute_list[$attr['id']] = $attr; $new_attribute_list[$attr['id']]['value'] = $document_info[$attr['name']]; } //表单字段排序及分组 if ($field_sort) { $new_attribute_list_sort = array(); foreach ($field_sort as $k1 => &$v1) { $new_attribute_list_sort[0]['type'] = 'group'; $new_attribute_list_sort[0]['options']['group' . $k1]['title'] = $field_group[$k1]; foreach ($v1 as $k2 => $v2) { $new_attribute_list_sort[0]['options']['group' . $k1]['options'][] = $new_attribute_list[$v2]; } } $new_attribute_list = $new_attribute_list_sort[0]['options']['group1']['options']; } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑文章')->setPostUrl(U('update'))->addFormItem('id', 'hidden', 'ID', 'ID')->setExtraItems($new_attribute_list)->setFormData($document_info)->setTemplate('_Builder/formbuilder_user')->display(); }
/** * 编辑模型 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $_POST['list_field'] = implode(',', $_POST['list_field']); $document_type_object = D('DocumentType'); $data = $document_type_object->create(); if ($data) { if ($document_type_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($document_type_object->getError()); } } else { $document_type_info = D('DocumentType')->find($id); $document_type_field_group = parse_attr($document_type_info['field_group']); $document_type_field_sort = json_decode($document_type_info['field_sort'], true); //获取文档字段 $map['status'] = array('eq', '1'); $map['show'] = array('eq', '1'); $map['doc_type'] = array('in', '0,' . $id); $attribute_list = D('DocumentAttribute')->where($map)->select(); //获取用于列表显示字段表单复选框的内容 $map['doc_type'] = array('eq', $id); $attribute_list_checkbox = select_list_as_tree('DocumentAttribute', $map); //解析字段 $new_attribute_list = array(); foreach ($attribute_list as $attr) { $new_attribute_list[$attr['id']] = $attr['title']; } //构造拖动排序options foreach ($document_type_field_sort as $key => $val) { $field[$key]['title'] = $document_type_field_group[$key]; $temp = array(); foreach ($val as $val2) { if ($new_attribute_list[$val2]) { $temp[$val2] = $new_attribute_list[$val2]; } unset($new_attribute_list[$val2]); } $field[$key]['field'] = $temp; } //计算未排序字段分组的key $unsort_key = array_pop(array_keys($field)) + 1; //未排序字段 if ($new_attribute_list) { $field[$unsort_key]['title'] = "未排序"; $field[$unsort_key]['field'] = $new_attribute_list; } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑模型')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('name', 'text', '模型名称', '模型名称')->addFormItem('title', 'text', '模型标题', '模型标题')->addFormItem('main_field', 'radio', '主要字段', '该模型的主要字段,如:文章的标题,商品的名称,用于前台列表及搜索列表显示', $attribute_list_checkbox)->addFormItem('list_field', 'checkbox', '列表显示字段', '后台文档列表需要显示字段及搜索字段,如:文章的标题,商品的名称', $attribute_list_checkbox)->addFormItem('field_group', 'textarea', '字段分组', '字段分组')->addFormItem('field_sort', 'board', '字段排序', '字段排序', $field)->addFormItem('icon', 'icon', '图标', '模型图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('DocumentType')->find($id))->display(); } }
/** * 编辑文章 * @author jry <*****@*****.**> */ public function edit($id) { //获取文档信息 $document_info = D('Document')->detail($id); //分类权限检测 if (!D('UserGroup')->checkCategoryAuth($document_info['cid'])) { $this->error('权限不足!'); } if (IS_POST) { //更新文档 $document_object = D('Document'); $result = $document_object->update(); if (!$result) { $this->error($document_object->getError()); } else { $this->success('更新成功', U('Document/index', array('cid' => I('post.cid')))); } } else { //获取当前分类 $category_info = D('Category')->find($document_info['cid']); $doc_type = D('DocumentType')->find($category_info['doc_type']); $field_sort = json_decode($doc_type['field_sort'], true); $field_group = parse_attr($doc_type['field_group']); //获取文档字段 $map['status'] = array('eq', '1'); $map['show'] = array('eq', '1'); $map['doc_type'] = array('in', '0,' . $category_info['doc_type']); $attribute_list = D('DocumentAttribute')->where($map)->select(); //解析字段options $new_attribute_list = array(); foreach ($attribute_list as $attr) { if ($attr['name'] == 'cid') { $con['group'] = $category_info['group']; $con['doc_type'] = $category_info['doc_type']; $con['status'] = array('egt', 0); $attr['options'] = select_list_as_tree('Category', $con); } else { $attr['options'] = parse_attr($attr['options']); } $new_attribute_list[$attr['id']] = $attr; $new_attribute_list[$attr['id']]['value'] = $document_info[$attr['name']]; } //表单字段排序及分组 if ($field_sort) { $new_attribute_list_sort = array(); foreach ($field_sort as $k1 => &$v1) { $new_attribute_list_sort[0]['type'] = 'group'; $new_attribute_list_sort[0]['options']['group' . $k1]['title'] = $field_group[$k1]; foreach ($v1 as $k2 => $v2) { $new_attribute_list_sort[0]['options']['group' . $k1]['options'][] = $new_attribute_list[$v2]; } } $new_attribute_list = $new_attribute_list_sort; } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑文章')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->setExtraItems($new_attribute_list)->setFormData($document_info)->display(); } }
/** * 编辑分类 * @author jry <*****@*****.**> */ public function edit($id, $group) { if (IS_POST) { $category_object = D('Category'); $data = $category_object->create(); if ($data) { if ($category_object->save() !== false) { $this->success('更新成功', U('Category/index', array('group' => I('post.group')))); } else { $this->error('更新失败'); } } else { $this->error($category_object->getError()); } } else { //获取分类信息 $category_object = D('Category'); $info = $category_object->find($id); //获取前台模版供选择 $current_theme = D('SystemTheme')->where(array('current' => 1))->order('id asc')->getField('name'); //从系统主题数据表获取当前主题的名称 $template_list = \Common\Util\File::get_dirs(getcwd() . '/Application/Home/View/' . $current_theme . '/Document'); foreach ($template_list['file'] as $val) { $val = substr($val, 0, -5); if (strstr($val, 'index')) { $template_list_index[$val] = $val; } elseif (strstr($val, 'detail')) { $template_list_detail[$val] = $val; } } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑分类')->setPostUrl(U('Admin/Category/edit/id/' . $id . '/group/' . $group))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('group', 'radio', '分组', '分组', C('CATEGORY_GROUP_LIST'))->addFormItem('pid', 'select', '上级分类', '所属的上级分类', select_list_as_tree('Category', array('group' => $group), '顶级分类'))->addFormItem('title', 'text', '分类标题', '分类标题')->addFormItem('doc_type', 'radio', '分类内容模型', '分类内容模型', select_list_as_tree('DocumentType'))->addFormItem('url', 'text', '链接', 'U函数解析的URL或者外链', null, $info['doc_type'] == 1 ?: 'hidden')->addFormItem('content', 'kindeditor', '内容', '单页模型填写内容', null, $info['doc_type'] == 2 ?: 'hidden')->addFormItem('index_template', 'select', '模版', '文档列表或封面模版', $template_list_index, $info['doc_type'] > 2 ?: 'hidden')->addFormItem('detail_template', 'select', '详情页模版', '单页使用的模版或其他模型文档详情页模版', $template_list_detail, $info['doc_type'] > 1 ?: 'hidden')->addFormItem('icon', 'icon', '图标', '菜单图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->addFormItem('post_auth', 'radio', '投稿权限', '前台用户投稿权限', $category_object->post_auth())->setFormData($info)->setExtraHtml($this->extra_html)->display(); } }
/** * 编辑文章 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $slider_object = D('Slider'); $data = $slider_object->create(); if ($data) { $id = $slider_object->save(); if ($id !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($slider_object->getError()); } } else { // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑幻灯')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('title', 'text', '标题', '标题')->addFormItem('cover', 'picture', '图片', '切换图片')->addFormItem('url', 'text', '链接', '点击跳转链接')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('Slider')->find($id))->display(); } }
/** * 编辑类型 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $document_type_object = D('DocumentType'); $data = $document_type_object->create(); if ($data) { if ($document_type_object->save() !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($document_type_object->getError()); } } else { $document_type_info = D('DocumentType')->find($id); $document_type_field_group = parse_attr($document_type_info['field_group']); $document_type_field_sort = json_decode($document_type_info['field_sort'], true); //获取文档字段 $map['status'] = array('eq', '1'); $map['show'] = array('eq', '1'); $map['doc_type'] = array('in', '0,' . $id); $attribute_list = D('DocumentAttribute')->where($map)->select(); //解析字段 $new_attribute_list = array(); foreach ($attribute_list as $attr) { $new_attribute_list[$attr['id']] = $attr['title']; } //构造拖动排序options foreach ($document_type_field_sort as $key => $val) { $field[$key]['title'] = $document_type_field_group[$key]; $temp = array(); foreach ($val as $val2) { if ($new_attribute_list[$val2]) { $temp[$val2] = $new_attribute_list[$val2]; } unset($new_attribute_list[$val2]); } $field[$key]['field'] = $temp; } //计算未排序字段分组的key $unsort_key = array_pop(array_keys($field)) + 1; //未排序字段 if ($new_attribute_list) { $field[$unsort_key]['title'] = "未排序"; $field[$unsort_key]['field'] = $new_attribute_list; } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('编辑类型')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('name', 'text', '类型名称', '类型名称')->addItem('title', 'text', '类型标题', '类型标题')->addItem('field_group', 'textarea', '字段分组', '字段分组')->addItem('icon', 'icon', '图标', '类型图标')->addItem('sort', 'num', '排序', '用于显示的顺序')->addItem('field_sort', 'board', '字段排序', '字段排序', $field)->setFormData(D('DocumentType')->find($id))->display(); } }
/** * 编辑导航 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $nav_object = D('Nav'); $data = $nav_object->create(); if ($data) { if ($nav_object->save($data)) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($nav_object->getError()); } } else { $info = D('Nav')->find($id); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑导航')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('pid', 'select', '上级导航', '上级导航', select_list_as_tree('Nav', array('group' => $group), '顶级导航'))->addFormItem('name', 'text', '导航名称', '名称一般为英文单词')->addFormItem('title', 'text', '导航标题', '导航前台显示标题')->addFormItem('type', 'select', '导航类型', '导航类型', D('Nav')->nav_type())->addFormItem('url', 'text', '请填写外链URL地址', '支持http://格式或者TP的U函数解析格式', null, $info['url'] ?: 'hidden')->addFormItem('module_name', 'select', '模块', '选择的模块需要具有前台页面', select_list_as_tree('Module', null, null, 'name'), $info['module_name'] ?: 'hidden')->addFormItem('icon', 'icon', '图标', '导航图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData($info)->setExtraHtml($this->extra_html)->display(); } }
/** * 用户修改信息 * @author jry <*****@*****.**> */ public function profile() { if (IS_POST) { // 强制设置用户ID $uid = $this->is_login(); $_POST['uid'] = $uid; //解析数据类似复选框类型的数组型值 foreach ($_POST as $key => $val) { if (is_array($val)) { $_POST[$key] = implode(',', $val); } else { if (check_date_time($val)) { $_POST[$key] = strtotime($val); } else { if (check_date_time($val, 'Y-m-d H:i')) { $_POST[$key] = strtotime($val); } else { if (check_date_time($val, 'Y-m-d')) { $_POST[$key] = strtotime($val); } } } } } // 获取用户信息 $user_object = D('User/User'); $user_info = $user_object->find($uid); // 保存信息 $type = $user_info['user_type']; $map['user_type'] = array('eq', $type); $count = D('User/Attribute')->where($map)->count(); if ($count) { $user_type_name = D('User/Type')->where(array('id' => $user_info['user_type']))->getField('name'); $user_extend_object = M('User' . ucfirst($user_type_name)); $extend_data = $user_extend_object->create(); $extend_info = $user_extend_object->find($uid); if ($extend_info) { $result = $user_extend_object->save($extend_data); } else { $result = $user_extend_object->add($extend_data); } if ($result === false) { $this->error('扩展信息修改失败' . $user_extend_object->getError()); } else { $this->success('信息修改成功'); } } } else { // 获取当前用户 $user_object = D('User/User'); $user_info = $user_object->detail($this->is_login()); $type = $user_info['user_type']; $user_type_info = D('User/Type')->find($type); // 获取扩展字段 $map['user_type'] = array('eq', $type); $attribute_list[$type] = D('User/Attribute')->where($map)->order('id asc')->select(); // 解析字段options $new_attribute_list_sort['user']['type'] = 'group'; if ($attribute_list[$type]) { foreach ($attribute_list[$type] as $attr) { $attr['options'] = parse_attr($attr['options']); $new_attribute_list[$type][$attr['id']] = $attr; $new_attribute_list[$type][$attr['id']]['value'] = $user_info[$attr['name']]; } $new_attribute_list_sort['user']['options']['group_extend']['title'] = $user_type_info['title'] . '信息'; $new_attribute_list_sort['user']['options']['group_extend']['options'] = $new_attribute_list[$type]; } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('修改信息')->setPostUrl(U(''))->setExtraItems($new_attribute_list_sort)->setTemplate('form')->display(); } }
/** * 编辑用户类型 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { // 提交数据 $type_object = D('Type'); $_POST['list_field'] = implode(',', $_POST['list_field']); $data = $type_object->create(); if ($data) { $result = $type_object->save($data); if ($result) { $this->success('更新成功', U('index')); } else { $this->error('更新失败', $type_object->getError()); } } else { $this->error($type_object->getError()); } } else { // 获取用户类型信息 $info = D('Type')->find($id); //获取用于列表显示字段表单复选框的内容 $map['user_type'] = array('eq', $id); $attribute_list_checkbox = select_list_as_tree('Attribute', $map); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑用户类型')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('name', 'text', '名称', '用户类型名称')->addFormItem('title', 'text', '标题', '用户类型标题')->addFormItem('list_field', 'checkbox', '前台查询搜索字段', '前台查询搜索字段', $attribute_list_checkbox)->addFormItem('home_template', 'text', '主页模版', '主页模版')->setFormData($info)->display(); } }
/** * 编辑分类 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $attribute_object = D('Attribute'); $data = $attribute_object->create(); if ($data) { $result = $attribute_object->updateField($data); // 更新字段 if ($result) { $status = $attribute_object->save(); // 更新字段信息 if ($status) { $this->success('更新字段成功', U('index', array('user_type' => I('user_type')))); } else { $this->error('更新属性出错!'); } } else { $this->error('更新字段出错!'); } } else { $this->error($attribute_object->getError()); } } else { // 获取Builder表单类型转换成一维数组 $form_item_type = C('FORM_ITEM_TYPE'); foreach ($form_item_type as $key => $val) { $new_form_item_type[$key]['title'] = $val[0]; $new_form_item_type[$key]['data-field'] = $val[1]; } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑字段')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('user_type', 'select', '文档类型', '文档类型', select_list_as_tree('Type'))->addFormItem('name', 'text', '字段名称', '字段名称,如“title”')->addFormItem('title', 'text', '字段标题', '字段标题,如“标题”')->addFormItem('type', 'select', '字段类型', '字段类型', $new_form_item_type)->addFormItem('field', 'text', '字段定义', '字段定义,如:int(11) NOT NULL ')->addFormItem('value', 'text', '字段默认值', '字段默认值')->addFormItem('show', 'radio', '是否显示', '是否显示', array('1' => '显示', '0' => '不显示'))->addFormItem('options', 'textarea', '额外选项', '额外选项radio/select等需要配置此项')->addFormItem('tip', 'textarea', '字段补充说明', '字段补充说明')->setFormData(D('Attribute')->find($id))->setExtraHtml($this->extra_html)->display(); } }
/** * 模块配置方法 * @author jry <*****@*****.**> */ public function module_config() { if (IS_POST) { $id = (int) I('id'); $config = I('config'); $flag = D('Admin/Module')->where("id={$id}")->setField('config', json_encode($config)); if ($flag !== false) { $this->success('保存成功'); } else { $this->error('保存失败'); } } else { $name = MODULE_NAME; $config_file = realpath(APP_PATH . $name) . '/' . D('Admin/Module')->install_file(); if (!$config_file) { $this->error('配置文件不存在'); } $module_config = (include $config_file); $module_info = D('Admin/Module')->where(array('name' => $name))->find($id); $db_config = $module_info['config']; // 构造配置 if ($db_config) { $db_config = json_decode($db_config, true); foreach ($module_config['config'] as $key => $value) { if ($value['type'] != 'group') { $module_config['config'][$key]['value'] = $db_config[$key]; } else { foreach ($value['options'] as $gourp => $options) { foreach ($options['options'] as $gkey => $value) { $module_config['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey]; } } } } } // 构造表单名 foreach ($module_config['config'] as $key => $val) { if ($val['type'] == 'group') { foreach ($val['options'] as $key2 => $val2) { foreach ($val2['options'] as $key3 => $val3) { $module_config['config'][$key]['options'][$key2]['options'][$key3]['name'] = 'config[' . $key3 . ']'; } } } else { $module_config['config'][$key]['name'] = 'config[' . $key . ']'; } } //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('设置')->setPostUrl(U(''))->addFormItem('id', 'hidden', 'ID', 'ID')->setExtraItems($module_config['config'])->setFormData($module_info)->display(); } }
/** * 用户修改信息 * @author jry <*****@*****.**> */ public function profile() { if (IS_POST) { // 强制设置用户ID $uid = $this->is_login(); $_POST['uid'] = $uid; $_POST = format_data(); // 获取用户信息 $user_object = D('User/User'); $user_info = $user_object->find($uid); // 保存昵称 if (I('post.nickname')) { $result = $user_object->where(array('id' => $uid))->setField('nickname', I('post.nickname')); if ($result === false) { $this->error('昵称修改失败' . $user_object->getError()); } } else { $this->error('请填写昵称'); } // 保存扩展信息 $type = $user_info['user_type']; $map['user_type'] = array('eq', $type); $count = D('User/Attribute')->where($map)->count(); if ($count) { $user_type_name = D('User/Type')->where(array('id' => $user_info['user_type']))->getField('name'); $user_extend_object = D('User' . ucfirst($user_type_name)); $extend_data = $user_extend_object->create(); if (!$extend_data) { $this->error($user_extend_object->getError()); } $extend_info = $user_extend_object->find($uid); if ($extend_info) { $result = $user_extend_object->save($extend_data); } else { $result = $user_extend_object->add($extend_data); } if ($result === false) { $this->error('扩展信息修改失败' . $user_extend_object->getError()); } else { $this->success('信息修改成功'); } } } else { // 获取当前用户 $user_object = D('User/User'); $user_info = $user_object->detail($this->is_login()); $type = $user_info['user_type']; $user_type_info = D('User/Type')->find($type); // 获取扩展字段 $map['user_type'] = array('eq', $type); $attribute_list[$type] = D('User/Attribute')->where($map)->order('id asc')->select(); // 解析字段options $new_attribute_list_sort['user']['type'] = 'group'; if ($attribute_list[$type]) { // 增加昵称表单 $nick['name'] = 'nickname'; $nick['title'] = '昵称'; $nick['type'] = 'text'; $nick['value'] = $user_info['nickname']; $new_attribute_list[1][0] = $nick; foreach ($attribute_list[$type] as $attr) { $attr['options'] = parse_attr($attr['options']); $new_attribute_list[$type][$attr['id']] = $attr; $new_attribute_list[$type][$attr['id']]['value'] = $user_info[$attr['name']]; } $new_attribute_list_sort['user']['options']['group_extend']['title'] = '完善' . $user_type_info['title'] . '信息'; $new_attribute_list_sort['user']['options']['group_extend']['options'] = $new_attribute_list[$type]; } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('修改信息')->setPostUrl(U(''))->setExtraItems($new_attribute_list_sort)->setTemplate(C('USER_CENTER_FORM'))->display(); } }
/** * 编辑导航 * @author jry <*****@*****.**> */ public function edit($id, $group) { if (IS_POST) { $nav_object = D('Admin/Nav'); $data = $nav_object->create(); if ($data) { if ($nav_object->save($data)) { $this->success('更新成功', U('index', array('group' => $group))); } else { $this->error('更新失败'); } } else { $this->error($nav_object->getError()); } } else { $info = D('Admin/Nav')->find($id); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑导航')->setPostUrl(U(''))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('group', 'hidden', '导航分组', '导航分组')->addFormItem('pid', 'select', '上级导航', '上级导航', select_list_as_tree('Admin/Nav', array('group' => $group), '顶级导航'))->addFormItem('title', 'text', '导航标题', '导航前台显示标题')->addFormItem('type', 'radio', '导航类型', '导航类型', D('Admin/Nav')->nav_type())->addFormItem('url', 'text', '外链URL地址', '支持http://格式或者TP的U函数解析格式', null, $info['type'] === 'link' ? '' : 'hidden')->addFormItem('module_name', 'select', '模块', '选择的模块需要具有前台页面', select_list_as_tree('Admin/Module', null, null, 'name'), $info['type'] === 'module' ? '' : 'hidden')->addFormItem('content', 'kindeditor', '单页内容', '单页内容', null, $info['type'] === 'page' ? '' : 'hidden')->addFormItem('target', 'radio', '打开方式', '打开方式', array('' => '当前窗口', '_blank' => '新窗口打开'))->addFormItem('icon', 'icon', '图标', '导航图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData($info)->setExtraHtml($this->extra_html)->display(); } }
/** * 编辑 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $access_object = D('Access'); $data = $access_object->create(); if ($data) { if ($access_object->save($data)) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($access_object->getError()); } } else { // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑配置')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('uid', 'uid', 'UID', '用户ID')->addFormItem('group', 'select', '用户组', '不同用户组对应相应的权限', select_list_as_tree('Group'))->setFormData(D('Access')->find($id))->display(); } }
/** * 编辑用户 * @author jry <*****@*****.**> */ public function edit($id) { //获取用户信息 $info = D('User')->find($id); if (IS_POST) { $user_object = D('User'); //不修改密码时销毁变量 if ($_POST['password'] == '' || $info['password'] == $_POST['password']) { unset($_POST['password']); } else { $_POST['password'] = user_md5($_POST['password']); } //不允许更改超级管理员用户组 if ($_POST['id'] == 1) { unset($_POST['group']); } if ($_POST['extend']) { $_POST['extend'] = json_encode($_POST['extend']); } if ($user_object->save($_POST)) { $this->success('更新成功', U('index')); } else { $this->error('更新失败', $user_object->getError()); } } else { $user_object = D('User'); $info = $user_object->find($id); //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑用户')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('usertype', 'radio', '用户类型', '用户类型', $user_object->user_type())->addFormItem('group', 'select', '部门', '所属部门', select_list_as_tree('UserGroup', null, '默认部门'))->addFormItem('username', 'text', '用户名', '用户名')->addFormItem('email', 'text', '邮箱', '邮箱')->addFormItem('mobile', 'text', '手机号码', '手机号码')->addFormItem('password', 'password', '密码', '密码')->addFormItem('avatar', 'picture', '用户头像', '用户头像')->addFormItem('vip', 'radio', 'VIP等级', 'VIP等级', $user_object->user_vip_level())->setFormData($info)->display(); } }
/** * 插件后台数据编辑 * @param string $name 插件名 * @author jry <*****@*****.**> */ public function adminEdit($name, $tab, $id) { //获取插件实例 $addon_class = get_addon_class($name); if (!class_exists($addon_class)) { $this->error('插件不存在'); } else { $addon = new $addon_class(); } //获取插件的$admin_list配置 $admin_list = $addon->admin_list; $admin = $admin_list[$tab]; $addon_model_object = D('Addons://' . $name . '/' . $admin['model']); $param = $addon_model_object->adminList; if ($param) { if (IS_POST) { $data = $addon_model_object->create(); if ($data) { $result = $addon_model_object->save($data); } else { $this->error($addon_model_object->getError()); } if ($result) { $this->success('更新成功', U('Addon/adminList/name/' . $name . '/tab/' . $tab)); } else { $this->error('更新错误'); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑数据')->setPostUrl(U('addon/adminEdit/name/' . $name . '/tab/' . $tab))->addFormItem('id', 'hidden', 'ID', 'ID')->setExtraItems($param['field'])->setFormData(M($param['model'])->find($id))->setTemplate('_Builder/formbuilder_addon')->display(); } } else { $this->error('插件列表信息不正确'); } }
/** * 编辑分类 * @author jry <*****@*****.**> */ public function edit_with_tree($id, $group = 1) { if (IS_POST) { $category_object = D('Category'); $data = $category_object->create(); if ($data) { if ($category_object->save() !== false) { $this->success('更新成功', U('index', array('group' => I('post.group')))); } else { $this->error('更新失败'); } } else { $this->error($category_object->getError()); } } else { // 获取分类信息 $category_object = D('Category'); $info = $category_object->find($id); // 获取前台模版供选择 if (C('CURRENT_THEME')) { $template_list = \Common\Util\File::get_dirs(getcwd() . '/Theme/' . C('CURRENT_THEME') . '/Article/article'); } else { $template_list = \Common\Util\File::get_dirs(getcwd() . '/Application/Article/View/Home/article'); } foreach ($template_list['file'] as $val) { $val = substr($val, 0, -5); if (strstr($val, 'index')) { $template_list_index[$val] = $val; } elseif (strstr($val, 'detail')) { $template_list_detail[$val] = $val; } } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑分类')->setPostUrl(U('edit', array('id' => $id, 'group' => $group)))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('group', 'radio', '分组', '分组', D('Category')->group_list())->addFormItem('pid', 'select', '上级分类', '所属的上级分类', select_list_as_tree('Category', array('group' => $group), '顶级分类'))->addFormItem('title', 'text', '分类标题', '分类标题')->addFormItem('doc_type', 'radio', '分类内容模型', '分类内容模型', select_list_as_tree('Type'))->addFormItem('url', 'text', '链接', 'U函数解析的URL或者外链', null, $info['doc_type'] == 1 ?: 'hidden')->addFormItem('content', 'kindeditor', '内容', '单页模型填写内容', null, $info['doc_type'] == 2 ?: 'hidden')->addFormItem('index_template', 'select', '模版', '文档列表或封面模版', $template_list_index, $info['doc_type'] > 2 ?: 'hidden')->addFormItem('detail_template', 'select', '详情页模版', '单页使用的模版或其他模型文档详情页模版', $template_list_detail, $info['doc_type'] > 1 ?: 'hidden')->addFormItem('icon', 'icon', '图标', '菜单图标')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->addFormItem('post_auth', 'radio', '投稿权限', '前台用户投稿权限', $category_object->post_auth())->setFormData($info)->setExtraHtml($this->extra_html)->setTemplate('Admin/builder/form')->display(); } }
/** * 编辑文章 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { $friendly_link_object = D('FriendlyLink'); $data = $friendly_link_object->create(); if ($data) { $id = $friendly_link_object->save(); if ($id !== false) { $this->success('更新成功', U('index')); } else { $this->error('更新失败'); } } else { $this->error($friendly_link_object->getError()); } } else { // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑友情链接')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('title', 'text', '标题', '标题')->addFormItem('logo', 'picture', 'Logo', 'Logo')->addFormItem('url', 'text', '链接', '点击跳转链接')->addFormItem('type', 'radio', '类型', '链接类型', array('1' => '友情链接', '2' => '合作伙伴'))->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('FriendlyLink')->find($id))->display(); } }
/** * 获取某个分组的配置参数 * @author jry <*****@*****.**> */ public function group($group = 1) { //根据分组获取配置 $map['status'] = array('egt', '0'); // 禁用和正常状态 $map['group'] = array('eq', $group); $data_list = D('Config')->where($map)->order('sort asc,id asc')->select(); // 设置Tab导航数据列表 $config_group_list = C('CONFIG_GROUP_LIST'); // 获取配置分组 foreach ($config_group_list as $key => $val) { $tab_list[$key]['title'] = $val; $tab_list[$key]['href'] = U('group', array('group' => $key)); } // 构造表单名、解析options foreach ($data_list as &$data) { $data['name'] = 'config[' . $data['name'] . ']'; $data['options'] = parse_attr($data['options']); } // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('系统设置')->SetTabNav($tab_list, $group)->setPostUrl(U('groupSave'))->setExtraItems($data_list)->display(); }
/** * 编辑用户 * @author jry <*****@*****.**> */ public function edit($id) { if (IS_POST) { // 密码为空表示不修改密码 if ($_POST['password'] === '') { unset($_POST['password']); } // 提交数据 $user_object = D('User'); $data = $user_object->create(); if ($data) { $result = $user_object->field('id,nickname,username,password,email,email_bind,mobile,mobile_bind,gender,avatar,update_time')->save($data); if ($result) { $this->success('更新成功', U('index')); } else { $this->error('更新失败', $user_object->getError()); } } else { $this->error($user_object->getError()); } } else { // 获取账号信息 $info = D('User')->find($id); unset($info['password']); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑用户')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('nickname', 'text', '昵称', '昵称')->addFormItem('username', 'text', '用户名', '用户名')->addFormItem('password', 'password', '密码', '密码')->addFormItem('email', 'text', '邮箱', '邮箱')->addFormItem('email_bind', 'radio', '邮箱绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))->addFormItem('mobile', 'text', '手机号', '手机号')->addFormItem('mobile_bind', 'radio', '手机绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))->addFormItem('avatar', 'picture', '头像', '头像')->setFormData($info)->display(); } }