news.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. 'reading' => array
  83. (
  84. 'type' => 'varchar-255',
  85. 'name' => '导读',
  86. 'default' => '',
  87. 'desc' => '请输入导读',
  88. 'match' => 'option',
  89. 'update' => 'textarea',
  90. //'search' => 'fulltext',
  91. //'list' => true,
  92. ),
  93. 'subname' => array
  94. (
  95. 'type' => 'varchar-80',
  96. 'name' => '子标题',
  97. 'default' => '',
  98. 'desc' => '子标题',
  99. 'match' => 'option',
  100. // 'update' => 'text',
  101. //'search' => 'fulltext',
  102. //'list' => true,
  103. ),
  104. 'info_id' => array
  105. (
  106. 'type' => 'int-11',
  107. 'name' => '所属小程序',
  108. 'default' => '1',
  109. 'desc' => '请选择所属小程序',
  110. 'match' => 'is_numeric',
  111. 'update' => 'select',
  112. 'option' => $info,
  113. 'search' => 'select',
  114. 'list' => '{info_id} > 0 ? Dever::load("set/info-one#name", {info_id}) : "未知"',
  115. ),
  116. 'author_id' => array
  117. (
  118. 'type' => 'int-11',
  119. 'name' => '作者',
  120. 'default' => '1',
  121. 'desc' => '请选择作者',
  122. 'match' => 'is_numeric',
  123. 'update' => 'select',
  124. 'option' => $author,
  125. //'search' => 'select',
  126. //'list' => '{author_id} > 0 ? Dever::load("set/author-one#name", {author_id}) : "未知"',
  127. ),
  128. 'cate_id_parent' => array
  129. (
  130. 'type' => 'int-11',
  131. 'name' => '父级栏目',
  132. 'default' => '0',
  133. 'desc' => '请选择父级栏目',
  134. 'match' => 'is_numeric',
  135. 'update' => 'select',
  136. //'search' => 'order,select',
  137. //'list' => '{cate_id_parent} > 0 ? Dever::load("set/cate-one#name", {cate_id_parent}) : "临时栏目"',
  138. 'option' => $cate,
  139. # 当值改变时,执行下一步操作
  140. 'child_name' => 'cate_id',
  141. 'child' => $cate_child,
  142. 'child_value' => '{cate_id}',
  143. ),
  144. 'cate_id' => array
  145. (
  146. 'type' => 'int-11',
  147. 'name' => '子栏目',
  148. 'default' => '0',
  149. 'desc' => '请选择子栏目',
  150. 'match' => 'is_numeric',
  151. 'search' => 'group',
  152. 'option' => $search_cate,
  153. 'list_name' => '栏目',
  154. 'list' => '{cate_id} > 0 ? Dever::load("set/cate-one#name", {cate_id}) : "无子栏目"',
  155. ),
  156. 'num_add_view' => array
  157. (
  158. 'type' => 'int-11',
  159. 'name' => '手动增加浏览量pv',
  160. 'default' => '0',
  161. 'desc' => '请填写手动增加浏览量pv',
  162. 'match' => 'option',
  163. 'update' => 'text',
  164. ),
  165. 'num_up' => array
  166. (
  167. 'type' => 'int-11',
  168. 'name' => '赞数',
  169. 'default' => '0',
  170. 'desc' => '请填写赞数',
  171. 'match' => 'option',
  172. //'search' => 'order',
  173. 'list' => '"赞数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />回复数:{num_review}<br />"',
  174. 'list_name' => '统计数字',
  175. ),
  176. 'num_view' => array
  177. (
  178. 'type' => 'int-11',
  179. 'name' => '浏览量pv',
  180. 'default' => '0',
  181. 'desc' => '请填写浏览量pv',
  182. 'match' => 'option',
  183. 'search' => 'order',
  184. //'list' => '{num_view}+{num_add_view}',
  185. ),
  186. 'num_review' => array
  187. (
  188. 'type' => 'int-11',
  189. 'name' => '回复数',
  190. 'default' => '0',
  191. 'desc' => '请填写回复数',
  192. 'search' => 'order',
  193. 'match' => 'option',
  194. //'list' => true,
  195. ),
  196. 'pic' => array
  197. (
  198. 'type' => 'varchar-150',
  199. 'name' => '封面',
  200. 'default' => '',
  201. 'desc' => '请选择封面',
  202. 'match' => 'is_string',
  203. 'update' => 'image',
  204. 'key' => '1',
  205. 'place' => '150',
  206. ),
  207. 'top' => array
  208. (
  209. 'type' => 'varchar-150',
  210. 'name' => '头图',
  211. 'default' => '',
  212. 'desc' => '请选择头图',
  213. 'match' => 'option',
  214. 'update' => 'image',
  215. 'key' => '1',
  216. 'place' => '150',
  217. ),
  218. 'content' => array
  219. (
  220. 'type' => 'text-800',
  221. 'name' => '内容',
  222. 'default' => '',
  223. 'desc' => '请输入内容',
  224. 'match' => 'is_string',
  225. 'update' => 'editor',
  226. 'key' => 1,
  227. ),
  228. 'reorder' => array
  229. (
  230. 'type' => 'int-11',
  231. 'name' => '排序(数值越大越靠前)',
  232. 'default' => '1',
  233. 'desc' => '请输入排序',
  234. 'match' => 'option',
  235. 'update' => 'text',
  236. 'search' => 'order',
  237. 'list_name' => '排序',
  238. 'list' => true,
  239. 'order' => 'desc',
  240. 'edit' => true,
  241. ),
  242. 'state' => array
  243. (
  244. 'type' => 'tinyint-1',
  245. 'name' => '状态',
  246. 'default' => '1',
  247. 'desc' => '请选择状态',
  248. 'match' => 'is_numeric',
  249. ),
  250. 'cdate' => array
  251. (
  252. 'type' => 'int-11',
  253. 'name' => '录入时间',
  254. 'match' => array('is_numeric', time()),
  255. 'desc' => '',
  256. # 只有insert时才生效
  257. 'insert' => true,
  258. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  259. ),
  260. ),
  261. # 索引
  262. 'index' => array
  263. (
  264. ),
  265. # 管理功能
  266. 'manage' => array
  267. (
  268. //'insert' => false,
  269. # 列表
  270. 'list_button' => array
  271. (
  272. 'list' => array('评论', '"review&project=comment&search_option_source_table=1&search_option_source_id={id}&oper_parent=news&oper_project=content"'),
  273. ),
  274. ),
  275. # request 请求接口定义
  276. 'request' => array
  277. (
  278. 'getAll' => array
  279. (
  280. # 匹配的正则或函数 选填项
  281. 'option' => array
  282. (
  283. 'info_id' => 'yes',
  284. 'cate_id_parent' => 'yes',
  285. 'cate_id' => 'yes',
  286. 'cate_ids' => array('yes-cate_id', 'in'),
  287. ),
  288. 'type' => 'all',
  289. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  290. 'page' => array(10, 'list'),
  291. 'col' => 'id, name, reading,subname,pic, top, cate_id, info_id, author_id, content, (num_view+num_add_view) as num_view,num_up,num_review, cdate',
  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. );