Project

General

Profile

Bug #43504 » ElementBrowserPatch-201307141340.patch

Matthias Toscanelli, 2013-07-14 13:47

View differences:

patched/ElementBrowser.php 2013-07-14 13:39:43.672998365 +0200
} 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;
......
/**
* 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 = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
} else {
// If foldername is OK, just add it:
$aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($baseFolder) . '\', \'folder\', \'' . rawurlencode($baseFolder) . '\', unescape(\'' . rawurlencode($baseFolder) . '\'), \'' . $fI['extension'] . '\', \'' . $ficon . '\');">';
$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 = '<a href="#" onclick="return insertElement(\'\',\'' . $encodedPublicUrl . '\', \'folder\', \'' . $encodedPublicUrl . '\', unescape(\'' . $encodedPublicUrl . '\'), \'\', \'\');">';
$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
$aTag_e = '</a>';
// Add the foder icon
$folderIcon = $aTag_alt;
$folderIcon .= '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
$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 . '<br />';
}
// Listing the folders:
if (is_array($folders)) {
if (count($folders) > 0) {
// Traverse the folder list:
$lines = array();
foreach ($folders as $folderPath) {
$pathInfo = pathinfo($folderPath);
// Create folder icon:
$icon = '<img src="clear.gif" width="16" height="16" alt="" /><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="16" height="16"') . ' title="' . htmlspecialchars(($pathInfo['basename'] . $size)) . '" class="absmiddle" alt="" />';
// Create links for adding the folder:
if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
$aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . rawurlencode($folderPath) . '\'));">';
} else {
$aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($folderPath) . '\', \'folder\', \'' . rawurlencode($folderPath) . '\', unescape(\'' . rawurlencode($folderPath) . '\'), \'' . $pathInfo['extension'] . '\', \'' . $ficon . '\');">';
}
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 = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
} else {
// If foldername is OK, just add it:
$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
}
$aTag_e = '</a>';
// Combine icon and folderpath:
$foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
if ($this->P['itemName'] != '') {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
<td>&nbsp;</td>
</tr>';
} else {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
<td>' . $aTag . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $aTag_e . ' </td>
<td>&nbsp;</td>
</tr>';
}
$lines[] = '
<tr>
<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></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>';
}
// Listing the folders:
if (count($subfolders) > 0) {
// Traverse the folder list:
$lines = array();
foreach ($subfolders as $subfolder) {
// Create folder icon:
$icon = '<img src="clear.gif" width="16" height="16" alt="" /><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="16" height="16"') . ' title="' . htmlspecialchars($subfolder->getName()) . '" class="absmiddle" alt="" />';
// Create links for adding the folder:
$encodedPublicUrl = rawurlencode($subfolder->getPublicUrl());
if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
$aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . $encodedPublicUrl . '\'));">';
} else {
$aTag = '<a href="#" onclick="return insertElement(\'\',\'' . $encodedPublicUrl . '\', \'folder\', \'' . $encodedPublicUrl . '\', unescape(\'' . $encodedPublicUrl . '\'), \'\', \'\');">';
}
$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
$aTag_e = '</a>';
// Combine icon and folderpath:
$foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($subfolder->getName(), $titleLength)) . $aTag_e;
if ($this->P['itemName'] != '') {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
<td>&nbsp;</td>
</tr>';
} else {
$lines[] = '
<tr class="bgColor4">
<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
<td>' . $aTag . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $aTag_e . ' </td>
<td>&nbsp;</td>
</tr>';
}
$lines[] = '
<tr>
<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></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 accumulated content for folderlisting:
return $content;
}
(1-1/4)