file.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. 'ext' => array
  133. (
  134. 'type' => 'varchar-24',
  135. 'name' => '后缀名',
  136. 'default' => '',
  137. 'desc' => '请输入后缀名',
  138. 'match' => 'is_string',
  139. 'list_name' => '文件信息',
  140. 'list' => 'Dever::load("upload/lib/manage.file", {id})',
  141. ),
  142. 'file' => array
  143. (
  144. 'type' => 'varchar-150',
  145. 'name' => '访问路径',
  146. 'default' => '',
  147. 'desc' => '请输入访问路径',
  148. 'match' => 'is_string',
  149. //'list' => true,
  150. ),
  151. 'yunfile' => array
  152. (
  153. 'type' => 'varchar-150',
  154. 'name' => '云端访问路径',
  155. 'default' => '',
  156. 'desc' => '云端访问路径',
  157. 'match' => 'is_string',
  158. //'list' => true,
  159. ),
  160. 'width' => array
  161. (
  162. 'type' => 'int-11',
  163. 'name' => '宽度',
  164. 'default' => '0',
  165. 'desc' => '请输入宽度',
  166. 'match' => 'option',
  167. //'list' => true,
  168. ),
  169. 'height' => array
  170. (
  171. 'type' => 'int-11',
  172. 'name' => '高度',
  173. 'default' => '0',
  174. 'desc' => '请输入高度',
  175. 'match' => 'option',
  176. //'list' => true,
  177. ),
  178. 'size' => array
  179. (
  180. 'type' => 'int-11',
  181. 'name' => '大小',
  182. 'default' => '0',
  183. 'desc' => '请输入大小',
  184. 'match' => 'option',
  185. //'list' => true,
  186. ),
  187. 'state' => array
  188. (
  189. 'type' => 'tinyint-1',
  190. 'name' => '状态',
  191. 'default' => '1',
  192. 'desc' => '请选择状态',
  193. 'match' => 'is_numeric',
  194. ),
  195. 'cdate' => array
  196. (
  197. 'type' => 'int-11',
  198. 'name' => '上传时间',
  199. 'match' => array('is_numeric', time()),
  200. 'desc' => '',
  201. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  202. ),
  203. ),
  204. # 更新表结构
  205. 'alter' => array
  206. (
  207. 3 => array
  208. (
  209. array('update', 'upload', 'upload', 'int-11 1 所属资源配置'),
  210. array('update', 'size', 'size', 'varchar-100 文件大小'),
  211. //array('add', 'config', 'config', 'int-11 1 配置'),
  212. ),
  213. 'version' => 3,
  214. ),
  215. 'manage' => array
  216. (
  217. 'insert' => false,
  218. 'delete' => false,
  219. ),
  220. # request 请求接口定义
  221. 'request' => array
  222. (
  223. # info 根据文件名获取数据
  224. 'file' => array
  225. (
  226. 'where' => array
  227. (
  228. 'file' => 'is_string',
  229. ),
  230. 'type' => 'one',
  231. ),
  232. 'name' => array
  233. (
  234. 'where' => array
  235. (
  236. 'name' => 'yes',
  237. 'upload' => 'yes',
  238. ),
  239. 'type' => 'one',
  240. ),
  241. 'getData' => array
  242. (
  243. 'option' => array
  244. (
  245. 'state' => 1,
  246. 'upload' => 'yes',
  247. 'cate' => 'yes',
  248. 'source_name' => array('yes', 'like'),
  249. //'source_name' => array('yes', 'like', 'and('),
  250. //'name' => array('yes', 'like', 'or)'),
  251. ),
  252. 'order' => array('id' => 'desc'),
  253. 'type' => 'all',
  254. 'page' => array(12, 'list')
  255. ),
  256. )
  257. );