data.php 7.8 KB

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