|
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\Controller; |
|
12
|
|
|
|
|
13
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
14
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
15
|
|
|
use TYPO3\CMS\Backend\Template\ModuleTemplate; |
|
16
|
|
|
use TYPO3\CMS\Core\Context\Context; |
|
17
|
|
|
use TYPO3\CMS\Core\Http\HtmlResponse; |
|
18
|
|
|
use TYPO3\CMS\Core\Page\PageRenderer; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Backend controller: The "Digital Asset Management" module |
|
24
|
|
|
* |
|
25
|
|
|
* Optional replacement of filelist |
|
26
|
|
|
*/ |
|
27
|
|
|
class DigitalAssetManagementController |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var ModuleTemplate |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $moduleTemplate; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var StandaloneView |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $view; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Default constructor |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param string $templateName |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function initializeView(string $templateName): void |
|
51
|
|
|
{ |
|
52
|
|
|
$this->view = GeneralUtility::makeInstance(StandaloneView::class); |
|
53
|
|
|
$this->view->setTemplate($templateName); |
|
54
|
|
|
$this->view->setTemplateRootPaths(['EXT:digital_asset_management/Resources/Private/Templates']); |
|
55
|
|
|
$this->view->setPartialRootPaths(['EXT:digital_asset_management/Resources/Private/Partials']); |
|
56
|
|
|
$this->view->setLayoutRootPaths(['EXT:digital_asset_management/Resources/Private/Layouts']); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Main entry method: Dispatch to other actions - those method names that end with "Action". |
|
61
|
|
|
* |
|
62
|
|
|
* @param ServerRequestInterface $request the current request |
|
63
|
|
|
* @return ResponseInterface the response with the content |
|
64
|
|
|
*/ |
|
65
|
|
|
public function handleRequest(ServerRequestInterface $request): ResponseInterface |
|
|
|
|
|
|
66
|
|
|
{ |
|
67
|
|
|
$backendUser = GeneralUtility::makeInstance(Context::class)->getAspect('backend.user'); |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var PageRenderer $pageRenderer |
|
71
|
|
|
*/ |
|
72
|
|
|
$pageRenderer = $this->moduleTemplate->getPageRenderer(); |
|
73
|
|
|
$pageRenderer->loadRequireJsModule('TYPO3/CMS/DigitalAssetManagement/DigitalAssetManagementActions'); |
|
74
|
|
|
$pageRenderer->addCssFile('EXT:backend/Resources/Public/Css/backend.css'); |
|
75
|
|
|
$pageRenderer->addCssFile('EXT:digital_asset_management/Resources/Public/JavaScript/Library/filelist.css'); |
|
76
|
|
|
$pageRenderer->addInlineLanguageLabelFile('EXT:digital_asset_management/Resources/Private/Language/locallang_mod.xlf'); |
|
77
|
|
|
$pageRenderer->addInlineLanguageLabelFile('EXT:digital_asset_management/Resources/Private/Language/locallang_vue.xlf'); |
|
78
|
|
|
$pageRenderer->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/locallang_core.xlf', 'file_upload'); |
|
79
|
|
|
$pageRenderer->addInlineSettingArray('BackendUser', [ |
|
80
|
|
|
'isAdmin' => $backendUser->isAdmin(), |
|
81
|
|
|
'username' => $backendUser->get('username'), |
|
82
|
|
|
]); |
|
83
|
|
|
$this->initializeView('index'); |
|
84
|
|
|
// Add shortcut button |
|
85
|
|
|
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); |
|
86
|
|
|
$myButton = $buttonBar->makeShortcutButton()->setModuleName('dam'); |
|
87
|
|
|
$buttonBar->addButton($myButton); |
|
88
|
|
|
$this->moduleTemplate->setContent($this->view->render()); |
|
89
|
|
|
return new HtmlResponse($this->moduleTemplate->renderContent()); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.