article.php 11 KB

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