/** * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images. * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE * * @param string The folder path to expand * @param string List of fileextensions to show * @return string HTML output */ function TBE_dragNDrop($expandFolder = 0, $extensionList = '') { global $BACK_PATH; $extensionList = $extensionList == '*' ? '' : $extensionList; $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder; $out = ''; if ($expandFolder && $this->checkFolder($expandFolder)) { if ($this->isWebFolder($expandFolder)) { // Read files from directory: $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList="",$prependPath=0,$order='') if (is_array($files)) { $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files))); $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); $picon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />'; $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder), $titleLen)); $out .= $picon . '<br />'; // Init row-array: $lines = array(); // Add "drag-n-drop" message: $lines[] = ' <tr> <td colspan="2">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td> </tr>'; // Traverse files: foreach ($files as $filepath) { $fI = pathinfo($filepath); // URL of image: $iurl = $this->siteURL . t3lib_div::rawurlencodeFP(substr($filepath, strlen(PATH_site))); // Show only web-images if (t3lib_div::inList('gif,jpeg,jpg,png', strtolower($fI['extension']))) { $imgInfo = @getimagesize($filepath); $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels'; $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')'; $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $ficon, 'width="18" height="16"') . ' class="absmiddle" title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />'; $filenameAndIcon = $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath), $titleLen)); if (t3lib_div::_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[] = ' <tr class="bgColor4"> <td nowrap="nowrap">' . $filenameAndIcon . ' </td> <td nowrap="nowrap">' . ($imgInfo[0] != $IW ? '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('noLimit' => '1'))) . '">' . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/icon_warning2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', 1) . '" alt="" />' . '</a>' : '') . $pDim . ' </td> </tr>'; $lines[] = ' <tr> <td colspan="2"><img src="' . $iurl . '" width="' . $IW . '" height="' . $IH . '" border="1" alt="" /></td> </tr>'; $lines[] = ' <tr> <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td> </tr>'; } } // Finally, wrap all rows in a table tag: $out .= ' <!-- File listing / Drag-n-drop --> <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox"> ' . implode('', $lines) . ' </table>'; } } 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; }
/** * Print the content on a pad. Called from ->printClipboard() * * @param string Pad reference * @return array Array with table rows for the clipboard. * @access private */ function printContentFromTab($pad) { global $TBE_TEMPLATE; $lines = array(); if (is_array($this->clipData[$pad]['el'])) { foreach ($this->clipData[$pad]['el'] as $k => $v) { if ($v) { list($table, $uid) = explode('|', $k); $bgColClass = $table == '_FILE' && $this->fileMode || $table != '_FILE' && !$this->fileMode ? 'bgColor4-20' : 'bgColor4'; if ($table == '_FILE') { // Rendering files/directories on the clipboard: if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) { $fI = pathinfo($v); $icon = is_dir($v) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); $size = ' (' . t3lib_div::formatSize(filesize($v)) . 'bytes)'; $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($v) ? 'folder' : strtolower($fI['extension']), array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars($fI['basename'] . $size))); $thumb = $this->clipData['_setThumb'] ? t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fI['extension']) ? t3lib_BEfunc::getThumbNail($this->backPath . 'thumbs.php', $v, ' vspace="4"') : '' : ''; $lines[] = ' <tr> <td class="' . $bgColClass . '">' . $icon . '</td> <td class="' . $bgColClass . '" nowrap="nowrap" width="95%"> ' . $this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v), $GLOBALS['BE_USER']->uc['titleLen'])), $v) . ($pad == 'normal' ? ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')</strong>' : '') . ' ' . ($thumb ? '<br />' . $thumb : '') . '</td> <td class="' . $bgColClass . '" align="center" nowrap="nowrap">' . '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $v . '\', \'\'); return false;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl('_FILE', t3lib_div::shortmd5($v))) . '#clip_head">' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>' . '</td> </tr>'; } else { // If the file did not exist (or is illegal) then it is removed from the clipboard immediately: unset($this->clipData[$pad]['el'][$k]); $this->changed = 1; } } else { // Rendering records: $rec = t3lib_BEfunc::getRecordWSOL($table, $uid); if (is_array($rec)) { $lines[] = ' <tr> <td class="' . $bgColClass . '">' . $this->linkItemText(t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec, $table)))), $rec, $table) . '</td> <td class="' . $bgColClass . '" nowrap="nowrap" width="95%"> ' . $this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])), $rec, $table) . ($pad == 'normal' ? ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')</strong>' : '') . ' </td> <td class="' . $bgColClass . '" align="center" nowrap="nowrap">' . '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . intval($uid) . '\'); return false;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl($table, $uid)) . '#clip_head">' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>' . '</td> </tr>'; $localizationData = $this->getLocalizations($table, $rec, $bgColClass, $pad); if ($localizationData) { $lines[] = $localizationData; } } else { unset($this->clipData[$pad]['el'][$k]); $this->changed = 1; } } } } } if (!count($lines)) { $lines[] = ' <tr> <td class="bgColor4"><img src="clear.gif" width="56" height="1" alt="" /></td> <td colspan="2" class="bgColor4" nowrap="nowrap" width="95%"> <em>(' . $this->clLabel('clipNoEl') . ')</em> </td> </tr>'; } $this->endClipboard(); return $lines; }
/** * Rendering preview output of a field value which is not shown as a form field but just outputted. * * @param string The value to output * @param array Configuration for field. * @param string Name of field. * @return string HTML formatted output */ function previewFieldValue($value, $config, $field = '') { if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) { // Ignore uploadfolder if internal_type is file_reference if ($config['config']['internal_type'] === 'file_reference') { $config['config']['uploadfolder'] = ''; } $show_thumbs = TRUE; $table = 'tt_content'; // Making the array of file items: $itemArray = t3lib_div::trimExplode(',', $value, 1); // Showing thumbnails: $thumbsnail = ''; if ($show_thumbs) { $imgs = array(); foreach ($itemArray as $imgRead) { $imgP = explode('|', $imgRead); $imgPath = rawurldecode($imgP[0]); $rowCopy = array(); $rowCopy[$field] = $imgPath; // Icon + clickmenu: $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath); $fI = pathinfo($imgPath); $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); $fileIcon = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/fileicons/' . $fileIcon, 'width="18" height="16"') . ' class="absmiddle" title="' . htmlspecialchars($fI['basename'] . ($absFilePath && @is_file($absFilePath) ? ' (' . t3lib_div::formatSize(filesize($absFilePath)) . 'bytes)' : ' - FILE NOT FOUND!')) . '" alt="" />'; $imgs[] = '<span class="nobr">' . t3lib_BEfunc::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon) . $imgPath . '</span>'; } $thumbsnail = implode('<br />', $imgs); } return $thumbsnail; } else { return nl2br(htmlspecialchars($value)); } }
/** * @param [type] $expandFolder: ... * @param [type] $plainFlag: ... * @return [type] ... */ function expandFolder($expandFolder = 0, $plainFlag = 0, $noThumbs = 0) { global $LANG; $expandFolder = $expandFolder ? $expandFolder : t3lib_div::_GP("expandFolder"); $out = ""; $resolutionLimit_x = $this->thisConfig['typo3filemanager.']['maxPlainImages.']['width']; $resolutionLimit_y = $this->thisConfig['typo3filemanager.']['maxPlainImages.']['height']; if ($expandFolder) { $files = t3lib_div::getFilesInDir($expandFolder, $plainFlag ? "jpg,jpeg,gif,png" : $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"], 1, 1); // $extensionList="",$prependPath=0,$order="") if (is_array($files)) { reset($files); $titleLen = intval($GLOBALS["BE_USER"]->uc["titleLen"]); $picon = '<img src="' . $this->doc->backPath . 'gfx/i/_icon_webfolders.gif" width="18" height="16" alt="folder" />'; $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder), $titleLen)); $out .= '<span class="nobr">' . $picon . '</span><br />'; $imgObj = t3lib_div::makeInstance("t3lib_stdGraphic"); $imgObj->init(); $imgObj->mayScaleUp = 0; $imgObj->tempPath = PATH_site . $imgObj->tempPath; $lines = array(); while (list(, $filepath) = each($files)) { $fI = pathinfo($filepath); //$iurl = $this->siteUrl.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))); $iurl = t3lib_div::rawUrlEncodeFP(substr($filepath, strlen(PATH_site))); $imgInfo = $imgObj->getImageDimensions($filepath); $icon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"])); $pDim = $imgInfo[0] . "x" . $imgInfo[1] . " pixels"; $size = " (" . t3lib_div::formatSize(filesize($filepath)) . "bytes, " . $pDim . ")"; $icon = '<img src="' . $this->doc->backPath . 'gfx/fileicons/' . $icon . '" style="width: 18px; height: 16px; border: none;" title="' . $fI["basename"] . $size . '" class="absmiddle" alt="' . $icon . '" />'; if (!$plainFlag) { $ATag = '<a href="#" onclick="return jumpToUrl(\'?insertMagicImage=' . rawurlencode($filepath) . '\');">'; } else { $ATag = '<a href="#" onclick="return insertImage(\'' . $iurl . '\',' . $imgInfo[0] . ',' . $imgInfo[1] . ');">'; } $ATag_e = "</a>"; if ($plainFlag && ($imgInfo[0] > $resolutionLimit_x || $imgInfo[1] > $resolutionLimit_y)) { $ATag = ""; $ATag_e = ""; $ATag2 = ""; $ATag2_e = ""; } else { $ATag2 = '<a href="#" onclick="launchView(\'' . rawurlencode($filepath) . '\'); return false;">'; $ATag2_e = "</a>"; } $filenameAndIcon = $ATag . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath), $titleLen)) . $ATag_e; $lines[] = '<tr class="bgColor4"><td nowrap="nowrap">' . $filenameAndIcon . ' </td></tr><tr><td nowrap="nowrap" class="pixel">' . $pDim . ' </td></tr>'; $lines[] = '<tr><td>' . ($noThumbs ? "" : $ATag2 . t3lib_BEfunc::getThumbNail($this->doc->backPath . 'thumbs.php', $filepath, 'hspace="5" vspace="5" border="1"', $this->thisConfig['typo3filemanager.']['thumbs.']['width'] . 'x' . $this->thisConfig['typo3filemanager.']['thumbs.']['height']) . $ATag2_e) . '</td></tr>'; $lines[] = '<tr><td><img src="clear.gif" style="width: 1px; height: 3px;" alt="clear" /></td></tr>'; } $out .= '<table border="0" cellpadding="0" cellspacing="1">' . implode("", $lines) . '</table>'; } } return $out; }
/** * Main function. Will generate the information to display for the item set internally. * * @param string <a> tag closing/returning. * @return void */ function renderFileInfo($returnLinkTag) { // Initialize object to work on the image: $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic'); $imgObj->init(); $imgObj->mayScaleUp = 0; $imgObj->absPrefix = PATH_site; // Read Image Dimensions (returns false if file was not an image type, otherwise dimensions in an array) $imgInfo = ''; $imgInfo = $imgObj->getImageDimensions($this->file); // File information $fI = t3lib_div::split_fileref($this->file); $ext = $fI['fileext']; $code = ''; // Setting header: $icon = t3lib_BEfunc::getFileIcon($ext); $url = 'gfx/fileicons/' . $icon; $fileName = '<img src="' . $url . '" width="18" height="16" align="top" alt="" /><strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', 1) . ':</strong> ' . $fI['file']; if (t3lib_div::isFirstPartOfStr($this->file, PATH_site)) { $code .= '<a href="../' . substr($this->file, strlen(PATH_site)) . '" target="_blank">' . $fileName . '</a>'; } else { $code .= $fileName; } $code .= ' <strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . t3lib_div::formatSize(@filesize($this->file)) . '<br /> '; if (is_array($imgInfo)) { $code .= '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels'); } $this->content .= $this->doc->section('', $code); $this->content .= $this->doc->divider(2); // If the file was an image...: if (is_array($imgInfo)) { $imgInfo = $imgObj->imageMagickConvert($this->file, 'web', '346', '200m', '', '', '', 1); $imgInfo[3] = '../' . substr($imgInfo[3], strlen(PATH_site)); $code = '<br /> <div align="center">' . $returnLinkTag . $imgObj->imgTag($imgInfo) . '</a></div>'; $this->content .= $this->doc->section('', $code); } else { $this->content .= $this->doc->spacer(10); $lowerFilename = strtolower($this->file); // Archive files: if (TYPO3_OS != 'WIN' && !$GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) { if ($ext == 'zip') { $code = ''; $t = array(); exec('unzip -l ' . $this->file, $t); if (is_array($t)) { reset($t); next($t); next($t); next($t); while (list(, $val) = each($t)) { $parts = explode(' ', trim($val), 7); $code .= ' ' . $parts[6] . '<br />'; } $code = ' <span class="nobr">' . $code . ' </span> <br /><br />'; } $this->content .= $this->doc->section('', $code); } elseif ($ext == 'tar' || $ext == 'tgz' || substr($lowerFilename, -6) == 'tar.gz' || substr($lowerFilename, -5) == 'tar.z') { $code = ''; if ($ext == 'tar') { $compr = ''; } else { $compr = 'z'; } $t = array(); exec('tar t' . $compr . 'f ' . $this->file, $t); if (is_array($t)) { foreach ($t as $val) { $code .= ' ' . $val . '<br />'; } $code .= ' -------<br/> ' . count($t) . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.files'); $code = ' <span class="nobr">' . $code . ' </span> <br /><br />'; } $this->content .= $this->doc->section('', $code); } } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) { $this->content .= $this->doc->section('', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.cannotDisplayArchive')); } // Font files: if ($ext == 'ttf') { $thumbScript = 'thumbs.php'; $check = basename($this->file) . ':' . filemtime($this->file) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; $params = '&file=' . rawurlencode($this->file); $params .= '&md5sum=' . t3lib_div::shortMD5($check); $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params; $thumb = '<br /> <div align="center">' . $returnLinkTag . '<img src="' . htmlspecialchars($url) . '" border="0" title="' . htmlspecialchars(trim($this->file)) . '" alt="" /></a></div>'; $this->content .= $this->doc->section('', $thumb); } } // References: $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'), $this->makeRef('_FILE', $this->file)); }