article.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <?php
  2. $code = array
  3. (
  4. 1 => '用户ID',
  5. 2 => '随机数字',
  6. 3 => '随机数字+字母',
  7. );
  8. # 每页的数据量
  9. $page = 15;
  10. $cate = function()
  11. {
  12. $array = array();
  13. $info = Dever::db('content/cate')->state();
  14. if($info)
  15. {
  16. $array += $info;
  17. }
  18. return $array;
  19. };
  20. $author = function()
  21. {
  22. $array = array();
  23. $info = Dever::db('content/author')->state();
  24. if($info)
  25. {
  26. $array += $info;
  27. }
  28. return $array;
  29. };
  30. $share = function()
  31. {
  32. $array = array();
  33. $info = Dever::db('poster/template')->state();
  34. if($info)
  35. {
  36. $array += $info;
  37. }
  38. return $array;
  39. };
  40. return array
  41. (
  42. # 表名
  43. 'name' => 'article',
  44. # 显示给用户看的名称
  45. 'lang' => '图文管理',
  46. 'order' => 100,
  47. 'end' => array
  48. (
  49. 'insert' => 'tag/lib/core.data?source_table=content/article',
  50. 'update' => 'tag/lib/core.data?source_table=content/article',
  51. ),
  52. # 数据结构
  53. 'struct' => array
  54. (
  55. 'id' => array
  56. (
  57. 'type' => 'int-11',
  58. 'name' => 'ID',
  59. 'default' => '',
  60. 'desc' => '',
  61. 'match' => 'is_numeric',
  62. ),
  63. 'name' => array
  64. (
  65. 'type' => 'varchar-80',
  66. 'name' => '标题',
  67. 'default' => '',
  68. 'desc' => '标题',
  69. 'match' => 'is_string',
  70. 'update' => 'text',
  71. 'list' => true,
  72. //增加预览
  73. 'preview' => true,
  74. ),
  75. 'cate_id' => array
  76. (
  77. 'type' => 'int-11',
  78. 'name' => '所属栏目',
  79. 'default' => '1',
  80. 'desc' => '所属栏目',
  81. 'match' => 'is_numeric',
  82. 'update' => 'select',
  83. 'option' => $cate,
  84. 'search' => 'select',
  85. ),
  86. 'author_id' => array
  87. (
  88. 'type' => 'int-11',
  89. 'name' => '作者',
  90. 'default' => '1',
  91. 'desc' => '作者',
  92. 'match' => 'is_numeric',
  93. 'update' => 'select',
  94. 'option' => $author,
  95. 'search' => 'select',
  96. ),
  97. 'tag' => array
  98. (
  99. 'type' => 'text-255',
  100. 'name' => '标签',
  101. 'default' => '',
  102. 'desc' => '标签',
  103. 'match' => 'is_numeric',
  104. 'update' => 'selects',
  105. //'search' => 'fulltext',
  106. 'update_search' => 'tag/lib/core.search',
  107. ),
  108. 'pic_cover' => array
  109. (
  110. 'type' => 'varchar-150',
  111. 'name' => '封面图-4:3比例的图片',
  112. 'default' => '',
  113. 'desc' => '封面图',
  114. 'match' => 'option',
  115. 'update' => 'image',
  116. 'key' => '1',
  117. 'place' => '150',
  118. ),
  119. 'num_add_view' => array
  120. (
  121. 'type' => 'int-11',
  122. 'name' => '浏览量基数',
  123. 'default' => '0',
  124. 'desc' => '浏览量基数',
  125. 'match' => 'option',
  126. 'update' => 'text',
  127. ),
  128. 'num_view' => array
  129. (
  130. 'type' => 'int-11',
  131. 'name' => '浏览量pv',
  132. 'default' => '0',
  133. 'desc' => '请填写浏览量pv',
  134. 'match' => 'option',
  135. 'search' => 'order',
  136. //'list' => '{num_view}+{num_add_view}',
  137. ),
  138. 'num_up' => array
  139. (
  140. 'type' => 'int-11',
  141. 'name' => '喜欢数',
  142. 'default' => '0',
  143. 'desc' => '请填写喜欢数',
  144. 'match' => 'option',
  145. //'search' => 'order',
  146. 'list' => '"喜欢数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />评论数:{num_comment}<br />"',
  147. 'list_name' => '统计数字',
  148. ),
  149. 'num_comment' => array
  150. (
  151. 'type' => 'int-11',
  152. 'name' => '评论数',
  153. 'default' => '0',
  154. 'desc' => '请填写评论数',
  155. 'search' => 'order',
  156. 'match' => 'option',
  157. //'list' => true,
  158. ),
  159. 'state' => array
  160. (
  161. 'type' => 'tinyint-1',
  162. 'name' => '状态',
  163. 'default' => '1',
  164. 'desc' => '请选择状态',
  165. 'match' => 'is_numeric',
  166. ),
  167. 'admin_founder' => array
  168. (
  169. 'type' => 'int-11',
  170. 'name' => '创建人',
  171. 'default' => '1',
  172. 'desc' => '创建人',
  173. 'match' => 'is_numeric',
  174. ),
  175. 'admin_editor' => array
  176. (
  177. 'type' => 'int-11',
  178. 'name' => '操作人',
  179. 'default' => '1',
  180. 'desc' => '操作人',
  181. 'match' => 'is_numeric',
  182. ),
  183. 'pdate' => array
  184. (
  185. 'type' => 'int-11',
  186. 'name' => '发布时间',
  187. 'match' => 'is_numeric',
  188. 'desc' => '',
  189. 'update' => 'date',
  190. 'callback' => 'maketime',
  191. 'list' => 'date("Y-m-d H:i:s", {pdate})',
  192. ),
  193. 'share' => array
  194. (
  195. 'type' => 'text-255',
  196. 'name' => '分享海报-选择海报库中的海报',
  197. 'default' => '',
  198. 'desc' => '分享海报',
  199. 'match' => 'option',
  200. 'update' => 'checkbox',
  201. 'option' => $share,
  202. ),
  203. 'udate' => array
  204. (
  205. 'type' => 'int-11',
  206. 'name' => '更新时间',
  207. 'match' => array('is_numeric', time()),
  208. 'desc' => '',
  209. ),
  210. 'content' => array
  211. (
  212. 'type' => 'text-255',
  213. 'name' => '内容',
  214. 'default' => '',
  215. 'desc' => '请输入内容',
  216. 'match' => 'is_string',
  217. 'update' => 'editor',
  218. //自定义编辑器右侧按钮
  219. 'editor' => array
  220. (
  221. 'name' => '选择插入模块',
  222. 'button' => array
  223. (
  224. array
  225. (
  226. # 名称
  227. 'name' => '图片',
  228. # 资源库id
  229. 'key' => 1,
  230. # 类型
  231. 'type' => 'image',
  232. ),
  233. array
  234. (
  235. 'name' => '音频',
  236. 'key' => 2,
  237. 'type' => 'media',
  238. ),
  239. array
  240. (
  241. 'name' => '视频',
  242. 'key' => 'video/lib/core.vod',
  243. ),
  244. array
  245. (
  246. 'name' => '直播',
  247. 'key' => 'video/lib/core.live',
  248. ),
  249. ),
  250. ),
  251. ),
  252. 'cdate' => array
  253. (
  254. 'type' => 'int-11',
  255. 'name' => '录入时间',
  256. 'match' => array('is_numeric', time()),
  257. 'desc' => '',
  258. # 只有insert时才生效
  259. 'insert' => true,
  260. ),
  261. ),
  262. # 索引
  263. 'index' => array
  264. (
  265. 'version' => 1,
  266. 1 => array
  267. (
  268. 'i1' => 'uid,cate_id',
  269. )
  270. ),
  271. # 管理功能
  272. 'manage' => array
  273. (
  274. //'insert' => false,
  275. # 列表
  276. /*
  277. 'list_button' => array
  278. (
  279. 'list' => array('评论列表', '"comment&search_option_data_id={id}&oper_parent=article"'),
  280. ),
  281. */
  282. ),
  283. # request 请求接口定义
  284. 'request' => array
  285. (
  286. 'getAll' => array
  287. (
  288. # 匹配的正则或函数 选填项
  289. 'option' => array
  290. (
  291. 'cate_id' => 'yes',
  292. 'cate_ids' => array('yes-cate_id', 'in'),
  293. 'id' => 'yes',
  294. ),
  295. 'type' => 'all',
  296. 'order' => array('id' => 'desc'),
  297. 'page' => array($page, 'list'),
  298. 'col' => '*',
  299. ),
  300. # 获取默认主题,按照置顶和时间排序的
  301. 'default' => array
  302. (
  303. # 匹配的正则或函数 选填项
  304. 'option' => array
  305. (
  306. 'cate_id' => 'yes',
  307. 'uid' => 'yes',
  308. ),
  309. 'type' => 'all',
  310. 'order' => array('id' => 'desc'),
  311. 'page' => array($page, 'list'),
  312. 'col' => '*',
  313. ),
  314. # 获取最新主题
  315. 'new' => array
  316. (
  317. # 匹配的正则或函数 选填项
  318. 'option' => array
  319. (
  320. 'name' => array('yes', 'like'),
  321. 'cate_id' => 'yes',
  322. 'uid' => 'yes',
  323. ),
  324. 'type' => 'all',
  325. 'order' => array('id', 'desc'),
  326. 'page' => array($page, 'list'),
  327. 'col' => '*',
  328. ),
  329. # 获取热门主题
  330. 'hot' => array
  331. (
  332. # 匹配的正则或函数 选填项
  333. 'option' => array
  334. (
  335. 'cate_id' => 'yes',
  336. 'uid' => 'yes',
  337. ),
  338. 'type' => 'all',
  339. 'order' => array('num_view`+`num_add_view' => 'desc', 'id' => 'desc'),
  340. 'page' => array($page, 'list'),
  341. 'col' => '*',
  342. ),
  343. # 获取冷门主题
  344. 'cold' => array
  345. (
  346. # 匹配的正则或函数 选填项
  347. 'option' => array
  348. (
  349. 'cate_id' => 'yes',
  350. 'uid' => 'yes',
  351. ),
  352. 'type' => 'all',
  353. 'order' => array('num_view`+`num_add_view' => 'asc', 'id' => 'desc'),
  354. 'page' => array($page, 'list'),
  355. 'col' => '*',
  356. ),
  357. # 更新浏览量
  358. 'addView' => array
  359. (
  360. 'type' => 'update',
  361. 'where' => array
  362. (
  363. 'id' => 'yes',
  364. ),
  365. 'set' => array
  366. (
  367. 'num_view' => array('1', '+='),
  368. ),
  369. ),
  370. # 更新回复数
  371. 'addComment' => array
  372. (
  373. 'type' => 'update',
  374. 'where' => array
  375. (
  376. 'id' => 'yes',
  377. ),
  378. 'set' => array
  379. (
  380. 'num_comment' => array('1', '+='),
  381. ),
  382. ),
  383. # 更新点赞数
  384. 'addUp' => array
  385. (
  386. 'type' => 'update',
  387. 'where' => array
  388. (
  389. 'id' => 'yes',
  390. ),
  391. 'set' => array
  392. (
  393. 'num_up' => array('1', '+='),
  394. ),
  395. ),
  396. # 更新点赞数
  397. 'desUp' => array
  398. (
  399. 'type' => 'update',
  400. 'where' => array
  401. (
  402. 'id' => 'yes',
  403. ),
  404. 'set' => array
  405. (
  406. 'num_up' => array('1', '-='),
  407. ),
  408. ),
  409. ),
  410. );