project.php 6.6 KB

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