1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the package typo3/cms-digital-asset-management. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please read the |
8
|
|
|
* LICENSE file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace TYPO3\CMS\DigitalAssetManagement\ContextMenu\ItemProviders; |
12
|
|
|
|
13
|
|
|
use TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider; |
14
|
|
|
use TYPO3\CMS\Core\Resource\FolderInterface; |
15
|
|
|
use TYPO3\CMS\Core\Resource\ResourceFactory; |
16
|
|
|
use TYPO3\CMS\Core\Resource\ResourceStorage; |
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Click menu on a storage or file mount |
21
|
|
|
* 'table' argument must be 'damStoragesAndMounts-drag' |
22
|
|
|
* 'uid' argument must be either the uid of a sys_file_storage, or a combinedIdentifier for a file mount |
23
|
|
|
*/ |
24
|
|
|
class StoragesAndMountsProvider extends AbstractProvider |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected $itemsConfiguration = [ |
30
|
|
|
'newFile' => [ |
31
|
|
|
'label' => 'New File', |
32
|
|
|
'iconIdentifier' => 'actions-page-new', |
33
|
|
|
'callbackAction' => '', |
34
|
|
|
], |
35
|
|
|
'newFolder' => [ |
36
|
|
|
'label' => 'New Folder', |
37
|
|
|
'iconIdentifier' => 'actions-folder', |
38
|
|
|
'callbackAction' => '', |
39
|
|
|
], |
40
|
|
|
'upload' => [ |
41
|
|
|
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.upload', |
42
|
|
|
'iconIdentifier' => 'actions-edit-upload', |
43
|
|
|
'callbackAction' => '' |
44
|
|
|
], |
45
|
|
|
'editStorage' => [ |
46
|
|
|
'label' => 'Edit Storage', |
47
|
|
|
'iconIdentifier' => 'actions-open', |
48
|
|
|
'callbackAction' => '' |
49
|
|
|
], |
50
|
|
|
'info' => [ |
51
|
|
|
'label' => 'Details', |
52
|
|
|
'iconIdentifier' => 'actions-document-info', |
53
|
|
|
'callbackAction' => '' |
54
|
|
|
], |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var ResourceStorage |
59
|
|
|
*/ |
60
|
|
|
protected $storage; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var FolderInterface |
64
|
|
|
*/ |
65
|
|
|
protected $mount; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function canHandle(): bool |
71
|
|
|
{ |
72
|
|
|
// -drag suffix used to shut down ext:impexp provider that would add import and export items |
73
|
|
|
return $this->table === 'damStoragesAndMounts-drag'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function initialize() |
77
|
|
|
{ |
78
|
|
|
parent::initialize(); |
79
|
|
|
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); |
80
|
|
|
if (is_numeric($this->identifier)) { |
81
|
|
|
$this->storage = $resourceFactory->getStorageObject($this->identifier); |
82
|
|
|
} else { |
83
|
|
|
$this->mount = $resourceFactory->retrieveFileOrFolderObject($this->identifier); |
84
|
|
|
if (!$this->mount instanceof FolderInterface) { |
85
|
|
|
throw new \InvalidArgumentException('uid must be either the uid of a storage, or a file mount folder'); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
protected function canRender(string $itemName, string $type): bool |
91
|
|
|
{ |
92
|
|
|
if ($itemName === 'editStorage' && !$this->storage instanceof ResourceStorage) { |
|
|
|
|
93
|
|
|
return false; |
94
|
|
|
} |
95
|
|
|
return true; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|