Completed
Push — master ( 02a2d0...8117b3 )
by Fabien
54:58
created
Tests/Feature/bootstrap/FeatureContext.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class FeatureContext extends MinkContext
16 16
 {
17
-    /**
18
-     * Initializes context.
19
-     * Every scenario gets it's own context object.
20
-     *
21
-     * @param array $parameters context parameters (set them up through behat.yml)
22
-     */
23
-    public function __construct(array $parameters)
24
-    {
25
-        // Initialize your context here
26
-    }
17
+	/**
18
+	 * Initializes context.
19
+	 * Every scenario gets it's own context object.
20
+	 *
21
+	 * @param array $parameters context parameters (set them up through behat.yml)
22
+	 */
23
+	public function __construct(array $parameters)
24
+	{
25
+		// Initialize your context here
26
+	}
27 27
 
28 28
 	/**
29 29
 	 * @Given /^I wait "([^"]*)" seconds$/
Please login to merge, or discard this patch.
Classes/View/Plugin/LinkCreatorPlugin.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,50 +27,50 @@
 block discarded – undo
27 27
 class LinkCreatorPlugin extends AbstractComponentView
28 28
 {
29 29
 
30
-    /**
31
-     * Renders a hidden link for link creator.
32
-     *
33
-     * @return string
34
-     */
35
-    public function render()
36
-    {
37
-        $result = '';
38
-        if ($this->getModuleLoader()->hasPlugin('linkCreator')) {
30
+	/**
31
+	 * Renders a hidden link for link creator.
32
+	 *
33
+	 * @return string
34
+	 */
35
+	public function render()
36
+	{
37
+		$result = '';
38
+		if ($this->getModuleLoader()->hasPlugin('linkCreator')) {
39 39
 
40
-            // Load Require JS code
41
-            $this->loadRequireJsCode();
40
+			// Load Require JS code
41
+			$this->loadRequireJsCode();
42 42
 
43
-            $result = sprintf('<a href="%s" id="btn-linkCreator-current" class="btn btn-linkCreator" style="display: none"></a>',
44
-                $this->getLinkCreatorUri()
45
-            );
46
-        };
47
-        return $result;
48
-    }
43
+			$result = sprintf('<a href="%s" id="btn-linkCreator-current" class="btn btn-linkCreator" style="display: none"></a>',
44
+				$this->getLinkCreatorUri()
45
+			);
46
+		};
47
+		return $result;
48
+	}
49 49
 
50
-    /**
51
-     * @return string
52
-     */
53
-    protected function getLinkCreatorUri()
54
-    {
55
-        $urlParameters = array(
56
-            MediaModule::getParameterPrefix() => array(
57
-                'controller' => 'LinkCreator',
58
-                'action' => 'show',
59
-            ),
60
-        );
61
-        return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
62
-    }
50
+	/**
51
+	 * @return string
52
+	 */
53
+	protected function getLinkCreatorUri()
54
+	{
55
+		$urlParameters = array(
56
+			MediaModule::getParameterPrefix() => array(
57
+				'controller' => 'LinkCreator',
58
+				'action' => 'show',
59
+			),
60
+		);
61
+		return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
62
+	}
63 63
 
64
-    /**
65
-     * @return void
66
-     */
67
-    protected function loadRequireJsCode()
68
-    {
69
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
64
+	/**
65
+	 * @return void
66
+	 */
67
+	protected function loadRequireJsCode()
68
+	{
69
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
70 70
 
71
-        $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
72
-        $pageRenderer->addRequireJsConfiguration($configuration);
73
-        $pageRenderer->loadRequireJsModule('Fab/Media/PluginLinkCreator');
74
-    }
71
+		$configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
72
+		$pageRenderer->addRequireJsConfiguration($configuration);
73
+		$pageRenderer->loadRequireJsModule('Fab/Media/PluginLinkCreator');
74
+	}
75 75
 
76 76
 }
Please login to merge, or discard this patch.
Classes/View/Plugin/ImageEditorPlugin.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,50 +27,50 @@
 block discarded – undo
27 27
 class ImageEditorPlugin extends AbstractComponentView
28 28
 {
29 29
 
30
-    /**
31
-     * Renders a hidden link for image editor.
32
-     *
33
-     * @return string
34
-     */
35
-    public function render()
36
-    {
30
+	/**
31
+	 * Renders a hidden link for image editor.
32
+	 *
33
+	 * @return string
34
+	 */
35
+	public function render()
36
+	{
37 37
 
38
-        $result = '';
39
-        if ($this->getModuleLoader()->hasPlugin('imageEditor')) {
38
+		$result = '';
39
+		if ($this->getModuleLoader()->hasPlugin('imageEditor')) {
40 40
 
41
-            // Load Require JS code
42
-            $this->loadRequireJsCode();
41
+			// Load Require JS code
42
+			$this->loadRequireJsCode();
43 43
 
44
-            $result = sprintf('<a href="%s" id="btn-imageEditor-current" class="btn btn-imageEditor" style="display: none"></a>',
45
-                $this->getImageEditorUri()
46
-            );
47
-        };
48
-        return $result;
49
-    }
44
+			$result = sprintf('<a href="%s" id="btn-imageEditor-current" class="btn btn-imageEditor" style="display: none"></a>',
45
+				$this->getImageEditorUri()
46
+			);
47
+		};
48
+		return $result;
49
+	}
50 50
 
51
-    /**
52
-     * @return string
53
-     */
54
-    protected function getImageEditorUri()
55
-    {
56
-        $urlParameters = array(
57
-            MediaModule::getParameterPrefix() => array(
58
-                'controller' => 'ImageEditor',
59
-                'action' => 'show',
60
-            ),
61
-        );
62
-        return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
63
-    }
51
+	/**
52
+	 * @return string
53
+	 */
54
+	protected function getImageEditorUri()
55
+	{
56
+		$urlParameters = array(
57
+			MediaModule::getParameterPrefix() => array(
58
+				'controller' => 'ImageEditor',
59
+				'action' => 'show',
60
+			),
61
+		);
62
+		return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
63
+	}
64 64
 
65
-    /**
66
-     * @return void
67
-     */
68
-    protected function loadRequireJsCode()
69
-    {
70
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
65
+	/**
66
+	 * @return void
67
+	 */
68
+	protected function loadRequireJsCode()
69
+	{
70
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71 71
 
72
-        $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
73
-        $pageRenderer->addRequireJsConfiguration($configuration);
74
-        $pageRenderer->loadRequireJsModule('Fab/Media/PluginImageEditor');
75
-    }
72
+		$configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
73
+		$pageRenderer->addRequireJsConfiguration($configuration);
74
+		$pageRenderer->loadRequireJsModule('Fab/Media/PluginImageEditor');
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Classes/Controller/LinkCreatorController.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -23,32 +23,32 @@
 block discarded – undo
23 23
 class LinkCreatorController extends ActionController
24 24
 {
25 25
 
26
-    /**
27
-     * Initializes the controller before invoking an action method.
28
-     */
29
-    public function initializeAction()
30
-    {
31
-
32
-        // Configure property mapping to retrieve the file object.
33
-        if ($this->arguments->hasArgument('file')) {
34
-
35
-            /** @var \Fab\Media\TypeConverter\FileConverter $typeConverter */
36
-            $typeConverter = $this->objectManager->get('Fab\Media\TypeConverter\FileConverter');
37
-
38
-            $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration();
39
-            $propertyMappingConfiguration->setTypeConverter($typeConverter);
40
-        }
41
-    }
42
-
43
-    /**
44
-     * Handle GUI for creating a link in the RTE.
45
-     *
46
-     * @param File $file
47
-     * @return void
48
-     */
49
-    public function showAction(File $file)
50
-    {
51
-        $this->view->assign('file', $file);
52
-    }
26
+	/**
27
+	 * Initializes the controller before invoking an action method.
28
+	 */
29
+	public function initializeAction()
30
+	{
31
+
32
+		// Configure property mapping to retrieve the file object.
33
+		if ($this->arguments->hasArgument('file')) {
34
+
35
+			/** @var \Fab\Media\TypeConverter\FileConverter $typeConverter */
36
+			$typeConverter = $this->objectManager->get('Fab\Media\TypeConverter\FileConverter');
37
+
38
+			$propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration();
39
+			$propertyMappingConfiguration->setTypeConverter($typeConverter);
40
+		}
41
+	}
42
+
43
+	/**
44
+	 * Handle GUI for creating a link in the RTE.
45
+	 *
46
+	 * @param File $file
47
+	 * @return void
48
+	 */
49
+	public function showAction(File $file)
50
+	{
51
+		$this->view->assign('file', $file);
52
+	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
Classes/View/Plugin/FilePickerPlugin.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,30 +25,30 @@
 block discarded – undo
25 25
 class FilePickerPlugin extends AbstractComponentView
26 26
 {
27 27
 
28
-    /**
29
-     * Renders a hidden link for file picker.
30
-     *
31
-     * @return string
32
-     */
33
-    public function render()
34
-    {
35
-
36
-        if ($this->getModuleLoader()->hasPlugin('filePicker')) {
37
-            $this->loadRequireJsCode();
38
-        };
39
-        return '';
40
-    }
41
-
42
-    /**
43
-     * @return void
44
-     */
45
-    protected function loadRequireJsCode()
46
-    {
47
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
48
-
49
-        $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
50
-        $pageRenderer->addRequireJsConfiguration($configuration);
51
-        $pageRenderer->loadRequireJsModule('Fab/Media/PluginFilePicker');
52
-    }
28
+	/**
29
+	 * Renders a hidden link for file picker.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function render()
34
+	{
35
+
36
+		if ($this->getModuleLoader()->hasPlugin('filePicker')) {
37
+			$this->loadRequireJsCode();
38
+		};
39
+		return '';
40
+	}
41
+
42
+	/**
43
+	 * @return void
44
+	 */
45
+	protected function loadRequireJsCode()
46
+	{
47
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
48
+
49
+		$configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
50
+		$pageRenderer->addRequireJsConfiguration($configuration);
51
+		$pageRenderer->loadRequireJsModule('Fab/Media/PluginFilePicker');
52
+	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
Configuration/TCA/Overrides/sys_file_reference.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 if (!defined('TYPO3_MODE')) die ('Access denied.');
3 3
 
4 4
 $tca = [
5
-    'ctrl' => [
6
-        'rootLevel' => -1, // Otherwise File Reference will not work between files.
7
-    ],
5
+	'ctrl' => [
6
+		'rootLevel' => -1, // Otherwise File Reference will not work between files.
7
+	],
8 8
 ];
9 9
 
10 10
 // Disable the File Upload in IRRE since it can not be configured the target storage.
Please login to merge, or discard this patch.
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/AbstractThumbnailProcessor.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -19,155 +19,155 @@
 block discarded – undo
19 19
 abstract class AbstractThumbnailProcessor implements ThumbnailProcessorInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @var ThumbnailService
24
-     */
25
-    protected $thumbnailService;
26
-
27
-    /**
28
-     * Store a Processed File along the processing.
29
-     *
30
-     * @var \TYPO3\CMS\Core\Resource\ProcessedFile
31
-     */
32
-    protected $processedFile;
33
-
34
-    /**
35
-     * Define what are the rendering steps for a thumbnail.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $renderingSteps = [
40
-        ThumbnailInterface::OUTPUT_URI => 'renderUri',
41
-        ThumbnailInterface::OUTPUT_IMAGE => 'renderTagImage',
42
-        ThumbnailInterface::OUTPUT_IMAGE_WRAPPED => 'renderTagAnchor',
43
-    ];
44
-
45
-    /**
46
-     * @param ThumbnailService $thumbnailService
47
-     * @return $this
48
-     */
49
-    public function setThumbnailService(ThumbnailService $thumbnailService)
50
-    {
51
-        $this->thumbnailService = $thumbnailService;
52
-        return $this;
53
-    }
54
-
55
-    /**
56
-     * Return what needs to be rendered
57
-     *
58
-     * @return array
59
-     */
60
-    protected function getRenderingSteps()
61
-    {
62
-        $position = array_search($this->thumbnailService->getOutputType(), array_keys($this->renderingSteps));
63
-        return array_slice($this->renderingSteps, 0, $position + 1);
64
-    }
65
-
66
-
67
-    /**
68
-     * Render additional attribute for this DOM element.
69
-     *
70
-     * @return string
71
-     */
72
-    protected function renderAttributes()
73
-    {
74
-        $result = '';
75
-        $attributes = $this->thumbnailService->getAttributes();
76
-        if (is_array($attributes)) {
77
-            foreach ($attributes as $attribute => $value) {
78
-                $result .= sprintf('%s="%s" ',
79
-                    htmlspecialchars($attribute),
80
-                    htmlspecialchars($value)
81
-                );
82
-            }
83
-        }
84
-        return $result;
85
-    }
86
-
87
-    /**
88
-     * @return array
89
-     * @throws \Fab\Media\Exception\InvalidKeyInArrayException
90
-     * @throws \Fab\Media\Exception\EmptyValueException
91
-     */
92
-    protected function getConfiguration()
93
-    {
94
-        $configuration = $this->thumbnailService->getConfiguration();
95
-        if (!$configuration) {
96
-            $dimension = ImagePresetUtility::getInstance()->preset('image_thumbnail');
97
-            $configuration = array(
98
-                'width' => $dimension->getWidth(),
99
-                'height' => $dimension->getHeight(),
100
-            );
101
-        }
102
-        return $configuration;
103
-    }
104
-
105
-    /**
106
-     * Returns a path to an icon given an extension.
107
-     *
108
-     * @param string $extension File extension
109
-     * @return string
110
-     */
111
-    protected function getIcon($extension)
112
-    {
113
-        $resource = Path::getRelativePath(sprintf('Icons/MimeType/%s.png', $extension));
114
-
115
-        // If file is not found, fall back to a default icon
116
-        if (Path::notExists($resource)) {
117
-            $resource = Path::getRelativePath('Icons/MissingMimeTypeIcon.png');
118
-        }
119
-
120
-        return $resource;
121
-    }
122
-
123
-    /**
124
-     * @param string $uri
125
-     * @return string
126
-     */
127
-    public function prefixUri($uri)
128
-    {
129
-        if ($this->isFrontendMode() && $this->getFrontendObject()->absRefPrefix) {
130
-            $uri = $this->getFrontendObject()->absRefPrefix . $uri;
131
-        }
132
-        return $uri;
133
-    }
134
-
135
-    /**
136
-     * Returns true whether an thumbnail can be generated
137
-     *
138
-     * @param string $extension File extension
139
-     * @return boolean
140
-     */
141
-    protected function isThumbnailPossible($extension)
142
-    {
143
-        return GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($extension));
144
-    }
145
-
146
-    /**
147
-     * @return File
148
-     */
149
-    protected function getFile()
150
-    {
151
-        return $this->thumbnailService->getFile();
152
-    }
153
-
154
-    /**
155
-     * Returns whether the current mode is Frontend
156
-     *
157
-     * @return bool
158
-     */
159
-    protected function isFrontendMode()
160
-    {
161
-        return TYPO3_MODE === 'FE';
162
-    }
163
-
164
-    /**
165
-     * Returns an instance of the Frontend object.
166
-     *
167
-     * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
168
-     */
169
-    protected function getFrontendObject()
170
-    {
171
-        return $GLOBALS['TSFE'];
172
-    }
22
+	/**
23
+	 * @var ThumbnailService
24
+	 */
25
+	protected $thumbnailService;
26
+
27
+	/**
28
+	 * Store a Processed File along the processing.
29
+	 *
30
+	 * @var \TYPO3\CMS\Core\Resource\ProcessedFile
31
+	 */
32
+	protected $processedFile;
33
+
34
+	/**
35
+	 * Define what are the rendering steps for a thumbnail.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $renderingSteps = [
40
+		ThumbnailInterface::OUTPUT_URI => 'renderUri',
41
+		ThumbnailInterface::OUTPUT_IMAGE => 'renderTagImage',
42
+		ThumbnailInterface::OUTPUT_IMAGE_WRAPPED => 'renderTagAnchor',
43
+	];
44
+
45
+	/**
46
+	 * @param ThumbnailService $thumbnailService
47
+	 * @return $this
48
+	 */
49
+	public function setThumbnailService(ThumbnailService $thumbnailService)
50
+	{
51
+		$this->thumbnailService = $thumbnailService;
52
+		return $this;
53
+	}
54
+
55
+	/**
56
+	 * Return what needs to be rendered
57
+	 *
58
+	 * @return array
59
+	 */
60
+	protected function getRenderingSteps()
61
+	{
62
+		$position = array_search($this->thumbnailService->getOutputType(), array_keys($this->renderingSteps));
63
+		return array_slice($this->renderingSteps, 0, $position + 1);
64
+	}
65
+
66
+
67
+	/**
68
+	 * Render additional attribute for this DOM element.
69
+	 *
70
+	 * @return string
71
+	 */
72
+	protected function renderAttributes()
73
+	{
74
+		$result = '';
75
+		$attributes = $this->thumbnailService->getAttributes();
76
+		if (is_array($attributes)) {
77
+			foreach ($attributes as $attribute => $value) {
78
+				$result .= sprintf('%s="%s" ',
79
+					htmlspecialchars($attribute),
80
+					htmlspecialchars($value)
81
+				);
82
+			}
83
+		}
84
+		return $result;
85
+	}
86
+
87
+	/**
88
+	 * @return array
89
+	 * @throws \Fab\Media\Exception\InvalidKeyInArrayException
90
+	 * @throws \Fab\Media\Exception\EmptyValueException
91
+	 */
92
+	protected function getConfiguration()
93
+	{
94
+		$configuration = $this->thumbnailService->getConfiguration();
95
+		if (!$configuration) {
96
+			$dimension = ImagePresetUtility::getInstance()->preset('image_thumbnail');
97
+			$configuration = array(
98
+				'width' => $dimension->getWidth(),
99
+				'height' => $dimension->getHeight(),
100
+			);
101
+		}
102
+		return $configuration;
103
+	}
104
+
105
+	/**
106
+	 * Returns a path to an icon given an extension.
107
+	 *
108
+	 * @param string $extension File extension
109
+	 * @return string
110
+	 */
111
+	protected function getIcon($extension)
112
+	{
113
+		$resource = Path::getRelativePath(sprintf('Icons/MimeType/%s.png', $extension));
114
+
115
+		// If file is not found, fall back to a default icon
116
+		if (Path::notExists($resource)) {
117
+			$resource = Path::getRelativePath('Icons/MissingMimeTypeIcon.png');
118
+		}
119
+
120
+		return $resource;
121
+	}
122
+
123
+	/**
124
+	 * @param string $uri
125
+	 * @return string
126
+	 */
127
+	public function prefixUri($uri)
128
+	{
129
+		if ($this->isFrontendMode() && $this->getFrontendObject()->absRefPrefix) {
130
+			$uri = $this->getFrontendObject()->absRefPrefix . $uri;
131
+		}
132
+		return $uri;
133
+	}
134
+
135
+	/**
136
+	 * Returns true whether an thumbnail can be generated
137
+	 *
138
+	 * @param string $extension File extension
139
+	 * @return boolean
140
+	 */
141
+	protected function isThumbnailPossible($extension)
142
+	{
143
+		return GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($extension));
144
+	}
145
+
146
+	/**
147
+	 * @return File
148
+	 */
149
+	protected function getFile()
150
+	{
151
+		return $this->thumbnailService->getFile();
152
+	}
153
+
154
+	/**
155
+	 * Returns whether the current mode is Frontend
156
+	 *
157
+	 * @return bool
158
+	 */
159
+	protected function isFrontendMode()
160
+	{
161
+		return TYPO3_MODE === 'FE';
162
+	}
163
+
164
+	/**
165
+	 * Returns an instance of the Frontend object.
166
+	 *
167
+	 * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
168
+	 */
169
+	protected function getFrontendObject()
170
+	{
171
+		return $GLOBALS['TSFE'];
172
+	}
173 173
 }
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.