Completed
Push — master ( 02a2d0...8117b3 )
by Fabien
54:58
created
Tests/Functional/Form/FileUploadTest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	public function setUp() {
42 42
 		parent::setUp();
43 43
 
44
-        $this->fixture = $this->getMock('Fab\Media\Form\FileUpload', array('addLanguage'));
44
+		$this->fixture = $this->getMock('Fab\Media\Form\FileUpload', array('addLanguage'));
45 45
 		$this->fakeName = uniqid('name');
46 46
 		$this->fakePrefix= uniqid('prefix');
47 47
 	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 use Fab\Media\Tests\Functional\AbstractFunctionalTestCase;
18 18
 
19
-require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php';
19
+require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php';
20 20
 
21 21
 /**
22 22
  * Test case for class \Fab\Media\Form\FileUpload.
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
         $this->fixture = $this->getMock('Fab\Media\Form\FileUpload', array('addLanguage'));
45 45
 		$this->fakeName = uniqid('name');
46
-		$this->fakePrefix= uniqid('prefix');
46
+		$this->fakePrefix = uniqid('prefix');
47 47
 	}
48 48
 
49 49
 	public function tearDown() {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$method->setAccessible(TRUE);
84 84
 
85 85
 		$basePart = uniqid();
86
-		$fakePrefix = $basePart . '[foo]';
86
+		$fakePrefix = $basePart.'[foo]';
87 87
 		$actual = $method->invokeArgs($this->fixture, array($fakePrefix));
88 88
 		$this->assertSame($basePart, $actual);
89 89
 	}
Please login to merge, or discard this patch.
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.
Classes/Utility/ImagePresetUtility.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
     {
55 55
         $size = ConfigurationUtility::getInstance()->get($preset);
56 56
         if (is_null($size)) {
57
-            throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
57
+            throw new \Fab\Media\Exception\EmptyValueException('No value for preset: '.$preset, 1362501066);
58 58
         }
59 59
 
60 60
         $this->currentPreset = $preset;
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,92 +16,92 @@
 block discarded – undo
16 16
 class ImagePresetUtility implements \TYPO3\CMS\Core\SingletonInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    protected $store = [];
19
+	/**
20
+	 * @var array
21
+	 */
22
+	protected $store = [];
23 23
 
24
-    /**
25
-     * @var string
26
-     */
27
-    protected $currentPreset = '';
24
+	/**
25
+	 * @var string
26
+	 */
27
+	protected $currentPreset = '';
28 28
 
29
-    /**
30
-     * Returns a class instance
31
-     *
32
-     * @return \Fab\Media\Utility\ImagePresetUtility|object
33
-     */
34
-    static public function getInstance()
35
-    {
36
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
37
-    }
29
+	/**
30
+	 * Returns a class instance
31
+	 *
32
+	 * @return \Fab\Media\Utility\ImagePresetUtility|object
33
+	 */
34
+	static public function getInstance()
35
+	{
36
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
37
+	}
38 38
 
39
-    /**
40
-     * Set the current preset value. Preset values come from the settings and can be:
41
-     * image_thumbnail, image_mini, image_small, image_medium, image_large
42
-     *
43
-     * @throws \Fab\Media\Exception\EmptyValueException
44
-     * @param string $preset image_thumbnail, image_mini, ...
45
-     * @return \Fab\Media\Utility\ImagePresetUtility
46
-     */
47
-    public function preset($preset)
48
-    {
49
-        $size = ConfigurationUtility::getInstance()->get($preset);
50
-        if (is_null($size)) {
51
-            throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
52
-        }
39
+	/**
40
+	 * Set the current preset value. Preset values come from the settings and can be:
41
+	 * image_thumbnail, image_mini, image_small, image_medium, image_large
42
+	 *
43
+	 * @throws \Fab\Media\Exception\EmptyValueException
44
+	 * @param string $preset image_thumbnail, image_mini, ...
45
+	 * @return \Fab\Media\Utility\ImagePresetUtility
46
+	 */
47
+	public function preset($preset)
48
+	{
49
+		$size = ConfigurationUtility::getInstance()->get($preset);
50
+		if (is_null($size)) {
51
+			throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
52
+		}
53 53
 
54
-        $this->currentPreset = $preset;
55
-        if (!isset($this->store[$this->currentPreset])) {
56
-            // @todo use object Dimension instead
57
-            $dimensions = GeneralUtility::trimExplode('x', $size);
58
-            $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
59
-            $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
60
-        }
61
-        return $this;
62
-    }
54
+		$this->currentPreset = $preset;
55
+		if (!isset($this->store[$this->currentPreset])) {
56
+			// @todo use object Dimension instead
57
+			$dimensions = GeneralUtility::trimExplode('x', $size);
58
+			$this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
59
+			$this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
60
+		}
61
+		return $this;
62
+	}
63 63
 
64
-    /**
65
-     * @return array
66
-     */
67
-    public function getStore()
68
-    {
69
-        return $this->store;
70
-    }
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function getStore()
68
+	{
69
+		return $this->store;
70
+	}
71 71
 
72
-    /**
73
-     * @param array $store
74
-     */
75
-    public function setStore($store)
76
-    {
77
-        $this->store = $store;
78
-    }
72
+	/**
73
+	 * @param array $store
74
+	 */
75
+	public function setStore($store)
76
+	{
77
+		$this->store = $store;
78
+	}
79 79
 
80
-    /**
81
-     * Returns width of the current preset.
82
-     *
83
-     * @throws \Fab\Media\Exception\InvalidKeyInArrayException
84
-     * @return int
85
-     */
86
-    public function getWidth()
87
-    {
88
-        if (empty($this->store[$this->currentPreset])) {
89
-            throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
90
-        }
91
-        return (int)$this->store[$this->currentPreset]['width'];
92
-    }
80
+	/**
81
+	 * Returns width of the current preset.
82
+	 *
83
+	 * @throws \Fab\Media\Exception\InvalidKeyInArrayException
84
+	 * @return int
85
+	 */
86
+	public function getWidth()
87
+	{
88
+		if (empty($this->store[$this->currentPreset])) {
89
+			throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
90
+		}
91
+		return (int)$this->store[$this->currentPreset]['width'];
92
+	}
93 93
 
94
-    /**
95
-     * Returns height of the current preset.
96
-     *
97
-     * @throws \Fab\Media\Exception\InvalidKeyInArrayException
98
-     * @return int
99
-     */
100
-    public function getHeight()
101
-    {
102
-        if (empty($this->store[$this->currentPreset])) {
103
-            throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
104
-        }
105
-        return (int)$this->store[$this->currentPreset]['height'];
106
-    }
94
+	/**
95
+	 * Returns height of the current preset.
96
+	 *
97
+	 * @throws \Fab\Media\Exception\InvalidKeyInArrayException
98
+	 * @return int
99
+	 */
100
+	public function getHeight()
101
+	{
102
+		if (empty($this->store[$this->currentPreset])) {
103
+			throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
104
+		}
105
+		return (int)$this->store[$this->currentPreset]['height'];
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/AbstractThumbnailProcessor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
     public function prefixUri($uri)
132 132
     {
133 133
         if ($this->isFrontendMode() && $this->getFrontendObject()->absRefPrefix) {
134
-            $uri = $this->getFrontendObject()->absRefPrefix . $uri;
134
+            $uri = $this->getFrontendObject()->absRefPrefix.$uri;
135 135
         }
136 136
         return $uri;
137 137
     }
Please login to merge, or discard this 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/ImageThumbnailProcessor.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
         return sprintf('<img src="%s%s" title="%s" alt="%s" %s/>',
93 93
             $result,
94
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->processedFile->getProperty('tstamp') : '',
94
+            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator.$this->processedFile->getProperty('tstamp') : '',
95 95
             $this->getTitle(),
96 96
             $this->getTitle(),
97 97
             $this->renderAttributes()
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
         return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
148 148
             $url,
149
-            $this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator . $file->getProperty('tstamp') : '',
149
+            $this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator.$file->getProperty('tstamp') : '',
150 150
             $this->thumbnailService->getTarget(),
151 151
             $file->getUid(),
152 152
             $result
Please login to merge, or discard this patch.
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -16,180 +16,180 @@
 block discarded – undo
16 16
 class ImageThumbnailProcessor extends AbstractThumbnailProcessor
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    protected $defaultConfigurationWrap = array(
23
-        'width' => 0,
24
-        'height' => 0,
25
-    );
26
-
27
-    /**
28
-     * Render a thumbnail of a resource of type image.
29
-     *
30
-     * @return string
31
-     */
32
-    public function create()
33
-    {
34
-        $steps = $this->getRenderingSteps();
35
-
36
-        $result = '';
37
-        while ($step = array_shift($steps)) {
38
-            $result = $this->$step($result);
39
-        }
40
-
41
-        return $result;
42
-    }
43
-
44
-    /**
45
-     * Render the URI of the thumbnail.
46
-     *
47
-     * @return string
48
-     * @throws \Fab\Media\Exception\EmptyValueException
49
-     */
50
-    public function renderUri()
51
-    {
52
-
53
-        // Makes sure the width and the height of the thumbnail is not bigger than the actual file
54
-        $configuration = $this->getConfiguration();
55
-        if (!empty($configuration['width']) && $configuration['width'] > $this->getFile()->getProperty('width')) {
56
-            $configuration['width'] = $this->getFile()->getProperty('width');
57
-        }
58
-        if (!empty($configuration['height']) && $configuration['height'] > $this->getFile()->getProperty('height')) {
59
-            $configuration['height'] = $this->getFile()->getProperty('height');
60
-        }
61
-
62
-        $configuration = $this->computeFinalImageDimension($configuration);
63
-        $this->processedFile = $this->getFile()->process($this->getProcessingType(), $configuration);
64
-        $uri = $this->processedFile->getPublicUrl(true);
65
-
66
-        // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
67
-        if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
68
-            $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
69
-        }
70
-
71
-        return $this->prefixUri($uri);
72
-    }
73
-
74
-    /**
75
-     * Render the tag image which is the main one for a thumbnail.
76
-     *
77
-     * @param string $result
78
-     * @return string
79
-     */
80
-    public function renderTagImage($result)
81
-    {
82
-
83
-        // Variable $result corresponds to an URL in this case.
84
-        // Analyse the URL and compute the adequate separator between arguments.
85
-        $parameterSeparator = strpos($result, '?') === false ? '?' : '&';
86
-
87
-        return sprintf('<img src="%s%s" title="%s" alt="%s" %s/>',
88
-            $result,
89
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->processedFile->getProperty('tstamp') : '',
90
-            $this->getTitle(),
91
-            $this->getTitle(),
92
-            $this->renderAttributes()
93
-        );
94
-    }
95
-
96
-    /**
97
-     * Compute and return the title of the file.
98
-     *
99
-     * @return string
100
-     */
101
-    protected function getTitle()
102
-    {
103
-        $result = $this->getFile()->getProperty('title');
104
-        if (!$result) {
105
-            $result = $this->getFile()->getName();
106
-        }
107
-        return htmlspecialchars($result);
108
-    }
109
-
110
-    /**
111
-     * Render a wrapping anchor around the thumbnail.
112
-     *
113
-     * @param string $result
114
-     * @return string
115
-     */
116
-    public function renderTagAnchor($result)
117
-    {
118
-
119
-        $file = $this->getFile();
120
-
121
-        // Perhaps the wrapping file must be processed
122
-        $configurationWrap = $this->thumbnailService->getConfigurationWrap();
123
-
124
-        // Make sure we have configurationWrap initialized correctly
125
-        if (!empty($configurationWrap['width']) || !empty($configurationWrap['height'])) {
126
-            $configurationWrap = array_merge($this->defaultConfigurationWrap, $configurationWrap);
127
-
128
-            // It looks maxW or maxH does not work as expected with CONTEXT_IMAGEPREVIEW...
129
-            // ... uses "width" and "height" instead.
130
-            if ($configurationWrap['width'] < $this->getFile()->getProperty('width')
131
-                || $configurationWrap['height'] < $this->getFile()->getProperty('height')
132
-            ) {
133
-                $configurationWrap = $this->computeFinalImageDimension($configurationWrap);
134
-                $file = $this->getFile()->process($this->getProcessingType(), $configurationWrap);
135
-            }
136
-        }
137
-
138
-        // Analyse the current $url and compute the adequate separator between arguments.
139
-        $url = $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true);
140
-        $parameterSeparator = strpos($url, '?') === false ? '?' : '&';
141
-
142
-        return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
143
-            $url,
144
-            $this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator . $file->getProperty('tstamp') : '',
145
-            $this->thumbnailService->getTarget(),
146
-            $file->getUid(),
147
-            $result
148
-        );
149
-    }
150
-
151
-    /**
152
-     * Compute the final configuration for the image preview.
153
-     * Keep ratio of width / height for the image.
154
-     *
155
-     * @param array $configuration
156
-     * @return array
157
-     */
158
-    protected function computeFinalImageDimension(array $configuration)
159
-    {
160
-        $ratio = $this->computeImageRatio();
161
-
162
-        if ($ratio > 1) {
163
-            $configuration['height'] = round($configuration['width'] / $ratio);
164
-        } else {
165
-            $configuration['width'] = round($configuration['height'] * $ratio);
166
-        }
167
-        return $configuration;
168
-    }
169
-
170
-    /**
171
-     * Compute the width / height ratio of the image.
172
-     *
173
-     * @return null|float
174
-     */
175
-    protected function computeImageRatio()
176
-    {
177
-        $ratio = null;
178
-        if ($this->getFile()->getProperty('width') > 0 && $this->getFile()->getProperty('height') > 0) {
179
-            $ratio = $this->getFile()->getProperty('width') / $this->getFile()->getProperty('height');
180
-        }
181
-        return $ratio;
182
-    }
183
-
184
-    /**
185
-     * @return string
186
-     */
187
-    public function getProcessingType()
188
-    {
189
-        if ($this->thumbnailService->getProcessingType() === null) {
190
-            return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
191
-        }
192
-        return $this->thumbnailService->getProcessingType();
193
-    }
19
+	/**
20
+	 * @var array
21
+	 */
22
+	protected $defaultConfigurationWrap = array(
23
+		'width' => 0,
24
+		'height' => 0,
25
+	);
26
+
27
+	/**
28
+	 * Render a thumbnail of a resource of type image.
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function create()
33
+	{
34
+		$steps = $this->getRenderingSteps();
35
+
36
+		$result = '';
37
+		while ($step = array_shift($steps)) {
38
+			$result = $this->$step($result);
39
+		}
40
+
41
+		return $result;
42
+	}
43
+
44
+	/**
45
+	 * Render the URI of the thumbnail.
46
+	 *
47
+	 * @return string
48
+	 * @throws \Fab\Media\Exception\EmptyValueException
49
+	 */
50
+	public function renderUri()
51
+	{
52
+
53
+		// Makes sure the width and the height of the thumbnail is not bigger than the actual file
54
+		$configuration = $this->getConfiguration();
55
+		if (!empty($configuration['width']) && $configuration['width'] > $this->getFile()->getProperty('width')) {
56
+			$configuration['width'] = $this->getFile()->getProperty('width');
57
+		}
58
+		if (!empty($configuration['height']) && $configuration['height'] > $this->getFile()->getProperty('height')) {
59
+			$configuration['height'] = $this->getFile()->getProperty('height');
60
+		}
61
+
62
+		$configuration = $this->computeFinalImageDimension($configuration);
63
+		$this->processedFile = $this->getFile()->process($this->getProcessingType(), $configuration);
64
+		$uri = $this->processedFile->getPublicUrl(true);
65
+
66
+		// Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
67
+		if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
68
+			$this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
69
+		}
70
+
71
+		return $this->prefixUri($uri);
72
+	}
73
+
74
+	/**
75
+	 * Render the tag image which is the main one for a thumbnail.
76
+	 *
77
+	 * @param string $result
78
+	 * @return string
79
+	 */
80
+	public function renderTagImage($result)
81
+	{
82
+
83
+		// Variable $result corresponds to an URL in this case.
84
+		// Analyse the URL and compute the adequate separator between arguments.
85
+		$parameterSeparator = strpos($result, '?') === false ? '?' : '&';
86
+
87
+		return sprintf('<img src="%s%s" title="%s" alt="%s" %s/>',
88
+			$result,
89
+			$this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->processedFile->getProperty('tstamp') : '',
90
+			$this->getTitle(),
91
+			$this->getTitle(),
92
+			$this->renderAttributes()
93
+		);
94
+	}
95
+
96
+	/**
97
+	 * Compute and return the title of the file.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	protected function getTitle()
102
+	{
103
+		$result = $this->getFile()->getProperty('title');
104
+		if (!$result) {
105
+			$result = $this->getFile()->getName();
106
+		}
107
+		return htmlspecialchars($result);
108
+	}
109
+
110
+	/**
111
+	 * Render a wrapping anchor around the thumbnail.
112
+	 *
113
+	 * @param string $result
114
+	 * @return string
115
+	 */
116
+	public function renderTagAnchor($result)
117
+	{
118
+
119
+		$file = $this->getFile();
120
+
121
+		// Perhaps the wrapping file must be processed
122
+		$configurationWrap = $this->thumbnailService->getConfigurationWrap();
123
+
124
+		// Make sure we have configurationWrap initialized correctly
125
+		if (!empty($configurationWrap['width']) || !empty($configurationWrap['height'])) {
126
+			$configurationWrap = array_merge($this->defaultConfigurationWrap, $configurationWrap);
127
+
128
+			// It looks maxW or maxH does not work as expected with CONTEXT_IMAGEPREVIEW...
129
+			// ... uses "width" and "height" instead.
130
+			if ($configurationWrap['width'] < $this->getFile()->getProperty('width')
131
+				|| $configurationWrap['height'] < $this->getFile()->getProperty('height')
132
+			) {
133
+				$configurationWrap = $this->computeFinalImageDimension($configurationWrap);
134
+				$file = $this->getFile()->process($this->getProcessingType(), $configurationWrap);
135
+			}
136
+		}
137
+
138
+		// Analyse the current $url and compute the adequate separator between arguments.
139
+		$url = $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true);
140
+		$parameterSeparator = strpos($url, '?') === false ? '?' : '&';
141
+
142
+		return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
143
+			$url,
144
+			$this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator . $file->getProperty('tstamp') : '',
145
+			$this->thumbnailService->getTarget(),
146
+			$file->getUid(),
147
+			$result
148
+		);
149
+	}
150
+
151
+	/**
152
+	 * Compute the final configuration for the image preview.
153
+	 * Keep ratio of width / height for the image.
154
+	 *
155
+	 * @param array $configuration
156
+	 * @return array
157
+	 */
158
+	protected function computeFinalImageDimension(array $configuration)
159
+	{
160
+		$ratio = $this->computeImageRatio();
161
+
162
+		if ($ratio > 1) {
163
+			$configuration['height'] = round($configuration['width'] / $ratio);
164
+		} else {
165
+			$configuration['width'] = round($configuration['height'] * $ratio);
166
+		}
167
+		return $configuration;
168
+	}
169
+
170
+	/**
171
+	 * Compute the width / height ratio of the image.
172
+	 *
173
+	 * @return null|float
174
+	 */
175
+	protected function computeImageRatio()
176
+	{
177
+		$ratio = null;
178
+		if ($this->getFile()->getProperty('width') > 0 && $this->getFile()->getProperty('height') > 0) {
179
+			$ratio = $this->getFile()->getProperty('width') / $this->getFile()->getProperty('height');
180
+		}
181
+		return $ratio;
182
+	}
183
+
184
+	/**
185
+	 * @return string
186
+	 */
187
+	public function getProcessingType()
188
+	{
189
+		if ($this->thumbnailService->getProcessingType() === null) {
190
+			return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
191
+		}
192
+		return $this->thumbnailService->getProcessingType();
193
+	}
194 194
 
195 195
 }
Please login to merge, or discard this patch.