data.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. return;
  32. }
  33. $function = explode(',', $info['func']);
  34. $type_id = array();
  35. foreach ($type as $k => $v) {
  36. if (!in_array($v['id'], $function)) {
  37. unset($type[$k]);
  38. } else {
  39. $type_default = $v['id'];
  40. if ($v['id'] > 0 && isset($v['type']) && $v['type'] == 1) {
  41. $type_id[] = $v['id'];
  42. }
  43. }
  44. }
  45. $type_id = implode(',', $type_id);
  46. }
  47. $struct = array
  48. (
  49. 'id' => array
  50. (
  51. 'type' => 'int-11',
  52. 'name' => 'ID',
  53. 'default' => '',
  54. 'desc' => '',
  55. 'match' => 'is_numeric',
  56. //'search' => 'order',
  57. 'order' => 'desc',
  58. //'list' => true,
  59. ),
  60. 'module_id' => array
  61. (
  62. 'type' => 'int-11',
  63. 'name' => '所属模块',
  64. 'default' => Dever::input('search_option_module_id', '1'),
  65. 'desc' => '模块',
  66. 'match' => 'is_numeric',
  67. 'search' => 'select',
  68. 'update' => 'hidden',
  69. 'option' => $list,
  70. 'list' => true,
  71. 'value' => Dever::input('search_option_module_id', '1'),
  72. ),
  73. 'type' => array
  74. (
  75. 'type' => 'int-11',
  76. 'name' => '功能类型',
  77. 'default' => ''.$type_default.'',
  78. 'desc' => '请选择功能类型',
  79. 'match' => 'is_numeric',
  80. 'update' => 'radio',
  81. //'search' => 'select',
  82. 'option' => $type,
  83. 'control' => 'type',
  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. } elseif ($v['type'] == 5) {
  145. $update_type = 'images';
  146. $pic_index++;
  147. } elseif ($v['type'] == 6) {
  148. $update_type = 'radio';
  149. } elseif ($v['type'] == 7) {
  150. $update_type = 'checkbox';
  151. } elseif ($v['type'] == 8) {
  152. $update_type = 'day';
  153. }
  154. if (!in_array($v['id'], $info['col'])) {
  155. $update_type = 'hidden';
  156. $list = false;
  157. }
  158. if ($v['is_option'] == 1) {
  159. $match = 'is_string';
  160. } else {
  161. $match = 'option';
  162. }
  163. $struct[$key] = array
  164. (
  165. //'col' => 'col_' . $v['id'],
  166. 'type' => $type,
  167. 'name' => $v['name'],
  168. 'default' => '',
  169. 'desc' => $v['name'],
  170. 'match' => $match,
  171. 'update' => $update_type,
  172. 'place' => $place,
  173. 'key' => 1,
  174. 'list' => $list,
  175. );
  176. }
  177. }
  178. }
  179. $struct += array
  180. (
  181. 'reorder' => array
  182. (
  183. 'type' => 'int-11',
  184. 'name' => '排序(数值越大越靠前)',
  185. 'default' => '1',
  186. 'desc' => '请输入排序',
  187. 'match' => 'option',
  188. 'update' => 'text',
  189. 'search' => 'order',
  190. 'list_name' => '排序',
  191. 'list' => true,
  192. 'order' => 'desc',
  193. 'edit' => true,
  194. ),
  195. 'state' => array
  196. (
  197. 'type' => 'tinyint-1',
  198. 'name' => '状态',
  199. 'default' => '1',
  200. 'desc' => '请选择状态',
  201. 'match' => 'is_numeric',
  202. ),
  203. 'cdate' => array
  204. (
  205. 'type' => 'int-11',
  206. 'name' => '录入时间',
  207. 'match' => array('is_numeric', time()),
  208. 'desc' => '',
  209. # 只有insert时才生效
  210. 'insert' => true,
  211. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  212. ),
  213. );
  214. return array
  215. (
  216. # 表名
  217. 'name' => 'data',
  218. # 显示给用户看的名称
  219. 'lang' => $name,
  220. 'order' => 20,
  221. 'menu' => false,
  222. //'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>',
  223. # 数据结构
  224. 'struct' => $struct,
  225. 'manage' => array
  226. (
  227. 'lang' => implode(',', $lang),
  228. ),
  229. # request 请求接口定义
  230. 'request' => array
  231. (
  232. # 获取列表页
  233. 'getAll' => array
  234. (
  235. # 匹配的正则或函数 选填项
  236. 'option' => array
  237. (
  238. 'module_id' => 'yes',
  239. 'type_no' => array('yes-type', '!='),
  240. 'state' => 1,
  241. ),
  242. 'type' => 'all',
  243. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  244. 'limit' => '0,10',
  245. 'col' => '*',
  246. ),
  247. # 获取列表页 带有分页的
  248. 'getAllPage' => array
  249. (
  250. # 匹配的正则或函数 选填项
  251. 'option' => array
  252. (
  253. 'module_id' => 'yes',
  254. 'type_no' => array('yes-type', '!='),
  255. 'state' => 1,
  256. ),
  257. 'type' => 'all',
  258. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  259. 'page' => array(10, 'list'),
  260. 'col' => '*',
  261. ),
  262. ),
  263. );