ElementBrowser.php | 81 +++++++++++++++++++++++-------------------------------
1 file changed, 35 insertions(+), 46 deletions(-)
diff --git a/ElementBrowser.php b/ElementBrowser.php
index 59293ae..9d74e4f 100644
--- a/ElementBrowser.php
+++ b/ElementBrowser.php
@@ -1240,6 +1240,10 @@ class ElementBrowser {
} else {
$createFolder = '';
}
+ // Or get the user's default upload folder
+ if (!$this->selectedFolder) {
+ $this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+ }
// Create folder tree:
$foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TBE_FolderTree');
$foldertree->thisScript = $this->thisScript;
@@ -1645,61 +1649,46 @@ class ElementBrowser {
/**
* Render list of folders.
*
- * @param array $baseFolder List of folders. See \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs
- * @param string $folders If set a header with a folder icon and folder name are shown
+ * @param string \TYPO3\CMS\Core\Resource\Folder $folder List content of this folder
* @return string HTML output
* @todo Define visibility
*/
- public function folderList($baseFolder, $folders) {
+ public function folderList(\TYPO3\CMS\Core\Resource\Folder $folder) {
$content = '';
- // Create headline (showing number of folders):
- $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
- $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
- // Create the header of current folder:
- if ($baseFolder) {
- if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
- // In case an invalid character is in the filepath, display error message:
- $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
- $aTag = ($aTag_alt = '');
- } else {
- // If foldername is OK, just add it:
- $aTag = '';
- $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
- }
+ if ($folder) {
+ $subfolders = $folder->getSubfolders();
+ // Create headline (showing number of folders):
+ $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($subfolders)));
+ $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
+ $encodedPublicUrl = rawurlencode($folder->getPublicUrl());
+ $aTag = '';
+ $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
$aTag_e = '';
// Add the foder icon
$folderIcon = $aTag_alt;
$folderIcon .= '';
- $folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
+ $folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLength));
$folderIcon .= $aTag_e;
$content .= $folderIcon . '
';
- }
- // Listing the folders:
- if (is_array($folders)) {
- if (count($folders) > 0) {
+
+ // Listing the folders:
+ if (count($subfolders) > 0) {
// Traverse the folder list:
$lines = array();
- foreach ($folders as $folderPath) {
- $pathInfo = pathinfo($folderPath);
+ foreach ($subfolders as $subfolder) {
// Create folder icon:
- $icon = '';
+ $icon = '';
// Create links for adding the folder:
+ $encodedPublicUrl = rawurlencode($subfolder->getPublicUrl());
if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
- $aTag = '';
- } else {
- $aTag = '';
- }
- if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
- // In case an invalid character is in the filepath, display error message:
- $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
- $aTag = ($aTag_alt = '');
+ $aTag = '';
} else {
- // If foldername is OK, just add it:
- $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
+ $aTag = '';
}
+ $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
$aTag_e = '';
// Combine icon and folderpath:
- $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
+ $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($subfolder->getName(), $titleLength)) . $aTag_e;
if ($this->P['itemName'] != '') {
$lines[] = '