news.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. $author = function()
  3. {
  4. $array = array();
  5. $author = Dever::load('set/author-state');
  6. if($author)
  7. {
  8. $array += $author;
  9. }
  10. return $array;
  11. };
  12. $info = function()
  13. {
  14. $array = array();
  15. $info = Dever::load('set/info-state');
  16. if($info)
  17. {
  18. $array += $info;
  19. }
  20. return $array;
  21. };
  22. $cate = function()
  23. {
  24. $array = array();
  25. $cate = Dever::load('set/cate-mainAll');
  26. if($cate)
  27. {
  28. $array += $cate;
  29. }
  30. return $array;
  31. };
  32. $cate_child = function()
  33. {
  34. $cate = Dever::load('set/cate-childAll');
  35. return $cate;
  36. };
  37. # 栏目
  38. $search_cate = function()
  39. {
  40. $array = array
  41. (
  42. -1 => array('id' => '-1', 'name' => '所有栏目'),
  43. );
  44. $cate = Dever::load('set/manage.cate');
  45. if($cate)
  46. {
  47. $array += $cate;
  48. }
  49. return $array;
  50. };
  51. return array
  52. (
  53. # 表名
  54. 'name' => 'news',
  55. # 显示给用户看的名称
  56. 'lang' => '资讯管理',
  57. 'order' => 200,
  58. # 数据结构
  59. 'struct' => array
  60. (
  61. 'id' => array
  62. (
  63. 'type' => 'int-11',
  64. 'name' => 'ID',
  65. 'default' => '',
  66. 'desc' => '',
  67. 'match' => 'is_numeric',
  68. 'search' => 'order',
  69. 'list' => true,
  70. ),
  71. 'name' => array
  72. (
  73. 'type' => 'varchar-80',
  74. 'name' => '标题',
  75. 'default' => '',
  76. 'desc' => '请输入主题标题',
  77. 'match' => 'is_string',
  78. 'update' => 'text',
  79. 'search' => 'fulltext',
  80. 'list' => true,
  81. ),
  82. 'info_id' => array
  83. (
  84. 'type' => 'int-11',
  85. 'name' => '所属小程序',
  86. 'default' => '1',
  87. 'desc' => '请选择所属小程序',
  88. 'match' => 'is_numeric',
  89. 'update' => 'select',
  90. 'option' => $info,
  91. 'search' => 'select',
  92. 'list' => '{info_id} > 0 ? Dever::load("set/info-one#name", {info_id}) : "未知"',
  93. ),
  94. 'author_id' => array
  95. (
  96. 'type' => 'int-11',
  97. 'name' => '作者',
  98. 'default' => '1',
  99. 'desc' => '请选择作者',
  100. 'match' => 'is_numeric',
  101. 'update' => 'select',
  102. 'option' => $author,
  103. //'search' => 'select',
  104. 'list' => '{author_id} > 0 ? Dever::load("set/author-one#name", {author_id}) : "未知"',
  105. ),
  106. 'cate_id_parent' => array
  107. (
  108. 'type' => 'int-11',
  109. 'name' => '父级栏目',
  110. 'default' => '0',
  111. 'desc' => '请选择父级栏目',
  112. 'match' => 'is_numeric',
  113. 'update' => 'select',
  114. //'search' => 'order,select',
  115. //'list' => '{cate_id_parent} > 0 ? Dever::load("set/cate-one#name", {cate_id_parent}) : "临时栏目"',
  116. 'option' => $cate,
  117. # 当值改变时,执行下一步操作
  118. 'child_name' => 'cate_id',
  119. 'child' => $cate_child,
  120. 'child_value' => '{cate_id}',
  121. ),
  122. 'cate_id' => array
  123. (
  124. 'type' => 'int-11',
  125. 'name' => '子栏目',
  126. 'default' => '0',
  127. 'desc' => '请选择子栏目',
  128. 'match' => 'is_numeric',
  129. 'search' => 'group',
  130. 'option' => $search_cate,
  131. 'list_name' => '栏目',
  132. 'list' => '{cate_id} > 0 ? Dever::load("set/cate-one#name", {cate_id}) : "无子栏目"',
  133. ),
  134. 'num_add_view' => array
  135. (
  136. 'type' => 'int-11',
  137. 'name' => '手动增加浏览量pv',
  138. 'default' => '0',
  139. 'desc' => '请填写手动增加浏览量pv',
  140. 'match' => 'option',
  141. 'update' => 'text',
  142. ),
  143. 'num_up' => array
  144. (
  145. 'type' => 'int-11',
  146. 'name' => '赞数',
  147. 'default' => '0',
  148. 'desc' => '请填写赞数',
  149. 'match' => 'option',
  150. //'search' => 'order',
  151. 'list' => '"赞数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />回复数:{num_review}<br />"',
  152. 'list_name' => '统计数字',
  153. ),
  154. 'num_view' => array
  155. (
  156. 'type' => 'int-11',
  157. 'name' => '浏览量pv',
  158. 'default' => '0',
  159. 'desc' => '请填写浏览量pv',
  160. 'match' => 'option',
  161. 'search' => 'order',
  162. //'list' => '{num_view}+{num_add_view}',
  163. ),
  164. 'num_review' => array
  165. (
  166. 'type' => 'int-11',
  167. 'name' => '回复数',
  168. 'default' => '0',
  169. 'desc' => '请填写回复数',
  170. 'search' => 'order',
  171. 'match' => 'option',
  172. //'list' => true,
  173. ),
  174. 'pic' => array
  175. (
  176. 'type' => 'varchar-150',
  177. 'name' => '封面-可以上传多个',
  178. 'default' => '',
  179. 'desc' => '请选择封面',
  180. 'match' => 'is_string',
  181. 'update' => 'images',
  182. 'key' => '1',
  183. 'place' => '150',
  184. ),
  185. 'top' => array
  186. (
  187. 'type' => 'varchar-150',
  188. 'name' => '头图',
  189. 'default' => '',
  190. 'desc' => '请选择头图',
  191. 'match' => 'is_string',
  192. 'update' => 'image',
  193. 'key' => '1',
  194. 'place' => '150',
  195. ),
  196. 'content' => array
  197. (
  198. 'type' => 'text-800',
  199. 'name' => '内容',
  200. 'default' => '',
  201. 'desc' => '请输入内容',
  202. 'match' => 'is_string',
  203. 'update' => 'editor',
  204. 'key' => 1,
  205. ),
  206. 'reorder' => array
  207. (
  208. 'type' => 'int-11',
  209. 'name' => '排序(数值越大越靠前)',
  210. 'default' => '1',
  211. 'desc' => '请输入排序',
  212. 'match' => 'option',
  213. 'update' => 'text',
  214. 'search' => 'order',
  215. 'list_name' => '排序',
  216. 'list' => true,
  217. 'order' => 'desc',
  218. 'edit' => true,
  219. ),
  220. 'state' => array
  221. (
  222. 'type' => 'tinyint-1',
  223. 'name' => '状态',
  224. 'default' => '1',
  225. 'desc' => '请选择状态',
  226. 'match' => 'is_numeric',
  227. ),
  228. 'cdate' => array
  229. (
  230. 'type' => 'int-11',
  231. 'name' => '录入时间',
  232. 'match' => array('is_numeric', time()),
  233. 'desc' => '',
  234. # 只有insert时才生效
  235. 'insert' => true,
  236. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  237. ),
  238. ),
  239. # 索引
  240. 'index' => array
  241. (
  242. ),
  243. # 管理功能
  244. 'manage' => array
  245. (
  246. //'insert' => false,
  247. # 列表
  248. 'list_button' => array
  249. (
  250. 'list' => array('评论', '"review&project=comment&search_option_source_table=1&search_option_source_id={id}&oper_parent=news&oper_project=content"'),
  251. ),
  252. ),
  253. # request 请求接口定义
  254. 'request' => array
  255. (
  256. 'getAll' => array
  257. (
  258. # 匹配的正则或函数 选填项
  259. 'option' => array
  260. (
  261. 'info_id' => 'yes',
  262. 'cate_id_parent' => 'yes',
  263. 'cate_id' => 'yes',
  264. 'cate_ids' => array('yes-cate_id', 'in'),
  265. ),
  266. 'type' => 'all',
  267. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  268. 'page' => array(10, 'list'),
  269. 'col' => 'id, name, pic, top, cate_id, info_id, author_id, content, (num_view+num_add_view) as num_view, cdate',
  270. ),
  271. # 更新浏览量
  272. 'addView' => array
  273. (
  274. 'type' => 'update',
  275. 'where' => array
  276. (
  277. 'id' => 'yes',
  278. ),
  279. 'set' => array
  280. (
  281. 'num_view' => array('1', '+='),
  282. ),
  283. ),
  284. # 更新回复数
  285. 'addReview' => array
  286. (
  287. 'type' => 'update',
  288. 'where' => array
  289. (
  290. 'id' => 'yes',
  291. ),
  292. 'set' => array
  293. (
  294. 'num_review' => array('1', '+='),
  295. ),
  296. ),
  297. # 更新点赞数
  298. 'addUp' => array
  299. (
  300. 'type' => 'update',
  301. 'where' => array
  302. (
  303. 'id' => 'yes',
  304. ),
  305. 'set' => array
  306. (
  307. 'num_up' => array('1', '+='),
  308. ),
  309. ),
  310. # 更新点赞数
  311. 'desUp' => array
  312. (
  313. 'type' => 'update',
  314. 'where' => array
  315. (
  316. 'id' => 'yes',
  317. ),
  318. 'set' => array
  319. (
  320. 'num_up' => array('1', '-='),
  321. ),
  322. ),
  323. ),
  324. );