Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
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/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.
Classes/Grid/CategoryRenderer.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 CategoryRenderer extends ColumnRendererAbstract
18 18
 {
19
-    /**
20
-     * Renders category list of an asset in the grid.
21
-     *
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        $result = '';
19
+	/**
20
+	 * Renders category list of an asset in the grid.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		$result = '';
27 27
 
28
-        $categories = $this->object['metadata']['categories'];
29
-        if (!empty($categories)) {
30
-            /** @var $category \TYPO3\CMS\Extbase\Domain\Model\Category */
31
-            foreach ($categories as $category) {
32
-                $result .= sprintf('<li>%s</li>', $category['title']);
33
-            }
34
-            $result = sprintf('<ul class="category-list">%s</ul>', $result);
35
-        }
36
-        return $result;
37
-    }
28
+		$categories = $this->object['metadata']['categories'];
29
+		if (!empty($categories)) {
30
+			/** @var $category \TYPO3\CMS\Extbase\Domain\Model\Category */
31
+			foreach ($categories as $category) {
32
+				$result .= sprintf('<li>%s</li>', $category['title']);
33
+			}
34
+			$result = sprintf('<ul class="category-list">%s</ul>', $result);
35
+		}
36
+		return $result;
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/ReportToViewHelper.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
16 16
  */
17 17
 class ReportToViewHelper extends AbstractViewHelper
18 18
 {
19
-    /**
20
-     * Returns the people who will receive a report.
21
-     *
22
-     * @throws \Exception
23
-     * @return string
24
-     */
25
-    public function render()
26
-    {
27
-        $reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
-        if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
-            $reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
-        }
31
-        return $reportTo;
32
-    }
19
+	/**
20
+	 * Returns the people who will receive a report.
21
+	 *
22
+	 * @throws \Exception
23
+	 * @return string
24
+	 */
25
+	public function render()
26
+	{
27
+		$reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
+		if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
+			$reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
+		}
31
+		return $reportTo;
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Form/Select/StorageViewHelper.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -20,50 +20,50 @@
 block discarded – undo
20 20
  */
21 21
 class StorageViewHelper extends AbstractViewHelper
22 22
 {
23
-    /**
24
-     * @return void
25
-     */
26
-    public function initializeArguments()
27
-    {
28
-        $this->registerArgument('objects', 'array', '', false, []);
29
-    }
23
+	/**
24
+	 * @return void
25
+	 */
26
+	public function initializeArguments()
27
+	{
28
+		$this->registerArgument('objects', 'array', '', false, []);
29
+	}
30 30
 
31
-    /**
32
-     * Render a file upload field
33
-     *
34
-     * @return string
35
-     */
36
-    public function render()
37
-    {
38
-        $objects = $this->arguments['objects'];
31
+	/**
32
+	 * Render a file upload field
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function render()
37
+	{
38
+		$objects = $this->arguments['objects'];
39 39
 
40
-        // Check if a storages is selected
41
-        $currentStorage = $this->getMediaModule()->getCurrentStorage();
40
+		// Check if a storages is selected
41
+		$currentStorage = $this->getMediaModule()->getCurrentStorage();
42 42
 
43
-        $template = '<select name="%s[target]">%s</select>';
44
-        $options = [];
45
-        foreach ($objects as $storage) {
46
-            /** @var ResourceStorage $storage */
47
-            $options[] = sprintf(
48
-                '<option value="%s" %s>%s %s</option>',
49
-                $storage->getUid(),
50
-                is_object($currentStorage) && $currentStorage->getUid() == $storage->getUid() ? 'selected="selected"' : '',
51
-                $storage->getName(),
52
-                !$storage->isOnline() ? '(offline)' : ''
53
-            );
54
-        }
55
-        return sprintf(
56
-            $template,
57
-            VidiModule::getParameterPrefix(),
58
-            implode("\n", $options)
59
-        );
60
-    }
43
+		$template = '<select name="%s[target]">%s</select>';
44
+		$options = [];
45
+		foreach ($objects as $storage) {
46
+			/** @var ResourceStorage $storage */
47
+			$options[] = sprintf(
48
+				'<option value="%s" %s>%s %s</option>',
49
+				$storage->getUid(),
50
+				is_object($currentStorage) && $currentStorage->getUid() == $storage->getUid() ? 'selected="selected"' : '',
51
+				$storage->getName(),
52
+				!$storage->isOnline() ? '(offline)' : ''
53
+			);
54
+		}
55
+		return sprintf(
56
+			$template,
57
+			VidiModule::getParameterPrefix(),
58
+			implode("\n", $options)
59
+		);
60
+	}
61 61
 
62
-    /**
63
-     * @return MediaModule|object
64
-     */
65
-    protected function getMediaModule()
66
-    {
67
-        return GeneralUtility::makeInstance(MediaModule::class);
68
-    }
62
+	/**
63
+	 * @return MediaModule|object
64
+	 */
65
+	protected function getMediaModule()
66
+	{
67
+		return GeneralUtility::makeInstance(MediaModule::class);
68
+	}
69 69
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Form/FooterViewHelper.php 2 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -21,122 +21,122 @@
 block discarded – undo
21 21
  */
22 22
 class FooterViewHelper extends AbstractViewHelper
23 23
 {
24
-    /**
25
-     * Render a form footer.
26
-     * Example:
27
-     * Created on 30-12-12 by John Updated on 22-05-12 by Jane
28
-     *
29
-     * @return string
30
-     */
31
-    public function render()
32
-    {
33
-        /** @var File $file */
34
-        $file = $this->templateVariableContainer->get('file');
35
-        $template = '<span>%s %s %s</span> <span style="padding-left: 50px">%s %s %s</span>';
36
-
37
-        $format = sprintf(
38
-            '%s @ %s',
39
-            $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],
40
-            $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']
41
-        );
42
-
43
-        $arguments = array(
44
-            'date' => null,
45
-            'format' => $format,
46
-            'base' => null
47
-        );
48
-
49
-        $result = sprintf(
50
-            $template,
51
-            LocalizationUtility::translate('created_on', 'media'),
52
-            $file->getProperty('crdate') ? $this->formatDate($arguments, $file->getProperty('crdate')) : '',
53
-            $this->getUserName($file->getProperty('cruser_id')),
54
-            LocalizationUtility::translate('updated_on', 'media'),
55
-            $file->getProperty('tstamp') ? $this->formatDate($arguments, '@' . $file->getProperty('tstamp')) : '',
56
-            $this->getUserName($file->getProperty('upuser_id'))
57
-        );
58
-
59
-        return $result;
60
-    }
61
-
62
-
63
-    /**
64
-     * Get the User name to be displayed
65
-     *
66
-     * @param int $userIdentifier
67
-     * @return string
68
-     */
69
-    public function getUserName($userIdentifier)
70
-    {
71
-        $username = '';
72
-
73
-        if ($userIdentifier > 0) {
74
-            $record = $this->getDataService()
75
-                ->getRecord(
76
-                    'be_users',
77
-                    [
78
-                        'uid' => $userIdentifier
79
-                    ]
80
-                );
81
-            $username = sprintf(
82
-                '%s %s',
83
-                LocalizationUtility::translate('by', 'media'),
84
-                empty($record['realName']) ? $record['username'] : $record['realName']
85
-            );
86
-        }
87
-
88
-        return $username;
89
-    }
90
-
91
-    /**
92
-     * @return object|DataService
93
-     */
94
-    protected function getDataService(): DataService
95
-    {
96
-        return GeneralUtility::makeInstance(DataService::class);
97
-    }
98
-
99
-    /**
100
-     * @param array $arguments
101
-     * @param int|string $date
102
-     * @return string
103
-     * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
104
-     */
105
-    public function formatDate(array $arguments, $date)
106
-    {
107
-        $format = $arguments['format'];
108
-        $base = $date;
109
-        if (is_string($base)) {
110
-            $base = trim($base);
111
-        }
112
-
113
-        if ($format === '') {
114
-            $format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d';
115
-        }
116
-
117
-        if (is_string($date)) {
118
-            $date = trim($date);
119
-        }
120
-
121
-        if ($date === '') {
122
-            $date = 'now';
123
-        }
124
-
125
-        if (!$date instanceof \DateTimeInterface) {
126
-            try {
127
-                $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base);
128
-                $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base);
129
-                $date = new \DateTime('@' . $dateTimestamp);
130
-                $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
131
-            } catch (\Exception $exception) {
132
-                throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579);
133
-            }
134
-        }
135
-
136
-        if (strpos($format, '%') !== false) {
137
-            return strftime($format, $date->format('U'));
138
-        } else {
139
-            return $date->format($format);
140
-        }
141
-    }
24
+	/**
25
+	 * Render a form footer.
26
+	 * Example:
27
+	 * Created on 30-12-12 by John Updated on 22-05-12 by Jane
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function render()
32
+	{
33
+		/** @var File $file */
34
+		$file = $this->templateVariableContainer->get('file');
35
+		$template = '<span>%s %s %s</span> <span style="padding-left: 50px">%s %s %s</span>';
36
+
37
+		$format = sprintf(
38
+			'%s @ %s',
39
+			$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],
40
+			$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']
41
+		);
42
+
43
+		$arguments = array(
44
+			'date' => null,
45
+			'format' => $format,
46
+			'base' => null
47
+		);
48
+
49
+		$result = sprintf(
50
+			$template,
51
+			LocalizationUtility::translate('created_on', 'media'),
52
+			$file->getProperty('crdate') ? $this->formatDate($arguments, $file->getProperty('crdate')) : '',
53
+			$this->getUserName($file->getProperty('cruser_id')),
54
+			LocalizationUtility::translate('updated_on', 'media'),
55
+			$file->getProperty('tstamp') ? $this->formatDate($arguments, '@' . $file->getProperty('tstamp')) : '',
56
+			$this->getUserName($file->getProperty('upuser_id'))
57
+		);
58
+
59
+		return $result;
60
+	}
61
+
62
+
63
+	/**
64
+	 * Get the User name to be displayed
65
+	 *
66
+	 * @param int $userIdentifier
67
+	 * @return string
68
+	 */
69
+	public function getUserName($userIdentifier)
70
+	{
71
+		$username = '';
72
+
73
+		if ($userIdentifier > 0) {
74
+			$record = $this->getDataService()
75
+				->getRecord(
76
+					'be_users',
77
+					[
78
+						'uid' => $userIdentifier
79
+					]
80
+				);
81
+			$username = sprintf(
82
+				'%s %s',
83
+				LocalizationUtility::translate('by', 'media'),
84
+				empty($record['realName']) ? $record['username'] : $record['realName']
85
+			);
86
+		}
87
+
88
+		return $username;
89
+	}
90
+
91
+	/**
92
+	 * @return object|DataService
93
+	 */
94
+	protected function getDataService(): DataService
95
+	{
96
+		return GeneralUtility::makeInstance(DataService::class);
97
+	}
98
+
99
+	/**
100
+	 * @param array $arguments
101
+	 * @param int|string $date
102
+	 * @return string
103
+	 * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
104
+	 */
105
+	public function formatDate(array $arguments, $date)
106
+	{
107
+		$format = $arguments['format'];
108
+		$base = $date;
109
+		if (is_string($base)) {
110
+			$base = trim($base);
111
+		}
112
+
113
+		if ($format === '') {
114
+			$format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d';
115
+		}
116
+
117
+		if (is_string($date)) {
118
+			$date = trim($date);
119
+		}
120
+
121
+		if ($date === '') {
122
+			$date = 'now';
123
+		}
124
+
125
+		if (!$date instanceof \DateTimeInterface) {
126
+			try {
127
+				$base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base);
128
+				$dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base);
129
+				$date = new \DateTime('@' . $dateTimestamp);
130
+				$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
131
+			} catch (\Exception $exception) {
132
+				throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579);
133
+			}
134
+		}
135
+
136
+		if (strpos($format, '%') !== false) {
137
+			return strftime($format, $date->format('U'));
138
+		} else {
139
+			return $date->format($format);
140
+		}
141
+	}
142 142
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $file->getProperty('crdate') ? $this->formatDate($arguments, $file->getProperty('crdate')) : '',
53 53
             $this->getUserName($file->getProperty('cruser_id')),
54 54
             LocalizationUtility::translate('updated_on', 'media'),
55
-            $file->getProperty('tstamp') ? $this->formatDate($arguments, '@' . $file->getProperty('tstamp')) : '',
55
+            $file->getProperty('tstamp') ? $this->formatDate($arguments, '@'.$file->getProperty('tstamp')) : '',
56 56
             $this->getUserName($file->getProperty('upuser_id'))
57 57
         );
58 58
 
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 
125 125
         if (!$date instanceof \DateTimeInterface) {
126 126
             try {
127
-                $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base);
128
-                $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base);
129
-                $date = new \DateTime('@' . $dateTimestamp);
127
+                $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '').$base);
128
+                $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '').$date, $base);
129
+                $date = new \DateTime('@'.$dateTimestamp);
130 130
                 $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
131 131
             } catch (\Exception $exception) {
132
-                throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579);
132
+                throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception('"'.$date.'" could not be parsed by \DateTime constructor: '.$exception->getMessage(), 1241722579);
133 133
             }
134 134
         }
135 135
 
Please login to merge, or discard this patch.
Classes/ViewHelpers/MetadataViewHelper.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -21,55 +21,55 @@
 block discarded – undo
21 21
  */
22 22
 class MetadataViewHelper extends AbstractViewHelper
23 23
 {
24
-    /**
25
-     * Returns metadata according to a template.
26
-     *
27
-     * @return string
28
-     */
29
-    public function render()
30
-    {
31
-        $file = $this->arguments['file'];
32
-        $template = $this->arguments['template'];
33
-        $metadataProperties = $this->arguments['metadataProperties'];
34
-        $configuration = $this->arguments['configuration'];
35
-        if (empty($template)) {
36
-            $template = $this->getDefaultTemplate($file);
37
-        }
38
-        $result = $template;
39
-        foreach ($metadataProperties as $metadataProperty) {
40
-            $value = $file->getProperty($metadataProperty);
41
-            if ($metadataProperty === 'size') {
42
-                $sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
43
-                $value = round($file->getSize() / $sizeUnit);
44
-            }
45
-            $result = str_replace('%' . $metadataProperty, $value, $result);
46
-        }
47
-        return $result;
48
-    }
24
+	/**
25
+	 * Returns metadata according to a template.
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function render()
30
+	{
31
+		$file = $this->arguments['file'];
32
+		$template = $this->arguments['template'];
33
+		$metadataProperties = $this->arguments['metadataProperties'];
34
+		$configuration = $this->arguments['configuration'];
35
+		if (empty($template)) {
36
+			$template = $this->getDefaultTemplate($file);
37
+		}
38
+		$result = $template;
39
+		foreach ($metadataProperties as $metadataProperty) {
40
+			$value = $file->getProperty($metadataProperty);
41
+			if ($metadataProperty === 'size') {
42
+				$sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
43
+				$value = round($file->getSize() / $sizeUnit);
44
+			}
45
+			$result = str_replace('%' . $metadataProperty, $value, $result);
46
+		}
47
+		return $result;
48
+	}
49 49
 
50
-    /**
51
-     * Returns a default template.
52
-     *
53
-     * @param File $file
54
-     * @return string
55
-     */
56
-    protected function getDefaultTemplate(File $file)
57
-    {
58
-        $template = '%size KB';
50
+	/**
51
+	 * Returns a default template.
52
+	 *
53
+	 * @param File $file
54
+	 * @return string
55
+	 */
56
+	protected function getDefaultTemplate(File $file)
57
+	{
58
+		$template = '%size KB';
59 59
 
60
-        if ($file->getType() == File::FILETYPE_IMAGE) {
61
-            $template = '%width x %height - ' . $template;
62
-        }
60
+		if ($file->getType() == File::FILETYPE_IMAGE) {
61
+			$template = '%width x %height - ' . $template;
62
+		}
63 63
 
64
-        return $template;
65
-    }
64
+		return $template;
65
+	}
66 66
 
67
-    public function initializeArguments(): void
68
-    {
69
-        parent::initializeArguments();
70
-        $this->registerArgument('file', File::class, '', true);
71
-        $this->registerArgument('template', 'string', '', false, '');
72
-        $this->registerArgument('metadataProperties', 'array', '', false, ['size', 'width', 'height']);
73
-        $this->registerArgument('configuration', 'array', '', false, []);
74
-    }
67
+	public function initializeArguments(): void
68
+	{
69
+		parent::initializeArguments();
70
+		$this->registerArgument('file', File::class, '', true);
71
+		$this->registerArgument('template', 'string', '', false, '');
72
+		$this->registerArgument('metadataProperties', 'array', '', false, ['size', 'width', 'height']);
73
+		$this->registerArgument('configuration', 'array', '', false, []);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 $sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
43 43
                 $value = round($file->getSize() / $sizeUnit);
44 44
             }
45
-            $result = str_replace('%' . $metadataProperty, $value, $result);
45
+            $result = str_replace('%'.$metadataProperty, $value, $result);
46 46
         }
47 47
         return $result;
48 48
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $template = '%size KB';
59 59
 
60 60
         if ($file->getType() == File::FILETYPE_IMAGE) {
61
-            $template = '%width x %height - ' . $template;
61
+            $template = '%width x %height - '.$template;
62 62
         }
63 63
 
64 64
         return $template;
Please login to merge, or discard this patch.
Classes/ViewHelpers/ImageDimensionViewHelper.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
  */
18 18
 class ImageDimensionViewHelper extends AbstractViewHelper
19 19
 {
20
-    /**
21
-     * @return void
22
-     */
23
-    public function initializeArguments()
24
-    {
25
-        $this->registerArgument('preset', 'string', '', true);
26
-        $this->registerArgument('dimension', 'string', '', false, 'width');
27
-    }
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function initializeArguments()
24
+	{
25
+		$this->registerArgument('preset', 'string', '', true);
26
+		$this->registerArgument('dimension', 'string', '', false, 'width');
27
+	}
28 28
 
29
-    /**
30
-     * Returns preset values related to an image dimension
31
-     *
32
-     * @return int
33
-     */
34
-    public function render()
35
-    {
36
-        $preset = $this->arguments['preset'];
37
-        $dimension = $this->arguments['dimension'];
29
+	/**
30
+	 * Returns preset values related to an image dimension
31
+	 *
32
+	 * @return int
33
+	 */
34
+	public function render()
35
+	{
36
+		$preset = $this->arguments['preset'];
37
+		$dimension = $this->arguments['dimension'];
38 38
 
39
-        $imageDimension = ImagePresetUtility::getInstance()->preset($preset);
40
-        if ($dimension === 'width') {
41
-            $result = $imageDimension->getWidth();
42
-        } else {
43
-            $result = $imageDimension->getHeight();
44
-        }
45
-        return $result;
46
-    }
39
+		$imageDimension = ImagePresetUtility::getInstance()->preset($preset);
40
+		if ($dimension === 'width') {
41
+			$result = $imageDimension->getWidth();
42
+		} else {
43
+			$result = $imageDimension->getHeight();
44
+		}
45
+		return $result;
46
+	}
47 47
 }
Please login to merge, or discard this patch.