video.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <?php
  2. $status = Dever::config('base')->status;
  3. # 每页的数据量
  4. $page = 12;
  5. $cate = function()
  6. {
  7. $array = array();
  8. $info = Dever::db('content/cate')->select(array('type' => 3));
  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,video,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' => 'video',
  36. # 显示给用户看的名称
  37. 'lang' => '视频管理',
  38. 'order' => 98,
  39. # 同步更新另外一个或多个表的数据
  40. 'syncone' => array
  41. (
  42. 'content/search' => array
  43. (
  44. # 更新另外一个表的字段 => 本表的字段
  45. 'where' => array('data_id' => 'id', 'type' => 3),
  46. # 要更新的数据
  47. 'update' => array('data_id' => 'id', 'type' => 3, '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/video','tag/lib/core.data?source_table=content/video'),
  53. 'update' => array('content/lib/author.data?source_table=content/video','tag/lib/core.data?source_table=content/video'),
  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. 'video' => array
  114. (
  115. 'type' => 'varchar-800',
  116. 'name' => '上传视频-视频格式mp4,上传大小不能超过4G',
  117. 'default' => '',
  118. 'desc' => '上传视频',
  119. 'match' => 'is_string',
  120. 'update' => 'video',
  121. 'key' => '3',
  122. 'place' => '150',
  123. 'upload' => 'yun',
  124. 'large' => true,
  125. 'cover' => 'pic_cover',//封面图字段名
  126. ),
  127. 'video_info' => array
  128. (
  129. 'type' => 'text-255',
  130. 'name' => '视频信息',
  131. 'default' => '',
  132. 'desc' => '视频信息',
  133. 'match' => 'is_string',
  134. ),
  135. 'pic_cover' => array
  136. (
  137. 'type' => 'varchar-150',
  138. 'name' => '封面图',
  139. 'default' => '',
  140. 'desc' => '封面图',
  141. 'match' => 'option',
  142. 'update' => 'image',
  143. 'key' => '1',
  144. 'place' => '345*200',
  145. ),
  146. 'tag' => array
  147. (
  148. 'type' => 'text-255',
  149. 'name' => '标签',
  150. 'default' => '',
  151. 'desc' => '标签',
  152. 'match' => 'is_numeric',
  153. 'update' => 'selects',
  154. //'search' => 'fulltext',
  155. 'update_search' => 'tag/lib/core.search',
  156. ),
  157. 'num_add_view' => array
  158. (
  159. 'type' => 'int-11',
  160. 'name' => '浏览量基数',
  161. 'default' => '0',
  162. 'desc' => '浏览量基数',
  163. 'match' => 'option',
  164. //'update' => 'text',
  165. ),
  166. 'num_view' => array
  167. (
  168. 'type' => 'int-11',
  169. 'name' => '浏览量',
  170. 'default' => '0',
  171. 'desc' => '请填写浏览量',
  172. 'match' => 'option',
  173. 'search' => 'order',
  174. 'list' => '{num_view}+{num_add_view}',
  175. ),
  176. 'num_add_up' => array
  177. (
  178. 'type' => 'int-11',
  179. 'name' => '点赞量基数',
  180. 'default' => '0',
  181. 'desc' => '点赞量基数',
  182. 'match' => 'option',
  183. //'update' => 'text',
  184. ),
  185. 'num_up' => array
  186. (
  187. 'type' => 'int-11',
  188. 'name' => '点赞量',
  189. 'default' => '0',
  190. 'desc' => '请填写点赞量',
  191. 'match' => 'option',
  192. 'search' => 'order',
  193. 'list' => '{num_up}+{num_add_up}',
  194. ),
  195. 'top' => array
  196. (
  197. 'type' => 'tinyint-1',
  198. 'name' => '是否精选推荐',
  199. 'default' => '2',
  200. 'desc' => '是否精选推荐',
  201. 'match' => 'is_numeric',
  202. 'update' => 'radio',
  203. 'option' => $yes,
  204. ),
  205. 'pdate' => array
  206. (
  207. 'type' => 'int-11',
  208. 'name' => '发布时间',
  209. 'match' => array('is_numeric', time()),
  210. 'default' => '',
  211. 'desc' => '',
  212. 'update' => 'date',
  213. 'callback' => 'maketime',
  214. 'insert' => true,
  215. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  216. 'auth' => '"{pdate}" > 0',
  217. ),
  218. 'reorder' => array
  219. (
  220. 'type' => 'int-11',
  221. 'name' => '排序(数值越大越靠前)',
  222. 'default' => '1',
  223. 'desc' => '请输入排序',
  224. 'match' => 'option',
  225. 'update' => 'text',
  226. 'search' => 'order',
  227. 'list' => true,
  228. 'order' => 'desc',
  229. 'edit' => true,
  230. ),
  231. 'udate' => array
  232. (
  233. 'type' => 'int-11',
  234. 'name' => '更新时间',
  235. 'match' => array('is_numeric', time()),
  236. 'desc' => '',
  237. ),
  238. 'status' => array
  239. (
  240. 'type' => 'int-11',
  241. 'name' => '发布状态',
  242. 'default' => '1',
  243. 'desc' => '发布状态',
  244. 'match' => 'is_numeric',
  245. //'update' => 'select',
  246. 'option' => $status,
  247. 'search' => 'select',
  248. 'list' => true,
  249. 'edit' => true,
  250. ),
  251. 'spider_data_id'=> array
  252. (
  253. 'type' => 'int-11',
  254. 'name' => '采集数据id',
  255. 'default' => '0',
  256. 'desc' => '采集数据id',
  257. 'match' => 'is_numeric',
  258. ),
  259. 'state' => array
  260. (
  261. 'type' => 'tinyint-1',
  262. 'name' => '状态',
  263. 'default' => '1',
  264. 'desc' => '请选择状态',
  265. 'match' => 'is_numeric',
  266. ),
  267. 'admin_founder' => array
  268. (
  269. 'type' => 'int-11',
  270. 'name' => '创建人',
  271. 'default' => '1',
  272. 'desc' => '创建人',
  273. 'match' => 'is_numeric',
  274. ),
  275. 'admin_editor' => array
  276. (
  277. 'type' => 'int-11',
  278. 'name' => '操作人',
  279. 'default' => '1',
  280. 'desc' => '操作人',
  281. 'match' => 'is_numeric',
  282. ),
  283. 'cdate' => array
  284. (
  285. 'type' => 'int-11',
  286. 'name' => '录入时间',
  287. 'match' => array('is_numeric', time()),
  288. 'desc' => '',
  289. # 只有insert时才生效
  290. 'insert' => true,
  291. ),
  292. ),
  293. # 索引
  294. 'index' => array
  295. (
  296. 'version' => 1,
  297. 1 => array
  298. (
  299. 'i1' => 'cate_id,reorder',
  300. )
  301. ),
  302. # 管理功能
  303. 'manage' => array
  304. (
  305. //'insert' => false,
  306. # 列表
  307. 'list_button' => array
  308. (
  309. //'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
  310. ),
  311. ),
  312. # request 请求接口定义
  313. 'request' => array
  314. (
  315. 'search' => array
  316. (
  317. # 匹配的正则或函数 选填项
  318. 'option' => array
  319. (
  320. 'ids' => array('yes-id', 'in'),
  321. 'cate_id' => 'yes',
  322. 'name' => array('yes', 'like'),
  323. 'id' => 'yes',
  324. 'state' => 1,
  325. ),
  326. 'type' => 'all',
  327. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  328. 'limit' => '0,1000',
  329. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  330. ),
  331. 'getAll' => array
  332. (
  333. # 匹配的正则或函数 选填项
  334. 'option' => array
  335. (
  336. 'cate_id' => 'yes',
  337. 'cate_ids' => array('yes-cate_id', 'in'),
  338. 'id' => 'yes',
  339. 'status' => 1,
  340. 'state' => 1,
  341. ),
  342. 'type' => 'all',
  343. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  344. 'page' => array($page, 'list'),
  345. 'col' => $col,
  346. ),
  347. # 获取首页推荐
  348. 'getTop' => array
  349. (
  350. # 匹配的正则或函数 选填项
  351. 'option' => array
  352. (
  353. 'cate_id' => 'yes',
  354. 'status' => 1,
  355. 'state' => 1,
  356. ),
  357. 'type' => 'all',
  358. 'order' => array('top' => 'asc', 'reorder' => 'desc','pdate' => 'desc'),
  359. 'limit' => '0,4',
  360. 'col' => $col,
  361. ),
  362. 'getList' => array
  363. (
  364. # 匹配的正则或函数 选填项
  365. 'option' => array
  366. (
  367. 'cate_id' => 'yes',
  368. 'status' => 1,
  369. 'state' => 1,
  370. ),
  371. 'type' => 'all',
  372. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  373. 'limit' => '0,10',
  374. 'col' => $col,
  375. ),
  376. 'getRelation' => array
  377. (
  378. # 匹配的正则或函数 选填项
  379. 'option' => array
  380. (
  381. 'cate_id' => 'yes',
  382. 'cate_ids' => array('yes-cate_id', 'in'),
  383. 'noid' => array('yes-id', '!='),
  384. 'status' => 1,
  385. 'state' => 1,
  386. ),
  387. 'type' => 'all',
  388. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  389. 'limit' => '0,2',
  390. 'col' => $col,
  391. ),
  392. 'getOne' => array
  393. (
  394. # 匹配的正则或函数 选填项
  395. 'where' => array
  396. (
  397. 'id' => 'yes',
  398. ),
  399. 'type' => 'one',
  400. 'col' => $col,
  401. ),
  402. # 更新浏览量
  403. 'addView' => array
  404. (
  405. 'type' => 'update',
  406. 'where' => array
  407. (
  408. 'id' => 'yes',
  409. ),
  410. 'set' => array
  411. (
  412. 'num_view' => array('1', '+='),
  413. ),
  414. ),
  415. # 更新点赞量
  416. 'addUp' => array
  417. (
  418. 'type' => 'update',
  419. 'where' => array
  420. (
  421. 'id' => 'yes',
  422. ),
  423. 'set' => array
  424. (
  425. 'num_up' => array('1', '+='),
  426. ),
  427. ),
  428. 'findPrev' => array
  429. (
  430. # 匹配的正则或函数 选填项
  431. 'where' => array
  432. (
  433. 'cate_id' => 'yes',
  434. 'id' => array('yes', '<'),
  435. 'status' => 1,
  436. 'state' => 1,
  437. ),
  438. 'type' => 'one',
  439. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  440. 'col' => $col,
  441. ),
  442. 'findNext' => array
  443. (
  444. # 匹配的正则或函数 选填项
  445. 'where' => array
  446. (
  447. 'cate_id' => 'yes',
  448. 'id' => array('yes', '>'),
  449. 'status' => 1,
  450. 'state' => 1,
  451. ),
  452. 'order' => array('reorder' => 'asc','pdate' => 'asc'),
  453. 'type' => 'one',
  454. 'col' => $col,
  455. ),
  456. ),
  457. );