-
Notifications
You must be signed in to change notification settings - Fork 25
/
ext_tables.php
210 lines (189 loc) · 7.57 KB
/
ext_tables.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use Fab\Media\Controller\AssetController;
use Fab\Media\Controller\ImageEditorController;
use Fab\Media\Controller\LinkCreatorController;
use Fab\Media\Controller\ProcessedFileController;
use Fab\Vidi\Module\ModuleLoader;
use Fab\Media\View\Menu\StorageMenu;
use Fab\Media\View\Checkbox\RecursiveCheckbox;
use Fab\Vidi\View\Button\ClipboardButton;
use Fab\Media\View\Button\NewFolder;
use Fab\Media\View\Button\UploadButton;
use Fab\Media\View\InlineJavaScript;
use Fab\Media\View\Warning\ConfigurationWarning;
use Fab\Media\View\Info\SelectedFolderInfo;
use Fab\Media\View\Plugin\LinkCreatorPlugin;
use Fab\Media\View\Plugin\ImageEditorPlugin;
use Fab\Media\View\Plugin\FilePickerPlugin;
use Fab\Media\View\Button\LinkCreatorButton;
use Fab\Media\View\Button\ImageEditorButton;
use Fab\Media\View\Button\FilePickerButton;
use Fab\Media\View\Button\EditButton;
use Fab\Media\View\Button\DownloadButton;
use Fab\Media\View\Button\DeleteButton;
use Fab\Vidi\View\MenuItem\ExportXlsMenuItem;
use Fab\Vidi\View\MenuItem\ExportXmlMenuItem;
use Fab\Vidi\View\MenuItem\ExportCsvMenuItem;
use Fab\Vidi\View\MenuItem\DividerMenuItem;
use Fab\Vidi\View\MenuItem\ClipboardMenuItem;
use Fab\Media\View\MenuItem\FilePickerMenuItem;
use Fab\Media\View\MenuItem\ChangeStorageMenuItem;
use Fab\Vidi\View\MenuItem\MassDeleteMenuItem;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use Fab\Vidi\Tool\ToolRegistry;
use Fab\Media\Tool\ThumbnailGeneratorTool;
use Fab\Media\Tool\CacheWarmUpTool;
use Fab\Media\Tool\MissingFilesFinderTool;
use Fab\Media\Tool\DuplicateRecordsFinderTool;
use Fab\Media\Tool\DuplicateFilesFinderTool;
use Fab\Media\Security\FilePermissionsAspect;
use Fab\Vidi\Domain\Repository\ContentRepository;
use Fab\Vidi\Service\ContentService;
use Fab\Media\Facet\ActionPermissionFacet;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
use TYPO3\CMS\Core\Utility\GeneralUtility;
defined('TYPO3') or die();
call_user_func(function () {
$configuration = GeneralUtility::makeInstance(
ExtensionConfiguration::class
)->get('media');
// Default User TSConfig to be added in any case.
ExtensionManagementUtility::addUserTSConfig('
# Enable or disabled the Media File Picker in the BE
options.vidi.enableMediaFilePicker = 1
# Hide the module in the BE.
options.hideModules.user := addToList(MediaM1)
');
$moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf';
if ($configuration['hide_file_list'] == 1) {
$moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang_filelist.xlf';
// Default User TSConfig to be added in any case.
ExtensionManagementUtility::addUserTSConfig('
# Hide default File List
options.hideModules.file := addToList(FilelistList)
');
}
ExtensionUtility::registerModule(
'Media',
'user', // Make media module a submodule of 'user'
'm1',
'bottom', // Position
[
AssetController::class => 'create, update, download, editStorage',
ImageEditorController::class => 'show',
LinkCreatorController::class => 'show',
ProcessedFileController::class => 'create',
],
[
'access' => 'user,group',
'icon' => 'EXT:media/Resources/Public/Icons/Extension.svg',
'labels' => 'LLL:EXT:media/Resources/Private/Language/locallang_module.xlf',
]
);
$defaultMainModule = (bool)$configuration['has_folder_tree'] ? 'file' : 'content';
/** @var ModuleLoader $moduleLoader */
$moduleLoader = GeneralUtility::makeInstance(
ModuleLoader::class,
'sys_file'
);
$moduleLoader->setIcon('EXT:media/Resources/Public/Icons/Extension.svg')
->setModuleLanguageFile($moduleFileLanguage)
->setMainModule($defaultMainModule)
->addJavaScriptFiles([
'EXT:media/Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js',
])
->addStyleSheetFiles([
'EXT:media/Resources/Public/StyleSheets/media.css',
'EXT:media/Resources/Public/StyleSheets/fineuploader.css',
])
->setDocHeaderTopLeftComponents(
[
StorageMenu::class,
RecursiveCheckbox::class,]
)
->setDocHeaderBottomLeftComponents([
ClipboardButton::class,
NewFolder::class,
UploadButton::class,
])
->setGridTopComponents([
InlineJavaScript::class,
ConfigurationWarning::class,
SelectedFolderInfo::class,
])
->setGridBottomComponents([
LinkCreatorPlugin::class,
ImageEditorPlugin::class,
FilePickerPlugin::class,
])
->setGridButtonsComponents([
LinkCreatorButton::class,
ImageEditorButton::class,
FilePickerButton::class,
EditButton::class,
DownloadButton::class,
DeleteButton::class,
])
->setMenuMassActionComponents([
ExportXlsMenuItem::class,
ExportXmlMenuItem::class,
ExportCsvMenuItem::class,
DividerMenuItem::class,
// Media custom View Helper
ClipboardMenuItem::class,
FilePickerMenuItem::class,
ChangeStorageMenuItem::class,
MassDeleteMenuItem::class,
])
->register();
/** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */
$signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
# Register some tool for Media.
ToolRegistry::getInstance()->register('sys_file', ThumbnailGeneratorTool::class);
ToolRegistry::getInstance()->register('sys_file', CacheWarmUpTool::class);
ToolRegistry::getInstance()->register('sys_file', MissingFilesFinderTool::class);
ToolRegistry::getInstance()->register('sys_file', DuplicateRecordsFinderTool::class);
ToolRegistry::getInstance()->register('sys_file', DuplicateFilesFinderTool::class);
// Connect some signals with slots.
$signalSlotDispatcher->connect(
'Fab\Vidi\Controller\Backend\ContentController', // Small exception in naming here as the class was previously located in "Controller\Backend".
'postProcessMatcherObject',
FilePermissionsAspect::class,
'addFilePermissionsForFileStorages'
);
$signalSlotDispatcher->connect(
ContentRepository::class,
'postProcessConstraintsObject',
FilePermissionsAspect::class,
'addFilePermissionsForFileMounts'
);
$signalSlotDispatcher->connect(
ContentService::class,
'afterFindContentObjects',
ActionPermissionFacet::class,
'modifyResultSet'
);
// Add new sprite icon.
$icons = [
'image-edit' => 'EXT:media/Resources/Public/Icons/image_edit.png',
'image-link' => 'EXT:media/Resources/Public/Icons/image_link.png',
'image-export' => 'EXT:media/Resources/Public/Icons/image_export.png',
'storage-change' => 'EXT:media/Resources/Public/Icons/folder_go.png',
];
/** @var IconRegistry $iconRegistry */
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
foreach ($icons as $key => $icon) {
$iconRegistry->registerIcon(
'extensions-media-' . $key,
BitmapIconProvider::class,
[
'source' => $icon
]
);
}
unset($iconRegistry);
});