project.php 6.9 KB

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