data.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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' => 'type',
  83. 'bind' => array('onclick', 'loading', array('url' => Dever::url('lib/manage.showType', 'page'), 'col' => '')),
  84. ),
  85. 'type_id' => array
  86. (
  87. 'type' => 'int-11',
  88. 'name' => '关联数据',
  89. 'default' => '',
  90. 'desc' => '关联数据',
  91. 'match' => 'option',
  92. 'update' => 'select',
  93. 'show' => 'type=' . $type_id,
  94. 'update_search' => 'page/lib/manage.search?{type}',
  95. ),
  96. /*
  97. 'data' => array
  98. (
  99. 'type' => 'text-1000',
  100. 'name' => '自定义数据项',
  101. 'default' => '',
  102. 'desc' => '自定义数据项',
  103. 'match' => 'is_string',
  104. 'option' => $data,
  105. 'update' => $data_update,
  106. 'list' => 'Dever::load("page/lib/manage.show", {id})',
  107. ),
  108. */
  109. );
  110. if ($info) {
  111. $info['col'] = explode(',', $info['col']);
  112. $col = Dever::db('page/col')->getAll();
  113. if ($col) {
  114. $pic_index = 0;
  115. if ($info['col_pic']) {
  116. $pic = $info['col_pic'];
  117. $pic_temp = explode("\r\n", $pic);
  118. }
  119. foreach ($col as $k => $v) {
  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. if ($v['type'] == 1) {
  128. $update_type = 'text';
  129. if ($v['id'] != 3) {
  130. $lang[] = $key;
  131. }
  132. $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
  133. } elseif ($v['type'] == 2) {
  134. $update_type = 'textarea';
  135. $lang[] = $key;
  136. $list = 'Dever::load("page/lib/manage.getData", "'.$v['id'].'", {id})';
  137. } elseif ($v['type'] == 3) {
  138. $update_type = 'editor';
  139. $lang[] = $key;
  140. $type = 'text-255';
  141. } elseif ($v['type'] == 4) {
  142. $update_type = 'image';
  143. $pic_index++;
  144. $list = 'Dever::load("page/lib/manage.pic", "{'.$key.'}")';
  145. } elseif ($v['type'] == 5) {
  146. $update_type = 'images';
  147. $pic_index++;
  148. } elseif ($v['type'] == 6) {
  149. $update_type = 'radio';
  150. } elseif ($v['type'] == 7) {
  151. $update_type = 'checkbox';
  152. } elseif ($v['type'] == 8) {
  153. $update_type = 'day';
  154. }
  155. if (!in_array($v['id'], $info['col'])) {
  156. $update_type = 'hidden';
  157. $list = false;
  158. }
  159. if ($v['is_option'] == 1) {
  160. $match = 'is_string';
  161. } else {
  162. $match = 'option';
  163. }
  164. $struct[$key] = array
  165. (
  166. //'col' => 'col_' . $v['id'],
  167. 'type' => $type,
  168. 'name' => $v['name'],
  169. 'default' => '',
  170. 'desc' => $v['name'],
  171. 'match' => $match,
  172. 'update' => $update_type,
  173. 'place' => $place,
  174. 'key' => 1,
  175. 'list' => $list,
  176. );
  177. }
  178. }
  179. }
  180. $struct += array
  181. (
  182. 'reorder' => array
  183. (
  184. 'type' => 'int-11',
  185. 'name' => '排序(数值越大越靠前)',
  186. 'default' => '1',
  187. 'desc' => '请输入排序',
  188. 'match' => 'option',
  189. 'update' => 'text',
  190. 'search' => 'order',
  191. 'list_name' => '排序',
  192. 'list' => true,
  193. 'order' => 'desc',
  194. 'edit' => true,
  195. ),
  196. 'state' => array
  197. (
  198. 'type' => 'tinyint-1',
  199. 'name' => '状态',
  200. 'default' => '1',
  201. 'desc' => '请选择状态',
  202. 'match' => 'is_numeric',
  203. ),
  204. 'cdate' => array
  205. (
  206. 'type' => 'int-11',
  207. 'name' => '录入时间',
  208. 'match' => array('is_numeric', time()),
  209. 'desc' => '',
  210. # 只有insert时才生效
  211. 'insert' => true,
  212. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  213. ),
  214. );
  215. return array
  216. (
  217. # 表名
  218. 'name' => 'data',
  219. # 显示给用户看的名称
  220. 'lang' => $name,
  221. 'order' => 20,
  222. 'menu' => false,
  223. //'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>',
  224. # 数据结构
  225. 'struct' => $struct,
  226. 'manage' => array
  227. (
  228. 'lang' => implode(',', $lang),
  229. 'insert' => false,
  230. 'edit' => false,
  231. # 自定义快捷新增和编辑
  232. 'button' => array
  233. (
  234. '新增' => array('fast'),
  235. ),
  236. 'list_button' => array
  237. (
  238. 'edit' => array('编辑'),
  239. )
  240. ),
  241. # request 请求接口定义
  242. 'request' => array
  243. (
  244. # 获取列表页
  245. 'getAll' => array
  246. (
  247. # 匹配的正则或函数 选填项
  248. 'option' => array
  249. (
  250. 'module_id' => 'yes',
  251. 'type_no' => array('yes-type', '!='),
  252. 'state' => 1,
  253. ),
  254. 'type' => 'all',
  255. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  256. 'limit' => '0,10',
  257. 'col' => '*',
  258. ),
  259. # 获取列表页 带有分页的
  260. 'getAllPage' => array
  261. (
  262. # 匹配的正则或函数 选填项
  263. 'option' => array
  264. (
  265. 'module_id' => 'yes',
  266. 'type_no' => array('yes-type', '!='),
  267. 'state' => 1,
  268. ),
  269. 'type' => 'all',
  270. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  271. 'page' => array(10, 'list'),
  272. 'col' => '*',
  273. ),
  274. ),
  275. );