news.php 7.0 KB

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