article.php 11 KB

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