Completed
Push — master ( ad447f...f2215d )
by Fabien
03:37 queued 48s
created
Classes/Tool/CacheWarmUpTool.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
      */
80 80
     protected function getWarmUpSemaphorFile()
81 81
     {
82
-        return PATH_site . 'typo3temp/.media_cache_warmed_up';
82
+        return PATH_site.'typo3temp/.media_cache_warmed_up';
83 83
     }
84 84
 
85 85
     /**
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -16,73 +16,73 @@
 block discarded – undo
16 16
 class CacheWarmUpTool extends AbstractTool
17 17
 {
18 18
 
19
-    /**
20
-     * Display the title of the tool on the welcome screen.
21
-     *
22
-     * @return string
23
-     */
24
-    public function getTitle()
25
-    {
26
-        return 'Cache warm up';
27
-    }
19
+	/**
20
+	 * Display the title of the tool on the welcome screen.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function getTitle()
25
+	{
26
+		return 'Cache warm up';
27
+	}
28 28
 
29
-    /**
30
-     * Display the description of the tool in the welcome screen.
31
-     *
32
-     * @return string
33
-     */
34
-    public function getDescription()
35
-    {
36
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
37
-        $view = $this->initializeStandaloneView($templateNameAndPath);
38
-        $view->assign('sitePath', PATH_site);
39
-        return $view->render();
40
-    }
29
+	/**
30
+	 * Display the description of the tool in the welcome screen.
31
+	 *
32
+	 * @return string
33
+	 */
34
+	public function getDescription()
35
+	{
36
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
37
+		$view = $this->initializeStandaloneView($templateNameAndPath);
38
+		$view->assign('sitePath', PATH_site);
39
+		return $view->render();
40
+	}
41 41
 
42
-    /**
43
-     * Do the job: warm up the cache.
44
-     *
45
-     * @param array $arguments
46
-     * @return string
47
-     */
48
-    public function work(array $arguments = [])
49
-    {
42
+	/**
43
+	 * Do the job: warm up the cache.
44
+	 *
45
+	 * @param array $arguments
46
+	 * @return string
47
+	 */
48
+	public function work(array $arguments = [])
49
+	{
50 50
 
51
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
52
-        $view = $this->initializeStandaloneView($templateNameAndPath);
51
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
52
+		$view = $this->initializeStandaloneView($templateNameAndPath);
53 53
 
54
-        $numberOfEntries = $this->getCacheService()->warmUp();
55
-        $view->assign('numberOfEntries', $numberOfEntries);
56
-        touch($this->getWarmUpSemaphorFile());
54
+		$numberOfEntries = $this->getCacheService()->warmUp();
55
+		$view->assign('numberOfEntries', $numberOfEntries);
56
+		touch($this->getWarmUpSemaphorFile());
57 57
 
58
-        return $view->render();
59
-    }
58
+		return $view->render();
59
+	}
60 60
 
61
-    /**
62
-     * Tell whether the tools should be displayed according to the context.
63
-     *
64
-     * @return bool
65
-     */
66
-    public function isShown()
67
-    {
68
-        return $this->getBackendUser()->isAdmin();
69
-    }
61
+	/**
62
+	 * Tell whether the tools should be displayed according to the context.
63
+	 *
64
+	 * @return bool
65
+	 */
66
+	public function isShown()
67
+	{
68
+		return $this->getBackendUser()->isAdmin();
69
+	}
70 70
 
71
-    /**
72
-     * @return string
73
-     */
74
-    protected function getWarmUpSemaphorFile()
75
-    {
76
-        return PATH_site . 'typo3temp/.media_cache_warmed_up';
77
-    }
71
+	/**
72
+	 * @return string
73
+	 */
74
+	protected function getWarmUpSemaphorFile()
75
+	{
76
+		return PATH_site . 'typo3temp/.media_cache_warmed_up';
77
+	}
78 78
 
79
-    /**
80
-     * @return \Fab\Media\Cache\CacheService|object
81
-     */
82
-    protected function getCacheService()
83
-    {
84
-        return GeneralUtility::makeInstance(\Fab\Media\Cache\CacheService::class);
85
-    }
79
+	/**
80
+	 * @return \Fab\Media\Cache\CacheService|object
81
+	 */
82
+	protected function getCacheService()
83
+	{
84
+		return GeneralUtility::makeInstance(\Fab\Media\Cache\CacheService::class);
85
+	}
86 86
 
87 87
 }
88 88
 
Please login to merge, or discard this patch.
Classes/Tool/MissingFilesFinderTool.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
                     // The case is special as we have a missing file in the file system
106 106
                     // As a result, we can't use $fileObject->delete(); which will
107 107
                     // raise exception "Error while fetching permissions"
108
-                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
108
+                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = '.$file->getUid());
109 109
                 }
110 110
             } catch (\Exception $e) {
111 111
                 continue;
Please login to merge, or discard this patch.
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -19,131 +19,131 @@
 block discarded – undo
19 19
 class MissingFilesFinderTool extends AbstractTool
20 20
 {
21 21
 
22
-    /**
23
-     * Display the title of the tool on the welcome screen.
24
-     *
25
-     * @return string
26
-     */
27
-    public function getTitle()
28
-    {
29
-        return 'Find missing files';
30
-    }
31
-
32
-    /**
33
-     * Display the description of the tool in the welcome screen.
34
-     *
35
-     * @return string
36
-     */
37
-    public function getDescription()
38
-    {
39
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/Launcher.html';
40
-        $view = $this->initializeStandaloneView($templateNameAndPath);
41
-        $view->assign('sitePath', PATH_site);
42
-        return $view->render();
43
-    }
44
-
45
-    /**
46
-     * Do the job: analyse Index.
47
-     *
48
-     * @param array $arguments
49
-     * @return string
50
-     */
51
-    public function work(array $arguments = [])
52
-    {
53
-
54
-        // Possible clean up of missing files if the User has clicked so.
55
-        if (!empty($arguments['deleteMissingFiles'])) {
56
-            $this->deleteMissingFilesAction($arguments['files']);
57
-        }
58
-
59
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/WorkResult.html';
60
-        $view = $this->initializeStandaloneView($templateNameAndPath);
61
-
62
-        $missingReports = [];
63
-        foreach ($this->getStorageRepository()->findAll() as $storage) {
64
-
65
-            if ($storage->isOnline()) {
66
-                $missingFiles = $this->getIndexAnalyser()->searchForMissingFiles($storage);
67
-
68
-                $missingReports[] = array(
69
-                    'storage' => $storage,
70
-                    'missingFiles' => $missingFiles,
71
-                    'numberOfMissingFiles' => count($missingFiles),
72
-                );
73
-            }
74
-        }
75
-
76
-        $view->assign('missingReports', $missingReports);
77
-
78
-        return $view->render();
79
-    }
80
-
81
-    /**
82
-     * Delete files given as parameter.
83
-     * This is a special case as we have a missing file in the file system
84
-     * As a result, we can't use $fileObject->delete(); which will
85
-     * raise exception "Error while fetching permissions".
86
-     *
87
-     * @param array $files
88
-     * @return void
89
-     */
90
-    protected function deleteMissingFilesAction(array $files = [])
91
-    {
92
-
93
-        foreach ($files as $fileUid) {
94
-
95
-            /** @var \TYPO3\CMS\Core\Resource\File $file */
96
-            try {
97
-                $file = ResourceFactory::getInstance()->getFileObject($fileUid);
98
-                if ($file) {
99
-                    // The case is special as we have a missing file in the file system
100
-                    // As a result, we can't use $fileObject->delete(); which will
101
-                    // raise exception "Error while fetching permissions"
102
-                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
103
-                }
104
-            } catch (\Exception $e) {
105
-                continue;
106
-            }
107
-        }
108
-    }
109
-
110
-    /**
111
-     * Return a pointer to the database.
112
-     *
113
-     * @return \Fab\Media\Index\IndexAnalyser|object
114
-     */
115
-    protected function getIndexAnalyser()
116
-    {
117
-        return GeneralUtility::makeInstance(\Fab\Media\Index\IndexAnalyser::class);
118
-    }
119
-
120
-    /**
121
-     * @return StorageRepository|object
122
-     */
123
-    protected function getStorageRepository()
124
-    {
125
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
126
-    }
127
-
128
-    /**
129
-     * Tell whether the tools should be displayed according to the context.
130
-     *
131
-     * @return bool
132
-     */
133
-    public function isShown()
134
-    {
135
-        return $this->getBackendUser()->isAdmin();
136
-    }
137
-
138
-    /**
139
-     * Return a pointer to the database.
140
-     *
141
-     * @return \Fab\Vidi\Database\DatabaseConnection
142
-     */
143
-    protected function getDatabaseConnection()
144
-    {
145
-        return $GLOBALS['TYPO3_DB'];
146
-    }
22
+	/**
23
+	 * Display the title of the tool on the welcome screen.
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function getTitle()
28
+	{
29
+		return 'Find missing files';
30
+	}
31
+
32
+	/**
33
+	 * Display the description of the tool in the welcome screen.
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function getDescription()
38
+	{
39
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/Launcher.html';
40
+		$view = $this->initializeStandaloneView($templateNameAndPath);
41
+		$view->assign('sitePath', PATH_site);
42
+		return $view->render();
43
+	}
44
+
45
+	/**
46
+	 * Do the job: analyse Index.
47
+	 *
48
+	 * @param array $arguments
49
+	 * @return string
50
+	 */
51
+	public function work(array $arguments = [])
52
+	{
53
+
54
+		// Possible clean up of missing files if the User has clicked so.
55
+		if (!empty($arguments['deleteMissingFiles'])) {
56
+			$this->deleteMissingFilesAction($arguments['files']);
57
+		}
58
+
59
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/WorkResult.html';
60
+		$view = $this->initializeStandaloneView($templateNameAndPath);
61
+
62
+		$missingReports = [];
63
+		foreach ($this->getStorageRepository()->findAll() as $storage) {
64
+
65
+			if ($storage->isOnline()) {
66
+				$missingFiles = $this->getIndexAnalyser()->searchForMissingFiles($storage);
67
+
68
+				$missingReports[] = array(
69
+					'storage' => $storage,
70
+					'missingFiles' => $missingFiles,
71
+					'numberOfMissingFiles' => count($missingFiles),
72
+				);
73
+			}
74
+		}
75
+
76
+		$view->assign('missingReports', $missingReports);
77
+
78
+		return $view->render();
79
+	}
80
+
81
+	/**
82
+	 * Delete files given as parameter.
83
+	 * This is a special case as we have a missing file in the file system
84
+	 * As a result, we can't use $fileObject->delete(); which will
85
+	 * raise exception "Error while fetching permissions".
86
+	 *
87
+	 * @param array $files
88
+	 * @return void
89
+	 */
90
+	protected function deleteMissingFilesAction(array $files = [])
91
+	{
92
+
93
+		foreach ($files as $fileUid) {
94
+
95
+			/** @var \TYPO3\CMS\Core\Resource\File $file */
96
+			try {
97
+				$file = ResourceFactory::getInstance()->getFileObject($fileUid);
98
+				if ($file) {
99
+					// The case is special as we have a missing file in the file system
100
+					// As a result, we can't use $fileObject->delete(); which will
101
+					// raise exception "Error while fetching permissions"
102
+					$this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
103
+				}
104
+			} catch (\Exception $e) {
105
+				continue;
106
+			}
107
+		}
108
+	}
109
+
110
+	/**
111
+	 * Return a pointer to the database.
112
+	 *
113
+	 * @return \Fab\Media\Index\IndexAnalyser|object
114
+	 */
115
+	protected function getIndexAnalyser()
116
+	{
117
+		return GeneralUtility::makeInstance(\Fab\Media\Index\IndexAnalyser::class);
118
+	}
119
+
120
+	/**
121
+	 * @return StorageRepository|object
122
+	 */
123
+	protected function getStorageRepository()
124
+	{
125
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
126
+	}
127
+
128
+	/**
129
+	 * Tell whether the tools should be displayed according to the context.
130
+	 *
131
+	 * @return bool
132
+	 */
133
+	public function isShown()
134
+	{
135
+		return $this->getBackendUser()->isAdmin();
136
+	}
137
+
138
+	/**
139
+	 * Return a pointer to the database.
140
+	 *
141
+	 * @return \Fab\Vidi\Database\DatabaseConnection
142
+	 */
143
+	protected function getDatabaseConnection()
144
+	{
145
+		return $GLOBALS['TYPO3_DB'];
146
+	}
147 147
 
148 148
 }
149 149
 
Please login to merge, or discard this patch.
Classes/Tool/ThumbnailGeneratorTool.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
                         $formattedResultSet[] = sprintf('* File "%s": %s %s',
86 86
                             $result['fileUid'],
87 87
                             $result['fileIdentifier'],
88
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
88
+                            empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri']
89 89
                         );
90 90
                     }
91 91
 
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -18,135 +18,135 @@
 block discarded – undo
18 18
 class ThumbnailGeneratorTool extends AbstractTool
19 19
 {
20 20
 
21
-    /**
22
-     * Display the title of the tool on the welcome screen.
23
-     *
24
-     * @return string
25
-     */
26
-    public function getTitle()
27
-    {
28
-        return 'Generate thumbnails';
29
-    }
30
-
31
-    /**
32
-     * Display the description of the tool in the welcome screen.
33
-     *
34
-     * @return string
35
-     */
36
-    public function getDescription()
37
-    {
38
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
39
-        $view = $this->initializeStandaloneView($templateNameAndPath);
40
-        $view->assign('sitePath', PATH_site);
41
-        return $view->render();
42
-    }
43
-
44
-    /**
45
-     * Do the job: analyse Index.
46
-     *
47
-     * @param array $arguments
48
-     * @return string
49
-     */
50
-    public function work(array $arguments = [])
51
-    {
52
-
53
-        $reports = [];
54
-
55
-        $limit = 500; // default value
56
-        $newOffset = 0;
57
-
58
-        // Possible clean up of missing files if the User has clicked so.
59
-        if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
-
61
-            $limit = (int)$arguments['limit'];
62
-            $offset = (int)$arguments['offset'];
63
-
64
-            foreach ($this->getStorageRepository()->findAll() as $storage) {
65
-
66
-                if ($storage->isOnline()) {
67
-
68
-                    $thumbnailGenerator = $this->getThumbnailGenerator();
69
-                    $thumbnailGenerator
70
-                        ->setStorage($storage)
71
-                        ->generate($limit, $offset);
72
-
73
-                    $formattedResultSet = [];
74
-                    $resultSet = $thumbnailGenerator->getResultSet();
75
-                    $processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
76
-
77
-                    foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
78
-                        $result = $resultSet[$fileIdentifier];
79
-                        $formattedResultSet[] = sprintf('* File "%s": %s %s',
80
-                            $result['fileUid'],
81
-                            $result['fileIdentifier'],
82
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
83
-                        );
84
-                    }
85
-
86
-                    $reports[] = array(
87
-                        'storage' => $storage,
88
-                        'isStorageOnline' => true,
89
-                        'resultSet' => $formattedResultSet,
90
-                        'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
91
-                        'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
92
-                        'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
93
-                        'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
94
-                    );
95
-                } else {
96
-                    $reports[] = array(
97
-                        'storage' => $storage,
98
-                        'isStorageOnline' => false,
99
-                    );
100
-                }
101
-            }
102
-
103
-            $newOffset = $limit + $offset;
104
-        }
105
-
106
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
107
-        $view = $this->initializeStandaloneView($templateNameAndPath);
108
-
109
-        $view->assign('limit', $limit);
110
-        $view->assign('offset', $newOffset);
111
-        $view->assign('reports', $reports);
112
-        return $view->render();
113
-    }
114
-
115
-    /**
116
-     * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
117
-     */
118
-    protected function getThumbnailGenerator()
119
-    {
120
-        return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
121
-    }
122
-
123
-    /**
124
-     * @return StorageRepository|object
125
-     */
126
-    protected function getStorageRepository()
127
-    {
128
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
129
-    }
130
-
131
-    /**
132
-     * Tell whether the tools should be displayed according to the context.
133
-     *
134
-     * @return bool
135
-     */
136
-    public function isShown()
137
-    {
138
-        return $this->getBackendUser()->isAdmin();
139
-    }
140
-
141
-    /**
142
-     * Return a pointer to the database.
143
-     *
144
-     * @return \Fab\Vidi\Database\DatabaseConnection
145
-     */
146
-    protected function getDatabaseConnection()
147
-    {
148
-        return $GLOBALS['TYPO3_DB'];
149
-    }
21
+	/**
22
+	 * Display the title of the tool on the welcome screen.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function getTitle()
27
+	{
28
+		return 'Generate thumbnails';
29
+	}
30
+
31
+	/**
32
+	 * Display the description of the tool in the welcome screen.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function getDescription()
37
+	{
38
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
39
+		$view = $this->initializeStandaloneView($templateNameAndPath);
40
+		$view->assign('sitePath', PATH_site);
41
+		return $view->render();
42
+	}
43
+
44
+	/**
45
+	 * Do the job: analyse Index.
46
+	 *
47
+	 * @param array $arguments
48
+	 * @return string
49
+	 */
50
+	public function work(array $arguments = [])
51
+	{
52
+
53
+		$reports = [];
54
+
55
+		$limit = 500; // default value
56
+		$newOffset = 0;
57
+
58
+		// Possible clean up of missing files if the User has clicked so.
59
+		if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
+
61
+			$limit = (int)$arguments['limit'];
62
+			$offset = (int)$arguments['offset'];
63
+
64
+			foreach ($this->getStorageRepository()->findAll() as $storage) {
65
+
66
+				if ($storage->isOnline()) {
67
+
68
+					$thumbnailGenerator = $this->getThumbnailGenerator();
69
+					$thumbnailGenerator
70
+						->setStorage($storage)
71
+						->generate($limit, $offset);
72
+
73
+					$formattedResultSet = [];
74
+					$resultSet = $thumbnailGenerator->getResultSet();
75
+					$processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
76
+
77
+					foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
78
+						$result = $resultSet[$fileIdentifier];
79
+						$formattedResultSet[] = sprintf('* File "%s": %s %s',
80
+							$result['fileUid'],
81
+							$result['fileIdentifier'],
82
+							empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
83
+						);
84
+					}
85
+
86
+					$reports[] = array(
87
+						'storage' => $storage,
88
+						'isStorageOnline' => true,
89
+						'resultSet' => $formattedResultSet,
90
+						'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
91
+						'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
92
+						'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
93
+						'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
94
+					);
95
+				} else {
96
+					$reports[] = array(
97
+						'storage' => $storage,
98
+						'isStorageOnline' => false,
99
+					);
100
+				}
101
+			}
102
+
103
+			$newOffset = $limit + $offset;
104
+		}
105
+
106
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
107
+		$view = $this->initializeStandaloneView($templateNameAndPath);
108
+
109
+		$view->assign('limit', $limit);
110
+		$view->assign('offset', $newOffset);
111
+		$view->assign('reports', $reports);
112
+		return $view->render();
113
+	}
114
+
115
+	/**
116
+	 * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
117
+	 */
118
+	protected function getThumbnailGenerator()
119
+	{
120
+		return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
121
+	}
122
+
123
+	/**
124
+	 * @return StorageRepository|object
125
+	 */
126
+	protected function getStorageRepository()
127
+	{
128
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
129
+	}
130
+
131
+	/**
132
+	 * Tell whether the tools should be displayed according to the context.
133
+	 *
134
+	 * @return bool
135
+	 */
136
+	public function isShown()
137
+	{
138
+		return $this->getBackendUser()->isAdmin();
139
+	}
140
+
141
+	/**
142
+	 * Return a pointer to the database.
143
+	 *
144
+	 * @return \Fab\Vidi\Database\DatabaseConnection
145
+	 */
146
+	protected function getDatabaseConnection()
147
+	{
148
+		return $GLOBALS['TYPO3_DB'];
149
+	}
150 150
 
151 151
 }
152 152
 
Please login to merge, or discard this patch.
Classes/Tool/DuplicateFilesFinderTool.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
                             foreach ($allowedMountPoints as $allowedMountPoint) {
113 113
 
114
-                                $pattern = '%^' . $allowedMountPoint . '%isU';
114
+                                $pattern = '%^'.$allowedMountPoint.'%isU';
115 115
                                 if (preg_match($pattern, $file['identifier'])) {
116 116
                                     $filteredFiles[] = $file;
117 117
                                     break; // no need to further loop around, stop the loop.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                         $file->delete();
166 166
                     }
167 167
                 } else {
168
-                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
168
+                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = '.$file->getUid());
169 169
                 }
170 170
             } catch (\Exception $e) {
171 171
                 continue;
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -18,208 +18,208 @@
 block discarded – undo
18 18
 class DuplicateFilesFinderTool extends AbstractTool
19 19
 {
20 20
 
21
-    /**
22
-     * Display the title of the tool on the welcome screen.
23
-     *
24
-     * @return string
25
-     */
26
-    public function getTitle()
27
-    {
28
-        return 'Find duplicate Files';
29
-    }
30
-
31
-    /**
32
-     * Display the description of the tool in the welcome screen.
33
-     *
34
-     * @return string
35
-     */
36
-    public function getDescription()
37
-    {
38
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/Launcher.html';
39
-        $view = $this->initializeStandaloneView($templateNameAndPath);
40
-        $view->assign('isAdmin', $this->getBackendUser()->isAdmin());
41
-        $view->assign('sitePath', PATH_site);
42
-        return $view->render();
43
-    }
44
-
45
-    /**
46
-     * Do the job: analyse Index.
47
-     *
48
-     * @param array $arguments
49
-     * @return string
50
-     */
51
-    public function work(array $arguments = [])
52
-    {
53
-
54
-        // Possible clean up of missing files if the User has clicked so.
55
-        if (!empty($arguments['deleteDuplicateFiles'])) {
56
-            $this->deleteMissingFilesAction($arguments['files']);
57
-        }
58
-
59
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/WorkResult.html';
60
-        $view = $this->initializeStandaloneView($templateNameAndPath);
61
-
62
-        $duplicateFilesReports = [];
63
-
64
-        if ($this->getBackendUser()->isAdmin()) {
65
-            foreach ($this->getStorageRepository()->findAll() as $storage) {
66
-                if ($storage->isOnline()) {
67
-                    $duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
68
-                    $duplicateFilesReports[] = array(
69
-                        'storage' => $storage,
70
-                        'duplicateFiles' => $duplicateFiles,
71
-                        'numberOfDuplicateFiles' => count($duplicateFiles),
72
-                    );
73
-                }
74
-            }
75
-        } else {
76
-
77
-            $fileMounts = $this->getBackendUser()->getFileMountRecords();
78
-
79
-            $allowedStorages = [];
80
-            foreach ($fileMounts as $fileMount) {
81
-                if ((bool)$fileMount['read_only']) {
82
-                    continue;
83
-                }
84
-
85
-                if (!isset($allowedStorages[$fileMount['base']])) {
86
-                    $allowedStorages[$fileMount['base']] = [];
87
-                }
88
-                if (!in_array($fileMount['base'], $allowedStorages)) {
89
-                    $allowedStorages[$fileMount['base']][] = $fileMount['path'];
90
-                }
91
-            }
92
-
93
-            foreach ($allowedStorages as $storageIdentifier => $allowedMountPoints) {
94
-                $storage = ResourceFactory::getInstance()->getStorageObject($storageIdentifier);
95
-
96
-                if ($storage->isOnline()) {
97
-
98
-                    $duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
99
-
100
-                    // Filter duplicates files
101
-                    foreach ($duplicateFiles as $key => $files) {
102
-
103
-                        $filteredFiles = [];
104
-                        foreach ($files as $file) {
105
-
106
-                            foreach ($allowedMountPoints as $allowedMountPoint) {
107
-
108
-                                $pattern = '%^' . $allowedMountPoint . '%isU';
109
-                                if (preg_match($pattern, $file['identifier'])) {
110
-                                    $filteredFiles[] = $file;
111
-                                    break; // no need to further loop around, stop the loop.
112
-                                }
113
-                            }
114
-                        }
115
-
116
-                        // We need more than 1 files to be shown as duplicate.
117
-                        if (count($filteredFiles) > 1) {
118
-                            $duplicateFiles[$key] = $filteredFiles;
119
-                        } else {
120
-                            unset($duplicateFiles[$key]);
121
-                        }
122
-                    }
123
-                    $duplicateFilesReports[] = array(
124
-                        'storage' => $storage,
125
-                        'duplicateFiles' => $duplicateFiles,
126
-                        'numberOfDuplicateFiles' => count($duplicateFiles),
127
-                    );
128
-
129
-                }
130
-            }
131
-        }
132
-
133
-        $view->assign('duplicateFilesReports', $duplicateFilesReports);
134
-
135
-        return $view->render();
136
-    }
137
-
138
-    /**
139
-     * Delete files given as parameter.
140
-     * This is a special case as we have a missing file in the file system
141
-     * As a result, we can't use $fileObject->delete(); which will
142
-     * raise exception "Error while fetching permissions".
143
-     *
144
-     * @param array $files
145
-     * @return void
146
-     */
147
-    protected function deleteMissingFilesAction(array $files = [])
148
-    {
149
-
150
-        foreach ($files as $fileUid) {
151
-
152
-            /** @var \TYPO3\CMS\Core\Resource\File $file */
153
-            try {
154
-                $file = ResourceFactory::getInstance()->getFileObject($fileUid);
155
-                if ($file->exists()) {
156
-
157
-                    $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
158
-                    if ($numberOfReferences === 0) {
159
-                        $file->delete();
160
-                    }
161
-                } else {
162
-                    $this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
163
-                }
164
-            } catch (\Exception $e) {
165
-                continue;
166
-            }
167
-        }
168
-    }
169
-
170
-    /**
171
-     * Return a pointer to the database.
172
-     *
173
-     * @return \Fab\Media\Index\IndexAnalyser|object
174
-     */
175
-    protected function getIndexAnalyser()
176
-    {
177
-        return GeneralUtility::makeInstance(\Fab\Media\Index\IndexAnalyser::class);
178
-    }
179
-
180
-    /**
181
-     * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
182
-     */
183
-    protected function getThumbnailGenerator()
184
-    {
185
-        return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
186
-    }
187
-
188
-    /**
189
-     * @return StorageRepository|object
190
-     */
191
-    protected function getStorageRepository()
192
-    {
193
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
194
-    }
195
-
196
-    /**
197
-     * Tell whether the tools should be displayed according to the context.
198
-     *
199
-     * @return bool
200
-     */
201
-    public function isShown()
202
-    {
203
-        return true;
204
-    }
205
-
206
-    /**
207
-     * @return \Fab\Media\Resource\FileReferenceService|object
208
-     */
209
-    protected function getFileReferenceService()
210
-    {
211
-        return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class);
212
-    }
213
-
214
-    /**
215
-     * Return a pointer to the database.
216
-     *
217
-     * @return \Fab\Vidi\Database\DatabaseConnection
218
-     */
219
-    protected function getDatabaseConnection()
220
-    {
221
-        return $GLOBALS['TYPO3_DB'];
222
-    }
21
+	/**
22
+	 * Display the title of the tool on the welcome screen.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function getTitle()
27
+	{
28
+		return 'Find duplicate Files';
29
+	}
30
+
31
+	/**
32
+	 * Display the description of the tool in the welcome screen.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function getDescription()
37
+	{
38
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/Launcher.html';
39
+		$view = $this->initializeStandaloneView($templateNameAndPath);
40
+		$view->assign('isAdmin', $this->getBackendUser()->isAdmin());
41
+		$view->assign('sitePath', PATH_site);
42
+		return $view->render();
43
+	}
44
+
45
+	/**
46
+	 * Do the job: analyse Index.
47
+	 *
48
+	 * @param array $arguments
49
+	 * @return string
50
+	 */
51
+	public function work(array $arguments = [])
52
+	{
53
+
54
+		// Possible clean up of missing files if the User has clicked so.
55
+		if (!empty($arguments['deleteDuplicateFiles'])) {
56
+			$this->deleteMissingFilesAction($arguments['files']);
57
+		}
58
+
59
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/WorkResult.html';
60
+		$view = $this->initializeStandaloneView($templateNameAndPath);
61
+
62
+		$duplicateFilesReports = [];
63
+
64
+		if ($this->getBackendUser()->isAdmin()) {
65
+			foreach ($this->getStorageRepository()->findAll() as $storage) {
66
+				if ($storage->isOnline()) {
67
+					$duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
68
+					$duplicateFilesReports[] = array(
69
+						'storage' => $storage,
70
+						'duplicateFiles' => $duplicateFiles,
71
+						'numberOfDuplicateFiles' => count($duplicateFiles),
72
+					);
73
+				}
74
+			}
75
+		} else {
76
+
77
+			$fileMounts = $this->getBackendUser()->getFileMountRecords();
78
+
79
+			$allowedStorages = [];
80
+			foreach ($fileMounts as $fileMount) {
81
+				if ((bool)$fileMount['read_only']) {
82
+					continue;
83
+				}
84
+
85
+				if (!isset($allowedStorages[$fileMount['base']])) {
86
+					$allowedStorages[$fileMount['base']] = [];
87
+				}
88
+				if (!in_array($fileMount['base'], $allowedStorages)) {
89
+					$allowedStorages[$fileMount['base']][] = $fileMount['path'];
90
+				}
91
+			}
92
+
93
+			foreach ($allowedStorages as $storageIdentifier => $allowedMountPoints) {
94
+				$storage = ResourceFactory::getInstance()->getStorageObject($storageIdentifier);
95
+
96
+				if ($storage->isOnline()) {
97
+
98
+					$duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
99
+
100
+					// Filter duplicates files
101
+					foreach ($duplicateFiles as $key => $files) {
102
+
103
+						$filteredFiles = [];
104
+						foreach ($files as $file) {
105
+
106
+							foreach ($allowedMountPoints as $allowedMountPoint) {
107
+
108
+								$pattern = '%^' . $allowedMountPoint . '%isU';
109
+								if (preg_match($pattern, $file['identifier'])) {
110
+									$filteredFiles[] = $file;
111
+									break; // no need to further loop around, stop the loop.
112
+								}
113
+							}
114
+						}
115
+
116
+						// We need more than 1 files to be shown as duplicate.
117
+						if (count($filteredFiles) > 1) {
118
+							$duplicateFiles[$key] = $filteredFiles;
119
+						} else {
120
+							unset($duplicateFiles[$key]);
121
+						}
122
+					}
123
+					$duplicateFilesReports[] = array(
124
+						'storage' => $storage,
125
+						'duplicateFiles' => $duplicateFiles,
126
+						'numberOfDuplicateFiles' => count($duplicateFiles),
127
+					);
128
+
129
+				}
130
+			}
131
+		}
132
+
133
+		$view->assign('duplicateFilesReports', $duplicateFilesReports);
134
+
135
+		return $view->render();
136
+	}
137
+
138
+	/**
139
+	 * Delete files given as parameter.
140
+	 * This is a special case as we have a missing file in the file system
141
+	 * As a result, we can't use $fileObject->delete(); which will
142
+	 * raise exception "Error while fetching permissions".
143
+	 *
144
+	 * @param array $files
145
+	 * @return void
146
+	 */
147
+	protected function deleteMissingFilesAction(array $files = [])
148
+	{
149
+
150
+		foreach ($files as $fileUid) {
151
+
152
+			/** @var \TYPO3\CMS\Core\Resource\File $file */
153
+			try {
154
+				$file = ResourceFactory::getInstance()->getFileObject($fileUid);
155
+				if ($file->exists()) {
156
+
157
+					$numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
158
+					if ($numberOfReferences === 0) {
159
+						$file->delete();
160
+					}
161
+				} else {
162
+					$this->getDatabaseConnection()->exec_DELETEquery('sys_file', 'uid = ' . $file->getUid());
163
+				}
164
+			} catch (\Exception $e) {
165
+				continue;
166
+			}
167
+		}
168
+	}
169
+
170
+	/**
171
+	 * Return a pointer to the database.
172
+	 *
173
+	 * @return \Fab\Media\Index\IndexAnalyser|object
174
+	 */
175
+	protected function getIndexAnalyser()
176
+	{
177
+		return GeneralUtility::makeInstance(\Fab\Media\Index\IndexAnalyser::class);
178
+	}
179
+
180
+	/**
181
+	 * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object
182
+	 */
183
+	protected function getThumbnailGenerator()
184
+	{
185
+		return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class);
186
+	}
187
+
188
+	/**
189
+	 * @return StorageRepository|object
190
+	 */
191
+	protected function getStorageRepository()
192
+	{
193
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
194
+	}
195
+
196
+	/**
197
+	 * Tell whether the tools should be displayed according to the context.
198
+	 *
199
+	 * @return bool
200
+	 */
201
+	public function isShown()
202
+	{
203
+		return true;
204
+	}
205
+
206
+	/**
207
+	 * @return \Fab\Media\Resource\FileReferenceService|object
208
+	 */
209
+	protected function getFileReferenceService()
210
+	{
211
+		return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class);
212
+	}
213
+
214
+	/**
215
+	 * Return a pointer to the database.
216
+	 *
217
+	 * @return \Fab\Vidi\Database\DatabaseConnection
218
+	 */
219
+	protected function getDatabaseConnection()
220
+	{
221
+		return $GLOBALS['TYPO3_DB'];
222
+	}
223 223
 
224 224
 }
225 225
 
Please login to merge, or discard this patch.
Classes/Form/FileUploadTceForms.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
         // Get the base prefix.
43 43
         $basePrefix = $this->getBasePrefix($this->getPrefix());
44
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
44
+        $filePath = ExtensionManagementUtility::extPath('media').'Resources/Private/Standalone/FileUploadTceForms.js';
45 45
 
46 46
         return sprintf(file_get_contents($filePath),
47 47
             $basePrefix,
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -20,64 +20,64 @@
 block discarded – undo
20 20
 class FileUploadTceForms extends FileUpload
21 21
 {
22 22
 
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $templateFile = 'Resources/Private/Standalone/FileUploadTceFormsTemplate.html';
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $templateFile = 'Resources/Private/Standalone/FileUploadTceFormsTemplate.html';
27 27
 
28
-    /**
29
-     * Fetch the JavaScript to be rendered and replace the markers with "live" variables.
30
-     *
31
-     * @return string
32
-     */
33
-    protected function getJavaScript()
34
-    {
28
+	/**
29
+	 * Fetch the JavaScript to be rendered and replace the markers with "live" variables.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	protected function getJavaScript()
34
+	{
35 35
 
36
-        // Get the base prefix.
37
-        $basePrefix = $this->getBasePrefix($this->getPrefix());
38
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
36
+		// Get the base prefix.
37
+		$basePrefix = $this->getBasePrefix($this->getPrefix());
38
+		$filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUploadTceForms.js';
39 39
 
40
-        return sprintf(file_get_contents($filePath),
41
-            $basePrefix,
42
-            $this->elementId,
43
-            $this->getModuleUrl(),
44
-            $this->getAllowedExtension(),
45
-            GeneralUtility::getMaxUploadFileSize() * 1024,
46
-            $this->getValue()
47
-        );
48
-    }
40
+		return sprintf(file_get_contents($filePath),
41
+			$basePrefix,
42
+			$this->elementId,
43
+			$this->getModuleUrl(),
44
+			$this->getAllowedExtension(),
45
+			GeneralUtility::getMaxUploadFileSize() * 1024,
46
+			$this->getValue()
47
+		);
48
+	}
49 49
 
50
-    /**
51
-     * @return string
52
-     */
53
-    protected function getModuleUrl()
54
-    {
55
-        $moduleSignature = MediaModule::getSignature();
56
-        return BackendUtility::getModuleUrl($moduleSignature);
57
-    }
50
+	/**
51
+	 * @return string
52
+	 */
53
+	protected function getModuleUrl()
54
+	{
55
+		$moduleSignature = MediaModule::getSignature();
56
+		return BackendUtility::getModuleUrl($moduleSignature);
57
+	}
58 58
 
59
-    /**
60
-     * Get allowed extension.
61
-     *
62
-     * @return string
63
-     */
64
-    protected function getAllowedExtension()
65
-    {
66
-        return $this->file->getExtension();
67
-    }
59
+	/**
60
+	 * Get allowed extension.
61
+	 *
62
+	 * @return string
63
+	 */
64
+	protected function getAllowedExtension()
65
+	{
66
+		return $this->file->getExtension();
67
+	}
68 68
 
69
-    /**
70
-     * Returns additional file info.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function getFileInfo()
75
-    {
76
-        /** @var \Fab\Media\ViewHelpers\MetadataViewHelper $metadataViewHelper */
77
-        $metadataViewHelper = GeneralUtility::makeInstance(\Fab\Media\ViewHelpers\MetadataViewHelper::class);
69
+	/**
70
+	 * Returns additional file info.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function getFileInfo()
75
+	{
76
+		/** @var \Fab\Media\ViewHelpers\MetadataViewHelper $metadataViewHelper */
77
+		$metadataViewHelper = GeneralUtility::makeInstance(\Fab\Media\ViewHelpers\MetadataViewHelper::class);
78 78
 
79
-        return sprintf('<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
80
-            $metadataViewHelper->render($this->file)
81
-        );
82
-    }
79
+		return sprintf('<div class="container-fileInfo" style="font-size: 7pt; color: #777;">%s</div>',
80
+			$metadataViewHelper->render($this->file)
81
+		);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Classes/Form/FileUpload.php 2 patches
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function __construct()
52 52
     {
53 53
         $this->addLanguage();
54
-        $this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
54
+        $this->elementId = 'jquery-wrapped-fine-uploader-'.uniqid();
55 55
 
56 56
         $this->template = <<<EOF
57 57
 <div class="control-group control-group-upload" style="%s">
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         /** @var PageRenderer $pageRenderer */
76 76
         $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
77
-        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
77
+        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media').'Resources/Private/Language/locallang.xlf', 'media_file_upload');
78 78
     }
79 79
 
80 80
     /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
162 162
         $view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
163 163
 
164
-        $templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
164
+        $templatePathAndFilename = ExtensionManagementUtility::extPath('media').$this->templateFile;
165 165
         $view->setTemplatePathAndFilename($templatePathAndFilename);
166 166
 
167 167
         return $view;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         // Get the base prefix
179 179
         $basePrefix = $this->getBasePrefix($this->getPrefix());
180 180
 
181
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
181
+        $filePath = ExtensionManagementUtility::extPath('media').'Resources/Private/Standalone/FileUpload.js';
182 182
 
183 183
         return sprintf(
184 184
             file_get_contents($filePath),
@@ -188,8 +188,7 @@  discard block
 block discarded – undo
188 188
             $this->getAllowedExtensions(),
189 189
             GeneralUtility::getMaxUploadFileSize() * 1024,
190 190
             $this->isDrivenByFolder() ?
191
-                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
192
-                $this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
191
+                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() : $this->getMediaModule()->getCurrentStorage()->getUid().':/'
193 192
 
194 193
         );
195 194
     }
Please login to merge, or discard this patch.
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -24,30 +24,30 @@  discard block
 block discarded – undo
24 24
 class FileUpload extends AbstractFormField
25 25
 {
26 26
 
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $elementId;
31
-
32
-    /**
33
-     * @var \TYPO3\CMS\Core\Resource\File
34
-     */
35
-    protected $file;
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected $templateFile = 'Resources/Private/Standalone/FileUploadTemplate.html';
41
-
42
-    /**
43
-     * @return \Fab\Media\Form\FileUpload
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->addLanguage();
48
-        $this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
49
-
50
-        $this->template = <<<EOF
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $elementId;
31
+
32
+	/**
33
+	 * @var \TYPO3\CMS\Core\Resource\File
34
+	 */
35
+	protected $file;
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected $templateFile = 'Resources/Private/Standalone/FileUploadTemplate.html';
41
+
42
+	/**
43
+	 * @return \Fab\Media\Form\FileUpload
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->addLanguage();
48
+		$this->elementId = 'jquery-wrapped-fine-uploader-' . uniqid();
49
+
50
+		$this->template = <<<EOF
51 51
 <div class="control-group control-group-upload" style="%s">
52 52
     <div class="container-thumbnail">%s</div>
53 53
     %s
@@ -59,213 +59,213 @@  discard block
 block discarded – undo
59 59
 </div>
60 60
 
61 61
 EOF;
62
-    }
63
-
64
-    /**
65
-     * Add language labels for JavaScript files
66
-     */
67
-    protected function addLanguage()
68
-    {
69
-        /** @var PageRenderer $pageRenderer */
70
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71
-        $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
72
-    }
73
-
74
-    /**
75
-     * Render a file upload field.
76
-     *
77
-     * @throws \Fab\Media\Exception\EmptyPropertyException
78
-     * @return string
79
-     */
80
-    public function render()
81
-    {
82
-
83
-        // Instantiate the file object for the whole class if possible.
84
-        if ($this->getValue()) {
85
-            $this->file = ResourceFactory::getInstance()->getFileObject($this->getValue());
86
-        }
87
-
88
-        $result = sprintf(
89
-            $this->template,
90
-            $this->getInlineStyle(),
91
-            $this->getThumbnail(),
92
-            $this->getFileInfo(),
93
-            $this->elementId,
94
-            $this->getJavaScriptTemplate(),
95
-            $this->getJavaScript()
96
-        );
97
-        return $result;
98
-    }
99
-
100
-    /**
101
-     * @return string
102
-     */
103
-    protected function getInlineStyle()
104
-    {
105
-        $style = 'float: left';
106
-        if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
107
-            $style .= '; padding-left: 3px';
108
-        }
109
-        return $style;
110
-    }
111
-
112
-    /**
113
-     * Get the javascript from a file and replace the markers with live variables.
114
-     *
115
-     * @return string
116
-     */
117
-    protected function getThumbnail()
118
-    {
119
-        $thumbnail = '';
120
-        if ($this->file) {
121
-
122
-            /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
123
-            $thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $this->file);
124
-            $thumbnail = $thumbnailService
125
-                ->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
126
-                ->setAppendTimeStamp(true)
127
-                ->create();
128
-        }
129
-        return $thumbnail;
130
-    }
131
-
132
-    /**
133
-     * Get the javascript from a file and replace the markers with live variables.
134
-     *
135
-     * @return string
136
-     */
137
-    protected function getJavaScriptTemplate()
138
-    {
139
-        $view = $this->getStandaloneView();
140
-        $view->assignMultiple(
141
-            array(
142
-                'maximumUploadLabel' => $this->getMaximumUploadLabel(),
143
-            )
144
-        );
145
-        return $view->render();
146
-    }
147
-
148
-    /**
149
-     * @return \TYPO3\CMS\Fluid\View\StandaloneView
150
-     */
151
-    protected function getStandaloneView()
152
-    {
153
-        $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
154
-
155
-        /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
156
-        $view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
157
-
158
-        $templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
159
-        $view->setTemplatePathAndFilename($templatePathAndFilename);
160
-
161
-        return $view;
162
-    }
163
-
164
-    /**
165
-     * Get the javascript from a file and replace the markers with live variables.
166
-     *
167
-     * @return string
168
-     */
169
-    protected function getJavaScript()
170
-    {
171
-
172
-        // Get the base prefix
173
-        $basePrefix = $this->getBasePrefix($this->getPrefix());
174
-
175
-        $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
176
-
177
-        return sprintf(
178
-            file_get_contents($filePath),
179
-            $basePrefix,
180
-            $this->elementId,
181
-            $this->getModuleUrl(),
182
-            $this->getAllowedExtensions(),
183
-            GeneralUtility::getMaxUploadFileSize() * 1024,
184
-            $this->isDrivenByFolder() ?
185
-                $this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
186
-                $this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
187
-
188
-        );
189
-    }
190
-
191
-    /**
192
-     * @return bool
193
-     */
194
-    protected function isDrivenByFolder()
195
-    {
196
-        return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin();
197
-    }
198
-
199
-    /**
200
-     * @return string
201
-     */
202
-    protected function getModuleUrl()
203
-    {
204
-        $moduleSignature = MediaModule::getSignature();
205
-        return BackendUtility::getModuleUrl($moduleSignature);
206
-    }
207
-
208
-    /**
209
-     * Returns the max upload file size in Mo.
210
-     *
211
-     * @return string
212
-     */
213
-    protected function getMaximumUploadLabel()
214
-    {
215
-        $result = round(GeneralUtility::getMaxUploadFileSize() / 1024, 2);
216
-        $label = LocalizationUtility::translate('max_upload_file', 'media');
217
-        $result = sprintf($label, $result);
218
-        return $result;
219
-    }
220
-
221
-    /**
222
-     * Get allowed extension.
223
-     *
224
-     * @return string
225
-     */
226
-    protected function getAllowedExtensions()
227
-    {
228
-        return implode("','", PermissionUtility::getInstance()->getAllowedExtensions());
229
-    }
230
-
231
-    /**
232
-     * Compute the base prefix by removing the square brackets.
233
-     *
234
-     * @param string $prefix
235
-     * @return string
236
-     */
237
-    protected function getBasePrefix($prefix)
238
-    {
239
-        $parts = explode('[', $prefix);
240
-        return empty($parts) ? '' : $parts[0];
241
-    }
242
-
243
-    /**
244
-     * Returns additional file info.
245
-     *
246
-     * @return string
247
-     */
248
-    protected function getFileInfo()
249
-    {
250
-        return ''; // empty return here but check out Tceforms/FileUpload
251
-    }
252
-
253
-    /**
254
-     * @return MediaModule|object
255
-     */
256
-    protected function getMediaModule()
257
-    {
258
-        return GeneralUtility::makeInstance(MediaModule::class);
259
-    }
260
-
261
-    /**
262
-     * Get the Vidi Module Loader.
263
-     *
264
-     * @return \Fab\Vidi\Module\ModuleLoader|object
265
-     */
266
-    protected function getModuleLoader()
267
-    {
268
-        return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class);
269
-    }
62
+	}
63
+
64
+	/**
65
+	 * Add language labels for JavaScript files
66
+	 */
67
+	protected function addLanguage()
68
+	{
69
+		/** @var PageRenderer $pageRenderer */
70
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71
+		$pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload');
72
+	}
73
+
74
+	/**
75
+	 * Render a file upload field.
76
+	 *
77
+	 * @throws \Fab\Media\Exception\EmptyPropertyException
78
+	 * @return string
79
+	 */
80
+	public function render()
81
+	{
82
+
83
+		// Instantiate the file object for the whole class if possible.
84
+		if ($this->getValue()) {
85
+			$this->file = ResourceFactory::getInstance()->getFileObject($this->getValue());
86
+		}
87
+
88
+		$result = sprintf(
89
+			$this->template,
90
+			$this->getInlineStyle(),
91
+			$this->getThumbnail(),
92
+			$this->getFileInfo(),
93
+			$this->elementId,
94
+			$this->getJavaScriptTemplate(),
95
+			$this->getJavaScript()
96
+		);
97
+		return $result;
98
+	}
99
+
100
+	/**
101
+	 * @return string
102
+	 */
103
+	protected function getInlineStyle()
104
+	{
105
+		$style = 'float: left';
106
+		if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
107
+			$style .= '; padding-left: 3px';
108
+		}
109
+		return $style;
110
+	}
111
+
112
+	/**
113
+	 * Get the javascript from a file and replace the markers with live variables.
114
+	 *
115
+	 * @return string
116
+	 */
117
+	protected function getThumbnail()
118
+	{
119
+		$thumbnail = '';
120
+		if ($this->file) {
121
+
122
+			/** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
123
+			$thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $this->file);
124
+			$thumbnail = $thumbnailService
125
+				->setOutputType(ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
126
+				->setAppendTimeStamp(true)
127
+				->create();
128
+		}
129
+		return $thumbnail;
130
+	}
131
+
132
+	/**
133
+	 * Get the javascript from a file and replace the markers with live variables.
134
+	 *
135
+	 * @return string
136
+	 */
137
+	protected function getJavaScriptTemplate()
138
+	{
139
+		$view = $this->getStandaloneView();
140
+		$view->assignMultiple(
141
+			array(
142
+				'maximumUploadLabel' => $this->getMaximumUploadLabel(),
143
+			)
144
+		);
145
+		return $view->render();
146
+	}
147
+
148
+	/**
149
+	 * @return \TYPO3\CMS\Fluid\View\StandaloneView
150
+	 */
151
+	protected function getStandaloneView()
152
+	{
153
+		$objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
154
+
155
+		/** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */
156
+		$view = $objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
157
+
158
+		$templatePathAndFilename = ExtensionManagementUtility::extPath('media') . $this->templateFile;
159
+		$view->setTemplatePathAndFilename($templatePathAndFilename);
160
+
161
+		return $view;
162
+	}
163
+
164
+	/**
165
+	 * Get the javascript from a file and replace the markers with live variables.
166
+	 *
167
+	 * @return string
168
+	 */
169
+	protected function getJavaScript()
170
+	{
171
+
172
+		// Get the base prefix
173
+		$basePrefix = $this->getBasePrefix($this->getPrefix());
174
+
175
+		$filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Standalone/FileUpload.js';
176
+
177
+		return sprintf(
178
+			file_get_contents($filePath),
179
+			$basePrefix,
180
+			$this->elementId,
181
+			$this->getModuleUrl(),
182
+			$this->getAllowedExtensions(),
183
+			GeneralUtility::getMaxUploadFileSize() * 1024,
184
+			$this->isDrivenByFolder() ?
185
+				$this->getMediaModule()->getCurrentFolder()->getCombinedIdentifier() :
186
+				$this->getMediaModule()->getCurrentStorage()->getUid() . ':/'
187
+
188
+		);
189
+	}
190
+
191
+	/**
192
+	 * @return bool
193
+	 */
194
+	protected function isDrivenByFolder()
195
+	{
196
+		return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin();
197
+	}
198
+
199
+	/**
200
+	 * @return string
201
+	 */
202
+	protected function getModuleUrl()
203
+	{
204
+		$moduleSignature = MediaModule::getSignature();
205
+		return BackendUtility::getModuleUrl($moduleSignature);
206
+	}
207
+
208
+	/**
209
+	 * Returns the max upload file size in Mo.
210
+	 *
211
+	 * @return string
212
+	 */
213
+	protected function getMaximumUploadLabel()
214
+	{
215
+		$result = round(GeneralUtility::getMaxUploadFileSize() / 1024, 2);
216
+		$label = LocalizationUtility::translate('max_upload_file', 'media');
217
+		$result = sprintf($label, $result);
218
+		return $result;
219
+	}
220
+
221
+	/**
222
+	 * Get allowed extension.
223
+	 *
224
+	 * @return string
225
+	 */
226
+	protected function getAllowedExtensions()
227
+	{
228
+		return implode("','", PermissionUtility::getInstance()->getAllowedExtensions());
229
+	}
230
+
231
+	/**
232
+	 * Compute the base prefix by removing the square brackets.
233
+	 *
234
+	 * @param string $prefix
235
+	 * @return string
236
+	 */
237
+	protected function getBasePrefix($prefix)
238
+	{
239
+		$parts = explode('[', $prefix);
240
+		return empty($parts) ? '' : $parts[0];
241
+	}
242
+
243
+	/**
244
+	 * Returns additional file info.
245
+	 *
246
+	 * @return string
247
+	 */
248
+	protected function getFileInfo()
249
+	{
250
+		return ''; // empty return here but check out Tceforms/FileUpload
251
+	}
252
+
253
+	/**
254
+	 * @return MediaModule|object
255
+	 */
256
+	protected function getMediaModule()
257
+	{
258
+		return GeneralUtility::makeInstance(MediaModule::class);
259
+	}
260
+
261
+	/**
262
+	 * Get the Vidi Module Loader.
263
+	 *
264
+	 * @return \Fab\Vidi\Module\ModuleLoader|object
265
+	 */
266
+	protected function getModuleLoader()
267
+	{
268
+		return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class);
269
+	}
270 270
 
271 271
 }
Please login to merge, or discard this patch.
Classes/Form/AbstractFormField.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
             reset($attribute);
132 132
             $key = key($attribute);
133 133
             if (!is_string($key)) {
134
-                throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
134
+                throw new InvalidStringException('Not an associative array. Is not a key: '.$key, 1356478742);
135 135
             }
136 136
 
137 137
             $this->attributes[$key] = $attribute[$key];
Please login to merge, or discard this patch.
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -18,267 +18,267 @@
 block discarded – undo
18 18
 abstract class AbstractFormField implements FormFieldInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $template = '';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $value = '';
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name = '';
35
-
36
-    /**
37
-     * @var string
38
-     */
39
-    protected $id = '';
40
-
41
-    /**
42
-     * @var string
43
-     */
44
-    protected $prefix = '';
45
-
46
-    /**
47
-     * @var string
48
-     */
49
-    protected $label = '';
50
-
51
-    /**
52
-     * Store what child element will contain this element.
53
-     *
54
-     * @var array
55
-     */
56
-    protected $items = [];
57
-
58
-    /**
59
-     * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
-     *
61
-     * @var array
62
-     */
63
-    protected $attributes = [];
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function render()
69
-    {
70
-        return $this->template;
71
-    }
72
-
73
-    /**
74
-     * Render the label if possible. Otherwise return an empty string.
75
-     *
76
-     * @return string
77
-     */
78
-    public function renderLabel()
79
-    {
80
-        $result = '';
81
-        if ($this->label) {
82
-            $template = '<label class="control-label" for="%s">%s</label>';
83
-
84
-            if (strpos($this->label, 'LLL:') === 0) {
85
-                $this->label = LocalizationUtility::translate($this->label, '');
86
-            }
87
-
88
-            $result = sprintf($template,
89
-                $this->getId(),
90
-                $this->label
91
-            );
92
-        }
93
-        return $result;
94
-    }
95
-
96
-    /**
97
-     * Render additional attribute for this DOM element.
98
-     *
99
-     * @return string
100
-     */
101
-    public function renderAttributes()
102
-    {
103
-        $result = '';
104
-        if (!empty($this->attributes)) {
105
-            foreach ($this->attributes as $attribute => $value) {
106
-                $result .= sprintf('%s="%s" ',
107
-                    htmlspecialchars($attribute),
108
-                    htmlspecialchars($value)
109
-                );
110
-            }
111
-        }
112
-        return $result;
113
-    }
114
-
115
-    /**
116
-     * Add an additional (DOM) attribute to be added to this template.
117
-     *
118
-     * @throws InvalidStringException
119
-     * @param array $attribute associative array that contains attribute => value
120
-     * @return \Fab\Media\Form\AbstractFormField
121
-     */
122
-    public function addAttribute(array $attribute)
123
-    {
124
-        if (!empty($attribute)) {
125
-            reset($attribute);
126
-            $key = key($attribute);
127
-            if (!is_string($key)) {
128
-                throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
-            }
130
-
131
-            $this->attributes[$key] = $attribute[$key];
132
-        }
133
-        return $this;
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getTemplate()
140
-    {
141
-        return $this->template;
142
-    }
143
-
144
-    /**
145
-     * @param string $template
146
-     * @return \Fab\Media\Form\AbstractFormField
147
-     */
148
-    public function setTemplate($template)
149
-    {
150
-        $this->template = $template;
151
-    }
152
-
153
-    /**
154
-     * @return string
155
-     */
156
-    public function getLabel()
157
-    {
158
-        return $this->label;
159
-    }
160
-
161
-    /**
162
-     * @param string $label
163
-     * @return \Fab\Media\Form\AbstractFormField
164
-     */
165
-    public function setLabel($label)
166
-    {
167
-        $this->label = $label;
168
-        return $this;
169
-    }
170
-
171
-    /**
172
-     * @return string
173
-     */
174
-    public function getPrefix()
175
-    {
176
-        return $this->prefix;
177
-    }
178
-
179
-    /**
180
-     * @param string $prefix
181
-     * @return \Fab\Media\Form\AbstractFormField
182
-     */
183
-    public function setPrefix($prefix)
184
-    {
185
-        $this->prefix = $prefix;
186
-        return $this;
187
-    }
188
-
189
-    /**
190
-     * @return array
191
-     */
192
-    public function getItems()
193
-    {
194
-        return $this->items;
195
-    }
196
-
197
-    /**
198
-     * @param array $items
199
-     */
200
-    public function setItems($items)
201
-    {
202
-        $this->items = $items;
203
-    }
204
-
205
-    /**
206
-     * @return string
207
-     */
208
-    public function getValue()
209
-    {
210
-        return htmlspecialchars($this->value);
211
-    }
212
-
213
-    /**
214
-     * @param string $value
215
-     * @return \Fab\Media\Form\AbstractFormField
216
-     */
217
-    public function setValue($value)
218
-    {
219
-        $this->value = $value;
220
-        return $this;
221
-    }
222
-
223
-    /**
224
-     * @return string
225
-     */
226
-    public function getName()
227
-    {
228
-        $result = $this->name;
229
-        if ($this->getPrefix()) {
230
-            $result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
-        }
232
-        return $result;
233
-    }
234
-
235
-    /**
236
-     * @param string $name
237
-     * @return \Fab\Media\Form\AbstractFormField
238
-     */
239
-    public function setName($name)
240
-    {
241
-        $this->name = $name;
242
-        return $this;
243
-    }
244
-
245
-    /**
246
-     * @return string
247
-     */
248
-    public function getId()
249
-    {
250
-        if ($this->id === '') {
251
-            $this->id = DomElement::getInstance()->formatId($this->getName());
252
-        }
253
-        return $this->id;
254
-    }
255
-
256
-    /**
257
-     * @param string $id
258
-     * @return \Fab\Media\Form\AbstractFormField
259
-     */
260
-    public function setId($id)
261
-    {
262
-        $this->id = $id;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return array
268
-     */
269
-    public function getAttributes()
270
-    {
271
-        return $this->attributes;
272
-    }
273
-
274
-    /**
275
-     * @param array $attributes
276
-     * @return \Fab\Media\Form\AbstractFormField
277
-     */
278
-    public function setAttributes($attributes)
279
-    {
280
-        $this->attributes = $attributes;
281
-        return $this;
282
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $template = '';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $value = '';
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name = '';
35
+
36
+	/**
37
+	 * @var string
38
+	 */
39
+	protected $id = '';
40
+
41
+	/**
42
+	 * @var string
43
+	 */
44
+	protected $prefix = '';
45
+
46
+	/**
47
+	 * @var string
48
+	 */
49
+	protected $label = '';
50
+
51
+	/**
52
+	 * Store what child element will contain this element.
53
+	 *
54
+	 * @var array
55
+	 */
56
+	protected $items = [];
57
+
58
+	/**
59
+	 * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected $attributes = [];
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function render()
69
+	{
70
+		return $this->template;
71
+	}
72
+
73
+	/**
74
+	 * Render the label if possible. Otherwise return an empty string.
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function renderLabel()
79
+	{
80
+		$result = '';
81
+		if ($this->label) {
82
+			$template = '<label class="control-label" for="%s">%s</label>';
83
+
84
+			if (strpos($this->label, 'LLL:') === 0) {
85
+				$this->label = LocalizationUtility::translate($this->label, '');
86
+			}
87
+
88
+			$result = sprintf($template,
89
+				$this->getId(),
90
+				$this->label
91
+			);
92
+		}
93
+		return $result;
94
+	}
95
+
96
+	/**
97
+	 * Render additional attribute for this DOM element.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	public function renderAttributes()
102
+	{
103
+		$result = '';
104
+		if (!empty($this->attributes)) {
105
+			foreach ($this->attributes as $attribute => $value) {
106
+				$result .= sprintf('%s="%s" ',
107
+					htmlspecialchars($attribute),
108
+					htmlspecialchars($value)
109
+				);
110
+			}
111
+		}
112
+		return $result;
113
+	}
114
+
115
+	/**
116
+	 * Add an additional (DOM) attribute to be added to this template.
117
+	 *
118
+	 * @throws InvalidStringException
119
+	 * @param array $attribute associative array that contains attribute => value
120
+	 * @return \Fab\Media\Form\AbstractFormField
121
+	 */
122
+	public function addAttribute(array $attribute)
123
+	{
124
+		if (!empty($attribute)) {
125
+			reset($attribute);
126
+			$key = key($attribute);
127
+			if (!is_string($key)) {
128
+				throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
+			}
130
+
131
+			$this->attributes[$key] = $attribute[$key];
132
+		}
133
+		return $this;
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getTemplate()
140
+	{
141
+		return $this->template;
142
+	}
143
+
144
+	/**
145
+	 * @param string $template
146
+	 * @return \Fab\Media\Form\AbstractFormField
147
+	 */
148
+	public function setTemplate($template)
149
+	{
150
+		$this->template = $template;
151
+	}
152
+
153
+	/**
154
+	 * @return string
155
+	 */
156
+	public function getLabel()
157
+	{
158
+		return $this->label;
159
+	}
160
+
161
+	/**
162
+	 * @param string $label
163
+	 * @return \Fab\Media\Form\AbstractFormField
164
+	 */
165
+	public function setLabel($label)
166
+	{
167
+		$this->label = $label;
168
+		return $this;
169
+	}
170
+
171
+	/**
172
+	 * @return string
173
+	 */
174
+	public function getPrefix()
175
+	{
176
+		return $this->prefix;
177
+	}
178
+
179
+	/**
180
+	 * @param string $prefix
181
+	 * @return \Fab\Media\Form\AbstractFormField
182
+	 */
183
+	public function setPrefix($prefix)
184
+	{
185
+		$this->prefix = $prefix;
186
+		return $this;
187
+	}
188
+
189
+	/**
190
+	 * @return array
191
+	 */
192
+	public function getItems()
193
+	{
194
+		return $this->items;
195
+	}
196
+
197
+	/**
198
+	 * @param array $items
199
+	 */
200
+	public function setItems($items)
201
+	{
202
+		$this->items = $items;
203
+	}
204
+
205
+	/**
206
+	 * @return string
207
+	 */
208
+	public function getValue()
209
+	{
210
+		return htmlspecialchars($this->value);
211
+	}
212
+
213
+	/**
214
+	 * @param string $value
215
+	 * @return \Fab\Media\Form\AbstractFormField
216
+	 */
217
+	public function setValue($value)
218
+	{
219
+		$this->value = $value;
220
+		return $this;
221
+	}
222
+
223
+	/**
224
+	 * @return string
225
+	 */
226
+	public function getName()
227
+	{
228
+		$result = $this->name;
229
+		if ($this->getPrefix()) {
230
+			$result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
+		}
232
+		return $result;
233
+	}
234
+
235
+	/**
236
+	 * @param string $name
237
+	 * @return \Fab\Media\Form\AbstractFormField
238
+	 */
239
+	public function setName($name)
240
+	{
241
+		$this->name = $name;
242
+		return $this;
243
+	}
244
+
245
+	/**
246
+	 * @return string
247
+	 */
248
+	public function getId()
249
+	{
250
+		if ($this->id === '') {
251
+			$this->id = DomElement::getInstance()->formatId($this->getName());
252
+		}
253
+		return $this->id;
254
+	}
255
+
256
+	/**
257
+	 * @param string $id
258
+	 * @return \Fab\Media\Form\AbstractFormField
259
+	 */
260
+	public function setId($id)
261
+	{
262
+		$this->id = $id;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return array
268
+	 */
269
+	public function getAttributes()
270
+	{
271
+		return $this->attributes;
272
+	}
273
+
274
+	/**
275
+	 * @param array $attributes
276
+	 * @return \Fab\Media\Form\AbstractFormField
277
+	 */
278
+	public function setAttributes($attributes)
279
+	{
280
+		$this->attributes = $attributes;
281
+		return $this;
282
+	}
283 283
 
284 284
 }
Please login to merge, or discard this patch.
Classes/View/Menu/StorageMenu.php 3 patches
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,8 +78,7 @@  discard block
 block discarded – undo
78 78
                 $selected,
79 79
                 $storage->getName(),
80 80
                 $storage->isOnline() ?
81
-                    '' :
82
-                    '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')'
81
+                    '' : '('.$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline').')'
83 82
             );
84 83
         }
85 84
 
@@ -87,7 +86,7 @@  discard block
 block discarded – undo
87 86
         $inputs = '';
88 87
         foreach ($parameters as $parameter => $value) {
89 88
             list($parameter, $value) = $this->computeParameterAndValue($parameter, $value);
90
-            if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') {
89
+            if ($parameter !== $this->moduleLoader->getParameterPrefix().'[storage]') {
91 90
                 $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value);
92 91
             }
93 92
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     }
45 45
 
46 46
     /**
47
-     * @return string
47
+     * @return boolean
48 48
      */
49 49
     protected function isDisplayed()
50 50
     {
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -19,126 +19,126 @@
 block discarded – undo
19 19
 class StorageMenu extends AbstractComponentView
20 20
 {
21 21
 
22
-    /**
23
-     * @var \Fab\Vidi\Module\ModuleLoader
24
-     * @inject
25
-     */
26
-    protected $moduleLoader;
27
-
28
-    /**
29
-     * Renders a dropdown menu for storage.
30
-     *
31
-     * @return string
32
-     */
33
-    public function render()
34
-    {
35
-
36
-        $output = '';
37
-        if ($this->isDisplayed()) {
38
-            $this->loadRequireJsCode();
39
-
40
-            $output = $this->renderStorageMenu();
41
-        }
42
-
43
-        return $output;
44
-    }
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    protected function isDisplayed()
50
-    {
51
-        $isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin();
52
-        return $isDisplayed;
53
-    }
54
-
55
-    /**
56
-     * @return string
57
-     */
58
-    protected function renderStorageMenu()
59
-    {
60
-
61
-        $currentStorage = $this->getMediaModule()->getCurrentStorage();
62
-
63
-        /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
64
-        $options = '';
65
-        foreach ($this->getMediaModule()->getAllowedStorages() as $storage) {
66
-            $selected = '';
67
-            if ($currentStorage->getUid() == $storage->getUid()) {
68
-                $selected = 'selected';
69
-            }
70
-            $options .= sprintf('<option value="%s" %s>%s %s</option>',
71
-                $storage->getUid(),
72
-                $selected,
73
-                $storage->getName(),
74
-                $storage->isOnline() ?
75
-                    '' :
76
-                    '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')'
77
-            );
78
-        }
79
-
80
-        $parameters = GeneralUtility::_GET();
81
-        $inputs = '';
82
-        foreach ($parameters as $parameter => $value) {
83
-            list($parameter, $value) = $this->computeParameterAndValue($parameter, $value);
84
-            if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') {
85
-                $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value);
86
-            }
87
-        }
88
-
89
-        $template = '<form action="%s" id="form-menu-storage" method="get">
22
+	/**
23
+	 * @var \Fab\Vidi\Module\ModuleLoader
24
+	 * @inject
25
+	 */
26
+	protected $moduleLoader;
27
+
28
+	/**
29
+	 * Renders a dropdown menu for storage.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function render()
34
+	{
35
+
36
+		$output = '';
37
+		if ($this->isDisplayed()) {
38
+			$this->loadRequireJsCode();
39
+
40
+			$output = $this->renderStorageMenu();
41
+		}
42
+
43
+		return $output;
44
+	}
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	protected function isDisplayed()
50
+	{
51
+		$isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin();
52
+		return $isDisplayed;
53
+	}
54
+
55
+	/**
56
+	 * @return string
57
+	 */
58
+	protected function renderStorageMenu()
59
+	{
60
+
61
+		$currentStorage = $this->getMediaModule()->getCurrentStorage();
62
+
63
+		/** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
64
+		$options = '';
65
+		foreach ($this->getMediaModule()->getAllowedStorages() as $storage) {
66
+			$selected = '';
67
+			if ($currentStorage->getUid() == $storage->getUid()) {
68
+				$selected = 'selected';
69
+			}
70
+			$options .= sprintf('<option value="%s" %s>%s %s</option>',
71
+				$storage->getUid(),
72
+				$selected,
73
+				$storage->getName(),
74
+				$storage->isOnline() ?
75
+					'' :
76
+					'(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')'
77
+			);
78
+		}
79
+
80
+		$parameters = GeneralUtility::_GET();
81
+		$inputs = '';
82
+		foreach ($parameters as $parameter => $value) {
83
+			list($parameter, $value) = $this->computeParameterAndValue($parameter, $value);
84
+			if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') {
85
+				$inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value);
86
+			}
87
+		}
88
+
89
+		$template = '<form action="%s" id="form-menu-storage" method="get">
90 90
 						%s
91 91
 						<select name="%s[storage]" class="form-control" style="padding-right: 20px" id="menu-storage" onchange="$(\'#form-menu-storage\').submit()">%s</select>
92 92
 					</form>';
93 93
 
94
-        return sprintf(
95
-            $template,
96
-            $this->getModuleLoader()->getModuleUrl(),
97
-            $inputs,
98
-            $this->moduleLoader->getParameterPrefix(),
99
-            $options
100
-        );
101
-    }
102
-
103
-    /**
104
-     * @return void
105
-     */
106
-    protected function loadRequireJsCode()
107
-    {
108
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
109
-
110
-        $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
111
-        $pageRenderer->addRequireJsConfiguration($configuration);
112
-        $pageRenderer->loadRequireJsModule('Fab/Media/EditStorage');
113
-    }
114
-
115
-    /**
116
-     * Compute parameter and value to be correctly encoded by the browser.
117
-     *
118
-     * @param string $parameter
119
-     * @param mixed $value
120
-     * @return array
121
-     */
122
-    protected function computeParameterAndValue($parameter, $value)
123
-    {
124
-
125
-        if (is_string($value)) {
126
-            $result = array($parameter, $value);
127
-        } else {
128
-            $key = key($value);
129
-            $value = current($value);
130
-            $parameter = sprintf('%s[%s]', $parameter, $key);
131
-            $result = $this->computeParameterAndValue($parameter, $value);
132
-        }
133
-        return $result;
134
-    }
135
-
136
-    /**
137
-     * @return MediaModule|object
138
-     */
139
-    protected function getMediaModule()
140
-    {
141
-        return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
142
-    }
94
+		return sprintf(
95
+			$template,
96
+			$this->getModuleLoader()->getModuleUrl(),
97
+			$inputs,
98
+			$this->moduleLoader->getParameterPrefix(),
99
+			$options
100
+		);
101
+	}
102
+
103
+	/**
104
+	 * @return void
105
+	 */
106
+	protected function loadRequireJsCode()
107
+	{
108
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
109
+
110
+		$configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript';
111
+		$pageRenderer->addRequireJsConfiguration($configuration);
112
+		$pageRenderer->loadRequireJsModule('Fab/Media/EditStorage');
113
+	}
114
+
115
+	/**
116
+	 * Compute parameter and value to be correctly encoded by the browser.
117
+	 *
118
+	 * @param string $parameter
119
+	 * @param mixed $value
120
+	 * @return array
121
+	 */
122
+	protected function computeParameterAndValue($parameter, $value)
123
+	{
124
+
125
+		if (is_string($value)) {
126
+			$result = array($parameter, $value);
127
+		} else {
128
+			$key = key($value);
129
+			$value = current($value);
130
+			$parameter = sprintf('%s[%s]', $parameter, $key);
131
+			$result = $this->computeParameterAndValue($parameter, $value);
132
+		}
133
+		return $result;
134
+	}
135
+
136
+	/**
137
+	 * @return MediaModule|object
138
+	 */
139
+	protected function getMediaModule()
140
+	{
141
+		return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
142
+	}
143 143
 
144 144
 }
Please login to merge, or discard this patch.
Classes/View/Button/NewFolder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
                 ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
45 45
                 ->render();
46 46
 
47
-            $output = '<div style="float: left;">' . $button . '</div>';
47
+            $output = '<div style="float: left;">'.$button.'</div>';
48 48
         }
49 49
         return $output;
50 50
     }
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -21,101 +21,101 @@
 block discarded – undo
21 21
 class NewFolder extends AbstractComponentView
22 22
 {
23 23
 
24
-    /**
25
-     * Renders a button to create a new folder.
26
-     *
27
-     * @param Content $object
28
-     * @return string
29
-     */
30
-    public function render($object = null)
31
-    {
32
-        $output = '';
33
-        if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
34
-
35
-            $button = $this->makeLinkButton()
36
-                ->setHref($this->getNewFolderUri())
37
-                ->setTitle($this->getLabel())
38
-                ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
39
-                ->render();
40
-
41
-            $output = '<div style="float: left;">' . $button . '</div>';
42
-        }
43
-        return $output;
44
-    }
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    protected function getLabel()
50
-    {
51
-        return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new');
52
-    }
53
-
54
-    /**
55
-     * @return string
56
-     */
57
-    protected function getNewFolderUri()
58
-    {
59
-        return BackendUtility::getModuleUrl(
60
-            'file_newfolder',
61
-            array(
62
-                'target' => $this->getCombineIdentifier(),
63
-                'returnUrl' => $this->getReturnUrl(),
64
-            )
65
-        );
66
-    }
67
-
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    protected function getCombineIdentifier()
73
-    {
74
-        $folder = $this->getMediaModule()->getCurrentFolder();
75
-        return $folder->getCombinedIdentifier();
76
-    }
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    protected function getReturnUrl()
82
-    {
83
-        $returnUrl = BackendUtility::getModuleUrl(
84
-            GeneralUtility::_GP('route'),
85
-            $this->getAdditionalParameters()
86
-        );
87
-        return $returnUrl;
88
-    }
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    protected function getAdditionalParameters()
94
-    {
95
-
96
-        $additionalParameters = [];
97
-        if (GeneralUtility::_GP('id')) {
98
-            $additionalParameters = [
99
-                'id' => urldecode(GeneralUtility::_GP('id')),
100
-            ];
101
-        }
102
-        return $additionalParameters;
103
-    }
104
-
105
-    /**
106
-     * @return MediaModule|object
107
-     */
108
-    protected function getMediaModule()
109
-    {
110
-        return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
111
-    }
112
-
113
-    /**
114
-     * @return \TYPO3\CMS\Lang\LanguageService
115
-     */
116
-    protected function getLanguageService()
117
-    {
118
-        return $GLOBALS['LANG'];
119
-    }
24
+	/**
25
+	 * Renders a button to create a new folder.
26
+	 *
27
+	 * @param Content $object
28
+	 * @return string
29
+	 */
30
+	public function render($object = null)
31
+	{
32
+		$output = '';
33
+		if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) {
34
+
35
+			$button = $this->makeLinkButton()
36
+				->setHref($this->getNewFolderUri())
37
+				->setTitle($this->getLabel())
38
+				->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
39
+				->render();
40
+
41
+			$output = '<div style="float: left;">' . $button . '</div>';
42
+		}
43
+		return $output;
44
+	}
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	protected function getLabel()
50
+	{
51
+		return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new');
52
+	}
53
+
54
+	/**
55
+	 * @return string
56
+	 */
57
+	protected function getNewFolderUri()
58
+	{
59
+		return BackendUtility::getModuleUrl(
60
+			'file_newfolder',
61
+			array(
62
+				'target' => $this->getCombineIdentifier(),
63
+				'returnUrl' => $this->getReturnUrl(),
64
+			)
65
+		);
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	protected function getCombineIdentifier()
73
+	{
74
+		$folder = $this->getMediaModule()->getCurrentFolder();
75
+		return $folder->getCombinedIdentifier();
76
+	}
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	protected function getReturnUrl()
82
+	{
83
+		$returnUrl = BackendUtility::getModuleUrl(
84
+			GeneralUtility::_GP('route'),
85
+			$this->getAdditionalParameters()
86
+		);
87
+		return $returnUrl;
88
+	}
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	protected function getAdditionalParameters()
94
+	{
95
+
96
+		$additionalParameters = [];
97
+		if (GeneralUtility::_GP('id')) {
98
+			$additionalParameters = [
99
+				'id' => urldecode(GeneralUtility::_GP('id')),
100
+			];
101
+		}
102
+		return $additionalParameters;
103
+	}
104
+
105
+	/**
106
+	 * @return MediaModule|object
107
+	 */
108
+	protected function getMediaModule()
109
+	{
110
+		return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
111
+	}
112
+
113
+	/**
114
+	 * @return \TYPO3\CMS\Lang\LanguageService
115
+	 */
116
+	protected function getLanguageService()
117
+	{
118
+		return $GLOBALS['LANG'];
119
+	}
120 120
 
121 121
 }
Please login to merge, or discard this patch.