data.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '显示',
  6. 2 => '不显示',
  7. );
  8. $type = Dever::db('push/info')->config['func'];
  9. $type = $type();
  10. $list = function()
  11. {
  12. return Dever::db('push/info')->state();
  13. };
  14. $info = Dever::input('search_option_info_id', 1);
  15. Dever::setInput('search_option_info_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('push/info')->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. 'info_id' => array
  57. (
  58. 'type' => 'int-11',
  59. 'name' => '所属推送位',
  60. 'default' => Dever::input('search_option_info_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_info_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' => 'push/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("push/lib/manage.show", {id})',
  103. ),
  104. */
  105. );
  106. if ($info) {
  107. $info['col'] = explode(',', $info['col']);
  108. $col = Dever::db('push/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. $struct[$key] = array
  151. (
  152. //'col' => 'col_' . $v['id'],
  153. 'type' => 'varchar-1000',
  154. 'name' => $v['name'],
  155. 'default' => '',
  156. 'desc' => $v['name'],
  157. 'match' => 'is_string',
  158. 'update' => $update_type,
  159. 'place' => $place,
  160. 'key' => 1,
  161. 'list' => $list,
  162. );
  163. }
  164. }
  165. }
  166. $struct += array
  167. (
  168. 'reorder' => array
  169. (
  170. 'type' => 'int-11',
  171. 'name' => '排序(数值越大越靠前)',
  172. 'default' => '1',
  173. 'desc' => '请输入排序',
  174. 'match' => 'option',
  175. 'update' => 'text',
  176. 'search' => 'order',
  177. 'list_name' => '排序',
  178. 'list' => true,
  179. 'order' => 'desc',
  180. 'edit' => true,
  181. ),
  182. 'state' => array
  183. (
  184. 'type' => 'tinyint-1',
  185. 'name' => '状态',
  186. 'default' => '1',
  187. 'desc' => '请选择状态',
  188. 'match' => 'is_numeric',
  189. ),
  190. 'cdate' => array
  191. (
  192. 'type' => 'int-11',
  193. 'name' => '录入时间',
  194. 'match' => array('is_numeric', time()),
  195. 'desc' => '',
  196. # 只有insert时才生效
  197. 'insert' => true,
  198. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  199. ),
  200. );
  201. return array
  202. (
  203. # 表名
  204. 'name' => 'data',
  205. # 显示给用户看的名称
  206. 'lang' => $name,
  207. 'order' => 20,
  208. //'menu' => false,
  209. //'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>',
  210. # 数据结构
  211. 'struct' => $struct,
  212. 'manage' => array
  213. (
  214. 'lang' => implode(',', $lang),
  215. ),
  216. # request 请求接口定义
  217. 'request' => array
  218. (
  219. # 获取列表页
  220. 'getAll' => array
  221. (
  222. # 匹配的正则或函数 选填项
  223. 'option' => array
  224. (
  225. 'info_id' => 'yes',
  226. 'type_no' => array('yes-type', '!='),
  227. 'state' => 1,
  228. ),
  229. 'type' => 'all',
  230. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  231. 'limit' => '0,10',
  232. 'col' => '*',
  233. ),
  234. # 获取列表页 带有分页的
  235. 'getAllPage' => array
  236. (
  237. # 匹配的正则或函数 选填项
  238. 'option' => array
  239. (
  240. 'info_id' => 'yes',
  241. 'type_no' => array('yes-type', '!='),
  242. 'state' => 1,
  243. ),
  244. 'type' => 'all',
  245. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  246. 'page' => array(10, 'list'),
  247. 'col' => '*',
  248. ),
  249. ),
  250. );