2 declare(strict_types = 1);
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
50 'main' =>
'Using CreateFolderController::main() is deprecated and will not be possible anymore in TYPO3 v10.0.',
57 'number' =>
'Using $number of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
58 'folderNumber' =>
'Using $folderNumber of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
59 'target' =>
'Using $target of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
60 'content' =>
'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
61 'returnUrl' =>
'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
62 'title' =>
'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
129 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
140 public function mainAction(ServerRequestInterface $request): ResponseInterface
143 return new HtmlResponse($this->moduleTemplate->renderContent());
152 protected function init(ServerRequestInterface $request): void
154 $parsedBody = $request->getParsedBody();
155 $queryParams = $request->getQueryParams();
157 $this->number = $parsedBody[
'number'] ?? $queryParams[
'number'] ?? 0;
158 $this->target = ($combinedIdentifier = $parsedBody[
'target'] ?? $queryParams[
'target'] ??
'');
159 $this->returnUrl = GeneralUtility::sanitizeLocalUrl($parsedBody[
'returnUrl'] ?? $queryParams[
'returnUrl'] ??
'');
161 if ($combinedIdentifier) {
166 if (!$this->folderObject) {
168 $message = $this->
getLanguageService()->
sL(
'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:targetNoDir');
169 throw new \RuntimeException(
$title .
': ' . $message, 1294586845);
171 if ($this->folderObject->getStorage()->getUid() === 0) {
172 throw new InsufficientFolderAccessPermissionsException(
173 'You are not allowed to access folders outside your storages',
179 'combined_identifier' => $this->folderObject->getCombinedIdentifier(),
181 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
183 $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation(
$pathInfo);
184 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/ContextMenu');
185 $this->moduleTemplate->addJavaScriptCode(
186 'CreateFolderInlineJavaScript',
187 'var path = "' . $this->target .
'";
189 . GeneralUtility::quoteJSvalue(
190 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')
194 . GeneralUtility::quoteJSvalue(
195 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.redraw')
199 var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . rawurlencode($this->returnUrl) .
'";
200 var url = \'' . (
string)$uriBuilder->buildUriFromRoute(
'file_newfolder') .
'\';
202 window.location.href = url + params;
204 var modal = top.TYPO3.Modal.confirm(confirmTitle, confirmText);
205 modal.on(\
'confirm.button.cancel\', function(e) {
206 top.TYPO3.Modal.currentModal.trigger(\'modal-dismiss\');
208 modal.on(\'confirm.button.ok\', function(e) {
209 top.TYPO3.Modal.currentModal.trigger(\'modal-dismiss\');
210 window.location.href = url + params;
214 function backToList() {
215 top.goToModule("file_FilelistList");
224 protected function main()
229 if ($this->folderObject->checkActionPermission(
'add')) {
230 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
231 $assigns[
'moduleUrlTceFile'] = (string)$uriBuilder->buildUriFromRoute(
'tce_file');
237 $options[
'value'] = $a;
238 $options[
'selected'] = ($this->number == $a ?
' selected="selected"' :
'');
239 $assigns[
'options'][] = $options;
244 $folder[
'this'] = $a;
245 $folder[
'next'] = $a + 1;
246 $assigns[
'folders'][] = $folder;
252 if ($this->folderObject->getStorage()->checkUserActionPermission(
'add',
'File')) {
253 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
254 $assigns[
'moduleUrlOnlineMedia'] = (string)$uriBuilder->buildUriFromRoute(
'online_media');
259 foreach ($onlineMediaFileExt as $fileExt) {
260 if (GeneralUtility::verifyFilenameAgainstDenyPattern(
'.' . $fileExt)) {
261 $fileExtList[] = strtoupper(htmlspecialchars($fileExt));
264 $assigns[
'fileExtList'] = $fileExtList;
266 $assigns[
'moduleUrlTceFile'] = (string)$uriBuilder->buildUriFromRoute(
'tce_file');
270 $textFileExt = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'textfile_ext'],
true);
271 foreach ($textFileExt as $fileExt) {
272 if (GeneralUtility::verifyFilenameAgainstDenyPattern(
'.' . $fileExt)) {
273 $fileExtList[] = strtoupper(htmlspecialchars($fileExt));
276 $assigns[
'txtFileExtList'] = $fileExtList;
279 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
281 $helpButton = $buttonBar->makeHelpButton()
282 ->setFieldName(
'file_new')
283 ->setModuleName(
'xMOD_csh_corebe');
284 $buttonBar->addButton($helpButton);
287 if ($this->returnUrl) {
288 $backButton = $buttonBar->makeLinkButton()
289 ->setHref($this->returnUrl)
290 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
291 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-view-go-back',
Icon::SIZE_SMALL));
292 $buttonBar->addButton($backButton);
296 $view = GeneralUtility::makeInstance(StandaloneView::class);
297 $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName(
'EXT:backend/Resources/Private/Templates')]);
298 $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName(
'EXT:backend/Resources/Private/Partials')]);
299 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
300 'EXT:backend/Resources/Private/Templates/File/CreateFolder.html'
302 $view->assignMultiple($assigns);
303 $this->moduleTemplate->setContent($view->render());