@@ -49,7 +49,7 @@ |
||
49 | 49 | // Work around a bug in BackendUtility::getModuleUrl if matches is empty getModuleUrl() will not return the parameter. |
50 | 50 | $matches = $this->templateVariableContainer->get('matches'); |
51 | 51 | if (empty($matches)) { |
52 | - $moduleUrl .= '&' . urlencode(VidiModule::getParameterPrefix() . '[matches]='); |
|
52 | + $moduleUrl .= '&'.urlencode(VidiModule::getParameterPrefix().'[matches]='); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return $moduleUrl; |
@@ -18,33 +18,33 @@ |
||
18 | 18 | */ |
19 | 19 | class MoveViewHelper extends AbstractViewHelper |
20 | 20 | { |
21 | - /** |
|
22 | - * Render a move storage URI. |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render() |
|
27 | - { |
|
28 | - $urlParameters = array( |
|
29 | - VidiModule::getParameterPrefix() => array( |
|
30 | - 'controller' => 'Content', |
|
31 | - 'action' => 'move', |
|
32 | - 'fieldNameAndPath' => $this->templateVariableContainer->get('fieldNameAndPath'), |
|
33 | - 'matches' => $this->templateVariableContainer->get('matches'), |
|
34 | - ), |
|
35 | - ); |
|
21 | + /** |
|
22 | + * Render a move storage URI. |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render() |
|
27 | + { |
|
28 | + $urlParameters = array( |
|
29 | + VidiModule::getParameterPrefix() => array( |
|
30 | + 'controller' => 'Content', |
|
31 | + 'action' => 'move', |
|
32 | + 'fieldNameAndPath' => $this->templateVariableContainer->get('fieldNameAndPath'), |
|
33 | + 'matches' => $this->templateVariableContainer->get('matches'), |
|
34 | + ), |
|
35 | + ); |
|
36 | 36 | |
37 | - $moduleUrl = BackendUtility::getModuleUrl( |
|
38 | - VidiModule::getSignature(), |
|
39 | - $urlParameters |
|
40 | - ); |
|
37 | + $moduleUrl = BackendUtility::getModuleUrl( |
|
38 | + VidiModule::getSignature(), |
|
39 | + $urlParameters |
|
40 | + ); |
|
41 | 41 | |
42 | - // Work around a bug in BackendUtility::getModuleUrl if matches is empty getModuleUrl() will not return the parameter. |
|
43 | - $matches = $this->templateVariableContainer->get('matches'); |
|
44 | - if (empty($matches)) { |
|
45 | - $moduleUrl .= '&' . urlencode(VidiModule::getParameterPrefix() . '[matches]='); |
|
46 | - } |
|
42 | + // Work around a bug in BackendUtility::getModuleUrl if matches is empty getModuleUrl() will not return the parameter. |
|
43 | + $matches = $this->templateVariableContainer->get('matches'); |
|
44 | + if (empty($matches)) { |
|
45 | + $moduleUrl .= '&' . urlencode(VidiModule::getParameterPrefix() . '[matches]='); |
|
46 | + } |
|
47 | 47 | |
48 | - return $moduleUrl; |
|
49 | - } |
|
48 | + return $moduleUrl; |
|
49 | + } |
|
50 | 50 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $permission .= 'W'; |
43 | 43 | } |
44 | 44 | |
45 | - return '<strong>' . $permission . '</strong>'; |
|
45 | + return '<strong>'.$permission.'</strong>'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -17,32 +17,32 @@ |
||
17 | 17 | */ |
18 | 18 | class ActionPermissionColumn extends ColumnRendererAbstract |
19 | 19 | { |
20 | - /** |
|
21 | - * Renders a configurable metadata property of a file in the Grid. |
|
22 | - * |
|
23 | - * @throws \Exception |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render() |
|
27 | - { |
|
28 | - $file = $this->getFileConverter()->convert($this->object); |
|
29 | - $permission = ''; |
|
20 | + /** |
|
21 | + * Renders a configurable metadata property of a file in the Grid. |
|
22 | + * |
|
23 | + * @throws \Exception |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render() |
|
27 | + { |
|
28 | + $file = $this->getFileConverter()->convert($this->object); |
|
29 | + $permission = ''; |
|
30 | 30 | |
31 | - if ($file->checkActionPermission('read')) { |
|
32 | - $permission = 'R'; |
|
33 | - } |
|
34 | - if ($file->checkActionPermission('write')) { |
|
35 | - $permission .= 'W'; |
|
36 | - } |
|
31 | + if ($file->checkActionPermission('read')) { |
|
32 | + $permission = 'R'; |
|
33 | + } |
|
34 | + if ($file->checkActionPermission('write')) { |
|
35 | + $permission .= 'W'; |
|
36 | + } |
|
37 | 37 | |
38 | - return '<strong>' . $permission . '</strong>'; |
|
39 | - } |
|
38 | + return '<strong>' . $permission . '</strong>'; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return ContentToFileConverter|object |
|
43 | - */ |
|
44 | - protected function getFileConverter() |
|
45 | - { |
|
46 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @return ContentToFileConverter|object |
|
43 | + */ |
|
44 | + protected function getFileConverter() |
|
45 | + { |
|
46 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
47 | + } |
|
48 | 48 | } |
@@ -131,7 +131,7 @@ |
||
131 | 131 | reset($attribute); |
132 | 132 | $key = key($attribute); |
133 | 133 | if (!is_string($key)) { |
134 | - throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
134 | + throw new InvalidStringException('Not an associative array. Is not a key: '.$key, 1356478742); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $this->attributes[$key] = $attribute[$key]; |
@@ -18,268 +18,268 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class AbstractFormField implements FormFieldInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $template = ''; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $value = ''; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $name = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $id = ''; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $prefix = ''; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - protected $label = ''; |
|
50 | - |
|
51 | - /** |
|
52 | - * Store what child element will contain this element. |
|
53 | - * |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - protected $items = []; |
|
57 | - |
|
58 | - /** |
|
59 | - * Attributes in sense of DOM attribute, e.g. class, style, etc... |
|
60 | - * |
|
61 | - * @var array |
|
62 | - */ |
|
63 | - protected $attributes = []; |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function render(): string |
|
69 | - { |
|
70 | - return $this->template; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Render the label if possible. Otherwise return an empty string. |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function renderLabel() |
|
79 | - { |
|
80 | - $result = ''; |
|
81 | - if ($this->label) { |
|
82 | - $template = '<label class="control-label" for="%s">%s</label>'; |
|
83 | - |
|
84 | - if (strpos($this->label, 'LLL:') === 0) { |
|
85 | - $this->label = LocalizationUtility::translate($this->label, ''); |
|
86 | - } |
|
87 | - |
|
88 | - $result = sprintf( |
|
89 | - $template, |
|
90 | - $this->getId(), |
|
91 | - $this->label |
|
92 | - ); |
|
93 | - } |
|
94 | - return $result; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Render additional attribute for this DOM element. |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function renderAttributes() |
|
103 | - { |
|
104 | - $result = ''; |
|
105 | - if (!empty($this->attributes)) { |
|
106 | - foreach ($this->attributes as $attribute => $value) { |
|
107 | - $result .= sprintf( |
|
108 | - '%s="%s" ', |
|
109 | - htmlspecialchars($attribute), |
|
110 | - htmlspecialchars($value) |
|
111 | - ); |
|
112 | - } |
|
113 | - } |
|
114 | - return $result; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Add an additional (DOM) attribute to be added to this template. |
|
119 | - * |
|
120 | - * @throws InvalidStringException |
|
121 | - * @param array $attribute associative array that contains attribute => value |
|
122 | - * @return \Fab\Media\Form\AbstractFormField |
|
123 | - */ |
|
124 | - public function addAttribute(array $attribute) |
|
125 | - { |
|
126 | - if (!empty($attribute)) { |
|
127 | - reset($attribute); |
|
128 | - $key = key($attribute); |
|
129 | - if (!is_string($key)) { |
|
130 | - throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
131 | - } |
|
132 | - |
|
133 | - $this->attributes[$key] = $attribute[$key]; |
|
134 | - } |
|
135 | - return $this; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function getTemplate() |
|
142 | - { |
|
143 | - return $this->template; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @param string $template |
|
148 | - * @return \Fab\Media\Form\AbstractFormField |
|
149 | - */ |
|
150 | - public function setTemplate($template) |
|
151 | - { |
|
152 | - $this->template = $template; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getLabel() |
|
159 | - { |
|
160 | - return $this->label; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @param string $label |
|
165 | - * @return \Fab\Media\Form\AbstractFormField |
|
166 | - */ |
|
167 | - public function setLabel($label) |
|
168 | - { |
|
169 | - $this->label = $label; |
|
170 | - return $this; |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function getPrefix() |
|
177 | - { |
|
178 | - return $this->prefix; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * @param string $prefix |
|
183 | - * @return \Fab\Media\Form\AbstractFormField |
|
184 | - */ |
|
185 | - public function setPrefix($prefix) |
|
186 | - { |
|
187 | - $this->prefix = $prefix; |
|
188 | - return $this; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * @return array |
|
193 | - */ |
|
194 | - public function getItems() |
|
195 | - { |
|
196 | - return $this->items; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @param array $items |
|
201 | - */ |
|
202 | - public function setItems($items) |
|
203 | - { |
|
204 | - $this->items = $items; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - public function getValue() |
|
211 | - { |
|
212 | - return htmlspecialchars($this->value); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @param string $value |
|
217 | - * @return \Fab\Media\Form\AbstractFormField |
|
218 | - */ |
|
219 | - public function setValue($value) |
|
220 | - { |
|
221 | - $this->value = $value; |
|
222 | - return $this; |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * @return string |
|
227 | - */ |
|
228 | - public function getName() |
|
229 | - { |
|
230 | - $result = $this->name; |
|
231 | - if ($this->getPrefix()) { |
|
232 | - $result = sprintf('%s[%s]', $this->getPrefix(), $this->name); |
|
233 | - } |
|
234 | - return $result; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @param string $name |
|
239 | - * @return \Fab\Media\Form\AbstractFormField |
|
240 | - */ |
|
241 | - public function setName($name) |
|
242 | - { |
|
243 | - $this->name = $name; |
|
244 | - return $this; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public function getId() |
|
251 | - { |
|
252 | - if ($this->id === '') { |
|
253 | - $this->id = DomElement::getInstance()->formatId($this->getName()); |
|
254 | - } |
|
255 | - return $this->id; |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * @param string $id |
|
260 | - * @return \Fab\Media\Form\AbstractFormField |
|
261 | - */ |
|
262 | - public function setId($id) |
|
263 | - { |
|
264 | - $this->id = $id; |
|
265 | - return $this; |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * @return array |
|
270 | - */ |
|
271 | - public function getAttributes() |
|
272 | - { |
|
273 | - return $this->attributes; |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * @param array $attributes |
|
278 | - * @return \Fab\Media\Form\AbstractFormField |
|
279 | - */ |
|
280 | - public function setAttributes($attributes) |
|
281 | - { |
|
282 | - $this->attributes = $attributes; |
|
283 | - return $this; |
|
284 | - } |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $template = ''; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $value = ''; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $name = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $id = ''; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $prefix = ''; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + protected $label = ''; |
|
50 | + |
|
51 | + /** |
|
52 | + * Store what child element will contain this element. |
|
53 | + * |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + protected $items = []; |
|
57 | + |
|
58 | + /** |
|
59 | + * Attributes in sense of DOM attribute, e.g. class, style, etc... |
|
60 | + * |
|
61 | + * @var array |
|
62 | + */ |
|
63 | + protected $attributes = []; |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function render(): string |
|
69 | + { |
|
70 | + return $this->template; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Render the label if possible. Otherwise return an empty string. |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function renderLabel() |
|
79 | + { |
|
80 | + $result = ''; |
|
81 | + if ($this->label) { |
|
82 | + $template = '<label class="control-label" for="%s">%s</label>'; |
|
83 | + |
|
84 | + if (strpos($this->label, 'LLL:') === 0) { |
|
85 | + $this->label = LocalizationUtility::translate($this->label, ''); |
|
86 | + } |
|
87 | + |
|
88 | + $result = sprintf( |
|
89 | + $template, |
|
90 | + $this->getId(), |
|
91 | + $this->label |
|
92 | + ); |
|
93 | + } |
|
94 | + return $result; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Render additional attribute for this DOM element. |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function renderAttributes() |
|
103 | + { |
|
104 | + $result = ''; |
|
105 | + if (!empty($this->attributes)) { |
|
106 | + foreach ($this->attributes as $attribute => $value) { |
|
107 | + $result .= sprintf( |
|
108 | + '%s="%s" ', |
|
109 | + htmlspecialchars($attribute), |
|
110 | + htmlspecialchars($value) |
|
111 | + ); |
|
112 | + } |
|
113 | + } |
|
114 | + return $result; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Add an additional (DOM) attribute to be added to this template. |
|
119 | + * |
|
120 | + * @throws InvalidStringException |
|
121 | + * @param array $attribute associative array that contains attribute => value |
|
122 | + * @return \Fab\Media\Form\AbstractFormField |
|
123 | + */ |
|
124 | + public function addAttribute(array $attribute) |
|
125 | + { |
|
126 | + if (!empty($attribute)) { |
|
127 | + reset($attribute); |
|
128 | + $key = key($attribute); |
|
129 | + if (!is_string($key)) { |
|
130 | + throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
131 | + } |
|
132 | + |
|
133 | + $this->attributes[$key] = $attribute[$key]; |
|
134 | + } |
|
135 | + return $this; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function getTemplate() |
|
142 | + { |
|
143 | + return $this->template; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @param string $template |
|
148 | + * @return \Fab\Media\Form\AbstractFormField |
|
149 | + */ |
|
150 | + public function setTemplate($template) |
|
151 | + { |
|
152 | + $this->template = $template; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getLabel() |
|
159 | + { |
|
160 | + return $this->label; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @param string $label |
|
165 | + * @return \Fab\Media\Form\AbstractFormField |
|
166 | + */ |
|
167 | + public function setLabel($label) |
|
168 | + { |
|
169 | + $this->label = $label; |
|
170 | + return $this; |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function getPrefix() |
|
177 | + { |
|
178 | + return $this->prefix; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * @param string $prefix |
|
183 | + * @return \Fab\Media\Form\AbstractFormField |
|
184 | + */ |
|
185 | + public function setPrefix($prefix) |
|
186 | + { |
|
187 | + $this->prefix = $prefix; |
|
188 | + return $this; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * @return array |
|
193 | + */ |
|
194 | + public function getItems() |
|
195 | + { |
|
196 | + return $this->items; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @param array $items |
|
201 | + */ |
|
202 | + public function setItems($items) |
|
203 | + { |
|
204 | + $this->items = $items; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + public function getValue() |
|
211 | + { |
|
212 | + return htmlspecialchars($this->value); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @param string $value |
|
217 | + * @return \Fab\Media\Form\AbstractFormField |
|
218 | + */ |
|
219 | + public function setValue($value) |
|
220 | + { |
|
221 | + $this->value = $value; |
|
222 | + return $this; |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * @return string |
|
227 | + */ |
|
228 | + public function getName() |
|
229 | + { |
|
230 | + $result = $this->name; |
|
231 | + if ($this->getPrefix()) { |
|
232 | + $result = sprintf('%s[%s]', $this->getPrefix(), $this->name); |
|
233 | + } |
|
234 | + return $result; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @param string $name |
|
239 | + * @return \Fab\Media\Form\AbstractFormField |
|
240 | + */ |
|
241 | + public function setName($name) |
|
242 | + { |
|
243 | + $this->name = $name; |
|
244 | + return $this; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public function getId() |
|
251 | + { |
|
252 | + if ($this->id === '') { |
|
253 | + $this->id = DomElement::getInstance()->formatId($this->getName()); |
|
254 | + } |
|
255 | + return $this->id; |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * @param string $id |
|
260 | + * @return \Fab\Media\Form\AbstractFormField |
|
261 | + */ |
|
262 | + public function setId($id) |
|
263 | + { |
|
264 | + $this->id = $id; |
|
265 | + return $this; |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * @return array |
|
270 | + */ |
|
271 | + public function getAttributes() |
|
272 | + { |
|
273 | + return $this->attributes; |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * @param array $attributes |
|
278 | + * @return \Fab\Media\Form\AbstractFormField |
|
279 | + */ |
|
280 | + public function setAttributes($attributes) |
|
281 | + { |
|
282 | + $this->attributes = $attributes; |
|
283 | + return $this; |
|
284 | + } |
|
285 | 285 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
45 | 45 | ->render(); |
46 | 46 | |
47 | - $output = '<div style="float: left;">' . $button . '</div>'; |
|
47 | + $output = '<div style="float: left;">'.$button.'</div>'; |
|
48 | 48 | } |
49 | 49 | return $output; |
50 | 50 | } |
@@ -21,98 +21,98 @@ |
||
21 | 21 | */ |
22 | 22 | class NewFolder extends AbstractComponentView |
23 | 23 | { |
24 | - /** |
|
25 | - * Renders a button to create a new folder. |
|
26 | - * |
|
27 | - * @param Content $object |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function render($object = null) |
|
31 | - { |
|
32 | - $output = ''; |
|
33 | - if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) { |
|
34 | - $button = $this->makeLinkButton() |
|
35 | - ->setHref($this->getNewFolderUri()) |
|
36 | - ->setTitle($this->getLabel()) |
|
37 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
38 | - ->render(); |
|
24 | + /** |
|
25 | + * Renders a button to create a new folder. |
|
26 | + * |
|
27 | + * @param Content $object |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function render($object = null) |
|
31 | + { |
|
32 | + $output = ''; |
|
33 | + if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) { |
|
34 | + $button = $this->makeLinkButton() |
|
35 | + ->setHref($this->getNewFolderUri()) |
|
36 | + ->setTitle($this->getLabel()) |
|
37 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
38 | + ->render(); |
|
39 | 39 | |
40 | - $output = '<div style="float: left;">' . $button . '</div>'; |
|
41 | - } |
|
42 | - return $output; |
|
43 | - } |
|
40 | + $output = '<div style="float: left;">' . $button . '</div>'; |
|
41 | + } |
|
42 | + return $output; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - protected function getLabel() |
|
49 | - { |
|
50 | - return $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'); |
|
51 | - } |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + protected function getLabel() |
|
49 | + { |
|
50 | + return $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - protected function getNewFolderUri() |
|
57 | - { |
|
58 | - return BackendUtility::getModuleUrl( |
|
59 | - 'file_newfolder', |
|
60 | - array( |
|
61 | - 'target' => $this->getCombineIdentifier(), |
|
62 | - 'returnUrl' => $this->getReturnUrl(), |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + protected function getNewFolderUri() |
|
57 | + { |
|
58 | + return BackendUtility::getModuleUrl( |
|
59 | + 'file_newfolder', |
|
60 | + array( |
|
61 | + 'target' => $this->getCombineIdentifier(), |
|
62 | + 'returnUrl' => $this->getReturnUrl(), |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - protected function getCombineIdentifier() |
|
72 | - { |
|
73 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
74 | - return $folder->getCombinedIdentifier(); |
|
75 | - } |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + protected function getCombineIdentifier() |
|
72 | + { |
|
73 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
74 | + return $folder->getCombinedIdentifier(); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - protected function getReturnUrl() |
|
81 | - { |
|
82 | - $returnUrl = BackendUtility::getModuleUrl( |
|
83 | - GeneralUtility::_GP('route'), |
|
84 | - $this->getAdditionalParameters() |
|
85 | - ); |
|
86 | - return $returnUrl; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + protected function getReturnUrl() |
|
81 | + { |
|
82 | + $returnUrl = BackendUtility::getModuleUrl( |
|
83 | + GeneralUtility::_GP('route'), |
|
84 | + $this->getAdditionalParameters() |
|
85 | + ); |
|
86 | + return $returnUrl; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function getAdditionalParameters() |
|
93 | - { |
|
94 | - $additionalParameters = []; |
|
95 | - if (GeneralUtility::_GP('id')) { |
|
96 | - $additionalParameters = [ |
|
97 | - 'id' => urldecode(GeneralUtility::_GP('id')), |
|
98 | - ]; |
|
99 | - } |
|
100 | - return $additionalParameters; |
|
101 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function getAdditionalParameters() |
|
93 | + { |
|
94 | + $additionalParameters = []; |
|
95 | + if (GeneralUtility::_GP('id')) { |
|
96 | + $additionalParameters = [ |
|
97 | + 'id' => urldecode(GeneralUtility::_GP('id')), |
|
98 | + ]; |
|
99 | + } |
|
100 | + return $additionalParameters; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @return MediaModule|object |
|
105 | - */ |
|
106 | - protected function getMediaModule() |
|
107 | - { |
|
108 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
109 | - } |
|
103 | + /** |
|
104 | + * @return MediaModule|object |
|
105 | + */ |
|
106 | + protected function getMediaModule() |
|
107 | + { |
|
108 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return LanguageService |
|
113 | - */ |
|
114 | - protected function getLanguageService() |
|
115 | - { |
|
116 | - return $GLOBALS['LANG']; |
|
117 | - } |
|
111 | + /** |
|
112 | + * @return LanguageService |
|
113 | + */ |
|
114 | + protected function getLanguageService() |
|
115 | + { |
|
116 | + return $GLOBALS['LANG']; |
|
117 | + } |
|
118 | 118 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | use Fab\Media\Tests\Functional\AbstractFunctionalTestCase; |
18 | 18 | |
19 | -require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php'; |
|
19 | +require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Test case for class \Fab\Media\Utility\Configuration. |
@@ -24,69 +24,69 @@ |
||
24 | 24 | */ |
25 | 25 | class ConfigurationUtilityTest extends AbstractFunctionalTestCase |
26 | 26 | { |
27 | - /** |
|
28 | - * @var ConfigurationUtility |
|
29 | - */ |
|
30 | - private $fixture; |
|
27 | + /** |
|
28 | + * @var ConfigurationUtility |
|
29 | + */ |
|
30 | + private $fixture; |
|
31 | 31 | |
32 | - public function setUp() |
|
33 | - { |
|
34 | - parent::setUp(); |
|
35 | - $this->fixture = new ConfigurationUtility(); |
|
36 | - } |
|
32 | + public function setUp() |
|
33 | + { |
|
34 | + parent::setUp(); |
|
35 | + $this->fixture = new ConfigurationUtility(); |
|
36 | + } |
|
37 | 37 | |
38 | - public function tearDown() |
|
39 | - { |
|
40 | - unset($this->fixture); |
|
41 | - } |
|
38 | + public function tearDown() |
|
39 | + { |
|
40 | + unset($this->fixture); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @test |
|
45 | - */ |
|
46 | - public function getConfigurationReturnNotEmptyArrayByDefault() |
|
47 | - { |
|
48 | - $actual = $this->fixture->getConfiguration(); |
|
49 | - $this->assertTrue(is_array($actual)); |
|
50 | - $this->assertNotEmpty($actual); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @test |
|
45 | + */ |
|
46 | + public function getConfigurationReturnNotEmptyArrayByDefault() |
|
47 | + { |
|
48 | + $actual = $this->fixture->getConfiguration(); |
|
49 | + $this->assertTrue(is_array($actual)); |
|
50 | + $this->assertNotEmpty($actual); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @test |
|
55 | - */ |
|
56 | - public function thumbnailSizeSettingReturnsNotEmpty() |
|
57 | - { |
|
58 | - $actual = $this->fixture->get('image_thumbnail'); |
|
59 | - $this->assertTrue($actual > 1); |
|
60 | - } |
|
53 | + /** |
|
54 | + * @test |
|
55 | + */ |
|
56 | + public function thumbnailSizeSettingReturnsNotEmpty() |
|
57 | + { |
|
58 | + $actual = $this->fixture->get('image_thumbnail'); |
|
59 | + $this->assertTrue($actual > 1); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @test |
|
64 | - */ |
|
65 | - public function getFooValueReturnsEmpty() |
|
66 | - { |
|
67 | - $expected = ''; |
|
68 | - $actual = $this->fixture->get(uniqid('foo')); |
|
69 | - $this->assertEquals($expected, $actual); |
|
70 | - } |
|
62 | + /** |
|
63 | + * @test |
|
64 | + */ |
|
65 | + public function getFooValueReturnsEmpty() |
|
66 | + { |
|
67 | + $expected = ''; |
|
68 | + $actual = $this->fixture->get(uniqid('foo')); |
|
69 | + $this->assertEquals($expected, $actual); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @test |
|
74 | - */ |
|
75 | - public function configurationArrayNotEmptyAfterGetARandomValue() |
|
76 | - { |
|
77 | - $this->fixture->get(uniqid('foo')); |
|
72 | + /** |
|
73 | + * @test |
|
74 | + */ |
|
75 | + public function configurationArrayNotEmptyAfterGetARandomValue() |
|
76 | + { |
|
77 | + $this->fixture->get(uniqid('foo')); |
|
78 | 78 | |
79 | - $actual = $this->fixture->getConfiguration(); |
|
80 | - $this->assertTrue(count($actual) > 0); |
|
81 | - } |
|
79 | + $actual = $this->fixture->getConfiguration(); |
|
80 | + $this->assertTrue(count($actual) > 0); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @test |
|
85 | - */ |
|
86 | - public function setConfigurationValueAndCheckReturnedValueIsCorresponding() |
|
87 | - { |
|
88 | - $expected = 'bar'; |
|
89 | - $this->fixture->set('foo', $expected); |
|
90 | - $this->assertSame($expected, $this->fixture->get('foo')); |
|
91 | - } |
|
83 | + /** |
|
84 | + * @test |
|
85 | + */ |
|
86 | + public function setConfigurationValueAndCheckReturnedValueIsCorresponding() |
|
87 | + { |
|
88 | + $expected = 'bar'; |
|
89 | + $this->fixture->set('foo', $expected); |
|
90 | + $this->assertSame($expected, $this->fixture->get('foo')); |
|
91 | + } |
|
92 | 92 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $tca = [ |
13 | 13 | 'types' => [ |
14 | - 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
14 | + 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'].', |
|
15 | 15 | |
16 | 16 | --div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.upload_settings, |
17 | 17 | maximum_dimension_original_image, extension_allowed_file_type_1, extension_allowed_file_type_2, extension_allowed_file_type_3, extension_allowed_file_type_4, extension_allowed_file_type_5, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $tcaForHiddenFolderTree = [ |
82 | 82 | |
83 | 83 | 'types' => [ |
84 | - 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
84 | + 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'].', |
|
85 | 85 | |
86 | 86 | --div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.media_mount_point, |
87 | 87 | mount_point_file_type_1, mount_point_file_type_2, mount_point_file_type_3, mount_point_file_type_4, mount_point_file_type_5, |
@@ -5,86 +5,86 @@ discard block |
||
5 | 5 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
6 | 6 | |
7 | 7 | if (!defined('TYPO3')) { |
8 | - die('Access denied.'); |
|
8 | + die('Access denied.'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | $configuration = GeneralUtility::makeInstance( |
12 | - ExtensionConfiguration::class |
|
12 | + ExtensionConfiguration::class |
|
13 | 13 | )->get('media'); |
14 | 14 | |
15 | 15 | $tca = [ |
16 | - 'types' => [ |
|
17 | - 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
16 | + 'types' => [ |
|
17 | + 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
18 | 18 | |
19 | 19 | --div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.upload_settings, |
20 | 20 | maximum_dimension_original_image, extension_allowed_file_type_1, extension_allowed_file_type_2, extension_allowed_file_type_3, extension_allowed_file_type_4, extension_allowed_file_type_5, |
21 | 21 | ', |
22 | - ], |
|
23 | - ], |
|
24 | - 'columns' => [ |
|
25 | - 'maximum_dimension_original_image' => [ |
|
26 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.maximum_dimension_original_image', |
|
27 | - 'config' => [ |
|
28 | - 'type' => 'input', |
|
29 | - 'size' => 24, |
|
30 | - 'default' => '1920x1920', |
|
31 | - 'eval' => 'trim', |
|
32 | - ], |
|
33 | - ], |
|
34 | - 'extension_allowed_file_type_1' => [ |
|
35 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_1', |
|
36 | - 'config' => [ |
|
37 | - 'type' => 'input', |
|
38 | - 'size' => 255, |
|
39 | - 'default' => 'txt, html', |
|
40 | - 'eval' => 'trim', |
|
41 | - ], |
|
42 | - ], |
|
43 | - 'extension_allowed_file_type_2' => [ |
|
44 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_2', |
|
45 | - 'config' => [ |
|
46 | - 'type' => 'input', |
|
47 | - 'size' => 255, |
|
48 | - 'default' => 'jpg, jpeg, bmp, png, tiff, tif, gif, eps', |
|
49 | - 'eval' => 'trim', |
|
50 | - ], |
|
51 | - ], |
|
52 | - 'extension_allowed_file_type_3' => [ |
|
53 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_3', |
|
54 | - 'config' => [ |
|
55 | - 'type' => 'input', |
|
56 | - 'size' => 255, |
|
57 | - 'default' => 'mp3, mp4, m4a, wma, f4a', |
|
58 | - 'eval' => 'trim', |
|
59 | - ], |
|
60 | - ], |
|
61 | - 'extension_allowed_file_type_4' => [ |
|
62 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_4', |
|
63 | - 'config' => [ |
|
64 | - 'type' => 'input', |
|
65 | - 'size' => 255, |
|
66 | - 'default' => 'mov, avi, mpeg, mpg, mp4, m4v, flv, f4v, webm, wmv, ogv, 3gp', |
|
67 | - 'eval' => 'trim', |
|
68 | - ], |
|
69 | - ], |
|
70 | - 'extension_allowed_file_type_5' => [ |
|
71 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_5', |
|
72 | - 'config' => [ |
|
73 | - 'type' => 'input', |
|
74 | - 'size' => 255, |
|
75 | - 'default' => 'pdf, zip, doc, docx, dotx, ppt, pptx, pps, ppsx, odt, xls, xlsx, xltx, rtf, xlt', |
|
76 | - 'eval' => 'trim', |
|
77 | - ], |
|
78 | - ], |
|
79 | - ], |
|
22 | + ], |
|
23 | + ], |
|
24 | + 'columns' => [ |
|
25 | + 'maximum_dimension_original_image' => [ |
|
26 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.maximum_dimension_original_image', |
|
27 | + 'config' => [ |
|
28 | + 'type' => 'input', |
|
29 | + 'size' => 24, |
|
30 | + 'default' => '1920x1920', |
|
31 | + 'eval' => 'trim', |
|
32 | + ], |
|
33 | + ], |
|
34 | + 'extension_allowed_file_type_1' => [ |
|
35 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_1', |
|
36 | + 'config' => [ |
|
37 | + 'type' => 'input', |
|
38 | + 'size' => 255, |
|
39 | + 'default' => 'txt, html', |
|
40 | + 'eval' => 'trim', |
|
41 | + ], |
|
42 | + ], |
|
43 | + 'extension_allowed_file_type_2' => [ |
|
44 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_2', |
|
45 | + 'config' => [ |
|
46 | + 'type' => 'input', |
|
47 | + 'size' => 255, |
|
48 | + 'default' => 'jpg, jpeg, bmp, png, tiff, tif, gif, eps', |
|
49 | + 'eval' => 'trim', |
|
50 | + ], |
|
51 | + ], |
|
52 | + 'extension_allowed_file_type_3' => [ |
|
53 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_3', |
|
54 | + 'config' => [ |
|
55 | + 'type' => 'input', |
|
56 | + 'size' => 255, |
|
57 | + 'default' => 'mp3, mp4, m4a, wma, f4a', |
|
58 | + 'eval' => 'trim', |
|
59 | + ], |
|
60 | + ], |
|
61 | + 'extension_allowed_file_type_4' => [ |
|
62 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_4', |
|
63 | + 'config' => [ |
|
64 | + 'type' => 'input', |
|
65 | + 'size' => 255, |
|
66 | + 'default' => 'mov, avi, mpeg, mpg, mp4, m4v, flv, f4v, webm, wmv, ogv, 3gp', |
|
67 | + 'eval' => 'trim', |
|
68 | + ], |
|
69 | + ], |
|
70 | + 'extension_allowed_file_type_5' => [ |
|
71 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.extension_allowed_file_type_5', |
|
72 | + 'config' => [ |
|
73 | + 'type' => 'input', |
|
74 | + 'size' => 255, |
|
75 | + 'default' => 'pdf, zip, doc, docx, dotx, ppt, pptx, pps, ppsx, odt, xls, xlsx, xltx, rtf, xlt', |
|
76 | + 'eval' => 'trim', |
|
77 | + ], |
|
78 | + ], |
|
79 | + ], |
|
80 | 80 | ]; |
81 | 81 | |
82 | 82 | $tcaForHiddenFolderTree = []; |
83 | 83 | if (!$configuration['has_folder_tree']) { |
84 | - $tcaForHiddenFolderTree = [ |
|
84 | + $tcaForHiddenFolderTree = [ |
|
85 | 85 | |
86 | - 'types' => [ |
|
87 | - 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
86 | + 'types' => [ |
|
87 | + 0 => ['showitem' => $GLOBALS['TCA']['sys_file_storage']['types'][0]['showitem'] . ', |
|
88 | 88 | |
89 | 89 | --div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.media_mount_point, |
90 | 90 | mount_point_file_type_1, mount_point_file_type_2, mount_point_file_type_3, mount_point_file_type_4, mount_point_file_type_5, |
@@ -93,121 +93,121 @@ discard block |
||
93 | 93 | maximum_dimension_original_image, extension_allowed_file_type_1, extension_allowed_file_type_2, extension_allowed_file_type_3, extension_allowed_file_type_4, extension_allowed_file_type_5, |
94 | 94 | ', |
95 | 95 | |
96 | - ], |
|
97 | - ], |
|
98 | - 'columns' => [ |
|
99 | - 'mount_point_file_type_1' => [ |
|
100 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_1', |
|
101 | - 'config' => [ |
|
102 | - 'type' => 'group', |
|
103 | - 'allowed' => 'sys_filemounts', |
|
104 | - 'size' => 1, |
|
105 | - 'minitems' => 0, |
|
106 | - 'maxitems' => 1, |
|
107 | - 'wizards' => [ |
|
108 | - 'edit' => [ |
|
109 | - 'type' => 'popup', |
|
110 | - 'module' => [ |
|
111 | - 'name' => 'wizard_edit', |
|
112 | - ], |
|
113 | - 'icon' => 'edit2.gif', |
|
114 | - 'popup_onlyOpenIfSelected' => 1, |
|
115 | - 'notNewRecords' => 1, |
|
116 | - 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
117 | - ], |
|
118 | - ], |
|
119 | - ], |
|
120 | - ], |
|
121 | - 'mount_point_file_type_2' => [ |
|
122 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_2', |
|
123 | - 'config' => [ |
|
124 | - 'type' => 'group', |
|
125 | - 'allowed' => 'sys_filemounts', |
|
126 | - 'size' => 1, |
|
127 | - 'minitems' => 0, |
|
128 | - 'maxitems' => 1, |
|
129 | - 'wizards' => [ |
|
130 | - 'edit' => [ |
|
131 | - 'type' => 'popup', |
|
132 | - 'module' => [ |
|
133 | - 'name' => 'wizard_edit', |
|
134 | - ], |
|
135 | - 'icon' => 'edit2.gif', |
|
136 | - 'popup_onlyOpenIfSelected' => 1, |
|
137 | - 'notNewRecords' => 1, |
|
138 | - 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
139 | - ], |
|
140 | - ], |
|
141 | - ], |
|
142 | - ], |
|
143 | - 'mount_point_file_type_3' => [ |
|
144 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_3', |
|
145 | - 'config' => [ |
|
146 | - 'type' => 'group', |
|
147 | - 'allowed' => 'sys_filemounts', |
|
148 | - 'size' => 1, |
|
149 | - 'minitems' => 0, |
|
150 | - 'maxitems' => 1, |
|
151 | - 'wizards' => [ |
|
152 | - 'edit' => [ |
|
153 | - 'type' => 'popup', |
|
154 | - 'module' => [ |
|
155 | - 'name' => 'wizard_edit', |
|
156 | - ], |
|
157 | - 'icon' => 'edit2.gif', |
|
158 | - 'popup_onlyOpenIfSelected' => 1, |
|
159 | - 'notNewRecords' => 1, |
|
160 | - 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
161 | - ], |
|
162 | - ], |
|
163 | - ], |
|
164 | - ], |
|
165 | - 'mount_point_file_type_4' => [ |
|
166 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_4', |
|
167 | - 'config' => [ |
|
168 | - 'type' => 'group', |
|
169 | - 'allowed' => 'sys_filemounts', |
|
170 | - 'size' => 1, |
|
171 | - 'minitems' => 0, |
|
172 | - 'maxitems' => 1, |
|
173 | - 'wizards' => [ |
|
174 | - 'edit' => [ |
|
175 | - 'type' => 'popup', |
|
176 | - 'module' => [ |
|
177 | - 'name' => 'wizard_edit', |
|
178 | - ], |
|
179 | - 'icon' => 'edit2.gif', |
|
180 | - 'popup_onlyOpenIfSelected' => 1, |
|
181 | - 'notNewRecords' => 1, |
|
182 | - 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
183 | - ], |
|
184 | - ], |
|
185 | - ], |
|
186 | - ], |
|
187 | - 'mount_point_file_type_5' => [ |
|
188 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_5', |
|
189 | - 'config' => [ |
|
190 | - 'type' => 'group', |
|
191 | - 'allowed' => 'sys_filemounts', |
|
192 | - 'size' => 1, |
|
193 | - 'minitems' => 0, |
|
194 | - 'maxitems' => 1, |
|
195 | - 'wizards' => [ |
|
196 | - 'edit' => [ |
|
197 | - 'type' => 'popup', |
|
198 | - 'module' => [ |
|
199 | - 'name' => 'wizard_edit', |
|
200 | - ], |
|
201 | - 'icon' => 'edit2.gif', |
|
202 | - 'popup_onlyOpenIfSelected' => 1, |
|
203 | - 'notNewRecords' => 1, |
|
204 | - 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
205 | - ], |
|
206 | - ], |
|
207 | - ], |
|
208 | - ], |
|
209 | - ], |
|
210 | - ]; |
|
96 | + ], |
|
97 | + ], |
|
98 | + 'columns' => [ |
|
99 | + 'mount_point_file_type_1' => [ |
|
100 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_1', |
|
101 | + 'config' => [ |
|
102 | + 'type' => 'group', |
|
103 | + 'allowed' => 'sys_filemounts', |
|
104 | + 'size' => 1, |
|
105 | + 'minitems' => 0, |
|
106 | + 'maxitems' => 1, |
|
107 | + 'wizards' => [ |
|
108 | + 'edit' => [ |
|
109 | + 'type' => 'popup', |
|
110 | + 'module' => [ |
|
111 | + 'name' => 'wizard_edit', |
|
112 | + ], |
|
113 | + 'icon' => 'edit2.gif', |
|
114 | + 'popup_onlyOpenIfSelected' => 1, |
|
115 | + 'notNewRecords' => 1, |
|
116 | + 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
117 | + ], |
|
118 | + ], |
|
119 | + ], |
|
120 | + ], |
|
121 | + 'mount_point_file_type_2' => [ |
|
122 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_2', |
|
123 | + 'config' => [ |
|
124 | + 'type' => 'group', |
|
125 | + 'allowed' => 'sys_filemounts', |
|
126 | + 'size' => 1, |
|
127 | + 'minitems' => 0, |
|
128 | + 'maxitems' => 1, |
|
129 | + 'wizards' => [ |
|
130 | + 'edit' => [ |
|
131 | + 'type' => 'popup', |
|
132 | + 'module' => [ |
|
133 | + 'name' => 'wizard_edit', |
|
134 | + ], |
|
135 | + 'icon' => 'edit2.gif', |
|
136 | + 'popup_onlyOpenIfSelected' => 1, |
|
137 | + 'notNewRecords' => 1, |
|
138 | + 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
139 | + ], |
|
140 | + ], |
|
141 | + ], |
|
142 | + ], |
|
143 | + 'mount_point_file_type_3' => [ |
|
144 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_3', |
|
145 | + 'config' => [ |
|
146 | + 'type' => 'group', |
|
147 | + 'allowed' => 'sys_filemounts', |
|
148 | + 'size' => 1, |
|
149 | + 'minitems' => 0, |
|
150 | + 'maxitems' => 1, |
|
151 | + 'wizards' => [ |
|
152 | + 'edit' => [ |
|
153 | + 'type' => 'popup', |
|
154 | + 'module' => [ |
|
155 | + 'name' => 'wizard_edit', |
|
156 | + ], |
|
157 | + 'icon' => 'edit2.gif', |
|
158 | + 'popup_onlyOpenIfSelected' => 1, |
|
159 | + 'notNewRecords' => 1, |
|
160 | + 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
161 | + ], |
|
162 | + ], |
|
163 | + ], |
|
164 | + ], |
|
165 | + 'mount_point_file_type_4' => [ |
|
166 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_4', |
|
167 | + 'config' => [ |
|
168 | + 'type' => 'group', |
|
169 | + 'allowed' => 'sys_filemounts', |
|
170 | + 'size' => 1, |
|
171 | + 'minitems' => 0, |
|
172 | + 'maxitems' => 1, |
|
173 | + 'wizards' => [ |
|
174 | + 'edit' => [ |
|
175 | + 'type' => 'popup', |
|
176 | + 'module' => [ |
|
177 | + 'name' => 'wizard_edit', |
|
178 | + ], |
|
179 | + 'icon' => 'edit2.gif', |
|
180 | + 'popup_onlyOpenIfSelected' => 1, |
|
181 | + 'notNewRecords' => 1, |
|
182 | + 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
183 | + ], |
|
184 | + ], |
|
185 | + ], |
|
186 | + ], |
|
187 | + 'mount_point_file_type_5' => [ |
|
188 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_storage.mount_point_file_type_5', |
|
189 | + 'config' => [ |
|
190 | + 'type' => 'group', |
|
191 | + 'allowed' => 'sys_filemounts', |
|
192 | + 'size' => 1, |
|
193 | + 'minitems' => 0, |
|
194 | + 'maxitems' => 1, |
|
195 | + 'wizards' => [ |
|
196 | + 'edit' => [ |
|
197 | + 'type' => 'popup', |
|
198 | + 'module' => [ |
|
199 | + 'name' => 'wizard_edit', |
|
200 | + ], |
|
201 | + 'icon' => 'edit2.gif', |
|
202 | + 'popup_onlyOpenIfSelected' => 1, |
|
203 | + 'notNewRecords' => 1, |
|
204 | + 'JSopenParams' => 'height=500,width=800,status=0,menubar=0,scrollbars=1,resizable=yes' |
|
205 | + ], |
|
206 | + ], |
|
207 | + ], |
|
208 | + ], |
|
209 | + ], |
|
210 | + ]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // Merge first two possible TCA whether the folder tree is displayed or not. |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function setOrientation($filename, $orientation) |
57 | 57 | { |
58 | - $exif_data = []; // Buffer |
|
58 | + $exif_data = []; // Buffer |
|
59 | 59 | $offsetJfif = 0; |
60 | 60 | |
61 | 61 | if (($fh = fopen($filename, 'rb+')) === false) { |
62 | - throw new \RuntimeException('Can\'t open ' . $filename, 1363533724); |
|
62 | + throw new \RuntimeException('Can\'t open '.$filename, 1363533724); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Read file head, check for JPEG SOI + JFIF/Exif APP1 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if ($exif_data[2] === 0xFF && $exif_data[3] === 0xE0) { |
74 | 74 | // Get the marker parameter length count |
75 | 75 | $length = self::read_2_bytes($fh); |
76 | - $offsetJfif = $length + 2; // "+ 2" to skip the 2 bytes introducing this additional segment |
|
76 | + $offsetJfif = $length + 2; // "+ 2" to skip the 2 bytes introducing this additional segment |
|
77 | 77 | // Length includes itself, so must be at least 2 |
78 | 78 | // Following JFIF data length must be at least 6 |
79 | 79 | if ($length < 8) { |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | // Set the Orientation value |
206 | 206 | if ($is_motorola) { |
207 | - $exif_data[$offset + 2] = 0; // Format = unsigned short (2 octets) |
|
207 | + $exif_data[$offset + 2] = 0; // Format = unsigned short (2 octets) |
|
208 | 208 | $exif_data[$offset + 3] = 3; |
209 | - $exif_data[$offset + 4] = 0; // Number of Components = 1 |
|
209 | + $exif_data[$offset + 4] = 0; // Number of Components = 1 |
|
210 | 210 | $exif_data[$offset + 5] = 0; |
211 | 211 | $exif_data[$offset + 6] = 0; |
212 | 212 | $exif_data[$offset + 7] = 1; |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | $exif_data[$offset + 10] = 0; |
216 | 216 | $exif_data[$offset + 11] = 0; |
217 | 217 | } else { |
218 | - $exif_data[$offset + 2] = 3; // Format = unsigned short (2 octets) |
|
218 | + $exif_data[$offset + 2] = 3; // Format = unsigned short (2 octets) |
|
219 | 219 | $exif_data[$offset + 3] = 0; |
220 | - $exif_data[$offset + 4] = 1; // Number of Components = 1 |
|
220 | + $exif_data[$offset + 4] = 1; // Number of Components = 1 |
|
221 | 221 | $exif_data[$offset + 5] = 0; |
222 | 222 | $exif_data[$offset + 6] = 0; |
223 | 223 | $exif_data[$offset + 7] = 0; |
@@ -45,266 +45,266 @@ |
||
45 | 45 | */ |
46 | 46 | class JpegExifOrient |
47 | 47 | { |
48 | - /** |
|
49 | - * Sets the Exif Orientation for a given JPG file. |
|
50 | - * |
|
51 | - * @param string $filename |
|
52 | - * @param integer $orientation |
|
53 | - * @return void |
|
54 | - * @throws \RuntimeException |
|
55 | - */ |
|
56 | - public static function setOrientation($filename, $orientation) |
|
57 | - { |
|
58 | - $exif_data = []; // Buffer |
|
59 | - $offsetJfif = 0; |
|
48 | + /** |
|
49 | + * Sets the Exif Orientation for a given JPG file. |
|
50 | + * |
|
51 | + * @param string $filename |
|
52 | + * @param integer $orientation |
|
53 | + * @return void |
|
54 | + * @throws \RuntimeException |
|
55 | + */ |
|
56 | + public static function setOrientation($filename, $orientation) |
|
57 | + { |
|
58 | + $exif_data = []; // Buffer |
|
59 | + $offsetJfif = 0; |
|
60 | 60 | |
61 | - if (($fh = fopen($filename, 'rb+')) === false) { |
|
62 | - throw new \RuntimeException('Can\'t open ' . $filename, 1363533724); |
|
63 | - } |
|
61 | + if (($fh = fopen($filename, 'rb+')) === false) { |
|
62 | + throw new \RuntimeException('Can\'t open ' . $filename, 1363533724); |
|
63 | + } |
|
64 | 64 | |
65 | - // Read file head, check for JPEG SOI + JFIF/Exif APP1 |
|
66 | - for ($i = 0; $i < 4; $i++) { |
|
67 | - $exif_data[$i] = self::read_1_byte($fh); |
|
68 | - } |
|
69 | - if ($exif_data[0] !== 0xFF || |
|
70 | - $exif_data[1] !== 0xD8 |
|
71 | - ) { |
|
72 | - } |
|
65 | + // Read file head, check for JPEG SOI + JFIF/Exif APP1 |
|
66 | + for ($i = 0; $i < 4; $i++) { |
|
67 | + $exif_data[$i] = self::read_1_byte($fh); |
|
68 | + } |
|
69 | + if ($exif_data[0] !== 0xFF || |
|
70 | + $exif_data[1] !== 0xD8 |
|
71 | + ) { |
|
72 | + } |
|
73 | 73 | |
74 | - // JFIF segment: http://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#JFIF_segment_format |
|
75 | - if ($exif_data[2] === 0xFF && $exif_data[3] === 0xE0) { |
|
76 | - // Get the marker parameter length count |
|
77 | - $length = self::read_2_bytes($fh); |
|
78 | - $offsetJfif = $length + 2; // "+ 2" to skip the 2 bytes introducing this additional segment |
|
79 | - // Length includes itself, so must be at least 2 |
|
80 | - // Following JFIF data length must be at least 6 |
|
81 | - if ($length < 8) { |
|
82 | - return; |
|
83 | - } |
|
84 | - $length -= 8; |
|
85 | - // Read JFIF head, check for "JFIF" |
|
86 | - for ($i = 0; $i < 5; $i++) { |
|
87 | - $exif_data[$i] = self::read_1_byte($fh); |
|
88 | - } |
|
89 | - if ($exif_data[0] !== 0x4A || |
|
90 | - $exif_data[1] !== 0x46 || |
|
91 | - $exif_data[2] !== 0x49 || |
|
92 | - $exif_data[3] !== 0x46 || |
|
93 | - $exif_data[4] !== 0 |
|
94 | - ) { |
|
95 | - return; |
|
96 | - } |
|
97 | - // Read JFIF body |
|
98 | - for ($i = 0; $i < $length; $i++) { |
|
99 | - $exif_data[$i] = self::read_1_byte($fh); |
|
100 | - } |
|
74 | + // JFIF segment: http://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#JFIF_segment_format |
|
75 | + if ($exif_data[2] === 0xFF && $exif_data[3] === 0xE0) { |
|
76 | + // Get the marker parameter length count |
|
77 | + $length = self::read_2_bytes($fh); |
|
78 | + $offsetJfif = $length + 2; // "+ 2" to skip the 2 bytes introducing this additional segment |
|
79 | + // Length includes itself, so must be at least 2 |
|
80 | + // Following JFIF data length must be at least 6 |
|
81 | + if ($length < 8) { |
|
82 | + return; |
|
83 | + } |
|
84 | + $length -= 8; |
|
85 | + // Read JFIF head, check for "JFIF" |
|
86 | + for ($i = 0; $i < 5; $i++) { |
|
87 | + $exif_data[$i] = self::read_1_byte($fh); |
|
88 | + } |
|
89 | + if ($exif_data[0] !== 0x4A || |
|
90 | + $exif_data[1] !== 0x46 || |
|
91 | + $exif_data[2] !== 0x49 || |
|
92 | + $exif_data[3] !== 0x46 || |
|
93 | + $exif_data[4] !== 0 |
|
94 | + ) { |
|
95 | + return; |
|
96 | + } |
|
97 | + // Read JFIF body |
|
98 | + for ($i = 0; $i < $length; $i++) { |
|
99 | + $exif_data[$i] = self::read_1_byte($fh); |
|
100 | + } |
|
101 | 101 | |
102 | - if (self::read_1_byte($fh) !== 0) { |
|
103 | - // Seems there is a 0 byte to separate segments... |
|
104 | - return; |
|
105 | - } |
|
106 | - // Read next 2 bytes in $exif_data[2] and $exif_data[3] as Exif APP1 segment |
|
107 | - // is now expected |
|
108 | - $exif_data[2] = self::read_1_byte($fh); |
|
109 | - $exif_data[3] = self::read_1_byte($fh); |
|
110 | - } |
|
102 | + if (self::read_1_byte($fh) !== 0) { |
|
103 | + // Seems there is a 0 byte to separate segments... |
|
104 | + return; |
|
105 | + } |
|
106 | + // Read next 2 bytes in $exif_data[2] and $exif_data[3] as Exif APP1 segment |
|
107 | + // is now expected |
|
108 | + $exif_data[2] = self::read_1_byte($fh); |
|
109 | + $exif_data[3] = self::read_1_byte($fh); |
|
110 | + } |
|
111 | 111 | |
112 | - // Exif APP1 |
|
113 | - if ($exif_data[2] !== 0xFF || $exif_data[3] !== 0xE1) { |
|
114 | - return; |
|
115 | - } |
|
112 | + // Exif APP1 |
|
113 | + if ($exif_data[2] !== 0xFF || $exif_data[3] !== 0xE1) { |
|
114 | + return; |
|
115 | + } |
|
116 | 116 | |
117 | - // Get the marker parameter length count |
|
118 | - $length = self::read_2_bytes($fh); |
|
119 | - // Length includes itself, so must be at least 2 |
|
120 | - // Following Exif data length must be at least 6 |
|
121 | - if ($length < 8) { |
|
122 | - return; |
|
123 | - } |
|
124 | - $length -= 8; |
|
125 | - // Read Exif head, check for "Exif" |
|
126 | - for ($i = 0; $i < 6; $i++) { |
|
127 | - $exif_data[$i] = self::read_1_byte($fh); |
|
128 | - } |
|
129 | - if ($exif_data[0] !== 0x45 || |
|
130 | - $exif_data[1] !== 0x78 || |
|
131 | - $exif_data[2] !== 0x69 || |
|
132 | - $exif_data[3] !== 0x66 || |
|
133 | - $exif_data[4] !== 0 || |
|
134 | - $exif_data[5] !== 0 |
|
135 | - ) { |
|
136 | - return; |
|
137 | - } |
|
138 | - // Read Exif body |
|
139 | - for ($i = 0; $i < $length; $i++) { |
|
140 | - $exif_data[$i] = self::read_1_byte($fh); |
|
141 | - } |
|
117 | + // Get the marker parameter length count |
|
118 | + $length = self::read_2_bytes($fh); |
|
119 | + // Length includes itself, so must be at least 2 |
|
120 | + // Following Exif data length must be at least 6 |
|
121 | + if ($length < 8) { |
|
122 | + return; |
|
123 | + } |
|
124 | + $length -= 8; |
|
125 | + // Read Exif head, check for "Exif" |
|
126 | + for ($i = 0; $i < 6; $i++) { |
|
127 | + $exif_data[$i] = self::read_1_byte($fh); |
|
128 | + } |
|
129 | + if ($exif_data[0] !== 0x45 || |
|
130 | + $exif_data[1] !== 0x78 || |
|
131 | + $exif_data[2] !== 0x69 || |
|
132 | + $exif_data[3] !== 0x66 || |
|
133 | + $exif_data[4] !== 0 || |
|
134 | + $exif_data[5] !== 0 |
|
135 | + ) { |
|
136 | + return; |
|
137 | + } |
|
138 | + // Read Exif body |
|
139 | + for ($i = 0; $i < $length; $i++) { |
|
140 | + $exif_data[$i] = self::read_1_byte($fh); |
|
141 | + } |
|
142 | 142 | |
143 | - if ($length < 12) { // Length of an IFD entry |
|
144 | - return; |
|
145 | - } |
|
143 | + if ($length < 12) { // Length of an IFD entry |
|
144 | + return; |
|
145 | + } |
|
146 | 146 | |
147 | - // Discover byte order |
|
148 | - if ($exif_data[0] === 0x49 && $exif_data[1] === 0x49) { |
|
149 | - $is_motorola = false; |
|
150 | - } elseif ($exif_data[0] === 0x4D && $exif_data[1] === 0x4D) { |
|
151 | - $is_motorola = true; |
|
152 | - } else { |
|
153 | - return; |
|
154 | - } |
|
147 | + // Discover byte order |
|
148 | + if ($exif_data[0] === 0x49 && $exif_data[1] === 0x49) { |
|
149 | + $is_motorola = false; |
|
150 | + } elseif ($exif_data[0] === 0x4D && $exif_data[1] === 0x4D) { |
|
151 | + $is_motorola = true; |
|
152 | + } else { |
|
153 | + return; |
|
154 | + } |
|
155 | 155 | |
156 | - // Check Tag mark |
|
157 | - if ($is_motorola) { |
|
158 | - if ($exif_data[2] !== 0) { |
|
159 | - return; |
|
160 | - } |
|
161 | - if ($exif_data[3] !== 0x2A) { |
|
162 | - return; |
|
163 | - } |
|
164 | - } else { |
|
165 | - if ($exif_data[3] !== 0) { |
|
166 | - return; |
|
167 | - } |
|
168 | - if ($exif_data[2] !== 0x2A) { |
|
169 | - return; |
|
170 | - } |
|
171 | - } |
|
156 | + // Check Tag mark |
|
157 | + if ($is_motorola) { |
|
158 | + if ($exif_data[2] !== 0) { |
|
159 | + return; |
|
160 | + } |
|
161 | + if ($exif_data[3] !== 0x2A) { |
|
162 | + return; |
|
163 | + } |
|
164 | + } else { |
|
165 | + if ($exif_data[3] !== 0) { |
|
166 | + return; |
|
167 | + } |
|
168 | + if ($exif_data[2] !== 0x2A) { |
|
169 | + return; |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | - // Get first IFD offset (offset to IFD0) |
|
174 | - if ($is_motorola) { |
|
175 | - if ($exif_data[4] !== 0) { |
|
176 | - return; |
|
177 | - } |
|
178 | - if ($exif_data[5] !== 0) { |
|
179 | - return; |
|
180 | - } |
|
181 | - $offset = $exif_data[6]; |
|
182 | - $offset <<= 8; |
|
183 | - $offset += $exif_data[7]; |
|
184 | - } else { |
|
185 | - if ($exif_data[7] !== 0) { |
|
186 | - return; |
|
187 | - } |
|
188 | - if ($exif_data[6] !== 0) { |
|
189 | - return; |
|
190 | - } |
|
191 | - $offset = $exif_data[5]; |
|
192 | - $offset <<= 8; |
|
193 | - $offset += $exif_data[4]; |
|
194 | - } |
|
195 | - // Check end of data segment |
|
196 | - if ($offset > $length - 2) { |
|
197 | - return; |
|
198 | - } |
|
173 | + // Get first IFD offset (offset to IFD0) |
|
174 | + if ($is_motorola) { |
|
175 | + if ($exif_data[4] !== 0) { |
|
176 | + return; |
|
177 | + } |
|
178 | + if ($exif_data[5] !== 0) { |
|
179 | + return; |
|
180 | + } |
|
181 | + $offset = $exif_data[6]; |
|
182 | + $offset <<= 8; |
|
183 | + $offset += $exif_data[7]; |
|
184 | + } else { |
|
185 | + if ($exif_data[7] !== 0) { |
|
186 | + return; |
|
187 | + } |
|
188 | + if ($exif_data[6] !== 0) { |
|
189 | + return; |
|
190 | + } |
|
191 | + $offset = $exif_data[5]; |
|
192 | + $offset <<= 8; |
|
193 | + $offset += $exif_data[4]; |
|
194 | + } |
|
195 | + // Check end of data segment |
|
196 | + if ($offset > $length - 2) { |
|
197 | + return; |
|
198 | + } |
|
199 | 199 | |
200 | - // Get the number of directory entries contained in this IFD |
|
201 | - if ($is_motorola) { |
|
202 | - $number_of_tags = $exif_data[$offset]; |
|
203 | - $number_of_tags <<= 8; |
|
204 | - $number_of_tags += $exif_data[$offset + 1]; |
|
205 | - } else { |
|
206 | - $number_of_tags = $exif_data[$offset + 1]; |
|
207 | - $number_of_tags <<= 8; |
|
208 | - $number_of_tags += $exif_data[$offset]; |
|
209 | - } |
|
210 | - if ($number_of_tags === 0) { |
|
211 | - return; |
|
212 | - } |
|
213 | - $offset += 2; |
|
200 | + // Get the number of directory entries contained in this IFD |
|
201 | + if ($is_motorola) { |
|
202 | + $number_of_tags = $exif_data[$offset]; |
|
203 | + $number_of_tags <<= 8; |
|
204 | + $number_of_tags += $exif_data[$offset + 1]; |
|
205 | + } else { |
|
206 | + $number_of_tags = $exif_data[$offset + 1]; |
|
207 | + $number_of_tags <<= 8; |
|
208 | + $number_of_tags += $exif_data[$offset]; |
|
209 | + } |
|
210 | + if ($number_of_tags === 0) { |
|
211 | + return; |
|
212 | + } |
|
213 | + $offset += 2; |
|
214 | 214 | |
215 | - // Search for Orientation Tag in IFD0 |
|
216 | - while (true) { |
|
217 | - // Check end of data segment |
|
218 | - if ($offset > $length - 12) { |
|
219 | - return; |
|
220 | - } |
|
221 | - // Get Tag number |
|
222 | - if ($is_motorola) { |
|
223 | - $tagnum = $exif_data[$offset]; |
|
224 | - $tagnum <<= 8; |
|
225 | - $tagnum += $exif_data[$offset + 1]; |
|
226 | - } else { |
|
227 | - $tagnum = $exif_data[$offset + 1]; |
|
228 | - $tagnum <<= 8; |
|
229 | - $tagnum += $exif_data[$offset]; |
|
230 | - } |
|
231 | - // Found Orientation Tag |
|
232 | - if ($tagnum === 0x0112) { |
|
233 | - break; |
|
234 | - } |
|
235 | - if (--$number_of_tags === 0) { |
|
236 | - return; |
|
237 | - } |
|
238 | - $offset += 12; |
|
239 | - } |
|
215 | + // Search for Orientation Tag in IFD0 |
|
216 | + while (true) { |
|
217 | + // Check end of data segment |
|
218 | + if ($offset > $length - 12) { |
|
219 | + return; |
|
220 | + } |
|
221 | + // Get Tag number |
|
222 | + if ($is_motorola) { |
|
223 | + $tagnum = $exif_data[$offset]; |
|
224 | + $tagnum <<= 8; |
|
225 | + $tagnum += $exif_data[$offset + 1]; |
|
226 | + } else { |
|
227 | + $tagnum = $exif_data[$offset + 1]; |
|
228 | + $tagnum <<= 8; |
|
229 | + $tagnum += $exif_data[$offset]; |
|
230 | + } |
|
231 | + // Found Orientation Tag |
|
232 | + if ($tagnum === 0x0112) { |
|
233 | + break; |
|
234 | + } |
|
235 | + if (--$number_of_tags === 0) { |
|
236 | + return; |
|
237 | + } |
|
238 | + $offset += 12; |
|
239 | + } |
|
240 | 240 | |
241 | - // Set the Orientation value |
|
242 | - if ($is_motorola) { |
|
243 | - $exif_data[$offset + 2] = 0; // Format = unsigned short (2 octets) |
|
244 | - $exif_data[$offset + 3] = 3; |
|
245 | - $exif_data[$offset + 4] = 0; // Number of Components = 1 |
|
246 | - $exif_data[$offset + 5] = 0; |
|
247 | - $exif_data[$offset + 6] = 0; |
|
248 | - $exif_data[$offset + 7] = 1; |
|
249 | - $exif_data[$offset + 8] = 0; |
|
250 | - $exif_data[$offset + 9] = $orientation; |
|
251 | - $exif_data[$offset + 10] = 0; |
|
252 | - $exif_data[$offset + 11] = 0; |
|
253 | - } else { |
|
254 | - $exif_data[$offset + 2] = 3; // Format = unsigned short (2 octets) |
|
255 | - $exif_data[$offset + 3] = 0; |
|
256 | - $exif_data[$offset + 4] = 1; // Number of Components = 1 |
|
257 | - $exif_data[$offset + 5] = 0; |
|
258 | - $exif_data[$offset + 6] = 0; |
|
259 | - $exif_data[$offset + 7] = 0; |
|
260 | - $exif_data[$offset + 8] = $orientation; |
|
261 | - $exif_data[$offset + 9] = 0; |
|
262 | - $exif_data[$offset + 10] = 0; |
|
263 | - $exif_data[$offset + 11] = 0; |
|
264 | - } |
|
265 | - fseek($fh, (4 + 2 + 6 + 2) + $offsetJfif + $offset, SEEK_SET); |
|
266 | - $data = ''; |
|
267 | - for ($i = 0; $i < 10; $i++) { |
|
268 | - $data .= chr($exif_data[$i + $offset + 2]); |
|
269 | - } |
|
270 | - fwrite($fh, $data); |
|
271 | - fclose($fh); |
|
272 | - } |
|
241 | + // Set the Orientation value |
|
242 | + if ($is_motorola) { |
|
243 | + $exif_data[$offset + 2] = 0; // Format = unsigned short (2 octets) |
|
244 | + $exif_data[$offset + 3] = 3; |
|
245 | + $exif_data[$offset + 4] = 0; // Number of Components = 1 |
|
246 | + $exif_data[$offset + 5] = 0; |
|
247 | + $exif_data[$offset + 6] = 0; |
|
248 | + $exif_data[$offset + 7] = 1; |
|
249 | + $exif_data[$offset + 8] = 0; |
|
250 | + $exif_data[$offset + 9] = $orientation; |
|
251 | + $exif_data[$offset + 10] = 0; |
|
252 | + $exif_data[$offset + 11] = 0; |
|
253 | + } else { |
|
254 | + $exif_data[$offset + 2] = 3; // Format = unsigned short (2 octets) |
|
255 | + $exif_data[$offset + 3] = 0; |
|
256 | + $exif_data[$offset + 4] = 1; // Number of Components = 1 |
|
257 | + $exif_data[$offset + 5] = 0; |
|
258 | + $exif_data[$offset + 6] = 0; |
|
259 | + $exif_data[$offset + 7] = 0; |
|
260 | + $exif_data[$offset + 8] = $orientation; |
|
261 | + $exif_data[$offset + 9] = 0; |
|
262 | + $exif_data[$offset + 10] = 0; |
|
263 | + $exif_data[$offset + 11] = 0; |
|
264 | + } |
|
265 | + fseek($fh, (4 + 2 + 6 + 2) + $offsetJfif + $offset, SEEK_SET); |
|
266 | + $data = ''; |
|
267 | + for ($i = 0; $i < 10; $i++) { |
|
268 | + $data .= chr($exif_data[$i + $offset + 2]); |
|
269 | + } |
|
270 | + fwrite($fh, $data); |
|
271 | + fclose($fh); |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Reads one byte, testing for EOF. |
|
276 | - * |
|
277 | - * @param resource $handle |
|
278 | - * @return integer |
|
279 | - * @throws \RuntimeException |
|
280 | - */ |
|
281 | - protected static function read_1_byte($handle) |
|
282 | - { |
|
283 | - $c = fgetc($handle); |
|
284 | - if ($c === false) { |
|
285 | - throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
286 | - } |
|
287 | - return ord($c); |
|
288 | - } |
|
274 | + /** |
|
275 | + * Reads one byte, testing for EOF. |
|
276 | + * |
|
277 | + * @param resource $handle |
|
278 | + * @return integer |
|
279 | + * @throws \RuntimeException |
|
280 | + */ |
|
281 | + protected static function read_1_byte($handle) |
|
282 | + { |
|
283 | + $c = fgetc($handle); |
|
284 | + if ($c === false) { |
|
285 | + throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
286 | + } |
|
287 | + return ord($c); |
|
288 | + } |
|
289 | 289 | |
290 | - /** |
|
291 | - * Reads 2 bytes, converts them to unsigned int |
|
292 | - * Remark: All 2-byte quantities in JPEG markers are MSB first. |
|
293 | - * |
|
294 | - * @param resource $handle |
|
295 | - * @return integer |
|
296 | - * @throws \RuntimeException |
|
297 | - */ |
|
298 | - protected static function read_2_bytes($handle) |
|
299 | - { |
|
300 | - $c1 = fgetc($handle); |
|
301 | - if ($c1 === false) { |
|
302 | - throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
303 | - } |
|
304 | - $c2 = fgetc($handle); |
|
305 | - if ($c2 === false) { |
|
306 | - throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
307 | - } |
|
308 | - return (ord($c1) << 8) + (ord($c2)); |
|
309 | - } |
|
290 | + /** |
|
291 | + * Reads 2 bytes, converts them to unsigned int |
|
292 | + * Remark: All 2-byte quantities in JPEG markers are MSB first. |
|
293 | + * |
|
294 | + * @param resource $handle |
|
295 | + * @return integer |
|
296 | + * @throws \RuntimeException |
|
297 | + */ |
|
298 | + protected static function read_2_bytes($handle) |
|
299 | + { |
|
300 | + $c1 = fgetc($handle); |
|
301 | + if ($c1 === false) { |
|
302 | + throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
303 | + } |
|
304 | + $c2 = fgetc($handle); |
|
305 | + if ($c2 === false) { |
|
306 | + throw new \RuntimeException('Premature EOF in JPEG file', 1363533326); |
|
307 | + } |
|
308 | + return (ord($c1) << 8) + (ord($c2)); |
|
309 | + } |
|
310 | 310 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | return sprintf( |
74 | 74 | '<img src="%s%s" title="%s" alt="%s" %s/>', |
75 | 75 | $result, |
76 | - $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '', |
|
76 | + $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator.$this->getTimeStamp() : '', |
|
77 | 77 | $this->getTitle(), |
78 | 78 | $this->getTitle(), |
79 | 79 | $this->renderAttributes() |
@@ -18,126 +18,126 @@ |
||
18 | 18 | */ |
19 | 19 | class ApplicationThumbnailProcessor extends AbstractThumbnailProcessor |
20 | 20 | { |
21 | - /** |
|
22 | - * Render a thumbnail of a resource of type application. |
|
23 | - * |
|
24 | - */ |
|
25 | - public function create(): string |
|
26 | - { |
|
27 | - $steps = $this->getRenderingSteps(); |
|
28 | - |
|
29 | - $result = ''; |
|
30 | - while ($step = array_shift($steps)) { |
|
31 | - $result = $this->$step($result); |
|
32 | - } |
|
33 | - |
|
34 | - return $result; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Render the URI of the thumbnail. |
|
39 | - * |
|
40 | - */ |
|
41 | - public function renderUri(): string |
|
42 | - { |
|
43 | - if ($this->isThumbnailPossible($this->getFile()->getExtension())) { |
|
44 | - $this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration()); |
|
45 | - $uri = $this->processedFile->getPublicUrl(true); |
|
46 | - |
|
47 | - // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail. |
|
48 | - if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) { |
|
49 | - $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp'))); |
|
50 | - } |
|
51 | - } else { |
|
52 | - $uri = $this->getIcon($this->getFile()->getExtension()); |
|
53 | - } |
|
54 | - return $this->prefixUri($uri); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Render the tag image which is the main one for a thumbnail. |
|
59 | - * |
|
60 | - * @param string $result |
|
61 | - */ |
|
62 | - public function renderTagImage($result): string |
|
63 | - { |
|
64 | - // Variable $result corresponds to an URL in this case. |
|
65 | - // Analyse the URL and compute the adequate separator between arguments. |
|
66 | - $parameterSeparator = strpos($result, '?') === false ? '?' : '&'; |
|
67 | - |
|
68 | - return sprintf( |
|
69 | - '<img src="%s%s" title="%s" alt="%s" %s/>', |
|
70 | - $result, |
|
71 | - $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '', |
|
72 | - $this->getTitle(), |
|
73 | - $this->getTitle(), |
|
74 | - $this->renderAttributes() |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Compute and return the time stamp. |
|
80 | - * |
|
81 | - * @return int |
|
82 | - */ |
|
83 | - protected function getTimeStamp() |
|
84 | - { |
|
85 | - $result = $this->getFile()->getProperty('tstamp'); |
|
86 | - if ($this->processedFile) { |
|
87 | - $result = $this->processedFile->getProperty('tstamp'); |
|
88 | - } |
|
89 | - return $result; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Compute and return the title of the file. |
|
94 | - */ |
|
95 | - protected function getTitle(): string |
|
96 | - { |
|
97 | - $result = $this->getFile()->getProperty('title'); |
|
98 | - if (empty($result)) { |
|
99 | - $result = $this->getFile()->getName(); |
|
100 | - } |
|
101 | - return htmlspecialchars($result); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Render a wrapping anchor around the thumbnail. |
|
106 | - * |
|
107 | - * @param string $result |
|
108 | - */ |
|
109 | - public function renderTagAnchor($result): string |
|
110 | - { |
|
111 | - $uri = $this->thumbnailService->getAnchorUri(); |
|
112 | - if (!$uri) { |
|
113 | - $uri = $this->getUri(); |
|
114 | - } |
|
115 | - |
|
116 | - return sprintf( |
|
117 | - '<a href="%s" target="_blank" data-uid="%s">%s</a>', |
|
118 | - $uri, |
|
119 | - $this->getFile()->getUid(), |
|
120 | - $result |
|
121 | - ); |
|
122 | - } |
|
123 | - |
|
124 | - protected function getUri(): string |
|
125 | - { |
|
126 | - $urlParameters = [ |
|
127 | - MediaModule::getParameterPrefix() => [ |
|
128 | - 'controller' => 'Asset', |
|
129 | - 'action' => 'download', |
|
130 | - 'file' => $this->getFile()->getUid(), |
|
131 | - ], |
|
132 | - ]; |
|
133 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
134 | - } |
|
135 | - |
|
136 | - public function getProcessingType(): string |
|
137 | - { |
|
138 | - if (!$this->thumbnailService->getProcessingType()) { |
|
139 | - return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK; |
|
140 | - } |
|
141 | - return $this->thumbnailService->getProcessingType(); |
|
142 | - } |
|
21 | + /** |
|
22 | + * Render a thumbnail of a resource of type application. |
|
23 | + * |
|
24 | + */ |
|
25 | + public function create(): string |
|
26 | + { |
|
27 | + $steps = $this->getRenderingSteps(); |
|
28 | + |
|
29 | + $result = ''; |
|
30 | + while ($step = array_shift($steps)) { |
|
31 | + $result = $this->$step($result); |
|
32 | + } |
|
33 | + |
|
34 | + return $result; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Render the URI of the thumbnail. |
|
39 | + * |
|
40 | + */ |
|
41 | + public function renderUri(): string |
|
42 | + { |
|
43 | + if ($this->isThumbnailPossible($this->getFile()->getExtension())) { |
|
44 | + $this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration()); |
|
45 | + $uri = $this->processedFile->getPublicUrl(true); |
|
46 | + |
|
47 | + // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail. |
|
48 | + if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) { |
|
49 | + $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp'))); |
|
50 | + } |
|
51 | + } else { |
|
52 | + $uri = $this->getIcon($this->getFile()->getExtension()); |
|
53 | + } |
|
54 | + return $this->prefixUri($uri); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Render the tag image which is the main one for a thumbnail. |
|
59 | + * |
|
60 | + * @param string $result |
|
61 | + */ |
|
62 | + public function renderTagImage($result): string |
|
63 | + { |
|
64 | + // Variable $result corresponds to an URL in this case. |
|
65 | + // Analyse the URL and compute the adequate separator between arguments. |
|
66 | + $parameterSeparator = strpos($result, '?') === false ? '?' : '&'; |
|
67 | + |
|
68 | + return sprintf( |
|
69 | + '<img src="%s%s" title="%s" alt="%s" %s/>', |
|
70 | + $result, |
|
71 | + $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '', |
|
72 | + $this->getTitle(), |
|
73 | + $this->getTitle(), |
|
74 | + $this->renderAttributes() |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Compute and return the time stamp. |
|
80 | + * |
|
81 | + * @return int |
|
82 | + */ |
|
83 | + protected function getTimeStamp() |
|
84 | + { |
|
85 | + $result = $this->getFile()->getProperty('tstamp'); |
|
86 | + if ($this->processedFile) { |
|
87 | + $result = $this->processedFile->getProperty('tstamp'); |
|
88 | + } |
|
89 | + return $result; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Compute and return the title of the file. |
|
94 | + */ |
|
95 | + protected function getTitle(): string |
|
96 | + { |
|
97 | + $result = $this->getFile()->getProperty('title'); |
|
98 | + if (empty($result)) { |
|
99 | + $result = $this->getFile()->getName(); |
|
100 | + } |
|
101 | + return htmlspecialchars($result); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Render a wrapping anchor around the thumbnail. |
|
106 | + * |
|
107 | + * @param string $result |
|
108 | + */ |
|
109 | + public function renderTagAnchor($result): string |
|
110 | + { |
|
111 | + $uri = $this->thumbnailService->getAnchorUri(); |
|
112 | + if (!$uri) { |
|
113 | + $uri = $this->getUri(); |
|
114 | + } |
|
115 | + |
|
116 | + return sprintf( |
|
117 | + '<a href="%s" target="_blank" data-uid="%s">%s</a>', |
|
118 | + $uri, |
|
119 | + $this->getFile()->getUid(), |
|
120 | + $result |
|
121 | + ); |
|
122 | + } |
|
123 | + |
|
124 | + protected function getUri(): string |
|
125 | + { |
|
126 | + $urlParameters = [ |
|
127 | + MediaModule::getParameterPrefix() => [ |
|
128 | + 'controller' => 'Asset', |
|
129 | + 'action' => 'download', |
|
130 | + 'file' => $this->getFile()->getUid(), |
|
131 | + ], |
|
132 | + ]; |
|
133 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
134 | + } |
|
135 | + |
|
136 | + public function getProcessingType(): string |
|
137 | + { |
|
138 | + if (!$this->thumbnailService->getProcessingType()) { |
|
139 | + return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK; |
|
140 | + } |
|
141 | + return $this->thumbnailService->getProcessingType(); |
|
142 | + } |
|
143 | 143 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | - $this->setName(uniqid() . '.' . $this->extension); |
|
68 | + $this->setName(uniqid().'.'.$this->extension); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -16,115 +16,115 @@ |
||
16 | 16 | */ |
17 | 17 | class Base64File extends UploadedFileAbstract |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $inputName = 'qqfile'; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $uploadFolder; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $name; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $image; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $extension; |
|
43 | - |
|
44 | - /** |
|
45 | - * @return \Fab\Media\FileUpload\Base64File |
|
46 | - */ |
|
47 | - public function __construct() |
|
48 | - { |
|
49 | - // Processes the encoded image data and returns the decoded image |
|
50 | - $encodedImage = GeneralUtility::_POST($this->inputName); |
|
51 | - if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) { |
|
52 | - $this->extension = $matches[1]; |
|
53 | - } else { |
|
54 | - return false; |
|
55 | - } |
|
56 | - |
|
57 | - // Remove the mime-type header |
|
58 | - $data = reset(array_reverse(explode('base64,', $encodedImage))); |
|
59 | - |
|
60 | - // Use strict mode to prevent characters from outside the base64 range |
|
61 | - $this->image = base64_decode($data, true); |
|
62 | - |
|
63 | - if (!$this->image) { |
|
64 | - return false; |
|
65 | - } |
|
66 | - |
|
67 | - $this->setName(uniqid() . '.' . $this->extension); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Save the file to the specified path |
|
72 | - * |
|
73 | - * @throws EmptyPropertyException |
|
74 | - * @return boolean true on success |
|
75 | - */ |
|
76 | - public function save() |
|
77 | - { |
|
78 | - if (is_null($this->uploadFolder)) { |
|
79 | - throw new EmptyPropertyException('Upload folder is not defined', 1362587741); |
|
80 | - } |
|
81 | - |
|
82 | - if (is_null($this->name)) { |
|
83 | - throw new EmptyPropertyException('File name is not defined', 1362587742); |
|
84 | - } |
|
85 | - |
|
86 | - return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get the original file name. |
|
91 | - * |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getOriginalName() |
|
95 | - { |
|
96 | - return $this->getName(); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Get the file size |
|
101 | - * |
|
102 | - * @throws \Exception |
|
103 | - * @return integer file-size in byte |
|
104 | - */ |
|
105 | - public function getSize() |
|
106 | - { |
|
107 | - if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) { |
|
108 | - return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH']; |
|
109 | - } else { |
|
110 | - throw new \Exception('Getting content length is not supported.'); |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Get MIME type of file. |
|
116 | - * |
|
117 | - * @return string|boolean MIME type. eg, text/html, false on error |
|
118 | - */ |
|
119 | - public function getMimeType() |
|
120 | - { |
|
121 | - $this->checkFileExistence(); |
|
122 | - if (function_exists('finfo_file')) { |
|
123 | - $fileInfo = new \finfo(); |
|
124 | - return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE); |
|
125 | - } elseif (function_exists('mime_content_type')) { |
|
126 | - return mime_content_type($this->getFileWithAbsolutePath()); |
|
127 | - } |
|
128 | - return false; |
|
129 | - } |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $inputName = 'qqfile'; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $uploadFolder; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $name; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $image; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $extension; |
|
43 | + |
|
44 | + /** |
|
45 | + * @return \Fab\Media\FileUpload\Base64File |
|
46 | + */ |
|
47 | + public function __construct() |
|
48 | + { |
|
49 | + // Processes the encoded image data and returns the decoded image |
|
50 | + $encodedImage = GeneralUtility::_POST($this->inputName); |
|
51 | + if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) { |
|
52 | + $this->extension = $matches[1]; |
|
53 | + } else { |
|
54 | + return false; |
|
55 | + } |
|
56 | + |
|
57 | + // Remove the mime-type header |
|
58 | + $data = reset(array_reverse(explode('base64,', $encodedImage))); |
|
59 | + |
|
60 | + // Use strict mode to prevent characters from outside the base64 range |
|
61 | + $this->image = base64_decode($data, true); |
|
62 | + |
|
63 | + if (!$this->image) { |
|
64 | + return false; |
|
65 | + } |
|
66 | + |
|
67 | + $this->setName(uniqid() . '.' . $this->extension); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Save the file to the specified path |
|
72 | + * |
|
73 | + * @throws EmptyPropertyException |
|
74 | + * @return boolean true on success |
|
75 | + */ |
|
76 | + public function save() |
|
77 | + { |
|
78 | + if (is_null($this->uploadFolder)) { |
|
79 | + throw new EmptyPropertyException('Upload folder is not defined', 1362587741); |
|
80 | + } |
|
81 | + |
|
82 | + if (is_null($this->name)) { |
|
83 | + throw new EmptyPropertyException('File name is not defined', 1362587742); |
|
84 | + } |
|
85 | + |
|
86 | + return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get the original file name. |
|
91 | + * |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getOriginalName() |
|
95 | + { |
|
96 | + return $this->getName(); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Get the file size |
|
101 | + * |
|
102 | + * @throws \Exception |
|
103 | + * @return integer file-size in byte |
|
104 | + */ |
|
105 | + public function getSize() |
|
106 | + { |
|
107 | + if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) { |
|
108 | + return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH']; |
|
109 | + } else { |
|
110 | + throw new \Exception('Getting content length is not supported.'); |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Get MIME type of file. |
|
116 | + * |
|
117 | + * @return string|boolean MIME type. eg, text/html, false on error |
|
118 | + */ |
|
119 | + public function getMimeType() |
|
120 | + { |
|
121 | + $this->checkFileExistence(); |
|
122 | + if (function_exists('finfo_file')) { |
|
123 | + $fileInfo = new \finfo(); |
|
124 | + return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE); |
|
125 | + } elseif (function_exists('mime_content_type')) { |
|
126 | + return mime_content_type($this->getFileWithAbsolutePath()); |
|
127 | + } |
|
128 | + return false; |
|
129 | + } |
|
130 | 130 | } |