@@ -20,72 +20,72 @@ |
||
20 | 20 | class PermissionUtility implements SingletonInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Returns a class instance. |
|
25 | - * |
|
26 | - * @return PermissionUtility |
|
27 | - * @throws \InvalidArgumentException |
|
28 | - */ |
|
29 | - static public function getInstance() |
|
30 | - { |
|
31 | - return GeneralUtility::makeInstance(PermissionUtility::class); |
|
32 | - } |
|
23 | + /** |
|
24 | + * Returns a class instance. |
|
25 | + * |
|
26 | + * @return PermissionUtility |
|
27 | + * @throws \InvalidArgumentException |
|
28 | + */ |
|
29 | + static public function getInstance() |
|
30 | + { |
|
31 | + return GeneralUtility::makeInstance(PermissionUtility::class); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Returns allowed extensions given a possible storage. |
|
36 | - * |
|
37 | - * @param null|int|ResourceStorage $storage |
|
38 | - * @return array |
|
39 | - * @throws \InvalidArgumentException |
|
40 | - */ |
|
41 | - public function getAllowedExtensions($storage = null) |
|
42 | - { |
|
34 | + /** |
|
35 | + * Returns allowed extensions given a possible storage. |
|
36 | + * |
|
37 | + * @param null|int|ResourceStorage $storage |
|
38 | + * @return array |
|
39 | + * @throws \InvalidArgumentException |
|
40 | + */ |
|
41 | + public function getAllowedExtensions($storage = null) |
|
42 | + { |
|
43 | 43 | |
44 | - $fieldNames = array( |
|
45 | - 'extension_allowed_file_type_1', |
|
46 | - 'extension_allowed_file_type_2', |
|
47 | - 'extension_allowed_file_type_3', |
|
48 | - 'extension_allowed_file_type_4', |
|
49 | - 'extension_allowed_file_type_5', |
|
50 | - ); |
|
44 | + $fieldNames = array( |
|
45 | + 'extension_allowed_file_type_1', |
|
46 | + 'extension_allowed_file_type_2', |
|
47 | + 'extension_allowed_file_type_3', |
|
48 | + 'extension_allowed_file_type_4', |
|
49 | + 'extension_allowed_file_type_5', |
|
50 | + ); |
|
51 | 51 | |
52 | - if (!is_null($storage)) { |
|
53 | - if (!$storage instanceof ResourceStorage) { |
|
54 | - $storage = ResourceFactory::getInstance()->getStorageObject((int)$storage); |
|
55 | - } |
|
56 | - } else { |
|
57 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
58 | - } |
|
52 | + if (!is_null($storage)) { |
|
53 | + if (!$storage instanceof ResourceStorage) { |
|
54 | + $storage = ResourceFactory::getInstance()->getStorageObject((int)$storage); |
|
55 | + } |
|
56 | + } else { |
|
57 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
58 | + } |
|
59 | 59 | |
60 | - $storageRecord = $storage->getStorageRecord(); |
|
61 | - $allowedExtensions = []; |
|
62 | - foreach ($fieldNames as $fieldName) { |
|
63 | - $_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true); |
|
64 | - $allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions); |
|
65 | - } |
|
60 | + $storageRecord = $storage->getStorageRecord(); |
|
61 | + $allowedExtensions = []; |
|
62 | + foreach ($fieldNames as $fieldName) { |
|
63 | + $_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true); |
|
64 | + $allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions); |
|
65 | + } |
|
66 | 66 | |
67 | - $uniqueAllowedExtensions = array_unique($allowedExtensions); |
|
68 | - return array_filter($uniqueAllowedExtensions, 'strlen'); |
|
69 | - } |
|
67 | + $uniqueAllowedExtensions = array_unique($allowedExtensions); |
|
68 | + return array_filter($uniqueAllowedExtensions, 'strlen'); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Returns allowed extensions list. |
|
73 | - * |
|
74 | - * @return string |
|
75 | - * @throws \InvalidArgumentException |
|
76 | - */ |
|
77 | - public function getAllowedExtensionList() |
|
78 | - { |
|
79 | - return implode(',', $this->getAllowedExtensions()); |
|
80 | - } |
|
71 | + /** |
|
72 | + * Returns allowed extensions list. |
|
73 | + * |
|
74 | + * @return string |
|
75 | + * @throws \InvalidArgumentException |
|
76 | + */ |
|
77 | + public function getAllowedExtensionList() |
|
78 | + { |
|
79 | + return implode(',', $this->getAllowedExtensions()); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return MediaModule|object |
|
84 | - * @throws \InvalidArgumentException |
|
85 | - */ |
|
86 | - protected function getMediaModule() |
|
87 | - { |
|
88 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
89 | - } |
|
82 | + /** |
|
83 | + * @return MediaModule|object |
|
84 | + * @throws \InvalidArgumentException |
|
85 | + */ |
|
86 | + protected function getMediaModule() |
|
87 | + { |
|
88 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
@@ -18,75 +18,75 @@ |
||
18 | 18 | class ConfigurationUtility implements \TYPO3\CMS\Core\SingletonInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $extensionKey = 'media'; |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $extensionKey = 'media'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $configuration = []; |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $configuration = []; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns a class instance. |
|
33 | - * |
|
34 | - * @return \Fab\Media\Utility\ConfigurationUtility|object |
|
35 | - */ |
|
36 | - static public function getInstance() |
|
37 | - { |
|
38 | - return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Returns a class instance. |
|
33 | + * |
|
34 | + * @return \Fab\Media\Utility\ConfigurationUtility|object |
|
35 | + */ |
|
36 | + static public function getInstance() |
|
37 | + { |
|
38 | + return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - */ |
|
44 | - public function __construct() |
|
45 | - { |
|
46 | - $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + */ |
|
44 | + public function __construct() |
|
45 | + { |
|
46 | + $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
47 | 47 | |
48 | - // Fill up configuration array with relevant values. |
|
49 | - foreach ($configuration as $key => $value) { |
|
50 | - $this->configuration[$key] = $value; |
|
51 | - } |
|
52 | - } |
|
48 | + // Fill up configuration array with relevant values. |
|
49 | + foreach ($configuration as $key => $value) { |
|
50 | + $this->configuration[$key] = $value; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return ObjectManager|object |
|
56 | - */ |
|
57 | - protected function getObjectManager() |
|
58 | - { |
|
59 | - return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return ObjectManager|object |
|
56 | + */ |
|
57 | + protected function getObjectManager() |
|
58 | + { |
|
59 | + return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Returns a setting key. |
|
64 | - * |
|
65 | - * @param string $key |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function get($key) |
|
69 | - { |
|
70 | - return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null; |
|
71 | - } |
|
62 | + /** |
|
63 | + * Returns a setting key. |
|
64 | + * |
|
65 | + * @param string $key |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function get($key) |
|
69 | + { |
|
70 | + return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Set a setting key. |
|
75 | - * |
|
76 | - * @param string $key |
|
77 | - * @param mixed $value |
|
78 | - * @return void |
|
79 | - */ |
|
80 | - public function set($key, $value) |
|
81 | - { |
|
82 | - $this->configuration[$key] = $value; |
|
83 | - } |
|
73 | + /** |
|
74 | + * Set a setting key. |
|
75 | + * |
|
76 | + * @param string $key |
|
77 | + * @param mixed $value |
|
78 | + * @return void |
|
79 | + */ |
|
80 | + public function set($key, $value) |
|
81 | + { |
|
82 | + $this->configuration[$key] = $value; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - public function getConfiguration() |
|
89 | - { |
|
90 | - return $this->configuration; |
|
91 | - } |
|
85 | + /** |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + public function getConfiguration() |
|
89 | + { |
|
90 | + return $this->configuration; |
|
91 | + } |
|
92 | 92 | } |
@@ -16,62 +16,62 @@ |
||
16 | 16 | class SessionUtility implements \TYPO3\CMS\Core\SingletonInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $moduleKey = 'media'; |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $moduleKey = 'media'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Returns a class instance. |
|
26 | - * |
|
27 | - * @return \Fab\Media\Utility\SessionUtility|object |
|
28 | - */ |
|
29 | - static public function getInstance() |
|
30 | - { |
|
31 | - return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Returns a class instance. |
|
26 | + * |
|
27 | + * @return \Fab\Media\Utility\SessionUtility|object |
|
28 | + */ |
|
29 | + static public function getInstance() |
|
30 | + { |
|
31 | + return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class); |
|
32 | + } |
|
33 | 33 | |
34 | - public function __construct() |
|
35 | - { |
|
34 | + public function __construct() |
|
35 | + { |
|
36 | 36 | |
37 | - // Initialize storage from the current |
|
38 | - if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) { |
|
39 | - $this->getBackendUser()->uc['moduleData'][$this->moduleKey] = []; |
|
40 | - $this->getBackendUser()->writeUC(); |
|
41 | - } |
|
42 | - } |
|
37 | + // Initialize storage from the current |
|
38 | + if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) { |
|
39 | + $this->getBackendUser()->uc['moduleData'][$this->moduleKey] = []; |
|
40 | + $this->getBackendUser()->writeUC(); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Return a value from the Session according to the key |
|
46 | - * |
|
47 | - * @param string $key |
|
48 | - * @return mixed |
|
49 | - */ |
|
50 | - public function get($key) |
|
51 | - { |
|
52 | - return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key]; |
|
53 | - } |
|
44 | + /** |
|
45 | + * Return a value from the Session according to the key |
|
46 | + * |
|
47 | + * @param string $key |
|
48 | + * @return mixed |
|
49 | + */ |
|
50 | + public function get($key) |
|
51 | + { |
|
52 | + return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key]; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Set a key to the Session. |
|
57 | - * |
|
58 | - * @param string $key |
|
59 | - * @param mixed $value |
|
60 | - * @return void |
|
61 | - */ |
|
62 | - public function set($key, $value) |
|
63 | - { |
|
64 | - $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value; |
|
65 | - $this->getBackendUser()->writeUC(); |
|
66 | - } |
|
55 | + /** |
|
56 | + * Set a key to the Session. |
|
57 | + * |
|
58 | + * @param string $key |
|
59 | + * @param mixed $value |
|
60 | + * @return void |
|
61 | + */ |
|
62 | + public function set($key, $value) |
|
63 | + { |
|
64 | + $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value; |
|
65 | + $this->getBackendUser()->writeUC(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns an instance of the current Backend User. |
|
70 | - * |
|
71 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
72 | - */ |
|
73 | - protected function getBackendUser() |
|
74 | - { |
|
75 | - return $GLOBALS['BE_USER']; |
|
76 | - } |
|
68 | + /** |
|
69 | + * Returns an instance of the current Backend User. |
|
70 | + * |
|
71 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
72 | + */ |
|
73 | + protected function getBackendUser() |
|
74 | + { |
|
75 | + return $GLOBALS['BE_USER']; |
|
76 | + } |
|
77 | 77 | } |
@@ -21,127 +21,127 @@ |
||
21 | 21 | class FileDataHandler extends AbstractDataHandler |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Process File with action "update". |
|
26 | - * |
|
27 | - * @param Content $content |
|
28 | - * @throws \Exception |
|
29 | - * @return bool |
|
30 | - */ |
|
31 | - public function processUpdate(Content $content) |
|
32 | - { |
|
33 | - throw new \Exception('Not yet implemented', 1409988673); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * Process File with action "remove". |
|
38 | - * |
|
39 | - * @param Content $content |
|
40 | - * @return bool|void |
|
41 | - */ |
|
42 | - public function processRemove(Content $content) |
|
43 | - { |
|
44 | - $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
45 | - |
|
46 | - $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file); |
|
47 | - if ($numberOfReferences === 0) { |
|
48 | - $file->delete(); |
|
49 | - } else { |
|
50 | - $message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences); |
|
51 | - $this->errorMessages = $message; |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Process File with action "copy". |
|
57 | - * |
|
58 | - * @param Content $content |
|
59 | - * @param string $target |
|
60 | - * @throws \Exception |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public function processCopy(Content $content, $target) |
|
64 | - { |
|
65 | - $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
66 | - |
|
67 | - if ($this->getMediaModule()->hasFolderTree()) { |
|
68 | - |
|
69 | - $targetFolder = $this->getMediaModule()->getCurrentFolder(); |
|
70 | - |
|
71 | - // Move file |
|
72 | - $file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
73 | - } |
|
74 | - return true; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Process File with action "move". |
|
79 | - * |
|
80 | - * @param Content $content |
|
81 | - * @param string $target |
|
82 | - * @throws \Exception |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function processMove(Content $content, $target) |
|
86 | - { |
|
87 | - $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
88 | - |
|
89 | - if ($this->getMediaModule()->hasFolderTree()) { |
|
90 | - |
|
91 | - $targetFolder = $this->getMediaModule()->getCurrentFolder(); |
|
92 | - if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) { |
|
93 | - |
|
94 | - // Move file |
|
95 | - $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
96 | - } |
|
97 | - } else { |
|
98 | - |
|
99 | - // Only process if the storage is different. |
|
100 | - if ((int)$file->getStorage()->getUid() !== (int)$target) { |
|
101 | - |
|
102 | - $targetStorage = ResourceFactory::getInstance()->getStorageObject((int)$target); |
|
103 | - |
|
104 | - // Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission. |
|
105 | - $targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file); |
|
106 | - |
|
107 | - try { |
|
108 | - // Move file |
|
109 | - $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
110 | - } catch (\Exception $e) { |
|
111 | - $this->errorMessages = $e->getMessage(); |
|
112 | - } |
|
113 | - } |
|
114 | - } |
|
115 | - return true; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return \Fab\Media\Resource\FileReferenceService|object |
|
120 | - */ |
|
121 | - protected function getFileReferenceService() |
|
122 | - { |
|
123 | - return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Process Content with action "localize". |
|
128 | - * |
|
129 | - * @param Content $content |
|
130 | - * @param int $language |
|
131 | - * @throws \Exception |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function processLocalize(Content $content, $language) |
|
135 | - { |
|
136 | - throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @return MediaModule|object |
|
141 | - */ |
|
142 | - protected function getMediaModule() |
|
143 | - { |
|
144 | - return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
145 | - } |
|
24 | + /** |
|
25 | + * Process File with action "update". |
|
26 | + * |
|
27 | + * @param Content $content |
|
28 | + * @throws \Exception |
|
29 | + * @return bool |
|
30 | + */ |
|
31 | + public function processUpdate(Content $content) |
|
32 | + { |
|
33 | + throw new \Exception('Not yet implemented', 1409988673); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * Process File with action "remove". |
|
38 | + * |
|
39 | + * @param Content $content |
|
40 | + * @return bool|void |
|
41 | + */ |
|
42 | + public function processRemove(Content $content) |
|
43 | + { |
|
44 | + $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
45 | + |
|
46 | + $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file); |
|
47 | + if ($numberOfReferences === 0) { |
|
48 | + $file->delete(); |
|
49 | + } else { |
|
50 | + $message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences); |
|
51 | + $this->errorMessages = $message; |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Process File with action "copy". |
|
57 | + * |
|
58 | + * @param Content $content |
|
59 | + * @param string $target |
|
60 | + * @throws \Exception |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public function processCopy(Content $content, $target) |
|
64 | + { |
|
65 | + $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
66 | + |
|
67 | + if ($this->getMediaModule()->hasFolderTree()) { |
|
68 | + |
|
69 | + $targetFolder = $this->getMediaModule()->getCurrentFolder(); |
|
70 | + |
|
71 | + // Move file |
|
72 | + $file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
73 | + } |
|
74 | + return true; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Process File with action "move". |
|
79 | + * |
|
80 | + * @param Content $content |
|
81 | + * @param string $target |
|
82 | + * @throws \Exception |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function processMove(Content $content, $target) |
|
86 | + { |
|
87 | + $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); |
|
88 | + |
|
89 | + if ($this->getMediaModule()->hasFolderTree()) { |
|
90 | + |
|
91 | + $targetFolder = $this->getMediaModule()->getCurrentFolder(); |
|
92 | + if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) { |
|
93 | + |
|
94 | + // Move file |
|
95 | + $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
96 | + } |
|
97 | + } else { |
|
98 | + |
|
99 | + // Only process if the storage is different. |
|
100 | + if ((int)$file->getStorage()->getUid() !== (int)$target) { |
|
101 | + |
|
102 | + $targetStorage = ResourceFactory::getInstance()->getStorageObject((int)$target); |
|
103 | + |
|
104 | + // Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission. |
|
105 | + $targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file); |
|
106 | + |
|
107 | + try { |
|
108 | + // Move file |
|
109 | + $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME); |
|
110 | + } catch (\Exception $e) { |
|
111 | + $this->errorMessages = $e->getMessage(); |
|
112 | + } |
|
113 | + } |
|
114 | + } |
|
115 | + return true; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return \Fab\Media\Resource\FileReferenceService|object |
|
120 | + */ |
|
121 | + protected function getFileReferenceService() |
|
122 | + { |
|
123 | + return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Process Content with action "localize". |
|
128 | + * |
|
129 | + * @param Content $content |
|
130 | + * @param int $language |
|
131 | + * @throws \Exception |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function processLocalize(Content $content, $language) |
|
135 | + { |
|
136 | + throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @return MediaModule|object |
|
141 | + */ |
|
142 | + protected function getMediaModule() |
|
143 | + { |
|
144 | + return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
145 | + } |
|
146 | 146 | |
147 | 147 | } |
@@ -19,36 +19,36 @@ |
||
19 | 19 | class ExistsViewHelper extends AbstractViewHelper |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function initializeArguments() |
|
26 | - { |
|
27 | - $this->registerArgument('file', 'mixed', '', true); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * Returns a property value of a file given by the context. |
|
32 | - * |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function render() |
|
36 | - { |
|
37 | - /** @var File|Content|int $file $file */ |
|
38 | - $file = $this->arguments['file']; |
|
39 | - |
|
40 | - if (!$file instanceof File) { |
|
41 | - $file = $this->getFileConverter()->convert($file); |
|
42 | - } |
|
43 | - |
|
44 | - return $file->exists(); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
49 | - */ |
|
50 | - protected function getFileConverter() |
|
51 | - { |
|
52 | - return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
53 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function initializeArguments() |
|
26 | + { |
|
27 | + $this->registerArgument('file', 'mixed', '', true); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * Returns a property value of a file given by the context. |
|
32 | + * |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function render() |
|
36 | + { |
|
37 | + /** @var File|Content|int $file $file */ |
|
38 | + $file = $this->arguments['file']; |
|
39 | + |
|
40 | + if (!$file instanceof File) { |
|
41 | + $file = $this->getFileConverter()->convert($file); |
|
42 | + } |
|
43 | + |
|
44 | + return $file->exists(); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
49 | + */ |
|
50 | + protected function getFileConverter() |
|
51 | + { |
|
52 | + return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
53 | + } |
|
54 | 54 | } |
@@ -17,25 +17,25 @@ |
||
17 | 17 | class PropertyViewHelper extends AbstractViewHelper |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function initializeArguments() |
|
24 | - { |
|
25 | - $this->registerArgument('name', 'string', '', true); |
|
26 | - } |
|
20 | + /** |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function initializeArguments() |
|
24 | + { |
|
25 | + $this->registerArgument('name', 'string', '', true); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Returns a property value of a file given by the context. |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function render() |
|
34 | - { |
|
35 | - $name = $this->arguments['name']; |
|
28 | + /** |
|
29 | + * Returns a property value of a file given by the context. |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function render() |
|
34 | + { |
|
35 | + $name = $this->arguments['name']; |
|
36 | 36 | |
37 | - /** @var File $file */ |
|
38 | - $file = $this->templateVariableContainer->get('file'); |
|
39 | - return $file->getProperty($name); |
|
40 | - } |
|
37 | + /** @var File $file */ |
|
38 | + $file = $this->templateVariableContainer->get('file'); |
|
39 | + return $file->getProperty($name); |
|
40 | + } |
|
41 | 41 | } |
@@ -21,65 +21,65 @@ |
||
21 | 21 | class ThumbnailViewHelper extends AbstractViewHelper |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function initializeArguments() |
|
28 | - { |
|
29 | - $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
30 | - $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
31 | - $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
32 | - $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
33 | - $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
34 | - $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
35 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function initializeArguments() |
|
28 | + { |
|
29 | + $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
30 | + $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
31 | + $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
32 | + $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
33 | + $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
34 | + $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Returns a configurable thumbnail of an asset |
|
39 | - * |
|
40 | - * @throws \Exception |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function render() |
|
44 | - { |
|
37 | + /** |
|
38 | + * Returns a configurable thumbnail of an asset |
|
39 | + * |
|
40 | + * @throws \Exception |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function render() |
|
44 | + { |
|
45 | 45 | |
46 | - $file = $this->arguments['file']; |
|
47 | - $preset = $this->arguments['preset']; |
|
48 | - $configuration = $this->arguments['configuration']; |
|
49 | - if (!is_array($configuration)) { |
|
50 | - $configuration = array(); |
|
51 | - } |
|
52 | - $configurationWrap = $this->arguments['configurationWrap']; |
|
53 | - $attributes = $this->arguments['attributes']; |
|
54 | - $output = $this->arguments['output']; |
|
46 | + $file = $this->arguments['file']; |
|
47 | + $preset = $this->arguments['preset']; |
|
48 | + $configuration = $this->arguments['configuration']; |
|
49 | + if (!is_array($configuration)) { |
|
50 | + $configuration = array(); |
|
51 | + } |
|
52 | + $configurationWrap = $this->arguments['configurationWrap']; |
|
53 | + $attributes = $this->arguments['attributes']; |
|
54 | + $output = $this->arguments['output']; |
|
55 | 55 | |
56 | - if ($file instanceof Content) { |
|
57 | - $file = $this->getFileConverter()->convert($file); |
|
58 | - } elseif (!($file instanceof File)) { |
|
59 | - $file = ResourceFactory::getInstance()->getFileObject((int)$file); |
|
60 | - } |
|
61 | - if ($preset) { |
|
62 | - $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
63 | - $configuration['width'] = $imageDimension->getWidth(); |
|
64 | - $configuration['height'] = $imageDimension->getHeight(); |
|
65 | - } |
|
66 | - /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
67 | - $thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $file); |
|
68 | - $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
69 | - ->setConfigurationWrap($configurationWrap) |
|
70 | - ->setAttributes($attributes) |
|
71 | - ->setOutputType($output) |
|
72 | - ->create(); |
|
56 | + if ($file instanceof Content) { |
|
57 | + $file = $this->getFileConverter()->convert($file); |
|
58 | + } elseif (!($file instanceof File)) { |
|
59 | + $file = ResourceFactory::getInstance()->getFileObject((int)$file); |
|
60 | + } |
|
61 | + if ($preset) { |
|
62 | + $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
63 | + $configuration['width'] = $imageDimension->getWidth(); |
|
64 | + $configuration['height'] = $imageDimension->getHeight(); |
|
65 | + } |
|
66 | + /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
67 | + $thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $file); |
|
68 | + $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
69 | + ->setConfigurationWrap($configurationWrap) |
|
70 | + ->setAttributes($attributes) |
|
71 | + ->setOutputType($output) |
|
72 | + ->create(); |
|
73 | 73 | |
74 | - return $thumbnail; |
|
75 | - } |
|
74 | + return $thumbnail; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
79 | - */ |
|
80 | - protected function getFileConverter() |
|
81 | - { |
|
82 | - return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
79 | + */ |
|
80 | + protected function getFileConverter() |
|
81 | + { |
|
82 | + return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | } |
@@ -19,37 +19,37 @@ |
||
19 | 19 | class UriViewHelper extends AbstractViewHelper |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function initializeArguments() |
|
26 | - { |
|
27 | - $this->registerArgument('file', 'mixed', '', true); |
|
28 | - $this->registerArgument('relative', 'bool', '', false, false); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function initializeArguments() |
|
26 | + { |
|
27 | + $this->registerArgument('file', 'mixed', '', true); |
|
28 | + $this->registerArgument('relative', 'bool', '', false, false); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns a property value of a file given by the context. |
|
33 | - * |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function render() |
|
37 | - { |
|
38 | - /** @var File|Content|int $file $file */ |
|
39 | - $file = $this->arguments['file']; |
|
40 | - $relative = $this->arguments['relative']; |
|
31 | + /** |
|
32 | + * Returns a property value of a file given by the context. |
|
33 | + * |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function render() |
|
37 | + { |
|
38 | + /** @var File|Content|int $file $file */ |
|
39 | + $file = $this->arguments['file']; |
|
40 | + $relative = $this->arguments['relative']; |
|
41 | 41 | |
42 | - if (!$file instanceof File) { |
|
43 | - $file = $this->getFileConverter()->convert($file); |
|
44 | - } |
|
45 | - return $file->getPublicUrl($relative); |
|
46 | - } |
|
42 | + if (!$file instanceof File) { |
|
43 | + $file = $this->getFileConverter()->convert($file); |
|
44 | + } |
|
45 | + return $file->getPublicUrl($relative); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
50 | - */ |
|
51 | - protected function getFileConverter() |
|
52 | - { |
|
53 | - return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return \Fab\Media\TypeConverter\ContentToFileConverter|object |
|
50 | + */ |
|
51 | + protected function getFileConverter() |
|
52 | + { |
|
53 | + return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class); |
|
54 | + } |
|
55 | 55 | } |
@@ -20,50 +20,50 @@ |
||
20 | 20 | class StorageViewHelper extends AbstractViewHelper |
21 | 21 | { |
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) { |
|
43 | + $template = '<select name="%s[target]">%s</select>'; |
|
44 | + $options = []; |
|
45 | + foreach ($objects as $storage) { |
|
46 | 46 | |
47 | - /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */ |
|
48 | - $options[] = sprintf('<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($template, |
|
56 | - VidiModule::getParameterPrefix(), |
|
57 | - implode("\n", $options) |
|
58 | - ); |
|
59 | - } |
|
47 | + /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */ |
|
48 | + $options[] = sprintf('<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($template, |
|
56 | + VidiModule::getParameterPrefix(), |
|
57 | + implode("\n", $options) |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return MediaModule|object |
|
63 | - */ |
|
64 | - protected function getMediaModule() |
|
65 | - { |
|
66 | - return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return MediaModule|object |
|
63 | + */ |
|
64 | + protected function getMediaModule() |
|
65 | + { |
|
66 | + return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |