posts.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '正常',
  6. 2 => '删除',
  7. );
  8. $essence = array
  9. (
  10. 1 => '普通',
  11. 2 => '精华',
  12. 3 => '推荐',
  13. );
  14. $top = array
  15. (
  16. 1 => '普通',
  17. 2 => '置顶',
  18. );
  19. $cate = function()
  20. {
  21. $array = array();
  22. $cate = Dever::load('forum/cate-mainAll');
  23. if($cate)
  24. {
  25. $array += $cate;
  26. }
  27. return $array;
  28. };
  29. $cate_child = function()
  30. {
  31. $cate = Dever::load('forum/cate-childAll');
  32. return $cate;
  33. };
  34. # 栏目
  35. $search_cate = function()
  36. {
  37. $array = array
  38. (
  39. -1 => array('id' => '-1', 'name' => '所有栏目'),
  40. );
  41. $cate = Dever::load('forum/cate.all');
  42. if($cate)
  43. {
  44. $array += $cate;
  45. }
  46. return $array;
  47. };
  48. return array
  49. (
  50. # 表名
  51. 'name' => 'posts',
  52. # 显示给用户看的名称
  53. 'lang' => '主题',
  54. 'order' => 9,
  55. # 数据结构
  56. 'struct' => array
  57. (
  58. 'id' => array
  59. (
  60. 'type' => 'int-11',
  61. 'name' => 'ID',
  62. 'default' => '',
  63. 'desc' => '',
  64. 'match' => 'is_numeric',
  65. 'search' => 'order',
  66. 'list' => true,
  67. ),
  68. 'name' => array
  69. (
  70. 'type' => 'varchar-80',
  71. 'name' => '标题',
  72. 'default' => '',
  73. 'desc' => '请输入主题标题',
  74. 'match' => 'is_string',
  75. 'update' => 'text',
  76. 'search' => 'fulltext',
  77. 'list' => true,
  78. ),
  79. 'uid' => array
  80. (
  81. 'type' => 'int-11',
  82. 'name' => '作者-请填写用户id',
  83. 'default' => '1',
  84. 'desc' => '请填写作者',
  85. 'match' => 'is_numeric',
  86. 'update' => 'text',
  87. //'search' => 'select',
  88. 'list' => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
  89. ),
  90. 'ip' => array
  91. (
  92. 'type' => 'varchar-32',
  93. 'name' => 'IP',
  94. 'default' => '',
  95. 'desc' => '请输入IP',
  96. 'match' => 'option',
  97. //'update' => 'text',
  98. //'search' => 'fulltext',
  99. //'list' => true,
  100. ),
  101. 'cate_id_parent' => array
  102. (
  103. 'type' => 'int-11',
  104. 'name' => '父级栏目',
  105. 'default' => '0',
  106. 'desc' => '请选择父级栏目',
  107. 'match' => 'is_numeric',
  108. 'update' => 'select',
  109. //'search' => 'order,select',
  110. //'list' => '{cate_id_parent} > 0 ? Dever::load("forum/cate-one#name", {cate_id_parent}) : "临时栏目"',
  111. 'option' => $cate,
  112. # 当值改变时,执行下一步操作
  113. 'child_name' => 'cate_id',
  114. 'child' => $cate_child,
  115. 'child_value' => '{cate_id}',
  116. ),
  117. 'cate_id' => array
  118. (
  119. 'type' => 'int-11',
  120. 'name' => '子栏目',
  121. 'default' => '0',
  122. 'desc' => '请选择子栏目',
  123. 'match' => 'is_numeric',
  124. 'search' => 'group',
  125. 'option' => $search_cate,
  126. 'list_name' => '栏目',
  127. 'list' => '{cate_id} > 0 ? Dever::load("forum/cate-one#name", {cate_id}) : "无子栏目"',
  128. ),
  129. 'num_add_view' => array
  130. (
  131. 'type' => 'int-11',
  132. 'name' => '手动增加浏览量pv',
  133. 'default' => '0',
  134. 'desc' => '请填写手动增加浏览量pv',
  135. 'match' => 'option',
  136. 'update' => 'text',
  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_review}<br />"',
  147. 'list_name' => '统计数字',
  148. ),
  149. 'num_view' => array
  150. (
  151. 'type' => 'int-11',
  152. 'name' => '浏览量pv',
  153. 'default' => '0',
  154. 'desc' => '请填写浏览量pv',
  155. 'match' => 'option',
  156. 'search' => 'order',
  157. //'list' => '{num_view}+{num_add_view}',
  158. ),
  159. 'num_review' => array
  160. (
  161. 'type' => 'int-11',
  162. 'name' => '回复数',
  163. 'default' => '0',
  164. 'desc' => '请填写回复数',
  165. 'search' => 'order',
  166. 'match' => 'option',
  167. //'list' => true,
  168. ),
  169. 'essence' => array
  170. (
  171. 'type' => 'tinyint-1',
  172. 'name' => '精华',
  173. 'default' => '1',
  174. 'desc' => '请选择精华',
  175. 'match' => 'is_numeric',
  176. 'option' => $essence,
  177. 'update' => 'radio',
  178. 'list' => true,
  179. 'edit' => true,
  180. ),
  181. 'top' => array
  182. (
  183. 'type' => 'tinyint-1',
  184. 'name' => '置顶',
  185. 'default' => '1',
  186. 'desc' => '请选择置顶',
  187. 'match' => 'is_numeric',
  188. 'option' => $top,
  189. 'update' => 'radio',
  190. 'list' => true,
  191. 'edit' => true,
  192. ),
  193. 'content' => array
  194. (
  195. 'type' => 'text-255',
  196. 'name' => '内容',
  197. 'default' => '',
  198. 'desc' => '请输入内容',
  199. 'match' => 'is_string',
  200. 'update' => 'editor',
  201. 'key' => 1,
  202. ),
  203. 'state' => array
  204. (
  205. 'type' => 'tinyint-1',
  206. 'name' => '状态',
  207. 'default' => '1',
  208. 'desc' => '请选择状态',
  209. 'match' => 'is_numeric',
  210. 'option' => $option,
  211. 'update' => 'radio',
  212. 'list' => true,
  213. ),
  214. 'cdate' => array
  215. (
  216. 'type' => 'int-11',
  217. 'name' => '录入时间',
  218. 'match' => array('is_numeric', time()),
  219. 'desc' => '',
  220. # 只有insert时才生效
  221. 'insert' => true,
  222. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  223. ),
  224. ),
  225. # 索引
  226. 'index' => array
  227. (
  228. 'version' => 5,
  229. 5 => array
  230. (
  231. 'i1' => 'uid,cate_id',
  232. )
  233. ),
  234. # 管理功能
  235. 'manage' => array
  236. (
  237. //'insert' => false,
  238. # 列表
  239. 'list_button' => array
  240. (
  241. 'list' => array('回复', '"review&search_option_posts_id={id}&oper_parent=posts"'),
  242. ),
  243. ),
  244. # request 请求接口定义
  245. 'request' => array
  246. (
  247. 'getAll' => array
  248. (
  249. # 匹配的正则或函数 选填项
  250. 'option' => array
  251. (
  252. 'cate_id' => 'yes',
  253. 'cate_ids' => array('yes-cate_id', 'in'),
  254. 'id' => 'yes',
  255. ),
  256. 'type' => 'all',
  257. 'order' => array('top' => 'desc', 'id' => 'desc'),
  258. 'page' => array(15, 'list'),
  259. 'col' => '*',
  260. ),
  261. # 获取默认主题,按照置顶和时间排序的
  262. 'default' => array
  263. (
  264. # 匹配的正则或函数 选填项
  265. 'option' => array
  266. (
  267. 'cate_id' => 'yes',
  268. 'cate_id_parent' => 'yes',
  269. 'uid' => 'yes',
  270. ),
  271. 'type' => 'all',
  272. 'order' => array('top' => 'desc', 'id' => 'desc'),
  273. 'page' => array(15, 'list'),
  274. 'col' => '*',
  275. ),
  276. # 获取最新主题
  277. 'new' => array
  278. (
  279. # 匹配的正则或函数 选填项
  280. 'option' => array
  281. (
  282. 'name' => array('yes', 'like'),
  283. 'cate_id' => 'yes',
  284. 'cate_id_parent' => 'yes',
  285. 'uid' => 'yes',
  286. ),
  287. 'type' => 'all',
  288. 'order' => array('id', 'desc'),
  289. 'page' => array(15, 'list'),
  290. 'col' => '*',
  291. ),
  292. # 获取精华主题
  293. 'essence' => array
  294. (
  295. 'where' => array
  296. (
  297. 'essence' => 2,
  298. ),
  299. # 匹配的正则或函数 选填项
  300. 'option' => array
  301. (
  302. 'cate_id' => 'yes',
  303. 'cate_id_parent' => 'yes',
  304. 'uid' => 'yes',
  305. ),
  306. 'type' => 'all',
  307. 'order' => array('id', 'desc'),
  308. 'page' => array(15, 'list'),
  309. 'col' => '*',
  310. ),
  311. # 获取热门主题
  312. 'hot' => array
  313. (
  314. # 匹配的正则或函数 选填项
  315. 'option' => array
  316. (
  317. 'cate_id' => 'yes',
  318. 'cate_id_parent' => 'yes',
  319. 'uid' => 'yes',
  320. ),
  321. 'type' => 'all',
  322. 'order' => array('num_view`+`num_add_view' => 'desc', 'id' => 'desc'),
  323. 'page' => array(15, 'list'),
  324. 'col' => '*',
  325. ),
  326. # 获取冷门主题
  327. 'cold' => array
  328. (
  329. # 匹配的正则或函数 选填项
  330. 'option' => array
  331. (
  332. 'cate_id' => 'yes',
  333. 'cate_id_parent' => 'yes',
  334. 'uid' => 'yes',
  335. ),
  336. 'type' => 'all',
  337. 'order' => array('num_view`+`num_add_view' => 'asc', 'id' => 'desc'),
  338. 'page' => array(15, 'list'),
  339. 'col' => '*',
  340. ),
  341. # 更新浏览量
  342. 'addView' => array
  343. (
  344. 'type' => 'update',
  345. 'where' => array
  346. (
  347. 'id' => 'yes',
  348. ),
  349. 'set' => array
  350. (
  351. 'num_view' => array('1', '+='),
  352. ),
  353. ),
  354. # 更新回复数
  355. 'addReview' => array
  356. (
  357. 'type' => 'update',
  358. 'where' => array
  359. (
  360. 'id' => 'yes',
  361. ),
  362. 'set' => array
  363. (
  364. 'num_review' => array('1', '+='),
  365. ),
  366. ),
  367. # 更新点赞数
  368. 'addUp' => array
  369. (
  370. 'type' => 'update',
  371. 'where' => array
  372. (
  373. 'id' => 'yes',
  374. ),
  375. 'set' => array
  376. (
  377. 'num_up' => array('1', '+='),
  378. ),
  379. ),
  380. # 更新点赞数
  381. 'desUp' => array
  382. (
  383. 'type' => 'update',
  384. 'where' => array
  385. (
  386. 'id' => 'yes',
  387. ),
  388. 'set' => array
  389. (
  390. 'num_up' => array('1', '-='),
  391. ),
  392. ),
  393. ),
  394. );