data.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '显示',
  6. 2 => '不显示',
  7. );
  8. $type = Dever::db('page/module')->config['func'];
  9. $type = $type();
  10. $list = function()
  11. {
  12. return Dever::db('page/module')->state();
  13. };
  14. $info = Dever::input('search_option_module_id', 1);
  15. $module_id = Dever::input('update_module_id');
  16. if ($module_id) {
  17. $info = $module_id;
  18. }
  19. Dever::setInput('search_option_module_id', $info);
  20. $type_default = -1;
  21. $type_id = '0';
  22. $data = array
  23. (
  24. 1 => '内容自定义',
  25. );
  26. $lang = array();
  27. $name = '内容管理';
  28. if ($info) {
  29. $info = Dever::db('page/module')->one($info);
  30. if ($info) {
  31. $function = explode(',', $info['func']);
  32. $type_id = array();
  33. foreach ($type as $k => $v) {
  34. if (!in_array($v['id'], $function)) {
  35. unset($type[$k]);
  36. } else {
  37. $type_default = $v['id'];
  38. if ($v['id'] > 0 && isset($v['type']) && $v['type'] == 1) {
  39. $type_id[] = $v['id'];
  40. }
  41. }
  42. }
  43. $type_id = implode(',', $type_id);
  44. }
  45. }
  46. $struct = array
  47. (
  48. 'id' => array
  49. (
  50. 'type' => 'int-11',
  51. 'name' => 'ID',
  52. 'default' => '',
  53. 'desc' => '',
  54. 'match' => 'is_numeric',
  55. //'search' => 'order',
  56. 'order' => 'desc',
  57. //'list' => true,
  58. ),
  59. 'module_id' => array
  60. (
  61. 'type' => 'int-11',
  62. 'name' => '所属模块',
  63. 'default' => Dever::input('search_option_module_id', '1'),
  64. 'desc' => '模块',
  65. 'match' => 'is_numeric',
  66. 'search' => 'select',
  67. 'update' => 'hidden',
  68. 'option' => $list,
  69. 'list' => true,
  70. 'value' => Dever::input('search_option_module_id', '1'),
  71. ),
  72. 'type' => array
  73. (
  74. 'type' => 'int-11',
  75. 'name' => '功能类型',
  76. 'default' => ''.$type_default.'',
  77. 'desc' => '请选择功能类型',
  78. 'match' => 'is_numeric',
  79. 'update' => 'radio',
  80. //'search' => 'select',
  81. 'option' => $type,
  82. 'control_url' => 'page/lib/manage.showType',
  83. ),
  84. 'type_id' => array
  85. (
  86. 'type' => 'int-11',
  87. 'name' => '关联数据',
  88. 'default' => '',
  89. 'desc' => '关联数据',
  90. 'match' => 'option',
  91. 'update' => 'select',
  92. 'show' => 'type=' . $type_id,
  93. //'update_search' => 'page/lib/manage.search?{type}',
  94. ),
  95. /*
  96. 'data' => array
  97. (
  98. 'type' => 'text-1000',
  99. 'name' => '自定义数据项',
  100. 'default' => '',
  101. 'desc' => '自定义数据项',
  102. 'match' => 'is_string',
  103. 'option' => $data,
  104. 'update' => $data_update,
  105. 'list' => 'Dever::load("page/lib/manage.show", {id})',
  106. ),
  107. */
  108. );
  109. if ($info) {
  110. $info['col'] = explode(',', $info['col']);
  111. $col = Dever::db('page/col')->getAll();
  112. if ($col) {
  113. $pic_index = 0;
  114. if ($info['col_pic']) {
  115. $pic = $info['col_pic'];
  116. $pic_temp = explode("\r\n", $pic);
  117. }
  118. foreach ($col as $k => $v) {
  119. $option = false;
  120. $place = $v['pic'];
  121. if ($info['col_pic'] && isset($pic_temp[$pic_index]) && $pic_temp[$pic_index]) {
  122. $place = $pic_temp[$pic_index];
  123. }
  124. $key = 'col_' . $v['id'];
  125. $list = false;
  126. $type = 'varchar-1000';
  127. $callback = false;
  128. if ($v['type'] == 1) {
  129. $update_type = 'text';
  130. if ($v['id'] != 3) {
  131. $lang[] = $key;
  132. }
  133. $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
  134. } elseif ($v['type'] == 2) {
  135. $update_type = 'textarea';
  136. $lang[] = $key;
  137. $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
  138. } elseif ($v['type'] == 3) {
  139. $update_type = 'editor';
  140. $lang[] = $key;
  141. $type = 'text-255';
  142. } elseif ($v['type'] == 4) {
  143. $update_type = 'image';
  144. $pic_index++;
  145. $list = 'Dever::load("page/lib/manage.getPic", "'.$v['id'].'", {id})';
  146. } elseif ($v['type'] == 5) {
  147. $update_type = 'images';
  148. $pic_index++;
  149. } elseif ($v['type'] == 6) {
  150. $update_type = 'radio';
  151. $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
  152. $list = true;
  153. } elseif ($v['type'] == 7) {
  154. $update_type = 'checkbox';
  155. $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
  156. $list = true;
  157. } elseif ($v['type'] == 8) {
  158. $update_type = 'day';
  159. $callback = 'maketime';
  160. $list = 'date("Y-m-d", {'.$v['name'].'})';
  161. }
  162. if ($v['list_show'] == 2) {
  163. $list = false;
  164. }
  165. if (!in_array($v['id'], $info['col'])) {
  166. $update_type = 'hidden';
  167. $list = false;
  168. }
  169. if ($v['is_option'] == 1) {
  170. $match = 'is_string';
  171. } else {
  172. $match = 'option';
  173. }
  174. if ($v['desc'] != $v['name']) {
  175. $v['name'] .= '-' . $v['desc'];
  176. }
  177. $struct[$key] = array
  178. (
  179. //'col' => 'col_' . $v['id'],
  180. 'type' => $type,
  181. 'name' => $v['name'],
  182. 'default' => '',
  183. 'desc' => $v['name'],
  184. 'match' => $match,
  185. 'update' => $update_type,
  186. 'update_bak' => $update_type,
  187. 'place' => $place,
  188. 'key' => 1,
  189. 'list' => $list,
  190. 'option' => $option,
  191. 'callback' => $callback,
  192. );
  193. }
  194. }
  195. }
  196. $struct += array
  197. (
  198. 'reorder' => array
  199. (
  200. 'type' => 'int-11',
  201. 'name' => '排序-数值越小越靠前',
  202. 'default' => '1',
  203. 'desc' => '请输入排序',
  204. 'match' => 'option',
  205. 'update' => 'text',
  206. 'search' => 'order',
  207. 'list' => true,
  208. 'order' => 'asc',
  209. 'edit' => true,
  210. ),
  211. 'state' => array
  212. (
  213. 'type' => 'tinyint-1',
  214. 'name' => '状态',
  215. 'default' => '1',
  216. 'desc' => '请选择状态',
  217. 'match' => 'is_numeric',
  218. ),
  219. 'cdate' => array
  220. (
  221. 'type' => 'int-11',
  222. 'name' => '录入时间',
  223. 'match' => array('is_numeric', time()),
  224. 'desc' => '',
  225. # 只有insert时才生效
  226. 'insert' => true,
  227. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  228. ),
  229. );
  230. return array
  231. (
  232. # 表名
  233. 'name' => 'data',
  234. # 显示给用户看的名称
  235. 'lang' => $name,
  236. 'order' => 20,
  237. 'menu' => false,
  238. //'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>',
  239. # 数据结构
  240. 'struct' => $struct,
  241. 'manage' => array
  242. (
  243. //'link' => 'parent=module.data&search_option_module_id=' . $info['id'],
  244. 'lang' => implode(',', $lang),
  245. 'insert' => false,
  246. 'edit' => false,
  247. # 自定义快捷新增和编辑
  248. 'button' => array
  249. (
  250. '新增' => array('fast'),
  251. ),
  252. 'list_button' => array
  253. (
  254. 'edit' => array('编辑'),
  255. )
  256. ),
  257. # request 请求接口定义
  258. 'request' => array
  259. (
  260. # 获取列表页
  261. 'getAll' => array
  262. (
  263. # 匹配的正则或函数 选填项
  264. 'option' => array
  265. (
  266. 'module_id' => 'yes',
  267. 'type_no' => array('yes-type', '!='),
  268. 'state' => 1,
  269. ),
  270. 'type' => 'all',
  271. 'order' => array('reorder' => 'asc', 'id' => 'desc'),
  272. 'limit' => '0,10',
  273. 'col' => '*',
  274. ),
  275. # 获取列表页 带有分页的
  276. 'getAllPage' => array
  277. (
  278. # 匹配的正则或函数 选填项
  279. 'option' => array
  280. (
  281. 'module_id' => 'yes',
  282. 'type_no' => array('yes-type', '!='),
  283. 'state' => 1,
  284. ),
  285. 'type' => 'all',
  286. 'order' => array('reorder' => 'asc', 'id' => 'desc'),
  287. 'page' => array(10, 'list'),
  288. 'col' => '*',
  289. ),
  290. ),
  291. );