📄 class.tx_cssstyledcontent_pi1.php
字号:
// Explode into an array: $fileArray = t3lib_div::trimExplode(',',$fileList,1); // If there were files to list...: if (count($fileArray)) { // Get the path from which the images came: $selectKeyValues = explode('|',$this->cObj->data['select_key']); $path = trim($selectKeyValues[0]) ? trim($selectKeyValues[0]) : 'uploads/media/'; // Get the descriptions for the files (if any): $descriptions = t3lib_div::trimExplode(chr(10),$this->cObj->data['imagecaption']); // Adding hardcoded TS to linkProc configuration: $conf['linkProc.']['path.']['current'] = 1; $conf['linkProc.']['icon'] = 1; // Always render icon - is inserted by PHP if needed. $conf['linkProc.']['icon.']['wrap'] = ' | //**//'; // Temporary, internal split-token! $conf['linkProc.']['icon_link'] = 1; // ALways link the icon $conf['linkProc.']['icon_image_ext_list'] = ($type==2 || $type==3) ? $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] : ''; // If the layout is type 2 or 3 we will render an image based icon if possible. // Traverse the files found: $filesData = array(); foreach($fileArray as $key => $fileName) { $absPath = t3lib_div::getFileAbsFileName($path.$fileName); if (@is_file($absPath)) { $fI = pathinfo($fileName); $filesData[$key] = array(); $filesData[$key]['filename'] = $fileName; $filesData[$key]['path'] = $path; $filesData[$key]['filesize'] = filesize($absPath); $filesData[$key]['fileextension'] = strtolower($fI['extension']); $filesData[$key]['description'] = trim($descriptions[$key]); $this->cObj->setCurrentVal($path); $GLOBALS['TSFE']->register['ICON_REL_PATH'] = $path.$fileName; $filesData[$key]['linkedFilenameParts'] = explode('//**//',$this->cObj->filelink($fileName, $conf['linkProc.'])); } } // Now, lets render the list! $tRows = array(); foreach($filesData as $key => $fileD) { // Setting class of table row for odd/even rows: $oddEven = $key%2 ? 'tr-odd' : 'tr-even'; // Render row, based on the "layout" setting $tRows[]=' <tr class="'.$oddEven.'">'.($type>0 ? ' <td class="csc-uploads-icon"> '.$fileD['linkedFilenameParts'][0].' </td>' : '').' <td class="csc-uploads-fileName"> <p>'.$fileD['linkedFilenameParts'][1].'</p>'. ($fileD['description'] ? ' <p class="csc-uploads-description">'.htmlspecialchars($fileD['description']).'</p>' : '').' </td>'.($this->cObj->data['filelink_size'] ? ' <td class="csc-uploads-fileSize"> <p>'.t3lib_div::formatSize($fileD['filesize']).'</p> </td>' : '').' </tr>'; } // Table tag params. $tableTagParams = $this->getTableAttributes($conf,$type); $tableTagParams['class'] = 'csc-uploads csc-uploads-'.$type; // Compile it all into table tags: $out = ' <table '.t3lib_div::implodeAttributes($tableTagParams).'> '.implode('',$tRows).' </table>'; } // Calling stdWrap: if ($conf['stdWrap.']) { $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); } // Return value return $out; } } /** * Rendering the IMGTEXT content element, called from TypoScript (tt_content.textpic.20) * * @param string Content input. Not used, ignore. * @param array TypoScript configuration. See TSRef "IMGTEXT". This function aims to be compatible. * @return string HTML output. * @access private * @coauthor Ernesto Baschny <ernst@cron-it.de> */ function render_textpic($content, $conf) { // Look for hook before running default code for function if (method_exists($this, 'hookRequest') && $hookObj = &$this->hookRequest('render_textpic')) { return $hookObj->render_textpic($content,$conf); } $renderMethod = $this->cObj->stdWrap($conf['renderMethod'], $conf['renderMethod.']); // Render using the default IMGTEXT code (table-based) if (!$renderMethod || $renderMethod == 'table') { return $this->cObj->IMGTEXT($conf); } // Specific configuration for the chosen rendering method if (is_array($conf['rendering.'][$renderMethod . '.'])) { $conf = $this->cObj->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']); } // Image or Text with Image? if (is_array($conf['text.'])) { $content = $this->cObj->stdWrap($this->cObj->cObjGet($conf['text.'], 'text.'), $conf['text.']); } $imgList = trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])); if (!$imgList) { // No images, that's easy if (is_array($conf['stdWrap.'])) { return $this->cObj->stdWrap($content, $conf['stdWrap.']); } return $content; } $imgs = t3lib_div::trimExplode(',', $imgList); $imgStart = intval($this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.'])); $imgCount = count($imgs) - $imgStart; $imgMax = intval($this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.'])); if ($imgMax) { $imgCount = t3lib_div::intInRange($imgCount, 0, $imgMax); // reduce the number of images. } $imgPath = $this->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']); // Global caption $caption = ''; if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) { $caption = $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); } // Positioning $position = $this->cObj->stdWrap($conf['textPos'], $conf['textPos.']); $imagePosition = $position&7; // 0,1,2 = center,right,left $contentPosition = $position&24; // 0,8,16,24 (above,below,intext,intext-wrap) $align = $this->cObj->align[$imagePosition]; $textMargin = intval($this->cObj->stdWrap($conf['textMargin'],$conf['textMargin.'])); if (!$conf['textMargin_outOfText'] && $contentPosition < 16) { $textMargin = 0; } $colspacing = intval($this->cObj->stdWrap($conf['colSpace'], $conf['colSpace.'])); $rowspacing = intval($this->cObj->stdWrap($conf['rowSpace'], $conf['rowSpace.'])); $border = intval($this->cObj->stdWrap($conf['border'], $conf['border.'])) ? 1:0; $borderColor = $this->cObj->stdWrap($conf['borderCol'], $conf['borderCol.']); $borderThickness = intval($this->cObj->stdWrap($conf['borderThick'], $conf['borderThick.'])); $borderColor = $borderColor?$borderColor:'black'; $borderThickness = $borderThickness?$borderThickness:1; $borderSpace = (($conf['borderSpace']&&$border) ? intval($conf['borderSpace']) : 0); // Generate cols $cols = intval($this->cObj->stdWrap($conf['cols'],$conf['cols.'])); $colCount = ($cols > 1) ? $cols : 1; if ($colCount > $imgCount) {$colCount = $imgCount;} $rowCount = ceil($imgCount / $colCount); // Generate rows $rows = intval($this->cObj->stdWrap($conf['rows'],$conf['rows.'])); if ($rows>1) { $rowCount = $rows; if ($rowCount > $imgCount) {$rowCount = $imgCount;} $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount; } // Max Width $maxW = intval($this->cObj->stdWrap($conf['maxW'], $conf['maxW.'])); if ($contentPosition>=16) { // in Text $maxWInText = intval($this->cObj->stdWrap($conf['maxWInText'],$conf['maxWInText.'])); if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 50% of the max $maxW = round($maxW/100*50); } else { $maxW = $maxWInText; } } // All columns have the same width: $defaultColumnWidth = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*($borderThickness+$borderSpace)*2)/$colCount); // Specify the maximum width for each column $columnWidths = array(); $colRelations = trim($this->cObj->stdWrap($conf['colRelations'],$conf['colRelations.'])); if (!$colRelations) { // Default 1:1-proportion, all columns same width for ($a=0;$a<$colCount;$a++) { $columnWidths[$a] = $defaultColumnWidth; } } else { // We need another proportion $rel_parts = explode(':',$colRelations); $rel_total = 0; for ($a=0;$a<$colCount;$a++) { $rel_parts[$a] = intval($rel_parts[$a]); $rel_total+= $rel_parts[$a]; } if ($rel_total) { for ($a=0;$a<$colCount;$a++) { $columnWidths[$a] = round(($defaultColumnWidth*$colCount)/$rel_total*$rel_parts[$a]); } if (min($columnWidths)<=0 || max($rel_parts)/min($rel_parts)>10) { // The difference in size between the largest and smalles must be within a factor of ten. for ($a=0;$a<$colCount;$a++) { $columnWidths[$a] = $defaultColumnWidth; } } } } $image_compression = intval($this->cObj->stdWrap($conf['image_compression'],$conf['image_compression.'])); $image_effects = intval($this->cObj->stdWrap($conf['image_effects'],$conf['image_effects.'])); $image_frames = intval($this->cObj->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.'])); // EqualHeight $equalHeight = intval($this->cObj->stdWrap($conf['equalH'],$conf['equalH.'])); if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); $gifCreator->init(); $relations_cols = Array(); for ($a=0; $a<$imgCount; $a++) { $imgKey = $a+$imgStart; $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]); $rel = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height if ($rel) { // if relations is zero, then the addition of this value is omitted as the image is not expected to display because of some error. $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$rel; // counts the total width of the row with the new height taken into consideration. } } } // Fetches pictures $splitArr = array(); $splitArr['imgObjNum'] = $conf['imgObjNum']; $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount); $imageRowsFinalWidths = Array(); // contains the width of every image row $imgsTag = array(); // array index of $imgsTag will be the same as in $imgs, but $imgsTag only contains the images that are actually shown $origImages = array(); for ($a=0; $a<$imgCount; $a++) { $imgKey = $a+$imgStart; $totalImagePath = $imgPath.$imgs[$imgKey]; $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgKey; // register IMG_NUM is kept for backwards compatibility $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgKey; $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $totalImagePath; $this->cObj->data[$this->cObj->currentValKey] = $totalImagePath; $imgObjNum = intval($splitArr[$a]['imgObjNum']); $imgConf = $conf[$imgObjNum.'.']; if ($equalHeight) { $scale = 1; $totalMaxW = $defaultColumnWidth*$colCount; $rowTotalMaxW = $relations_cols[floor($a/$colCount)]; if ($rowTotalMaxW > $totalMaxW) { $scale = $rowTotalMaxW / $totalMaxW; } // transfer info to the imageObject. Please note, that $imgConf['file.']['height'] = round($equalHeight/$scale); // other stuff will be calculated accordingly: unset($imgConf['file.']['width']); unset($imgConf['file.']['maxW']); unset($imgConf['file.']['maxH']); unset($imgConf['file.']['minW']); unset($imgConf['file.']['minH']); unset($imgConf['file.']['width.']); unset($imgConf['file.']['maxW.']); unset($imgConf['file.']['maxH.']); unset($imgConf['file.']['minW.']); unset($imgConf['file.']['minH.']); } else { $imgConf['file.']['maxW'] = $columnWidths[($a%$colCount)]; } $titleInLink = $this->cObj->stdWrap($imgConf['titleInLink'], $imgConf['titleInLink.']); $titleInLinkAndImg = $this->cObj->stdWrap($imgConf['titleInLinkAndImg'], $imgConf['titleInLinkAndImg.']); $oldATagParms = $GLOBALS['TSFE']->ATagParams; if ($titleInLink) { // Title in A-tag instead of IMG-tag $titleText = trim($this->cObj->stdWrap($imgConf['titleText'], $imgConf['titleText.']));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -