project.php 5.9 KB

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