article.php 9.2 KB

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