data.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. $lang[] = $key;
  128. $list = true;
  129. } elseif ($v['type'] == 2) {
  130. $update_type = 'textarea';
  131. $lang[] = $key;
  132. $list = true;
  133. } elseif ($v['type'] == 3) {
  134. $update_type = 'editor';
  135. $lang[] = $key;
  136. } elseif ($v['type'] == 4) {
  137. $update_type = 'image';
  138. $pic_index++;
  139. } elseif ($v['type'] == 5) {
  140. $update_type = 'images';
  141. $pic_index++;
  142. } elseif ($v['type'] == 6) {
  143. $update_type = 'radio';
  144. } elseif ($v['type'] == 7) {
  145. $update_type = 'checkbox';
  146. } elseif ($v['type'] == 8) {
  147. $update_type = 'day';
  148. }
  149. }
  150. if ($v['is_option'] == 1) {
  151. $match = 'is_string';
  152. } else {
  153. $match = 'option';
  154. }
  155. $struct[$key] = array
  156. (
  157. //'col' => 'col_' . $v['id'],
  158. 'type' => 'varchar-1000',
  159. 'name' => $v['name'],
  160. 'default' => '',
  161. 'desc' => $v['name'],
  162. 'match' => $match,
  163. 'update' => $update_type,
  164. 'place' => $place,
  165. 'key' => 1,
  166. 'list' => $list,
  167. );
  168. }
  169. }
  170. }
  171. $struct += array
  172. (
  173. 'reorder' => array
  174. (
  175. 'type' => 'int-11',
  176. 'name' => '排序(数值越大越靠前)',
  177. 'default' => '1',
  178. 'desc' => '请输入排序',
  179. 'match' => 'option',
  180. 'update' => 'text',
  181. 'search' => 'order',
  182. 'list_name' => '排序',
  183. 'list' => true,
  184. 'order' => 'desc',
  185. 'edit' => true,
  186. ),
  187. 'state' => array
  188. (
  189. 'type' => 'tinyint-1',
  190. 'name' => '状态',
  191. 'default' => '1',
  192. 'desc' => '请选择状态',
  193. 'match' => 'is_numeric',
  194. ),
  195. 'cdate' => array
  196. (
  197. 'type' => 'int-11',
  198. 'name' => '录入时间',
  199. 'match' => array('is_numeric', time()),
  200. 'desc' => '',
  201. # 只有insert时才生效
  202. 'insert' => true,
  203. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  204. ),
  205. );
  206. return array
  207. (
  208. # 表名
  209. 'name' => 'data',
  210. # 显示给用户看的名称
  211. 'lang' => $name,
  212. 'order' => 20,
  213. 'menu' => false,
  214. //'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>',
  215. # 数据结构
  216. 'struct' => $struct,
  217. 'manage' => array
  218. (
  219. 'lang' => implode(',', $lang),
  220. ),
  221. # request 请求接口定义
  222. 'request' => array
  223. (
  224. # 获取列表页
  225. 'getAll' => array
  226. (
  227. # 匹配的正则或函数 选填项
  228. 'option' => array
  229. (
  230. 'module_id' => 'yes',
  231. 'type_no' => array('yes-type', '!='),
  232. 'state' => 1,
  233. ),
  234. 'type' => 'all',
  235. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  236. 'limit' => '0,10',
  237. 'col' => '*',
  238. ),
  239. # 获取列表页 带有分页的
  240. 'getAllPage' => array
  241. (
  242. # 匹配的正则或函数 选填项
  243. 'option' => array
  244. (
  245. 'module_id' => 'yes',
  246. 'type_no' => array('yes-type', '!='),
  247. 'state' => 1,
  248. ),
  249. 'type' => 'all',
  250. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  251. 'page' => array(10, 'list'),
  252. 'col' => '*',
  253. ),
  254. ),
  255. );