Completed
Push — master ( 522461...c89cc2 )
by Fabien
02:24
created
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 2 patches
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.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
  */
10 10
 
11 11
 use Fab\Vidi\View\AbstractComponentView;
12
-use Fab\Media\Utility\Path;
13 12
 use TYPO3\CMS\Core\Page\PageRenderer;
14 13
 use TYPO3\CMS\Core\Utility\GeneralUtility;
15 14
 
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.
Classes/Grid/ActionPermissionColumn.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
             $permission .= 'W';
43 43
         }
44 44
 
45
-        return '<strong>' . $permission . '</strong>';
45
+        return '<strong>'.$permission.'</strong>';
46 46
     }
47 47
 
48 48
     /**
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,34 +17,34 @@
 block discarded – undo
17 17
 class ActionPermissionColumn extends ColumnRendererAbstract
18 18
 {
19 19
 
20
-    /**
21
-     * Renders a configurable metadata property of a file in the Grid.
22
-     *
23
-     * @throws \Exception
24
-     * @return string
25
-     */
26
-    public function render()
27
-    {
28
-
29
-        $file = $this->getFileConverter()->convert($this->object);
30
-        $permission = '';
31
-
32
-        if ($file->checkActionPermission('read')) {
33
-            $permission = 'R';
34
-        }
35
-        if ($file->checkActionPermission('write')) {
36
-            $permission .= 'W';
37
-        }
38
-
39
-        return '<strong>' . $permission . '</strong>';
40
-    }
41
-
42
-    /**
43
-     * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
44
-     */
45
-    protected function getFileConverter()
46
-    {
47
-        return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
48
-    }
20
+	/**
21
+	 * Renders a configurable metadata property of a file in the Grid.
22
+	 *
23
+	 * @throws \Exception
24
+	 * @return string
25
+	 */
26
+	public function render()
27
+	{
28
+
29
+		$file = $this->getFileConverter()->convert($this->object);
30
+		$permission = '';
31
+
32
+		if ($file->checkActionPermission('read')) {
33
+			$permission = 'R';
34
+		}
35
+		if ($file->checkActionPermission('write')) {
36
+			$permission .= 'W';
37
+		}
38
+
39
+		return '<strong>' . $permission . '</strong>';
40
+	}
41
+
42
+	/**
43
+	 * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
44
+	 */
45
+	protected function getFileConverter()
46
+	{
47
+		return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
48
+	}
49 49
 
50 50
 }
Please login to merge, or discard this patch.
Classes/Tool/CacheWarmUpTool.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
      */
80 80
     protected function getWarmUpSemaphorFile()
81 81
     {
82
-        return PATH_site . 'typo3temp/.media_cache_warmed_up';
82
+        return PATH_site.'typo3temp/.media_cache_warmed_up';
83 83
     }
84 84
 
85 85
     /**
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -16,73 +16,73 @@
 block discarded – undo
16 16
 class CacheWarmUpTool extends AbstractTool
17 17
 {
18 18
 
19
-    /**
20
-     * Display the title of the tool on the welcome screen.
21
-     *
22
-     * @return string
23
-     */
24
-    public function getTitle()
25
-    {
26
-        return 'Cache warm up';
27
-    }
19
+	/**
20
+	 * Display the title of the tool on the welcome screen.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function getTitle()
25
+	{
26
+		return 'Cache warm up';
27
+	}
28 28
 
29
-    /**
30
-     * Display the description of the tool in the welcome screen.
31
-     *
32
-     * @return string
33
-     */
34
-    public function getDescription()
35
-    {
36
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
37
-        $view = $this->initializeStandaloneView($templateNameAndPath);
38
-        $view->assign('sitePath', PATH_site);
39
-        return $view->render();
40
-    }
29
+	/**
30
+	 * Display the description of the tool in the welcome screen.
31
+	 *
32
+	 * @return string
33
+	 */
34
+	public function getDescription()
35
+	{
36
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
37
+		$view = $this->initializeStandaloneView($templateNameAndPath);
38
+		$view->assign('sitePath', PATH_site);
39
+		return $view->render();
40
+	}
41 41
 
42
-    /**
43
-     * Do the job: warm up the cache.
44
-     *
45
-     * @param array $arguments
46
-     * @return string
47
-     */
48
-    public function work(array $arguments = [])
49
-    {
42
+	/**
43
+	 * Do the job: warm up the cache.
44
+	 *
45
+	 * @param array $arguments
46
+	 * @return string
47
+	 */
48
+	public function work(array $arguments = [])
49
+	{
50 50
 
51
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
52
-        $view = $this->initializeStandaloneView($templateNameAndPath);
51
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
52
+		$view = $this->initializeStandaloneView($templateNameAndPath);
53 53
 
54
-        $numberOfEntries = $this->getCacheService()->warmUp();
55
-        $view->assign('numberOfEntries', $numberOfEntries);
56
-        touch($this->getWarmUpSemaphorFile());
54
+		$numberOfEntries = $this->getCacheService()->warmUp();
55
+		$view->assign('numberOfEntries', $numberOfEntries);
56
+		touch($this->getWarmUpSemaphorFile());
57 57
 
58
-        return $view->render();
59
-    }
58
+		return $view->render();
59
+	}
60 60
 
61
-    /**
62
-     * Tell whether the tools should be displayed according to the context.
63
-     *
64
-     * @return bool
65
-     */
66
-    public function isShown()
67
-    {
68
-        return $this->getBackendUser()->isAdmin();
69
-    }
61
+	/**
62
+	 * Tell whether the tools should be displayed according to the context.
63
+	 *
64
+	 * @return bool
65
+	 */
66
+	public function isShown()
67
+	{
68
+		return $this->getBackendUser()->isAdmin();
69
+	}
70 70
 
71
-    /**
72
-     * @return string
73
-     */
74
-    protected function getWarmUpSemaphorFile()
75
-    {
76
-        return PATH_site . 'typo3temp/.media_cache_warmed_up';
77
-    }
71
+	/**
72
+	 * @return string
73
+	 */
74
+	protected function getWarmUpSemaphorFile()
75
+	{
76
+		return PATH_site . 'typo3temp/.media_cache_warmed_up';
77
+	}
78 78
 
79
-    /**
80
-     * @return \Fab\Media\Cache\CacheService|object
81
-     */
82
-    protected function getCacheService()
83
-    {
84
-        return GeneralUtility::makeInstance(\Fab\Media\Cache\CacheService::class);
85
-    }
79
+	/**
80
+	 * @return \Fab\Media\Cache\CacheService|object
81
+	 */
82
+	protected function getCacheService()
83
+	{
84
+		return GeneralUtility::makeInstance(\Fab\Media\Cache\CacheService::class);
85
+	}
86 86
 
87 87
 }
88 88
 
Please login to merge, or discard this patch.
Classes/Tool/ThumbnailGeneratorTool.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
                         $formattedResultSet[] = sprintf('* File "%s": %s %s',
86 86
                             $result['fileUid'],
87 87
                             $result['fileIdentifier'],
88
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
88
+                            empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri']
89 89
                         );
90 90
                     }
91 91
 
Please login to merge, or discard this patch.
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -18,125 +18,125 @@
 block discarded – undo
18 18
 class ThumbnailGeneratorTool extends AbstractTool
19 19
 {
20 20
 
21
-    /**
22
-     * Display the title of the tool on the welcome screen.
23
-     *
24
-     * @return string
25
-     */
26
-    public function getTitle()
27
-    {
28
-        return 'Generate thumbnails';
29
-    }
30
-
31
-    /**
32
-     * Display the description of the tool in the welcome screen.
33
-     *
34
-     * @return string
35
-     */
36
-    public function getDescription()
37
-    {
38
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
39
-        $view = $this->initializeStandaloneView($templateNameAndPath);
40
-        $view->assign('sitePath', PATH_site);
41
-        return $view->render();
42
-    }
43
-
44
-    /**
45
-     * Do the job: analyse Index.
46
-     *
47
-     * @param array $arguments
48
-     * @return string
49
-     */
50
-    public function work(array $arguments = [])
51
-    {
52
-
53
-        $reports = [];
54
-
55
-        $limit = 500; // default value
56
-        $newOffset = 0;
57
-
58
-        // Possible clean up of missing files if the User has clicked so.
59
-        if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
-
61
-            $limit = (int)$arguments['limit'];
62
-            $offset = (int)$arguments['offset'];
63
-
64
-            foreach ($this->getStorageRepository()->findAll() as $storage) {
65
-
66
-                if ($storage->isOnline()) {
67
-
68
-                    $thumbnailGenerator = $this->getThumbnailGenerator();
69
-                    $thumbnailGenerator
70
-                        ->setStorage($storage)
71
-                        ->generate($limit, $offset);
72
-
73
-                    $formattedResultSet = [];
74
-                    $resultSet = $thumbnailGenerator->getResultSet();
75
-                    $processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
76
-
77
-                    foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
78
-                        $result = $resultSet[$fileIdentifier];
79
-                        $formattedResultSet[] = sprintf('* File "%s": %s %s',
80
-                            $result['fileUid'],
81
-                            $result['fileIdentifier'],
82
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
83
-                        );
84
-                    }
85
-
86
-                    $reports[] = array(
87
-                        'storage' => $storage,
88
-                        'isStorageOnline' => true,
89
-                        'resultSet' => $formattedResultSet,
90
-                        'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
91
-                        'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
92
-                        'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
93
-                        'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
94
-                    );
95
-                } else {
96
-                    $reports[] = array(
97
-                        'storage' => $storage,
98
-                        'isStorageOnline' => false,
99
-                    );
100
-                }
101
-            }
102
-
103
-            $newOffset = $limit + $offset;
104
-        }
105
-
106
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
107
-        $view = $this->initializeStandaloneView($templateNameAndPath);
108
-
109
-        $view->assign('limit', $limit);
110
-        $view->assign('offset', $newOffset);
111
-        $view->assign('reports', $reports);
112
-        return $view->render();
113
-    }
114
-
115
-    /**
116
-     * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
117
-     */
118
-    protected function getThumbnailGenerator()
119
-    {
120
-        return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
121
-    }
122
-
123
-    /**
124
-     * @return StorageRepository|object
125
-     */
126
-    protected function getStorageRepository()
127
-    {
128
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
129
-    }
130
-
131
-    /**
132
-     * Tell whether the tools should be displayed according to the context.
133
-     *
134
-     * @return bool
135
-     */
136
-    public function isShown()
137
-    {
138
-        return $this->getBackendUser()->isAdmin();
139
-    }
21
+	/**
22
+	 * Display the title of the tool on the welcome screen.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function getTitle()
27
+	{
28
+		return 'Generate thumbnails';
29
+	}
30
+
31
+	/**
32
+	 * Display the description of the tool in the welcome screen.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function getDescription()
37
+	{
38
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
39
+		$view = $this->initializeStandaloneView($templateNameAndPath);
40
+		$view->assign('sitePath', PATH_site);
41
+		return $view->render();
42
+	}
43
+
44
+	/**
45
+	 * Do the job: analyse Index.
46
+	 *
47
+	 * @param array $arguments
48
+	 * @return string
49
+	 */
50
+	public function work(array $arguments = [])
51
+	{
52
+
53
+		$reports = [];
54
+
55
+		$limit = 500; // default value
56
+		$newOffset = 0;
57
+
58
+		// Possible clean up of missing files if the User has clicked so.
59
+		if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
+
61
+			$limit = (int)$arguments['limit'];
62
+			$offset = (int)$arguments['offset'];
63
+
64
+			foreach ($this->getStorageRepository()->findAll() as $storage) {
65
+
66
+				if ($storage->isOnline()) {
67
+
68
+					$thumbnailGenerator = $this->getThumbnailGenerator();
69
+					$thumbnailGenerator
70
+						->setStorage($storage)
71
+						->generate($limit, $offset);
72
+
73
+					$formattedResultSet = [];
74
+					$resultSet = $thumbnailGenerator->getResultSet();
75
+					$processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
76
+
77
+					foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
78
+						$result = $resultSet[$fileIdentifier];
79
+						$formattedResultSet[] = sprintf('* File "%s": %s %s',
80
+							$result['fileUid'],
81
+							$result['fileIdentifier'],
82
+							empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
83
+						);
84
+					}
85
+
86
+					$reports[] = array(
87
+						'storage' => $storage,
88
+						'isStorageOnline' => true,
89
+						'resultSet' => $formattedResultSet,
90
+						'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
91
+						'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
92
+						'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
93
+						'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
94
+					);
95
+				} else {
96
+					$reports[] = array(
97
+						'storage' => $storage,
98
+						'isStorageOnline' => false,
99
+					);
100
+				}
101
+			}
102
+
103
+			$newOffset = $limit + $offset;
104
+		}
105
+
106
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
107
+		$view = $this->initializeStandaloneView($templateNameAndPath);
108
+
109
+		$view->assign('limit', $limit);
110
+		$view->assign('offset', $newOffset);
111
+		$view->assign('reports', $reports);
112
+		return $view->render();
113
+	}
114
+
115
+	/**
116
+	 * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
117
+	 */
118
+	protected function getThumbnailGenerator()
119
+	{
120
+		return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
121
+	}
122
+
123
+	/**
124
+	 * @return StorageRepository|object
125
+	 */
126
+	protected function getStorageRepository()
127
+	{
128
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
129
+	}
130
+
131
+	/**
132
+	 * Tell whether the tools should be displayed according to the context.
133
+	 *
134
+	 * @return bool
135
+	 */
136
+	public function isShown()
137
+	{
138
+		return $this->getBackendUser()->isAdmin();
139
+	}
140 140
 
141 141
 }
142 142
 
Please login to merge, or discard this patch.
Classes/Form/FileUploadTceForms.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
         // Get the base prefix.
43 43
         $basePrefix = $this->getBasePrefix($this->getPrefix());
44
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
44
+        $filePath = ExtensionManagementUtility::extPath('media').'Resources/Private/Standalone/FileUploadTceForms.js';
45 45
 
46 46
         return sprintf(file_get_contents($filePath),
47 47
             $basePrefix,
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -20,64 +20,64 @@
 block discarded – undo
20 20
 class FileUploadTceForms extends FileUpload
21 21
 {
22 22
 
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $templateFile = 'Resources/Private/Standalone/FileUploadTceFormsTemplate.html';
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $templateFile = 'Resources/Private/Standalone/FileUploadTceFormsTemplate.html';
27 27
 
28
-    /**
29
-     * Fetch the JavaScript to be rendered and replace the markers with "live" variables.
30
-     *
31
-     * @return string
32
-     */
33
-    protected function getJavaScript()
34
-    {
28
+	/**
29
+	 * Fetch the JavaScript to be rendered and replace the markers with "live" variables.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	protected function getJavaScript()
34
+	{
35 35
 
36
-        // Get the base prefix.
37
-        $basePrefix = $this->getBasePrefix($this->getPrefix());
38
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
36
+		// Get the base prefix.
37
+		$basePrefix = $this->getBasePrefix($this->getPrefix());
38
+		$filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
39 39
 
40
-        return sprintf(file_get_contents($filePath),
41
-            $basePrefix,
42
-            $this->elementId,
43
-            $this->getModuleUrl(),
44
-            $this->getAllowedExtension(),
45
-            GeneralUtility::getMaxUploadFileSize() * 1024,
46
-            $this->getValue()
47
-        );
48
-    }
40
+		return sprintf(file_get_contents($filePath),
41
+			$basePrefix,
42
+			$this->elementId,
43
+			$this->getModuleUrl(),
44
+			$this->getAllowedExtension(),
45
+			GeneralUtility::getMaxUploadFileSize() * 1024,
46
+			$this->getValue()
47
+		);
48
+	}
49 49
 
50
-    /**
51
-     * @return string
52
-     */
53
-    protected function getModuleUrl()
54
-    {
55
-        $moduleSignature = MediaModule::getSignature();
56
-        return BackendUtility::getModuleUrl($moduleSignature);
57
-    }
50
+	/**
51
+	 * @return string
52
+	 */
53
+	protected function getModuleUrl()
54
+	{
55
+		$moduleSignature = MediaModule::getSignature();
56
+		return BackendUtility::getModuleUrl($moduleSignature);
57
+	}
58 58
 
59
-    /**
60
-     * Get allowed extension.
61
-     *
62
-     * @return string
63
-     */
64
-    protected function getAllowedExtension()
65
-    {
66
-        return $this->file->getExtension();
67
-    }
59
+	/**
60
+	 * Get allowed extension.
61
+	 *
62
+	 * @return string
63
+	 */
64
+	protected function getAllowedExtension()
65
+	{
66
+		return $this->file->getExtension();
67
+	}
68 68
 
69
-    /**
70
-     * Returns additional file info.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function getFileInfo()
75
-    {
76
-        /** @var \Fab\Media\ViewHelpers\MetadataViewHelper $metadataViewHelper */
77
-        $metadataViewHelper = GeneralUtility::makeInstance(\Fab\Media\ViewHelpers\MetadataViewHelper::class);
69
+	/**
70
+	 * Returns additional file info.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function getFileInfo()
75
+	{
76
+		/** @var \Fab\Media\ViewHelpers\MetadataViewHelper $metadataViewHelper */
77
+		$metadataViewHelper = GeneralUtility::makeInstance(\Fab\Media\ViewHelpers\MetadataViewHelper::class);
78 78
 
79
-        return sprintf('<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
80
-            $metadataViewHelper->render($this->file)
81
-        );
82
-    }
79
+		return sprintf('<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
80
+			$metadataViewHelper->render($this->file)
81
+		);
82
+	}
83 83
 }
Please login to merge, or discard this patch.