article.php 11 KB

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