project.php 6.0 KB

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