2 declare(strict_types = 1);
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
41 'title' =>
'Using $title of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
42 'target' =>
'Using $target of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
43 'returnUrl' =>
'Using $returnUrl of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
44 'content' =>
'Using $content of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
94 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
107 public function mainAction(ServerRequestInterface $request): ResponseInterface
118 public function main()
120 trigger_error(
'FileUploadController->main() will be replaced by protected method renderContent() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
132 trigger_error(
'FileUploadController->renderUploadForm() will be replaced by protected method renderUploadFormInternal() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
142 protected function init(ServerRequestInterface $request): void
144 $parsedBody = $request->getParsedBody();
145 $queryParams = $request->getQueryParams();
148 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
150 $this->target = $parsedBody[
'target'] ?? $queryParams[
'target'] ??
null;
151 $this->returnUrl = GeneralUtility::sanitizeLocalUrl($parsedBody[
'returnUrl'] ?? $queryParams[
'returnUrl'] ??
'');
152 if (!$this->returnUrl) {
153 $this->returnUrl = (string)$uriBuilder->buildUriFromRoute(
'file_list', [
154 'id' => rawurlencode($this->target)
162 if ($this->folderObject->getStorage()->getUid() === 0) {
163 throw new InsufficientFolderAccessPermissionsException(
164 'You are not allowed to access folders outside your storages',
170 if (!$this->folderObject) {
172 $message = $this->
getLanguageService()->
sL(
'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:targetNoDir');
173 throw new \RuntimeException(
$title .
': ' . $message, 1294586843);
177 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/ContextMenu');
181 'combined_identifier' => $this->folderObject->getCombinedIdentifier(),
183 $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pathInfo);
193 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
196 $this->moduleTemplate->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.php.pagetitle'));
198 $pageContent =
'<form action="'
199 . htmlspecialchars((
string)$uriBuilder->buildUriFromRoute(
'tce_file'))
200 .
'" method="post" id="FileUploadController" name="editform" enctype="multipart/form-data">';
202 $pageContent .=
'<h1>' . $lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.php.pagetitle') .
'</h1>';
206 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
209 $cshButton = $buttonBar->makeHelpButton()
210 ->setModuleName(
'xMOD_csh_corebe')
211 ->setFieldName(
'file_upload');
212 $buttonBar->addButton($cshButton);
215 if ($this->returnUrl) {
216 $backButton = $buttonBar->makeLinkButton()
217 ->setHref($this->returnUrl)
218 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
219 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-view-go-back',
Icon::SIZE_SMALL));
220 $buttonBar->addButton($backButton);
223 $pageContent .=
'</form>';
224 $this->content .=
'<div>' . $pageContent .
'</div>';
225 $this->moduleTemplate->setContent($this->content);
236 <div class="form-group">
237 <input type="file" multiple="multiple" class="form-control" name="upload_1[]" />
238 <input type="hidden" name="data[upload][1][target]" value="' . htmlspecialchars($this->folderObject->getCombinedIdentifier()) .
'" />
239 <input type="hidden" name="data[upload][1][data]" value="1" />
241 <div class="checkbox">
242 <label for="overwriteExistingFiles">
243 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="replace" /> ' . htmlspecialchars($this->
getLanguageService()->getLL(
'overwriteExistingFiles')) .
'</label>
246 <input type="hidden" name="data[upload][1][redirect]" value="' . $this->returnUrl .
'" />
247 <input class="btn btn-primary" type="submit" value="' . htmlspecialchars($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.php.submit')) .
'" />
249 <div class="callout callout-warning">