Project

General

Profile

Bug #43504 » ElementBrowserPatch-v6.0.6.patch

Benjamin Schmidt, 2013-07-22 17:13

View differences:

ElementBrowser.php
} 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) {
// 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 = '<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="" />';
$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(\'' . 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;">');
$aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . $encodedPublicUrl . '\'));">';
} else {
// If foldername is OK, just add it:
$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
$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(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[] = '
<tr class="bgColor4">
......
</tr>';
}
$lines[] = '
<tr>
<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
</tr>';
<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>';
}
<!--
Folder listing
-->
<table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
' . implode('', $lines) . '
</table>';
}
// Return accumulated content for folderlisting:
return $content;
}
(2-2/4)