data.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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' => '-1',
  86. 'desc' => '关联数据',
  87. 'match' => 'option',
  88. //'update' => 'select',
  89. 'show' => 'type=' . $type_id,
  90. //'value' => '-1',
  91. 'update_search' => 'push/lib/manage.search?{type}',
  92. ),
  93. /*
  94. 'data' => array
  95. (
  96. 'type' => 'text-1000',
  97. 'name' => '自定义数据项',
  98. 'default' => '',
  99. 'desc' => '自定义数据项',
  100. 'match' => 'is_string',
  101. 'option' => $data,
  102. 'update' => $data_update,
  103. 'list' => 'Dever::load("push/lib/manage.show", {id})',
  104. ),
  105. */
  106. );
  107. if ($info) {
  108. $info['col'] = explode(',', $info['col']);
  109. $col = Dever::db('push/col')->getAll();
  110. if ($col) {
  111. $pic_index = 0;
  112. if ($info['col_pic']) {
  113. $pic = $info['col_pic'];
  114. $pic_temp = explode("\r\n", $pic);
  115. }
  116. foreach ($col as $k => $v) {
  117. $place = $v['pic'];
  118. if ($info['col_pic'] && isset($pic_temp[$pic_index]) && $pic_temp[$pic_index]) {
  119. $place = $pic_temp[$pic_index];
  120. }
  121. $key = 'col_' . $v['id'];
  122. $list = false;
  123. if (!in_array($v['id'], $info['col'])) {
  124. $update_type = false;
  125. } else {
  126. if ($v['type'] == 1) {
  127. $update_type = 'text';
  128. $lang[] = $key;
  129. $list = true;
  130. } elseif ($v['type'] == 2) {
  131. $update_type = 'textarea';
  132. $lang[] = $key;
  133. $list = true;
  134. } elseif ($v['type'] == 3) {
  135. $update_type = 'editor';
  136. $lang[] = $key;
  137. } elseif ($v['type'] == 4) {
  138. $update_type = 'image';
  139. $pic_index++;
  140. } elseif ($v['type'] == 5) {
  141. $update_type = 'images';
  142. $pic_index++;
  143. } elseif ($v['type'] == 6) {
  144. $update_type = 'radio';
  145. } elseif ($v['type'] == 7) {
  146. $update_type = 'checkbox';
  147. } elseif ($v['type'] == 8) {
  148. $update_type = 'day';
  149. }
  150. }
  151. $struct[$key] = array
  152. (
  153. //'col' => 'col_' . $v['id'],
  154. 'type' => 'varchar-1000',
  155. 'name' => $v['name'],
  156. 'default' => '',
  157. 'desc' => $v['name'],
  158. 'match' => 'is_string',
  159. 'update' => $update_type,
  160. 'place' => $place,
  161. 'key' => 1,
  162. 'list' => $list,
  163. );
  164. }
  165. }
  166. }
  167. $struct += array
  168. (
  169. 'reorder' => array
  170. (
  171. 'type' => 'int-11',
  172. 'name' => '排序(数值越大越靠前)',
  173. 'default' => '1',
  174. 'desc' => '请输入排序',
  175. 'match' => 'option',
  176. 'update' => 'text',
  177. 'search' => 'order',
  178. 'list_name' => '排序',
  179. 'list' => true,
  180. 'order' => 'desc',
  181. 'edit' => true,
  182. ),
  183. 'state' => array
  184. (
  185. 'type' => 'tinyint-1',
  186. 'name' => '状态',
  187. 'default' => '1',
  188. 'desc' => '请选择状态',
  189. 'match' => 'is_numeric',
  190. ),
  191. 'cdate' => array
  192. (
  193. 'type' => 'int-11',
  194. 'name' => '录入时间',
  195. 'match' => array('is_numeric', time()),
  196. 'desc' => '',
  197. # 只有insert时才生效
  198. 'insert' => true,
  199. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  200. ),
  201. );
  202. return array
  203. (
  204. # 表名
  205. 'name' => 'data',
  206. # 显示给用户看的名称
  207. 'lang' => $name,
  208. 'order' => 20,
  209. //'menu' => false,
  210. //'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>',
  211. # 数据结构
  212. 'struct' => $struct,
  213. 'manage' => array
  214. (
  215. 'lang' => implode(',', $lang),
  216. ),
  217. # request 请求接口定义
  218. 'request' => array
  219. (
  220. # 获取列表页
  221. 'getAll' => array
  222. (
  223. # 匹配的正则或函数 选填项
  224. 'option' => array
  225. (
  226. 'info_id' => 'yes',
  227. 'type_no' => array('yes-type', '!='),
  228. 'state' => 1,
  229. ),
  230. 'type' => 'all',
  231. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  232. 'limit' => '0,10',
  233. 'col' => '*',
  234. ),
  235. # 获取列表页 带有分页的
  236. 'getAllPage' => array
  237. (
  238. # 匹配的正则或函数 选填项
  239. 'option' => array
  240. (
  241. 'info_id' => 'yes',
  242. 'type_no' => array('yes-type', '!='),
  243. 'state' => 1,
  244. ),
  245. 'type' => 'all',
  246. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  247. 'page' => array(10, 'list'),
  248. 'col' => '*',
  249. ),
  250. ),
  251. );