article.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <?php
  2. $status = Dever::config('base')->status;
  3. # 每页的数据量
  4. $page = 15;
  5. $cate = function()
  6. {
  7. $array = array();
  8. $info = Dever::db('content/cate')->select(array('type' => 1));
  9. if($info)
  10. {
  11. $array += $info;
  12. }
  13. return $array;
  14. };
  15. $author = function()
  16. {
  17. $array = array();
  18. $info = Dever::db('content/author')->state();
  19. if($info)
  20. {
  21. $array += $info;
  22. }
  23. return $array;
  24. };
  25. $yes = array
  26. (
  27. 1 => '是',
  28. 2 => '否',
  29. );
  30. # 常用的col
  31. $col = 'id,cate_id,name,pic_cover,num_add_view+num_view as num_view,content,author_id,`desc`,pdate,cdate,tag';
  32. return array
  33. (
  34. # 表名
  35. 'name' => 'article',
  36. # 显示给用户看的名称
  37. 'lang' => '文章管理',
  38. 'order' => 100,
  39. # 同步更新另外一个或多个表的数据
  40. 'syncone' => array
  41. (
  42. 'content/search' => array
  43. (
  44. # 更新另外一个表的字段 => 本表的字段
  45. 'where' => array('data_id' => 'id', 'type' => 1),
  46. # 要更新的数据
  47. 'update' => array('data_id' => 'id', 'type' => 1, 'pdate' => 'pdate', 'reorder' => 'reorder', 'name' => 'name', 'status' => 'status', 'cate_id' => 'cate_id', 'state' => 'state'),
  48. )
  49. ),
  50. 'end' => array
  51. (
  52. 'insert' => array('content/lib/author.data?source_table=content/article','tag/lib/core.data?source_table=content/article'),
  53. 'update' => array('content/lib/author.data?source_table=content/article','tag/lib/core.data?source_table=content/article'),
  54. ),
  55. # 数据结构
  56. 'struct' => array
  57. (
  58. 'id' => array
  59. (
  60. 'type' => 'int-11',
  61. 'name' => 'ID',
  62. 'default' => '',
  63. 'desc' => '',
  64. 'match' => 'is_numeric',
  65. 'list' => true,
  66. ),
  67. 'name' => array
  68. (
  69. 'type' => 'varchar-80',
  70. 'name' => '标题',
  71. 'default' => '',
  72. 'desc' => '标题',
  73. 'match' => 'is_string',
  74. 'update' => 'text',
  75. 'list' => true,
  76. 'search' => 'fulltext',
  77. //增加预览
  78. 'preview' => true,
  79. ),
  80. 'desc' => array
  81. (
  82. 'type' => 'varchar-500',
  83. 'name' => '摘要',
  84. 'default' => '',
  85. 'desc' => '摘要',
  86. 'match' => 'is_string',
  87. 'update' => 'textarea',
  88. ),
  89. 'cate_id' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '所属栏目',
  93. 'default' => '1',
  94. 'desc' => '所属栏目',
  95. 'match' => 'is_numeric',
  96. 'update' => 'select',
  97. 'option' => $cate,
  98. 'search' => 'select',
  99. 'list' => 'Dever::load("content/cate-one#name", {cate_id})',
  100. ),
  101. 'author_id' => array
  102. (
  103. 'type' => 'int-11',
  104. 'name' => '作者',
  105. 'default' => '1',
  106. 'desc' => '作者',
  107. 'match' => 'is_numeric',
  108. 'update' => 'select',
  109. //'option' => $author,
  110. 'search' => 'select',
  111. 'update_search' => 'content/lib/author.search',
  112. ),
  113. 'pic_cover' => array
  114. (
  115. 'type' => 'varchar-150',
  116. 'name' => '封面图',
  117. 'default' => '',
  118. 'desc' => '封面图',
  119. 'match' => 'option',
  120. 'update' => 'image',
  121. 'key' => '1',
  122. 'place' => '210*158',
  123. ),
  124. 'tag' => array
  125. (
  126. 'type' => 'text-255',
  127. 'name' => '标签',
  128. 'default' => '',
  129. 'desc' => '标签',
  130. 'match' => 'is_numeric',
  131. 'update' => 'selects',
  132. //'search' => 'fulltext',
  133. 'update_search' => 'tag/lib/core.search',
  134. ),
  135. 'num_add_view' => array
  136. (
  137. 'type' => 'int-11',
  138. 'name' => '浏览量基数',
  139. 'default' => '0',
  140. 'desc' => '浏览量基数',
  141. 'match' => 'option',
  142. //'update' => 'text',
  143. ),
  144. 'num_view' => array
  145. (
  146. 'type' => 'int-11',
  147. 'name' => '浏览量',
  148. 'default' => '0',
  149. 'desc' => '请填写浏览量',
  150. 'match' => 'option',
  151. 'search' => 'order',
  152. 'list' => '{num_view}+{num_add_view}',
  153. ),
  154. 'top' => array
  155. (
  156. 'type' => 'tinyint-1',
  157. 'name' => '是否精选推荐',
  158. 'default' => '2',
  159. 'desc' => '是否精选推荐',
  160. 'match' => 'is_numeric',
  161. 'update' => 'radio',
  162. 'option' => $yes,
  163. ),
  164. 'pdate' => array
  165. (
  166. 'type' => 'int-11',
  167. 'name' => '发布时间',
  168. 'match' => array('is_numeric', time()),
  169. 'default' => '',
  170. 'desc' => '',
  171. 'update' => 'date',
  172. 'callback' => 'maketime',
  173. 'insert' => true,
  174. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  175. 'auth' => '"{pdate}" > 0',
  176. ),
  177. 'reorder' => array
  178. (
  179. 'type' => 'int-11',
  180. 'name' => '排序(数值越大越靠前)',
  181. 'default' => '1',
  182. 'desc' => '请输入排序',
  183. 'match' => 'option',
  184. 'update' => 'text',
  185. 'search' => 'order',
  186. 'list' => true,
  187. 'order' => 'desc',
  188. 'edit' => true,
  189. ),
  190. 'udate' => array
  191. (
  192. 'type' => 'int-11',
  193. 'name' => '更新时间',
  194. 'match' => array('is_numeric', time()),
  195. 'desc' => '',
  196. ),
  197. 'content' => array
  198. (
  199. 'type' => 'text-255',
  200. 'name' => '内容',
  201. 'default' => '',
  202. 'desc' => '请输入内容',
  203. 'match' => 'is_string',
  204. 'update' => 'editor',
  205. 'key' => '1',
  206. //自定义编辑器右侧按钮
  207. 'editors' => array
  208. (
  209. 'name' => '选择插入模块',
  210. 'button' => array
  211. (
  212. array
  213. (
  214. 'name' => '视频',
  215. 'key' => 'content/lib/video.get',
  216. ),
  217. ),
  218. ),
  219. ),
  220. 'status' => array
  221. (
  222. 'type' => 'int-11',
  223. 'name' => '发布状态',
  224. 'default' => '1',
  225. 'desc' => '发布状态',
  226. 'match' => 'is_numeric',
  227. //'update' => 'select',
  228. 'option' => $status,
  229. 'search' => 'select',
  230. 'list' => true,
  231. 'edit' => true,
  232. ),
  233. 'spider_data_id'=> array
  234. (
  235. 'type' => 'int-11',
  236. 'name' => '采集数据id',
  237. 'default' => '0',
  238. 'desc' => '采集数据id',
  239. 'match' => 'is_numeric',
  240. ),
  241. 'state' => array
  242. (
  243. 'type' => 'tinyint-1',
  244. 'name' => '状态',
  245. 'default' => '1',
  246. 'desc' => '请选择状态',
  247. 'match' => 'is_numeric',
  248. ),
  249. 'admin_founder' => array
  250. (
  251. 'type' => 'int-11',
  252. 'name' => '创建人',
  253. 'default' => '1',
  254. 'desc' => '创建人',
  255. 'match' => 'is_numeric',
  256. ),
  257. 'admin_editor' => array
  258. (
  259. 'type' => 'int-11',
  260. 'name' => '操作人',
  261. 'default' => '1',
  262. 'desc' => '操作人',
  263. 'match' => 'is_numeric',
  264. ),
  265. 'cdate' => array
  266. (
  267. 'type' => 'int-11',
  268. 'name' => '录入时间',
  269. 'match' => array('is_numeric', time()),
  270. 'desc' => '',
  271. # 只有insert时才生效
  272. 'insert' => true,
  273. ),
  274. ),
  275. # 索引
  276. 'index' => array
  277. (
  278. 'version' => 1,
  279. 1 => array
  280. (
  281. 'i1' => 'cate_id,reorder',
  282. )
  283. ),
  284. # 管理功能
  285. 'manage' => array
  286. (
  287. 'button' => array
  288. (
  289. //'栏目管理' => array('list', 'cate&oper_parent=article'),
  290. ),
  291. //'insert' => false,
  292. # 列表
  293. 'list_button' => array
  294. (
  295. //'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  296. ),
  297. ),
  298. # request 请求接口定义
  299. 'request' => array
  300. (
  301. 'search' => array
  302. (
  303. # 匹配的正则或函数 选填项
  304. 'option' => array
  305. (
  306. 'ids' => array('yes-id', 'in'),
  307. 'cate_id' => 'yes',
  308. 'name' => array('yes', 'like'),
  309. 'id' => 'yes',
  310. 'state' => 1,
  311. ),
  312. 'type' => 'all',
  313. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  314. 'limit' => '0,1000',
  315. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  316. ),
  317. 'getAll' => array
  318. (
  319. # 匹配的正则或函数 选填项
  320. 'option' => array
  321. (
  322. 'cate_id' => 'yes',
  323. 'cate_ids' => array('yes-cate_id', 'in'),
  324. 'id' => 'yes',
  325. 'status' => 1,
  326. 'state' => 1,
  327. ),
  328. 'type' => 'all',
  329. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  330. 'page' => array($page, 'list'),
  331. 'col' => $col,
  332. ),
  333. 'findPrev' => array
  334. (
  335. # 匹配的正则或函数 选填项
  336. 'where' => array
  337. (
  338. 'cate_id' => 'yes',
  339. 'id' => array('yes', '<'),
  340. 'status' => 1,
  341. 'state' => 1,
  342. ),
  343. 'type' => 'one',
  344. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  345. 'col' => $col,
  346. ),
  347. 'findNext' => array
  348. (
  349. # 匹配的正则或函数 选填项
  350. 'where' => array
  351. (
  352. 'cate_id' => 'yes',
  353. 'id' => array('yes', '>'),
  354. 'status' => 1,
  355. 'state' => 1,
  356. ),
  357. 'order' => array('reorder' => 'asc','pdate' => 'asc'),
  358. 'type' => 'one',
  359. 'col' => $col,
  360. ),
  361. 'getDataByNum' => array
  362. (
  363. # 匹配的正则或函数 选填项
  364. 'option' => array
  365. (
  366. 'cate_id' => 'yes',
  367. 'cate_ids' => array('yes-cate_id', 'in'),
  368. 'id' => 'yes',
  369. 'status' => 1,
  370. 'state' => 1,
  371. ),
  372. 'type' => 'all',
  373. 'order' => array('num_view`+`num_add_view' => 'desc','reorder' => 'desc','pdate' => 'desc'),
  374. 'limit' => '0,10',
  375. 'col' => $col,
  376. ),
  377. 'getList' => array
  378. (
  379. # 匹配的正则或函数 选填项
  380. 'option' => array
  381. (
  382. 'cate_id' => 'yes',
  383. 'status' => 1,
  384. 'state' => 1,
  385. ),
  386. 'type' => 'all',
  387. 'order' => array('pdate' => 'desc'),
  388. 'limit' => '0,12',
  389. 'col' => $col,
  390. ),
  391. # 获取首页推荐
  392. 'getTop' => array
  393. (
  394. # 匹配的正则或函数 选填项
  395. 'option' => array
  396. (
  397. 'cate_id' => 'yes',
  398. 'status' => 1,
  399. 'state' => 1,
  400. ),
  401. 'type' => 'all',
  402. 'order' => array('top' => 'asc', 'reorder' => 'desc','pdate' => 'desc'),
  403. 'limit' => '0,4',
  404. 'col' => $col,
  405. ),
  406. 'getRelation' => array
  407. (
  408. # 匹配的正则或函数 选填项
  409. 'option' => array
  410. (
  411. 'cate_id' => 'yes',
  412. 'cate_ids' => array('yes-cate_id', 'in'),
  413. 'noid' => array('yes-id', '!='),
  414. 'status' => 1,
  415. 'state' => 1,
  416. ),
  417. 'type' => 'all',
  418. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  419. 'limit' => '0,6',
  420. 'col' => $col,
  421. ),
  422. 'getOne' => array
  423. (
  424. # 匹配的正则或函数 选填项
  425. 'where' => array
  426. (
  427. 'id' => 'yes',
  428. 'state' => 1,
  429. ),
  430. 'type' => 'one',
  431. 'col' => $col,
  432. ),
  433. # 更新浏览量
  434. 'addView' => array
  435. (
  436. 'type' => 'update',
  437. 'where' => array
  438. (
  439. 'id' => 'yes',
  440. ),
  441. 'set' => array
  442. (
  443. 'num_view' => array('1', '+='),
  444. ),
  445. ),
  446. ),
  447. );