article.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. //'upload' => 'qiniu',
  134. //上传大数据
  135. //'large' => true,
  136. ),
  137. 'num_add_view' => array
  138. (
  139. 'type' => 'int-11',
  140. 'name' => '浏览量基数',
  141. 'default' => '0',
  142. 'desc' => '浏览量基数',
  143. 'match' => 'option',
  144. 'update' => 'text',
  145. ),
  146. 'num_view' => array
  147. (
  148. 'type' => 'int-11',
  149. 'name' => '浏览量pv',
  150. 'default' => '0',
  151. 'desc' => '请填写浏览量pv',
  152. 'match' => 'option',
  153. 'search' => 'order',
  154. //'list' => '{num_view}+{num_add_view}',
  155. ),
  156. 'num_add_up' => array
  157. (
  158. 'type' => 'int-11',
  159. 'name' => '喜欢基数',
  160. 'default' => '0',
  161. 'desc' => '喜欢基数',
  162. 'match' => 'option',
  163. 'update' => 'text',
  164. ),
  165. 'num_up' => array
  166. (
  167. 'type' => 'int-11',
  168. 'name' => '喜欢数',
  169. 'default' => '0',
  170. 'desc' => '请填写喜欢数',
  171. 'match' => 'option',
  172. //'search' => 'order',
  173. 'list' => '"喜欢数:{num_up}+{num_add_up}<br />浏览量:{num_view}+{num_add_view}<br />评论数:{num_comment}<br />"',
  174. 'list_name' => '统计数字',
  175. ),
  176. 'num_comment' => array
  177. (
  178. 'type' => 'int-11',
  179. 'name' => '评论数',
  180. 'default' => '0',
  181. 'desc' => '请填写评论数',
  182. 'search' => 'order',
  183. 'match' => 'option',
  184. //'list' => true,
  185. ),
  186. 'state' => array
  187. (
  188. 'type' => 'tinyint-1',
  189. 'name' => '状态',
  190. 'default' => '1',
  191. 'desc' => '请选择状态',
  192. 'match' => 'is_numeric',
  193. ),
  194. 'admin_founder' => array
  195. (
  196. 'type' => 'int-11',
  197. 'name' => '创建人',
  198. 'default' => '1',
  199. 'desc' => '创建人',
  200. 'match' => 'is_numeric',
  201. ),
  202. 'admin_editor' => array
  203. (
  204. 'type' => 'int-11',
  205. 'name' => '操作人',
  206. 'default' => '1',
  207. 'desc' => '操作人',
  208. 'match' => 'is_numeric',
  209. ),
  210. 'pdate' => array
  211. (
  212. 'type' => 'int-11',
  213. 'name' => '发布时间',
  214. 'match' => array('is_numeric', time()),
  215. 'default' => '',
  216. 'desc' => '',
  217. 'update' => 'date',
  218. 'callback' => 'maketime',
  219. 'insert' => true,
  220. 'list' => 'date("Y-m-d H:i:s", {pdate})',
  221. 'auth' => '"{pdate}" > 0',
  222. ),
  223. 'share' => array
  224. (
  225. 'type' => 'text-255',
  226. 'name' => '分享海报-选择海报库中的海报',
  227. 'default' => '',
  228. 'desc' => '分享海报',
  229. 'match' => 'option',
  230. //'update' => 'checkbox',
  231. 'option' => $share,
  232. ),
  233. 'reorder' => array
  234. (
  235. 'type' => 'int-11',
  236. 'name' => '排序(数值越大越靠前)',
  237. 'default' => '1',
  238. 'desc' => '请输入排序',
  239. 'match' => 'option',
  240. 'update' => 'text',
  241. 'search' => 'order',
  242. 'list' => true,
  243. 'order' => 'desc',
  244. 'edit' => true,
  245. ),
  246. 'udate' => array
  247. (
  248. 'type' => 'int-11',
  249. 'name' => '更新时间',
  250. 'match' => array('is_numeric', time()),
  251. 'desc' => '',
  252. ),
  253. 'function' => array
  254. (
  255. 'type' => 'varchar-100',
  256. 'name' => '功能选择',
  257. 'default' => '1',
  258. 'desc' => '功能选择',
  259. 'match' => 'option',
  260. 'update' => 'checkbox',
  261. 'option' => $function,
  262. ),
  263. 'share_yes' => array
  264. (
  265. 'type' => 'int-11',
  266. 'name' => '是否显示分享按钮',
  267. 'default' => '1',
  268. 'desc' => '是否显示分享按钮',
  269. 'match' => 'option',
  270. 'update' => 'radio',
  271. 'option' => $share,
  272. 'control' => 'share_yes',
  273. ),
  274. 'share_title' => array
  275. (
  276. 'type' => 'varchar-100',
  277. 'name' => '分享标题',
  278. 'default' => '',
  279. 'desc' => '分享标题',
  280. 'match' => 'option',
  281. 'update' => 'text',
  282. 'show' => 'share_yes=1',
  283. ),
  284. 'share_pic' => array
  285. (
  286. 'type' => 'varchar-150',
  287. 'name' => '分享图片',
  288. 'default' => '',
  289. 'desc' => '分享图片',
  290. 'match' => 'option',
  291. 'update' => 'image',
  292. 'key' => '1',
  293. 'place' => '150',
  294. 'show' => 'share_yes=1',
  295. 'upload' => 'qiniu',
  296. 'large' => true,
  297. ),
  298. 'share_content' => array
  299. (
  300. 'type' => 'varchar-200',
  301. 'name' => '分享内容',
  302. 'default' => '',
  303. 'desc' => '分享内容',
  304. 'match' => 'option',
  305. 'update' => 'textarea',
  306. 'show' => 'share_yes=1',
  307. ),
  308. 'content' => array
  309. (
  310. 'type' => 'text-255',
  311. 'name' => '内容',
  312. 'default' => '',
  313. 'desc' => '请输入内容',
  314. 'match' => 'is_string',
  315. 'update' => 'editor',
  316. //自定义编辑器右侧按钮
  317. 'editor' => array
  318. (
  319. 'name' => '选择插入模块',
  320. 'button' => array
  321. (
  322. array
  323. (
  324. # 名称
  325. 'name' => '图片',
  326. # 资源库id
  327. 'key' => 1,
  328. # 类型
  329. 'type' => 'image',
  330. ),
  331. array
  332. (
  333. 'name' => '音频',
  334. 'key' => 2,
  335. 'type' => 'media',
  336. ),
  337. array
  338. (
  339. 'name' => '视频',
  340. 'key' => 'video/lib/core.vod',
  341. ),
  342. array
  343. (
  344. 'name' => '直播',
  345. 'key' => 'video/lib/core.live',
  346. ),
  347. ),
  348. ),
  349. ),
  350. 'audit' => array
  351. (
  352. 'type' => 'int-11',
  353. 'name' => '审核状态',
  354. 'default' => '1',
  355. 'desc' => '审核',
  356. 'match' => 'is_numeric',
  357. //'update' => 'select',
  358. 'option' => $audit,
  359. 'search' => 'select',
  360. 'list' => true,
  361. 'edit' => true,
  362. ),
  363. 'status' => array
  364. (
  365. 'type' => 'int-11',
  366. 'name' => '发布状态',
  367. 'default' => '1',
  368. 'desc' => '发布状态',
  369. 'match' => 'is_numeric',
  370. //'update' => 'select',
  371. 'option' => $status,
  372. 'search' => 'select',
  373. 'list' => true,
  374. 'edit' => true,
  375. ),
  376. 'cdate' => array
  377. (
  378. 'type' => 'int-11',
  379. 'name' => '录入时间',
  380. 'match' => array('is_numeric', time()),
  381. 'desc' => '',
  382. # 只有insert时才生效
  383. 'insert' => true,
  384. ),
  385. ),
  386. # 索引
  387. 'index' => array
  388. (
  389. 'version' => 1,
  390. 1 => array
  391. (
  392. 'i1' => 'uid,cate_id',
  393. )
  394. ),
  395. # 管理功能
  396. 'manage' => array
  397. (
  398. //'insert' => false,
  399. # 列表
  400. 'list_button' => array
  401. (
  402. 'edit' => array('预览', Dever::url('main/preview.get?type=1')),
  403. ),
  404. ),
  405. # request 请求接口定义
  406. 'request' => array
  407. (
  408. 'search' => array
  409. (
  410. # 匹配的正则或函数 选填项
  411. 'option' => array
  412. (
  413. 'ids' => array('yes-id', 'in'),
  414. 'cate_id' => 'yes',
  415. 'name' => array('yes', 'like'),
  416. 'id' => 'yes',
  417. 'state' => 1,
  418. ),
  419. 'type' => 'all',
  420. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  421. 'limit' => '0,1000',
  422. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled',
  423. ),
  424. 'getAll' => array
  425. (
  426. # 匹配的正则或函数 选填项
  427. 'option' => array
  428. (
  429. 'cate_id' => 'yes',
  430. 'cate_ids' => array('yes-cate_id', 'in'),
  431. 'id' => 'yes',
  432. 'state' => 1,
  433. ),
  434. 'type' => 'all',
  435. 'order' => array('reorder' => 'desc','id' => 'desc'),
  436. 'page' => array($page, 'list'),
  437. 'col' => 'id,name,pic_cover,pdate,num_add_view,num_view,num_up,num_add_up,num_comment,share_yes,share_title,share_pic,share_content,function,content',
  438. ),
  439. 'getRelation' => array
  440. (
  441. # 匹配的正则或函数 选填项
  442. 'option' => array
  443. (
  444. 'cate_id' => 'yes',
  445. 'cate_ids' => array('yes-cate_id', 'in'),
  446. 'noid' => array('yes', '!='),
  447. 'state' => 1,
  448. ),
  449. 'type' => 'all',
  450. 'order' => array('reorder' => 'desc','id' => 'desc'),
  451. 'limit' => '0,4',
  452. 'col' => 'id,name,pic_cover,pdate,num_add_view,num_view,num_up,num_add_up,num_comment,share_yes,share_title,share_pic,share_content,function,content',
  453. ),
  454. 'getOne' => array
  455. (
  456. # 匹配的正则或函数 选填项
  457. 'where' => array
  458. (
  459. 'id' => 'yes',
  460. ),
  461. 'type' => 'one',
  462. 'col' => 'id,name,pic_cover,pdate,num_add_view,num_view,num_up,num_add_up,num_comment,share_yes,share_title,share_pic,share_content,function,content',
  463. ),
  464. # 更新浏览量
  465. 'addView' => array
  466. (
  467. 'type' => 'update',
  468. 'where' => array
  469. (
  470. 'id' => 'yes',
  471. ),
  472. 'set' => array
  473. (
  474. 'num_view' => array('1', '+='),
  475. ),
  476. ),
  477. # 更新回复数
  478. 'addComment' => array
  479. (
  480. 'type' => 'update',
  481. 'where' => array
  482. (
  483. 'id' => 'yes',
  484. ),
  485. 'set' => array
  486. (
  487. 'num_comment' => array('1', '+='),
  488. ),
  489. ),
  490. # 更新点赞数
  491. 'addUp' => array
  492. (
  493. 'type' => 'update',
  494. 'where' => array
  495. (
  496. 'id' => 'yes',
  497. ),
  498. 'set' => array
  499. (
  500. 'num_up' => array('1', '+='),
  501. ),
  502. ),
  503. # 更新点赞数
  504. 'desUp' => array
  505. (
  506. 'type' => 'update',
  507. 'where' => array
  508. (
  509. 'id' => 'yes',
  510. ),
  511. 'set' => array
  512. (
  513. 'num_up' => array('1', '-='),
  514. ),
  515. ),
  516. ),
  517. );