file.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <?php
  2. /**
  3. * 上传表
  4. * demo: data/upload/upload_name/10000/10/10.thumb_test.jpg
  5. * 基本操作:根据upload上传、保存到pic表,所有保存到pic表的图片,均可参与后续处理操作 
  6. */
  7. # 定义几个常用的选项
  8. $option = array
  9. (
  10. 1 => '启用',
  11. 2 => '关闭',
  12. );
  13. $cate = function()
  14. {
  15. return Dever::db('upload/cate')->state();
  16. };
  17. $upload = function()
  18. {
  19. return Dever::db('upload/upload')->state();
  20. };
  21. return array
  22. (
  23. # 表名
  24. 'name' => 'file',
  25. # 显示给用户看的名称
  26. 'lang' => '资源列表',
  27. 'order' => 9,
  28. 'end' => array
  29. (
  30. //'insert' => 'upload/lib/manage.add_tag',
  31. //'update' => 'upload/lib/manage.add_tag',
  32. ),
  33. /*
  34. # 同步更新另外一个或多个表的数据
  35. 'sync' => array
  36. (
  37. 'upload/file_tag' => array
  38. (
  39. # 更新另外一个表的字段 => 本表的字段
  40. 'where' => array('file_id', 'id'),
  41. # 要更新的数据
  42. 'update' => array('tag_id' => 'tag'),
  43. # 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
  44. 'type' => 'delete',
  45. )
  46. ),*/
  47. # 数据结构
  48. 'struct' => array
  49. (
  50. 'id' => array
  51. (
  52. 'type' => 'int-11',
  53. 'name' => 'ID',
  54. 'default' => '',
  55. 'desc' => '',
  56. 'match' => 'is_numeric',
  57. 'search' => 'order',
  58. //'list' => true,
  59. ),
  60. 'name' => array
  61. (
  62. 'type' => 'varchar-32',
  63. 'name' => '文件名',
  64. 'default' => '',
  65. 'desc' => '请输入文件名',
  66. 'match' => 'is_string',
  67. 'search' => 'fulltext',
  68. //'list' => true,
  69. ),
  70. 'source_name' => array
  71. (
  72. 'type' => 'varchar-200',
  73. 'name' => '原文件名',
  74. 'default' => '',
  75. 'desc' => '请输入原文件名',
  76. 'match' => 'is_string',
  77. 'search' => 'fulltext',
  78. 'list' => true,
  79. ),
  80. 'upload' => array
  81. (
  82. 'type' => 'int-11',
  83. 'name' => '所属资源配置',
  84. 'default' => '1',
  85. 'desc' => '所属资源配置',
  86. 'match' => 'is_numeric',
  87. 'option' => $upload,
  88. //'update' => 'select',
  89. 'search' => 'select',
  90. //'control' => 'type',
  91. //'list' => true,
  92. ),
  93. 'cate' => array
  94. (
  95. 'type' => 'int-11',
  96. 'name' => '所属分类',
  97. 'default' => '1',
  98. 'desc' => '分类',
  99. 'match' => 'is_numeric',
  100. 'option' => $cate,
  101. 'update' => 'select',
  102. 'search' => 'select',
  103. //'control' => 'type',
  104. 'list' => true,
  105. 'edit' => true,
  106. ),
  107. /*
  108. 'tag' => array
  109. (
  110. 'type' => 'text-255',
  111. 'name' => '标签',
  112. 'default' => '',
  113. 'desc' => '标签',
  114. 'match' => 'is_numeric',
  115. 'update' => 'text',
  116. 'search' => 'fulltext',
  117. 'autocomplete' => array('upload/lib/manage.search_tag?json=1', 'id', 'upload/lib/manage.search_tag_by_ids'),
  118. //'control' => 'type',
  119. //'list' => true,
  120. ),
  121. */
  122. 'key' => array
  123. (
  124. 'type' => 'varchar-32',
  125. 'name' => 'key',
  126. 'default' => '',
  127. 'desc' => 'key',
  128. 'match' => 'is_string',
  129. //'search' => 'fulltext',
  130. //'list' => true,
  131. ),
  132. 'search' => array
  133. (
  134. 'type' => 'varchar-100',
  135. 'name' => 'search',
  136. 'default' => '',
  137. 'desc' => 'search',
  138. 'match' => 'is_string',
  139. //'search' => 'fulltext',
  140. //'list' => true,
  141. ),
  142. 'value' => array
  143. (
  144. 'type' => 'varchar-800',
  145. 'name' => '附加值',
  146. 'default' => '',
  147. 'desc' => '附加值',
  148. 'match' => 'is_string',
  149. //'search' => 'fulltext',
  150. //'list' => true,
  151. ),
  152. 'ext' => array
  153. (
  154. 'type' => 'varchar-24',
  155. 'name' => '后缀名',
  156. 'default' => '',
  157. 'desc' => '请输入后缀名',
  158. 'match' => 'is_string',
  159. 'list_name' => '文件信息',
  160. 'list' => 'Dever::load("upload/lib/manage.file", {id})',
  161. ),
  162. 'file' => array
  163. (
  164. 'type' => 'varchar-150',
  165. 'name' => '访问路径',
  166. 'default' => '',
  167. 'desc' => '请输入访问路径',
  168. 'match' => 'is_string',
  169. //'list' => true,
  170. ),
  171. 'yunfile' => array
  172. (
  173. 'type' => 'varchar-150',
  174. 'name' => '云端访问路径',
  175. 'default' => '',
  176. 'desc' => '云端访问路径',
  177. 'match' => 'is_string',
  178. //'list' => true,
  179. ),
  180. 'width' => array
  181. (
  182. 'type' => 'int-11',
  183. 'name' => '宽度',
  184. 'default' => '0',
  185. 'desc' => '请输入宽度',
  186. 'match' => 'option',
  187. //'list' => true,
  188. ),
  189. 'height' => array
  190. (
  191. 'type' => 'int-11',
  192. 'name' => '高度',
  193. 'default' => '0',
  194. 'desc' => '请输入高度',
  195. 'match' => 'option',
  196. //'list' => true,
  197. ),
  198. 'size' => array
  199. (
  200. 'type' => 'int-11',
  201. 'name' => '大小',
  202. 'default' => '0',
  203. 'desc' => '请输入大小',
  204. 'match' => 'option',
  205. //'list' => true,
  206. ),
  207. 'state' => array
  208. (
  209. 'type' => 'tinyint-1',
  210. 'name' => '状态',
  211. 'default' => '1',
  212. 'desc' => '请选择状态',
  213. 'match' => 'is_numeric',
  214. ),
  215. 'cdate' => array
  216. (
  217. 'type' => 'int-11',
  218. 'name' => '上传时间',
  219. 'match' => array('is_numeric', time()),
  220. 'desc' => '',
  221. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  222. ),
  223. ),
  224. # 索引
  225. 'index' => array
  226. (
  227. # 索引名 => 索引id
  228. 2 => array
  229. (
  230. 'search' => '`key`,cate,search',
  231. ),
  232. 'version' => 2,
  233. ),
  234. # 更新表结构
  235. 'alter' => array
  236. (
  237. 3 => array
  238. (
  239. array('update', 'upload', 'upload', 'int-11 1 所属资源配置'),
  240. array('update', 'size', 'size', 'varchar-100 文件大小'),
  241. //array('add', 'config', 'config', 'int-11 1 配置'),
  242. ),
  243. 'version' => 3,
  244. ),
  245. 'manage' => array
  246. (
  247. 'insert' => false,
  248. 'delete' => false,
  249. ),
  250. # request 请求接口定义
  251. 'request' => array
  252. (
  253. # info 根据文件名获取数据
  254. 'file' => array
  255. (
  256. 'where' => array
  257. (
  258. 'file' => 'is_string',
  259. ),
  260. 'type' => 'one',
  261. ),
  262. 'name' => array
  263. (
  264. 'where' => array
  265. (
  266. 'name' => 'yes',
  267. 'upload' => 'yes',
  268. ),
  269. 'type' => 'one',
  270. ),
  271. 'getData' => array
  272. (
  273. 'option' => array
  274. (
  275. 'state' => 'yes',
  276. 'upload' => 'yes',
  277. 'cate' => 'yes',
  278. 'search' => 'yes',
  279. 'source_name' => array('yes', 'like'),
  280. //'source_name' => array('yes', 'like', 'and('),
  281. //'name' => array('yes', 'like', 'or)'),
  282. ),
  283. 'order' => array('id' => 'desc'),
  284. 'type' => 'all',
  285. 'page' => array(12, 'list')
  286. ),
  287. )
  288. );