file.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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/manage.add_tag',
  31. //'update' => 'upload/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. ),
  106. 'tag' => array
  107. (
  108. 'type' => 'text-255',
  109. 'name' => '标签',
  110. 'default' => '',
  111. 'desc' => '标签',
  112. 'match' => 'is_numeric',
  113. 'update' => 'text',
  114. 'search' => 'fulltext',
  115. 'autocomplete' => array('upload/manage.search_tag?json=1', 'id', 'upload/manage.search_tag_by_ids'),
  116. //'control' => 'type',
  117. //'list' => true,
  118. ),
  119. 'key' => array
  120. (
  121. 'type' => 'varchar-32',
  122. 'name' => 'key',
  123. 'default' => '',
  124. 'desc' => 'key',
  125. 'match' => 'is_string',
  126. //'search' => 'fulltext',
  127. //'list' => true,
  128. ),
  129. 'ext' => array
  130. (
  131. 'type' => 'varchar-24',
  132. 'name' => '后缀名',
  133. 'default' => '',
  134. 'desc' => '请输入后缀名',
  135. 'match' => 'is_string',
  136. 'list_name' => '文件信息',
  137. 'list' => 'Dever::load("upload/manage.file", {id})',
  138. ),
  139. 'file' => array
  140. (
  141. 'type' => 'varchar-150',
  142. 'name' => '访问路径',
  143. 'default' => '',
  144. 'desc' => '请输入访问路径',
  145. 'match' => 'is_string',
  146. //'list' => true,
  147. ),
  148. 'width' => array
  149. (
  150. 'type' => 'int-11',
  151. 'name' => '宽度',
  152. 'default' => '0',
  153. 'desc' => '请输入宽度',
  154. 'match' => 'option',
  155. //'list' => true,
  156. ),
  157. 'height' => array
  158. (
  159. 'type' => 'int-11',
  160. 'name' => '高度',
  161. 'default' => '0',
  162. 'desc' => '请输入高度',
  163. 'match' => 'option',
  164. //'list' => true,
  165. ),
  166. 'size' => array
  167. (
  168. 'type' => 'int-11',
  169. 'name' => '大小',
  170. 'default' => '0',
  171. 'desc' => '请输入大小',
  172. 'match' => 'option',
  173. //'list' => true,
  174. ),
  175. 'state' => array
  176. (
  177. 'type' => 'tinyint-1',
  178. 'name' => '状态',
  179. 'default' => '1',
  180. 'desc' => '请选择状态',
  181. 'match' => 'is_numeric',
  182. ),
  183. 'cdate' => array
  184. (
  185. 'type' => 'int-11',
  186. 'name' => '上传时间',
  187. 'match' => array('is_numeric', time()),
  188. 'desc' => '',
  189. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  190. ),
  191. ),
  192. # request 请求接口定义
  193. 'request' => array
  194. (
  195. # info 根据文件名获取数据
  196. 'file' => array
  197. (
  198. 'where' => array
  199. (
  200. 'file' => 'is_string',
  201. ),
  202. 'type' => 'one',
  203. ),
  204. 'name' => array
  205. (
  206. 'where' => array
  207. (
  208. 'name' => 'is_string',
  209. ),
  210. 'type' => 'one',
  211. ),
  212. )
  213. );