article.php 7.4 KB

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