Completed
Push — master ( 02a2d0...8117b3 )
by Fabien
54:58
created
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.
Classes/Form/FileUpload.php 2 patches
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function __construct()
52 52
     {
53 53
         $this->addLanguage();
54
-        $this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
54
+        $this->elementId = 'jquery-wrapped-fine-uploader-'.uniqid();
55 55
 
56 56
         $this->template = <<<EOF
57 57
 <div class="control-group control-group-upload" style="%s">
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         /** @var PageRenderer $pageRenderer */
76 76
         $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
77
-        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
77
+        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media').'Resources/Private/Language/locallang.xlf', 'media_file_upload');
78 78
     }
79 79
 
80 80
     /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
162 162
         $view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
163 163
 
164
-        $templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
164
+        $templatePathAndFilename = ExtensionManagementUtility::extPath('media').$this->templateFile;
165 165
         $view->setTemplatePathAndFilename($templatePathAndFilename);
166 166
 
167 167
         return $view;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         // Get the base prefix
179 179
         $basePrefix = $this->getBasePrefix($this->getPrefix());
180 180
 
181
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
181
+        $filePath = ExtensionManagementUtility::extPath('media').'Resources/Private/Standalone/FileUpload.js';
182 182
 
183 183
         return sprintf(
184 184
             file_get_contents($filePath),
@@ -188,8 +188,7 @@  discard block
 block discarded – undo
188 188
             $this->getAllowedExtensions(),
189 189
             GeneralUtility::getMaxUploadFileSize() * 1024,
190 190
             $this->isDrivenByFolder() ?
191
-                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
192
-                $this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
191
+                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() : $this->getMediaModule()->getCurrentStorage()->getUid().':/'
193 192
 
194 193
         );
195 194
     }
Please login to merge, or discard this patch.
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -24,30 +24,30 @@  discard block
 block discarded – undo
24 24
 class FileUpload extends AbstractFormField
25 25
 {
26 26
 
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $elementId;
31
-
32
-    /**
33
-     * @var \TYPO3\CMS\Core\Resource\File
34
-     */
35
-    protected $file;
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected $templateFile = 'Resources/Private/Standalone/FileUploadTemplate.html';
41
-
42
-    /**
43
-     * @return \Fab\Media\Form\FileUpload
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->addLanguage();
48
-        $this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
49
-
50
-        $this->template = <<<EOF
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $elementId;
31
+
32
+	/**
33
+	 * @var \TYPO3\CMS\Core\Resource\File
34
+	 */
35
+	protected $file;
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected $templateFile = 'Resources/Private/Standalone/FileUploadTemplate.html';
41
+
42
+	/**
43
+	 * @return \Fab\Media\Form\FileUpload
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->addLanguage();
48
+		$this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
49
+
50
+		$this->template = <<<EOF
51 51
 <div class="control-group control-group-upload" style="%s">
52 52
     <div class="container-thumbnail">%s</div>
53 53
     %s
@@ -59,213 +59,213 @@  discard block
 block discarded – undo
59 59
 </div>
60 60
 
61 61
 EOF;
62
-    }
63
-
64
-    /**
65
-     * Add language labels for JavaScript files
66
-     */
67
-    protected function addLanguage()
68
-    {
69
-        /** @var PageRenderer $pageRenderer */
70
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71
-        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
72
-    }
73
-
74
-    /**
75
-     * Render a file upload field.
76
-     *
77
-     * @throws \Fab\Media\Exception\EmptyPropertyException
78
-     * @return string
79
-     */
80
-    public function render()
81
-    {
82
-
83
-        // Instantiate the file object for the whole class if possible.
84
-        if ($this->getValue()) {
85
-            $this->file = ResourceFactory::getInstance()->getFileObject($this->getValue());
86
-        }
87
-
88
-        $result = sprintf(
89
-            $this->template,
90
-            $this->getInlineStyle(),
91
-            $this->getThumbnail(),
92
-            $this->getFileInfo(),
93
-            $this->elementId,
94
-            $this->getJavaScriptTemplate(),
95
-            $this->getJavaScript()
96
-        );
97
-        return $result;
98
-    }
99
-
100
-    /**
101
-     * @return string
102
-     */
103
-    protected function getInlineStyle()
104
-    {
105
-        $style = 'float: left';
106
-        if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
107
-            $style .= '; padding-left: 3px';
108
-        }
109
-        return $style;
110
-    }
111
-
112
-    /**
113
-     * Get the javascript from a file and replace the markers with live variables.
114
-     *
115
-     * @return string
116
-     */
117
-    protected function getThumbnail()
118
-    {
119
-        $thumbnail = '';
120
-        if ($this->file) {
121
-
122
-            /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
123
-            $thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $this->file);
124
-            $thumbnail = $thumbnailService
125
-                ->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
126
-                ->setAppendTimeStamp(true)
127
-                ->create();
128
-        }
129
-        return $thumbnail;
130
-    }
131
-
132
-    /**
133
-     * Get the javascript from a file and replace the markers with live variables.
134
-     *
135
-     * @return string
136
-     */
137
-    protected function getJavaScriptTemplate()
138
-    {
139
-        $view = $this->getStandaloneView();
140
-        $view->assignMultiple(
141
-            array(
142
-                'maximumUploadLabel' => $this->getMaximumUploadLabel(),
143
-            )
144
-        );
145
-        return $view->render();
146
-    }
147
-
148
-    /**
149
-     * @return \TYPO3\CMS\Fluid\View\StandaloneView
150
-     */
151
-    protected function getStandaloneView()
152
-    {
153
-        $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
154
-
155
-        /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
156
-        $view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
157
-
158
-        $templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
159
-        $view->setTemplatePathAndFilename($templatePathAndFilename);
160
-
161
-        return $view;
162
-    }
163
-
164
-    /**
165
-     * Get the javascript from a file and replace the markers with live variables.
166
-     *
167
-     * @return string
168
-     */
169
-    protected function getJavaScript()
170
-    {
171
-
172
-        // Get the base prefix
173
-        $basePrefix = $this->getBasePrefix($this->getPrefix());
174
-
175
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
176
-
177
-        return sprintf(
178
-            file_get_contents($filePath),
179
-            $basePrefix,
180
-            $this->elementId,
181
-            $this->getModuleUrl(),
182
-            $this->getAllowedExtensions(),
183
-            GeneralUtility::getMaxUploadFileSize() * 1024,
184
-            $this->isDrivenByFolder() ?
185
-                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
186
-                $this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
187
-
188
-        );
189
-    }
190
-
191
-    /**
192
-     * @return bool
193
-     */
194
-    protected function isDrivenByFolder()
195
-    {
196
-        return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin();
197
-    }
198
-
199
-    /**
200
-     * @return string
201
-     */
202
-    protected function getModuleUrl()
203
-    {
204
-        $moduleSignature = MediaModule::getSignature();
205
-        return BackendUtility::getModuleUrl($moduleSignature);
206
-    }
207
-
208
-    /**
209
-     * Returns the max upload file size in Mo.
210
-     *
211
-     * @return string
212
-     */
213
-    protected function getMaximumUploadLabel()
214
-    {
215
-        $result = round(GeneralUtility::getMaxUploadFileSize() / 1024, 2);
216
-        $label = LocalizationUtility::translate('max_upload_file', 'media');
217
-        $result = sprintf($label, $result);
218
-        return $result;
219
-    }
220
-
221
-    /**
222
-     * Get allowed extension.
223
-     *
224
-     * @return string
225
-     */
226
-    protected function getAllowedExtensions()
227
-    {
228
-        return implode("','", PermissionUtility::getInstance()->getAllowedExtensions());
229
-    }
230
-
231
-    /**
232
-     * Compute the base prefix by removing the square brackets.
233
-     *
234
-     * @param string $prefix
235
-     * @return string
236
-     */
237
-    protected function getBasePrefix($prefix)
238
-    {
239
-        $parts = explode('[', $prefix);
240
-        return empty($parts) ? '' : $parts[0];
241
-    }
242
-
243
-    /**
244
-     * Returns additional file info.
245
-     *
246
-     * @return string
247
-     */
248
-    protected function getFileInfo()
249
-    {
250
-        return ''; // empty return here but check out Tceforms/FileUpload
251
-    }
252
-
253
-    /**
254
-     * @return MediaModule|object
255
-     */
256
-    protected function getMediaModule()
257
-    {
258
-        return GeneralUtility::makeInstance(MediaModule::class);
259
-    }
260
-
261
-    /**
262
-     * Get the Vidi Module Loader.
263
-     *
264
-     * @return \Fab\Vidi\Module\ModuleLoader|object
265
-     */
266
-    protected function getModuleLoader()
267
-    {
268
-        return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class);
269
-    }
62
+	}
63
+
64
+	/**
65
+	 * Add language labels for JavaScript files
66
+	 */
67
+	protected function addLanguage()
68
+	{
69
+		/** @var PageRenderer $pageRenderer */
70
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71
+		$pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
72
+	}
73
+
74
+	/**
75
+	 * Render a file upload field.
76
+	 *
77
+	 * @throws \Fab\Media\Exception\EmptyPropertyException
78
+	 * @return string
79
+	 */
80
+	public function render()
81
+	{
82
+
83
+		// Instantiate the file object for the whole class if possible.
84
+		if ($this->getValue()) {
85
+			$this->file = ResourceFactory::getInstance()->getFileObject($this->getValue());
86
+		}
87
+
88
+		$result = sprintf(
89
+			$this->template,
90
+			$this->getInlineStyle(),
91
+			$this->getThumbnail(),
92
+			$this->getFileInfo(),
93
+			$this->elementId,
94
+			$this->getJavaScriptTemplate(),
95
+			$this->getJavaScript()
96
+		);
97
+		return $result;
98
+	}
99
+
100
+	/**
101
+	 * @return string
102
+	 */
103
+	protected function getInlineStyle()
104
+	{
105
+		$style = 'float: left';
106
+		if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
107
+			$style .= '; padding-left: 3px';
108
+		}
109
+		return $style;
110
+	}
111
+
112
+	/**
113
+	 * Get the javascript from a file and replace the markers with live variables.
114
+	 *
115
+	 * @return string
116
+	 */
117
+	protected function getThumbnail()
118
+	{
119
+		$thumbnail = '';
120
+		if ($this->file) {
121
+
122
+			/** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
123
+			$thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $this->file);
124
+			$thumbnail = $thumbnailService
125
+				->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
126
+				->setAppendTimeStamp(true)
127
+				->create();
128
+		}
129
+		return $thumbnail;
130
+	}
131
+
132
+	/**
133
+	 * Get the javascript from a file and replace the markers with live variables.
134
+	 *
135
+	 * @return string
136
+	 */
137
+	protected function getJavaScriptTemplate()
138
+	{
139
+		$view = $this->getStandaloneView();
140
+		$view->assignMultiple(
141
+			array(
142
+				'maximumUploadLabel' => $this->getMaximumUploadLabel(),
143
+			)
144
+		);
145
+		return $view->render();
146
+	}
147
+
148
+	/**
149
+	 * @return \TYPO3\CMS\Fluid\View\StandaloneView
150
+	 */
151
+	protected function getStandaloneView()
152
+	{
153
+		$objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
154
+
155
+		/** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
156
+		$view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
157
+
158
+		$templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
159
+		$view->setTemplatePathAndFilename($templatePathAndFilename);
160
+
161
+		return $view;
162
+	}
163
+
164
+	/**
165
+	 * Get the javascript from a file and replace the markers with live variables.
166
+	 *
167
+	 * @return string
168
+	 */
169
+	protected function getJavaScript()
170
+	{
171
+
172
+		// Get the base prefix
173
+		$basePrefix = $this->getBasePrefix($this->getPrefix());
174
+
175
+		$filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
176
+
177
+		return sprintf(
178
+			file_get_contents($filePath),
179
+			$basePrefix,
180
+			$this->elementId,
181
+			$this->getModuleUrl(),
182
+			$this->getAllowedExtensions(),
183
+			GeneralUtility::getMaxUploadFileSize() * 1024,
184
+			$this->isDrivenByFolder() ?
185
+				$this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
186
+				$this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
187
+
188
+		);
189
+	}
190
+
191
+	/**
192
+	 * @return bool
193
+	 */
194
+	protected function isDrivenByFolder()
195
+	{
196
+		return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin();
197
+	}
198
+
199
+	/**
200
+	 * @return string
201
+	 */
202
+	protected function getModuleUrl()
203
+	{
204
+		$moduleSignature = MediaModule::getSignature();
205
+		return BackendUtility::getModuleUrl($moduleSignature);
206
+	}
207
+
208
+	/**
209
+	 * Returns the max upload file size in Mo.
210
+	 *
211
+	 * @return string
212
+	 */
213
+	protected function getMaximumUploadLabel()
214
+	{
215
+		$result = round(GeneralUtility::getMaxUploadFileSize() / 1024, 2);
216
+		$label = LocalizationUtility::translate('max_upload_file', 'media');
217
+		$result = sprintf($label, $result);
218
+		return $result;
219
+	}
220
+
221
+	/**
222
+	 * Get allowed extension.
223
+	 *
224
+	 * @return string
225
+	 */
226
+	protected function getAllowedExtensions()
227
+	{
228
+		return implode("','", PermissionUtility::getInstance()->getAllowedExtensions());
229
+	}
230
+
231
+	/**
232
+	 * Compute the base prefix by removing the square brackets.
233
+	 *
234
+	 * @param string $prefix
235
+	 * @return string
236
+	 */
237
+	protected function getBasePrefix($prefix)
238
+	{
239
+		$parts = explode('[', $prefix);
240
+		return empty($parts) ? '' : $parts[0];
241
+	}
242
+
243
+	/**
244
+	 * Returns additional file info.
245
+	 *
246
+	 * @return string
247
+	 */
248
+	protected function getFileInfo()
249
+	{
250
+		return ''; // empty return here but check out Tceforms/FileUpload
251
+	}
252
+
253
+	/**
254
+	 * @return MediaModule|object
255
+	 */
256
+	protected function getMediaModule()
257
+	{
258
+		return GeneralUtility::makeInstance(MediaModule::class);
259
+	}
260
+
261
+	/**
262
+	 * Get the Vidi Module Loader.
263
+	 *
264
+	 * @return \Fab\Vidi\Module\ModuleLoader|object
265
+	 */
266
+	protected function getModuleLoader()
267
+	{
268
+		return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class);
269
+	}
270 270
 
271 271
 }
Please login to merge, or discard this patch.
Classes/Form/AbstractFormField.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
             reset($attribute);
132 132
             $key = key($attribute);
133 133
             if (!is_string($key)) {
134
-                throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
134
+                throw new InvalidStringException('Not an associative array. Is not a key: '.$key, 1356478742);
135 135
             }
136 136
 
137 137
             $this->attributes[$key] = $attribute[$key];
Please login to merge, or discard this patch.
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -18,267 +18,267 @@
 block discarded – undo
18 18
 abstract class AbstractFormField implements FormFieldInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $template = '';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $value = '';
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name = '';
35
-
36
-    /**
37
-     * @var string
38
-     */
39
-    protected $id = '';
40
-
41
-    /**
42
-     * @var string
43
-     */
44
-    protected $prefix = '';
45
-
46
-    /**
47
-     * @var string
48
-     */
49
-    protected $label = '';
50
-
51
-    /**
52
-     * Store what child element will contain this element.
53
-     *
54
-     * @var array
55
-     */
56
-    protected $items = [];
57
-
58
-    /**
59
-     * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
-     *
61
-     * @var array
62
-     */
63
-    protected $attributes = [];
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function render()
69
-    {
70
-        return $this->template;
71
-    }
72
-
73
-    /**
74
-     * Render the label if possible. Otherwise return an empty string.
75
-     *
76
-     * @return string
77
-     */
78
-    public function renderLabel()
79
-    {
80
-        $result = '';
81
-        if ($this->label) {
82
-            $template = '<label class="control-label" for="%s">%s</label>';
83
-
84
-            if (strpos($this->label, 'LLL:') === 0) {
85
-                $this->label = LocalizationUtility::translate($this->label, '');
86
-            }
87
-
88
-            $result = sprintf($template,
89
-                $this->getId(),
90
-                $this->label
91
-            );
92
-        }
93
-        return $result;
94
-    }
95
-
96
-    /**
97
-     * Render additional attribute for this DOM element.
98
-     *
99
-     * @return string
100
-     */
101
-    public function renderAttributes()
102
-    {
103
-        $result = '';
104
-        if (!empty($this->attributes)) {
105
-            foreach ($this->attributes as $attribute => $value) {
106
-                $result .= sprintf('%s="%s" ',
107
-                    htmlspecialchars($attribute),
108
-                    htmlspecialchars($value)
109
-                );
110
-            }
111
-        }
112
-        return $result;
113
-    }
114
-
115
-    /**
116
-     * Add an additional (DOM) attribute to be added to this template.
117
-     *
118
-     * @throws InvalidStringException
119
-     * @param array $attribute associative array that contains attribute => value
120
-     * @return \Fab\Media\Form\AbstractFormField
121
-     */
122
-    public function addAttribute(array $attribute)
123
-    {
124
-        if (!empty($attribute)) {
125
-            reset($attribute);
126
-            $key = key($attribute);
127
-            if (!is_string($key)) {
128
-                throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
-            }
130
-
131
-            $this->attributes[$key] = $attribute[$key];
132
-        }
133
-        return $this;
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getTemplate()
140
-    {
141
-        return $this->template;
142
-    }
143
-
144
-    /**
145
-     * @param string $template
146
-     * @return \Fab\Media\Form\AbstractFormField
147
-     */
148
-    public function setTemplate($template)
149
-    {
150
-        $this->template = $template;
151
-    }
152
-
153
-    /**
154
-     * @return string
155
-     */
156
-    public function getLabel()
157
-    {
158
-        return $this->label;
159
-    }
160
-
161
-    /**
162
-     * @param string $label
163
-     * @return \Fab\Media\Form\AbstractFormField
164
-     */
165
-    public function setLabel($label)
166
-    {
167
-        $this->label = $label;
168
-        return $this;
169
-    }
170
-
171
-    /**
172
-     * @return string
173
-     */
174
-    public function getPrefix()
175
-    {
176
-        return $this->prefix;
177
-    }
178
-
179
-    /**
180
-     * @param string $prefix
181
-     * @return \Fab\Media\Form\AbstractFormField
182
-     */
183
-    public function setPrefix($prefix)
184
-    {
185
-        $this->prefix = $prefix;
186
-        return $this;
187
-    }
188
-
189
-    /**
190
-     * @return array
191
-     */
192
-    public function getItems()
193
-    {
194
-        return $this->items;
195
-    }
196
-
197
-    /**
198
-     * @param array $items
199
-     */
200
-    public function setItems($items)
201
-    {
202
-        $this->items = $items;
203
-    }
204
-
205
-    /**
206
-     * @return string
207
-     */
208
-    public function getValue()
209
-    {
210
-        return htmlspecialchars($this->value);
211
-    }
212
-
213
-    /**
214
-     * @param string $value
215
-     * @return \Fab\Media\Form\AbstractFormField
216
-     */
217
-    public function setValue($value)
218
-    {
219
-        $this->value = $value;
220
-        return $this;
221
-    }
222
-
223
-    /**
224
-     * @return string
225
-     */
226
-    public function getName()
227
-    {
228
-        $result = $this->name;
229
-        if ($this->getPrefix()) {
230
-            $result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
-        }
232
-        return $result;
233
-    }
234
-
235
-    /**
236
-     * @param string $name
237
-     * @return \Fab\Media\Form\AbstractFormField
238
-     */
239
-    public function setName($name)
240
-    {
241
-        $this->name = $name;
242
-        return $this;
243
-    }
244
-
245
-    /**
246
-     * @return string
247
-     */
248
-    public function getId()
249
-    {
250
-        if ($this->id === '') {
251
-            $this->id = DomElement::getInstance()->formatId($this->getName());
252
-        }
253
-        return $this->id;
254
-    }
255
-
256
-    /**
257
-     * @param string $id
258
-     * @return \Fab\Media\Form\AbstractFormField
259
-     */
260
-    public function setId($id)
261
-    {
262
-        $this->id = $id;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return array
268
-     */
269
-    public function getAttributes()
270
-    {
271
-        return $this->attributes;
272
-    }
273
-
274
-    /**
275
-     * @param array $attributes
276
-     * @return \Fab\Media\Form\AbstractFormField
277
-     */
278
-    public function setAttributes($attributes)
279
-    {
280
-        $this->attributes = $attributes;
281
-        return $this;
282
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $template = '';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $value = '';
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name = '';
35
+
36
+	/**
37
+	 * @var string
38
+	 */
39
+	protected $id = '';
40
+
41
+	/**
42
+	 * @var string
43
+	 */
44
+	protected $prefix = '';
45
+
46
+	/**
47
+	 * @var string
48
+	 */
49
+	protected $label = '';
50
+
51
+	/**
52
+	 * Store what child element will contain this element.
53
+	 *
54
+	 * @var array
55
+	 */
56
+	protected $items = [];
57
+
58
+	/**
59
+	 * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected $attributes = [];
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function render()
69
+	{
70
+		return $this->template;
71
+	}
72
+
73
+	/**
74
+	 * Render the label if possible. Otherwise return an empty string.
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function renderLabel()
79
+	{
80
+		$result = '';
81
+		if ($this->label) {
82
+			$template = '<label class="control-label" for="%s">%s</label>';
83
+
84
+			if (strpos($this->label, 'LLL:') === 0) {
85
+				$this->label = LocalizationUtility::translate($this->label, '');
86
+			}
87
+
88
+			$result = sprintf($template,
89
+				$this->getId(),
90
+				$this->label
91
+			);
92
+		}
93
+		return $result;
94
+	}
95
+
96
+	/**
97
+	 * Render additional attribute for this DOM element.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	public function renderAttributes()
102
+	{
103
+		$result = '';
104
+		if (!empty($this->attributes)) {
105
+			foreach ($this->attributes as $attribute => $value) {
106
+				$result .= sprintf('%s="%s" ',
107
+					htmlspecialchars($attribute),
108
+					htmlspecialchars($value)
109
+				);
110
+			}
111
+		}
112
+		return $result;
113
+	}
114
+
115
+	/**
116
+	 * Add an additional (DOM) attribute to be added to this template.
117
+	 *
118
+	 * @throws InvalidStringException
119
+	 * @param array $attribute associative array that contains attribute => value
120
+	 * @return \Fab\Media\Form\AbstractFormField
121
+	 */
122
+	public function addAttribute(array $attribute)
123
+	{
124
+		if (!empty($attribute)) {
125
+			reset($attribute);
126
+			$key = key($attribute);
127
+			if (!is_string($key)) {
128
+				throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
+			}
130
+
131
+			$this->attributes[$key] = $attribute[$key];
132
+		}
133
+		return $this;
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getTemplate()
140
+	{
141
+		return $this->template;
142
+	}
143
+
144
+	/**
145
+	 * @param string $template
146
+	 * @return \Fab\Media\Form\AbstractFormField
147
+	 */
148
+	public function setTemplate($template)
149
+	{
150
+		$this->template = $template;
151
+	}
152
+
153
+	/**
154
+	 * @return string
155
+	 */
156
+	public function getLabel()
157
+	{
158
+		return $this->label;
159
+	}
160
+
161
+	/**
162
+	 * @param string $label
163
+	 * @return \Fab\Media\Form\AbstractFormField
164
+	 */
165
+	public function setLabel($label)
166
+	{
167
+		$this->label = $label;
168
+		return $this;
169
+	}
170
+
171
+	/**
172
+	 * @return string
173
+	 */
174
+	public function getPrefix()
175
+	{
176
+		return $this->prefix;
177
+	}
178
+
179
+	/**
180
+	 * @param string $prefix
181
+	 * @return \Fab\Media\Form\AbstractFormField
182
+	 */
183
+	public function setPrefix($prefix)
184
+	{
185
+		$this->prefix = $prefix;
186
+		return $this;
187
+	}
188
+
189
+	/**
190
+	 * @return array
191
+	 */
192
+	public function getItems()
193
+	{
194
+		return $this->items;
195
+	}
196
+
197
+	/**
198
+	 * @param array $items
199
+	 */
200
+	public function setItems($items)
201
+	{
202
+		$this->items = $items;
203
+	}
204
+
205
+	/**
206
+	 * @return string
207
+	 */
208
+	public function getValue()
209
+	{
210
+		return htmlspecialchars($this->value);
211
+	}
212
+
213
+	/**
214
+	 * @param string $value
215
+	 * @return \Fab\Media\Form\AbstractFormField
216
+	 */
217
+	public function setValue($value)
218
+	{
219
+		$this->value = $value;
220
+		return $this;
221
+	}
222
+
223
+	/**
224
+	 * @return string
225
+	 */
226
+	public function getName()
227
+	{
228
+		$result = $this->name;
229
+		if ($this->getPrefix()) {
230
+			$result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
+		}
232
+		return $result;
233
+	}
234
+
235
+	/**
236
+	 * @param string $name
237
+	 * @return \Fab\Media\Form\AbstractFormField
238
+	 */
239
+	public function setName($name)
240
+	{
241
+		$this->name = $name;
242
+		return $this;
243
+	}
244
+
245
+	/**
246
+	 * @return string
247
+	 */
248
+	public function getId()
249
+	{
250
+		if ($this->id === '') {
251
+			$this->id = DomElement::getInstance()->formatId($this->getName());
252
+		}
253
+		return $this->id;
254
+	}
255
+
256
+	/**
257
+	 * @param string $id
258
+	 * @return \Fab\Media\Form\AbstractFormField
259
+	 */
260
+	public function setId($id)
261
+	{
262
+		$this->id = $id;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return array
268
+	 */
269
+	public function getAttributes()
270
+	{
271
+		return $this->attributes;
272
+	}
273
+
274
+	/**
275
+	 * @param array $attributes
276
+	 * @return \Fab\Media\Form\AbstractFormField
277
+	 */
278
+	public function setAttributes($attributes)
279
+	{
280
+		$this->attributes = $attributes;
281
+		return $this;
282
+	}
283 283
 
284 284
 }
Please login to merge, or discard this patch.
Classes/View/Button/NewFolder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
                 ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
45 45
                 ->render();
46 46
 
47
-            $output = '<div style="float: left;">' . $button . '</div>';
47
+            $output = '<div style="float: left;">'.$button.'</div>';
48 48
         }
49 49
         return $output;
50 50
     }
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -21,101 +21,101 @@
 block discarded – undo
21 21
 class NewFolder extends AbstractComponentView
22 22
 {
23 23
 
24
-    /**
25
-     * Renders a button to create a new folder.
26
-     *
27
-     * @param Content $object
28
-     * @return string
29
-     */
30
-    public function render($object = null)
31
-    {
32
-        $output = '';
33
-        if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
34
-
35
-            $button = $this->makeLinkButton()
36
-                ->setHref($this->getNewFolderUri())
37
-                ->setTitle($this->getLabel())
38
-                ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
39
-                ->render();
40
-
41
-            $output = '<div style="float: left;">' . $button . '</div>';
42
-        }
43
-        return $output;
44
-    }
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    protected function getLabel()
50
-    {
51
-        return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new');
52
-    }
53
-
54
-    /**
55
-     * @return string
56
-     */
57
-    protected function getNewFolderUri()
58
-    {
59
-        return BackendUtility::getModuleUrl(
60
-            'file_newfolder',
61
-            array(
62
-                'target' => $this->getCombineIdentifier(),
63
-                'returnUrl' => $this->getReturnUrl(),
64
-            )
65
-        );
66
-    }
67
-
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    protected function getCombineIdentifier()
73
-    {
74
-        $folder = $this->getMediaModule()->getCurrentFolder();
75
-        return $folder->getCombinedIdentifier();
76
-    }
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    protected function getReturnUrl()
82
-    {
83
-        $returnUrl = BackendUtility::getModuleUrl(
84
-            GeneralUtility::_GP('route'),
85
-            $this->getAdditionalParameters()
86
-        );
87
-        return $returnUrl;
88
-    }
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    protected function getAdditionalParameters()
94
-    {
95
-
96
-        $additionalParameters = [];
97
-        if (GeneralUtility::_GP('id')) {
98
-            $additionalParameters = [
99
-                'id' => urldecode(GeneralUtility::_GP('id')),
100
-            ];
101
-        }
102
-        return $additionalParameters;
103
-    }
104
-
105
-    /**
106
-     * @return MediaModule|object
107
-     */
108
-    protected function getMediaModule()
109
-    {
110
-        return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
111
-    }
112
-
113
-    /**
114
-     * @return \TYPO3\CMS\Lang\LanguageService
115
-     */
116
-    protected function getLanguageService()
117
-    {
118
-        return $GLOBALS['LANG'];
119
-    }
24
+	/**
25
+	 * Renders a button to create a new folder.
26
+	 *
27
+	 * @param Content $object
28
+	 * @return string
29
+	 */
30
+	public function render($object = null)
31
+	{
32
+		$output = '';
33
+		if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
34
+
35
+			$button = $this->makeLinkButton()
36
+				->setHref($this->getNewFolderUri())
37
+				->setTitle($this->getLabel())
38
+				->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
39
+				->render();
40
+
41
+			$output = '<div style="float: left;">' . $button . '</div>';
42
+		}
43
+		return $output;
44
+	}
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	protected function getLabel()
50
+	{
51
+		return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new');
52
+	}
53
+
54
+	/**
55
+	 * @return string
56
+	 */
57
+	protected function getNewFolderUri()
58
+	{
59
+		return BackendUtility::getModuleUrl(
60
+			'file_newfolder',
61
+			array(
62
+				'target' => $this->getCombineIdentifier(),
63
+				'returnUrl' => $this->getReturnUrl(),
64
+			)
65
+		);
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	protected function getCombineIdentifier()
73
+	{
74
+		$folder = $this->getMediaModule()->getCurrentFolder();
75
+		return $folder->getCombinedIdentifier();
76
+	}
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	protected function getReturnUrl()
82
+	{
83
+		$returnUrl = BackendUtility::getModuleUrl(
84
+			GeneralUtility::_GP('route'),
85
+			$this->getAdditionalParameters()
86
+		);
87
+		return $returnUrl;
88
+	}
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	protected function getAdditionalParameters()
94
+	{
95
+
96
+		$additionalParameters = [];
97
+		if (GeneralUtility::_GP('id')) {
98
+			$additionalParameters = [
99
+				'id' => urldecode(GeneralUtility::_GP('id')),
100
+			];
101
+		}
102
+		return $additionalParameters;
103
+	}
104
+
105
+	/**
106
+	 * @return MediaModule|object
107
+	 */
108
+	protected function getMediaModule()
109
+	{
110
+		return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
111
+	}
112
+
113
+	/**
114
+	 * @return \TYPO3\CMS\Lang\LanguageService
115
+	 */
116
+	protected function getLanguageService()
117
+	{
118
+		return $GLOBALS['LANG'];
119
+	}
120 120
 
121 121
 }
Please login to merge, or discard this patch.
Classes/Command/ThumbnailCommandController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
                         $message = sprintf('* File "%s": %s %s',
65 65
                             $result['fileUid'],
66 66
                             $result['fileIdentifier'],
67
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
67
+                            empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri']
68 68
                         );
69 69
                         $this->outputLine($message);
70 70
                     }
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -21,137 +21,137 @@
 block discarded – undo
21 21
 class ThumbnailCommandController extends CommandController
22 22
 {
23 23
 
24
-    /**
25
-     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException
26
-     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
27
-     */
28
-    protected function initializeCommandMethodArguments()
29
-    {
30
-        parent::initializeCommandMethodArguments();
31
-        if ($this->arguments->hasArgument('configuration')) {
32
-            $propertyMappingConfiguration = $this->arguments->getArgument('configuration')->getPropertyMappingConfiguration();
33
-            $propertyMappingConfiguration->setTypeConverter(
34
-                $this->objectManager->get(ConfigurationArrayConverter::class)
35
-            );
36
-        }
37
-    }
38
-
39
-
40
-    /**
41
-     * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module.
42
-     *
43
-     * @param int $limit where to stop in the batch processing.
44
-     * @param int $offset where to start in the batch processing.
45
-     * @param array $configuration override the default thumbnail configuration.
46
-     * @param bool $verbose will output a detail result of the thumbnail generation.
47
-     * @return void
48
-     */
49
-    public function generateCommand($limit = 0, $offset = 0, $configuration = [], $verbose = false)
50
-    {
51
-
52
-        $this->checkEnvironment();
53
-
54
-        foreach ($this->getStorageRepository()->findAll() as $storage) {
55
-
56
-            // TODO: Make me more flexible by passing thumbnail configuration. For now it will only generate thumbnails for the BE module.
57
-
58
-            $this->outputLine();
59
-            $this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid()));
60
-            $this->outputLine('--------------------------------------------');
61
-            $this->outputLine();
62
-
63
-            if ($storage->isOnline()) {
64
-
65
-                // For the CLI cause.
66
-                $storage->setEvaluatePermissions(false);
67
-
68
-                $thumbnailGenerator = $this->getThumbnailGenerator();
69
-                $thumbnailGenerator
70
-                    ->setStorage($storage)
71
-                    ->setConfiguration($configuration)
72
-                    ->generate($limit, $offset);
73
-
74
-                if ($verbose) {
75
-                    $resultSet = $thumbnailGenerator->getResultSet();
76
-                    foreach ($resultSet as $result) {
77
-                        $message = sprintf('* File "%s": %s %s',
78
-                            $result['fileUid'],
79
-                            $result['fileIdentifier'],
80
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
81
-                        );
82
-                        $this->outputLine($message);
83
-                    }
84
-                    $this->outputLine();
85
-                }
86
-
87
-                $message = sprintf('Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.',
88
-                    $thumbnailGenerator->getNumberOfProcessedFiles(),
89
-                    $thumbnailGenerator->getNumberOfTraversedFiles(),
90
-                    $thumbnailGenerator->getTotalNumberOfFiles()
91
-                );
92
-                $this->outputLine($message);
93
-
94
-                // Add warning message if missing files were found along the way.
95
-                if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) {
96
-
97
-                    $message = sprintf('ATTENTION! %s missing file(s) detected.',
98
-                        $thumbnailGenerator->getNumberOfMissingFiles()
99
-                    );
100
-                    $this->outputLine($message);
101
-                }
102
-            } else {
103
-                $this->outputLine('Storage is offline!');
104
-            }
105
-        }
106
-    }
107
-
108
-    /**
109
-     * @return void
110
-     */
111
-    protected function checkEnvironment()
112
-    {
113
-        $user = $this->getDataService()->getRecord(
114
-            'be_users', [
115
-            'username' => '_cli_lowlevel'
116
-        ]);
117
-
118
-        if (empty($user)) {
119
-            $this->outputLine('Missing User "_cli_lowlevel" and / or its password.');
120
-            $this->sendAndExit(1);
121
-        }
122
-
123
-        $user = $this->getDataService()->getRecord(
124
-            'be_users', [
125
-            'username' => '_cli_scheduler'
126
-        ]);
127
-
128
-        if (empty($user)) {
129
-            $this->outputLine('Missing User "_cli_scheduler" and / or its password.');
130
-            $this->sendAndExit(1);
131
-        }
132
-    }
133
-
134
-    /**
135
-     * @return object|DataService
136
-     */
137
-    protected function getDataService(): DataService
138
-    {
139
-        return GeneralUtility::makeInstance(DataService::class);
140
-    }
141
-
142
-    /**
143
-     * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
144
-     */
145
-    protected function getThumbnailGenerator()
146
-    {
147
-        return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
148
-    }
149
-
150
-    /**
151
-     * @return StorageRepository|object
152
-     */
153
-    protected function getStorageRepository()
154
-    {
155
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
156
-    }
24
+	/**
25
+	 * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException
26
+	 * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
27
+	 */
28
+	protected function initializeCommandMethodArguments()
29
+	{
30
+		parent::initializeCommandMethodArguments();
31
+		if ($this->arguments->hasArgument('configuration')) {
32
+			$propertyMappingConfiguration = $this->arguments->getArgument('configuration')->getPropertyMappingConfiguration();
33
+			$propertyMappingConfiguration->setTypeConverter(
34
+				$this->objectManager->get(ConfigurationArrayConverter::class)
35
+			);
36
+		}
37
+	}
38
+
39
+
40
+	/**
41
+	 * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module.
42
+	 *
43
+	 * @param int $limit where to stop in the batch processing.
44
+	 * @param int $offset where to start in the batch processing.
45
+	 * @param array $configuration override the default thumbnail configuration.
46
+	 * @param bool $verbose will output a detail result of the thumbnail generation.
47
+	 * @return void
48
+	 */
49
+	public function generateCommand($limit = 0, $offset = 0, $configuration = [], $verbose = false)
50
+	{
51
+
52
+		$this->checkEnvironment();
53
+
54
+		foreach ($this->getStorageRepository()->findAll() as $storage) {
55
+
56
+			// TODO: Make me more flexible by passing thumbnail configuration. For now it will only generate thumbnails for the BE module.
57
+
58
+			$this->outputLine();
59
+			$this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid()));
60
+			$this->outputLine('--------------------------------------------');
61
+			$this->outputLine();
62
+
63
+			if ($storage->isOnline()) {
64
+
65
+				// For the CLI cause.
66
+				$storage->setEvaluatePermissions(false);
67
+
68
+				$thumbnailGenerator = $this->getThumbnailGenerator();
69
+				$thumbnailGenerator
70
+					->setStorage($storage)
71
+					->setConfiguration($configuration)
72
+					->generate($limit, $offset);
73
+
74
+				if ($verbose) {
75
+					$resultSet = $thumbnailGenerator->getResultSet();
76
+					foreach ($resultSet as $result) {
77
+						$message = sprintf('* File "%s": %s %s',
78
+							$result['fileUid'],
79
+							$result['fileIdentifier'],
80
+							empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
81
+						);
82
+						$this->outputLine($message);
83
+					}
84
+					$this->outputLine();
85
+				}
86
+
87
+				$message = sprintf('Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.',
88
+					$thumbnailGenerator->getNumberOfProcessedFiles(),
89
+					$thumbnailGenerator->getNumberOfTraversedFiles(),
90
+					$thumbnailGenerator->getTotalNumberOfFiles()
91
+				);
92
+				$this->outputLine($message);
93
+
94
+				// Add warning message if missing files were found along the way.
95
+				if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) {
96
+
97
+					$message = sprintf('ATTENTION! %s missing file(s) detected.',
98
+						$thumbnailGenerator->getNumberOfMissingFiles()
99
+					);
100
+					$this->outputLine($message);
101
+				}
102
+			} else {
103
+				$this->outputLine('Storage is offline!');
104
+			}
105
+		}
106
+	}
107
+
108
+	/**
109
+	 * @return void
110
+	 */
111
+	protected function checkEnvironment()
112
+	{
113
+		$user = $this->getDataService()->getRecord(
114
+			'be_users', [
115
+			'username' => '_cli_lowlevel'
116
+		]);
117
+
118
+		if (empty($user)) {
119
+			$this->outputLine('Missing User "_cli_lowlevel" and / or its password.');
120
+			$this->sendAndExit(1);
121
+		}
122
+
123
+		$user = $this->getDataService()->getRecord(
124
+			'be_users', [
125
+			'username' => '_cli_scheduler'
126
+		]);
127
+
128
+		if (empty($user)) {
129
+			$this->outputLine('Missing User "_cli_scheduler" and / or its password.');
130
+			$this->sendAndExit(1);
131
+		}
132
+	}
133
+
134
+	/**
135
+	 * @return object|DataService
136
+	 */
137
+	protected function getDataService(): DataService
138
+	{
139
+		return GeneralUtility::makeInstance(DataService::class);
140
+	}
141
+
142
+	/**
143
+	 * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
144
+	 */
145
+	protected function getThumbnailGenerator()
146
+	{
147
+		return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
148
+	}
149
+
150
+	/**
151
+	 * @return StorageRepository|object
152
+	 */
153
+	protected function getStorageRepository()
154
+	{
155
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Tests/Functional/Utility/ConfigurationUtilityTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 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\Utility\Configuration.
Please login to merge, or discard this patch.
Tests/Functional/Utility/ImagePresetUtilityTest.php 1 patch
Spacing   +2 added lines, -2 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
 /**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$preset = 'image_large';
129 129
 		$actualWidth = rand(10, 100);
130 130
 		$actualHeight = rand(10, 100);
131
-		\Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth . 'x' . $actualHeight);
131
+		\Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth.'x'.$actualHeight);
132 132
 		$this->assertSame($actualWidth, $this->fixture->preset($preset)->getWidth());
133 133
 		$this->assertSame($actualHeight, $this->fixture->preset($preset)->getHeight());
134 134
 	}
Please login to merge, or discard this patch.
Tests/Unit/FileUpload/UploadManagerTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function setUp() {
38 38
 		$this->fixture = new \Fab\Media\FileUpload\UploadManager();
39 39
 		$this->fakeName = uniqid('name');
40
-		$this->fakePrefix= uniqid('prefix');
40
+		$this->fakePrefix = uniqid('prefix');
41 41
 	}
42 42
 
43 43
 	public function tearDown() {
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * @dataProvider propertyProvider
50 50
 	 */
51 51
 	public function testProperty($propertyName, $value) {
52
-		$setter = 'set' . ucfirst($propertyName);
53
-		$getter = 'get' . ucfirst($propertyName);
52
+		$setter = 'set'.ucfirst($propertyName);
53
+		$getter = 'get'.ucfirst($propertyName);
54 54
 		call_user_func_array(array($this->fixture, $setter), array($value));
55 55
 		$this->assertEquals($value, call_user_func(array($this->fixture, $getter)));
56 56
 	}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		return array(
63 63
 			array('uploadFolder', uniqid()),
64 64
 			array('inputName', uniqid()),
65
-			array('sizeLimit', rand(10,100)),
65
+			array('sizeLimit', rand(10, 100)),
66 66
 		);
67 67
 	}
68 68
 
Please login to merge, or discard this patch.
Classes/Override/Backend/Form/FormResultCompiler.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 block discarded – undo
40 40
 
41 41
             $pageRenderer = $this->getPageRenderer();
42 42
             $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) {
43
-            MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\';
44
-            MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\';
45
-            MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . ';
43
+            MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()).'\';
44
+            MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix().'\';
45
+            MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')).';
46 46
         }');
47 47
         }
48 48
 
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,38 +18,38 @@
 block discarded – undo
18 18
 class FormResultCompiler extends \TYPO3\CMS\Backend\Form\FormResultCompiler
19 19
 {
20 20
 
21
-    /**
22
-     * JavaScript bottom code
23
-     *
24
-     * @param string $formname The identification of the form on the page.
25
-     * @return string A section with JavaScript - if $update is false, embedded in <script></script>
26
-     */
27
-    protected function JSbottom($formname = 'forms[0]')
28
-    {
29
-
30
-        $out = parent::JSbottom($formname);
31
-
32
-        $enableMediaFilePicker = (bool)$this->getBackendUser()->getTSConfigVal('options.vidi.enableMediaFilePicker');
33
-        if ($enableMediaFilePicker) {
34
-
35
-            $pageRenderer = $this->getPageRenderer();
36
-            $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) {
21
+	/**
22
+	 * JavaScript bottom code
23
+	 *
24
+	 * @param string $formname The identification of the form on the page.
25
+	 * @return string A section with JavaScript - if $update is false, embedded in <script></script>
26
+	 */
27
+	protected function JSbottom($formname = 'forms[0]')
28
+	{
29
+
30
+		$out = parent::JSbottom($formname);
31
+
32
+		$enableMediaFilePicker = (bool)$this->getBackendUser()->getTSConfigVal('options.vidi.enableMediaFilePicker');
33
+		if ($enableMediaFilePicker) {
34
+
35
+			$pageRenderer = $this->getPageRenderer();
36
+			$pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) {
37 37
             MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\';
38 38
             MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\';
39 39
             MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . ';
40 40
         }');
41
-        }
42
-
43
-        return $out;
44
-    }
45
-
46
-    /**
47
-     * Returns an instance of the current Backend User.
48
-     *
49
-     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
50
-     */
51
-    protected function getBackendUser()
52
-    {
53
-        return $GLOBALS['BE_USER'];
54
-    }
41
+		}
42
+
43
+		return $out;
44
+	}
45
+
46
+	/**
47
+	 * Returns an instance of the current Backend User.
48
+	 *
49
+	 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
50
+	 */
51
+	protected function getBackendUser()
52
+	{
53
+		return $GLOBALS['BE_USER'];
54
+	}
55 55
 }
Please login to merge, or discard this patch.