/** * Create the panel of buttons for submitting the form or otherwise perform operations. * * @return array All available buttons as an assoc. array */ protected function registerButtons() { /** @var ButtonBar $buttonBar */ $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); /** @var IconFactory $iconFactory */ $iconFactory = $this->view->getModuleTemplate()->getIconFactory(); /** @var $resourceFactory ResourceFactory */ $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); $lang = $this->getLanguageService(); // Refresh page $refreshLink = GeneralUtility::linkThisScript(['target' => rawurlencode($this->folderObject->getCombinedIdentifier()), 'imagemode' => $this->filelist->thumbs]); $refreshButton = $buttonBar->makeLinkButton()->setHref($refreshLink)->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload'))->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)); $buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT); // Level up try { $currentStorage = $this->folderObject->getStorage(); $parentFolder = $this->folderObject->getParentFolder(); if ($parentFolder->getIdentifier() !== $this->folderObject->getIdentifier() && $currentStorage->isWithinFileMountBoundaries($parentFolder)) { $levelUpClick = 'top.document.getElementsByName("navigation")[0].contentWindow.Tree.highlightActiveItem("file","folder' . GeneralUtility::md5int($parentFolder->getCombinedIdentifier()) . '_"+top.fsMod.currentBank)'; $levelUpButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('file_FilelistList', ['id' => $parentFolder->getCombinedIdentifier()]))->setOnClick($levelUpClick)->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.upOneLevel'))->setIcon($iconFactory->getIcon('actions-view-go-up', Icon::SIZE_SMALL)); $buttonBar->addButton($levelUpButton, ButtonBar::BUTTON_POSITION_LEFT, 1); } } catch (\Exception $e) { } // Shortcut if ($this->getBackendUser()->mayMakeShortcut()) { $shortCutButton = $buttonBar->makeShortcutButton()->setModuleName('file_FilelistList'); $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT); } // Upload button (only if upload to this directory is allowed) if ($this->folderObject && $this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $uploadButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('file_upload', ['target' => $this->folderObject->getCombinedIdentifier(), 'returnUrl' => $this->filelist->listURL()]))->setClasses('t3js-drag-uploader-trigger')->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.upload'))->setIcon($iconFactory->getIcon('actions-edit-upload', Icon::SIZE_SMALL)); $buttonBar->addButton($uploadButton, ButtonBar::BUTTON_POSITION_LEFT, 1); } // New folder button if ($this->folderObject && $this->folderObject->checkActionPermission('write') && ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') || $this->folderObject->checkActionPermission('add'))) { $newButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('file_newfolder', ['target' => $this->folderObject->getCombinedIdentifier(), 'returnUrl' => $this->filelist->listURL()]))->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.new'))->setIcon($iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)); $buttonBar->addButton($newButton, ButtonBar::BUTTON_POSITION_LEFT, 1); } // Add paste button if clipboard is initialized if ($this->filelist->clipObj instanceof Clipboard && $this->folderObject->checkActionPermission('write')) { $elFromTable = $this->filelist->clipObj->elFromTable('_FILE'); if (!empty($elFromTable)) { $addPasteButton = true; $elToConfirm = []; foreach ($elFromTable as $key => $element) { $clipBoardElement = $resourceFactory->retrieveFileOrFolderObject($element); if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $this->folderObject)) { $addPasteButton = false; } $elToConfirm[$key] = $clipBoardElement->getName(); } if ($addPasteButton) { $confirmText = $this->filelist->clipObj->confirmMsgText('_FILE', $this->folderObject->getReadablePath(), 'into', $elToConfirm); $pasteButton = $buttonBar->makeLinkButton()->setHref($this->filelist->clipObj->pasteUrl('_FILE', $this->folderObject->getCombinedIdentifier()))->setClasses('t3js-modal-trigger')->setDataAttributes(['severity' => 'warning', 'content' => $confirmText, 'title' => $lang->getLL('clip_paste')])->setTitle($lang->getLL('clip_paste'))->setIcon($iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)); $buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 2); } } } }
/** * Create the panel of buttons for submitting the form or otherwise perform operations. * * @return array All available buttons as an assoc. array */ public function getButtons() { $buttons = array('csh' => '', 'shortcut' => '', 'upload' => '', 'new' => ''); // Add shortcut if ($this->getBackendUser()->mayMakeShortcut()) { $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table', implode(',', array_keys($this->MOD_MENU)), $this->moduleName); } // FileList Module CSH: $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'filelist_module'); // Upload button (only if upload to this directory is allowed) if ($this->folderObject && $this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $buttons['upload'] = '<a href="' . htmlspecialchars($GLOBALS['BACK_PATH'] . BackendUtility::getModuleUrl('file_upload', array('target' => $this->folderObject->getCombinedIdentifier(), 'returnUrl' => $this->filelist->listURL()))) . '" id="button-upload" title="' . $this->getLanguageService()->makeEntities($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.upload', TRUE)) . '">' . IconUtility::getSpriteIcon('actions-edit-upload') . '</a>'; } // New folder button if ($this->folderObject && $this->folderObject->checkActionPermission('write') && ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') || $this->folderObject->checkActionPermission('add'))) { $buttons['new'] = '<a href="' . htmlspecialchars($GLOBALS['BACK_PATH'] . BackendUtility::getModuleUrl('file_newfolder', array('target' => $this->folderObject->getCombinedIdentifier(), 'returnUrl' => $this->filelist->listURL()))) . '" title="' . $this->getLanguageService()->makeEntities($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new', TRUE)) . '">' . IconUtility::getSpriteIcon('actions-document-new') . '</a>'; } return $buttons; }
/** * Init file/folder parameters */ protected function initFileOrFolderRecord() { $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid); if ($fileOrFolderObject instanceof Folder) { $this->folderObject = $fileOrFolderObject; $this->access = $this->folderObject->checkActionPermission('read'); $this->type = 'folder'; } else { $this->fileObject = $fileOrFolderObject; $this->access = $this->fileObject->checkActionPermission('read'); $this->type = 'file'; $this->table = 'sys_file'; try { $this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid()); } catch (\Exception $e) { $this->row = array(); } } }
/** * Create the panel of buttons for submitting the form or otherwise perform operations. * * @return array All available buttons as an assoc. array * @todo Define visibility */ public function getButtons() { $buttons = array('csh' => '', 'shortcut' => '', 'upload' => '', 'new' => ''); // Add shortcut if ($GLOBALS['BE_USER']->mayMakeShortcut()) { $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']); } // FileList Module CSH: $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE); // Upload button (only if upload to this directory is allowed) if ($this->folderObject && $this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $buttons['upload'] = '<a href="' . $GLOBALS['BACK_PATH'] . 'file_upload.php?target=' . rawurlencode($this->folderObject->getCombinedIdentifier()) . '&returnUrl=' . rawurlencode($this->filelist->listURL()) . '" id="button-upload" title="' . $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.upload', TRUE)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-upload') . '</a>'; } // New folder button if ($this->folderObject && $this->folderObject->checkActionPermission('write') && ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') || $this->folderObject->checkActionPermission('add'))) { $buttons['new'] = '<a href="' . $GLOBALS['BACK_PATH'] . 'file_newfolder.php?target=' . rawurlencode($this->folderObject->getCombinedIdentifier()) . '&returnUrl=' . rawurlencode($this->filelist->listURL()) . '" title="' . $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.new', TRUE)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-new') . '</a>'; } return $buttons; }
/** * Init file/folder parameters */ protected function initFileOrFolderRecord() { $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid); if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) { $this->folderObject = $fileOrFolderObject; $this->access = $this->folderObject->checkActionPermission('read'); $this->type = 'folder'; } else { $this->fileObject = $fileOrFolderObject; $this->access = $this->fileObject->checkActionPermission('read'); $this->type = 'file'; $this->table = 'sys_file_metadata'; try { $metaData = $fileOrFolderObject->_getMetaData(); $this->row = BackendUtility::getRecordWSOL($this->table, $metaData['uid']); } catch (\Exception $e) { $this->row = array(); } } }
/** * For RTE: This displays all files from folder. No thumbnails shown * * @param Folder $folder The folder path to expand * @param string $extensionList List of file extensions to show * @return string HTML output */ public function expandFolder(Folder $folder, $extensionList = '') { if (!$folder->checkActionPermission('read')) { return ''; } $out = '<h3>' . htmlspecialchars($this->getTitle()) . ':</h3>'; // Create header element; The folder from which files are listed. $titleLen = (int) $this->getBackendUser()->uc['titleLen']; $folderIcon = $this->iconFactory->getIconForResource($folder, Icon::SIZE_SMALL); $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)); $currentIdentifier = !empty($this->linkParts) ? $this->linkParts['url'] : ''; $selected = $currentIdentifier === $folder->getCombinedIdentifier() ? $this->additionalFolderClass : ''; $out .= ' <span class="' . $selected . '" title="' . htmlspecialchars($folder->getIdentifier()) . '"> ' . $folderIcon . ' </span> '; // Get files from the folder: $folderContent = $this->getFolderContent($folder, $extensionList); if (!empty($folderContent)) { $out .= '<ul class="list-tree">'; foreach ($folderContent as $fileOrFolderObject) { list($fileIdentifier, $icon) = $this->renderItem($fileOrFolderObject); $selected = $currentIdentifier === $fileIdentifier ? ' class="active"' : ''; $out .= '<li' . $selected . '> <span class="list-tree-group"> <a href="#" class="t3js-fileLink list-tree-group" title="' . htmlspecialchars($fileOrFolderObject->getName()) . '" data-file="file:' . htmlspecialchars($fileIdentifier) . '"> <span class="list-tree-icon">' . $icon . '</span> <span class="list-tree-title">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)) . '</span> </a> </span> </li>'; } $out .= '</ul>'; } return $out; }
/** * @param Folder $parentFolder * @return string HTML code */ protected function renderFolders(Folder $parentFolder) { if (!$parentFolder->checkActionPermission('read')) { return ''; } $content = ''; $lang = $this->getLanguageService(); $folders = $parentFolder->getSubfolders(); $folderIdentifier = $parentFolder->getCombinedIdentifier(); // Create headline (showing number of folders): $content .= '<h3>' . sprintf($lang->getLL('folders', true) . ' (%s):', count($folders)) . '</h3>'; $titleLength = (int) $this->getBackendUser()->uc['titleLen']; // Create the header of current folder: $folderIcon = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="1">'; $folderIcon .= $this->iconFactory->getIcon('apps-filetree-folder-default', Icon::SIZE_SMALL); $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($parentFolder->getName(), $titleLength)); $folderIcon .= '</a>'; $content .= $folderIcon . '<br />'; $lines = array(); // Traverse the folder list: foreach ($folders as $subFolder) { $subFolderIdentifier = $subFolder->getCombinedIdentifier(); // Create folder icon: $icon = '<span style="width: 16px; height: 16px; display: inline-block;"></span>'; $icon .= '<span title="' . htmlspecialchars($subFolder->getName()) . '">' . $this->iconFactory->getIcon('apps-filetree-folder-default', Icon::SIZE_SMALL) . '</span>'; // Create links for adding the folder: $aTag = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="0">'; $aTag_alt = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="1">'; if (strstr($subFolderIdentifier, ',') || strstr($subFolderIdentifier, '|')) { // In case an invalid character is in the filepath, display error message: $errorMessage = sprintf($lang->getLL('invalidChar', true), ', |'); $aTag = '<a href="#" class="t3-js-folderIdError" data-message="' . $errorMessage . '">'; } $aTag_e = '</a>'; // Combine icon and folderpath: $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($subFolder->getName(), $titleLength)) . $aTag_e; $lines[] = ' <tr class="bgColor4"> <td nowrap="nowrap">' . $foldernameAndIcon . ' </td> <td>' . $aTag . '<span title="' . $lang->getLL('addToList', true) . '">' . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . '</span>' . $aTag_e . '</td> <td> </td> </tr>'; $lines[] = ' <tr> <td colspan="3"><span style="width: 1px; height: 3px; display: inline-block;"></span></td> </tr>'; } // Wrap all the rows in table tags: $content .= ' <!-- Folder listing --> <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList"> ' . implode('', $lines) . ' </table>'; return $content; }
/** * Creates the clipboard control pad * * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing. * @return string HTML-table * @todo Define visibility */ public function makeClip($fileOrFolderObject) { if (!$fileOrFolderObject->checkActionPermission('read')) { return ''; } $cells = array(); $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier(); $md5 = GeneralUtility::shortmd5($fullIdentifier); // For normal clipboard, add copy/cut buttons: if ($this->clipObj->current == 'normal') { $isSel = $this->clipObj->isSelected('_FILE', $md5); $cells[] = '<a href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, $isSel == 'copy')) . '">' . IconUtility::getSpriteIcon('actions-edit-copy' . ($isSel == 'copy' ? '-release' : ''), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE))) . '</a>'; // we can only cut if file can be moved if ($fileOrFolderObject->checkActionPermission('move')) { $cells[] = '<a href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, $isSel == 'cut')) . '">' . IconUtility::getSpriteIcon('actions-edit-cut' . ($isSel == 'cut' ? '-release' : ''), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE))) . '</a>'; } else { $cells[] = IconUtility::getSpriteIcon('empty-empty'); } } else { // For numeric pads, add select checkboxes: $n = '_FILE|' . $md5; $this->CBnames[] = $n; $checked = $this->clipObj->isSelected('_FILE', $md5) ? ' checked="checked"' : ''; $cells[] = '<input type="hidden" name="CBH[' . $n . ']" value="0" />' . '<input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" class="smallCheckboxes"' . $checked . ' />'; } // Display PASTE button, if directory: $elFromTable = $this->clipObj->elFromTable('_FILE'); if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder') && count($elFromTable) && $fileOrFolderObject->checkActionPermission('write')) { $addPasteButton = TRUE; foreach ($elFromTable as $element) { $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element); if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $fileOrFolderObject)) { $addPasteButton = FALSE; } } if ($addPasteButton) { $cells[] = '<a class="btn" href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $fullIdentifier)) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $fullIdentifier, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>'; } } // Compile items into a DIV-element: return ' <!-- CLIPBOARD PANEL: --> <div class="typo3-clipCtrl"> ' . implode(' ', $cells) . ' </div>'; }
/** * Creates the edit control section * * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing. * @return string HTML-table */ public function makeEdit($fileOrFolderObject) { $cells = []; $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier(); // Edit file content (if editable) if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) { $url = BackendUtility::getModuleUrl('file_edit', ['target' => $fullIdentifier]); $editOnClick = 'top.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;'; $cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.editcontent') . '">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>'; } else { $cells['edit'] = $this->spaceIcon; } if ($fileOrFolderObject instanceof File) { $fileUrl = $fileOrFolderObject->getPublicUrl(true); if ($fileUrl) { $aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');'; $cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>'; } else { $cells['view'] = $this->spaceIcon; } } else { $cells['view'] = $this->spaceIcon; } // replace file if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('replace')) { $url = BackendUtility::getModuleUrl('file_replace', ['target' => $fullIdentifier, 'uid' => $fileOrFolderObject->getUid()]); $replaceOnClick = 'top.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;'; $cells['replace'] = '<a href="#" class="btn btn-default" onclick="' . $replaceOnClick . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.replace') . '">' . $this->iconFactory->getIcon('actions-edit-replace', Icon::SIZE_SMALL)->render() . '</a>'; } // rename the file if ($fileOrFolderObject->checkActionPermission('rename')) { $url = BackendUtility::getModuleUrl('file_rename', ['target' => $fullIdentifier]); $renameOnClick = 'top.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;'; $cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.rename') . '">' . $this->iconFactory->getIcon('actions-edit-rename', Icon::SIZE_SMALL)->render() . '</a>'; } else { $cells['rename'] = $this->spaceIcon; } if ($fileOrFolderObject->checkActionPermission('read')) { $infoOnClick = ''; if ($fileOrFolderObject instanceof Folder) { $infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;'; } elseif ($fileOrFolderObject instanceof File) { $infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;'; } $cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.info') . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>'; } else { $cells['info'] = $this->spaceIcon; } // delete the file if ($fileOrFolderObject->checkActionPermission('delete')) { $identifier = $fileOrFolderObject->getIdentifier(); if ($fileOrFolderObject instanceof Folder) { $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFolder')); $deleteType = 'delete_folder'; } else { $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFile')); $deleteType = 'delete_file'; } if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) { $confirmationCheck = '1'; } else { $confirmationCheck = '0'; } $deleteUrl = BackendUtility::getModuleUrl('tce_file'); $confirmationMessage = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText; $title = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.delete'); $cells['delete'] = '<a href="#" class="btn btn-default t3js-filelist-delete" data-content="' . htmlspecialchars($confirmationMessage) . '" data-check="' . $confirmationCheck . '" data-delete-url="' . htmlspecialchars($deleteUrl) . '" data-title="' . htmlspecialchars($title) . '" data-identifier="' . htmlspecialchars($fileOrFolderObject->getCombinedIdentifier()) . '" data-veri-code="' . $this->getBackendUser()->veriCode() . '" data-delete-type="' . $deleteType . '" title="' . htmlspecialchars($title) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>'; } else { $cells['delete'] = $this->spaceIcon; } // Hook for manipulating edit icons. if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) { $cells['__fileOrFolderObject'] = $fileOrFolderObject; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof FileListEditIconHookInterface) { throw new \UnexpectedValueException($classData . ' must implement interface ' . FileListEditIconHookInterface::class, 1235225797); } $hookObject->manipulateEditIcons($cells, $this); } unset($cells['__fileOrFolderObject']); } // Compile items into a DIV-element: return '<div class="btn-group">' . implode('', $cells) . '</div>'; }
/** * Creates the edit control section * * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing. * @return string HTML-table */ public function makeEdit($fileOrFolderObject) { $cells = array(); $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier(); // Edit file content (if editable) if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) { $url = BackendUtility::getModuleUrl('file_edit', array('target' => $fullIdentifier)); $editOnClick = 'top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;'; $cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editcontent') . '">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>'; } else { $cells['edit'] = $this->spaceIcon; } if ($fileOrFolderObject instanceof File) { $fileUrl = $fileOrFolderObject->getPublicUrl(TRUE); if ($fileUrl) { $aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');'; $cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.view') . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>'; } else { $cells['view'] = $this->spaceIcon; } } else { $cells['view'] = $this->spaceIcon; } // rename the file if ($fileOrFolderObject->checkActionPermission('rename')) { $url = BackendUtility::getModuleUrl('file_rename', array('target' => $fullIdentifier)); $renameOnClick = 'top.content.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;'; $cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.rename') . '">' . IconUtility::getSpriteIcon('actions-edit-rename') . '</a>'; } else { $cells['rename'] = $this->spaceIcon; } if ($fileOrFolderObject->checkActionPermission('read')) { $infoOnClick = ''; if ($fileOrFolderObject instanceof Folder) { $infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;'; } elseif ($fileOrFolderObject instanceof File) { $infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;'; } $cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.info') . '">' . IconUtility::getSpriteIcon('status-dialog-information') . '</a>'; } else { $cells['info'] = $this->spaceIcon; } // delete the file if ($fileOrFolderObject->checkActionPermission('delete')) { $identifier = $fileOrFolderObject->getIdentifier(); if ($fileOrFolderObject instanceof Folder) { $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)'); } else { $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)'); } if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) { $confirmationCheck = 'confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText) . ')'; } else { $confirmationCheck = '1 == 1'; } $removeOnClick = 'if (' . $confirmationCheck . ') { top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') . '&file[delete][0][data]=' . rawurlencode($fileOrFolderObject->getCombinedIdentifier()) . '&vC=' . $this->getBackendUser()->veriCode() . BackendUtility::getUrlToken('tceAction') . '&redirect=') . '+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);};'; $cells['delete'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($removeOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete') . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>'; } else { $cells['delete'] = $this->spaceIcon; } // Hook for manipulating edit icons. if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof FileListEditIconHookInterface) { throw new \UnexpectedValueException('$hookObject must implement interface \\TYPO3\\CMS\\Filelist\\FileListEditIconHookInterface', 1235225797); } $hookObject->manipulateEditIcons($cells, $this); } } // Compile items into a DIV-element: return '<div class="btn-group">' . implode('', $cells) . '</div>'; }
/** * Main function, rendering the main module content * * @return void */ public function main() { $lang = $this->getLanguageService(); // Start content compilation $this->content .= $this->doc->startPage($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle')); // Make page header: $pageContent = $this->doc->header($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle')); if ($this->folderObject->checkActionPermission('add')) { $code = '<form role="form" action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform">'; // Making the selector box for the number of concurrent folder-creations $this->number = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->number, 1, 10); $code .= ' <div class="form-group"> <div class="form-section"> <div class="form-group"> <label for="number-of-new-folders">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.number_of_folders') . ' ' . BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfolder') . '</label> <div class="form-control-wrap"> <div class="input-group"> <select class="form-control form-control-adapt" name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">'; for ($a = 1; $a <= $this->folderNumber; $a++) { $code .= '<option value="' . $a . '"' . ($this->number == $a ? ' selected="selected"' : '') . '>' . $a . '</option>'; } $code .= ' </select> </div> </div> </div> </div> '; // Making the number of new-folder boxes needed: for ($a = 0; $a < $this->number; $a++) { $code .= ' <div class="form-section"> <div class="form-group"> <label for="folder_new_' . $a . '">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.label_newfolder') . ' ' . ($a + 1) . ':</label> <div class="form-control-wrap"> <input type="text" class="form-control" id="folder_new_' . $a . '" name="file[newfolder][' . $a . '][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /> </div> </div> </div>'; } // Making submit button for folder creation: $code .= ' </div><div class="form-group"> <input class="btn btn-default" type="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . ' </div> '; // Switching form tags: $pageContent .= $this->doc->section($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfolders'), $code); $pageContent .= $this->doc->sectionEnd() . '</form>'; } if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')) { $pageContent .= '<form action="' . BackendUtility::getModuleUrl('tce_file') . '" method="post" name="editform2">'; // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc. $fileExtList = array(); $textFileExt = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE); foreach ($textFileExt as $fileExt) { if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) { $fileExtList[] = '<span class="label label-success">' . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } // Add form fields for creation of a new, blank text file: $code = ' <div class="form-group"> <div class="form-section"> <div class="form-group"> <label for="newfile">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.label_newfile') . ' ' . BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfile') . '</label> <div class="form-control-wrap"> <input class="form-control" type="text" id="newfile" name="file[newfile][0][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfile][0][target]" value="' . htmlspecialchars($this->target) . '" /> </div> <div class="help-block"> ' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:cm.allowedFileExtensions') . '<br> ' . implode(' ', $fileExtList) . ' </div> </div> </div> </div> '; // Submit button for creation of a new file: $code .= ' <div class="form-group"> <input class="btn btn-default" type="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile_submit', TRUE) . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . ' </div> '; $pageContent .= $this->doc->section($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile'), $code); $pageContent .= $this->doc->sectionEnd(); $pageContent .= '</form>'; } $docHeaderButtons = array('back' => ''); // Back if ($this->returnUrl) { $docHeaderButtons['back'] = '<a href="' . htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl)) . '" class="typo3-goBack" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>'; } // Add the HTML as a section: $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => '', 'CONTENT' => $pageContent, 'PATH' => $this->title); $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }
/** * Returns some data specific for the directories... * * @param \TYPO3\CMS\Core\Resource\Folder $folderObject File information array * @return array (title, icon, path) * @todo Define visibility */ public function dirData(\TYPO3\CMS\Core\Resource\Folder $folderObject) { $title = htmlspecialchars($folderObject->getName()); $icon = 'apps-filetree-folder-default'; if ($title == '_temp_') { $icon = 'apps-filetree-folder-temp'; $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', TRUE) . '</strong>'; } if ($title == '_recycler_') { $icon = 'apps-filetree-folder-recycler'; $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', TRUE) . '</strong>'; } // Mark the icon as read-only icon if the folder is not writable if ($folderObject->checkActionPermission('write') === FALSE) { $icon = 'apps-filetree-folder-locked'; } return array($title, $icon, $folderObject->getIdentifier()); }
/** * For TBE: Makes a form for creating new folders in the filemount the user is browsing. * The folder creation request is sent to the tce_file.php script in the core which will handle the creation. * * @param Folder $folderObject Absolute filepath on server in which to create the new folder. * @return string HTML for the create folder form. */ public function createFolder(Folder $folderObject) { if (!$folderObject->checkActionPermission('write')) { return ''; } $backendUser = $this->getBackendUser(); if (!($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.createFoldersInEB'))) { return ''; } // Don't show Folder-create form if it's denied if ($backendUser->getTSConfigVal('options.folderTree.hideCreateFolder')) { return ''; } $lang = $this->getLanguageService(); // Create header, showing upload path: $header = $folderObject->getIdentifier(); $code = ' <!-- Form, for creating new folders: --> <form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform2" id="typo3-crFolderForm"> <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder"> <tr> <td>' . $this->barheader($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':') . '</td> </tr> <tr> <td class="c-wCell c-hCell"><strong>' . $lang->getLL('path', true) . ':</strong> ' . htmlspecialchars($header) . '</td> </tr> <tr> <td class="c-wCell c-hCell">'; // Create the new-folder name field: $a = 1; $code .= '<input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />' . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />'; // Make footer of upload form, including the submit button: $redirectValue = $this->getThisScript() . 'act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams) . (is_array($this->P) ? GeneralUtility::implodeArrayForUrl('P', $this->P) : ''); $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />' . '<input class="btn btn-default" type="submit" name="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', true) . '" />'; $code .= '</td> </tr> </table> </form>'; return $code; }
/** * Initialization of the class * Will determine if table/uid GET vars are database record or a file and if * the user has access to view information about the item. * * @return void * @todo Define visibility */ public function init() { // Setting input variables. $this->table = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('table'); $this->uid = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('uid'); // Initialize: $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); // Set to TRUE if there is access to the record / file. $this->access = FALSE; // Sets the type, "db" or "file". If blank, nothing can be shown. $this->type = ''; // Checking if the $table value is really a table and if the user has // access to it. if (isset($GLOBALS['TCA'][$this->table])) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($this->table); $this->type = 'db'; $this->uid = intval($this->uid); // Check permissions and uid value: if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) { if ((string) $this->table == 'pages') { $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->uid, $this->perms_clause); $this->access = is_array($this->pageinfo) ? 1 : 0; $this->row = $this->pageinfo; } else { $this->row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->table, $this->uid); if ($this->row) { $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause); $this->access = is_array($this->pageinfo) ? 1 : 0; } } /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */ $treatData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor'); $treatData->renderRecord($this->table, $this->uid, 0, $this->row); } } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') { $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid); if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) { $this->folderObject = $fileOrFolderObject; $this->access = $this->folderObject->checkActionPermission('read'); $this->type = 'folder'; } else { $this->fileObject = $fileOrFolderObject; $this->access = $this->fileObject->checkActionPermission('read'); $this->type = 'file'; $this->table = 'sys_file'; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($this->table); try { $this->row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->table, $this->fileObject->getUid()); } catch (\Exception $e) { $this->row = array(); } } } // Initialize document template object: $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $GLOBALS['BACK_PATH']; // Starting the page by creating page header stuff: $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem')); $this->content .= '<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>'; $this->content .= $this->doc->spacer(5); }
/** * Main function, rendering the main module content * * @return void */ public function main() { $lang = $this->getLanguageService(); $assigns = []; $assigns['target'] = $this->target; if ($this->folderObject->checkActionPermission('add')) { $assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file'); $assigns['cshFileNewFolder'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfolder'); // Making the selector box for the number of concurrent folder-creations $this->number = MathUtility::forceIntegerInRange($this->number, 1, 10); for ($a = 1; $a <= $this->folderNumber; $a++) { $options = []; $options['value'] = $a; $options['selected'] = $this->number == $a ? ' selected="selected"' : ''; $assigns['options'][] = $options; } // Making the number of new-folder boxes needed: for ($a = 0; $a < $this->number; $a++) { $folder = []; $folder['this'] = $a; $folder['next'] = $a + 1; $assigns['folders'][] = $folder; } // Making submit button for folder creation: $assigns['returnUrl'] = $this->returnUrl; } if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')) { $assigns['moduleUrlOnlineMedia'] = BackendUtility::getModuleUrl('online_media'); $assigns['cshFileNewMedia'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newMedia'); // Create a list of allowed file extensions with the readable format "youtube, vimeo" etc. $fileExtList = []; $onlineMediaFileExt = OnlineMediaHelperRegistry::getInstance()->getSupportedFileExtensions(); foreach ($onlineMediaFileExt as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern('.' . $fileExt)) { $fileExtList[] = strtoupper(htmlspecialchars($fileExt)); } } $assigns['fileExtList'] = $fileExtList; $assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file'); $assigns['cshFileNewFile'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfile'); // Create a list of allowed file extensions with a text format "*.txt, *.css" etc. $fileExtList = []; $textFileExt = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], true); foreach ($textFileExt as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern('.' . $fileExt)) { $fileExtList[] = strtoupper(htmlspecialchars($fileExt)); } } $assigns['txtFileExtList'] = $fileExtList; } $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); // Back if ($this->returnUrl) { $backButton = $buttonBar->makeLinkButton()->setHref($this->returnUrl)->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL)); $buttonBar->addButton($backButton); } // Rendering of the output via fluid $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]); $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/File/CreateFolder.html')); $view->assignMultiple($assigns); $this->content = $view->render(); $this->moduleTemplate->setContent($this->content); }
/** * For TBE: Makes a form for creating new folders in the filemount the user is browsing. * The folder creation request is sent to the tce_file.php script in the core which will handle the creation. * * @param Folder $folderObject Absolute filepath on server in which to create the new folder. * @return string HTML for the create folder form. * @todo Define visibility */ public function createFolder(Folder $folderObject) { if (!$folderObject->checkActionPermission('write')) { return ''; } if (!($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB'))) { return ''; } // Don't show Folder-create form if it's denied if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) { return ''; } // Create header, showing upload path: $header = $folderObject->getIdentifier(); $code = ' <!-- Form, for creating new folders: --> <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform2" id="typo3-crFolderForm"> <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder"> <tr> <td>' . $this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':') . '</td> </tr> <tr> <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td> </tr> <tr> <td class="c-wCell c-hCell">'; // Create the new-folder name field: $a = 1; $code .= '<input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />' . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />'; // Make footer of upload form, including the submit button: $redirectValue = $this->getThisScript() . 'act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams); $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '<input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />'; $code .= '</td> </tr> </table> </form>'; return $code; }
/** * For TYPO3 Element Browser: Expand folder of files. * * @param Folder $folder The folder path to expand * @param array $extensionList List of fileextensions to show * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown. * @return string HTML output */ public function renderFilesInFolder(Folder $folder, array $extensionList = [], $noThumbs = false) { if (!$folder->checkActionPermission('read')) { return ''; } $lang = $this->getLanguageService(); $titleLen = (int) $this->getBackendUser()->uc['titleLen']; if ($this->searchWord !== '') { $files = $this->fileRepository->searchByName($folder, $this->searchWord); } else { $extensionList = !empty($extensionList) && $extensionList[0] === '*' ? [] : $extensionList; $files = $this->getFilesInFolder($folder, $extensionList); } $filesCount = count($files); $lines = array(); // Create the header of current folder: $folderIcon = $this->iconFactory->getIconForResource($folder, Icon::SIZE_SMALL); $lines[] = ' <tr> <th class="col-title" nowrap="nowrap">' . $folderIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</th> <th class="col-control" nowrap="nowrap"></th> <th class="col-clipboard" nowrap="nowrap"> <a href="#" class="btn btn-default" id="t3js-importSelection" title="' . $lang->getLL('importSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL) . '</a> <a href="#" class="btn btn-default" id="t3js-toggleSelection" title="' . $lang->getLL('toggleSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL) . '</a> </th> <th nowrap="nowrap"> </th> </tr>'; if ($filesCount === 0) { $lines[] = ' <tr> <td colspan="4">No files found.</td> </tr>'; } foreach ($files as $fileObject) { $fileExtension = $fileObject->getExtension(); // Thumbnail/size generation: $imgInfo = array(); if (!$noThumbs && GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']), strtolower($fileExtension))) { $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 64, 'height' => 64)); $imageUrl = $processedFile->getPublicUrl(true); $imgInfo = array($fileObject->getProperty('width'), $fileObject->getProperty('height')); $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels'; $clickIcon = '<img src="' . $imageUrl . '"' . ' width="' . $processedFile->getProperty('width') . '"' . ' height="' . $processedFile->getProperty('height') . '"' . ' hspace="5" vspace="5" border="1" />'; } else { $clickIcon = ''; $pDim = ''; } // Create file icon: $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')'; $icon = '<span title="' . htmlspecialchars($fileObject->getName() . $size) . '">' . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL) . '</span>'; // Create links for adding the file: $filesIndex = count($this->elements); $this->elements['file_' . $filesIndex] = array('type' => 'file', 'table' => 'sys_file', 'uid' => $fileObject->getUid(), 'fileName' => $fileObject->getName(), 'filePath' => $fileObject->getUid(), 'fileExt' => $fileExtension, 'fileIcon' => $icon); if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) { $ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="0">'; $ATag_alt = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="1">'; $ATag_e = '</a>'; $bulkCheckBox = '<label class="btn btn-default btn-checkbox"><input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /><span class="t3-icon fa"></span></label>'; } else { $ATag = ''; $ATag_alt = ''; $ATag_e = ''; $bulkCheckBox = ''; } // Create link to showing details about the file in a window: $Ahref = BackendUtility::getModuleUrl('show_item', array('type' => 'file', 'table' => '_FILE', 'uid' => $fileObject->getCombinedIdentifier(), 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'))); // Combine the stuff: $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e; // Show element: $lines[] = ' <tr class="file_list_normal"> <td class="col-title" nowrap="nowrap">' . $filenameAndIcon . ' </td> <td class="col-control"> <div class="btn-group">' . $ATag . '<span title="' . $lang->getLL('addToList', true) . '">' . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . '</span>' . $ATag_e . ' <a href="' . htmlspecialchars($Ahref) . '" class="btn btn-default" title="' . $lang->getLL('info', true) . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</a> </td> <td class="col-clipboard" valign="top">' . $bulkCheckBox . '</td> <td nowrap="nowrap"> ' . $pDim . '</td> </tr>'; if ($pDim) { $lines[] = ' <tr> <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td> </tr>'; } } $out = '<h3>' . $lang->getLL('files', true) . ' ' . $filesCount . ':</h3>'; $out .= GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this)->getFileSearchField($this->searchWord); $out .= '<div id="filelist">'; $out .= $this->getBulkSelector($filesCount); // Wrap all the rows in table tags: $out .= ' <!-- Filelisting --> <table class="table table-striped table-hover" id="typo3-filelist"> ' . implode('', $lines) . ' </table>'; // Return accumulated content for filelisting: $out .= '</div>'; return $out; }
/** * Makes an upload form for uploading files to the filemount the user is browsing. * The files are uploaded to the tce_file.php script in the core which will handle the upload. * * @param Folder $folderObject * @param string[] $allowedExtensions * * @return string HTML for an upload form. */ public function uploadForm(Folder $folderObject, array $allowedExtensions) { if (!$folderObject->checkActionPermission('write')) { return ''; } // Read configuration of upload field count $userSetting = $this->getBackendUser()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser'); $count = isset($userSetting) ? (int) $userSetting : 1; if ($count === 0) { return ''; } $count = (int) $count === 0 ? 1 : (int) $count; // Create header, showing upload path: $header = $folderObject->getIdentifier(); $lang = $this->getLanguageService(); // Create a list of allowed file extensions with the readable format "youtube, vimeo" etc. $fileExtList = array(); foreach ($allowedExtensions as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { $fileExtList[] = '<span class="label label-success">' . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } $formAction = BackendUtility::getModuleUrl('tce_file'); $combinedIdentifier = $folderObject->getCombinedIdentifier(); $markup = array(); $markup[] = '<div class="element-browser-section element-browser-upload">'; $markup[] = ' <form action="' . htmlspecialchars($formAction) . '" method="post" name="editform" enctype="multipart/form-data">'; $markup[] = ' <h3>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle', true) . ':</h3>'; $markup[] = ' <p><strong>' . $lang->getLL('path', true) . ':</strong>' . htmlspecialchars($header) . '</p>'; // Traverse the number of upload fields: for ($a = 1; $a <= $count; $a++) { $markup[] = '<div class="form-group">'; $markup[] = '<span class="btn btn-default btn-file">'; $markup[] = '<input type="file" multiple="multiple" name="upload_' . $a . '[]" size="50" />'; $markup[] = '</span>'; $markup[] = '</div>'; $markup[] = '<input type="hidden" name="file[upload][' . $a . '][target]" value="' . htmlspecialchars($combinedIdentifier) . '" />'; $markup[] = '<input type="hidden" name="file[upload][' . $a . '][data]" value="' . $a . '" />'; } $redirectValue = $this->parameterProvider->getScriptUrl() . GeneralUtility::implodeArrayForUrl('', $this->parameterProvider->getUrlParameters(['identifier' => $combinedIdentifier])); $markup[] = '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'; if (!empty($fileExtList)) { $markup[] = '<div class="form-group">'; $markup[] = ' <label>'; $markup[] = $lang->sL('LLL:EXT:lang/locallang_core.xlf:cm.allowedFileExtensions', true) . '<br/>'; $markup[] = ' </label>'; $markup[] = ' <div class="form-control">'; $markup[] = implode(' ', $fileExtList); $markup[] = ' </div>'; $markup[] = '</div>'; } $markup[] = '<div class="checkbox">'; $markup[] = ' <label>'; $markup[] = ' <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" />'; $markup[] = $lang->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', true); $markup[] = ' </label>'; $markup[] = '</div>'; $markup[] = '<input class="btn btn-default" type="submit" name="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', true) . '" />'; $markup[] = ' </form>'; $markup[] = '</div>'; $code = implode(LF, $markup); // Add online media // Create a list of allowed file extensions in a readable format "youtube, vimeo" etc. $fileExtList = array(); $onlineMediaFileExt = OnlineMediaHelperRegistry::getInstance()->getSupportedFileExtensions(); foreach ($onlineMediaFileExt as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt) && (empty($allowedExtensions) || in_array($fileExt, $allowedExtensions, true))) { $fileExtList[] = '<span class="label label-success">' . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } if (!empty($fileExtList)) { $formAction = BackendUtility::getModuleUrl('online_media'); $markup = array(); $markup[] = '<div class="element-browser-section element-browser-mediaurls">'; $markup[] = ' <form action="' . htmlspecialchars($formAction) . '" method="post" name="editform1" id="typo3-addMediaForm" enctype="multipart/form-data">'; $markup[] = '<h3>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media', true) . ':</h3>'; $markup[] = '<p><strong>' . $lang->getLL('path', true) . ':</strong>' . htmlspecialchars($header) . '</p>'; $markup[] = '<div class="form-group">'; $markup[] = '<input type="hidden" name="file[newMedia][0][target]" value="' . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />'; $markup[] = '<input type="hidden" name="file[newMedia][0][allowed]" value="' . htmlspecialchars(implode(',', $allowedExtensions)) . '" />'; $markup[] = '<input type="text" name="file[newMedia][0][url]" class="form-control" placeholder="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.placeholder', true) . '" />'; $markup[] = '<button class="btn btn-default">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.submit', true) . '</button>'; $markup[] = '</div>'; $markup[] = '<div class="form-group">'; $markup[] = ' <label>'; $markup[] = $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.allowedProviders') . '<br/>'; $markup[] = ' </label>'; $markup[] = ' <div class="form-control">'; $markup[] = implode(' ', $fileExtList); $markup[] = ' </div>'; $markup[] = '</div>'; $markup[] = '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'; $markup[] = '</div>'; $markup[] = '</form>'; $markup[] = '</div>'; $code .= implode(LF, $markup); } return $code; }
/** * Main function, rendering the main module content * * @return void */ public function main() { $lang = $this->getLanguageService(); $pageContent = '<h1>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . '</h1>'; if ($this->folderObject->checkActionPermission('add')) { $code = '<form role="form" action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform">'; // Making the selector box for the number of concurrent folder-creations $this->number = MathUtility::forceIntegerInRange($this->number, 1, 10); $code .= ' <div class="form-group"> <div class="form-section"> <div class="form-group"> <label for="number-of-new-folders">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.number_of_folders') . '</label> ' . BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfolder') . ' <div class="form-control-wrap"> <div class="input-group"> <select class="form-control form-control-adapt" name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">'; for ($a = 1; $a <= $this->folderNumber; $a++) { $code .= '<option value="' . $a . '"' . ($this->number == $a ? ' selected="selected"' : '') . '>' . $a . '</option>'; } $code .= ' </select> </div> </div> </div> </div> '; // Making the number of new-folder boxes needed: for ($a = 0; $a < $this->number; $a++) { $code .= ' <div class="form-section"> <div class="form-group"> <label for="folder_new_' . $a . '">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.label_newfolder') . ' ' . ($a + 1) . ':</label> <div class="form-control-wrap"> <input type="text" class="form-control" id="folder_new_' . $a . '" name="file[newfolder][' . $a . '][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /> </div> </div> </div>'; } // Making submit button for folder creation: $code .= ' </div><div class="form-group"> <input class="btn btn-default" type="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', true) . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> </div> '; // Switching form tags: $pageContent .= '<h3>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfolders', true) . '</h3>'; $pageContent .= '<div>' . $code . '</form></div>'; } if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')) { $pageContent .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('online_media')) . '" method="post" name="editform2">'; // Create a list of allowed file extensions with the readable format "youtube, vimeo" etc. $fileExtList = array(); $onlineMediaFileExt = OnlineMediaHelperRegistry::getInstance()->getSupportedFileExtensions(); foreach ($onlineMediaFileExt as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { $fileExtList[] = '<span class="label label-success">' . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } // Add form fields for adding media files: $code = ' <div class="form-group"> <div class="form-section"> <div class="form-group"> <label for="newMedia">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.label', true) . '</label> ' . BackendUtility::cshItem('xMOD_csh_corebe', 'file_newMedia') . ' <div class="form-control-wrap"> <input class="form-control" type="text" id="newMedia" name="file[newMedia][0][url]" placeholder="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.placeholder', true) . '" /> <input type="hidden" name="file[newMedia][0][target]" value="' . htmlspecialchars($this->target) . '" /> </div> <div class="help-block"> ' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.allowedProviders', true) . '<br> ' . implode(' ', $fileExtList) . ' </div> </div> </div> </div> '; // Submit button for creation of a new media: $code .= ' <div class="form-group"> <input class="btn btn-default" type="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.submit', true) . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> </div> '; $pageContent .= '<h3>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media', true) . '</h3>'; $pageContent .= '<div>' . $code . '</div>'; $pageContent .= '</form>'; $pageContent .= '<form action="' . BackendUtility::getModuleUrl('tce_file') . '" method="post" name="editform3">'; // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc. $fileExtList = array(); $textFileExt = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], true); foreach ($textFileExt as $fileExt) { if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { $fileExtList[] = '<span class="label label-success">' . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } // Add form fields for creation of a new, blank text file: $code = ' <div class="form-group"> <div class="form-section"> <div class="form-group"> <label for="newfile">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.label_newfile', true) . '</label> ' . BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfile') . ' <div class="form-control-wrap"> <input class="form-control" type="text" id="newfile" name="file[newfile][0][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfile][0][target]" value="' . htmlspecialchars($this->target) . '" /> </div> <div class="help-block"> ' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:cm.allowedFileExtensions', true) . '<br> ' . implode(' ', $fileExtList) . ' </div> </div> </div> </div> '; // Submit button for creation of a new file: $code .= ' <div class="form-group"> <input class="btn btn-default" type="submit" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile_submit', true) . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> </div> '; $pageContent .= '<h3>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile', true) . '</h3>'; $pageContent .= '<div>' . $code . '</div>'; $pageContent .= '</form>'; } $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); // Back if ($this->returnUrl) { $backButton = $buttonBar->makeLinkButton()->setHref(GeneralUtility::linkThisUrl($this->returnUrl))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL)); $buttonBar->addButton($backButton); } $this->content .= '<div>' . $pageContent . '</div>'; $this->moduleTemplate->setContent($this->content); }
/** * Main function, rendering the main module content * * @return void */ public function main() { // Start content compilation $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle')); // Make page header: $pageContent = $this->doc->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle')); $pageContent .= $this->doc->spacer(5); $pageContent .= $this->doc->divider(5); if ($this->folderObject->checkActionPermission('add')) { $code = '<form action="tce_file.php" method="post" name="editform">'; // Making the selector box for the number of concurrent folder-creations $this->number = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->number, 1, 10); $code .= ' <div id="c-select"> <label for="number-of-new-folders">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.number_of_folders') . '</label> <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">'; for ($a = 1; $a <= $this->folderNumber; $a++) { $code .= '<option value="' . $a . '"' . ($this->number == $a ? ' selected="selected"' : '') . '>' . $a . '</option>'; } $code .= ' </select> </div> '; // Making the number of new-folder boxes needed: $code .= ' <div id="c-createFolders"> '; for ($a = 0; $a < $this->number; $a++) { $code .= ' <input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /><br /> '; } $code .= ' </div> '; // Making submit button for folder creation: $code .= ' <div id="c-submitFolders"> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', TRUE) . '" onclick="backToList(); return false;" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . ' </div> '; // CSH: $code .= BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />'); $pageContent .= $code; // Add spacer: $pageContent .= $this->doc->spacer(10); // Switching form tags: $pageContent .= $this->doc->sectionEnd() . '</form>'; } if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')) { $pageContent .= '<form action="tce_file.php" method="post" name="editform2">'; // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc. $fileExtList = array(); $textfileExt = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE); foreach ($textfileExt as $fileExt) { if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) { $fileExtList[] = '*.' . $fileExt; } } // Add form fields for creation of a new, blank text file: $code = ' <div id="c-newFile"> <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p> <input' . $this->doc->formWidth(20) . ' type="text" name="file[newfile][0][data]" onchange="changed=true;" /> <input type="hidden" name="file[newfile][0][target]" value="' . htmlspecialchars($this->target) . '" /> </div> '; // Submit button for creation of a new file: $code .= ' <div id="c-submitFiles"> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile_submit', TRUE) . '" /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', TRUE) . '" onclick="backToList(); return false;" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . ' </div> '; // CSH: $code .= BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />'); $pageContent .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.newfile'), $code); $pageContent .= $this->doc->sectionEnd(); $pageContent .= '</form>'; } $docHeaderButtons = array('back' => ''); // Back if ($this->returnUrl) { $docHeaderButtons['back'] = '<a href="' . htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl)) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>'; } // Add the HTML as a section: $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'CONTENT' => $pageContent, 'PATH' => $this->title); $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }