/** * Get the HTML data required for the file search field of the TYPO3 Element Browser. * * @param string $searchWord * @return string HTML data required for the search field in the file list of the Element Browser */ public function getFileSearchField($searchWord) { $action = $this->parameterProvider->getScriptUrl() . GeneralUtility::implodeArrayForUrl('', $this->parameterProvider->getUrlParameters([])); $markup = []; $markup[] = '<form method="post" action="' . htmlspecialchars($action) . '" style="padding-bottom: 15px;">'; $markup[] = ' <div class="input-group">'; $markup[] = ' <input class="form-control" type="text" name="searchWord" value="' . htmlspecialchars($searchWord) . '">'; $markup[] = ' <span class="input-group-btn">'; $markup[] = ' <button class="btn btn-default" type="submit">' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:search')) . '</button>'; $markup[] = ' </span>'; $markup[] = ' </div>'; $markup[] = '</form>'; return implode(LF, $markup); }
/** * @param LinkParameterProviderInterface $linkParameterProvider * * @return void */ public function setLinkParameterProvider(LinkParameterProviderInterface $linkParameterProvider) { $this->linkParameterProvider = $linkParameterProvider; $this->thisScript = $linkParameterProvider->getScriptUrl(); }
/** * 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; }