article.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <?php
  2. $audit = Dever::config('base')->audit;
  3. $status = Dever::config('base')->status;
  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 = array
  27. (
  28. 1 => '显示',
  29. 2 => '不显示',
  30. );
  31. $template = array
  32. (
  33. 1 => '图文',
  34. 2 => '视频',
  35. );
  36. # 常用的col
  37. $col = 'id,cate_id,name,pic_cover,pic_index,num_add_view+num_view as num_view,content,author_id,template,`desc`,video';
  38. return array
  39. (
  40. # 表名
  41. 'name' => 'article',
  42. # 显示给用户看的名称
  43. 'lang' => '文章管理',
  44. 'order' => 100,
  45. # 数据结构
  46. 'struct' => array
  47. (
  48. 'id' => array
  49. (
  50. 'type' => 'int-11',
  51. 'name' => 'ID',
  52. 'default' => '',
  53. 'desc' => '',
  54. 'match' => 'is_numeric',
  55. 'list' => true,
  56. ),
  57. 'name' => array
  58. (
  59. 'type' => 'varchar-80',
  60. 'name' => '标题-文章标题,同时也用于分享标题',
  61. 'default' => '',
  62. 'desc' => '标题',
  63. 'match' => 'is_string',
  64. 'update' => 'text',
  65. 'list' => true,
  66. 'search' => 'fulltext',
  67. //增加预览
  68. 'preview' => true,
  69. ),
  70. 'desc' => array
  71. (
  72. 'type' => 'varchar-500',
  73. 'name' => '摘要-文章摘要,同时也用于分享内容',
  74. 'default' => '',
  75. 'desc' => '摘要',
  76. 'match' => 'is_string',
  77. 'update' => 'textarea',
  78. ),
  79. 'cate_id' => array
  80. (
  81. 'type' => 'int-11',
  82. 'name' => '所属栏目',
  83. 'default' => '1',
  84. 'desc' => '所属栏目',
  85. 'match' => 'is_numeric',
  86. 'update' => 'select',
  87. 'option' => $cate,
  88. 'search' => 'select',
  89. 'list' => 'Dever::load("content/cate-one#name", {cate_id})',
  90. ),
  91. 'author_id' => array
  92. (
  93. 'type' => 'int-11',
  94. 'name' => '编辑',
  95. 'default' => '1',
  96. 'desc' => '编辑',
  97. 'match' => 'is_numeric',
  98. 'update' => 'select',
  99. //'option' => $author,
  100. 'search' => 'select',
  101. 'update_search' => 'content/lib/author.search',
  102. ),
  103. 'pic_cover' => array
  104. (
  105. 'type' => 'varchar-150',
  106. 'name' => '1:1封面图-图片尺寸380*380px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,同时用于分享图片',
  107. 'default' => '',
  108. 'desc' => '封面图',
  109. 'match' => 'is_string',
  110. 'update' => 'image',
  111. 'key' => '1',
  112. 'place' => '150',
  113. //直接上传到云端
  114. //'upload' => 'qiniu',
  115. //上传大数据
  116. //'large' => true,
  117. ),
  118. 'pic_index' => array
  119. (
  120. 'type' => 'varchar-150',
  121. 'name' => '16:9封面图-一般用于首页,图片尺寸380*214px或等比尺寸,秀场图片尺寸360*540px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,同时用于分享图片',
  122. 'default' => '',
  123. 'desc' => '封面图',
  124. 'match' => 'is_string',
  125. 'update' => 'image',
  126. 'key' => '1',
  127. 'place' => '150',
  128. //直接上传到云端
  129. //'upload' => 'qiniu',
  130. //上传大数据
  131. //'large' => true,
  132. ),
  133. 'template' => array
  134. (
  135. 'type' => 'int-11',
  136. 'name' => '文章模板',
  137. 'default' => '1',
  138. 'desc' => '文章模板',
  139. 'match' => 'is_numeric',
  140. 'update' => 'radio',
  141. 'option' => $template,
  142. 'search' => 'select',
  143. 'control' => 'template',
  144. ),
  145. 'video' => array
  146. (
  147. 'type' => 'varchar-800',
  148. 'name' => '上传视频-上传视频格式mp4,mov,上传大小不能超过4G,也可以直接填入腾讯视频的地址(如:https://v.qq.com/x/page/p0873p0efbx.html)或者mp4地址',
  149. 'default' => '',
  150. 'desc' => '上传视频',
  151. 'match' => 'is_string',
  152. 'update' => 'upload',
  153. 'key' => '5',
  154. 'place' => '150',
  155. 'upload' => 'qiniu',
  156. 'large' => true,
  157. //不覆盖原文件,生成新文件
  158. 'cover' => 2,
  159. 'show' => 'template=2',
  160. ),
  161. 'video_info' => array
  162. (
  163. 'type' => 'text-255',
  164. 'name' => '视频信息',
  165. 'default' => '',
  166. 'desc' => '视频信息',
  167. 'match' => 'is_string',
  168. 'show' => 'template=2',
  169. ),
  170. 'num_add_view' => array
  171. (
  172. 'type' => 'int-11',
  173. 'name' => '浏览量基数',
  174. 'default' => '0',
  175. 'desc' => '浏览量基数',
  176. 'match' => 'option',
  177. //'update' => 'text',
  178. ),
  179. 'num_view' => array
  180. (
  181. 'type' => 'int-11',
  182. 'name' => '浏览量',
  183. 'default' => '0',
  184. 'desc' => '请填写浏览量',
  185. 'match' => 'option',
  186. 'search' => 'order',
  187. 'list' => '{num_view}+{num_add_view}',
  188. ),
  189. 'pdate' => array
  190. (
  191. 'type' => 'int-11',
  192. 'name' => '发布时间',
  193. 'match' => array('is_numeric', time()),
  194. 'default' => '',
  195. 'desc' => '',
  196. 'update' => 'date',
  197. 'callback' => 'maketime',
  198. 'insert' => true,
  199. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  200. 'auth' => '"{pdate}" > 0',
  201. ),
  202. 'reorder' => array
  203. (
  204. 'type' => 'int-11',
  205. 'name' => '排序(数值越大越靠前)',
  206. 'default' => '1',
  207. 'desc' => '请输入排序',
  208. 'match' => 'option',
  209. 'update' => 'text',
  210. 'search' => 'order',
  211. 'list' => true,
  212. 'order' => 'desc',
  213. 'edit' => true,
  214. ),
  215. 'udate' => array
  216. (
  217. 'type' => 'int-11',
  218. 'name' => '更新时间',
  219. 'match' => array('is_numeric', time()),
  220. 'desc' => '',
  221. ),
  222. 'content' => array
  223. (
  224. 'type' => 'text-255',
  225. 'name' => '内容',
  226. 'default' => '',
  227. 'desc' => '请输入内容',
  228. 'match' => 'is_string',
  229. 'update' => 'editor',
  230. 'key' => '1',
  231. //'media' => '5',//下面的音视频已经做到了
  232. //直接上传到云端
  233. //'upload' => 'qiniu',
  234. //上传大数据
  235. //'large' => true,
  236. //自定义编辑器右侧按钮
  237. /*
  238. 'editor' => array
  239. (
  240. 'name' => '选择插入模块',
  241. 'button' => array
  242. (
  243. array
  244. (
  245. # 名称
  246. 'name' => '图片',
  247. # 资源库id
  248. 'key' => 1,
  249. # 类型
  250. 'type' => 'image',
  251. ),
  252. array
  253. (
  254. 'name' => '音频',
  255. 'key' => 5,
  256. 'type' => 'media',
  257. ),
  258. array
  259. (
  260. 'name' => '视频',
  261. 'key' => 'video/lib/core.vod',
  262. ),
  263. array
  264. (
  265. 'name' => '直播',
  266. 'key' => 'video/lib/core.live',
  267. ),
  268. array
  269. (
  270. 'name' => '小程序',
  271. 'key' => 'content/lib/applet.update',
  272. 'type' => 'update',
  273. ),
  274. ),
  275. ),
  276. */
  277. ),
  278. 'status' => array
  279. (
  280. 'type' => 'int-11',
  281. 'name' => '发布状态',
  282. 'default' => '2',
  283. 'desc' => '发布状态',
  284. 'match' => 'is_numeric',
  285. //'update' => 'select',
  286. 'option' => $status,
  287. 'search' => 'select',
  288. 'list' => true,
  289. 'edit' => true,
  290. ),
  291. 'state' => array
  292. (
  293. 'type' => 'tinyint-1',
  294. 'name' => '状态',
  295. 'default' => '1',
  296. 'desc' => '请选择状态',
  297. 'match' => 'is_numeric',
  298. ),
  299. 'admin_founder' => array
  300. (
  301. 'type' => 'int-11',
  302. 'name' => '创建人',
  303. 'default' => '1',
  304. 'desc' => '创建人',
  305. 'match' => 'is_numeric',
  306. ),
  307. 'admin_editor' => array
  308. (
  309. 'type' => 'int-11',
  310. 'name' => '操作人',
  311. 'default' => '1',
  312. 'desc' => '操作人',
  313. 'match' => 'is_numeric',
  314. ),
  315. 'cdate' => array
  316. (
  317. 'type' => 'int-11',
  318. 'name' => '录入时间',
  319. 'match' => array('is_numeric', time()),
  320. 'desc' => '',
  321. # 只有insert时才生效
  322. 'insert' => true,
  323. ),
  324. ),
  325. # 索引
  326. 'index' => array
  327. (
  328. 'version' => 1,
  329. 1 => array
  330. (
  331. 'i1' => 'cate_id,reorder',
  332. )
  333. ),
  334. # 管理功能
  335. 'manage' => array
  336. (
  337. //'insert' => false,
  338. # 列表
  339. 'list_button' => array
  340. (
  341. 'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  342. ),
  343. ),
  344. # request 请求接口定义
  345. 'request' => array
  346. (
  347. 'search' => array
  348. (
  349. # 匹配的正则或函数 选填项
  350. 'option' => array
  351. (
  352. 'ids' => array('yes-id', 'in'),
  353. 'cate_id' => 'yes',
  354. 'name' => array('yes', 'like'),
  355. 'id' => 'yes',
  356. 'state' => 1,
  357. ),
  358. 'type' => 'all',
  359. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  360. 'limit' => '0,1000',
  361. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  362. ),
  363. 'getAll' => array
  364. (
  365. # 匹配的正则或函数 选填项
  366. 'option' => array
  367. (
  368. 'cate_id' => 'yes',
  369. 'cate_ids' => array('yes-cate_id', 'in'),
  370. 'id' => 'yes',
  371. 'status' => 2,
  372. 'state' => 1,
  373. ),
  374. 'type' => 'all',
  375. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  376. 'page' => array($page, 'list'),
  377. 'col' => $col,
  378. ),
  379. 'getList' => array
  380. (
  381. # 匹配的正则或函数 选填项
  382. 'option' => array
  383. (
  384. 'cate_id' => 'yes',
  385. 'status' => 2,
  386. 'state' => 1,
  387. ),
  388. 'type' => 'all',
  389. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  390. 'limit' => '0,10',
  391. 'col' => $col,
  392. ),
  393. 'getRelation' => array
  394. (
  395. # 匹配的正则或函数 选填项
  396. 'option' => array
  397. (
  398. 'cate_id' => 'yes',
  399. 'cate_ids' => array('yes-cate_id', 'in'),
  400. 'noid' => array('yes-id', '!='),
  401. 'status' => 2,
  402. 'state' => 1,
  403. ),
  404. 'type' => 'all',
  405. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  406. 'limit' => '0,4',
  407. 'col' => $col,
  408. ),
  409. 'getOne' => array
  410. (
  411. # 匹配的正则或函数 选填项
  412. 'where' => array
  413. (
  414. 'id' => 'yes',
  415. ),
  416. 'type' => 'one',
  417. 'col' => $col,
  418. ),
  419. # 更新浏览量
  420. 'addView' => array
  421. (
  422. 'type' => 'update',
  423. 'where' => array
  424. (
  425. 'id' => 'yes',
  426. ),
  427. 'set' => array
  428. (
  429. 'num_view' => array('1', '+='),
  430. ),
  431. ),
  432. ),
  433. );