project.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. # 定义几个常用的选项
  3. $local = array
  4. (
  5. 1 => '关闭',
  6. 2 => '开启',
  7. );
  8. $status = array
  9. (
  10. 1 => '待机',
  11. 2 => '入队',
  12. );
  13. $cate = function()
  14. {
  15. $array = array();
  16. $cate = Dever::load('spider/cate-main');
  17. if ($cate) {
  18. $array += $cate;
  19. }
  20. return $array;
  21. };
  22. $cate_child = function()
  23. {
  24. $cate = Dever::load('spider/cate-child');
  25. return $cate;
  26. };
  27. $search_cate = function()
  28. {
  29. $array = array
  30. (
  31. -1 => array('id' => '-1', 'name' => '所有分类'),
  32. );
  33. $cate = Dever::load('forum/cate.all');
  34. if ($cate) {
  35. $array += $cate;
  36. }
  37. return $array;
  38. };
  39. return array
  40. (
  41. # 表名
  42. 'name' => 'project',
  43. # 显示给用户看的名称
  44. 'lang' => '项目管理',
  45. # 后台菜单排序
  46. 'order' => 20,
  47. //'desc' => 'API:http://192.168.15.10/plant/spider/??project_id=1',
  48. # 数据结构
  49. 'struct' => array
  50. (
  51. 'id' => array
  52. (
  53. 'type' => 'int-11',
  54. 'name' => '项目ID',
  55. 'default' => '',
  56. 'desc' => '',
  57. 'match' => 'is_numeric',
  58. 'search' => 'order',
  59. 'list' => true,
  60. 'order' => 'desc',
  61. ),
  62. 'name' => array
  63. (
  64. 'type' => 'varchar-100',
  65. 'name' => '项目名称',
  66. 'default' => '',
  67. 'desc' => '请输入项目名称',
  68. 'match' => 'is_string',
  69. 'update' => 'text',
  70. 'search' => 'order,fulltext',
  71. 'list' => true,
  72. 'edit' => true,
  73. ),
  74. 'cate_id_parent' => array
  75. (
  76. 'type' => 'int-11',
  77. 'name' => '选择分类',
  78. 'default' => '0',
  79. 'desc' => '请选择分类',
  80. 'match' => 'is_numeric',
  81. 'update' => 'select',
  82. //'search' => 'order,select',
  83. 'list_name' => '父级分类',
  84. 'option' => $cate,
  85. # 当值改变时,执行下一步操作
  86. 'child_name' => 'cate_id',
  87. 'child' => $cate_child,
  88. 'child_value' => '{cate_id}',
  89. ),
  90. 'cate_id' => array
  91. (
  92. 'type' => 'int-11',
  93. 'name' => '子分类',
  94. 'default' => '0',
  95. 'desc' => '请选择子分类',
  96. 'match' => 'is_numeric',
  97. 'search' => 'group',
  98. 'option' => $search_cate,
  99. 'list_name' => '分类',
  100. 'list' => '{cate_id} > 0 ? Dever::load("spider/cate-one#name", {cate_id}) : "无"',
  101. ),
  102. 'site' => array
  103. (
  104. 'type' => 'text-255',
  105. 'name' => '采集网址-多个网址换行隔开',
  106. 'default' => '',
  107. 'desc' => '采集网址',
  108. 'match' => 'option',
  109. 'update' => 'textarea',
  110. //'list' => true,
  111. //'edit' => 'textarea',
  112. ),
  113. 'collect_rule' => array
  114. (
  115. 'type' => 'varchar-500',
  116. 'name' => '采集规则-支持dom解析、正则、json格式',
  117. 'default' => '',
  118. 'desc' => '采集规则',
  119. 'match' => 'is_string',
  120. 'update' => 'textarea',
  121. 'edit' => true,
  122. 'list' => true,
  123. ),
  124. 'page_num' => array
  125. (
  126. 'type' => 'int-11',
  127. 'name' => '采集页数-值为0则默认采集1000页',
  128. 'default' => '0',
  129. 'desc' => '采集页数',
  130. 'match' => 'option',
  131. 'update' => 'text',
  132. ),
  133. 'status' => array
  134. (
  135. 'type' => 'tinyint-1',
  136. 'name' => '状态',
  137. 'default' => '1',
  138. 'desc' => '状态',
  139. 'match' => 'is_numeric',
  140. 'option' => $status,
  141. 'list' => true,
  142. 'update' => 'radio',
  143. 'edit' => true,
  144. ),
  145. 'num' => array
  146. (
  147. 'type' => 'int-11',
  148. 'name' => '抓取次数',
  149. 'default' => '0',
  150. 'desc' => '抓取次数',
  151. 'match' => 'is_numeric',
  152. 'list' => true,
  153. ),
  154. 'sdate' => array
  155. (
  156. 'type' => 'int-11',
  157. 'name' => '抓取开始时间',
  158. 'default' => '0',
  159. 'desc' => '抓取开始时间',
  160. 'match' => 'is_numeric',
  161. 'update' => 'date',
  162. 'list' => 'date("Y-m-d H:i:s", {sdate})',
  163. 'callback' => 'maketime',
  164. ),
  165. 'interval' => array
  166. (
  167. 'type' => 'int-11',
  168. 'name' => '抓取间隔秒数-填写开始时间之后的间隔抓取的秒数,为0则只抓取一次',
  169. 'default' => '0',
  170. 'desc' => '抓取间隔秒数',
  171. 'match' => 'is_numeric',
  172. 'update' => 'text',
  173. ),
  174. 'state' => array
  175. (
  176. 'type' => 'tinyint-1',
  177. 'name' => '状态',
  178. 'default' => '1',
  179. 'desc' => '请选择状态',
  180. 'match' => 'is_numeric',
  181. ),
  182. 'cdate' => array
  183. (
  184. 'type' => 'int-11',
  185. 'name' => '更新时间',
  186. 'match' => array('is_numeric', time()),
  187. 'desc' => '',
  188. # 只有insert时才生效
  189. //'insert' => true,
  190. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  191. ),
  192. ),
  193. 'manage' => array
  194. (
  195. # 更新数据时,要显示的按钮,这里填写js脚本事件即可。保存当前数据可为固定参数:"save-data",复制数据为:copy-data
  196. 'update_button' => array
  197. (
  198. '提交保存' => 'save-data',
  199. '放弃保存' => "msg({status:1,msg:'yes'})",
  200. '复制数据' => 'copy-data',
  201. ),
  202. # 不允许编辑
  203. //'edit' => false,
  204. # 列表页的类型
  205. //'list_type' => 'parent',
  206. # 可以删除
  207. 'list_button' => array
  208. (
  209. 'list_col' => array('字段设置', '"col&search_option_project_id={id}&oper_parent=project"'),
  210. //'list_data' => array('数据列表', '"data&search_option_project_id={id}&oper_save_jump=project&oper_parent=project"'),
  211. //'delete' => array('采集数据', 'Dever::url("spider/data.daemon?id={id}&")'),
  212. ),
  213. //'desc' => '注意:命令码',
  214. ),
  215. # request 请求接口定义
  216. 'request' => array
  217. (
  218. # 获取所有入队并且符合当前时间的配置
  219. 'get' => array
  220. (
  221. 'option' => array
  222. (
  223. 'id' => 'yes',
  224. 'status' => 2,
  225. 'sdate' => array('yes-sdate`+`interval', '<='),
  226. 'state' => 1,
  227. ),
  228. 'type' => 'all',
  229. 'order' => array('id' => 'desc'),
  230. 'col' => '*',
  231. ),
  232. # 获取所有运行中的数据
  233. 'getOne' => array
  234. (
  235. 'option' => array
  236. (
  237. 'id' => 'yes',
  238. 'status' => array('yes'),
  239. 'sdate' => array('yes-sdate`+`interval', '<='),
  240. 'state' => 1,
  241. ),
  242. 'type' => 'one',
  243. ),
  244. )
  245. );