data.php 7.9 KB

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