/** * 编辑菜单 */ 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 edit($id) { if (IS_POST) { $tag_object = D('Tag'); $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->title('编辑标签')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('title', 'text', '标签名称', '标签名称')->addItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('Tag')->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->title('编辑评论')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('table', 'radio', '数据表', '数据表ID', C('TABLE_LIST'))->addItem('data_id', 'num', '数据ID', '数据ID')->addItem('content', 'textarea', '评论内容', '评论内容')->addItem('pictures', 'pictures', '图片列表', '图片列表')->addItem('rate', 'num', '评分', '评分')->addItem('pid', 'num', '父评论ID', '父评论ID')->addItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('UserComment')->find($id))->display(); } }
/** * 编辑文章 * @author jry <*****@*****.**> */ public function edit($id) { //获取文档信息 $document_info = D('Document')->detail($id); //获取当前分类 $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']; $attr['options'] = $this->selectListAsTree('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->title('编辑文章')->setUrl(U('update'))->addItem('id', 'hidden', 'ID', 'ID')->setExtraItems($new_attribute_list)->setFormData($document_info)->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(); } }
/** * 插件后台数据编辑 * @param string $name 插件名 * @author jry <*****@*****.**> */ public function weijiaEdit($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/weijia/name/' . $name . '/tab/' . $tab)); } else { $this->error('更新错误'); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('编辑数据')->setUrl(U('addon/weijiaEdit/name/' . $name . '/tab/' . $tab))->addItem('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($id) { if (IS_POST) { $document_attribute_object = D('DocumentAttribute'); $data = $document_attribute_object->create(); if ($data) { $result = $document_attribute_object->updateField($data); //更新字段 if ($result) { $status = $document_attribute_object->save(); //更新字段信息 if ($status) { $this->success('更新字段成功', U('index', array('doc_type' => I('doc_type')))); } else { $this->error('更新属性出错!'); } } else { $this->error('更新字段出错!'); } } else { $this->error($document_attribute_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('编辑字段')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('doc_type', 'select', '文档类型', '文档类型', $this->selectListAsTree('DocumentType'))->addItem('name', 'text', '字段名称', '字段名称,如“title”')->addItem('title', 'text', '字段标题', '字段标题,如“标题”')->addItem('type', 'select', '字段类型', '字段类型', C('FORM_ITEM_TYPE'))->addItem('field', 'text', '字段定义', '字段定义,如:int(11) unsigned NOT NULL ')->addItem('value', 'text', '字段默认值', '字段默认值')->addItem('show', 'radio', '是否显示', '是否显示', array('1' => '显示', '0' => '不显示'))->addItem('options', 'textarea', '额外选项', '额外选项radio/select等需要配置此项')->addItem('tip', 'textarea', '字段补充说明', '字段补充说明')->setFormData(D('DocumentAttribute')->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 { $info = D('User')->find($id); //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('编辑用户')->setUrl(U('edit'))->addItem('id', 'hidden', 'ID', 'ID')->addItem('usertype', 'radio', '用户类型', '用户类型', C('USER_TYPE_LIST'))->addItem('group', 'select', '部门', '所属部门', $this->selectListAsTree('UserGroup', null, '默认部门'))->addItem('username', 'text', '用户名', '用户名')->addItem('email', 'text', '邮箱', '邮箱')->addItem('mobile', 'text', '手机号码', '手机号码')->addItem('password', 'password', '密码', '密码')->addItem('avatar', 'picture', '用户头像', '用户头像')->addItem('vip', 'radio', 'VIP等级', 'VIP等级', C('USER_VIP_LEVEL'))->setFormData($info)->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_info = D('User')->find($this->is_login()); $date = new Date((int) $user_info['birthday']); $user_info['gz'] = $date->magicInfo('GZ'); $user_info['xz'] = $date->magicInfo('XZ'); $user_info['sx'] = $date->magicInfo('SX'); //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->title('修改' . $user_info['username'] . '的信息')->setUrl(U(''))->addItem('username', 'text', '用户名', '')->addItem('avatar', 'picture', '头像', '')->addItem('sex', 'radio', '性别', '', C('USER_SEX_LIST'))->addItem('age', 'num', '年龄', '')->addItem('birthday', 'date', '生日', '自动计算:' . $user_info['gz'] . ' ' . $user_info['xz'] . ' ' . $user_info['sx'])->addItem('summary', 'text', '签名', '一句话介绍')->setFormData($user_info)->setTemplate('Builder/formbuilder_user')->display(); } }
/** * 编辑分类 * @author jry <*****@*****.**> */ public function edit($id, $tab) { if (IS_POST) { $category_object = D('Category'); $data = $category_object->create(); if ($data) { if ($category_object->save() !== false) { $this->success('更新成功', U('Category/index', array('tab' => I('post.group')))); } else { $this->error('更新失败'); } } else { $this->error($category_object->getError()); } } else { //获取分类信息 $info = D('Category')->find($id); //获取前台模版供选择 $default_theme = D('SystemConfig')->getFieldByName('DEFAULT_THEME', 'value'); $template_list = \Common\Util\File::get_dirs(getcwd() . '/Application/Home/View/' . $default_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->title('编辑分类')->setUrl(U('Admin/Category/edit/id/' . $id . '/tab/' . $tab))->addItem('id', 'hidden', 'ID', 'ID')->addItem('group', 'radio', '分组', '分组', C('CATEGORY_GROUP_LIST'))->addItem('pid', 'select', '上级分类', '所属的上级分类', $this->selectListAsTree('Category', array('group' => $tab), '顶级分类'))->addItem('title', 'text', '分类标题', '分类标题')->addItem('doc_type', 'radio', '分类内容模型', '分类内容模型', $this->selectListAsTree('DocumentType'))->addItem('url', 'text', '链接', 'U函数解析的URL或者外链', null, $info['doc_type'] == 1 ?: 'hidden')->addItem('content', 'kindeditor', '内容', '单页模型填写内容', null, $info['doc_type'] == 2 ?: 'hidden')->addItem('index_template', 'select', '模版', '文档列表或封面模版', $template_list_index, $info['doc_type'] > 2 ?: 'hidden')->addItem('detail_template', 'select', '详情页模版', '单页使用的模版或其他模型文档详情页模版', $template_list_detail, $info['doc_type'] > 1 ?: 'hidden')->addItem('icon', 'icon', '图标', '菜单图标')->addItem('sort', 'num', '排序', '用于显示的顺序')->addItem('post_auth', 'radio', '投稿权限', '前台用户投稿权限', C('CATEGORY_POST_AUTH'))->setFormData($info)->setExtraHtml($this->extra_html)->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->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(); } }