album.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <?php
  2. $status = Dever::config('base')->status;
  3. # 每页的数据量
  4. $page = 10;
  5. $cate = function()
  6. {
  7. $array = array();
  8. $info = Dever::db('content/cate')->select(array('type' => 2));
  9. if($info)
  10. {
  11. $array += $info;
  12. }
  13. return $array;
  14. };
  15. $author = function()
  16. {
  17. $array = array();
  18. $info = Dever::db('content/author')->state();
  19. if($info)
  20. {
  21. $array += $info;
  22. }
  23. return $array;
  24. };
  25. $yes = array
  26. (
  27. 1 => '是',
  28. 2 => '否',
  29. );
  30. # 常用的col
  31. $col = 'id,cate_id,name,pic_cover,pic,num_add_view+num_view as num_view,num_add_up+num_up as num_up,author_id,`desc`,pdate,cdate,tag';
  32. return array
  33. (
  34. # 表名
  35. 'name' => 'album',
  36. # 显示给用户看的名称
  37. 'lang' => '相册管理',
  38. 'order' => 99,
  39. # 同步更新另外一个或多个表的数据
  40. 'syncone' => array
  41. (
  42. 'content/search' => array
  43. (
  44. # 更新另外一个表的字段 => 本表的字段
  45. 'where' => array('data_id' => 'id', 'type' => 2),
  46. # 要更新的数据
  47. 'update' => array('data_id' => 'id', 'type' => 2, 'pdate' => 'pdate', 'reorder' => 'reorder', 'name' => 'name', 'status' => 'status', 'cate_id' => 'cate_id', 'state' => 'state'),
  48. )
  49. ),
  50. 'end' => array
  51. (
  52. 'insert' => array('content/lib/author.data?source_table=content/album','tag/lib/core.data?source_table=content/album'),
  53. 'update' => array('content/lib/author.data?source_table=content/album','tag/lib/core.data?source_table=content/album'),
  54. ),
  55. # 数据结构
  56. 'struct' => array
  57. (
  58. 'id' => array
  59. (
  60. 'type' => 'int-11',
  61. 'name' => 'ID',
  62. 'default' => '',
  63. 'desc' => '',
  64. 'match' => 'is_numeric',
  65. 'list' => true,
  66. ),
  67. 'name' => array
  68. (
  69. 'type' => 'varchar-80',
  70. 'name' => '标题',
  71. 'default' => '',
  72. 'desc' => '标题',
  73. 'match' => 'is_string',
  74. 'update' => 'text',
  75. 'list' => true,
  76. 'search' => 'fulltext',
  77. //增加预览
  78. 'preview' => true,
  79. ),
  80. 'desc' => array
  81. (
  82. 'type' => 'varchar-500',
  83. 'name' => '摘要',
  84. 'default' => '',
  85. 'desc' => '摘要',
  86. 'match' => 'is_string',
  87. 'update' => 'textarea',
  88. ),
  89. 'cate_id' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '所属栏目',
  93. 'default' => '1',
  94. 'desc' => '所属栏目',
  95. 'match' => 'is_numeric',
  96. 'update' => 'select',
  97. 'option' => $cate,
  98. 'search' => 'select',
  99. 'list' => 'Dever::load("content/cate-one#name", {cate_id})',
  100. ),
  101. 'author_id' => array
  102. (
  103. 'type' => 'int-11',
  104. 'name' => '作者',
  105. 'default' => '1',
  106. 'desc' => '作者',
  107. 'match' => 'is_numeric',
  108. 'update' => 'select',
  109. //'option' => $author,
  110. 'search' => 'select',
  111. 'update_search' => 'content/lib/author.search',
  112. ),
  113. 'pic_cover' => array
  114. (
  115. 'type' => 'varchar-150',
  116. 'name' => '封面图',
  117. 'default' => '',
  118. 'desc' => '封面图',
  119. 'match' => 'option',
  120. 'update' => 'image',
  121. 'key' => '1',
  122. 'place' => '345*200',
  123. ),
  124. 'pic' => array
  125. (
  126. 'type' => 'text-255',
  127. 'name' => '多张图片',
  128. 'default' => '',
  129. 'desc' => '多张图片',
  130. 'match' => 'option',
  131. 'update' => 'images',
  132. 'key' => '1',
  133. //'place' => '345*200',
  134. ),
  135. 'tag' => array
  136. (
  137. 'type' => 'text-255',
  138. 'name' => '标签',
  139. 'default' => '',
  140. 'desc' => '标签',
  141. 'match' => 'is_numeric',
  142. 'update' => 'selects',
  143. //'search' => 'fulltext',
  144. 'update_search' => 'tag/lib/core.search',
  145. ),
  146. 'num_add_view' => array
  147. (
  148. 'type' => 'int-11',
  149. 'name' => '浏览量基数',
  150. 'default' => '0',
  151. 'desc' => '浏览量基数',
  152. 'match' => 'option',
  153. //'update' => 'text',
  154. ),
  155. 'num_view' => array
  156. (
  157. 'type' => 'int-11',
  158. 'name' => '浏览量',
  159. 'default' => '0',
  160. 'desc' => '请填写浏览量',
  161. 'match' => 'option',
  162. 'search' => 'order',
  163. 'list' => '{num_view}+{num_add_view}',
  164. ),
  165. 'num_add_up' => array
  166. (
  167. 'type' => 'int-11',
  168. 'name' => '点赞量基数',
  169. 'default' => '0',
  170. 'desc' => '点赞量基数',
  171. 'match' => 'option',
  172. //'update' => 'text',
  173. ),
  174. 'num_up' => array
  175. (
  176. 'type' => 'int-11',
  177. 'name' => '点赞量',
  178. 'default' => '0',
  179. 'desc' => '请填写点赞量',
  180. 'match' => 'option',
  181. 'search' => 'order',
  182. 'list' => '{num_up}+{num_add_up}',
  183. ),
  184. 'top' => array
  185. (
  186. 'type' => 'tinyint-1',
  187. 'name' => '是否精选推荐',
  188. 'default' => '2',
  189. 'desc' => '是否精选推荐',
  190. 'match' => 'is_numeric',
  191. 'update' => 'radio',
  192. 'option' => $yes,
  193. ),
  194. 'pdate' => array
  195. (
  196. 'type' => 'int-11',
  197. 'name' => '发布时间',
  198. 'match' => array('is_numeric', time()),
  199. 'default' => '',
  200. 'desc' => '',
  201. 'update' => 'date',
  202. 'callback' => 'maketime',
  203. 'insert' => true,
  204. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  205. 'auth' => '"{pdate}" > 0',
  206. ),
  207. 'reorder' => array
  208. (
  209. 'type' => 'int-11',
  210. 'name' => '排序(数值越大越靠前)',
  211. 'default' => '1',
  212. 'desc' => '请输入排序',
  213. 'match' => 'option',
  214. 'update' => 'text',
  215. 'search' => 'order',
  216. 'list' => true,
  217. 'order' => 'desc',
  218. 'edit' => true,
  219. ),
  220. 'udate' => array
  221. (
  222. 'type' => 'int-11',
  223. 'name' => '更新时间',
  224. 'match' => array('is_numeric', time()),
  225. 'desc' => '',
  226. ),
  227. 'status' => array
  228. (
  229. 'type' => 'int-11',
  230. 'name' => '发布状态',
  231. 'default' => '1',
  232. 'desc' => '发布状态',
  233. 'match' => 'is_numeric',
  234. //'update' => 'select',
  235. 'option' => $status,
  236. 'search' => 'select',
  237. 'list' => true,
  238. 'edit' => true,
  239. ),
  240. 'spider_data_id'=> array
  241. (
  242. 'type' => 'int-11',
  243. 'name' => '采集数据id',
  244. 'default' => '0',
  245. 'desc' => '采集数据id',
  246. 'match' => 'is_numeric',
  247. ),
  248. 'state' => array
  249. (
  250. 'type' => 'tinyint-1',
  251. 'name' => '状态',
  252. 'default' => '1',
  253. 'desc' => '请选择状态',
  254. 'match' => 'is_numeric',
  255. ),
  256. 'admin_founder' => array
  257. (
  258. 'type' => 'int-11',
  259. 'name' => '创建人',
  260. 'default' => '1',
  261. 'desc' => '创建人',
  262. 'match' => 'is_numeric',
  263. ),
  264. 'admin_editor' => array
  265. (
  266. 'type' => 'int-11',
  267. 'name' => '操作人',
  268. 'default' => '1',
  269. 'desc' => '操作人',
  270. 'match' => 'is_numeric',
  271. ),
  272. 'cdate' => array
  273. (
  274. 'type' => 'int-11',
  275. 'name' => '录入时间',
  276. 'match' => array('is_numeric', time()),
  277. 'desc' => '',
  278. # 只有insert时才生效
  279. 'insert' => true,
  280. ),
  281. ),
  282. # 索引
  283. 'index' => array
  284. (
  285. 'version' => 1,
  286. 1 => array
  287. (
  288. 'i1' => 'cate_id,reorder',
  289. )
  290. ),
  291. # 管理功能
  292. 'manage' => array
  293. (
  294. //'insert' => false,
  295. # 列表
  296. 'list_button' => array
  297. (
  298. //'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  299. ),
  300. ),
  301. # request 请求接口定义
  302. 'request' => array
  303. (
  304. 'search' => array
  305. (
  306. # 匹配的正则或函数 选填项
  307. 'option' => array
  308. (
  309. 'ids' => array('yes-id', 'in'),
  310. 'cate_id' => 'yes',
  311. 'name' => array('yes', 'like'),
  312. 'id' => 'yes',
  313. 'state' => 1,
  314. ),
  315. 'type' => 'all',
  316. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  317. 'limit' => '0,1000',
  318. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  319. ),
  320. 'getAll' => array
  321. (
  322. # 匹配的正则或函数 选填项
  323. 'option' => array
  324. (
  325. 'cate_id' => 'yes',
  326. 'cate_ids' => array('yes-cate_id', 'in'),
  327. 'id' => 'yes',
  328. 'status' => 1,
  329. 'state' => 1,
  330. ),
  331. 'type' => 'all',
  332. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  333. 'page' => array($page, 'list'),
  334. 'col' => $col,
  335. ),
  336. 'getList' => array
  337. (
  338. # 匹配的正则或函数 选填项
  339. 'option' => array
  340. (
  341. 'cate_id' => 'yes',
  342. 'status' => 1,
  343. 'state' => 1,
  344. ),
  345. 'type' => 'all',
  346. 'order' => array('pdate' => 'desc'),
  347. 'limit' => '0,5',
  348. 'col' => $col,
  349. ),
  350. # 获取首页推荐
  351. 'getTop' => array
  352. (
  353. # 匹配的正则或函数 选填项
  354. 'option' => array
  355. (
  356. 'cate_id' => 'yes',
  357. 'status' => 1,
  358. 'state' => 1,
  359. ),
  360. 'type' => 'all',
  361. 'order' => array('top' => 'asc', 'reorder' => 'desc','pdate' => 'desc'),
  362. 'limit' => '0,4',
  363. 'col' => $col,
  364. ),
  365. 'getRelation' => array
  366. (
  367. # 匹配的正则或函数 选填项
  368. 'option' => array
  369. (
  370. 'cate_id' => 'yes',
  371. 'cate_ids' => array('yes-cate_id', 'in'),
  372. 'noid' => array('yes-id', '!='),
  373. 'status' => 1,
  374. 'state' => 1,
  375. ),
  376. 'type' => 'all',
  377. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  378. 'limit' => '0,2',
  379. 'col' => $col,
  380. ),
  381. 'getOne' => array
  382. (
  383. # 匹配的正则或函数 选填项
  384. 'where' => array
  385. (
  386. 'id' => 'yes',
  387. ),
  388. 'type' => 'one',
  389. 'col' => $col,
  390. ),
  391. # 更新浏览量
  392. 'addView' => array
  393. (
  394. 'type' => 'update',
  395. 'where' => array
  396. (
  397. 'id' => 'yes',
  398. ),
  399. 'set' => array
  400. (
  401. 'num_view' => array('1', '+='),
  402. ),
  403. ),
  404. # 更新点赞量
  405. 'addUp' => array
  406. (
  407. 'type' => 'update',
  408. 'where' => array
  409. (
  410. 'id' => 'yes',
  411. ),
  412. 'set' => array
  413. (
  414. 'num_up' => array('1', '+='),
  415. ),
  416. ),
  417. 'findPrev' => array
  418. (
  419. # 匹配的正则或函数 选填项
  420. 'where' => array
  421. (
  422. 'cate_id' => 'yes',
  423. 'id' => array('yes', '<'),
  424. 'status' => 1,
  425. 'state' => 1,
  426. ),
  427. 'type' => 'one',
  428. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  429. 'col' => $col,
  430. ),
  431. 'findNext' => array
  432. (
  433. # 匹配的正则或函数 选填项
  434. 'where' => array
  435. (
  436. 'cate_id' => 'yes',
  437. 'id' => array('yes', '>'),
  438. 'status' => 1,
  439. 'state' => 1,
  440. ),
  441. 'order' => array('reorder' => 'asc','pdate' => 'asc'),
  442. 'type' => 'one',
  443. 'col' => $col,
  444. ),
  445. ),
  446. );