data.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. $name = '推送数据管理';
  23. if ($info) {
  24. $info = Dever::db('push/info')->one($info);
  25. if (!$info) {
  26. return;
  27. }
  28. $function = explode(',', $info['func']);
  29. $type_id = array();
  30. foreach ($type as $k => $v) {
  31. if (!in_array($v['id'], $function)) {
  32. unset($type[$k]);
  33. } else {
  34. $type_default = $v['id'];
  35. if ($v['id'] > 0 && isset($v['type']) && $v['type'] == 1) {
  36. $type_id[] = $v['id'];
  37. }
  38. }
  39. }
  40. $type_id = implode(',', $type_id);
  41. }
  42. $struct = array
  43. (
  44. 'id' => array
  45. (
  46. 'type' => 'int-11',
  47. 'name' => 'ID',
  48. 'default' => '',
  49. 'desc' => '',
  50. 'match' => 'is_numeric',
  51. //'search' => 'order',
  52. 'order' => 'desc',
  53. //'list' => true,
  54. ),
  55. 'info_id' => array
  56. (
  57. 'type' => 'int-11',
  58. 'name' => '所属推送位',
  59. 'default' => Dever::input('search_option_info_id', '1'),
  60. 'desc' => '推送位',
  61. 'match' => 'is_numeric',
  62. 'search' => 'select',
  63. 'update' => 'hidden',
  64. 'option' => $list,
  65. 'list' => true,
  66. 'value' => Dever::input('search_option_info_id', '1'),
  67. ),
  68. 'type' => array
  69. (
  70. 'type' => 'int-11',
  71. 'name' => '功能类型',
  72. 'default' => ''.$type_default.'',
  73. 'desc' => '请选择功能类型',
  74. 'match' => 'is_numeric',
  75. 'update' => 'radio',
  76. //'search' => 'select',
  77. 'option' => $type,
  78. 'control' => 'type',
  79. ),
  80. 'type_id' => array
  81. (
  82. 'type' => 'int-11',
  83. 'name' => '关联数据',
  84. 'default' => '',
  85. 'desc' => '关联数据',
  86. 'match' => 'option',
  87. 'update' => 'select',
  88. 'show' => 'type=' . $type_id,
  89. 'update_search' => 'push/lib/manage.search?{type}',
  90. ),
  91. /*
  92. 'data' => array
  93. (
  94. 'type' => 'text-1000',
  95. 'name' => '自定义数据项',
  96. 'default' => '',
  97. 'desc' => '自定义数据项',
  98. 'match' => 'is_string',
  99. 'option' => $data,
  100. 'update' => $data_update,
  101. 'list' => 'Dever::load("push/lib/manage.show", {id})',
  102. ),
  103. */
  104. );
  105. if ($info) {
  106. $col = Dever::db('push/col')->getAll(array('id' => $info['col']));
  107. if ($col) {
  108. $pic_index = 0;
  109. if ($info['col_pic']) {
  110. $pic = $info['col_pic'];
  111. $pic_temp = explode("\r\n", $pic);
  112. }
  113. foreach ($col as $k => $v) {
  114. $place = $v['pic'];
  115. if ($info['col_pic'] && isset($pic_temp[$pic_index]) && $pic_temp[$pic_index]) {
  116. $place = $pic_temp[$pic_index];
  117. }
  118. $key = 'col_' . $v['id'];
  119. $list = false;
  120. if ($v['type'] == 1) {
  121. $update_type = 'text';
  122. $lang[] = $key;
  123. $list = true;
  124. } elseif ($v['type'] == 2) {
  125. $update_type = 'textarea';
  126. $lang[] = $key;
  127. $list = true;
  128. } elseif ($v['type'] == 3) {
  129. $update_type = 'editor';
  130. $lang[] = $key;
  131. } elseif ($v['type'] == 4) {
  132. $update_type = 'image';
  133. $pic_index++;
  134. } elseif ($v['type'] == 5) {
  135. $update_type = 'images';
  136. $pic_index++;
  137. } elseif ($v['type'] == 6) {
  138. $update_type = 'radio';
  139. } elseif ($v['type'] == 7) {
  140. $update_type = 'checkbox';
  141. } elseif ($v['type'] == 8) {
  142. $update_type = 'day';
  143. }
  144. $struct[$key] = array
  145. (
  146. //'col' => 'col_' . $v['id'],
  147. 'type' => 'varchar-1000',
  148. 'name' => $v['name'],
  149. 'default' => '',
  150. 'desc' => $v['name'],
  151. 'match' => 'is_string',
  152. 'update' => $update_type,
  153. 'place' => $place,
  154. 'key' => 1,
  155. 'list' => $list,
  156. );
  157. }
  158. }
  159. }
  160. $struct += array
  161. (
  162. 'reorder' => array
  163. (
  164. 'type' => 'int-11',
  165. 'name' => '排序(数值越大越靠前)',
  166. 'default' => '1',
  167. 'desc' => '请输入排序',
  168. 'match' => 'option',
  169. 'update' => 'text',
  170. 'search' => 'order',
  171. 'list_name' => '排序',
  172. 'list' => true,
  173. 'order' => 'desc',
  174. 'edit' => true,
  175. ),
  176. 'state' => array
  177. (
  178. 'type' => 'tinyint-1',
  179. 'name' => '状态',
  180. 'default' => '1',
  181. 'desc' => '请选择状态',
  182. 'match' => 'is_numeric',
  183. ),
  184. 'cdate' => array
  185. (
  186. 'type' => 'int-11',
  187. 'name' => '录入时间',
  188. 'match' => array('is_numeric', time()),
  189. 'desc' => '',
  190. # 只有insert时才生效
  191. 'insert' => true,
  192. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  193. ),
  194. );
  195. return array
  196. (
  197. # 表名
  198. 'name' => 'data',
  199. # 显示给用户看的名称
  200. 'lang' => $name,
  201. 'order' => 20,
  202. //'menu' => false,
  203. //'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>',
  204. # 数据结构
  205. 'struct' => $struct,
  206. 'manage' => array
  207. (
  208. 'lang' => implode(',', $lang),
  209. ),
  210. # request 请求接口定义
  211. 'request' => array
  212. (
  213. # 获取列表页
  214. 'getAll' => array
  215. (
  216. # 匹配的正则或函数 选填项
  217. 'option' => array
  218. (
  219. 'info_id' => 'yes',
  220. 'type_no' => array('yes-type', '!='),
  221. 'state' => 1,
  222. ),
  223. 'type' => 'all',
  224. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  225. 'limit' => '0,10',
  226. 'col' => '*',
  227. ),
  228. # 获取列表页 带有分页的
  229. 'getAllPage' => array
  230. (
  231. # 匹配的正则或函数 选填项
  232. 'option' => array
  233. (
  234. 'info_id' => 'yes',
  235. 'type_no' => array('yes-type', '!='),
  236. 'state' => 1,
  237. ),
  238. 'type' => 'all',
  239. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  240. 'page' => array(10, 'list'),
  241. 'col' => '*',
  242. ),
  243. ),
  244. );