article.php 12 KB

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