Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
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.
Classes/DataHandler/FileDataHandler.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,126 +21,126 @@
 block discarded – undo
21 21
  */
22 22
 class FileDataHandler extends AbstractDataHandler
23 23
 {
24
-    /**
25
-     * Process File with action "update".
26
-     *
27
-     * @param Content $content
28
-     * @throws \Exception
29
-     * @return bool
30
-     */
31
-    public function processUpdate(Content $content)
32
-    {
33
-        throw new \Exception('Not yet implemented', 1409988673);
34
-    }
35
-
36
-    /**
37
-     * Process File with action "remove".
38
-     *
39
-     * @param Content $content
40
-     * @return bool|void
41
-     */
42
-    public function processRemove(Content $content)
43
-    {
44
-        $file = $this->getResourceFactory()->getFileObject($content->getUid());
45
-
46
-        $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
47
-        if ($numberOfReferences === 0) {
48
-            $file->delete();
49
-        } else {
50
-            $message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences);
51
-            $this->errorMessages = $message;
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Process File with action "copy".
57
-     *
58
-     * @param Content $content
59
-     * @param string $target
60
-     * @throws \Exception
61
-     * @return bool
62
-     */
63
-    public function processCopy(Content $content, $target)
64
-    {
65
-        $file = $this->getResourceFactory()->getFileObject($content->getUid());
66
-
67
-        if ($this->getMediaModule()->hasFolderTree()) {
68
-            $targetFolder = $this->getMediaModule()->getCurrentFolder();
69
-
70
-            // Move file
71
-            $file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
72
-        }
73
-        return true;
74
-    }
75
-
76
-    /**
77
-     * Process File with action "move".
78
-     *
79
-     * @param Content $content
80
-     * @param string $target
81
-     * @throws \Exception
82
-     * @return bool
83
-     */
84
-    public function processMove(Content $content, $target)
85
-    {
86
-        $file = $this->getResourceFactory()->getFileObject($content->getUid());
87
-
88
-        if ($this->getMediaModule()->hasFolderTree()) {
89
-            $targetFolder = $this->getMediaModule()->getCurrentFolder();
90
-            if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) {
91
-                // Move file
92
-                $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
93
-            }
94
-        } else {
95
-            // Only process if the storage is different.
96
-            if ((int)$file->getStorage()->getUid() !== (int)$target) {
97
-                $targetStorage = $this->getResourceFactory()->getStorageObject((int)$target);
98
-
99
-                // Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission.
100
-                $targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file);
101
-
102
-                try {
103
-                    // Move file
104
-                    $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
105
-                } catch (\Exception $e) {
106
-                    $this->errorMessages = $e->getMessage();
107
-                }
108
-            }
109
-        }
110
-        return true;
111
-    }
112
-
113
-    /**
114
-     * @return FileReferenceService|object
115
-     */
116
-    protected function getFileReferenceService()
117
-    {
118
-        return GeneralUtility::makeInstance(FileReferenceService::class);
119
-    }
120
-
121
-    /**
122
-     * Process Content with action "localize".
123
-     *
124
-     * @param Content $content
125
-     * @param int $language
126
-     * @throws \Exception
127
-     * @return bool
128
-     */
129
-    public function processLocalize(Content $content, $language)
130
-    {
131
-        throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788);
132
-    }
133
-
134
-    /**
135
-     * @return MediaModule|object
136
-     */
137
-    protected function getMediaModule()
138
-    {
139
-        return GeneralUtility::makeInstance(MediaModule::class);
140
-    }
141
-
142
-    protected function getResourceFactory(): ResourceFactory
143
-    {
144
-        return GeneralUtility::makeInstance(ResourceFactory::class);
145
-    }
24
+	/**
25
+	 * Process File with action "update".
26
+	 *
27
+	 * @param Content $content
28
+	 * @throws \Exception
29
+	 * @return bool
30
+	 */
31
+	public function processUpdate(Content $content)
32
+	{
33
+		throw new \Exception('Not yet implemented', 1409988673);
34
+	}
35
+
36
+	/**
37
+	 * Process File with action "remove".
38
+	 *
39
+	 * @param Content $content
40
+	 * @return bool|void
41
+	 */
42
+	public function processRemove(Content $content)
43
+	{
44
+		$file = $this->getResourceFactory()->getFileObject($content->getUid());
45
+
46
+		$numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
47
+		if ($numberOfReferences === 0) {
48
+			$file->delete();
49
+		} else {
50
+			$message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences);
51
+			$this->errorMessages = $message;
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Process File with action "copy".
57
+	 *
58
+	 * @param Content $content
59
+	 * @param string $target
60
+	 * @throws \Exception
61
+	 * @return bool
62
+	 */
63
+	public function processCopy(Content $content, $target)
64
+	{
65
+		$file = $this->getResourceFactory()->getFileObject($content->getUid());
66
+
67
+		if ($this->getMediaModule()->hasFolderTree()) {
68
+			$targetFolder = $this->getMediaModule()->getCurrentFolder();
69
+
70
+			// Move file
71
+			$file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
72
+		}
73
+		return true;
74
+	}
75
+
76
+	/**
77
+	 * Process File with action "move".
78
+	 *
79
+	 * @param Content $content
80
+	 * @param string $target
81
+	 * @throws \Exception
82
+	 * @return bool
83
+	 */
84
+	public function processMove(Content $content, $target)
85
+	{
86
+		$file = $this->getResourceFactory()->getFileObject($content->getUid());
87
+
88
+		if ($this->getMediaModule()->hasFolderTree()) {
89
+			$targetFolder = $this->getMediaModule()->getCurrentFolder();
90
+			if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) {
91
+				// Move file
92
+				$file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
93
+			}
94
+		} else {
95
+			// Only process if the storage is different.
96
+			if ((int)$file->getStorage()->getUid() !== (int)$target) {
97
+				$targetStorage = $this->getResourceFactory()->getStorageObject((int)$target);
98
+
99
+				// Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission.
100
+				$targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file);
101
+
102
+				try {
103
+					// Move file
104
+					$file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
105
+				} catch (\Exception $e) {
106
+					$this->errorMessages = $e->getMessage();
107
+				}
108
+			}
109
+		}
110
+		return true;
111
+	}
112
+
113
+	/**
114
+	 * @return FileReferenceService|object
115
+	 */
116
+	protected function getFileReferenceService()
117
+	{
118
+		return GeneralUtility::makeInstance(FileReferenceService::class);
119
+	}
120
+
121
+	/**
122
+	 * Process Content with action "localize".
123
+	 *
124
+	 * @param Content $content
125
+	 * @param int $language
126
+	 * @throws \Exception
127
+	 * @return bool
128
+	 */
129
+	public function processLocalize(Content $content, $language)
130
+	{
131
+		throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788);
132
+	}
133
+
134
+	/**
135
+	 * @return MediaModule|object
136
+	 */
137
+	protected function getMediaModule()
138
+	{
139
+		return GeneralUtility::makeInstance(MediaModule::class);
140
+	}
141
+
142
+	protected function getResourceFactory(): ResourceFactory
143
+	{
144
+		return GeneralUtility::makeInstance(ResourceFactory::class);
145
+	}
146 146
 }
Please login to merge, or discard this patch.
Classes/Grid/FrontendPermissionRenderer.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
  */
17 17
 class FrontendPermissionRenderer extends ColumnRendererAbstract
18 18
 {
19
-    /**
20
-     * Render permission in the grid.
21
-     *
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        $result = '';
19
+	/**
20
+	 * Render permission in the grid.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		$result = '';
27 27
 
28
-        $frontendUserGroups = $this->object['metadata']['fe_groups'];
29
-        if (!empty($frontendUserGroups)) {
30
-            /** @var $frontendUserGroup \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup */
31
-            foreach ($frontendUserGroups as $frontendUserGroup) {
32
-                $result .= sprintf('<li style="list-style: disc">%s</li>', $frontendUserGroup['title']);
33
-            }
34
-            $result = sprintf('<ul>%s</ul>', $result);
35
-        }
36
-        return $result;
37
-    }
28
+		$frontendUserGroups = $this->object['metadata']['fe_groups'];
29
+		if (!empty($frontendUserGroups)) {
30
+			/** @var $frontendUserGroup \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup */
31
+			foreach ($frontendUserGroups as $frontendUserGroup) {
32
+				$result .= sprintf('<li style="list-style: disc">%s</li>', $frontendUserGroup['title']);
33
+			}
34
+			$result = sprintf('<ul>%s</ul>', $result);
35
+		}
36
+		return $result;
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Classes/Grid/PreviewRenderer.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -23,81 +23,81 @@
 block discarded – undo
23 23
  */
24 24
 class PreviewRenderer extends ColumnRendererAbstract
25 25
 {
26
-    /**
27
-     * Render a preview of a file in the Grid.
28
-     *
29
-     * @return string
30
-     */
31
-    public function render()
32
-    {
33
-        $file = $this->getFileConverter()->convert($this->object);
26
+	/**
27
+	 * Render a preview of a file in the Grid.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function render()
32
+	{
33
+		$file = $this->getFileConverter()->convert($this->object);
34 34
 
35
-        $uri = false;
36
-        $appendTime = true;
35
+		$uri = false;
36
+		$appendTime = true;
37 37
 
38
-        // Compute image-editor or link-creator URL.
39
-        if ($this->getModuleLoader()->hasPlugin('imageEditor')) {
40
-            $appendTime = false;
41
-            $uri = $this->getPluginUri('ImageEditor');
42
-        } elseif ($this->getModuleLoader()->hasPlugin('linkCreator')) {
43
-            $appendTime = false;
44
-            $uri = $this->getPluginUri('LinkCreator');
45
-        }
38
+		// Compute image-editor or link-creator URL.
39
+		if ($this->getModuleLoader()->hasPlugin('imageEditor')) {
40
+			$appendTime = false;
41
+			$uri = $this->getPluginUri('ImageEditor');
42
+		} elseif ($this->getModuleLoader()->hasPlugin('linkCreator')) {
43
+			$appendTime = false;
44
+			$uri = $this->getPluginUri('LinkCreator');
45
+		}
46 46
 
47
-        $result = $this->getThumbnailService($file)
48
-            ->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
49
-            ->setAppendTimeStamp($appendTime)
50
-            ->setTarget(ThumbnailInterface::TARGET_BLANK)
51
-            ->setAnchorUri($uri)
52
-            ->setAttributes([])
53
-            ->create();
47
+		$result = $this->getThumbnailService($file)
48
+			->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
49
+			->setAppendTimeStamp($appendTime)
50
+			->setTarget(ThumbnailInterface::TARGET_BLANK)
51
+			->setAnchorUri($uri)
52
+			->setAttributes([])
53
+			->create();
54 54
 
55
-        // Add file info
56
-        $result .= sprintf(
57
-            '<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
58
-            $this->getMetadataViewHelper()->render($file)
59
-        );
60
-        return $result;
61
-    }
55
+		// Add file info
56
+		$result .= sprintf(
57
+			'<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
58
+			$this->getMetadataViewHelper()->render($file)
59
+		);
60
+		return $result;
61
+	}
62 62
 
63
-    /**
64
-     * @param File $file
65
-     * @return ThumbnailService|object
66
-     */
67
-    protected function getThumbnailService(File $file)
68
-    {
69
-        return GeneralUtility::makeInstance(ThumbnailService::class, $file);
70
-    }
63
+	/**
64
+	 * @param File $file
65
+	 * @return ThumbnailService|object
66
+	 */
67
+	protected function getThumbnailService(File $file)
68
+	{
69
+		return GeneralUtility::makeInstance(ThumbnailService::class, $file);
70
+	}
71 71
 
72
-    /**
73
-     * @return MetadataViewHelper|object
74
-     */
75
-    protected function getMetadataViewHelper()
76
-    {
77
-        return GeneralUtility::makeInstance(MetadataViewHelper::class);
78
-    }
72
+	/**
73
+	 * @return MetadataViewHelper|object
74
+	 */
75
+	protected function getMetadataViewHelper()
76
+	{
77
+		return GeneralUtility::makeInstance(MetadataViewHelper::class);
78
+	}
79 79
 
80
-    /**
81
-     * @param string $controllerName
82
-     * @return string
83
-     */
84
-    protected function getPluginUri($controllerName)
85
-    {
86
-        $urlParameters = array(
87
-            MediaModule::getParameterPrefix() => array(
88
-                'controller' => $controllerName,
89
-                'action' => 'show',
90
-                'file' => $this->object->getUid(),
91
-            ),
92
-        );
93
-        return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
94
-    }
80
+	/**
81
+	 * @param string $controllerName
82
+	 * @return string
83
+	 */
84
+	protected function getPluginUri($controllerName)
85
+	{
86
+		$urlParameters = array(
87
+			MediaModule::getParameterPrefix() => array(
88
+				'controller' => $controllerName,
89
+				'action' => 'show',
90
+				'file' => $this->object->getUid(),
91
+			),
92
+		);
93
+		return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
94
+	}
95 95
 
96
-    /**
97
-     * @return ContentToFileConverter|object
98
-     */
99
-    protected function getFileConverter()
100
-    {
101
-        return GeneralUtility::makeInstance(ContentToFileConverter::class);
102
-    }
96
+	/**
97
+	 * @return ContentToFileConverter|object
98
+	 */
99
+	protected function getFileConverter()
100
+	{
101
+		return GeneralUtility::makeInstance(ContentToFileConverter::class);
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Classes/Grid/ActionPermissionColumn.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,32 +17,32 @@
 block discarded – undo
17 17
  */
18 18
 class ActionPermissionColumn extends ColumnRendererAbstract
19 19
 {
20
-    /**
21
-     * Renders a configurable metadata property of a file in the Grid.
22
-     *
23
-     * @throws \Exception
24
-     * @return string
25
-     */
26
-    public function render()
27
-    {
28
-        $file = $this->getFileConverter()->convert($this->object);
29
-        $permission = '';
20
+	/**
21
+	 * Renders a configurable metadata property of a file in the Grid.
22
+	 *
23
+	 * @throws \Exception
24
+	 * @return string
25
+	 */
26
+	public function render()
27
+	{
28
+		$file = $this->getFileConverter()->convert($this->object);
29
+		$permission = '';
30 30
 
31
-        if ($file->checkActionPermission('read')) {
32
-            $permission = 'R';
33
-        }
34
-        if ($file->checkActionPermission('write')) {
35
-            $permission .= 'W';
36
-        }
31
+		if ($file->checkActionPermission('read')) {
32
+			$permission = 'R';
33
+		}
34
+		if ($file->checkActionPermission('write')) {
35
+			$permission .= 'W';
36
+		}
37 37
 
38
-        return '<strong>' . $permission . '</strong>';
39
-    }
38
+		return '<strong>' . $permission . '</strong>';
39
+	}
40 40
 
41
-    /**
42
-     * @return ContentToFileConverter|object
43
-     */
44
-    protected function getFileConverter()
45
-    {
46
-        return GeneralUtility::makeInstance(ContentToFileConverter::class);
47
-    }
41
+	/**
42
+	 * @return ContentToFileConverter|object
43
+	 */
44
+	protected function getFileConverter()
45
+	{
46
+		return GeneralUtility::makeInstance(ContentToFileConverter::class);
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Classes/Grid/UsageRenderer.php 1 patch
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -23,205 +23,205 @@
 block discarded – undo
23 23
  */
24 24
 class UsageRenderer extends ColumnRendererAbstract
25 25
 {
26
-    /**
27
-     * Render usage of an asset in the grid.
28
-     *
29
-     * @return string
30
-     */
31
-    public function render()
32
-    {
33
-        $file = $this->getFileConverter()->convert($this->object);
34
-
35
-        $result = '';
36
-
37
-        // Add number of references on the top!
38
-        if ($this->object['number_of_references'] > 1) {
39
-            $result .= sprintf(
40
-                '<div><strong>%s (%s)</strong></div>',
41
-                $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:references'),
42
-                $this->object['number_of_references']
43
-            );
44
-        }
45
-
46
-        // Render File usage
47
-        $fileReferences = $this->getFileReferenceService()->findFileReferences($file);
48
-        if (!empty($fileReferences)) {
49
-            // Finalize file references assembling.
50
-            $result .= sprintf(
51
-                $this->getWrappingTemplate(),
52
-                $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:file_reference'),
53
-                $this->assembleOutput($fileReferences, array('referenceIdentifier' => 'uid_foreign', 'tableName' => 'tablenames'))
54
-            );
55
-        }
56
-
57
-        // Render link usage in RTE
58
-        $linkSoftReferences = $this->getFileReferenceService()->findSoftLinkReferences($file);
59
-        if (!empty($linkSoftReferences)) {
60
-            // Finalize link references assembling.
61
-            $result .= sprintf(
62
-                $this->getWrappingTemplate(),
63
-                $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:link_references_in_rte'),
64
-                $this->assembleOutput($linkSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename'))
65
-            );
66
-        }
67
-
68
-        // Render image usage in RTE
69
-        $imageSoftReferences = $this->getFileReferenceService()->findSoftImageReferences($file);
70
-        if (!empty($imageSoftReferences)) {
71
-            // Finalize image references assembling.
72
-            $result .= sprintf(
73
-                $this->getWrappingTemplate(),
74
-                $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:image_references_in_rte'),
75
-                $this->assembleOutput($imageSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename'))
76
-            );
77
-        }
78
-
79
-        return $result;
80
-    }
81
-
82
-    /**
83
-     * Assemble output reference.
84
-     *
85
-     * @param array $references
86
-     * @param array $mapping
87
-     * @return string
88
-     */
89
-    protected function assembleOutput(array $references, array $mapping)
90
-    {
91
-        $result = '';
92
-        foreach ($references as $reference) {
93
-            $button = $this->makeLinkButton()
94
-                ->setHref($this->getEditUri($reference, $mapping))
95
-                ->setClasses('btn-edit-reference')
96
-                ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL))
97
-                ->render();
98
-
99
-            $tableName = $reference[$mapping['tableName']];
100
-            $identifier = (int)$reference[$mapping['referenceIdentifier']];
101
-
102
-            $result .= sprintf(
103
-                '<li title="">%s %s</li>',
104
-                $button,
105
-                $this->computeTitle($tableName, $identifier)
106
-            );
107
-        }
108
-
109
-        return $result;
110
-    }
111
-
112
-    /**
113
-     * @param string $tableName
114
-     * @param int $identifier
115
-     * @return string
116
-     */
117
-    protected function computeTitle($tableName, $identifier)
118
-    {
119
-        $title = '';
120
-        if (!empty($GLOBALS['TCA'][$tableName])) {
121
-            $title = $this->getRecordTitle($tableName, $identifier);
122
-            if (!$title) {
123
-                $title = Tca::table($tableName)->getTitle();
124
-            }
125
-        }
126
-        return $title;
127
-    }
128
-
129
-    /**
130
-     * @return object|LinkButton
131
-     */
132
-    protected function makeLinkButton()
133
-    {
134
-        return GeneralUtility::makeInstance(LinkButton::class);
135
-    }
136
-
137
-    /**
138
-     * @param array $reference
139
-     * @param array $mapping
140
-     * @return string
141
-     */
142
-    protected function getEditUri(array $reference, array $mapping)
143
-    {
144
-        $parameterName = sprintf('edit[%s][%s]', $reference[$mapping['tableName']], $reference[$mapping['referenceIdentifier']]);
145
-        $uri = BackendUtility::getModuleUrl(
146
-            'record_edit',
147
-            array(
148
-                $parameterName => 'edit',
149
-                'returnUrl' => $this->getModuleUrl()
150
-            )
151
-        );
152
-        return $uri;
153
-    }
154
-
155
-    /**
156
-     * @return string
157
-     */
158
-    protected function getModuleUrl()
159
-    {
160
-        $additionalParameters = [];
161
-        if (GeneralUtility::_GP('id')) {
162
-            $additionalParameters = array(
163
-                'id' => urldecode(GeneralUtility::_GP('id')),
164
-            );
165
-        }
166
-        return BackendUtility::getModuleUrl(GeneralUtility::_GP('route'), $additionalParameters);
167
-    }
168
-
169
-    /**
170
-     * Return the title given a table name and an identifier.
171
-     *
172
-     * @param string $tableName
173
-     * @param string $identifier
174
-     * @return string
175
-     */
176
-    protected function getRecordTitle($tableName, $identifier)
177
-    {
178
-        $result = '';
179
-        if ($tableName && (int)$identifier > 0) {
180
-            $labelField = Tca::table($tableName)->getLabelField();
181
-
182
-            // Get the title of the record.
183
-            $record = $this->getDataService()
184
-                ->getRecord($tableName, ['uid' => $identifier,]);
185
-
186
-            if (!empty($record[$labelField])) {
187
-                $result = $record[$labelField];
188
-            }
189
-        }
190
-
191
-        return $result;
192
-    }
193
-
194
-    /**
195
-     * @return object|DataService
196
-     */
197
-    protected function getDataService(): DataService
198
-    {
199
-        return GeneralUtility::makeInstance(DataService::class);
200
-    }
201
-
202
-    /**
203
-     * Return the wrapping HTML template.
204
-     *
205
-     * @return string
206
-     */
207
-    protected function getWrappingTemplate()
208
-    {
209
-        return '<div style="text-decoration: underline; margin-top: 10px; margin-bottom: 10px">%s</div><ul class="usage-list">%s</ul>';
210
-    }
211
-
212
-    /**
213
-     * @return FileReferenceService|object
214
-     */
215
-    protected function getFileReferenceService()
216
-    {
217
-        return GeneralUtility::makeInstance(FileReferenceService::class);
218
-    }
219
-
220
-    /**
221
-     * @return ContentToFileConverter|object
222
-     */
223
-    protected function getFileConverter()
224
-    {
225
-        return GeneralUtility::makeInstance(ContentToFileConverter::class);
226
-    }
26
+	/**
27
+	 * Render usage of an asset in the grid.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function render()
32
+	{
33
+		$file = $this->getFileConverter()->convert($this->object);
34
+
35
+		$result = '';
36
+
37
+		// Add number of references on the top!
38
+		if ($this->object['number_of_references'] > 1) {
39
+			$result .= sprintf(
40
+				'<div><strong>%s (%s)</strong></div>',
41
+				$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:references'),
42
+				$this->object['number_of_references']
43
+			);
44
+		}
45
+
46
+		// Render File usage
47
+		$fileReferences = $this->getFileReferenceService()->findFileReferences($file);
48
+		if (!empty($fileReferences)) {
49
+			// Finalize file references assembling.
50
+			$result .= sprintf(
51
+				$this->getWrappingTemplate(),
52
+				$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:file_reference'),
53
+				$this->assembleOutput($fileReferences, array('referenceIdentifier' => 'uid_foreign', 'tableName' => 'tablenames'))
54
+			);
55
+		}
56
+
57
+		// Render link usage in RTE
58
+		$linkSoftReferences = $this->getFileReferenceService()->findSoftLinkReferences($file);
59
+		if (!empty($linkSoftReferences)) {
60
+			// Finalize link references assembling.
61
+			$result .= sprintf(
62
+				$this->getWrappingTemplate(),
63
+				$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:link_references_in_rte'),
64
+				$this->assembleOutput($linkSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename'))
65
+			);
66
+		}
67
+
68
+		// Render image usage in RTE
69
+		$imageSoftReferences = $this->getFileReferenceService()->findSoftImageReferences($file);
70
+		if (!empty($imageSoftReferences)) {
71
+			// Finalize image references assembling.
72
+			$result .= sprintf(
73
+				$this->getWrappingTemplate(),
74
+				$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:image_references_in_rte'),
75
+				$this->assembleOutput($imageSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename'))
76
+			);
77
+		}
78
+
79
+		return $result;
80
+	}
81
+
82
+	/**
83
+	 * Assemble output reference.
84
+	 *
85
+	 * @param array $references
86
+	 * @param array $mapping
87
+	 * @return string
88
+	 */
89
+	protected function assembleOutput(array $references, array $mapping)
90
+	{
91
+		$result = '';
92
+		foreach ($references as $reference) {
93
+			$button = $this->makeLinkButton()
94
+				->setHref($this->getEditUri($reference, $mapping))
95
+				->setClasses('btn-edit-reference')
96
+				->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL))
97
+				->render();
98
+
99
+			$tableName = $reference[$mapping['tableName']];
100
+			$identifier = (int)$reference[$mapping['referenceIdentifier']];
101
+
102
+			$result .= sprintf(
103
+				'<li title="">%s %s</li>',
104
+				$button,
105
+				$this->computeTitle($tableName, $identifier)
106
+			);
107
+		}
108
+
109
+		return $result;
110
+	}
111
+
112
+	/**
113
+	 * @param string $tableName
114
+	 * @param int $identifier
115
+	 * @return string
116
+	 */
117
+	protected function computeTitle($tableName, $identifier)
118
+	{
119
+		$title = '';
120
+		if (!empty($GLOBALS['TCA'][$tableName])) {
121
+			$title = $this->getRecordTitle($tableName, $identifier);
122
+			if (!$title) {
123
+				$title = Tca::table($tableName)->getTitle();
124
+			}
125
+		}
126
+		return $title;
127
+	}
128
+
129
+	/**
130
+	 * @return object|LinkButton
131
+	 */
132
+	protected function makeLinkButton()
133
+	{
134
+		return GeneralUtility::makeInstance(LinkButton::class);
135
+	}
136
+
137
+	/**
138
+	 * @param array $reference
139
+	 * @param array $mapping
140
+	 * @return string
141
+	 */
142
+	protected function getEditUri(array $reference, array $mapping)
143
+	{
144
+		$parameterName = sprintf('edit[%s][%s]', $reference[$mapping['tableName']], $reference[$mapping['referenceIdentifier']]);
145
+		$uri = BackendUtility::getModuleUrl(
146
+			'record_edit',
147
+			array(
148
+				$parameterName => 'edit',
149
+				'returnUrl' => $this->getModuleUrl()
150
+			)
151
+		);
152
+		return $uri;
153
+	}
154
+
155
+	/**
156
+	 * @return string
157
+	 */
158
+	protected function getModuleUrl()
159
+	{
160
+		$additionalParameters = [];
161
+		if (GeneralUtility::_GP('id')) {
162
+			$additionalParameters = array(
163
+				'id' => urldecode(GeneralUtility::_GP('id')),
164
+			);
165
+		}
166
+		return BackendUtility::getModuleUrl(GeneralUtility::_GP('route'), $additionalParameters);
167
+	}
168
+
169
+	/**
170
+	 * Return the title given a table name and an identifier.
171
+	 *
172
+	 * @param string $tableName
173
+	 * @param string $identifier
174
+	 * @return string
175
+	 */
176
+	protected function getRecordTitle($tableName, $identifier)
177
+	{
178
+		$result = '';
179
+		if ($tableName && (int)$identifier > 0) {
180
+			$labelField = Tca::table($tableName)->getLabelField();
181
+
182
+			// Get the title of the record.
183
+			$record = $this->getDataService()
184
+				->getRecord($tableName, ['uid' => $identifier,]);
185
+
186
+			if (!empty($record[$labelField])) {
187
+				$result = $record[$labelField];
188
+			}
189
+		}
190
+
191
+		return $result;
192
+	}
193
+
194
+	/**
195
+	 * @return object|DataService
196
+	 */
197
+	protected function getDataService(): DataService
198
+	{
199
+		return GeneralUtility::makeInstance(DataService::class);
200
+	}
201
+
202
+	/**
203
+	 * Return the wrapping HTML template.
204
+	 *
205
+	 * @return string
206
+	 */
207
+	protected function getWrappingTemplate()
208
+	{
209
+		return '<div style="text-decoration: underline; margin-top: 10px; margin-bottom: 10px">%s</div><ul class="usage-list">%s</ul>';
210
+	}
211
+
212
+	/**
213
+	 * @return FileReferenceService|object
214
+	 */
215
+	protected function getFileReferenceService()
216
+	{
217
+		return GeneralUtility::makeInstance(FileReferenceService::class);
218
+	}
219
+
220
+	/**
221
+	 * @return ContentToFileConverter|object
222
+	 */
223
+	protected function getFileConverter()
224
+	{
225
+		return GeneralUtility::makeInstance(ContentToFileConverter::class);
226
+	}
227 227
 }
Please login to merge, or discard this patch.
Classes/Grid/MetadataRenderer.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -19,76 +19,76 @@
 block discarded – undo
19 19
  */
20 20
 class MetadataRenderer extends ColumnRendererAbstract
21 21
 {
22
-    /**
23
-     * Renders a configurable metadata property of a file in the Grid.
24
-     *
25
-     * @throws \Exception
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        if (empty($this->gridRendererConfiguration['property'])) {
31
-            throw new \Exception('Missing property value for Grid Renderer Metadata', 1390391042);
32
-        }
22
+	/**
23
+	 * Renders a configurable metadata property of a file in the Grid.
24
+	 *
25
+	 * @throws \Exception
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		if (empty($this->gridRendererConfiguration['property'])) {
31
+			throw new \Exception('Missing property value for Grid Renderer Metadata', 1390391042);
32
+		}
33 33
 
34
-        $file = $this->getFileConverter()->convert($this->object);
35
-        $propertyName = $this->gridRendererConfiguration['property'];
34
+		$file = $this->getFileConverter()->convert($this->object);
35
+		$propertyName = $this->gridRendererConfiguration['property'];
36 36
 
37
-        if ($propertyName === 'uid') {
38
-            $metadata = $file->getMetaData();
39
-            $result = $metadata['uid']; // make an exception here to retrieve the uid of the metadata.
40
-        } else {
41
-            $result = $file->getProperty($propertyName);
42
-        }
37
+		if ($propertyName === 'uid') {
38
+			$metadata = $file->getMetaData();
39
+			$result = $metadata['uid']; // make an exception here to retrieve the uid of the metadata.
40
+		} else {
41
+			$result = $file->getProperty($propertyName);
42
+		}
43 43
 
44
-        // Avoid bad surprise, converts characters to HTML.
45
-        $fieldType = Tca::table('sys_file_metadata')->field($propertyName)->getType();
46
-        if ($fieldType !== FieldType::TEXTAREA) {
47
-            $result = htmlentities($result);
48
-        } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($result)) {
49
-            $result = htmlentities($result);
50
-        } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($result)) {
51
-            $result = nl2br($result);
52
-        }
44
+		// Avoid bad surprise, converts characters to HTML.
45
+		$fieldType = Tca::table('sys_file_metadata')->field($propertyName)->getType();
46
+		if ($fieldType !== FieldType::TEXTAREA) {
47
+			$result = htmlentities($result);
48
+		} elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($result)) {
49
+			$result = htmlentities($result);
50
+		} elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($result)) {
51
+			$result = nl2br($result);
52
+		}
53 53
 
54
-        return $result;
55
-    }
54
+		return $result;
55
+	}
56 56
 
57
-    /**
58
-     * Check whether a string contains HTML tags.
59
-     *
60
-     * @param string $content the content to be analyzed
61
-     * @return boolean
62
-     */
63
-    protected function hasHtml($content)
64
-    {
65
-        $result = false;
57
+	/**
58
+	 * Check whether a string contains HTML tags.
59
+	 *
60
+	 * @param string $content the content to be analyzed
61
+	 * @return boolean
62
+	 */
63
+	protected function hasHtml($content)
64
+	{
65
+		$result = false;
66 66
 
67
-        // We compare the length of the string with html tags and without html tags.
68
-        if (strlen($content) != strlen(strip_tags($content))) {
69
-            $result = true;
70
-        }
71
-        return $result;
72
-    }
67
+		// We compare the length of the string with html tags and without html tags.
68
+		if (strlen($content) != strlen(strip_tags($content))) {
69
+			$result = true;
70
+		}
71
+		return $result;
72
+	}
73 73
 
74
-    /**
75
-     * Check whether a string contains potential XSS
76
-     *
77
-     * @param string $content the content to be analyzed
78
-     * @return boolean
79
-     */
80
-    protected function isClean($content)
81
-    {
82
-        // @todo implement me!
83
-        $result = true;
84
-        return $result;
85
-    }
74
+	/**
75
+	 * Check whether a string contains potential XSS
76
+	 *
77
+	 * @param string $content the content to be analyzed
78
+	 * @return boolean
79
+	 */
80
+	protected function isClean($content)
81
+	{
82
+		// @todo implement me!
83
+		$result = true;
84
+		return $result;
85
+	}
86 86
 
87
-    /**
88
-     * @return ContentToFileConverter|object
89
-     */
90
-    protected function getFileConverter()
91
-    {
92
-        return GeneralUtility::makeInstance(ContentToFileConverter::class);
93
-    }
87
+	/**
88
+	 * @return ContentToFileConverter|object
89
+	 */
90
+	protected function getFileConverter()
91
+	{
92
+		return GeneralUtility::makeInstance(ContentToFileConverter::class);
93
+	}
94 94
 }
Please login to merge, or discard this patch.