Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
Classes/Dimension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
  */
17 17
 class Dimension
18 18
 {
19
-    /**
20
-     * @var int
21
-     */
22
-    protected $width = 0;
23
-
24
-    /**
25
-     * @var int
26
-     */
27
-    protected $height = 0;
28
-
29
-    /**
30
-     * @param string $dimension
31
-     */
32
-    public function __construct($dimension)
33
-    {
34
-        $dimensions = GeneralUtility::trimExplode('x', $dimension);
35
-        $this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
-        $this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
-    }
38
-
39
-    /**
40
-     * @return mixed
41
-     */
42
-    public function getWidth()
43
-    {
44
-        return $this->width;
45
-    }
46
-
47
-    /**
48
-     * @return int
49
-     */
50
-    public function getHeight()
51
-    {
52
-        return $this->height;
53
-    }
19
+	/**
20
+	 * @var int
21
+	 */
22
+	protected $width = 0;
23
+
24
+	/**
25
+	 * @var int
26
+	 */
27
+	protected $height = 0;
28
+
29
+	/**
30
+	 * @param string $dimension
31
+	 */
32
+	public function __construct($dimension)
33
+	{
34
+		$dimensions = GeneralUtility::trimExplode('x', $dimension);
35
+		$this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
+		$this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
+	}
38
+
39
+	/**
40
+	 * @return mixed
41
+	 */
42
+	public function getWidth()
43
+	{
44
+		return $this->width;
45
+	}
46
+
47
+	/**
48
+	 * @return int
49
+	 */
50
+	public function getHeight()
51
+	{
52
+		return $this->height;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Classes/FileUpload/FormUtility.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -16,53 +16,53 @@
 block discarded – undo
16 16
  */
17 17
 class FormUtility implements SingletonInterface
18 18
 {
19
-    /**
20
-     * Returns a class instance.
21
-     *
22
-     * @return \Fab\Media\FileUpload\FormUtility|object
23
-     */
24
-    public static function getInstance()
25
-    {
26
-        return GeneralUtility::makeInstance(\Fab\Media\FileUpload\FormUtility::class);
27
-    }
19
+	/**
20
+	 * Returns a class instance.
21
+	 *
22
+	 * @return \Fab\Media\FileUpload\FormUtility|object
23
+	 */
24
+	public static function getInstance()
25
+	{
26
+		return GeneralUtility::makeInstance(\Fab\Media\FileUpload\FormUtility::class);
27
+	}
28 28
 
29
-    /**
30
-     * Tells whether the content type is valid.
31
-     *
32
-     * @return bool
33
-     */
34
-    public function hasValidContentType()
35
-    {
36
-        return isset($GLOBALS['_SERVER']['CONTENT_TYPE']);
37
-    }
29
+	/**
30
+	 * Tells whether the content type is valid.
31
+	 *
32
+	 * @return bool
33
+	 */
34
+	public function hasValidContentType()
35
+	{
36
+		return isset($GLOBALS['_SERVER']['CONTENT_TYPE']);
37
+	}
38 38
 
39
-    /**
40
-     * Tells whether the form is multiparted, e.g "multipart/form-data"
41
-     *
42
-     * @return bool
43
-     */
44
-    public function isMultiparted()
45
-    {
46
-        return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'multipart/form-data') === 0;
47
-    }
39
+	/**
40
+	 * Tells whether the form is multiparted, e.g "multipart/form-data"
41
+	 *
42
+	 * @return bool
43
+	 */
44
+	public function isMultiparted()
45
+	{
46
+		return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'multipart/form-data') === 0;
47
+	}
48 48
 
49
-    /**
50
-     * Tells whether the form is URL encoded, e.g "application/x-www-form-urlencoded; charset=UTF-8"
51
-     *
52
-     * @return bool
53
-     */
54
-    public function isUrlEncoded()
55
-    {
56
-        return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/x-www-form-urlencoded') === 0;
57
-    }
49
+	/**
50
+	 * Tells whether the form is URL encoded, e.g "application/x-www-form-urlencoded; charset=UTF-8"
51
+	 *
52
+	 * @return bool
53
+	 */
54
+	public function isUrlEncoded()
55
+	{
56
+		return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/x-www-form-urlencoded') === 0;
57
+	}
58 58
 
59
-    /**
60
-     * Tells whether the form is octet streamed, e.g "application/x-www-form-urlencoded; charset=UTF-8"
61
-     *
62
-     * @return bool
63
-     */
64
-    public function isOctetStreamed()
65
-    {
66
-        return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/octet-stream') === 0;
67
-    }
59
+	/**
60
+	 * Tells whether the form is octet streamed, e.g "application/x-www-form-urlencoded; charset=UTF-8"
61
+	 *
62
+	 * @return bool
63
+	 */
64
+	public function isOctetStreamed()
65
+	{
66
+		return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/octet-stream') === 0;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Classes/FileUpload/ImageOptimizerInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 block discarded – undo
14 14
  */
15 15
 interface ImageOptimizerInterface
16 16
 {
17
-    /**
18
-     * Optimize the given uploaded image
19
-     *
20
-     * @param UploadedFileInterface $uploadedFile
21
-     * @return UploadedFileInterface
22
-     */
23
-    public function optimize($uploadedFile);
17
+	/**
18
+	 * Optimize the given uploaded image
19
+	 *
20
+	 * @param UploadedFileInterface $uploadedFile
21
+	 * @return UploadedFileInterface
22
+	 */
23
+	public function optimize($uploadedFile);
24 24
 }
Please login to merge, or discard this patch.
Classes/FileUpload/StreamedFile.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -18,93 +18,93 @@
 block discarded – undo
18 18
  */
19 19
 class StreamedFile extends UploadedFileAbstract
20 20
 {
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $inputName = 'qqfile';
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $inputName = 'qqfile';
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $uploadFolder;
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $uploadFolder;
30 30
 
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name;
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name;
35 35
 
36
-    /**
37
-     * Save the file to the specified path
38
-     *
39
-     * @throws EmptyPropertyException
40
-     * @return boolean true on success
41
-     */
42
-    public function save()
43
-    {
44
-        if (is_null($this->uploadFolder)) {
45
-            throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
46
-        }
36
+	/**
37
+	 * Save the file to the specified path
38
+	 *
39
+	 * @throws EmptyPropertyException
40
+	 * @return boolean true on success
41
+	 */
42
+	public function save()
43
+	{
44
+		if (is_null($this->uploadFolder)) {
45
+			throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
46
+		}
47 47
 
48
-        if (is_null($this->name)) {
49
-            throw new EmptyPropertyException('File name is not defined', 1361787580);
50
-        }
48
+		if (is_null($this->name)) {
49
+			throw new EmptyPropertyException('File name is not defined', 1361787580);
50
+		}
51 51
 
52
-        $input = fopen("php://input", "r");
53
-        $temp = tmpfile();
54
-        $realSize = stream_copy_to_stream($input, $temp);
55
-        fclose($input);
52
+		$input = fopen("php://input", "r");
53
+		$temp = tmpfile();
54
+		$realSize = stream_copy_to_stream($input, $temp);
55
+		fclose($input);
56 56
 
57
-        if ($realSize != $this->getSize()) {
58
-            return false;
59
-        }
57
+		if ($realSize != $this->getSize()) {
58
+			return false;
59
+		}
60 60
 
61
-        $target = fopen($this->getFileWithAbsolutePath(), "w");
62
-        fseek($temp, 0, SEEK_SET);
63
-        stream_copy_to_stream($temp, $target);
64
-        fclose($target);
61
+		$target = fopen($this->getFileWithAbsolutePath(), "w");
62
+		fseek($temp, 0, SEEK_SET);
63
+		stream_copy_to_stream($temp, $target);
64
+		fclose($target);
65 65
 
66
-        return true;
67
-    }
66
+		return true;
67
+	}
68 68
 
69
-    /**
70
-     * Get the original file name.
71
-     *
72
-     * @return string
73
-     */
74
-    public function getOriginalName()
75
-    {
76
-        return $_GET[$this->inputName];
77
-    }
69
+	/**
70
+	 * Get the original file name.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	public function getOriginalName()
75
+	{
76
+		return $_GET[$this->inputName];
77
+	}
78 78
 
79
-    /**
80
-     * Get the file size
81
-     *
82
-     * @throws \Exception
83
-     * @return integer file-size in byte
84
-     */
85
-    public function getSize()
86
-    {
87
-        if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
88
-            return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
89
-        } else {
90
-            throw new \Exception('Getting content length is not supported.');
91
-        }
92
-    }
79
+	/**
80
+	 * Get the file size
81
+	 *
82
+	 * @throws \Exception
83
+	 * @return integer file-size in byte
84
+	 */
85
+	public function getSize()
86
+	{
87
+		if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
88
+			return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
89
+		} else {
90
+			throw new \Exception('Getting content length is not supported.');
91
+		}
92
+	}
93 93
 
94
-    /**
95
-     * Get MIME type of file.
96
-     *
97
-     * @return string|boolean MIME type. eg, text/html, false on error
98
-     */
99
-    public function getMimeType()
100
-    {
101
-        $this->checkFileExistence();
102
-        if (function_exists('finfo_file')) {
103
-            $fileInfo = new \finfo();
104
-            return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
105
-        } elseif (function_exists('mime_content_type')) {
106
-            return mime_content_type($this->getFileWithAbsolutePath());
107
-        }
108
-        return false;
109
-    }
94
+	/**
95
+	 * Get MIME type of file.
96
+	 *
97
+	 * @return string|boolean MIME type. eg, text/html, false on error
98
+	 */
99
+	public function getMimeType()
100
+	{
101
+		$this->checkFileExistence();
102
+		if (function_exists('finfo_file')) {
103
+			$fileInfo = new \finfo();
104
+			return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
105
+		} elseif (function_exists('mime_content_type')) {
106
+			return mime_content_type($this->getFileWithAbsolutePath());
107
+		}
108
+		return false;
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Classes/FileUpload/ImageOptimizer.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -17,81 +17,81 @@
 block discarded – undo
17 17
  */
18 18
 class ImageOptimizer implements SingletonInterface
19 19
 {
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $optimizers = [];
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $optimizers = [];
24 24
 
25
-    /**
26
-     * @var ResourceStorage
27
-     */
28
-    protected $storage;
25
+	/**
26
+	 * @var ResourceStorage
27
+	 */
28
+	protected $storage;
29 29
 
30
-    /**
31
-     * Returns a class instance.
32
-     *
33
-     * @return ImageOptimizer
34
-     * @throws \InvalidArgumentException
35
-     * @param ResourceStorage $storage
36
-     */
37
-    public static function getInstance($storage = null)
38
-    {
39
-        return GeneralUtility::makeInstance(self::class, $storage);
40
-    }
30
+	/**
31
+	 * Returns a class instance.
32
+	 *
33
+	 * @return ImageOptimizer
34
+	 * @throws \InvalidArgumentException
35
+	 * @param ResourceStorage $storage
36
+	 */
37
+	public static function getInstance($storage = null)
38
+	{
39
+		return GeneralUtility::makeInstance(self::class, $storage);
40
+	}
41 41
 
42
-    /**
43
-     * Constructor
44
-     *
45
-     * @return ImageOptimizer
46
-     * @param ResourceStorage $storage
47
-     */
48
-    public function __construct($storage = null)
49
-    {
50
-        $this->storage = $storage;
51
-        $this->add('Fab\Media\FileUpload\Optimizer\Resize');
52
-        $this->add('Fab\Media\FileUpload\Optimizer\Rotate');
53
-    }
42
+	/**
43
+	 * Constructor
44
+	 *
45
+	 * @return ImageOptimizer
46
+	 * @param ResourceStorage $storage
47
+	 */
48
+	public function __construct($storage = null)
49
+	{
50
+		$this->storage = $storage;
51
+		$this->add('Fab\Media\FileUpload\Optimizer\Resize');
52
+		$this->add('Fab\Media\FileUpload\Optimizer\Rotate');
53
+	}
54 54
 
55
-    /**
56
-     * Register a new optimizer
57
-     *
58
-     * @param string $className
59
-     * @return void
60
-     */
61
-    public function add($className)
62
-    {
63
-        $this->optimizers[] = $className;
64
-    }
55
+	/**
56
+	 * Register a new optimizer
57
+	 *
58
+	 * @param string $className
59
+	 * @return void
60
+	 */
61
+	public function add($className)
62
+	{
63
+		$this->optimizers[] = $className;
64
+	}
65 65
 
66
-    /**
67
-     * Un-register a new optimizer
68
-     *
69
-     * @param string $className
70
-     * @return void
71
-     */
72
-    public function remove($className)
73
-    {
74
-        if (in_array($className, $this->optimizers)) {
75
-            $key = array_search($className, $this->optimizers);
76
-            unset($this->optimizers[$key]);
77
-        }
78
-    }
66
+	/**
67
+	 * Un-register a new optimizer
68
+	 *
69
+	 * @param string $className
70
+	 * @return void
71
+	 */
72
+	public function remove($className)
73
+	{
74
+		if (in_array($className, $this->optimizers)) {
75
+			$key = array_search($className, $this->optimizers);
76
+			unset($this->optimizers[$key]);
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * Optimize an image
82
-     *
83
-     * @param UploadedFileInterface $uploadedFile
84
-     * @return UploadedFileInterface
85
-     * @throws \InvalidArgumentException
86
-     */
87
-    public function optimize(UploadedFileInterface $uploadedFile)
88
-    {
89
-        foreach ($this->optimizers as $optimizer) {
90
-            /** @var $optimizer \Fab\Media\FileUpload\ImageOptimizerInterface */
91
-            $optimizer = GeneralUtility::makeInstance($optimizer, $this->storage);
92
-            $uploadedFile = $optimizer->optimize($uploadedFile);
93
-        }
80
+	/**
81
+	 * Optimize an image
82
+	 *
83
+	 * @param UploadedFileInterface $uploadedFile
84
+	 * @return UploadedFileInterface
85
+	 * @throws \InvalidArgumentException
86
+	 */
87
+	public function optimize(UploadedFileInterface $uploadedFile)
88
+	{
89
+		foreach ($this->optimizers as $optimizer) {
90
+			/** @var $optimizer \Fab\Media\FileUpload\ImageOptimizerInterface */
91
+			$optimizer = GeneralUtility::makeInstance($optimizer, $this->storage);
92
+			$uploadedFile = $optimizer->optimize($uploadedFile);
93
+		}
94 94
 
95
-        return $uploadedFile;
96
-    }
95
+		return $uploadedFile;
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Classes/FileUpload/Optimizer/Resize.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -22,110 +22,110 @@
 block discarded – undo
22 22
  */
23 23
 class Resize implements ImageOptimizerInterface
24 24
 {
25
-    /**
26
-     * @var GifBuilder
27
-     */
28
-    protected $gifCreator;
25
+	/**
26
+	 * @var GifBuilder
27
+	 */
28
+	protected $gifCreator;
29 29
 
30
-    /**
31
-     * @var ResourceStorage
32
-     */
33
-    protected $storage;
30
+	/**
31
+	 * @var ResourceStorage
32
+	 */
33
+	protected $storage;
34 34
 
35
-    /**
36
-     * Constructor
37
-     */
38
-    public function __construct($storage = null)
39
-    {
40
-        $this->storage = $storage;
41
-        $this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
42
-        $this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
43
-    }
35
+	/**
36
+	 * Constructor
37
+	 */
38
+	public function __construct($storage = null)
39
+	{
40
+		$this->storage = $storage;
41
+		$this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
42
+		$this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
43
+	}
44 44
 
45
-    /**
46
-     * Optimize the given uploaded image.
47
-     *
48
-     * @param UploadedFileInterface $uploadedFile
49
-     * @return UploadedFileInterface
50
-     */
51
-    public function optimize($uploadedFile)
52
-    {
53
-        $imageInfo = getimagesize($uploadedFile->getFileWithAbsolutePath());
45
+	/**
46
+	 * Optimize the given uploaded image.
47
+	 *
48
+	 * @param UploadedFileInterface $uploadedFile
49
+	 * @return UploadedFileInterface
50
+	 */
51
+	public function optimize($uploadedFile)
52
+	{
53
+		$imageInfo = getimagesize($uploadedFile->getFileWithAbsolutePath());
54 54
 
55
-        $currentWidth = $imageInfo[0];
56
-        $currentHeight = $imageInfo[1];
55
+		$currentWidth = $imageInfo[0];
56
+		$currentHeight = $imageInfo[1];
57 57
 
58
-        // resize an image if this one is bigger than telling by the settings.
59
-        if (is_object($this->storage)) {
60
-            $storageRecord = $this->storage->getStorageRecord();
61
-        } else {
62
-            // Will only work in the BE for now.
63
-            $storage = $this->getMediaModule()->getCurrentStorage();
64
-            $storageRecord = $storage->getStorageRecord();
65
-        }
58
+		// resize an image if this one is bigger than telling by the settings.
59
+		if (is_object($this->storage)) {
60
+			$storageRecord = $this->storage->getStorageRecord();
61
+		} else {
62
+			// Will only work in the BE for now.
63
+			$storage = $this->getMediaModule()->getCurrentStorage();
64
+			$storageRecord = $storage->getStorageRecord();
65
+		}
66 66
 
67
-        if (strlen($storageRecord['maximum_dimension_original_image']) > 0) {
68
-            /** @var Dimension $imageDimension */
69
-            $imageDimension = GeneralUtility::makeInstance(Dimension::class, $storageRecord['maximum_dimension_original_image']);
70
-            if ($currentWidth > $imageDimension->getWidth() || $currentHeight > $imageDimension->getHeight()) {
71
-                // resize taking the width as reference
72
-                $this->resize($uploadedFile->getFileWithAbsolutePath(), $imageDimension->getWidth(), $imageDimension->getHeight());
73
-            }
74
-        }
75
-        return $uploadedFile;
76
-    }
67
+		if (strlen($storageRecord['maximum_dimension_original_image']) > 0) {
68
+			/** @var Dimension $imageDimension */
69
+			$imageDimension = GeneralUtility::makeInstance(Dimension::class, $storageRecord['maximum_dimension_original_image']);
70
+			if ($currentWidth > $imageDimension->getWidth() || $currentHeight > $imageDimension->getHeight()) {
71
+				// resize taking the width as reference
72
+				$this->resize($uploadedFile->getFileWithAbsolutePath(), $imageDimension->getWidth(), $imageDimension->getHeight());
73
+			}
74
+		}
75
+		return $uploadedFile;
76
+	}
77 77
 
78
-    /**
79
-     * Resize an image according to given parameter.
80
-     *
81
-     * @throws \Exception
82
-     * @param string $fileNameAndPath
83
-     * @param int $width
84
-     * @param int $height
85
-     * @return void
86
-     */
87
-    public function resize($fileNameAndPath, $width = 0, $height = 0)
88
-    {
89
-        // Skip profile of the image
90
-        $imParams = '###SkipStripProfile###';
91
-        $options = array(
92
-            'maxW' => $width,
93
-            'maxH' => $height,
94
-        );
78
+	/**
79
+	 * Resize an image according to given parameter.
80
+	 *
81
+	 * @throws \Exception
82
+	 * @param string $fileNameAndPath
83
+	 * @param int $width
84
+	 * @param int $height
85
+	 * @return void
86
+	 */
87
+	public function resize($fileNameAndPath, $width = 0, $height = 0)
88
+	{
89
+		// Skip profile of the image
90
+		$imParams = '###SkipStripProfile###';
91
+		$options = array(
92
+			'maxW' => $width,
93
+			'maxH' => $height,
94
+		);
95 95
 
96
-        $tempFileInfo = $this->gifCreator->imageMagickConvert($fileNameAndPath, '', '', '', $imParams, '', $options, true);
97
-        if ($tempFileInfo) {
98
-            // Overwrite original file
99
-            @unlink($fileNameAndPath);
100
-            @rename($tempFileInfo[3], $fileNameAndPath);
101
-        }
102
-    }
96
+		$tempFileInfo = $this->gifCreator->imageMagickConvert($fileNameAndPath, '', '', '', $imParams, '', $options, true);
97
+		if ($tempFileInfo) {
98
+			// Overwrite original file
99
+			@unlink($fileNameAndPath);
100
+			@rename($tempFileInfo[3], $fileNameAndPath);
101
+		}
102
+	}
103 103
 
104
-    /**
105
-     * Escapes a file name so it can safely be used on the command line.
106
-     *
107
-     * @see \TYPO3\CMS\Core\Imaging\GraphicalFunctions
108
-     * @param string $inputName filename to safeguard, must not be empty
109
-     * @return string $inputName escaped as needed
110
-     */
111
-    protected function wrapFileName($inputName)
112
-    {
113
-        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
114
-            $currentLocale = setlocale(LC_CTYPE, 0);
115
-            setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
116
-        }
117
-        $escapedInputName = escapeshellarg($inputName);
118
-        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
119
-            setlocale(LC_CTYPE, $currentLocale);
120
-        }
121
-        return $escapedInputName;
122
-    }
104
+	/**
105
+	 * Escapes a file name so it can safely be used on the command line.
106
+	 *
107
+	 * @see \TYPO3\CMS\Core\Imaging\GraphicalFunctions
108
+	 * @param string $inputName filename to safeguard, must not be empty
109
+	 * @return string $inputName escaped as needed
110
+	 */
111
+	protected function wrapFileName($inputName)
112
+	{
113
+		if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
114
+			$currentLocale = setlocale(LC_CTYPE, 0);
115
+			setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
116
+		}
117
+		$escapedInputName = escapeshellarg($inputName);
118
+		if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
119
+			setlocale(LC_CTYPE, $currentLocale);
120
+		}
121
+		return $escapedInputName;
122
+	}
123 123
 
124
-    /**
125
-     * @return MediaModule|object
126
-     */
127
-    protected function getMediaModule()
128
-    {
129
-        return GeneralUtility::makeInstance(MediaModule::class);
130
-    }
124
+	/**
125
+	 * @return MediaModule|object
126
+	 */
127
+	protected function getMediaModule()
128
+	{
129
+		return GeneralUtility::makeInstance(MediaModule::class);
130
+	}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     {
40 40
         $this->storage = $storage;
41 41
         $this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
42
-        $this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
42
+        $this->gifCreator->absPrefix = Environment::getPublicPath().'/';
43 43
     }
44 44
 
45 45
     /**
Please login to merge, or discard this patch.
Classes/FileUpload/Optimizer/Rotate.php 2 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -19,152 +19,152 @@
 block discarded – undo
19 19
  */
20 20
 class Rotate implements ImageOptimizerInterface
21 21
 {
22
-    /**
23
-     * @var GifBuilder
24
-     */
25
-    protected $gifCreator;
22
+	/**
23
+	 * @var GifBuilder
24
+	 */
25
+	protected $gifCreator;
26 26
 
27
-    /**
28
-     * Constructor
29
-     */
30
-    public function __construct()
31
-    {
32
-        $this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
33
-        $this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
34
-    }
27
+	/**
28
+	 * Constructor
29
+	 */
30
+	public function __construct()
31
+	{
32
+		$this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
33
+		$this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
34
+	}
35 35
 
36
-    /**
37
-     * Optimize the given uploaded image
38
-     *
39
-     * @param UploadedFileInterface $uploadedFile
40
-     * @return UploadedFileInterface
41
-     */
42
-    public function optimize($uploadedFile)
43
-    {
44
-        $orientation = $this->getOrientation($uploadedFile->getFileWithAbsolutePath());
45
-        $isRotated = $this->isRotated($orientation);
36
+	/**
37
+	 * Optimize the given uploaded image
38
+	 *
39
+	 * @param UploadedFileInterface $uploadedFile
40
+	 * @return UploadedFileInterface
41
+	 */
42
+	public function optimize($uploadedFile)
43
+	{
44
+		$orientation = $this->getOrientation($uploadedFile->getFileWithAbsolutePath());
45
+		$isRotated = $this->isRotated($orientation);
46 46
 
47
-        // Only rotate image if necessary!
48
-        if ($isRotated > 0) {
49
-            $transformation = $this->getTransformation($orientation);
47
+		// Only rotate image if necessary!
48
+		if ($isRotated > 0) {
49
+			$transformation = $this->getTransformation($orientation);
50 50
 
51
-            $imParams = '###SkipStripProfile###';
52
-            if ($transformation !== '') {
53
-                $imParams .= ' ' . $transformation;
54
-            }
51
+			$imParams = '###SkipStripProfile###';
52
+			if ($transformation !== '') {
53
+				$imParams .= ' ' . $transformation;
54
+			}
55 55
 
56
-            $tempFileInfo = $this->gifCreator->imageMagickConvert($uploadedFile->getFileWithAbsolutePath(), '', '', '', $imParams, '', [], true);
57
-            if ($tempFileInfo) {
58
-                // Replace original file
59
-                @unlink($uploadedFile->getFileWithAbsolutePath());
60
-                @rename($tempFileInfo[3], $uploadedFile->getFileWithAbsolutePath());
56
+			$tempFileInfo = $this->gifCreator->imageMagickConvert($uploadedFile->getFileWithAbsolutePath(), '', '', '', $imParams, '', [], true);
57
+			if ($tempFileInfo) {
58
+				// Replace original file
59
+				@unlink($uploadedFile->getFileWithAbsolutePath());
60
+				@rename($tempFileInfo[3], $uploadedFile->getFileWithAbsolutePath());
61 61
 
62
-                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
63
-                    $this->resetOrientation($uploadedFile->getFileWithAbsolutePath());
64
-                }
65
-            }
66
-        }
67
-        return $uploadedFile;
68
-    }
62
+				if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
63
+					$this->resetOrientation($uploadedFile->getFileWithAbsolutePath());
64
+				}
65
+			}
66
+		}
67
+		return $uploadedFile;
68
+	}
69 69
 
70
-    /**
71
-     * Returns the EXIF orientation of a given picture.
72
-     *
73
-     * @param string $filename
74
-     * @return integer
75
-     */
76
-    protected function getOrientation($filename)
77
-    {
78
-        $extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
79
-        $orientation = 1; // Fallback to "straight"
80
-        if (GeneralUtility::inList('jpg,jpeg,tif,tiff', $extension) && function_exists('exif_read_data')) {
81
-            try {
82
-                $exif = exif_read_data($filename);
83
-                if ($exif) {
84
-                    $orientation = $exif['Orientation'];
85
-                }
86
-            } catch (\Exception $e) {
87
-            }
88
-        }
89
-        return $orientation;
90
-    }
70
+	/**
71
+	 * Returns the EXIF orientation of a given picture.
72
+	 *
73
+	 * @param string $filename
74
+	 * @return integer
75
+	 */
76
+	protected function getOrientation($filename)
77
+	{
78
+		$extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
79
+		$orientation = 1; // Fallback to "straight"
80
+		if (GeneralUtility::inList('jpg,jpeg,tif,tiff', $extension) && function_exists('exif_read_data')) {
81
+			try {
82
+				$exif = exif_read_data($filename);
83
+				if ($exif) {
84
+					$orientation = $exif['Orientation'];
85
+				}
86
+			} catch (\Exception $e) {
87
+			}
88
+		}
89
+		return $orientation;
90
+	}
91 91
 
92
-    /**
93
-     * Returns true if the given picture is rotated.
94
-     *
95
-     * @param integer $orientation EXIF orientation
96
-     * @return integer
97
-     * @see http://www.impulseadventure.com/photo/exif-orientation.html
98
-     */
99
-    protected function isRotated($orientation)
100
-    {
101
-        $ret = false;
102
-        switch ($orientation) {
103
-            case 2: // horizontal flip
104
-            case 3: // 180°
105
-            case 4: // vertical flip
106
-            case 5: // vertical flip + 90 rotate right
107
-            case 6: // 90° rotate right
108
-            case 7: // horizontal flip + 90 rotate right
109
-            case 8: // 90° rotate left
110
-                $ret = true;
111
-                break;
112
-        }
113
-        return $ret;
114
-    }
92
+	/**
93
+	 * Returns true if the given picture is rotated.
94
+	 *
95
+	 * @param integer $orientation EXIF orientation
96
+	 * @return integer
97
+	 * @see http://www.impulseadventure.com/photo/exif-orientation.html
98
+	 */
99
+	protected function isRotated($orientation)
100
+	{
101
+		$ret = false;
102
+		switch ($orientation) {
103
+			case 2: // horizontal flip
104
+			case 3: // 180°
105
+			case 4: // vertical flip
106
+			case 5: // vertical flip + 90 rotate right
107
+			case 6: // 90° rotate right
108
+			case 7: // horizontal flip + 90 rotate right
109
+			case 8: // 90° rotate left
110
+				$ret = true;
111
+				break;
112
+		}
113
+		return $ret;
114
+	}
115 115
 
116
-    /**
117
-     * Returns a command line parameter to fix the orientation of a rotated picture.
118
-     *
119
-     * @param integer $orientation
120
-     * @return string
121
-     */
122
-    protected function getTransformation($orientation)
123
-    {
124
-        $transformation = '';
125
-        if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] !== 'gm') {
126
-            // ImageMagick
127
-            if ($orientation >= 2 && $orientation <= 8) {
128
-                $transformation = '-auto-orient';
129
-            }
130
-        } else {
131
-            // GraphicsMagick
132
-            switch ($orientation) {
133
-                case 2: // horizontal flip
134
-                    $transformation = '-flip horizontal';
135
-                    break;
136
-                case 3: // 180°
137
-                    $transformation = '-rotate 180';
138
-                    break;
139
-                case 4: // vertical flip
140
-                    $transformation = '-flip vertical';
141
-                    break;
142
-                case 5: // vertical flip + 90 rotate right
143
-                    $transformation = '-transpose';
144
-                    break;
145
-                case 6: // 90° rotate right
146
-                    $transformation = '-rotate 90';
147
-                    break;
148
-                case 7: // horizontal flip + 90 rotate right
149
-                    $transformation = '-transverse';
150
-                    break;
151
-                case 8: // 90° rotate left
152
-                    $transformation = '-rotate 270';
153
-                    break;
154
-            }
155
-        }
156
-        return $transformation;
157
-    }
116
+	/**
117
+	 * Returns a command line parameter to fix the orientation of a rotated picture.
118
+	 *
119
+	 * @param integer $orientation
120
+	 * @return string
121
+	 */
122
+	protected function getTransformation($orientation)
123
+	{
124
+		$transformation = '';
125
+		if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] !== 'gm') {
126
+			// ImageMagick
127
+			if ($orientation >= 2 && $orientation <= 8) {
128
+				$transformation = '-auto-orient';
129
+			}
130
+		} else {
131
+			// GraphicsMagick
132
+			switch ($orientation) {
133
+				case 2: // horizontal flip
134
+					$transformation = '-flip horizontal';
135
+					break;
136
+				case 3: // 180°
137
+					$transformation = '-rotate 180';
138
+					break;
139
+				case 4: // vertical flip
140
+					$transformation = '-flip vertical';
141
+					break;
142
+				case 5: // vertical flip + 90 rotate right
143
+					$transformation = '-transpose';
144
+					break;
145
+				case 6: // 90° rotate right
146
+					$transformation = '-rotate 90';
147
+					break;
148
+				case 7: // horizontal flip + 90 rotate right
149
+					$transformation = '-transverse';
150
+					break;
151
+				case 8: // 90° rotate left
152
+					$transformation = '-rotate 270';
153
+					break;
154
+			}
155
+		}
156
+		return $transformation;
157
+	}
158 158
 
159
-    /**
160
-     * Resets the EXIF orientation flag of a picture.
161
-     *
162
-     * @param string $filename
163
-     * @return void
164
-     * @see http://sylvana.net/jpegcrop/exif_orientation.html
165
-     */
166
-    protected function resetOrientation($filename)
167
-    {
168
-        JpegExifOrient::setOrientation($filename, 1);
169
-    }
159
+	/**
160
+	 * Resets the EXIF orientation flag of a picture.
161
+	 *
162
+	 * @param string $filename
163
+	 * @return void
164
+	 * @see http://sylvana.net/jpegcrop/exif_orientation.html
165
+	 */
166
+	protected function resetOrientation($filename)
167
+	{
168
+		JpegExifOrient::setOrientation($filename, 1);
169
+	}
170 170
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     public function __construct()
31 31
     {
32 32
         $this->gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
33
-        $this->gifCreator->absPrefix = Environment::getPublicPath() . '/';
33
+        $this->gifCreator->absPrefix = Environment::getPublicPath().'/';
34 34
     }
35 35
 
36 36
     /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
             $imParams = '###SkipStripProfile###';
52 52
             if ($transformation !== '') {
53
-                $imParams .= ' ' . $transformation;
53
+                $imParams .= ' '.$transformation;
54 54
             }
55 55
 
56 56
             $tempFileInfo = $this->gifCreator->imageMagickConvert($uploadedFile->getFileWithAbsolutePath(), '', '', '', $imParams, '', [], true);
Please login to merge, or discard this patch.
Classes/FileUpload/UploadedFileInterface.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -14,83 +14,83 @@
 block discarded – undo
14 14
  */
15 15
 interface UploadedFileInterface
16 16
 {
17
-    /**
18
-     * Save the file to the specified path.
19
-     *
20
-     * @return boolean true on success
21
-     */
22
-    public function save();
17
+	/**
18
+	 * Save the file to the specified path.
19
+	 *
20
+	 * @return boolean true on success
21
+	 */
22
+	public function save();
23 23
 
24
-    /**
25
-     * Get the original filename.
26
-     *
27
-     * @return string filename
28
-     */
29
-    public function getOriginalName();
24
+	/**
25
+	 * Get the original filename.
26
+	 *
27
+	 * @return string filename
28
+	 */
29
+	public function getOriginalName();
30 30
 
31
-    /**
32
-     * Get the file size.
33
-     *
34
-     * @return int
35
-     */
36
-    public function getSize();
31
+	/**
32
+	 * Get the file size.
33
+	 *
34
+	 * @return int
35
+	 */
36
+	public function getSize();
37 37
 
38
-    /**
39
-     * Get the file name.
40
-     *
41
-     * @return int
42
-     */
43
-    public function getName();
38
+	/**
39
+	 * Get the file name.
40
+	 *
41
+	 * @return int
42
+	 */
43
+	public function getName();
44 44
 
45
-    /**
46
-     * Get the file type.
47
-     *
48
-     * @return int
49
-     */
50
-    public function getType();
45
+	/**
46
+	 * Get the file type.
47
+	 *
48
+	 * @return int
49
+	 */
50
+	public function getType();
51 51
 
52
-    /**
53
-     * Get the mime type of the file.
54
-     *
55
-     * @return int
56
-     */
57
-    public function getMimeType();
52
+	/**
53
+	 * Get the mime type of the file.
54
+	 *
55
+	 * @return int
56
+	 */
57
+	public function getMimeType();
58 58
 
59
-    /**
60
-     * Get the file with its absolute path.
61
-     *
62
-     * @return string
63
-     */
64
-    public function getFileWithAbsolutePath();
59
+	/**
60
+	 * Get the file with its absolute path.
61
+	 *
62
+	 * @return string
63
+	 */
64
+	public function getFileWithAbsolutePath();
65 65
 
66
-    /**
67
-     * Get the file's public URL.
68
-     *
69
-     * @return string
70
-     */
71
-    public function getPublicUrl();
66
+	/**
67
+	 * Get the file's public URL.
68
+	 *
69
+	 * @return string
70
+	 */
71
+	public function getPublicUrl();
72 72
 
73
-    /**
74
-     * Set the file input name from the DOM.
75
-     *
76
-     * @param string $inputName
77
-     * @return \Fab\Media\FileUpload\UploadedFileInterface
78
-     */
79
-    public function setInputName($inputName);
73
+	/**
74
+	 * Set the file input name from the DOM.
75
+	 *
76
+	 * @param string $inputName
77
+	 * @return \Fab\Media\FileUpload\UploadedFileInterface
78
+	 */
79
+	public function setInputName($inputName);
80 80
 
81
-    /**
82
-     * Set the upload folder
83
-     *
84
-     * @param string $uploadFolder
85
-     * @return \Fab\Media\FileUpload\UploadedFileInterface
86
-     */
87
-    public function setUploadFolder($uploadFolder);
81
+	/**
82
+	 * Set the upload folder
83
+	 *
84
+	 * @param string $uploadFolder
85
+	 * @return \Fab\Media\FileUpload\UploadedFileInterface
86
+	 */
87
+	public function setUploadFolder($uploadFolder);
88 88
 
89
-    /**
90
-     * Set the file name to be saved
91
-     *
92
-     * @param string $name
93
-     * @return \Fab\Media\FileUpload\UploadedFileInterface
94
-     */
95
-    public function setName($name);
89
+	/**
90
+	 * Set the file name to be saved
91
+	 *
92
+	 * @param string $name
93
+	 * @return \Fab\Media\FileUpload\UploadedFileInterface
94
+	 */
95
+	public function setName($name);
96 96
 }
Please login to merge, or discard this patch.
Classes/FileUpload/MultipartedFile.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -16,48 +16,48 @@
 block discarded – undo
16 16
  */
17 17
 class MultipartedFile extends UploadedFileAbstract
18 18
 {
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $inputName = 'qqfile';
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $inputName = 'qqfile';
23 23
 
24
-    /**
25
-     * Save the file to the specified path
26
-     *
27
-     * @return boolean true on success
28
-     */
29
-    public function save()
30
-    {
31
-        return move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->getFileWithAbsolutePath());
32
-    }
24
+	/**
25
+	 * Save the file to the specified path
26
+	 *
27
+	 * @return boolean true on success
28
+	 */
29
+	public function save()
30
+	{
31
+		return move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->getFileWithAbsolutePath());
32
+	}
33 33
 
34
-    /**
35
-     * Get the original filename
36
-     *
37
-     * @return string filename
38
-     */
39
-    public function getOriginalName()
40
-    {
41
-        return $_FILES[$this->inputName]['name'];
42
-    }
34
+	/**
35
+	 * Get the original filename
36
+	 *
37
+	 * @return string filename
38
+	 */
39
+	public function getOriginalName()
40
+	{
41
+		return $_FILES[$this->inputName]['name'];
42
+	}
43 43
 
44
-    /**
45
-     * Get the file size
46
-     *
47
-     * @return integer file-size in byte
48
-     */
49
-    public function getSize()
50
-    {
51
-        return $_FILES[$this->inputName]['size'];
52
-    }
44
+	/**
45
+	 * Get the file size
46
+	 *
47
+	 * @return integer file-size in byte
48
+	 */
49
+	public function getSize()
50
+	{
51
+		return $_FILES[$this->inputName]['size'];
52
+	}
53 53
 
54
-    /**
55
-     * Get the mime type of the file.
56
-     *
57
-     * @return int
58
-     */
59
-    public function getMimeType()
60
-    {
61
-        return $_FILES[$this->inputName]['type'];
62
-    }
54
+	/**
55
+	 * Get the mime type of the file.
56
+	 *
57
+	 * @return int
58
+	 */
59
+	public function getMimeType()
60
+	{
61
+		return $_FILES[$this->inputName]['type'];
62
+	}
63 63
 }
Please login to merge, or discard this patch.