news.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <?php
  2. $status = array
  3. (
  4. 1 => '发布',
  5. 2 => '下线',
  6. );
  7. # 每页的数据量
  8. $page = 10;
  9. $cate = function()
  10. {
  11. $array = array();
  12. $info = Dever::db('main/cate')->state();
  13. if($info)
  14. {
  15. $array += $info;
  16. }
  17. return $array;
  18. };
  19. $source = function()
  20. {
  21. $array = array();
  22. $info = Dever::db('main/source')->state();
  23. if($info)
  24. {
  25. $array += $info;
  26. }
  27. return $array;
  28. };
  29. $share = array
  30. (
  31. 1 => '显示',
  32. 2 => '不显示',
  33. );
  34. # 常用的col
  35. $col = 'id,cate_id,name,pic_cover,num_add_view+num_view as num_view,content,source_id,`desc`,cdate,pdate';
  36. return array
  37. (
  38. # 表名
  39. 'name' => 'info',
  40. # 显示给用户看的名称
  41. 'lang' => '文章管理',
  42. 'order' => 100,
  43. # 数据结构
  44. 'struct' => array
  45. (
  46. 'id' => array
  47. (
  48. 'type' => 'int-11',
  49. 'name' => 'ID',
  50. 'default' => '',
  51. 'desc' => '',
  52. 'match' => 'is_numeric',
  53. 'list' => true,
  54. ),
  55. 'name' => array
  56. (
  57. 'type' => 'varchar-80',
  58. 'name' => '标题-文章标题,同时也用于分享标题',
  59. 'default' => '',
  60. 'desc' => '标题',
  61. 'match' => 'is_string',
  62. 'update' => 'text',
  63. 'list' => true,
  64. 'search' => 'fulltext',
  65. //增加预览
  66. 'preview' => true,
  67. ),
  68. 'desc' => array
  69. (
  70. 'type' => 'varchar-500',
  71. 'name' => '摘要-文章摘要,同时也用于分享内容',
  72. 'default' => '',
  73. 'desc' => '摘要',
  74. 'match' => 'is_string',
  75. 'update' => 'textarea',
  76. ),
  77. 'cate_id' => array
  78. (
  79. 'type' => 'int-11',
  80. 'name' => '所属分类',
  81. 'default' => '1',
  82. 'desc' => '所属分类',
  83. 'match' => 'is_numeric',
  84. 'update' => 'select',
  85. 'option' => $cate,
  86. 'search' => 'select',
  87. 'list' => 'Dever::load("main/cate-one#name", {cate_id})',
  88. ),
  89. 'source_id' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '来源',
  93. 'default' => '1',
  94. 'desc' => '来源',
  95. 'match' => 'is_numeric',
  96. 'update' => 'select',
  97. 'option' => $source,
  98. 'search' => 'select',
  99. 'list' => 'Dever::load("main/source-one#name", {source_id})',
  100. ),
  101. 'pic_cover' => array
  102. (
  103. 'type' => 'text-255',
  104. 'name' => '封面图',
  105. 'default' => '',
  106. 'desc' => '封面图',
  107. 'match' => 'option',
  108. 'update' => 'image',
  109. 'key' => '1',
  110. 'place' => '378*224',
  111. //直接上传到云端
  112. //'upload' => 'qiniu',
  113. //上传大数据
  114. //'large' => true,
  115. ),
  116. 'num_add_view' => array
  117. (
  118. 'type' => 'int-11',
  119. 'name' => '浏览量基数',
  120. 'default' => '0',
  121. 'desc' => '浏览量基数',
  122. 'match' => 'option',
  123. //'update' => 'text',
  124. ),
  125. 'num_view' => array
  126. (
  127. 'type' => 'int-11',
  128. 'name' => '浏览量',
  129. 'default' => '0',
  130. 'desc' => '请填写浏览量',
  131. 'match' => 'option',
  132. //'search' => 'order',
  133. //'list' => '{num_view}+{num_add_view}',
  134. ),
  135. 'pdate' => array
  136. (
  137. 'type' => 'int-11',
  138. 'name' => '发布时间',
  139. 'match' => array('is_numeric', time()),
  140. 'default' => '',
  141. 'desc' => '',
  142. 'update' => 'date',
  143. 'callback' => 'maketime',
  144. 'insert' => true,
  145. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  146. 'auth' => '"{pdate}" > 0',
  147. ),
  148. 'reorder' => array
  149. (
  150. 'type' => 'int-11',
  151. 'name' => '排序(数值越大越靠前)',
  152. 'default' => '1',
  153. 'desc' => '请输入排序',
  154. 'match' => 'option',
  155. //'update' => 'text',
  156. //'search' => 'order',
  157. //'list' => true,
  158. //'order' => 'desc',
  159. //'edit' => true,
  160. ),
  161. 'udate' => array
  162. (
  163. 'type' => 'int-11',
  164. 'name' => '更新时间',
  165. 'match' => array('is_numeric', time()),
  166. 'desc' => '',
  167. ),
  168. 'content' => array
  169. (
  170. 'type' => 'text-255',
  171. 'name' => '内容',
  172. 'default' => '',
  173. 'desc' => '请输入内容',
  174. 'match' => 'is_string',
  175. 'update' => 'editor',
  176. 'key' => '1',
  177. //'media' => '5',//下面的音视频已经做到了
  178. //直接上传到云端
  179. //'upload' => 'qiniu',
  180. //上传大数据
  181. //'large' => true,
  182. //自定义编辑器右侧按钮
  183. 'editors' => array
  184. (
  185. 'name' => '选择插入模块',
  186. 'button' => array
  187. (
  188. array
  189. (
  190. 'name' => '视频',
  191. 'key' => 'article/lib/article.vod',
  192. ),
  193. ),
  194. ),
  195. ),
  196. 'status' => array
  197. (
  198. 'type' => 'int-11',
  199. 'name' => '发布状态',
  200. 'default' => '1',
  201. 'desc' => '发布状态',
  202. 'match' => 'is_numeric',
  203. //'update' => 'select',
  204. 'option' => $status,
  205. 'search' => 'select',
  206. 'list' => true,
  207. 'edit' => true,
  208. ),
  209. 'state' => array
  210. (
  211. 'type' => 'tinyint-1',
  212. 'name' => '状态',
  213. 'default' => '1',
  214. 'desc' => '请选择状态',
  215. 'match' => 'is_numeric',
  216. ),
  217. 'cdate' => array
  218. (
  219. 'type' => 'int-11',
  220. 'name' => '录入时间',
  221. 'match' => array('is_numeric', time()),
  222. 'desc' => '',
  223. # 只有insert时才生效
  224. 'insert' => true,
  225. ),
  226. ),
  227. # 索引
  228. 'index' => array
  229. (
  230. 'version' => 1,
  231. 1 => array
  232. (
  233. 'i1' => 'cate_id,reorder',
  234. )
  235. ),
  236. # 管理功能
  237. 'manage' => array
  238. (
  239. 'button' => array
  240. (
  241. '分类管理' => array('list', 'cate&oper_parent=news&oper_project=main'),
  242. '来源管理' => array('list', 'source&oper_parent=news&oper_project=main'),
  243. ),
  244. //'insert' => false,
  245. # 列表
  246. 'list_button' => array
  247. (
  248. //'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  249. ),
  250. ),
  251. # request 请求接口定义
  252. 'request' => array
  253. (
  254. 'search' => array
  255. (
  256. # 匹配的正则或函数 选填项
  257. 'option' => array
  258. (
  259. 'ids' => array('yes-id', 'in'),
  260. 'cate_id' => 'yes',
  261. 'name' => array('yes', 'like'),
  262. 'id' => 'yes',
  263. 'state' => 1,
  264. ),
  265. 'type' => 'all',
  266. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  267. 'limit' => '0,1000',
  268. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  269. ),
  270. 'getAll' => array
  271. (
  272. # 匹配的正则或函数 选填项
  273. 'option' => array
  274. (
  275. 'cate_id' => 'yes',
  276. 'cate_ids' => array('yes-cate_id', 'in'),
  277. 'id' => 'yes',
  278. 'status' => 1,
  279. 'state' => 1,
  280. ),
  281. 'type' => 'all',
  282. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  283. 'page' => array($page, 'list'),
  284. 'col' => $col,
  285. ),
  286. 'getList' => array
  287. (
  288. # 匹配的正则或函数 选填项
  289. 'option' => array
  290. (
  291. 'cate_id' => 'yes',
  292. 'status' => 1,
  293. 'state' => 1,
  294. ),
  295. 'type' => 'all',
  296. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  297. 'limit' => '0,3',
  298. 'col' => $col,
  299. ),
  300. 'getRelation' => array
  301. (
  302. # 匹配的正则或函数 选填项
  303. 'option' => array
  304. (
  305. 'cate_id' => 'yes',
  306. 'cate_ids' => array('yes-cate_id', 'in'),
  307. 'noid' => array('yes-id', '!='),
  308. 'status' => 1,
  309. 'state' => 1,
  310. ),
  311. 'type' => 'all',
  312. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  313. 'limit' => '0,2',
  314. 'col' => $col,
  315. ),
  316. 'getOne' => array
  317. (
  318. # 匹配的正则或函数 选填项
  319. 'where' => array
  320. (
  321. 'id' => 'yes',
  322. 'state' => 1,
  323. 'status' => 1,
  324. ),
  325. 'type' => 'one',
  326. 'col' => $col,
  327. ),
  328. 'findPrev' => array
  329. (
  330. # 匹配的正则或函数 选填项
  331. 'where' => array
  332. (
  333. 'cate_id' => 'yes',
  334. 'id' => array('yes', '<'),
  335. 'state' => 1,
  336. 'status' => 1,
  337. ),
  338. 'type' => 'one',
  339. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  340. 'col' => $col,
  341. ),
  342. 'findNext' => array
  343. (
  344. # 匹配的正则或函数 选填项
  345. 'where' => array
  346. (
  347. 'cate_id' => 'yes',
  348. 'id' => array('yes', '>'),
  349. 'state' => 1,
  350. 'status' => 1,
  351. ),
  352. 'order' => array('reorder' => 'asc','pdate' => 'asc'),
  353. 'type' => 'one',
  354. 'col' => $col,
  355. ),
  356. # 更新浏览量
  357. 'addView' => array
  358. (
  359. 'type' => 'update',
  360. 'where' => array
  361. (
  362. 'id' => 'yes',
  363. ),
  364. 'set' => array
  365. (
  366. 'num_view' => array('1', '+='),
  367. ),
  368. ),
  369. ),
  370. );