Completed
Push — master ( ad447f...f2215d )
by Fabien
03:37 queued 48s
created
Classes/Thumbnail/FallBackThumbnailProcessor.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,48 +15,48 @@
 block discarded – undo
15 15
 class FallBackThumbnailProcessor extends AbstractThumbnailProcessor
16 16
 {
17 17
 
18
-    /**
19
-     * Render a fallback thumbnail if no type was found for the given resource.
20
-     *
21
-     * @return string
22
-     */
23
-    public function create()
24
-    {
25
-        return sprintf(
26
-            '<img src="%s" hspace="2" class="" alt="" />',
27
-            Path::getRelativePath('Icons/UnknownMimeType.png')
28
-        );
29
-    }
18
+	/**
19
+	 * Render a fallback thumbnail if no type was found for the given resource.
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public function create()
24
+	{
25
+		return sprintf(
26
+			'<img src="%s" hspace="2" class="" alt="" />',
27
+			Path::getRelativePath('Icons/UnknownMimeType.png')
28
+		);
29
+	}
30 30
 
31
-    /**
32
-     * Render the URI of the thumbnail.
33
-     *
34
-     * @return string
35
-     */
36
-    public function renderUri()
37
-    {
38
-        // Nothing to implement.
39
-    }
31
+	/**
32
+	 * Render the URI of the thumbnail.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function renderUri()
37
+	{
38
+		// Nothing to implement.
39
+	}
40 40
 
41
-    /**
42
-     * Render the tag image which is the main one for a thumbnail.
43
-     *
44
-     * @param string $result
45
-     * @return string
46
-     */
47
-    public function renderTagImage($result)
48
-    {
49
-        // Nothing to implement.
50
-    }
41
+	/**
42
+	 * Render the tag image which is the main one for a thumbnail.
43
+	 *
44
+	 * @param string $result
45
+	 * @return string
46
+	 */
47
+	public function renderTagImage($result)
48
+	{
49
+		// Nothing to implement.
50
+	}
51 51
 
52
-    /**
53
-     * Render a wrapping anchor around the thumbnail.
54
-     *
55
-     * @param string $result
56
-     * @return string
57
-     */
58
-    public function renderTagAnchor($result)
59
-    {
60
-        // Nothing to implement.
61
-    }
52
+	/**
53
+	 * Render a wrapping anchor around the thumbnail.
54
+	 *
55
+	 * @param string $result
56
+	 * @return string
57
+	 */
58
+	public function renderTagAnchor($result)
59
+	{
60
+		// Nothing to implement.
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/ThumbnailService.php 1 patch
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -20,313 +20,313 @@
 block discarded – undo
20 20
 class ThumbnailService
21 21
 {
22 22
 
23
-    /**
24
-     * @var array
25
-     */
26
-    protected $allowedOutputTypes = array(
27
-        ThumbnailInterface::OUTPUT_IMAGE,
28
-        ThumbnailInterface::OUTPUT_IMAGE_WRAPPED,
29
-        ThumbnailInterface::OUTPUT_URI,
30
-    );
31
-
32
-    /**
33
-     * Configure the output of the thumbnail service whether it is wrapped or not.
34
-     * Default output is: ThumbnailInterface::OUTPUT_IMAGE
35
-     *
36
-     * @var string
37
-     */
38
-    protected $outputType = ThumbnailInterface::OUTPUT_IMAGE;
39
-
40
-    /**
41
-     * @var File
42
-     */
43
-    protected $file;
44
-
45
-    /**
46
-     * Define width, height and all sort of attributes to render a thumbnail.
47
-     * @see TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::Image
48
-     * @var array
49
-     */
50
-    protected $configuration = [];
51
-
52
-    /**
53
-     * Define width, height and all sort of attributes to render the anchor file
54
-     * which is wrapping the image
55
-     *
56
-     * @see TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::Image
57
-     * @var array
58
-     */
59
-    protected $configurationWrap = [];
60
-
61
-    /**
62
-     * DOM attributes to add to the image preview.
63
-     *
64
-     * @var array
65
-     */
66
-    protected $attributes = [
67
-        'class' => 'thumbnail',
68
-    ];
69
-
70
-    /**
71
-     * Define in which window will the thumbnail be opened.
72
-     * Does only apply if the thumbnail is wrapped (with an anchor).
73
-     *
74
-     * @var string
75
-     */
76
-    protected $target = ThumbnailInterface::TARGET_BLANK;
77
-
78
-    /**
79
-     * URI of the wrapping anchor pointing to the file.
80
-     * replacing the "?" <a href="?">...</a>
81
-     * The URI is automatically computed if not set.
82
-     * @var string
83
-     */
84
-    protected $anchorUri;
85
-
86
-    /**
87
-     * Whether a time stamp is appended to the image.
88
-     * Appending the time stamp can prevent caching
89
-     *
90
-     * @var bool
91
-     */
92
-    protected $appendTimeStamp = false;
93
-
94
-    /**
95
-     * Define the processing type for the thumbnail.
96
-     * As instance for image the default is ProcessedFile::CONTEXT_IMAGECROPSCALEMASK.
97
-     *
98
-     * @var string
99
-     */
100
-    protected $processingType;
101
-
102
-    /**
103
-     * Constructor
104
-     *
105
-     * @param File $file
106
-     */
107
-    public function __construct(File $file = null)
108
-    {
109
-        $this->file = $file;
110
-    }
111
-
112
-    /**
113
-     * Render a thumbnail of a media
114
-     *
115
-     * @throws MissingTcaConfigurationException
116
-     * @return string
117
-     * @throws \InvalidArgumentException
118
-     */
119
-    public function create()
120
-    {
121
-
122
-        if (!$this->file) {
123
-            throw new MissingTcaConfigurationException('Missing File object. Forgotten to set a file?', 1355933144);
124
-        }
125
-
126
-        // Default class name
127
-        $className = 'Fab\Media\Thumbnail\FallBackThumbnailProcessor';
128
-        if (File::FILETYPE_IMAGE === $this->file->getType()) {
129
-            $className = 'Fab\Media\Thumbnail\ImageThumbnailProcessor';
130
-        } elseif (File::FILETYPE_AUDIO === $this->file->getType()) {
131
-            $className = 'Fab\Media\Thumbnail\AudioThumbnailProcessor';
132
-        } elseif (File::FILETYPE_VIDEO === $this->file->getType()) {
133
-            $className = 'Fab\Media\Thumbnail\VideoThumbnailProcessor';
134
-        } elseif (File::FILETYPE_APPLICATION === $this->file->getType() || File::FILETYPE_TEXT === $this->file->getType()) {
135
-            $className = 'Fab\Media\Thumbnail\ApplicationThumbnailProcessor';
136
-        }
137
-
138
-        /** @var $processorInstance \Fab\Media\Thumbnail\ThumbnailProcessorInterface */
139
-        $processorInstance = GeneralUtility::makeInstance($className);
140
-
141
-        $thumbnail = '';
142
-        if ($this->file->exists()) {
143
-            $thumbnail = $processorInstance->setThumbnailService($this)->create();
144
-        } else {
145
-            $logger = Logger::getInstance($this);
146
-            $logger->warning(sprintf('Resource not found for File uid "%s" at %s', $this->file->getUid(), $this->file->getIdentifier()));
147
-        }
148
-
149
-        return $thumbnail;
150
-    }
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public function getConfigurationWrap()
156
-    {
157
-        return $this->configurationWrap;
158
-    }
159
-
160
-    /**
161
-     * @param array $configurationWrap
162
-     * @return $this
163
-     */
164
-    public function setConfigurationWrap($configurationWrap)
165
-    {
166
-        $this->configurationWrap = $configurationWrap;
167
-        return $this;
168
-    }
169
-
170
-    /**
171
-     * @return mixed
172
-     */
173
-    public function getFile()
174
-    {
175
-        return $this->file;
176
-    }
177
-
178
-    /**
179
-     * @return array
180
-     */
181
-    public function getConfiguration()
182
-    {
183
-        return $this->configuration;
184
-    }
185
-
186
-    /**
187
-     * @param array|ThumbnailConfiguration $configuration
188
-     * @return $this
189
-     */
190
-    public function setConfiguration($configuration)
191
-    {
192
-        if ($configuration instanceof ThumbnailConfiguration) {
193
-            $configurationObject = $configuration;
194
-            $configuration = [];
195
-
196
-            if ($configurationObject->getWidth() > 0) {
197
-                $configuration['width'] = $configurationObject->getWidth();
198
-            }
199
-
200
-            if ($configurationObject->getHeight() > 0) {
201
-                $configuration['height'] = $configurationObject->getHeight();
202
-            }
203
-
204
-            if ($configurationObject->getStyle()) {
205
-                $this->attributes['style'] = $configurationObject->getStyle();
206
-            }
207
-
208
-            if ($configurationObject->getClassName()) {
209
-                $this->attributes['class'] = $configurationObject->getClassName();
210
-            }
211
-        }
212
-
213
-        $this->configuration = $configuration;
214
-        return $this;
215
-    }
216
-
217
-    /**
218
-     * @return array
219
-     */
220
-    public function getAttributes()
221
-    {
222
-        return $this->attributes;
223
-    }
224
-
225
-    /**
226
-     * @param array $attributes
227
-     * @return $this
228
-     */
229
-    public function setAttributes($attributes)
230
-    {
231
-        $this->attributes = $attributes;
232
-        return $this;
233
-    }
234
-
235
-    /**
236
-     * @return string
237
-     */
238
-    public function getOutputType()
239
-    {
240
-        return $this->outputType;
241
-    }
242
-
243
-    /**
244
-     * @throws InvalidKeyInArrayException
245
-     * @param string $outputType
246
-     * @return $this
247
-     */
248
-    public function setOutputType($outputType)
249
-    {
250
-        if (!in_array($outputType, $this->allowedOutputTypes)) {
251
-            throw new InvalidKeyInArrayException(
252
-                sprintf('Output type "%s" is not allowed', $outputType),
253
-                1373020076
254
-            );
255
-        }
256
-        $this->outputType = $outputType;
257
-        return $this;
258
-    }
259
-
260
-    /**
261
-     * @return string
262
-     */
263
-    public function getTarget()
264
-    {
265
-        return $this->target;
266
-    }
267
-
268
-    /**
269
-     * @param string $target
270
-     * @return $this
271
-     */
272
-    public function setTarget($target)
273
-    {
274
-        $this->target = $target;
275
-        return $this;
276
-    }
277
-
278
-    /**
279
-     * @return string
280
-     */
281
-    public function getAnchorUri()
282
-    {
283
-        return $this->anchorUri;
284
-    }
285
-
286
-    /**
287
-     * @param string $anchorUri
288
-     * @return $this
289
-     */
290
-    public function setAnchorUri($anchorUri)
291
-    {
292
-        $this->anchorUri = $anchorUri;
293
-        return $this;
294
-    }
295
-
296
-    /**
297
-     * @return boolean
298
-     */
299
-    public function getAppendTimeStamp()
300
-    {
301
-        return $this->appendTimeStamp;
302
-    }
303
-
304
-    /**
305
-     * @param boolean $appendTimeStamp
306
-     * @return $this
307
-     */
308
-    public function setAppendTimeStamp($appendTimeStamp)
309
-    {
310
-        $this->appendTimeStamp = (bool)$appendTimeStamp;
311
-        return $this;
312
-    }
313
-
314
-    /**
315
-     * @return string
316
-     */
317
-    public function getProcessingType()
318
-    {
319
-        $this->processingType;
320
-    }
321
-
322
-    /**
323
-     * @param string $processingType
324
-     * @return $this
325
-     */
326
-    public function setProcessingType($processingType)
327
-    {
328
-        $this->processingType = $processingType;
329
-        return $this;
330
-    }
23
+	/**
24
+	 * @var array
25
+	 */
26
+	protected $allowedOutputTypes = array(
27
+		ThumbnailInterface::OUTPUT_IMAGE,
28
+		ThumbnailInterface::OUTPUT_IMAGE_WRAPPED,
29
+		ThumbnailInterface::OUTPUT_URI,
30
+	);
31
+
32
+	/**
33
+	 * Configure the output of the thumbnail service whether it is wrapped or not.
34
+	 * Default output is: ThumbnailInterface::OUTPUT_IMAGE
35
+	 *
36
+	 * @var string
37
+	 */
38
+	protected $outputType = ThumbnailInterface::OUTPUT_IMAGE;
39
+
40
+	/**
41
+	 * @var File
42
+	 */
43
+	protected $file;
44
+
45
+	/**
46
+	 * Define width, height and all sort of attributes to render a thumbnail.
47
+	 * @see TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::Image
48
+	 * @var array
49
+	 */
50
+	protected $configuration = [];
51
+
52
+	/**
53
+	 * Define width, height and all sort of attributes to render the anchor file
54
+	 * which is wrapping the image
55
+	 *
56
+	 * @see TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::Image
57
+	 * @var array
58
+	 */
59
+	protected $configurationWrap = [];
60
+
61
+	/**
62
+	 * DOM attributes to add to the image preview.
63
+	 *
64
+	 * @var array
65
+	 */
66
+	protected $attributes = [
67
+		'class' => 'thumbnail',
68
+	];
69
+
70
+	/**
71
+	 * Define in which window will the thumbnail be opened.
72
+	 * Does only apply if the thumbnail is wrapped (with an anchor).
73
+	 *
74
+	 * @var string
75
+	 */
76
+	protected $target = ThumbnailInterface::TARGET_BLANK;
77
+
78
+	/**
79
+	 * URI of the wrapping anchor pointing to the file.
80
+	 * replacing the "?" <a href="?">...</a>
81
+	 * The URI is automatically computed if not set.
82
+	 * @var string
83
+	 */
84
+	protected $anchorUri;
85
+
86
+	/**
87
+	 * Whether a time stamp is appended to the image.
88
+	 * Appending the time stamp can prevent caching
89
+	 *
90
+	 * @var bool
91
+	 */
92
+	protected $appendTimeStamp = false;
93
+
94
+	/**
95
+	 * Define the processing type for the thumbnail.
96
+	 * As instance for image the default is ProcessedFile::CONTEXT_IMAGECROPSCALEMASK.
97
+	 *
98
+	 * @var string
99
+	 */
100
+	protected $processingType;
101
+
102
+	/**
103
+	 * Constructor
104
+	 *
105
+	 * @param File $file
106
+	 */
107
+	public function __construct(File $file = null)
108
+	{
109
+		$this->file = $file;
110
+	}
111
+
112
+	/**
113
+	 * Render a thumbnail of a media
114
+	 *
115
+	 * @throws MissingTcaConfigurationException
116
+	 * @return string
117
+	 * @throws \InvalidArgumentException
118
+	 */
119
+	public function create()
120
+	{
121
+
122
+		if (!$this->file) {
123
+			throw new MissingTcaConfigurationException('Missing File object. Forgotten to set a file?', 1355933144);
124
+		}
125
+
126
+		// Default class name
127
+		$className = 'Fab\Media\Thumbnail\FallBackThumbnailProcessor';
128
+		if (File::FILETYPE_IMAGE === $this->file->getType()) {
129
+			$className = 'Fab\Media\Thumbnail\ImageThumbnailProcessor';
130
+		} elseif (File::FILETYPE_AUDIO === $this->file->getType()) {
131
+			$className = 'Fab\Media\Thumbnail\AudioThumbnailProcessor';
132
+		} elseif (File::FILETYPE_VIDEO === $this->file->getType()) {
133
+			$className = 'Fab\Media\Thumbnail\VideoThumbnailProcessor';
134
+		} elseif (File::FILETYPE_APPLICATION === $this->file->getType() || File::FILETYPE_TEXT === $this->file->getType()) {
135
+			$className = 'Fab\Media\Thumbnail\ApplicationThumbnailProcessor';
136
+		}
137
+
138
+		/** @var $processorInstance \Fab\Media\Thumbnail\ThumbnailProcessorInterface */
139
+		$processorInstance = GeneralUtility::makeInstance($className);
140
+
141
+		$thumbnail = '';
142
+		if ($this->file->exists()) {
143
+			$thumbnail = $processorInstance->setThumbnailService($this)->create();
144
+		} else {
145
+			$logger = Logger::getInstance($this);
146
+			$logger->warning(sprintf('Resource not found for File uid "%s" at %s', $this->file->getUid(), $this->file->getIdentifier()));
147
+		}
148
+
149
+		return $thumbnail;
150
+	}
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function getConfigurationWrap()
156
+	{
157
+		return $this->configurationWrap;
158
+	}
159
+
160
+	/**
161
+	 * @param array $configurationWrap
162
+	 * @return $this
163
+	 */
164
+	public function setConfigurationWrap($configurationWrap)
165
+	{
166
+		$this->configurationWrap = $configurationWrap;
167
+		return $this;
168
+	}
169
+
170
+	/**
171
+	 * @return mixed
172
+	 */
173
+	public function getFile()
174
+	{
175
+		return $this->file;
176
+	}
177
+
178
+	/**
179
+	 * @return array
180
+	 */
181
+	public function getConfiguration()
182
+	{
183
+		return $this->configuration;
184
+	}
185
+
186
+	/**
187
+	 * @param array|ThumbnailConfiguration $configuration
188
+	 * @return $this
189
+	 */
190
+	public function setConfiguration($configuration)
191
+	{
192
+		if ($configuration instanceof ThumbnailConfiguration) {
193
+			$configurationObject = $configuration;
194
+			$configuration = [];
195
+
196
+			if ($configurationObject->getWidth() > 0) {
197
+				$configuration['width'] = $configurationObject->getWidth();
198
+			}
199
+
200
+			if ($configurationObject->getHeight() > 0) {
201
+				$configuration['height'] = $configurationObject->getHeight();
202
+			}
203
+
204
+			if ($configurationObject->getStyle()) {
205
+				$this->attributes['style'] = $configurationObject->getStyle();
206
+			}
207
+
208
+			if ($configurationObject->getClassName()) {
209
+				$this->attributes['class'] = $configurationObject->getClassName();
210
+			}
211
+		}
212
+
213
+		$this->configuration = $configuration;
214
+		return $this;
215
+	}
216
+
217
+	/**
218
+	 * @return array
219
+	 */
220
+	public function getAttributes()
221
+	{
222
+		return $this->attributes;
223
+	}
224
+
225
+	/**
226
+	 * @param array $attributes
227
+	 * @return $this
228
+	 */
229
+	public function setAttributes($attributes)
230
+	{
231
+		$this->attributes = $attributes;
232
+		return $this;
233
+	}
234
+
235
+	/**
236
+	 * @return string
237
+	 */
238
+	public function getOutputType()
239
+	{
240
+		return $this->outputType;
241
+	}
242
+
243
+	/**
244
+	 * @throws InvalidKeyInArrayException
245
+	 * @param string $outputType
246
+	 * @return $this
247
+	 */
248
+	public function setOutputType($outputType)
249
+	{
250
+		if (!in_array($outputType, $this->allowedOutputTypes)) {
251
+			throw new InvalidKeyInArrayException(
252
+				sprintf('Output type "%s" is not allowed', $outputType),
253
+				1373020076
254
+			);
255
+		}
256
+		$this->outputType = $outputType;
257
+		return $this;
258
+	}
259
+
260
+	/**
261
+	 * @return string
262
+	 */
263
+	public function getTarget()
264
+	{
265
+		return $this->target;
266
+	}
267
+
268
+	/**
269
+	 * @param string $target
270
+	 * @return $this
271
+	 */
272
+	public function setTarget($target)
273
+	{
274
+		$this->target = $target;
275
+		return $this;
276
+	}
277
+
278
+	/**
279
+	 * @return string
280
+	 */
281
+	public function getAnchorUri()
282
+	{
283
+		return $this->anchorUri;
284
+	}
285
+
286
+	/**
287
+	 * @param string $anchorUri
288
+	 * @return $this
289
+	 */
290
+	public function setAnchorUri($anchorUri)
291
+	{
292
+		$this->anchorUri = $anchorUri;
293
+		return $this;
294
+	}
295
+
296
+	/**
297
+	 * @return boolean
298
+	 */
299
+	public function getAppendTimeStamp()
300
+	{
301
+		return $this->appendTimeStamp;
302
+	}
303
+
304
+	/**
305
+	 * @param boolean $appendTimeStamp
306
+	 * @return $this
307
+	 */
308
+	public function setAppendTimeStamp($appendTimeStamp)
309
+	{
310
+		$this->appendTimeStamp = (bool)$appendTimeStamp;
311
+		return $this;
312
+	}
313
+
314
+	/**
315
+	 * @return string
316
+	 */
317
+	public function getProcessingType()
318
+	{
319
+		$this->processingType;
320
+	}
321
+
322
+	/**
323
+	 * @param string $processingType
324
+	 * @return $this
325
+	 */
326
+	public function setProcessingType($processingType)
327
+	{
328
+		$this->processingType = $processingType;
329
+		return $this;
330
+	}
331 331
 
332 332
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/VideoThumbnailProcessor.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -17,96 +17,96 @@
 block discarded – undo
17 17
 class VideoThumbnailProcessor extends AbstractThumbnailProcessor
18 18
 {
19 19
 
20
-    /**
21
-     * Render a thumbnail of a resource of type video.
22
-     *
23
-     * @return string
24
-     */
25
-    public function create()
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
-     * @return string
41
-     */
42
-    public function renderUri()
43
-    {
44
-
45
-        $relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
-        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
-        if (!file_exists($fileNameAndPath)) {
48
-            $relativePath = 'Icons/UnknownMimeType.png';
49
-        }
50
-
51
-        $uri = Path::getRelativePath($relativePath);
52
-        return $this->prefixUri($uri);
53
-    }
54
-
55
-    /**
56
-     * Render the tag image which is the main one for a thumbnail.
57
-     *
58
-     * @param string $result
59
-     * @return string
60
-     */
61
-    public function renderTagImage($result)
62
-    {
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->getFile()->getProperty('tstamp') : '',
72
-            $this->getTitle(),
73
-            $this->getTitle(),
74
-            $this->renderAttributes()
75
-        );
76
-    }
77
-
78
-    /**
79
-     * Compute and return the title of the file.
80
-     *
81
-     * @return string
82
-     */
83
-    protected function getTitle()
84
-    {
85
-        $result = $this->getFile()->getProperty('title');
86
-        if (!$result) {
87
-            $result = $this->getFile()->getName();
88
-        }
89
-        return htmlspecialchars($result);
90
-    }
91
-
92
-    /**
93
-     * Render a wrapping anchor around the thumbnail.
94
-     *
95
-     * @param string $result
96
-     * @return string
97
-     */
98
-    public function renderTagAnchor($result)
99
-    {
100
-
101
-        $file = $this->getFile();
102
-
103
-        return sprintf(
104
-            '<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
-            $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
-            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
-            $this->thumbnailService->getTarget(),
108
-            $file->getUid(),
109
-            $result
110
-        );
111
-    }
20
+	/**
21
+	 * Render a thumbnail of a resource of type video.
22
+	 *
23
+	 * @return string
24
+	 */
25
+	public function create()
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
+	 * @return string
41
+	 */
42
+	public function renderUri()
43
+	{
44
+
45
+		$relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
+		$fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
+		if (!file_exists($fileNameAndPath)) {
48
+			$relativePath = 'Icons/UnknownMimeType.png';
49
+		}
50
+
51
+		$uri = Path::getRelativePath($relativePath);
52
+		return $this->prefixUri($uri);
53
+	}
54
+
55
+	/**
56
+	 * Render the tag image which is the main one for a thumbnail.
57
+	 *
58
+	 * @param string $result
59
+	 * @return string
60
+	 */
61
+	public function renderTagImage($result)
62
+	{
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->getFile()->getProperty('tstamp') : '',
72
+			$this->getTitle(),
73
+			$this->getTitle(),
74
+			$this->renderAttributes()
75
+		);
76
+	}
77
+
78
+	/**
79
+	 * Compute and return the title of the file.
80
+	 *
81
+	 * @return string
82
+	 */
83
+	protected function getTitle()
84
+	{
85
+		$result = $this->getFile()->getProperty('title');
86
+		if (!$result) {
87
+			$result = $this->getFile()->getName();
88
+		}
89
+		return htmlspecialchars($result);
90
+	}
91
+
92
+	/**
93
+	 * Render a wrapping anchor around the thumbnail.
94
+	 *
95
+	 * @param string $result
96
+	 * @return string
97
+	 */
98
+	public function renderTagAnchor($result)
99
+	{
100
+
101
+		$file = $this->getFile();
102
+
103
+		return sprintf(
104
+			'<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
+			$this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
+			$this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
+			$this->thumbnailService->getTarget(),
108
+			$file->getUid(),
109
+			$result
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
 
45 45
         $relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
-        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
46
+        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/'.$relativePath);
47 47
         if (!file_exists($fileNameAndPath)) {
48 48
             $relativePath = 'Icons/UnknownMimeType.png';
49 49
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         return sprintf(
69 69
             '<img src="%s%s" title="%s" alt="%s" %s/>',
70 70
             $result,
71
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getFile()->getProperty('tstamp') : '',
71
+            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator.$this->getFile()->getProperty('tstamp') : '',
72 72
             $this->getTitle(),
73 73
             $this->getTitle(),
74 74
             $this->renderAttributes()
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         return sprintf(
104 104
             '<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105 105
             $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
-            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
106
+            $this->thumbnailService->getAppendTimeStamp() ? '?'.$file->getProperty('tstamp') : '',
107 107
             $this->thumbnailService->getTarget(),
108 108
             $file->getUid(),
109 109
             $result
Please login to merge, or discard this patch.
Classes/Thumbnail/ThumbnailConfiguration.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -15,96 +15,96 @@
 block discarded – undo
15 15
 class ThumbnailConfiguration
16 16
 {
17 17
 
18
-    /**
19
-     * @var int
20
-     */
21
-    protected $width = 0;
22
-
23
-    /**
24
-     * @var int
25
-     */
26
-    protected $height = 0;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $style = '';
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $className = '';
37
-
38
-    /**
39
-     * @return int
40
-     */
41
-    public function getWidth()
42
-    {
43
-        return $this->width;
44
-    }
45
-
46
-    /**
47
-     * @param int $width
48
-     * @return $this
49
-     */
50
-    public function setWidth($width)
51
-    {
52
-        $this->width = $width;
53
-        return $this;
54
-    }
55
-
56
-    /**
57
-     * @return int
58
-     */
59
-    public function getHeight()
60
-    {
61
-        return $this->height;
62
-    }
63
-
64
-    /**
65
-     * @param int $height
66
-     * @return $this
67
-     */
68
-    public function setHeight($height)
69
-    {
70
-        $this->height = $height;
71
-        return $this;
72
-    }
73
-
74
-    /**
75
-     * @return string
76
-     */
77
-    public function getStyle()
78
-    {
79
-        return $this->style;
80
-    }
81
-
82
-    /**
83
-     * @param string $style
84
-     * @return $this
85
-     */
86
-    public function setStyle($style)
87
-    {
88
-        $this->style = $style;
89
-        return $this;
90
-    }
91
-
92
-    /**
93
-     * @return string
94
-     */
95
-    public function getClassName()
96
-    {
97
-        return $this->className;
98
-    }
99
-
100
-    /**
101
-     * @param string $className
102
-     * @return $this
103
-     */
104
-    public function setClassName($className)
105
-    {
106
-        $this->className = $className;
107
-        return $this;
108
-    }
18
+	/**
19
+	 * @var int
20
+	 */
21
+	protected $width = 0;
22
+
23
+	/**
24
+	 * @var int
25
+	 */
26
+	protected $height = 0;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $style = '';
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $className = '';
37
+
38
+	/**
39
+	 * @return int
40
+	 */
41
+	public function getWidth()
42
+	{
43
+		return $this->width;
44
+	}
45
+
46
+	/**
47
+	 * @param int $width
48
+	 * @return $this
49
+	 */
50
+	public function setWidth($width)
51
+	{
52
+		$this->width = $width;
53
+		return $this;
54
+	}
55
+
56
+	/**
57
+	 * @return int
58
+	 */
59
+	public function getHeight()
60
+	{
61
+		return $this->height;
62
+	}
63
+
64
+	/**
65
+	 * @param int $height
66
+	 * @return $this
67
+	 */
68
+	public function setHeight($height)
69
+	{
70
+		$this->height = $height;
71
+		return $this;
72
+	}
73
+
74
+	/**
75
+	 * @return string
76
+	 */
77
+	public function getStyle()
78
+	{
79
+		return $this->style;
80
+	}
81
+
82
+	/**
83
+	 * @param string $style
84
+	 * @return $this
85
+	 */
86
+	public function setStyle($style)
87
+	{
88
+		$this->style = $style;
89
+		return $this;
90
+	}
91
+
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function getClassName()
96
+	{
97
+		return $this->className;
98
+	}
99
+
100
+	/**
101
+	 * @param string $className
102
+	 * @return $this
103
+	 */
104
+	public function setClassName($className)
105
+	{
106
+		$this->className = $className;
107
+		return $this;
108
+	}
109 109
 
110 110
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/AudioThumbnailProcessor.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -17,96 +17,96 @@
 block discarded – undo
17 17
 class AudioThumbnailProcessor extends AbstractThumbnailProcessor
18 18
 {
19 19
 
20
-    /**
21
-     * Render a thumbnail of a resource of type audio.
22
-     *
23
-     * @return string
24
-     */
25
-    public function create()
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
-     * @return string
41
-     */
42
-    public function renderUri()
43
-    {
44
-
45
-        $relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
-        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
-        if (!file_exists($fileNameAndPath)) {
48
-            $relativePath = 'Icons/UnknownMimeType.png';
49
-        }
50
-
51
-        $uri = Path::getRelativePath($relativePath);
52
-        return $this->prefixUri($uri);
53
-    }
54
-
55
-    /**
56
-     * Render the tag image which is the main one for a thumbnail.
57
-     *
58
-     * @param string $result
59
-     * @return string
60
-     */
61
-    public function renderTagImage($result)
62
-    {
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->getFile()->getProperty('tstamp') : '',
72
-            $this->getTitle(),
73
-            $this->getTitle(),
74
-            $this->renderAttributes()
75
-        );
76
-    }
77
-
78
-    /**
79
-     * Compute and return the title of the file.
80
-     *
81
-     * @return string
82
-     */
83
-    protected function getTitle()
84
-    {
85
-        $result = $this->getFile()->getProperty('title');
86
-        if (!$result) {
87
-            $result = $this->getFile()->getName();
88
-        }
89
-        return htmlspecialchars($result);
90
-    }
91
-
92
-    /**
93
-     * Render a wrapping anchor around the thumbnail.
94
-     *
95
-     * @param string $result
96
-     * @return string
97
-     */
98
-    public function renderTagAnchor($result)
99
-    {
100
-
101
-        $file = $this->getFile();
102
-
103
-        return sprintf(
104
-            '<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
-            $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
-            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
-            $this->thumbnailService->getTarget(),
108
-            $file->getUid(),
109
-            $result
110
-        );
111
-    }
20
+	/**
21
+	 * Render a thumbnail of a resource of type audio.
22
+	 *
23
+	 * @return string
24
+	 */
25
+	public function create()
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
+	 * @return string
41
+	 */
42
+	public function renderUri()
43
+	{
44
+
45
+		$relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
+		$fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
+		if (!file_exists($fileNameAndPath)) {
48
+			$relativePath = 'Icons/UnknownMimeType.png';
49
+		}
50
+
51
+		$uri = Path::getRelativePath($relativePath);
52
+		return $this->prefixUri($uri);
53
+	}
54
+
55
+	/**
56
+	 * Render the tag image which is the main one for a thumbnail.
57
+	 *
58
+	 * @param string $result
59
+	 * @return string
60
+	 */
61
+	public function renderTagImage($result)
62
+	{
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->getFile()->getProperty('tstamp') : '',
72
+			$this->getTitle(),
73
+			$this->getTitle(),
74
+			$this->renderAttributes()
75
+		);
76
+	}
77
+
78
+	/**
79
+	 * Compute and return the title of the file.
80
+	 *
81
+	 * @return string
82
+	 */
83
+	protected function getTitle()
84
+	{
85
+		$result = $this->getFile()->getProperty('title');
86
+		if (!$result) {
87
+			$result = $this->getFile()->getName();
88
+		}
89
+		return htmlspecialchars($result);
90
+	}
91
+
92
+	/**
93
+	 * Render a wrapping anchor around the thumbnail.
94
+	 *
95
+	 * @param string $result
96
+	 * @return string
97
+	 */
98
+	public function renderTagAnchor($result)
99
+	{
100
+
101
+		$file = $this->getFile();
102
+
103
+		return sprintf(
104
+			'<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
+			$this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
+			$this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
+			$this->thumbnailService->getTarget(),
108
+			$file->getUid(),
109
+			$result
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
 
45 45
         $relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
-        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
46
+        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/'.$relativePath);
47 47
         if (!file_exists($fileNameAndPath)) {
48 48
             $relativePath = 'Icons/UnknownMimeType.png';
49 49
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         return sprintf(
69 69
             '<img src="%s%s" title="%s" alt="%s" %s/>',
70 70
             $result,
71
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getFile()->getProperty('tstamp') : '',
71
+            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator.$this->getFile()->getProperty('tstamp') : '',
72 72
             $this->getTitle(),
73 73
             $this->getTitle(),
74 74
             $this->renderAttributes()
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         return sprintf(
104 104
             '<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105 105
             $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
-            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
106
+            $this->thumbnailService->getAppendTimeStamp() ? '?'.$file->getProperty('tstamp') : '',
107 107
             $this->thumbnailService->getTarget(),
108 108
             $file->getUid(),
109 109
             $result
Please login to merge, or discard this patch.
Classes/Thumbnail/ApplicationThumbnailProcessor.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -18,140 +18,140 @@
 block discarded – undo
18 18
 class ApplicationThumbnailProcessor extends AbstractThumbnailProcessor
19 19
 {
20 20
 
21
-    /**
22
-     * Render a thumbnail of a resource of type application.
23
-     *
24
-     * @return string
25
-     */
26
-    public function create()
27
-    {
28
-
29
-        $steps = $this->getRenderingSteps();
30
-
31
-        $result = '';
32
-        while ($step = array_shift($steps)) {
33
-            $result = $this->$step($result);
34
-        }
35
-
36
-        return $result;
37
-    }
38
-
39
-    /**
40
-     * Render the URI of the thumbnail.
41
-     *
42
-     * @return string
43
-     */
44
-    public function renderUri()
45
-    {
46
-        if ($this->isThumbnailPossible($this->getFile()->getExtension())) {
47
-            $this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration());
48
-            $uri = $this->processedFile->getPublicUrl(true);
49
-
50
-            // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
51
-            if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
52
-                $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
53
-            }
54
-        } else {
55
-            $uri = $this->getIcon($this->getFile()->getExtension());
56
-        }
57
-        return $this->prefixUri($uri);
58
-    }
59
-
60
-    /**
61
-     * Render the tag image which is the main one for a thumbnail.
62
-     *
63
-     * @param string $result
64
-     * @return string
65
-     */
66
-    public function renderTagImage($result)
67
-    {
68
-
69
-        // Variable $result corresponds to an URL in this case.
70
-        // Analyse the URL and compute the adequate separator between arguments.
71
-        $parameterSeparator = strpos($result, '?') === false ? '?' : '&';
72
-
73
-        return sprintf(
74
-            '<img src="%s%s" title="%s" alt="%s" %s/>',
75
-            $result,
76
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '',
77
-            $this->getTitle(),
78
-            $this->getTitle(),
79
-            $this->renderAttributes()
80
-        );
81
-    }
82
-
83
-    /**
84
-     * Compute and return the time stamp.
85
-     *
86
-     * @return int
87
-     */
88
-    protected function getTimeStamp()
89
-    {
90
-        $result = $this->getFile()->getProperty('tstamp');
91
-        if ($this->processedFile) {
92
-            $result = $this->processedFile->getProperty('tstamp');
93
-        }
94
-        return $result;
95
-    }
96
-
97
-    /**
98
-     * Compute and return the title of the file.
99
-     *
100
-     * @return string
101
-     */
102
-    protected function getTitle()
103
-    {
104
-        $result = $this->getFile()->getProperty('title');
105
-        if (empty($result)) {
106
-            $result = $this->getFile()->getName();
107
-        }
108
-        return htmlspecialchars($result);
109
-    }
110
-
111
-    /**
112
-     * Render a wrapping anchor around the thumbnail.
113
-     *
114
-     * @param string $result
115
-     * @return string
116
-     */
117
-    public function renderTagAnchor($result)
118
-    {
119
-        $uri = $this->thumbnailService->getAnchorUri();
120
-        if (!$uri) {
121
-            $uri = $this->getUri();
122
-        }
123
-
124
-        return sprintf(
125
-            '<a href="%s" target="_blank" data-uid="%s">%s</a>',
126
-            $uri,
127
-            $this->getFile()->getUid(),
128
-            $result
129
-        );
130
-    }
131
-
132
-    /**
133
-     * @return string
134
-     */
135
-    protected function getUri()
136
-    {
137
-        $urlParameters = array(
138
-            MediaModule::getParameterPrefix() => [
139
-                'controller' => 'Asset',
140
-                'action' => 'download',
141
-                'file' => $this->getFile()->getUid(),
142
-            ],
143
-        );
144
-        return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
145
-    }
146
-
147
-    /**
148
-     * @return string
149
-     */
150
-    public function getProcessingType()
151
-    {
152
-        if ($this->thumbnailService->getProcessingType() === null) {
153
-            return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
154
-        }
155
-        return $this->thumbnailService->getProcessingType();
156
-    }
21
+	/**
22
+	 * Render a thumbnail of a resource of type application.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function create()
27
+	{
28
+
29
+		$steps = $this->getRenderingSteps();
30
+
31
+		$result = '';
32
+		while ($step = array_shift($steps)) {
33
+			$result = $this->$step($result);
34
+		}
35
+
36
+		return $result;
37
+	}
38
+
39
+	/**
40
+	 * Render the URI of the thumbnail.
41
+	 *
42
+	 * @return string
43
+	 */
44
+	public function renderUri()
45
+	{
46
+		if ($this->isThumbnailPossible($this->getFile()->getExtension())) {
47
+			$this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration());
48
+			$uri = $this->processedFile->getPublicUrl(true);
49
+
50
+			// Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
51
+			if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
52
+				$this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
53
+			}
54
+		} else {
55
+			$uri = $this->getIcon($this->getFile()->getExtension());
56
+		}
57
+		return $this->prefixUri($uri);
58
+	}
59
+
60
+	/**
61
+	 * Render the tag image which is the main one for a thumbnail.
62
+	 *
63
+	 * @param string $result
64
+	 * @return string
65
+	 */
66
+	public function renderTagImage($result)
67
+	{
68
+
69
+		// Variable $result corresponds to an URL in this case.
70
+		// Analyse the URL and compute the adequate separator between arguments.
71
+		$parameterSeparator = strpos($result, '?') === false ? '?' : '&';
72
+
73
+		return sprintf(
74
+			'<img src="%s%s" title="%s" alt="%s" %s/>',
75
+			$result,
76
+			$this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '',
77
+			$this->getTitle(),
78
+			$this->getTitle(),
79
+			$this->renderAttributes()
80
+		);
81
+	}
82
+
83
+	/**
84
+	 * Compute and return the time stamp.
85
+	 *
86
+	 * @return int
87
+	 */
88
+	protected function getTimeStamp()
89
+	{
90
+		$result = $this->getFile()->getProperty('tstamp');
91
+		if ($this->processedFile) {
92
+			$result = $this->processedFile->getProperty('tstamp');
93
+		}
94
+		return $result;
95
+	}
96
+
97
+	/**
98
+	 * Compute and return the title of the file.
99
+	 *
100
+	 * @return string
101
+	 */
102
+	protected function getTitle()
103
+	{
104
+		$result = $this->getFile()->getProperty('title');
105
+		if (empty($result)) {
106
+			$result = $this->getFile()->getName();
107
+		}
108
+		return htmlspecialchars($result);
109
+	}
110
+
111
+	/**
112
+	 * Render a wrapping anchor around the thumbnail.
113
+	 *
114
+	 * @param string $result
115
+	 * @return string
116
+	 */
117
+	public function renderTagAnchor($result)
118
+	{
119
+		$uri = $this->thumbnailService->getAnchorUri();
120
+		if (!$uri) {
121
+			$uri = $this->getUri();
122
+		}
123
+
124
+		return sprintf(
125
+			'<a href="%s" target="_blank" data-uid="%s">%s</a>',
126
+			$uri,
127
+			$this->getFile()->getUid(),
128
+			$result
129
+		);
130
+	}
131
+
132
+	/**
133
+	 * @return string
134
+	 */
135
+	protected function getUri()
136
+	{
137
+		$urlParameters = array(
138
+			MediaModule::getParameterPrefix() => [
139
+				'controller' => 'Asset',
140
+				'action' => 'download',
141
+				'file' => $this->getFile()->getUid(),
142
+			],
143
+		);
144
+		return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
145
+	}
146
+
147
+	/**
148
+	 * @return string
149
+	 */
150
+	public function getProcessingType()
151
+	{
152
+		if ($this->thumbnailService->getProcessingType() === null) {
153
+			return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
154
+		}
155
+		return $this->thumbnailService->getProcessingType();
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
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()
Please login to merge, or discard this patch.
Classes/Dimension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
 class Dimension
17 17
 {
18 18
 
19
-    /**
20
-     * @var int
21
-     */
22
-    protected $width = 0;
23
-
24
-    /**
25
-     * @var int
26
-     */
27
-    protected $height = 0;
28
-
29
-    /**
30
-     * @param string $dimension
31
-     */
32
-    public function __construct($dimension)
33
-    {
34
-        $dimensions = GeneralUtility::trimExplode('x', $dimension);
35
-        $this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
-        $this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
-    }
38
-
39
-    /**
40
-     * @return mixed
41
-     */
42
-    public function getWidth()
43
-    {
44
-        return $this->width;
45
-    }
46
-
47
-    /**
48
-     * @return int
49
-     */
50
-    public function getHeight()
51
-    {
52
-        return $this->height;
53
-    }
19
+	/**
20
+	 * @var int
21
+	 */
22
+	protected $width = 0;
23
+
24
+	/**
25
+	 * @var int
26
+	 */
27
+	protected $height = 0;
28
+
29
+	/**
30
+	 * @param string $dimension
31
+	 */
32
+	public function __construct($dimension)
33
+	{
34
+		$dimensions = GeneralUtility::trimExplode('x', $dimension);
35
+		$this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
+		$this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
+	}
38
+
39
+	/**
40
+	 * @return mixed
41
+	 */
42
+	public function getWidth()
43
+	{
44
+		return $this->width;
45
+	}
46
+
47
+	/**
48
+	 * @return int
49
+	 */
50
+	public function getHeight()
51
+	{
52
+		return $this->height;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Classes/FileUpload/Base64File.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     protected $extension;
43 43
 
44 44
     /**
45
-     * @return \Fab\Media\FileUpload\Base64File
45
+     * @return false|null
46 46
      */
47 47
     public function __construct()
48 48
     {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     /**
117 117
      * Get MIME type of file.
118 118
      *
119
-     * @return string|boolean MIME type. eg, text/html, false on error
119
+     * @return string|false MIME type. eg, text/html, false on error
120 120
      */
121 121
     public function getMimeType()
122 122
     {
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -16,117 +16,117 @@
 block discarded – undo
16 16
 class Base64File extends \Fab\Media\FileUpload\UploadedFileAbstract
17 17
 {
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
-
50
-        // Processes the encoded image data and returns the decoded image
51
-        $encodedImage = GeneralUtility::_POST($this->inputName);
52
-        if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) {
53
-            $this->extension = $matches[1];
54
-        } else {
55
-            return false;
56
-        }
57
-
58
-        // Remove the mime-type header
59
-        $data = reset(array_reverse(explode('base64,', $encodedImage)));
60
-
61
-        // Use strict mode to prevent characters from outside the base64 range
62
-        $this->image = base64_decode($data, true);
63
-
64
-        if (!$this->image) {
65
-            return false;
66
-        }
67
-
68
-        $this->setName(uniqid() . '.' . $this->extension);
69
-    }
70
-
71
-    /**
72
-     * Save the file to the specified path
73
-     *
74
-     * @throws \Fab\Media\Exception\EmptyPropertyException
75
-     * @return boolean true on success
76
-     */
77
-    public function save()
78
-    {
79
-
80
-        if (is_null($this->uploadFolder)) {
81
-            throw new \Fab\Media\Exception\EmptyPropertyException('Upload folder is not defined', 1362587741);
82
-        }
83
-
84
-        if (is_null($this->name)) {
85
-            throw new \Fab\Media\Exception\EmptyPropertyException('File name is not defined', 1362587742);
86
-        }
87
-
88
-        return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0;
89
-    }
90
-
91
-    /**
92
-     * Get the original file name.
93
-     *
94
-     * @return string
95
-     */
96
-    public function getOriginalName()
97
-    {
98
-        return $this->getName();
99
-    }
100
-
101
-    /**
102
-     * Get the file size
103
-     *
104
-     * @throws \Exception
105
-     * @return integer file-size in byte
106
-     */
107
-    public function getSize()
108
-    {
109
-        if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
110
-            return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
111
-        } else {
112
-            throw new \Exception('Getting content length is not supported.');
113
-        }
114
-    }
115
-
116
-    /**
117
-     * Get MIME type of file.
118
-     *
119
-     * @return string|boolean MIME type. eg, text/html, false on error
120
-     */
121
-    public function getMimeType()
122
-    {
123
-        $this->checkFileExistence();
124
-        if (function_exists('finfo_file')) {
125
-            $fileInfo = new \finfo();
126
-            return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
127
-        } elseif (function_exists('mime_content_type')) {
128
-            return mime_content_type($this->getFileWithAbsolutePath());
129
-        }
130
-        return false;
131
-    }
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
+
50
+		// Processes the encoded image data and returns the decoded image
51
+		$encodedImage = GeneralUtility::_POST($this->inputName);
52
+		if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) {
53
+			$this->extension = $matches[1];
54
+		} else {
55
+			return false;
56
+		}
57
+
58
+		// Remove the mime-type header
59
+		$data = reset(array_reverse(explode('base64,', $encodedImage)));
60
+
61
+		// Use strict mode to prevent characters from outside the base64 range
62
+		$this->image = base64_decode($data, true);
63
+
64
+		if (!$this->image) {
65
+			return false;
66
+		}
67
+
68
+		$this->setName(uniqid() . '.' . $this->extension);
69
+	}
70
+
71
+	/**
72
+	 * Save the file to the specified path
73
+	 *
74
+	 * @throws \Fab\Media\Exception\EmptyPropertyException
75
+	 * @return boolean true on success
76
+	 */
77
+	public function save()
78
+	{
79
+
80
+		if (is_null($this->uploadFolder)) {
81
+			throw new \Fab\Media\Exception\EmptyPropertyException('Upload folder is not defined', 1362587741);
82
+		}
83
+
84
+		if (is_null($this->name)) {
85
+			throw new \Fab\Media\Exception\EmptyPropertyException('File name is not defined', 1362587742);
86
+		}
87
+
88
+		return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0;
89
+	}
90
+
91
+	/**
92
+	 * Get the original file name.
93
+	 *
94
+	 * @return string
95
+	 */
96
+	public function getOriginalName()
97
+	{
98
+		return $this->getName();
99
+	}
100
+
101
+	/**
102
+	 * Get the file size
103
+	 *
104
+	 * @throws \Exception
105
+	 * @return integer file-size in byte
106
+	 */
107
+	public function getSize()
108
+	{
109
+		if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
110
+			return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
111
+		} else {
112
+			throw new \Exception('Getting content length is not supported.');
113
+		}
114
+	}
115
+
116
+	/**
117
+	 * Get MIME type of file.
118
+	 *
119
+	 * @return string|boolean MIME type. eg, text/html, false on error
120
+	 */
121
+	public function getMimeType()
122
+	{
123
+		$this->checkFileExistence();
124
+		if (function_exists('finfo_file')) {
125
+			$fileInfo = new \finfo();
126
+			return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
127
+		} elseif (function_exists('mime_content_type')) {
128
+			return mime_content_type($this->getFileWithAbsolutePath());
129
+		}
130
+		return false;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Classes/FileUpload/StreamedFile.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
     /**
96 96
      * Get MIME type of file.
97 97
      *
98
-     * @return string|boolean MIME type. eg, text/html, false on error
98
+     * @return string|false MIME type. eg, text/html, false on error
99 99
      */
100 100
     public function getMimeType()
101 101
     {
Please login to merge, or discard this patch.
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -18,94 +18,94 @@
 block discarded – undo
18 18
 class StreamedFile extends \Fab\Media\FileUpload\UploadedFileAbstract
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $inputName = 'qqfile';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $uploadFolder;
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name;
35
-
36
-    /**
37
-     * Save the file to the specified path
38
-     *
39
-     * @throws EmptyPropertyException
40
-     * @return boolean true on success
41
-     */
42
-    public function save()
43
-    {
44
-
45
-        if (is_null($this->uploadFolder)) {
46
-            throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
47
-        }
48
-
49
-        if (is_null($this->name)) {
50
-            throw new EmptyPropertyException('File name is not defined', 1361787580);
51
-        }
52
-
53
-        $input = fopen("php://input", "r");
54
-        $temp = tmpfile();
55
-        $realSize = stream_copy_to_stream($input, $temp);
56
-        fclose($input);
57
-
58
-        if ($realSize != $this->getSize()) {
59
-            return false;
60
-        }
61
-
62
-        $target = fopen($this->getFileWithAbsolutePath(), "w");
63
-        fseek($temp, 0, SEEK_SET);
64
-        stream_copy_to_stream($temp, $target);
65
-        fclose($target);
66
-
67
-        return true;
68
-    }
69
-
70
-    /**
71
-     * Get the original file name.
72
-     *
73
-     * @return string
74
-     */
75
-    public function getOriginalName()
76
-    {
77
-        return $_GET[$this->inputName];
78
-    }
79
-
80
-    /**
81
-     * Get the file size
82
-     *
83
-     * @throws \Exception
84
-     * @return integer file-size in byte
85
-     */
86
-    public function getSize()
87
-    {
88
-        if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
89
-            return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
90
-        } else {
91
-            throw new \Exception('Getting content length is not supported.');
92
-        }
93
-    }
94
-
95
-    /**
96
-     * Get MIME type of file.
97
-     *
98
-     * @return string|boolean MIME type. eg, text/html, false on error
99
-     */
100
-    public function getMimeType()
101
-    {
102
-        $this->checkFileExistence();
103
-        if (function_exists('finfo_file')) {
104
-            $fileInfo = new \finfo();
105
-            return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
106
-        } elseif (function_exists('mime_content_type')) {
107
-            return mime_content_type($this->getFileWithAbsolutePath());
108
-        }
109
-        return false;
110
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $inputName = 'qqfile';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $uploadFolder;
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name;
35
+
36
+	/**
37
+	 * Save the file to the specified path
38
+	 *
39
+	 * @throws EmptyPropertyException
40
+	 * @return boolean true on success
41
+	 */
42
+	public function save()
43
+	{
44
+
45
+		if (is_null($this->uploadFolder)) {
46
+			throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
47
+		}
48
+
49
+		if (is_null($this->name)) {
50
+			throw new EmptyPropertyException('File name is not defined', 1361787580);
51
+		}
52
+
53
+		$input = fopen("php://input", "r");
54
+		$temp = tmpfile();
55
+		$realSize = stream_copy_to_stream($input, $temp);
56
+		fclose($input);
57
+
58
+		if ($realSize != $this->getSize()) {
59
+			return false;
60
+		}
61
+
62
+		$target = fopen($this->getFileWithAbsolutePath(), "w");
63
+		fseek($temp, 0, SEEK_SET);
64
+		stream_copy_to_stream($temp, $target);
65
+		fclose($target);
66
+
67
+		return true;
68
+	}
69
+
70
+	/**
71
+	 * Get the original file name.
72
+	 *
73
+	 * @return string
74
+	 */
75
+	public function getOriginalName()
76
+	{
77
+		return $_GET[$this->inputName];
78
+	}
79
+
80
+	/**
81
+	 * Get the file size
82
+	 *
83
+	 * @throws \Exception
84
+	 * @return integer file-size in byte
85
+	 */
86
+	public function getSize()
87
+	{
88
+		if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
89
+			return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
90
+		} else {
91
+			throw new \Exception('Getting content length is not supported.');
92
+		}
93
+	}
94
+
95
+	/**
96
+	 * Get MIME type of file.
97
+	 *
98
+	 * @return string|boolean MIME type. eg, text/html, false on error
99
+	 */
100
+	public function getMimeType()
101
+	{
102
+		$this->checkFileExistence();
103
+		if (function_exists('finfo_file')) {
104
+			$fileInfo = new \finfo();
105
+			return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
106
+		} elseif (function_exists('mime_content_type')) {
107
+			return mime_content_type($this->getFileWithAbsolutePath());
108
+		}
109
+		return false;
110
+	}
111 111
 }
Please login to merge, or discard this patch.