article.php 11 KB

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