article.php 11 KB

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