X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/faeb2528ec1f4989f452262793e7881a25cd1147..52585063a5240b11aa1d541c699e240de8261813:/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php diff --git a/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php b/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php index ebab560c1211..f585e0f9ba64 100644 --- a/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php @@ -1499,7 +1499,7 @@ class ElementBrowser { /** * For RTE: This displays all files from folder. No thumbnails shown * - * @param string $folder The folder path to expand + * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand * @param string $extensionList List of fileextensions to show * @return string HTML output * @todo Define visibility @@ -1528,11 +1528,7 @@ class ElementBrowser { if ($renderFolders) { $items = $folder->getSubfolders(); } else { - $filter = new \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter(); - $filter->setAllowedFileExtensions($extensionList); - $folder->getStorage()->setFileAndFolderNameFilters(array(array($filter, 'filterFileList'))); - - $items = $folder->getFiles(); + $items = $this->getFilesInFolder($folder, $extensionList); } $c = 0; $totalItems = count($items); @@ -1573,16 +1569,13 @@ class ElementBrowser { * @return string HTML output * @todo Define visibility */ - public function TBE_expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '', $noThumbs = 0) { - $extensionList = $extensionList == '*' ? '' : $extensionList; - $content = ''; - if ($folder->checkActionPermission('read')) { - // Listing the files: - $files = $folder->getFiles($extensionList); - $content = $this->fileList($files, $folder, $noThumbs); + public function TBE_expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '', $noThumbs = FALSE) { + if (!$folder->checkActionPermission('read')) { + return ''; } - // Return accumulated content for filelisting: - return $content; + $extensionList = $extensionList == '*' ? '' : $extensionList; + $files = $this->getFilesInFolder($folder, $extensionList); + return $this->fileList($files, $folder, $noThumbs); } /** @@ -1802,86 +1795,85 @@ class ElementBrowser { * @todo Define visibility */ public function TBE_dragNDrop(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '') { - $extensionList = $extensionList == '*' ? '' : $extensionList; + if (!$folder) { + return ''; + } $out = ''; - if ($folder) { - if ($folder->getStorage()->isPublic()) { - // Read files from directory: - $files = $folder->getFiles($extensionList); - if (is_array($files)) { - $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files))); - $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); - $picon = ''; - $picon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen)); - $out .= $picon . '
'; - // Init row-array: - $lines = array(); - // Add "drag-n-drop" message: + if ($folder->getStorage()->isPublic()) { + // Read files from directory: + $extensionList = $extensionList == '*' ? '' : $extensionList; + $files = $this->getFilesInFolder($folder, $extensionList); + $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files))); + $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); + $picon = ''; + $picon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen)); + $out .= $picon . '
'; + // Init row-array: + $lines = array(); + // Add "drag-n-drop" message: + $lines[] = ' + + ' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . ' + '; + // Traverse files: + foreach ($files as $fileObject) { + $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject); + // URL of image: + $iUrl = GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE)); + // Show only web-images + $fileExtension = strtolower($fileObject->getExtension()); + if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) { + $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE)); + $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels'; + $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')'; + $filenameAndIcon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size)); + if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('noLimit')) { + $maxW = 10000; + $maxH = 10000; + } else { + $maxW = 380; + $maxH = 500; + } + $IW = $imgInfo[0]; + $IH = $imgInfo[1]; + if ($IW > $maxW) { + $IH = ceil($IH / $IW * $maxW); + $IW = $maxW; + } + if ($IH > $maxH) { + $IW = ceil($IW / $IH * $maxH); + $IH = $maxH; + } + // Make row: + $lines[] = ' + + ' . $filenameAndIcon . '  + ' . ($imgInfo[0] != $IW ? '' . '' . '' : '') . $pDim . '  + '; $lines[] = ' - ' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . ' + + '; + $lines[] = ' + + '; - // Traverse files: - foreach ($files as $fileObject) { - $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject); - // URL of image: - $iUrl = GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE)); - // Show only web-images - $fileExtension = strtolower($fileObject->getExtension()); - if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) { - $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE)); - $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels'; - $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')'; - $filenameAndIcon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size)); - if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('noLimit')) { - $maxW = 10000; - $maxH = 10000; - } else { - $maxW = 380; - $maxH = 500; - } - $IW = $imgInfo[0]; - $IH = $imgInfo[1]; - if ($IW > $maxW) { - $IH = ceil($IH / $IW * $maxW); - $IW = $maxW; - } - if ($IH > $maxH) { - $IW = ceil($IW / $IH * $maxH); - $IH = $maxH; - } - // Make row: - $lines[] = ' - - ' . $filenameAndIcon . '  - ' . ($imgInfo[0] != $IW ? '' . '' . '' : '') . $pDim . '  - '; - $lines[] = ' - - - '; - $lines[] = ' - - - '; - } - } - // Finally, wrap all rows in a table tag: - $out .= ' - - - - - ' . implode('', $lines) . ' -
'; } - } else { - // Print this warning if the folder is NOT a web folder: - $out .= $this->barheader($GLOBALS['LANG']->getLL('files')); - $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2'); } + // Finally, wrap all rows in a table tag: + $out .= ' + + + + + ' . implode('', $lines) . ' +
'; + } else { + // Print this warning if the folder is NOT a web folder: + $out .= $this->barheader($GLOBALS['LANG']->getLL('files')); + $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2'); } return $out; } @@ -2253,4 +2245,21 @@ class ElementBrowser { return $result; } + /** + * Get a list of Files in a folder filtered by extension + * + * @param \TYPO3\CMS\Core\Resource\Folder $folder + * @param string $extensionList + * @return \TYPO3\CMS\Core\Resource\File[] + */ + protected function getFilesInFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList) { + if ($extensionList !== '') { + /** @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter $filter */ + $filter = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter'); + $filter->setAllowedFileExtensions($extensionList); + $folder->setFileAndFolderNameFilters(array(array($filter, 'filterFileList'))); + } + return $folder->getFiles(); + } + }