ElementBrowserPatch-201307141340.patch

Matthias Toscanelli, 2013-07-14 13:47

Download (9.99 KB)

View differences:

patched/ElementBrowser.php 2013-07-14 13:39:43.672998365 +0200
1266 1266
		} else {
1267 1267
			$createFolder = '';
1268 1268
		}
1269
		// Or get the user's default upload folder
1270
		if (!$this->selectedFolder) {
1271
			$this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
1272
		}
1269 1273
		// Create folder tree:
1270 1274
		$foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TBE_FolderTree');
1271 1275
		$foldertree->thisScript = $this->thisScript;
......
1671 1675
	/**
1672 1676
	 * Render list of folders.
1673 1677
	 *
1674
	 * @param array $baseFolder List of folders. See \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs
1675
	 * @param string $folders If set a header with a folder icon and folder name are shown
1678
	 * @param string \TYPO3\CMS\Core\Resource\Folder $folder List content of this folder
1676 1679
	 * @return string HTML output
1677 1680
	 * @todo Define visibility
1678 1681
	 */
1679
	public function folderList($baseFolder, $folders) {
1682
	public function folderList(\TYPO3\CMS\Core\Resource\Folder $folder) {
1680 1683
		$content = '';
1681
		// Create headline (showing number of folders):
1682
		$content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
1683
		$titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
1684
		// Create the header of current folder:
1685
		if ($baseFolder) {
1686
			if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
1687
				// In case an invalid character is in the filepath, display error message:
1688
				$errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
1689
				$aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
1690
			} else {
1691
				// If foldername is OK, just add it:
1692
				$aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($baseFolder) . '\', \'folder\', \'' . rawurlencode($baseFolder) . '\', unescape(\'' . rawurlencode($baseFolder) . '\'), \'' . $fI['extension'] . '\', \'' . $ficon . '\');">';
1693
				$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
1694
			}
1684
                if ($folder) {
1685
                        $subfolders = $folder->getSubfolders();
1686
                        // Create headline (showing number of folders):
1687
                        $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($subfolders)));
1688
                        $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
1689
                        $encodedPublicUrl = rawurlencode($folder->getPublicUrl());
1690
                        $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . $encodedPublicUrl . '\', \'folder\', \'' . $encodedPublicUrl . '\', unescape(\'' . $encodedPublicUrl . '\'), \'\', \'\');">';
1691
                        $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
1695 1692
			$aTag_e = '</a>';
1696 1693
			// Add the foder icon
1697 1694
			$folderIcon = $aTag_alt;
1698 1695
			$folderIcon .= '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
1699
			$folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
1696
                        $folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLength));
1700 1697
			$folderIcon .= $aTag_e;
1701 1698
			$content .= $folderIcon . '<br />';
1702
		}
1703
		// Listing the folders:
1704
		if (is_array($folders)) {
1705
			if (count($folders) > 0) {
1706
				// Traverse the folder list:
1707
				$lines = array();
1708
				foreach ($folders as $folderPath) {
1709
					$pathInfo = pathinfo($folderPath);
1710
					// Create folder icon:
1711
					$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="" />';
1712
					// Create links for adding the folder:
1713
					if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
1714
						$aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . rawurlencode($folderPath) . '\'));">';
1715
					} else {
1716
						$aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($folderPath) . '\', \'folder\', \'' . rawurlencode($folderPath) . '\', unescape(\'' . rawurlencode($folderPath) . '\'), \'' . $pathInfo['extension'] . '\', \'' . $ficon . '\');">';
1717
					}
1718
					if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
1719
						// In case an invalid character is in the filepath, display error message:
1720
						$errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
1721
						$aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
1722
					} else {
1723
						// If foldername is OK, just add it:
1724
						$aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
1725
					}
1726
					$aTag_e = '</a>';
1727
					// Combine icon and folderpath:
1728
					$foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
1729
					if ($this->P['itemName'] != '') {
1730
						$lines[] = '
1731
							<tr class="bgColor4">
1732
								<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
1733
								<td>&nbsp;</td>
1734
							</tr>';
1735
					} else {
1736
						$lines[] = '
1737
							<tr class="bgColor4">
1738
								<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
1739
								<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>
1740
								<td>&nbsp;</td>
1741
							</tr>';
1742
					}
1743
					$lines[] = '
1744
							<tr>
1745
								<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
1746
							</tr>';
1747
				}
1748
			}
1749
			// Wrap all the rows in table tags:
1750
			$content .= '
1751

  
1752
		<!--
1753
			Folder listing
1754
		-->
1755
				<table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
1756
					' . implode('', $lines) . '
1757
				</table>';
1758
		}
1699
                        
1700
                        // Listing the folders:
1701
                        if (count($subfolders) > 0) {
1702
                                // Traverse the folder list:
1703
                                $lines = array();
1704
                                foreach ($subfolders as $subfolder) {
1705
                                        // Create folder icon:
1706
                                        $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="" />';
1707
                                        // Create links for adding the folder:
1708
                                        $encodedPublicUrl = rawurlencode($subfolder->getPublicUrl());
1709
                                        if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
1710
                                                $aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . $encodedPublicUrl . '\'));">';
1711
                                        } else {
1712
                                                $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . $encodedPublicUrl . '\', \'folder\', \'' . $encodedPublicUrl . '\', unescape(\'' . $encodedPublicUrl . '\'), \'\', \'\');">';
1713
                                        }
1714
                                        $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
1715
                                        $aTag_e = '</a>';
1716
                                        // Combine icon and folderpath:
1717
                                        $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($subfolder->getName(), $titleLength)) . $aTag_e;
1718
                                        if ($this->P['itemName'] != '') {
1719
                                                $lines[] = '
1720
                                                        <tr class="bgColor4">
1721
                                                                <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
1722
                                                                <td>&nbsp;</td>
1723
                                                        </tr>';
1724
                                        } else {
1725
                                                $lines[] = '
1726
                                                        <tr class="bgColor4">
1727
                                                                <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
1728
                                                                <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>
1729
                                                                <td>&nbsp;</td>
1730
                                                        </tr>';
1731
                                        }
1732
                                        $lines[] = '
1733
                                                        <tr>
1734
                                                                <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
1735
                                                        </tr>';
1736
                                }
1737
                        }
1738
                        // Wrap all the rows in table tags:
1739
                        $content .= '
1740

  
1741
        <!--
1742
                Folder listing
1743
        -->
1744
                        <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
1745
                                ' . implode('', $lines) . '
1746
                        </table>';
1747
                }
1759 1748
		// Return accumulated content for folderlisting:
1760 1749
		return $content;
1761 1750
	}