123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?php
- # 定义几个常用的选项
- $option = array
- (
- 1 => '显示',
- 2 => '不显示',
- );
- $type = Dever::db('page/module')->config['func'];
- $type = $type();
- $list = function()
- {
- return Dever::db('page/module')->state();
- };
- $info = Dever::input('search_option_module_id', 1);
- $module_id = Dever::input('update_module_id');
- if ($module_id) {
- $info = $module_id;
- }
- Dever::setInput('search_option_module_id', $info);
- $type_default = -1;
- $type_id = '0';
- $data = array
- (
- 1 => '内容自定义',
- );
- $lang = array();
- $name = '内容管理';
- if ($info) {
- $info = Dever::db('page/module')->one($info);
- if ($info) {
- $function = explode(',', $info['func']);
-
- $type_id = array();
- foreach ($type as $k => $v) {
- if (!in_array($v['id'], $function)) {
- unset($type[$k]);
- } else {
- $type_default = $v['id'];
- if ($v['id'] > 0 && isset($v['type']) && $v['type'] == 1) {
- $type_id[] = $v['id'];
- }
- }
- }
- $type_id = implode(',', $type_id);
- }
- }
- $struct = array
- (
- 'id' => array
- (
- 'type' => 'int-11',
- 'name' => 'ID',
- 'default' => '',
- 'desc' => '',
- 'match' => 'is_numeric',
- //'search' => 'order',
- 'order' => 'desc',
- //'list' => true,
- ),
- 'module_id' => array
- (
- 'type' => 'int-11',
- 'name' => '所属模块',
- 'default' => Dever::input('search_option_module_id', '1'),
- 'desc' => '模块',
- 'match' => 'is_numeric',
- 'search' => 'select',
- 'update' => 'hidden',
- 'option' => $list,
- 'list' => true,
- 'value' => Dever::input('search_option_module_id', '1'),
- ),
- 'type' => array
- (
- 'type' => 'int-11',
- 'name' => '功能类型',
- 'default' => ''.$type_default.'',
- 'desc' => '请选择功能类型',
- 'match' => 'is_numeric',
- 'update' => 'radio',
- //'search' => 'select',
- 'option' => $type,
- 'control_url' => 'page/lib/manage.showType',
- ),
- 'type_id' => array
- (
- 'type' => 'int-11',
- 'name' => '关联数据',
- 'default' => '',
- 'desc' => '关联数据',
- 'match' => 'option',
- 'update' => 'select',
- 'show' => 'type=' . $type_id,
- //'update_search' => 'page/lib/manage.search?{type}',
- ),
- /*
- 'data' => array
- (
- 'type' => 'text-1000',
- 'name' => '自定义数据项',
- 'default' => '',
- 'desc' => '自定义数据项',
- 'match' => 'is_string',
- 'option' => $data,
- 'update' => $data_update,
- 'list' => 'Dever::load("page/lib/manage.show", {id})',
- ),
- */
- );
- if ($info) {
- $info['col'] = explode(',', $info['col']);
- $col = Dever::db('page/col')->getAll();
- if ($col) {
- $pic_index = 0;
- if ($info['col_pic']) {
- $pic = $info['col_pic'];
- $pic_temp = explode("\r\n", $pic);
- }
- foreach ($col as $k => $v) {
- $option = false;
- $place = $v['pic'];
- if ($info['col_pic'] && isset($pic_temp[$pic_index]) && $pic_temp[$pic_index]) {
- $place = $pic_temp[$pic_index];
- }
- $key = 'col_' . $v['id'];
- $list = false;
- $type = 'varchar-1000';
- $callback = false;
- if ($v['type'] == 1) {
- $update_type = 'text';
- if ($v['id'] != 3) {
- $lang[] = $key;
- }
-
- $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
- } elseif ($v['type'] == 2) {
- $update_type = 'textarea';
- $lang[] = $key;
- $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
- } elseif ($v['type'] == 3) {
- $update_type = 'editor';
- $lang[] = $key;
- $type = 'text-255';
- } elseif ($v['type'] == 4) {
- $update_type = 'image';
- $pic_index++;
- $list = 'Dever::load("page/lib/manage.getPic", "'.$v['id'].'", {id})';
- } elseif ($v['type'] == 5) {
- $update_type = 'images';
- $pic_index++;
- } elseif ($v['type'] == 6) {
- $update_type = 'radio';
- $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
- $list = true;
- } elseif ($v['type'] == 7) {
- $update_type = 'checkbox';
- $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
- $list = true;
- } elseif ($v['type'] == 8) {
- $update_type = 'day';
- $callback = 'maketime';
- $list = 'date("Y-m-d", {'.$v['name'].'})';
- }
- if ($v['list_show'] == 2) {
- $list = false;
- }
- if (!in_array($v['id'], $info['col'])) {
- $update_type = 'hidden';
- $list = false;
- }
- if ($v['is_option'] == 1) {
- $match = 'is_string';
- } else {
- $match = 'option';
- }
- if ($v['desc'] != $v['name']) {
- $v['name'] .= '-' . $v['desc'];
- }
-
- $struct[$key] = array
- (
- //'col' => 'col_' . $v['id'],
- 'type' => $type,
- 'name' => $v['name'],
- 'default' => '',
- 'desc' => $v['name'],
- 'match' => $match,
- 'update' => $update_type,
- 'update_bak' => $update_type,
- 'place' => $place,
- 'key' => 1,
- 'list' => $list,
- 'option' => $option,
- 'callback' => $callback,
- );
- }
- }
- }
- $struct += array
- (
- 'reorder' => array
- (
- 'type' => 'int-11',
- 'name' => '排序-数值越小越靠前',
- 'default' => '1',
- 'desc' => '请输入排序',
- 'match' => 'option',
- 'update' => 'text',
- 'search' => 'order',
- 'list' => true,
- 'order' => 'asc',
- 'edit' => true,
- ),
- 'state' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- ),
-
- 'cdate' => array
- (
- 'type' => 'int-11',
- 'name' => '录入时间',
- 'match' => array('is_numeric', time()),
- 'desc' => '',
- # 只有insert时才生效
- 'insert' => true,
- 'list' => 'date("Y-m-d H:i:s", {cdate})',
- ),
- );
- return array
- (
- # 表名
- 'name' => 'data',
- # 显示给用户看的名称
- 'lang' => $name,
- 'order' => 20,
- 'menu' => false,
- //'desc' => '预览地址:<br /><iframe id="preview" height="'.$preview_height.'" width="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" src="'.$preview.'" ></iframe>',
- # 数据结构
- 'struct' => $struct,
- 'manage' => array
- (
- //'link' => 'parent=module.data&search_option_module_id=' . $info['id'],
- 'lang' => implode(',', $lang),
- 'insert' => false,
- 'edit' => false,
- # 自定义快捷新增和编辑
- 'button' => array
- (
- '新增' => array('fast'),
- ),
- 'list_button' => array
- (
- 'edit' => array('编辑'),
- )
- ),
- # request 请求接口定义
- 'request' => array
- (
- # 获取列表页
- 'getAll' => array
- (
- # 匹配的正则或函数 选填项
- 'option' => array
- (
- 'module_id' => 'yes',
- 'type_no' => array('yes-type', '!='),
- 'state' => 1,
- ),
- 'type' => 'all',
- 'order' => array('reorder' => 'asc', 'id' => 'desc'),
- 'limit' => '0,10',
- 'col' => '*',
- ),
- # 获取列表页 带有分页的
- 'getAllPage' => array
- (
- # 匹配的正则或函数 选填项
- 'option' => array
- (
- 'module_id' => 'yes',
- 'type_no' => array('yes-type', '!='),
- 'state' => 1,
- ),
- 'type' => 'all',
- 'order' => array('reorder' => 'asc', 'id' => 'desc'),
- 'page' => array(10, 'list'),
- 'col' => '*',
- ),
- ),
- );
|