pic.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <?php
  2. $status = Dever::config('base')->status;
  3. # 每页的数据量
  4. $page = 15;
  5. $cate = function()
  6. {
  7. $array = array();
  8. $info = Dever::db('content/cate')->state();
  9. if($info)
  10. {
  11. $array += $info;
  12. }
  13. return $array;
  14. };
  15. # 常用的col
  16. $col = 'id,cate_id,name,pic,num_add_view+num_view as num_view,`desc`';
  17. return array
  18. (
  19. # 表名
  20. 'name' => 'pic',
  21. # 显示给用户看的名称
  22. 'lang' => '图片管理',
  23. 'order' => 100,
  24. # 数据结构
  25. 'struct' => array
  26. (
  27. 'id' => array
  28. (
  29. 'type' => 'int-11',
  30. 'name' => 'ID',
  31. 'default' => '',
  32. 'desc' => '',
  33. 'match' => 'is_numeric',
  34. 'list' => true,
  35. ),
  36. 'name' => array
  37. (
  38. 'type' => 'varchar-80',
  39. 'name' => '标题-标题,同时也用于分享标题',
  40. 'default' => '',
  41. 'desc' => '标题',
  42. 'match' => 'is_string',
  43. 'update' => 'text',
  44. 'list' => true,
  45. 'search' => 'fulltext',
  46. //增加预览
  47. 'preview' => true,
  48. ),
  49. 'desc' => array
  50. (
  51. 'type' => 'varchar-500',
  52. 'name' => '摘要-摘要,同时也用于分享内容',
  53. 'default' => '',
  54. 'desc' => '摘要',
  55. 'match' => 'is_string',
  56. 'update' => 'textarea',
  57. ),
  58. 'cate_id' => array
  59. (
  60. 'type' => 'int-11',
  61. 'name' => '所属栏目',
  62. 'default' => '1',
  63. 'desc' => '所属栏目',
  64. 'match' => 'is_numeric',
  65. 'update' => 'select',
  66. 'option' => $cate,
  67. 'search' => 'select',
  68. 'list' => 'Dever::load("content/cate-one#name", {cate_id})',
  69. ),
  70. 'pic' => array
  71. (
  72. 'type' => 'text-255',
  73. 'name' => '图片',
  74. 'default' => '',
  75. 'desc' => '图片',
  76. 'match' => 'is_string',
  77. 'update' => 'images',
  78. 'key' => '1',
  79. 'place' => '150',
  80. //直接上传到云端
  81. //'upload' => 'qiniu',
  82. //上传大数据
  83. //'large' => true,
  84. ),
  85. 'num_add_view' => array
  86. (
  87. 'type' => 'int-11',
  88. 'name' => '浏览量基数',
  89. 'default' => '0',
  90. 'desc' => '浏览量基数',
  91. 'match' => 'option',
  92. //'update' => 'text',
  93. ),
  94. 'num_view' => array
  95. (
  96. 'type' => 'int-11',
  97. 'name' => '浏览量',
  98. 'default' => '0',
  99. 'desc' => '请填写浏览量',
  100. 'match' => 'option',
  101. 'search' => 'order',
  102. 'list' => '{num_view}+{num_add_view}',
  103. ),
  104. 'num_up' => array
  105. (
  106. 'type' => 'int-11',
  107. 'name' => '点赞数',
  108. 'default' => '0',
  109. 'desc' => '点赞数',
  110. 'match' => 'option',
  111. //'search' => 'order',
  112. //'list' => true,
  113. ),
  114. 'num_comment' => array
  115. (
  116. 'type' => 'int-11',
  117. 'name' => '评论数',
  118. 'default' => '0',
  119. 'desc' => '评论数',
  120. 'match' => 'option',
  121. //'search' => 'order',
  122. //'list' => true,
  123. ),
  124. 'num_collect' => array
  125. (
  126. 'type' => 'int-11',
  127. 'name' => '收藏数',
  128. 'default' => '0',
  129. 'desc' => '收藏数',
  130. 'match' => 'option',
  131. //'search' => 'order',
  132. //'list' => true,
  133. ),
  134. 'pdate' => array
  135. (
  136. 'type' => 'int-11',
  137. 'name' => '发布时间',
  138. 'match' => array('is_numeric', time()),
  139. 'default' => '',
  140. 'desc' => '',
  141. 'update' => 'date',
  142. 'callback' => 'maketime',
  143. 'insert' => true,
  144. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  145. 'auth' => '"{pdate}" > 0',
  146. ),
  147. 'reorder' => array
  148. (
  149. 'type' => 'int-11',
  150. 'name' => '排序(数值越大越靠前)',
  151. 'default' => '1',
  152. 'desc' => '请输入排序',
  153. 'match' => 'option',
  154. 'update' => 'text',
  155. 'search' => 'order',
  156. 'list' => true,
  157. 'order' => 'desc',
  158. 'edit' => true,
  159. ),
  160. 'udate' => array
  161. (
  162. 'type' => 'int-11',
  163. 'name' => '更新时间',
  164. 'match' => array('is_numeric', time()),
  165. 'desc' => '',
  166. ),
  167. 'status' => array
  168. (
  169. 'type' => 'int-11',
  170. 'name' => '发布状态',
  171. 'default' => '2',
  172. 'desc' => '发布状态',
  173. 'match' => 'is_numeric',
  174. //'update' => 'select',
  175. 'option' => $status,
  176. 'search' => 'select',
  177. 'list' => true,
  178. 'edit' => true,
  179. ),
  180. 'state' => array
  181. (
  182. 'type' => 'tinyint-1',
  183. 'name' => '状态',
  184. 'default' => '1',
  185. 'desc' => '请选择状态',
  186. 'match' => 'is_numeric',
  187. ),
  188. 'cdate' => array
  189. (
  190. 'type' => 'int-11',
  191. 'name' => '录入时间',
  192. 'match' => array('is_numeric', time()),
  193. 'desc' => '',
  194. # 只有insert时才生效
  195. 'insert' => true,
  196. ),
  197. ),
  198. # 索引
  199. 'index' => array
  200. (
  201. 'version' => 1,
  202. 1 => array
  203. (
  204. 'i1' => 'cate_id,reorder',
  205. )
  206. ),
  207. # 管理功能
  208. 'manage' => array
  209. (
  210. //'insert' => false,
  211. # 列表
  212. 'list_button' => array
  213. (
  214. 'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  215. ),
  216. ),
  217. # request 请求接口定义
  218. 'request' => array
  219. (
  220. 'search' => array
  221. (
  222. # 匹配的正则或函数 选填项
  223. 'option' => array
  224. (
  225. 'ids' => array('yes-id', 'in'),
  226. 'cate_id' => 'yes',
  227. 'name' => array('yes', 'like'),
  228. 'id' => 'yes',
  229. 'state' => 1,
  230. ),
  231. 'type' => 'all',
  232. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  233. 'limit' => '0,1000',
  234. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  235. ),
  236. 'getAll' => array
  237. (
  238. # 匹配的正则或函数 选填项
  239. 'option' => array
  240. (
  241. 'cate_id' => 'yes',
  242. 'cate_ids' => array('yes-cate_id', 'in'),
  243. 'id' => 'yes',
  244. 'status' => 2,
  245. 'state' => 1,
  246. ),
  247. 'type' => 'all',
  248. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  249. 'page' => array($page, 'list'),
  250. 'col' => $col,
  251. ),
  252. 'getList' => array
  253. (
  254. # 匹配的正则或函数 选填项
  255. 'option' => array
  256. (
  257. 'cate_id' => 'yes',
  258. 'status' => 2,
  259. 'state' => 1,
  260. ),
  261. 'type' => 'all',
  262. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  263. 'limit' => '0,10',
  264. 'col' => $col,
  265. ),
  266. 'getRelation' => array
  267. (
  268. # 匹配的正则或函数 选填项
  269. 'option' => array
  270. (
  271. 'cate_id' => 'yes',
  272. 'cate_ids' => array('yes-cate_id', 'in'),
  273. 'noid' => array('yes-id', '!='),
  274. 'status' => 2,
  275. 'state' => 1,
  276. ),
  277. 'type' => 'all',
  278. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  279. 'limit' => '0,4',
  280. 'col' => $col,
  281. ),
  282. 'getOne' => array
  283. (
  284. # 匹配的正则或函数 选填项
  285. 'where' => array
  286. (
  287. 'id' => 'yes',
  288. ),
  289. 'type' => 'one',
  290. 'col' => $col,
  291. ),
  292. # 更新浏览量
  293. 'addView' => array
  294. (
  295. 'type' => 'update',
  296. 'where' => array
  297. (
  298. 'id' => 'yes',
  299. ),
  300. 'set' => array
  301. (
  302. 'num_view' => array('1', '+='),
  303. ),
  304. ),
  305. ),
  306. );