file.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. return array
  18. (
  19. # 表名
  20. 'name' => 'file',
  21. # 显示给用户看的名称
  22. 'lang' => '资源列表',
  23. 'order' => 9,
  24. 'end' => array
  25. (
  26. //'insert' => 'upload/manage.add_tag',
  27. //'update' => 'upload/manage.add_tag',
  28. ),
  29. /*
  30. # 同步更新另外一个或多个表的数据
  31. 'sync' => array
  32. (
  33. 'upload/file_tag' => array
  34. (
  35. # 更新另外一个表的字段 => 本表的字段
  36. 'where' => array('file_id', 'id'),
  37. # 要更新的数据
  38. 'update' => array('tag_id' => 'tag'),
  39. # 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
  40. 'type' => 'delete',
  41. )
  42. ),*/
  43. # 数据结构
  44. 'struct' => array
  45. (
  46. 'id' => array
  47. (
  48. 'type' => 'int-11',
  49. 'name' => 'ID',
  50. 'default' => '',
  51. 'desc' => '',
  52. 'match' => 'is_numeric',
  53. 'search' => 'order',
  54. //'list' => true,
  55. ),
  56. 'name' => array
  57. (
  58. 'type' => 'varchar-32',
  59. 'name' => '文件名',
  60. 'default' => '',
  61. 'desc' => '请输入文件名',
  62. 'match' => 'is_string',
  63. 'search' => 'fulltext',
  64. //'list' => true,
  65. ),
  66. 'source_name' => array
  67. (
  68. 'type' => 'varchar-200',
  69. 'name' => '原文件名',
  70. 'default' => '',
  71. 'desc' => '请输入原文件名',
  72. 'match' => 'is_string',
  73. 'search' => 'fulltext',
  74. 'list' => true,
  75. ),
  76. 'cate' => array
  77. (
  78. 'type' => 'int-11',
  79. 'name' => '所属分类',
  80. 'default' => '1',
  81. 'desc' => '分类',
  82. 'match' => 'is_numeric',
  83. 'option' => $cate,
  84. 'update' => 'select',
  85. 'search' => 'select',
  86. //'control' => 'type',
  87. //'list' => true,
  88. ),
  89. 'tag' => array
  90. (
  91. 'type' => 'text-255',
  92. 'name' => '标签',
  93. 'default' => '',
  94. 'desc' => '标签',
  95. 'match' => 'is_numeric',
  96. 'update' => 'text',
  97. 'search' => 'fulltext',
  98. 'autocomplete' => array('upload/manage.search_tag?json=1', 'id', 'upload/manage.search_tag_by_ids'),
  99. //'control' => 'type',
  100. //'list' => true,
  101. ),
  102. 'key' => array
  103. (
  104. 'type' => 'varchar-32',
  105. 'name' => 'key',
  106. 'default' => '',
  107. 'desc' => 'key',
  108. 'match' => 'is_string',
  109. //'search' => 'fulltext',
  110. //'list' => true,
  111. ),
  112. 'ext' => array
  113. (
  114. 'type' => 'varchar-24',
  115. 'name' => '后缀名',
  116. 'default' => '',
  117. 'desc' => '请输入后缀名',
  118. 'match' => 'is_string',
  119. 'list_name' => '文件信息',
  120. 'list' => 'Dever::load("upload/manage.file", {id})',
  121. ),
  122. 'file' => array
  123. (
  124. 'type' => 'varchar-150',
  125. 'name' => '访问路径',
  126. 'default' => '',
  127. 'desc' => '请输入访问路径',
  128. 'match' => 'is_string',
  129. //'list' => true,
  130. ),
  131. 'width' => array
  132. (
  133. 'type' => 'int-11',
  134. 'name' => '宽度',
  135. 'default' => '0',
  136. 'desc' => '请输入宽度',
  137. 'match' => 'option',
  138. //'list' => true,
  139. ),
  140. 'height' => array
  141. (
  142. 'type' => 'int-11',
  143. 'name' => '高度',
  144. 'default' => '0',
  145. 'desc' => '请输入高度',
  146. 'match' => 'option',
  147. //'list' => true,
  148. ),
  149. 'size' => array
  150. (
  151. 'type' => 'int-11',
  152. 'name' => '大小',
  153. 'default' => '0',
  154. 'desc' => '请输入大小',
  155. 'match' => 'option',
  156. //'list' => true,
  157. ),
  158. 'state' => array
  159. (
  160. 'type' => 'tinyint-1',
  161. 'name' => '状态',
  162. 'default' => '1',
  163. 'desc' => '请选择状态',
  164. 'match' => 'is_numeric',
  165. ),
  166. 'cdate' => array
  167. (
  168. 'type' => 'int-11',
  169. 'name' => '上传时间',
  170. 'match' => array('is_numeric', time()),
  171. 'desc' => '',
  172. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  173. ),
  174. ),
  175. # request 请求接口定义
  176. 'request' => array
  177. (
  178. # info 根据文件名获取数据
  179. 'file' => array
  180. (
  181. 'where' => array
  182. (
  183. 'file' => 'is_string',
  184. ),
  185. 'type' => 'one',
  186. ),
  187. 'name' => array
  188. (
  189. 'where' => array
  190. (
  191. 'name' => 'is_string',
  192. ),
  193. 'type' => 'one',
  194. ),
  195. )
  196. );