1 | <?php |
||
27 | class UploadField extends FormField implements FileHandleField |
||
28 | { |
||
29 | use FileUploadReceiver; |
||
30 | |||
31 | /** |
||
32 | * @config |
||
33 | * @var array |
||
34 | */ |
||
35 | private static $allowed_actions = [ |
||
36 | 'upload' |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @config |
||
41 | * @var int |
||
42 | */ |
||
43 | private static $thumbnail_width = 60; |
||
44 | |||
45 | /** |
||
46 | * @config |
||
47 | * @var int |
||
48 | */ |
||
49 | private static $thumbnail_height = 60; |
||
50 | |||
51 | protected $inputType = 'file'; |
||
52 | |||
53 | protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_CUSTOM; |
||
54 | |||
55 | protected $schemaComponent = 'UploadField'; |
||
56 | |||
57 | /** |
||
58 | * @var bool|null |
||
59 | */ |
||
60 | protected $multiUpload = null; |
||
61 | |||
62 | /** |
||
63 | * Create a new file field. |
||
64 | * |
||
65 | * @param string $name The internal field name, passed to forms. |
||
66 | * @param string $title The field label. |
||
67 | * @param SS_List $items Items assigned to this field |
||
68 | */ |
||
69 | public function __construct($name, $title = null, SS_List $items = null) |
||
81 | |||
82 | public function getSchemaDataDefaults() |
||
95 | |||
96 | /** |
||
97 | * Creates a single file based on a form-urlencoded upload. |
||
98 | * |
||
99 | * @param HTTPRequest $request |
||
100 | * @return HTTPResponse |
||
101 | */ |
||
102 | public function upload(HTTPRequest $request) |
||
144 | |||
145 | /** |
||
146 | * Get ID of target parent folder |
||
147 | * |
||
148 | * @return int |
||
149 | */ |
||
150 | protected function getFolderID() |
||
159 | |||
160 | public function getSchemaStateDefaults() |
||
167 | |||
168 | /** |
||
169 | * Encode selected values for react |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | protected function getEncodedItems() |
||
182 | |||
183 | /** |
||
184 | * Check if allowed to upload more than one file |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | public function getIsMultiUpload() |
||
203 | |||
204 | /** |
||
205 | * Set upload type to multi / single |
||
206 | * |
||
207 | * @param $multi |
||
208 | * @return $this |
||
209 | */ |
||
210 | public function setIsMultiUpload($multi) |
||
215 | |||
216 | public function getAttributes() |
||
233 | |||
234 | public function Type() |
||
238 | } |
||
239 |