@@ -20,43 +20,43 @@ |
||
20 | 20 | class LinkCreatorButton extends AbstractComponentView |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Renders a "link-creator" button to be placed in the grid. |
|
25 | - * |
|
26 | - * @param Content $object |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function render(Content $object = null) |
|
30 | - { |
|
31 | - $button = ''; |
|
32 | - if ($this->getModuleLoader()->hasPlugin('linkCreator')) { |
|
33 | - $button = $this->makeLinkButton() |
|
34 | - ->setHref($this->getLinkCreatorUri($object)) |
|
35 | - ->setDataAttributes([ |
|
36 | - 'uid' => $object->getUid(), |
|
37 | - 'toggle' => 'tooltip', |
|
38 | - ]) |
|
39 | - ->setClasses('btn-linkCreator') |
|
40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:create_link')) |
|
41 | - ->setIcon($this->getIconFactory()->getIcon('apps-pagetree-page-shortcut-external-root', Icon::SIZE_SMALL)) |
|
42 | - ->render(); |
|
43 | - } |
|
44 | - return $button; |
|
45 | - } |
|
23 | + /** |
|
24 | + * Renders a "link-creator" button to be placed in the grid. |
|
25 | + * |
|
26 | + * @param Content $object |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function render(Content $object = null) |
|
30 | + { |
|
31 | + $button = ''; |
|
32 | + if ($this->getModuleLoader()->hasPlugin('linkCreator')) { |
|
33 | + $button = $this->makeLinkButton() |
|
34 | + ->setHref($this->getLinkCreatorUri($object)) |
|
35 | + ->setDataAttributes([ |
|
36 | + 'uid' => $object->getUid(), |
|
37 | + 'toggle' => 'tooltip', |
|
38 | + ]) |
|
39 | + ->setClasses('btn-linkCreator') |
|
40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:create_link')) |
|
41 | + ->setIcon($this->getIconFactory()->getIcon('apps-pagetree-page-shortcut-external-root', Icon::SIZE_SMALL)) |
|
42 | + ->render(); |
|
43 | + } |
|
44 | + return $button; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param Content $object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - protected function getLinkCreatorUri(Content $object) |
|
52 | - { |
|
53 | - $urlParameters = array( |
|
54 | - MediaModule::getParameterPrefix() => array( |
|
55 | - 'controller' => 'LinkCreator', |
|
56 | - 'action' => 'show', |
|
57 | - 'file' => $object->getUid(), |
|
58 | - ), |
|
59 | - ); |
|
60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | - } |
|
47 | + /** |
|
48 | + * @param Content $object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + protected function getLinkCreatorUri(Content $object) |
|
52 | + { |
|
53 | + $urlParameters = array( |
|
54 | + MediaModule::getParameterPrefix() => array( |
|
55 | + 'controller' => 'LinkCreator', |
|
56 | + 'action' => 'show', |
|
57 | + 'file' => $object->getUid(), |
|
58 | + ), |
|
59 | + ); |
|
60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | + } |
|
62 | 62 | } |
@@ -20,43 +20,43 @@ |
||
20 | 20 | class ImageEditorButton extends AbstractComponentView |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Renders a "image-editor" button to be placed in the grid. |
|
25 | - * |
|
26 | - * @param Content $object |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function render(Content $object = null) |
|
30 | - { |
|
31 | - $button = ''; |
|
32 | - if ($this->getModuleLoader()->hasPlugin('imageEditor')) { |
|
33 | - $button = $this->makeLinkButton() |
|
34 | - ->setHref($this->getImageEditorUri($object)) |
|
35 | - ->setDataAttributes([ |
|
36 | - 'uid' => $object->getUid(), |
|
37 | - 'toggle' => 'tooltip', |
|
38 | - ]) |
|
39 | - ->setClasses('btn-imageEditor') |
|
40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
41 | - ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-edit', Icon::SIZE_SMALL)) |
|
42 | - ->render(); |
|
43 | - } |
|
44 | - return $button; |
|
45 | - } |
|
23 | + /** |
|
24 | + * Renders a "image-editor" button to be placed in the grid. |
|
25 | + * |
|
26 | + * @param Content $object |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function render(Content $object = null) |
|
30 | + { |
|
31 | + $button = ''; |
|
32 | + if ($this->getModuleLoader()->hasPlugin('imageEditor')) { |
|
33 | + $button = $this->makeLinkButton() |
|
34 | + ->setHref($this->getImageEditorUri($object)) |
|
35 | + ->setDataAttributes([ |
|
36 | + 'uid' => $object->getUid(), |
|
37 | + 'toggle' => 'tooltip', |
|
38 | + ]) |
|
39 | + ->setClasses('btn-imageEditor') |
|
40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
41 | + ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-edit', Icon::SIZE_SMALL)) |
|
42 | + ->render(); |
|
43 | + } |
|
44 | + return $button; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param Content $object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - protected function getImageEditorUri(Content $object) |
|
52 | - { |
|
53 | - $urlParameters = array( |
|
54 | - MediaModule::getParameterPrefix() => array( |
|
55 | - 'controller' => 'ImageEditor', |
|
56 | - 'action' => 'show', |
|
57 | - 'file' => $object->getUid(), |
|
58 | - ), |
|
59 | - ); |
|
60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | - } |
|
47 | + /** |
|
48 | + * @param Content $object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + protected function getImageEditorUri(Content $object) |
|
52 | + { |
|
53 | + $urlParameters = array( |
|
54 | + MediaModule::getParameterPrefix() => array( |
|
55 | + 'controller' => 'ImageEditor', |
|
56 | + 'action' => 'show', |
|
57 | + 'file' => $object->getUid(), |
|
58 | + ), |
|
59 | + ); |
|
60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | + } |
|
62 | 62 | } |
@@ -20,44 +20,44 @@ |
||
20 | 20 | class FilePickerButton extends AbstractComponentView |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Renders a "file-picker" button to be placed in the grid. |
|
25 | - * |
|
26 | - * @param Content $object |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function render(Content $object = null) |
|
30 | - { |
|
31 | - $button = ''; |
|
32 | - if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
33 | - $button = $this->makeLinkButton() |
|
34 | - ->setHref($this->getFilePickerUri($object)) |
|
35 | - ->setDataAttributes([ |
|
36 | - 'uid' => $object->getUid(), |
|
37 | - 'toggle' => 'tooltip', |
|
38 | - ]) |
|
39 | - ->setClasses('btn-filePicker') |
|
40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
41 | - ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL)) |
|
42 | - ->render(); |
|
23 | + /** |
|
24 | + * Renders a "file-picker" button to be placed in the grid. |
|
25 | + * |
|
26 | + * @param Content $object |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function render(Content $object = null) |
|
30 | + { |
|
31 | + $button = ''; |
|
32 | + if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
33 | + $button = $this->makeLinkButton() |
|
34 | + ->setHref($this->getFilePickerUri($object)) |
|
35 | + ->setDataAttributes([ |
|
36 | + 'uid' => $object->getUid(), |
|
37 | + 'toggle' => 'tooltip', |
|
38 | + ]) |
|
39 | + ->setClasses('btn-filePicker') |
|
40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
41 | + ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL)) |
|
42 | + ->render(); |
|
43 | 43 | |
44 | - } |
|
45 | - return $button; |
|
46 | - } |
|
44 | + } |
|
45 | + return $button; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param Content $object |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - protected function getFilePickerUri(Content $object) |
|
53 | - { |
|
54 | - $urlParameters = array( |
|
55 | - MediaModule::getParameterPrefix() => array( |
|
56 | - 'controller' => 'Asset', |
|
57 | - 'action' => 'download', |
|
58 | - 'file' => $object->getUid(), |
|
59 | - ), |
|
60 | - ); |
|
61 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
62 | - } |
|
48 | + /** |
|
49 | + * @param Content $object |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + protected function getFilePickerUri(Content $object) |
|
53 | + { |
|
54 | + $urlParameters = array( |
|
55 | + MediaModule::getParameterPrefix() => array( |
|
56 | + 'controller' => 'Asset', |
|
57 | + 'action' => 'download', |
|
58 | + 'file' => $object->getUid(), |
|
59 | + ), |
|
60 | + ); |
|
61 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
62 | + } |
|
63 | 63 | } |
@@ -23,248 +23,248 @@ |
||
23 | 23 | class ActionPermissionFacet implements FacetInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $name = '__action_permission'; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission'; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $suggestions = array( |
|
40 | - 'r' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.read_only', |
|
41 | - 'w' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.write', |
|
42 | - ); |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $fieldNameAndPath = ''; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $dataType; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var bool |
|
56 | - */ |
|
57 | - protected $canModifyMatcher = false; |
|
58 | - |
|
59 | - /** |
|
60 | - * Constructor of a Generic Facet in Vidi. |
|
61 | - * |
|
62 | - * @param string $name |
|
63 | - * @param string $label |
|
64 | - * @param array $suggestions |
|
65 | - * @param string $fieldNameAndPath |
|
66 | - */ |
|
67 | - public function __construct($name = '', $label = '', array $suggestions = [], $fieldNameAndPath = '') |
|
68 | - { |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getName() |
|
75 | - { |
|
76 | - return $this->name; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function getLabel() |
|
83 | - { |
|
84 | - return $this->getLanguageService()->sL($this->label); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - public function getSuggestions() |
|
91 | - { |
|
92 | - $suggestions = []; |
|
93 | - foreach ($this->suggestions as $key => $label) { |
|
94 | - $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
95 | - } |
|
96 | - |
|
97 | - return $suggestions; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function hasSuggestions() |
|
104 | - { |
|
105 | - return true; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $dataType |
|
110 | - * @return $this |
|
111 | - */ |
|
112 | - public function setDataType($dataType) |
|
113 | - { |
|
114 | - $this->dataType = $dataType; |
|
115 | - return $this; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return bool |
|
120 | - */ |
|
121 | - public function canModifyMatcher() |
|
122 | - { |
|
123 | - return $this->canModifyMatcher; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @param Matcher $matcher |
|
128 | - * @param $value |
|
129 | - * @return Matcher |
|
130 | - */ |
|
131 | - public function modifyMatcher(Matcher $matcher, $value) |
|
132 | - { |
|
133 | - return $matcher; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @param AfterFindContentObjectsSignalArguments $signalArguments |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - public function modifyResultSet(AfterFindContentObjectsSignalArguments $signalArguments) |
|
141 | - { |
|
142 | - |
|
143 | - if ($signalArguments->getDataType() === 'sys_file') { |
|
144 | - |
|
145 | - $queryParts = $this->getQueryParts(); |
|
146 | - |
|
147 | - if (!empty($queryParts)) { |
|
148 | - $permission = $this->getPermissionValue($queryParts); |
|
149 | - |
|
150 | - if ($permission) { |
|
151 | - |
|
152 | - // We are force to query the content repository again here without limit |
|
153 | - $matcher = $signalArguments->getMatcher(); |
|
154 | - $order = $signalArguments->getOrder(); |
|
155 | - $objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order); |
|
156 | - |
|
157 | - $filteredObjects = []; |
|
158 | - foreach ($objects as $object) { |
|
159 | - |
|
160 | - $file = $this->getFileConverter()->convert($object->getUid()); |
|
161 | - if ($permission === 'read' && !$file->checkActionPermission('write')) { |
|
162 | - $filteredObjects[] = $object; |
|
163 | - } elseif ($permission === 'write' && $file->checkActionPermission('write')) { |
|
164 | - $filteredObjects[] = $object; |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - // Only take part of the array according to offset and limit. |
|
169 | - $offset = $signalArguments->getOffset(); |
|
170 | - $limit = $signalArguments->getLimit(); |
|
171 | - $signalArguments->setContentObjects(array_slice($filteredObjects, $offset, $limit)); |
|
172 | - |
|
173 | - // Count number of records |
|
174 | - $signalArguments->setNumberOfObjects(count($filteredObjects)); |
|
175 | - $signalArguments->setHasBeenProcessed(true); |
|
176 | - } |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - return array($signalArguments); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * @return array |
|
185 | - */ |
|
186 | - protected function getQueryParts() |
|
187 | - { |
|
188 | - |
|
189 | - // Transmit recursive selection parameter. |
|
190 | - $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
191 | - $parameters = GeneralUtility::_GP($parameterPrefix); |
|
192 | - |
|
193 | - $queryParts = []; |
|
194 | - if (!empty($parameters['searchTerm'])) { |
|
195 | - $query = rawurldecode($parameters['searchTerm']); |
|
196 | - $queryParts = json_decode($query, true); |
|
197 | - } |
|
198 | - |
|
199 | - return $queryParts; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Retrieve the search permission value. |
|
204 | - * |
|
205 | - * @param array $queryParts |
|
206 | - * @return string |
|
207 | - */ |
|
208 | - protected function getPermissionValue(array $queryParts) |
|
209 | - { |
|
210 | - $permission = ''; |
|
211 | - |
|
212 | - // Check also amongst labels. |
|
213 | - $labelReadOnly = $this->getLanguageService()->sL($this->suggestions['r']); |
|
214 | - $labelWrite = $this->getLanguageService()->sL($this->suggestions['w']); |
|
215 | - |
|
216 | - foreach ($queryParts as $queryPart) { |
|
217 | - $facetName = key($queryPart); |
|
218 | - $value = $queryPart[$facetName]; |
|
219 | - if ($facetName === $this->name) { |
|
220 | - |
|
221 | - if ($value === 'r' || $value === $labelReadOnly) { |
|
222 | - $permission = 'read'; |
|
223 | - } elseif ($value === 'w' || $value === $labelWrite) { |
|
224 | - $permission = 'write'; |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - return $permission; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Magic method implementation for retrieving state. |
|
233 | - * |
|
234 | - * @param array $states |
|
235 | - * @return $this |
|
236 | - */ |
|
237 | - static public function __set_state($states) |
|
238 | - { |
|
239 | - return new ActionPermissionFacet($states['name'], $states['label'], $states['suggestions'], $states['fieldNameAndPath']); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @return \TYPO3\CMS\Lang\LanguageService |
|
244 | - */ |
|
245 | - protected function getLanguageService() |
|
246 | - { |
|
247 | - return $GLOBALS['LANG']; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * @return ContentToFileConverter |
|
252 | - * @throws \InvalidArgumentException |
|
253 | - */ |
|
254 | - protected function getFileConverter() |
|
255 | - { |
|
256 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the Vidi Module Loader. |
|
261 | - * |
|
262 | - * @return ModuleLoader |
|
263 | - * @throws \InvalidArgumentException |
|
264 | - */ |
|
265 | - protected function getModuleLoader() |
|
266 | - { |
|
267 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
268 | - } |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $name = '__action_permission'; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission'; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $suggestions = array( |
|
40 | + 'r' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.read_only', |
|
41 | + 'w' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.write', |
|
42 | + ); |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $fieldNameAndPath = ''; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $dataType; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var bool |
|
56 | + */ |
|
57 | + protected $canModifyMatcher = false; |
|
58 | + |
|
59 | + /** |
|
60 | + * Constructor of a Generic Facet in Vidi. |
|
61 | + * |
|
62 | + * @param string $name |
|
63 | + * @param string $label |
|
64 | + * @param array $suggestions |
|
65 | + * @param string $fieldNameAndPath |
|
66 | + */ |
|
67 | + public function __construct($name = '', $label = '', array $suggestions = [], $fieldNameAndPath = '') |
|
68 | + { |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getName() |
|
75 | + { |
|
76 | + return $this->name; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function getLabel() |
|
83 | + { |
|
84 | + return $this->getLanguageService()->sL($this->label); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + public function getSuggestions() |
|
91 | + { |
|
92 | + $suggestions = []; |
|
93 | + foreach ($this->suggestions as $key => $label) { |
|
94 | + $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
95 | + } |
|
96 | + |
|
97 | + return $suggestions; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + public function hasSuggestions() |
|
104 | + { |
|
105 | + return true; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $dataType |
|
110 | + * @return $this |
|
111 | + */ |
|
112 | + public function setDataType($dataType) |
|
113 | + { |
|
114 | + $this->dataType = $dataType; |
|
115 | + return $this; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return bool |
|
120 | + */ |
|
121 | + public function canModifyMatcher() |
|
122 | + { |
|
123 | + return $this->canModifyMatcher; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @param Matcher $matcher |
|
128 | + * @param $value |
|
129 | + * @return Matcher |
|
130 | + */ |
|
131 | + public function modifyMatcher(Matcher $matcher, $value) |
|
132 | + { |
|
133 | + return $matcher; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @param AfterFindContentObjectsSignalArguments $signalArguments |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + public function modifyResultSet(AfterFindContentObjectsSignalArguments $signalArguments) |
|
141 | + { |
|
142 | + |
|
143 | + if ($signalArguments->getDataType() === 'sys_file') { |
|
144 | + |
|
145 | + $queryParts = $this->getQueryParts(); |
|
146 | + |
|
147 | + if (!empty($queryParts)) { |
|
148 | + $permission = $this->getPermissionValue($queryParts); |
|
149 | + |
|
150 | + if ($permission) { |
|
151 | + |
|
152 | + // We are force to query the content repository again here without limit |
|
153 | + $matcher = $signalArguments->getMatcher(); |
|
154 | + $order = $signalArguments->getOrder(); |
|
155 | + $objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order); |
|
156 | + |
|
157 | + $filteredObjects = []; |
|
158 | + foreach ($objects as $object) { |
|
159 | + |
|
160 | + $file = $this->getFileConverter()->convert($object->getUid()); |
|
161 | + if ($permission === 'read' && !$file->checkActionPermission('write')) { |
|
162 | + $filteredObjects[] = $object; |
|
163 | + } elseif ($permission === 'write' && $file->checkActionPermission('write')) { |
|
164 | + $filteredObjects[] = $object; |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + // Only take part of the array according to offset and limit. |
|
169 | + $offset = $signalArguments->getOffset(); |
|
170 | + $limit = $signalArguments->getLimit(); |
|
171 | + $signalArguments->setContentObjects(array_slice($filteredObjects, $offset, $limit)); |
|
172 | + |
|
173 | + // Count number of records |
|
174 | + $signalArguments->setNumberOfObjects(count($filteredObjects)); |
|
175 | + $signalArguments->setHasBeenProcessed(true); |
|
176 | + } |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + return array($signalArguments); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * @return array |
|
185 | + */ |
|
186 | + protected function getQueryParts() |
|
187 | + { |
|
188 | + |
|
189 | + // Transmit recursive selection parameter. |
|
190 | + $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
191 | + $parameters = GeneralUtility::_GP($parameterPrefix); |
|
192 | + |
|
193 | + $queryParts = []; |
|
194 | + if (!empty($parameters['searchTerm'])) { |
|
195 | + $query = rawurldecode($parameters['searchTerm']); |
|
196 | + $queryParts = json_decode($query, true); |
|
197 | + } |
|
198 | + |
|
199 | + return $queryParts; |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Retrieve the search permission value. |
|
204 | + * |
|
205 | + * @param array $queryParts |
|
206 | + * @return string |
|
207 | + */ |
|
208 | + protected function getPermissionValue(array $queryParts) |
|
209 | + { |
|
210 | + $permission = ''; |
|
211 | + |
|
212 | + // Check also amongst labels. |
|
213 | + $labelReadOnly = $this->getLanguageService()->sL($this->suggestions['r']); |
|
214 | + $labelWrite = $this->getLanguageService()->sL($this->suggestions['w']); |
|
215 | + |
|
216 | + foreach ($queryParts as $queryPart) { |
|
217 | + $facetName = key($queryPart); |
|
218 | + $value = $queryPart[$facetName]; |
|
219 | + if ($facetName === $this->name) { |
|
220 | + |
|
221 | + if ($value === 'r' || $value === $labelReadOnly) { |
|
222 | + $permission = 'read'; |
|
223 | + } elseif ($value === 'w' || $value === $labelWrite) { |
|
224 | + $permission = 'write'; |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + return $permission; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Magic method implementation for retrieving state. |
|
233 | + * |
|
234 | + * @param array $states |
|
235 | + * @return $this |
|
236 | + */ |
|
237 | + static public function __set_state($states) |
|
238 | + { |
|
239 | + return new ActionPermissionFacet($states['name'], $states['label'], $states['suggestions'], $states['fieldNameAndPath']); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @return \TYPO3\CMS\Lang\LanguageService |
|
244 | + */ |
|
245 | + protected function getLanguageService() |
|
246 | + { |
|
247 | + return $GLOBALS['LANG']; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * @return ContentToFileConverter |
|
252 | + * @throws \InvalidArgumentException |
|
253 | + */ |
|
254 | + protected function getFileConverter() |
|
255 | + { |
|
256 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the Vidi Module Loader. |
|
261 | + * |
|
262 | + * @return ModuleLoader |
|
263 | + * @throws \InvalidArgumentException |
|
264 | + */ |
|
265 | + protected function getModuleLoader() |
|
266 | + { |
|
267 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
268 | + } |
|
269 | 269 | |
270 | 270 | } |
@@ -19,45 +19,45 @@ |
||
19 | 19 | class ProcessedFileController extends ActionController |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Initializes the controller before invoking an action method. |
|
24 | - */ |
|
25 | - public function initializeAction() |
|
26 | - { |
|
27 | - |
|
28 | - // Configure property mapping to retrieve the file object. |
|
29 | - if ($this->arguments->hasArgument('file')) { |
|
30 | - |
|
31 | - /** @var \Fab\Media\TypeConverter\FileConverter $typeConverter */ |
|
32 | - $typeConverter = $this->objectManager->get('Fab\Media\TypeConverter\FileConverter'); |
|
33 | - |
|
34 | - $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
35 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Create a processed file according to some configuration. |
|
41 | - * |
|
42 | - * @param File $file |
|
43 | - * @param array $processingConfiguration |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function createAction(File $file, array $processingConfiguration = []) |
|
47 | - { |
|
48 | - $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration); |
|
49 | - |
|
50 | - $response = array( |
|
51 | - 'success' => true, |
|
52 | - 'original' => $file->getUid(), |
|
53 | - 'title' => $file->getProperty('title') ? $file->getProperty('title') : $file->getName(), |
|
54 | - 'publicUrl' => $processedFile->getPublicUrl(), |
|
55 | - 'width' => $processedFile->getProperty('width'), |
|
56 | - 'height' => $processedFile->getProperty('height'), |
|
57 | - ); |
|
58 | - |
|
59 | - header("Content-Type: text/json"); |
|
60 | - return htmlspecialchars(json_encode($response), ENT_NOQUOTES); |
|
61 | - } |
|
22 | + /** |
|
23 | + * Initializes the controller before invoking an action method. |
|
24 | + */ |
|
25 | + public function initializeAction() |
|
26 | + { |
|
27 | + |
|
28 | + // Configure property mapping to retrieve the file object. |
|
29 | + if ($this->arguments->hasArgument('file')) { |
|
30 | + |
|
31 | + /** @var \Fab\Media\TypeConverter\FileConverter $typeConverter */ |
|
32 | + $typeConverter = $this->objectManager->get('Fab\Media\TypeConverter\FileConverter'); |
|
33 | + |
|
34 | + $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
35 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Create a processed file according to some configuration. |
|
41 | + * |
|
42 | + * @param File $file |
|
43 | + * @param array $processingConfiguration |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function createAction(File $file, array $processingConfiguration = []) |
|
47 | + { |
|
48 | + $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration); |
|
49 | + |
|
50 | + $response = array( |
|
51 | + 'success' => true, |
|
52 | + 'original' => $file->getUid(), |
|
53 | + 'title' => $file->getProperty('title') ? $file->getProperty('title') : $file->getName(), |
|
54 | + 'publicUrl' => $processedFile->getPublicUrl(), |
|
55 | + 'width' => $processedFile->getProperty('width'), |
|
56 | + 'height' => $processedFile->getProperty('height'), |
|
57 | + ); |
|
58 | + |
|
59 | + header("Content-Type: text/json"); |
|
60 | + return htmlspecialchars(json_encode($response), ENT_NOQUOTES); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Renders a button for uploading assets. |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render() |
|
27 | - { |
|
28 | - $parameterPrefix = MediaModule::getParameterPrefix(); |
|
29 | - $output = " |
|
21 | + /** |
|
22 | + * Renders a button for uploading assets. |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render() |
|
27 | + { |
|
28 | + $parameterPrefix = MediaModule::getParameterPrefix(); |
|
29 | + $output = " |
|
30 | 30 | <script> |
31 | 31 | |
32 | 32 | window.Media = window.Media || {}; |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | |
35 | 35 | </script>"; |
36 | 36 | |
37 | - return $output; |
|
38 | - } |
|
37 | + return $output; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | } |
@@ -20,47 +20,47 @@ |
||
20 | 20 | class ChangeStorageMenuItem extends AbstractComponentView |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Renders a "change storage" menu item to be placed in the grid menu of Media. |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function render() |
|
29 | - { |
|
30 | - $output = ''; |
|
31 | - if (!$this->getMediaModule()->hasFolderTree()) { |
|
23 | + /** |
|
24 | + * Renders a "change storage" menu item to be placed in the grid menu of Media. |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function render() |
|
29 | + { |
|
30 | + $output = ''; |
|
31 | + if (!$this->getMediaModule()->hasFolderTree()) { |
|
32 | 32 | |
33 | 33 | |
34 | - $output = sprintf('<li><a href="%s" class="change-storage" >%s %s</a>', |
|
35 | - $this->getChangeStorageUri(), |
|
36 | - $this->getIconFactory()->getIcon('extensions-media-storage-change', Icon::SIZE_SMALL), |
|
37 | - $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:change_storage') |
|
38 | - ); |
|
34 | + $output = sprintf('<li><a href="%s" class="change-storage" >%s %s</a>', |
|
35 | + $this->getChangeStorageUri(), |
|
36 | + $this->getIconFactory()->getIcon('extensions-media-storage-change', Icon::SIZE_SMALL), |
|
37 | + $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:change_storage') |
|
38 | + ); |
|
39 | 39 | |
40 | - } |
|
41 | - return $output; |
|
42 | - } |
|
40 | + } |
|
41 | + return $output; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - protected function getChangeStorageUri() |
|
48 | - { |
|
49 | - $urlParameters = array( |
|
50 | - MediaModule::getParameterPrefix() => array( |
|
51 | - 'controller' => 'Asset', |
|
52 | - 'action' => 'editStorage', |
|
53 | - ), |
|
54 | - ); |
|
55 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
56 | - } |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + protected function getChangeStorageUri() |
|
48 | + { |
|
49 | + $urlParameters = array( |
|
50 | + MediaModule::getParameterPrefix() => array( |
|
51 | + 'controller' => 'Asset', |
|
52 | + 'action' => 'editStorage', |
|
53 | + ), |
|
54 | + ); |
|
55 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return object|MediaModule |
|
60 | - */ |
|
61 | - protected function getMediaModule() |
|
62 | - { |
|
63 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
64 | - } |
|
58 | + /** |
|
59 | + * @return object|MediaModule |
|
60 | + */ |
|
61 | + protected function getMediaModule() |
|
62 | + { |
|
63 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | |
4 | 4 | call_user_func(function () { |
5 | 5 | |
6 | - if (TYPO3_MODE === 'BE') { |
|
6 | + if (TYPO3_MODE === 'BE') { |
|
7 | 7 | |
8 | - $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
9 | - \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
10 | - )->get('media'); |
|
8 | + $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
9 | + \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
10 | + )->get('media'); |
|
11 | 11 | |
12 | - // Default User TSConfig to be added in any case. |
|
13 | - TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
12 | + // Default User TSConfig to be added in any case. |
|
13 | + TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
14 | 14 | |
15 | 15 | # Enable or disabled the Media File Picker in the BE |
16 | 16 | options.vidi.enableMediaFilePicker = 1 |
@@ -20,149 +20,149 @@ discard block |
||
20 | 20 | |
21 | 21 | '); |
22 | 22 | |
23 | - $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf'; |
|
24 | - if ($configuration['hide_file_list'] == 1) { |
|
23 | + $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf'; |
|
24 | + if ($configuration['hide_file_list'] == 1) { |
|
25 | 25 | |
26 | - $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang_filelist.xlf'; |
|
26 | + $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang_filelist.xlf'; |
|
27 | 27 | |
28 | - // Default User TSConfig to be added in any case. |
|
29 | - TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
28 | + // Default User TSConfig to be added in any case. |
|
29 | + TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
30 | 30 | |
31 | 31 | # Hide default File List |
32 | 32 | options.hideModules.file := addToList(FilelistList) |
33 | 33 | '); |
34 | - } |
|
35 | - |
|
36 | - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
37 | - 'Fab.media', |
|
38 | - 'user', // Make media module a submodule of 'user' |
|
39 | - 'm1', |
|
40 | - 'bottom', // Position |
|
41 | - [ |
|
42 | - 'Asset' => 'create, update, download, editStorage', |
|
43 | - 'ImageEditor' => 'show', |
|
44 | - 'LinkCreator' => 'show', |
|
45 | - 'ProcessedFile' => 'create', |
|
46 | - ], |
|
47 | - [ |
|
48 | - 'access' => 'user,group', |
|
49 | - 'icon' => 'EXT:media/Resources/Public/Icons/Extension.svg', |
|
50 | - 'labels' => 'LLL:EXT:media/Resources/Private/Language/locallang_module.xlf', |
|
51 | - ] |
|
52 | - ); |
|
53 | - |
|
54 | - $defaultMainModule = (bool)$configuration['has_folder_tree'] ? 'file' : 'content'; |
|
55 | - |
|
56 | - /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
57 | - $moduleLoader = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
58 | - \Fab\Vidi\Module\ModuleLoader::class, |
|
59 | - 'sys_file' |
|
60 | - ); |
|
61 | - $moduleLoader->setIcon('EXT:media/Resources/Public/Icons/Extension.svg') |
|
62 | - ->setModuleLanguageFile($moduleFileLanguage) |
|
63 | - ->setMainModule($defaultMainModule) |
|
64 | - ->addJavaScriptFiles([ |
|
65 | - 'EXT:media/Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js', |
|
66 | - ]) |
|
67 | - ->addStyleSheetFiles([ |
|
68 | - 'EXT:media/Resources/Public/StyleSheets/media.css', |
|
69 | - 'EXT:media/Resources/Public/StyleSheets/fineuploader.css', |
|
70 | - ]) |
|
71 | - ->setDocHeaderTopLeftComponents([ |
|
72 | - \Fab\Media\View\Menu\StorageMenu::class, |
|
73 | - \Fab\Media\View\Checkbox\RecursiveCheckbox::class,] |
|
74 | - ) |
|
75 | - ->setDocHeaderBottomLeftComponents([ |
|
76 | - \Fab\Vidi\View\Button\ClipboardButton::class, |
|
77 | - \Fab\Media\View\Button\NewFolder::class, |
|
78 | - \Fab\Media\View\Button\UploadButton::class, |
|
79 | - ]) |
|
80 | - ->setGridTopComponents([ |
|
81 | - \Fab\Media\View\InlineJavaScript::class, |
|
82 | - \Fab\Media\View\Warning\ConfigurationWarning::class, |
|
83 | - \Fab\Media\View\Info\SelectedFolderInfo::class, |
|
84 | - ]) |
|
85 | - ->setGridBottomComponents([ |
|
86 | - \Fab\Media\View\Plugin\LinkCreatorPlugin::class, |
|
87 | - \Fab\Media\View\Plugin\ImageEditorPlugin::class, |
|
88 | - \Fab\Media\View\Plugin\FilePickerPlugin::class, |
|
89 | - ]) |
|
90 | - ->setGridButtonsComponents([ |
|
91 | - \Fab\Media\View\Button\LinkCreatorButton::class, |
|
92 | - \Fab\Media\View\Button\ImageEditorButton::class, |
|
93 | - \Fab\Media\View\Button\FilePickerButton::class, |
|
94 | - \Fab\Media\View\Button\EditButton::class, |
|
95 | - \Fab\Media\View\Button\DownloadButton::class, |
|
96 | - \Fab\Media\View\Button\DeleteButton::class, |
|
97 | - ]) |
|
98 | - ->setMenuMassActionComponents([ |
|
99 | - \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
100 | - \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
101 | - \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
102 | - \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
103 | - |
|
104 | - // Media custom View Helper |
|
105 | - \Fab\Vidi\View\MenuItem\ClipboardMenuItem::class, |
|
106 | - \Fab\Media\View\MenuItem\FilePickerMenuItem::class, |
|
107 | - \Fab\Media\View\MenuItem\ChangeStorageMenuItem::class, |
|
108 | - \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
109 | - ]) |
|
110 | - ->register(); |
|
111 | - |
|
112 | - /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ |
|
113 | - $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
114 | - |
|
115 | - /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */ |
|
116 | - $signalSlotDispatcher = $objectManager->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); |
|
117 | - |
|
118 | - # Register some tool for Media. |
|
119 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\ThumbnailGeneratorTool::class); |
|
120 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\CacheWarmUpTool::class); |
|
121 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\MissingFilesFinderTool::class); |
|
122 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\DuplicateRecordsFinderTool::class); |
|
123 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\DuplicateFilesFinderTool::class); |
|
124 | - |
|
125 | - // Connect some signals with slots. |
|
126 | - $signalSlotDispatcher->connect( |
|
127 | - 'Fab\Vidi\Controller\Backend\ContentController', // Small exception in naming here as the class was previously located in "Controller\Backend". |
|
128 | - 'postProcessMatcherObject', |
|
129 | - \Fab\Media\Security\FilePermissionsAspect::class, |
|
130 | - 'addFilePermissionsForFileStorages' |
|
131 | - ); |
|
132 | - |
|
133 | - $signalSlotDispatcher->connect( |
|
134 | - \Fab\Vidi\Domain\Repository\ContentRepository::class, |
|
135 | - 'postProcessConstraintsObject', |
|
136 | - \Fab\Media\Security\FilePermissionsAspect::class, |
|
137 | - 'addFilePermissionsForFileMounts' |
|
138 | - ); |
|
139 | - |
|
140 | - $signalSlotDispatcher->connect( |
|
141 | - \Fab\Vidi\Service\ContentService::class, |
|
142 | - 'afterFindContentObjects', |
|
143 | - \Fab\Media\Facet\ActionPermissionFacet::class, |
|
144 | - 'modifyResultSet' |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - // Add new sprite icon. |
|
149 | - $icons = [ |
|
150 | - 'image-edit' => 'EXT:media/Resources/Public/Icons/image_edit.png', |
|
151 | - 'image-link' => 'EXT:media/Resources/Public/Icons/image_link.png', |
|
152 | - 'image-export' => 'EXT:media/Resources/Public/Icons/image_export.png', |
|
153 | - 'storage-change' => 'EXT:media/Resources/Public/Icons/folder_go.png', |
|
154 | - ]; |
|
155 | - /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ |
|
156 | - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); |
|
157 | - foreach ($icons as $key => $icon) { |
|
158 | - $iconRegistry->registerIcon('extensions-media-' . $key, |
|
159 | - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, |
|
160 | - [ |
|
161 | - 'source' => $icon |
|
162 | - ] |
|
163 | - ); |
|
164 | - } |
|
165 | - unset($iconRegistry); |
|
34 | + } |
|
35 | + |
|
36 | + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
37 | + 'Fab.media', |
|
38 | + 'user', // Make media module a submodule of 'user' |
|
39 | + 'm1', |
|
40 | + 'bottom', // Position |
|
41 | + [ |
|
42 | + 'Asset' => 'create, update, download, editStorage', |
|
43 | + 'ImageEditor' => 'show', |
|
44 | + 'LinkCreator' => 'show', |
|
45 | + 'ProcessedFile' => 'create', |
|
46 | + ], |
|
47 | + [ |
|
48 | + 'access' => 'user,group', |
|
49 | + 'icon' => 'EXT:media/Resources/Public/Icons/Extension.svg', |
|
50 | + 'labels' => 'LLL:EXT:media/Resources/Private/Language/locallang_module.xlf', |
|
51 | + ] |
|
52 | + ); |
|
53 | + |
|
54 | + $defaultMainModule = (bool)$configuration['has_folder_tree'] ? 'file' : 'content'; |
|
55 | + |
|
56 | + /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
57 | + $moduleLoader = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
58 | + \Fab\Vidi\Module\ModuleLoader::class, |
|
59 | + 'sys_file' |
|
60 | + ); |
|
61 | + $moduleLoader->setIcon('EXT:media/Resources/Public/Icons/Extension.svg') |
|
62 | + ->setModuleLanguageFile($moduleFileLanguage) |
|
63 | + ->setMainModule($defaultMainModule) |
|
64 | + ->addJavaScriptFiles([ |
|
65 | + 'EXT:media/Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js', |
|
66 | + ]) |
|
67 | + ->addStyleSheetFiles([ |
|
68 | + 'EXT:media/Resources/Public/StyleSheets/media.css', |
|
69 | + 'EXT:media/Resources/Public/StyleSheets/fineuploader.css', |
|
70 | + ]) |
|
71 | + ->setDocHeaderTopLeftComponents([ |
|
72 | + \Fab\Media\View\Menu\StorageMenu::class, |
|
73 | + \Fab\Media\View\Checkbox\RecursiveCheckbox::class,] |
|
74 | + ) |
|
75 | + ->setDocHeaderBottomLeftComponents([ |
|
76 | + \Fab\Vidi\View\Button\ClipboardButton::class, |
|
77 | + \Fab\Media\View\Button\NewFolder::class, |
|
78 | + \Fab\Media\View\Button\UploadButton::class, |
|
79 | + ]) |
|
80 | + ->setGridTopComponents([ |
|
81 | + \Fab\Media\View\InlineJavaScript::class, |
|
82 | + \Fab\Media\View\Warning\ConfigurationWarning::class, |
|
83 | + \Fab\Media\View\Info\SelectedFolderInfo::class, |
|
84 | + ]) |
|
85 | + ->setGridBottomComponents([ |
|
86 | + \Fab\Media\View\Plugin\LinkCreatorPlugin::class, |
|
87 | + \Fab\Media\View\Plugin\ImageEditorPlugin::class, |
|
88 | + \Fab\Media\View\Plugin\FilePickerPlugin::class, |
|
89 | + ]) |
|
90 | + ->setGridButtonsComponents([ |
|
91 | + \Fab\Media\View\Button\LinkCreatorButton::class, |
|
92 | + \Fab\Media\View\Button\ImageEditorButton::class, |
|
93 | + \Fab\Media\View\Button\FilePickerButton::class, |
|
94 | + \Fab\Media\View\Button\EditButton::class, |
|
95 | + \Fab\Media\View\Button\DownloadButton::class, |
|
96 | + \Fab\Media\View\Button\DeleteButton::class, |
|
97 | + ]) |
|
98 | + ->setMenuMassActionComponents([ |
|
99 | + \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
100 | + \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
101 | + \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
102 | + \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
103 | + |
|
104 | + // Media custom View Helper |
|
105 | + \Fab\Vidi\View\MenuItem\ClipboardMenuItem::class, |
|
106 | + \Fab\Media\View\MenuItem\FilePickerMenuItem::class, |
|
107 | + \Fab\Media\View\MenuItem\ChangeStorageMenuItem::class, |
|
108 | + \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
109 | + ]) |
|
110 | + ->register(); |
|
111 | + |
|
112 | + /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ |
|
113 | + $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
114 | + |
|
115 | + /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */ |
|
116 | + $signalSlotDispatcher = $objectManager->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); |
|
117 | + |
|
118 | + # Register some tool for Media. |
|
119 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\ThumbnailGeneratorTool::class); |
|
120 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\CacheWarmUpTool::class); |
|
121 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\MissingFilesFinderTool::class); |
|
122 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\DuplicateRecordsFinderTool::class); |
|
123 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', \Fab\Media\Tool\DuplicateFilesFinderTool::class); |
|
124 | + |
|
125 | + // Connect some signals with slots. |
|
126 | + $signalSlotDispatcher->connect( |
|
127 | + 'Fab\Vidi\Controller\Backend\ContentController', // Small exception in naming here as the class was previously located in "Controller\Backend". |
|
128 | + 'postProcessMatcherObject', |
|
129 | + \Fab\Media\Security\FilePermissionsAspect::class, |
|
130 | + 'addFilePermissionsForFileStorages' |
|
131 | + ); |
|
132 | + |
|
133 | + $signalSlotDispatcher->connect( |
|
134 | + \Fab\Vidi\Domain\Repository\ContentRepository::class, |
|
135 | + 'postProcessConstraintsObject', |
|
136 | + \Fab\Media\Security\FilePermissionsAspect::class, |
|
137 | + 'addFilePermissionsForFileMounts' |
|
138 | + ); |
|
139 | + |
|
140 | + $signalSlotDispatcher->connect( |
|
141 | + \Fab\Vidi\Service\ContentService::class, |
|
142 | + 'afterFindContentObjects', |
|
143 | + \Fab\Media\Facet\ActionPermissionFacet::class, |
|
144 | + 'modifyResultSet' |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + // Add new sprite icon. |
|
149 | + $icons = [ |
|
150 | + 'image-edit' => 'EXT:media/Resources/Public/Icons/image_edit.png', |
|
151 | + 'image-link' => 'EXT:media/Resources/Public/Icons/image_link.png', |
|
152 | + 'image-export' => 'EXT:media/Resources/Public/Icons/image_export.png', |
|
153 | + 'storage-change' => 'EXT:media/Resources/Public/Icons/folder_go.png', |
|
154 | + ]; |
|
155 | + /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ |
|
156 | + $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); |
|
157 | + foreach ($icons as $key => $icon) { |
|
158 | + $iconRegistry->registerIcon('extensions-media-' . $key, |
|
159 | + \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, |
|
160 | + [ |
|
161 | + 'source' => $icon |
|
162 | + ] |
|
163 | + ); |
|
164 | + } |
|
165 | + unset($iconRegistry); |
|
166 | 166 | |
167 | 167 | }); |
168 | 168 |
@@ -21,59 +21,59 @@ |
||
21 | 21 | class SelectedFolderInfo extends AbstractComponentView |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - public $notAllowedMountPoints = []; |
|
24 | + /** |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + public $notAllowedMountPoints = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Renders a button for uploading assets. |
|
31 | - * |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function render() |
|
35 | - { |
|
29 | + /** |
|
30 | + * Renders a button for uploading assets. |
|
31 | + * |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function render() |
|
35 | + { |
|
36 | 36 | |
37 | - $result = ''; |
|
38 | - if ($this->getMediaModule()->hasFolderTree()) { |
|
37 | + $result = ''; |
|
38 | + if ($this->getMediaModule()->hasFolderTree()) { |
|
39 | 39 | |
40 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
41 | - $result = sprintf('<h1>%s</h1>', $this->getFolderName($folder)); |
|
42 | - } |
|
40 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
41 | + $result = sprintf('<h1>%s</h1>', $this->getFolderName($folder)); |
|
42 | + } |
|
43 | 43 | |
44 | - return $result; |
|
45 | - } |
|
44 | + return $result; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get main headline based on active folder or storage for backend module |
|
49 | - * |
|
50 | - * Folder names are resolved to their special names like done in the tree view. |
|
51 | - * |
|
52 | - * @param Folder $folder |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - protected function getFolderName(Folder $folder) |
|
56 | - { |
|
57 | - $name = $folder->getName(); |
|
58 | - if ($name === '') { |
|
59 | - // Show storage name on storage root |
|
60 | - if ($folder->getIdentifier() === '/') { |
|
61 | - $name = $folder->getStorage()->getName(); |
|
62 | - } |
|
63 | - } else { |
|
64 | - $name = key(ListUtility::resolveSpecialFolderNames( |
|
65 | - array($name => $folder) |
|
66 | - )); |
|
67 | - } |
|
68 | - return $name; |
|
69 | - } |
|
47 | + /** |
|
48 | + * Get main headline based on active folder or storage for backend module |
|
49 | + * |
|
50 | + * Folder names are resolved to their special names like done in the tree view. |
|
51 | + * |
|
52 | + * @param Folder $folder |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + protected function getFolderName(Folder $folder) |
|
56 | + { |
|
57 | + $name = $folder->getName(); |
|
58 | + if ($name === '') { |
|
59 | + // Show storage name on storage root |
|
60 | + if ($folder->getIdentifier() === '/') { |
|
61 | + $name = $folder->getStorage()->getName(); |
|
62 | + } |
|
63 | + } else { |
|
64 | + $name = key(ListUtility::resolveSpecialFolderNames( |
|
65 | + array($name => $folder) |
|
66 | + )); |
|
67 | + } |
|
68 | + return $name; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return MediaModule|object |
|
73 | - */ |
|
74 | - protected function getMediaModule() |
|
75 | - { |
|
76 | - return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
77 | - } |
|
71 | + /** |
|
72 | + * @return MediaModule|object |
|
73 | + */ |
|
74 | + protected function getMediaModule() |
|
75 | + { |
|
76 | + return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | } |