article.php 11 KB

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