article.php 9.2 KB

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