"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php Source File", "datetime" => "Sat Dec 2 19:22:30 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00056 require_once(PATH_tslib.'class.tslib_pibase.php'); 00057 00058 00059 00068 class tx_cssstyledcontent_pi1 extends tslib_pibase { 00069 00070 // Default plugin variables: 00071 var $prefixId = 'tx_cssstyledcontent_pi1'; // Same as class name 00072 var $scriptRelPath = 'pi1/class.tx_cssstyledcontent_pi1.php'; // Path to this script relative to the extension dir. 00073 var $extKey = 'css_styled_content'; // The extension key. 00074 var $conf = array(); 00075 00076 00077 00078 00079 00080 00081 00082 /*********************************** 00083 * 00084 * Rendering of Content Elements: 00085 * 00086 ***********************************/ 00087 00096 function render_bullets($content,$conf) { 00097 00098 // Look for hook before running default code for function 00099 if ($hookObj = &$this->hookRequest('render_bullets')) { 00100 return $hookObj->render_bullets($content,$conf); 00101 } else { 00102 00103 // Get bodytext field content, returning blank if empty: 00104 $content = trim($this->cObj->data['bodytext']); 00105 if (!strcmp($content,'')) return ''; 00106 00107 // Split into single lines: 00108 $lines = t3lib_div::trimExplode(chr(10),$content); 00109 while(list($k)=each($lines)) { 00110 $lines[$k]=' 00111 <li>'.$this->cObj->stdWrap($lines[$k],$conf['innerStdWrap.']).'</li>'; 00112 } 00113 00114 // Set header type: 00115 $type = intval($this->cObj->data['layout']); 00116 00117 // Compile list: 00118 $out = ' 00119 <ul class="csc-bulletlist csc-bulletlist-'.$type.'">'. 00120 implode('',$lines).' 00121 </ul>'; 00122 00123 // Calling stdWrap: 00124 if ($conf['stdWrap.']) { 00125 $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); 00126 } 00127 00128 // Return value 00129 return $out; 00130 } 00131 } 00132 00141 function render_table($content,$conf) { 00142 00143 // Look for hook before running default code for function 00144 if ($hookObj = &$this->hookRequest('render_table')) { 00145 return $hookObj->render_table($content,$conf); 00146 } else { 00147 // Init FlexForm configuration 00148 $this->pi_initPIflexForm(); 00149 00150 // Get bodytext field content 00151 $content = trim($this->cObj->data['bodytext']); 00152 if (!strcmp($content,'')) return ''; 00153 00154 // get flexform values 00155 $caption = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_caption'))); 00156 $summary = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_summary'))); 00157 $useTfoot = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_tfoot')); 00158 $headerPos = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_headerpos'); 00159 $noStyles = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_nostyles'); 00160 $tableClass = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_tableclass'); 00161 00162 $delimiter = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'tableparsing_delimiter','s_parsing')); 00163 if ($delimiter) { 00164 $delimiter = chr(intval($delimiter)); 00165 } else { 00166 $delimiter = '|'; 00167 } 00168 $quotedInput = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'tableparsing_quote','s_parsing')); 00169 if ($quotedInput) { 00170 $quotedInput = chr(intval($quotedInput)); 00171 } else { 00172 $quotedInput = ''; 00173 } 00174 00175 // generate id prefix for accessible header 00176 $headerScope = ($headerPos=='top'?'col':'row'); 00177 $headerIdPrefix = $headerScope.$this->cObj->data['uid'].'-'; 00178 00179 // Split into single lines (will become table-rows): 00180 $rows = t3lib_div::trimExplode(chr(10),$content); 00181 00182 // Find number of columns to render: 00183 $cols = t3lib_div::intInRange($this->cObj->data['cols']?$this->cObj->data['cols']:count(explode($delimiter,current($rows))),0,100); 00184 00185 // Traverse rows (rendering the table here) 00186 $rCount = count($rows); 00187 foreach($rows as $k => $v) { 00188 $cells = explode($delimiter,$v); 00189 $newCells=array(); 00190 for($a=0;$a<$cols;$a++) { 00191 // remove quotes if needed 00192 if ($quotedInput && substr($cells[$a],0,1) == $quotedInput && substr($cells[$a],-1,1) == $quotedInput) { 00193 $cells[$a] = substr($cells[$a],1,-1); 00194 } 00195 00196 if (!strcmp(trim($cells[$a]),'')) $cells[$a]=' '; 00197 $cellAttribs = ($noStyles?'':($a>0 && ($cols-1)==$a) ? ' class="td-last"' : ' class="td-'.$a.'"'); 00198 if (($headerPos == 'top' && !$k) || ($headerPos == 'left' && !$a)) { 00199 $scope = ' scope="'.$headerScope.'"'; 00200 $scope .= ' id="'.$headerIdPrefix.(($headerScope=='col')?$a:$k).'"'; 00201 00202 $newCells[$a] = ' 00203 <th'.$cellAttribs.$scope.'>'.$this->cObj->stdWrap($cells[$a],$conf['innerStdWrap.']).'</th>'; 00204 } else { 00205 if (empty($headerPos)) { 00206 $accessibleHeader = ''; 00207 } else { 00208 $accessibleHeader = ' headers="'.$headerIdPrefix.(($headerScope=='col')?$a:$k).'"'; 00209 } 00210 $newCells[$a] = ' 00211 <td'.$cellAttribs.$accessibleHeader.'>'.$this->cObj->stdWrap($cells[$a],$conf['innerStdWrap.']).'</td>'; 00212 } 00213 } 00214 if (!$noStyles) { 00215 $oddEven = $k%2 ? 'tr-odd' : 'tr-even'; 00216 $rowAttribs = ($k>0 && ($rCount-1)==$k) ? ' class="'.$oddEven.' tr-last"' : ' class="'.$oddEven.' tr-'.$k.'"'; 00217 } 00218 $rows[$k]=' 00219 <tr'.$rowAttribs.'>'.implode('',$newCells).' 00220 </tr>'; 00221 } 00222 00223 $addTbody = 0; 00224 $tableContents = ''; 00225 if ($caption) { 00226 $tableContents .= ' 00227 <caption>'.$caption.'</caption>'; 00228 } 00229 if ($headerPos == 'top' && $rows[0]) { 00230 $tableContents .= '<thead>'. $rows[0] .' 00231 </thead>'; 00232 unset($rows[0]); 00233 $addTbody = 1; 00234 } 00235 if ($useTfoot) { 00236 $tableContents .= ' 00237 <tfoot>'.$rows[$rCount-1].'</tfoot>'; 00238 unset($rows[$rCount-1]); 00239 $addTbody = 1; 00240 } 00241 $tmpTable = implode('',$rows); 00242 if ($addTbody) { 00243 $tmpTable = '<tbody>'.$tmpTable.'</tbody>'; 00244 } 00245 $tableContents .= $tmpTable; 00246 00247 // Set header type: 00248 $type = intval($this->cObj->data['layout']); 00249 00250 // Table tag params. 00251 $tableTagParams = $this->getTableAttributes($conf,$type); 00252 if (!$noStyles) { 00253 $tableTagParams['class'] = 'contenttable contenttable-'.$type.($tableClass?' '.$tableClass:''); 00254 } elseif ($tableClass) { 00255 $tableTagParams['class'] = $tableClass; 00256 } 00257 00258 00259 // Compile table output: 00260 $out = ' 00261 <table '.t3lib_div::implodeAttributes($tableTagParams).($summary?' summary="'.$summary.'"':'').'>'. // Omitted xhtmlSafe argument TRUE - none of the values will be needed to be converted anyways, no need to spend processing time on that. 00262 $tableContents.' 00263 </table>'; 00264 00265 // Calling stdWrap: 00266 if ($conf['stdWrap.']) { 00267 $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); 00268 } 00269 00270 // Return value 00271 return $out; 00272 } 00273 } 00274 00283 function render_uploads($content,$conf) { 00284 00285 // Look for hook before running default code for function 00286 if ($hookObj = &$this->hookRequest('render_uploads')) { 00287 return $hookObj->render_uploads($content,$conf); 00288 } else { 00289 00290 $out = ''; 00291 00292 // Set layout type: 00293 $type = intval($this->cObj->data['layout']); 00294 00295 // Get the list of files (using stdWrap function since that is easiest) 00296 $lConf = array(); 00297 $lConf['override.']['filelist.']['field'] = 'select_key'; 00298 $fileList = $this->cObj->stdWrap($this->cObj->data['media'],$lConf); 00299 00300 // Explode into an array: 00301 $fileArray = t3lib_div::trimExplode(',',$fileList,1); 00302 00303 // If there were files to list...: 00304 if (count($fileArray)) { 00305 00306 // Get the path from which the images came: 00307 $selectKeyValues = explode('|',$this->cObj->data['select_key']); 00308 $path = trim($selectKeyValues[0]) ? trim($selectKeyValues[0]) : 'uploads/media/'; 00309 00310 // Get the descriptions for the files (if any): 00311 $descriptions = t3lib_div::trimExplode(chr(10),$this->cObj->data['imagecaption']); 00312 00313 // Adding hardcoded TS to linkProc configuration: 00314 $conf['linkProc.']['path.']['current'] = 1; 00315 $conf['linkProc.']['icon'] = 1; // Always render icon - is inserted by PHP if needed. 00316 $conf['linkProc.']['icon.']['wrap'] = ' | //**//'; // Temporary, internal split-token! 00317 $conf['linkProc.']['icon_link'] = 1; // ALways link the icon 00318 $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. 00319 00320 // Traverse the files found: 00321 $filesData = array(); 00322 foreach($fileArray as $key => $fileName) { 00323 $absPath = t3lib_div::getFileAbsFileName($path.$fileName); 00324 if (@is_file($absPath)) { 00325 $fI = pathinfo($fileName); 00326 $filesData[$key] = array(); 00327 00328 $filesData[$key]['filename'] = $fileName; 00329 $filesData[$key]['path'] = $path; 00330 $filesData[$key]['filesize'] = filesize($absPath); 00331 $filesData[$key]['fileextension'] = strtolower($fI['extension']); 00332 $filesData[$key]['description'] = trim($descriptions[$key]); 00333 00334 $this->cObj->setCurrentVal($path); 00335 $GLOBALS['TSFE']->register['ICON_REL_PATH'] = $path.$fileName; 00336 $filesData[$key]['linkedFilenameParts'] = explode('//**//',$this->cObj->filelink($fileName, $conf['linkProc.'])); 00337 } 00338 } 00339 00340 // Now, lets render the list! 00341 $tRows = array(); 00342 foreach($filesData as $key => $fileD) { 00343 00344 // Setting class of table row for odd/even rows: 00345 $oddEven = $key%2 ? 'tr-odd' : 'tr-even'; 00346 00347 // Render row, based on the "layout" setting 00348 $tRows[]=' 00349 <tr class="'.$oddEven.'">'.($type>0 ? ' 00350 <td class="csc-uploads-icon"> 00351 '.$fileD['linkedFilenameParts'][0].' 00352 </td>' : '').' 00353 <td class="csc-uploads-fileName"> 00354 <p>'.$fileD['linkedFilenameParts'][1].'</p>'. 00355 ($fileD['description'] ? ' 00356 <p class="csc-uploads-description">'.htmlspecialchars($fileD['description']).'</p>' : '').' 00357 </td>'.($this->cObj->data['filelink_size'] ? ' 00358 <td class="csc-uploads-fileSize"> 00359 <p>'.t3lib_div::formatSize($fileD['filesize']).'</p> 00360 </td>' : '').' 00361 </tr>'; 00362 } 00363 00364 // Table tag params. 00365 $tableTagParams = $this->getTableAttributes($conf,$type); 00366 $tableTagParams['class'] = 'csc-uploads csc-uploads-'.$type; 00367 00368 00369 // Compile it all into table tags: 00370 $out = ' 00371 <table '.t3lib_div::implodeAttributes($tableTagParams).'> 00372 '.implode('',$tRows).' 00373 </table>'; 00374 } 00375 00376 // Calling stdWrap: 00377 if ($conf['stdWrap.']) { 00378 $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); 00379 } 00380 00381 // Return value 00382 return $out; 00383 } 00384 } 00385 00395 function render_textpic($content, $conf) { 00396 // Look for hook before running default code for function 00397 if (method_exists($this, 'hookRequest') && $hookObj = &$this->hookRequest('render_textpic')) { 00398 return $hookObj->render_textpic($content,$conf); 00399 } 00400 00401 $renderMethod = $this->cObj->stdWrap($conf['renderMethod'], $conf['renderMethod.']); 00402 00403 // Render using the default IMGTEXT code (table-based) 00404 if (!$renderMethod || $renderMethod == 'table') { 00405 return $this->cObj->IMGTEXT($conf); 00406 } 00407 00408 // Specific configuration for the chosen rendering method 00409 if (is_array($conf['rendering.'][$renderMethod . '.'])) { 00410 $conf = $this->cObj->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']); 00411 } 00412 00413 // Image or Text with Image? 00414 if (is_array($conf['text.'])) { 00415 $content = $this->cObj->stdWrap($this->cObj->cObjGet($conf['text.'], 'text.'), $conf['text.']); 00416 } 00417 00418 $imgList = trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])); 00419 00420 if (!$imgList) { 00421 // No images, that's easy 00422 if (is_array($conf['stdWrap.'])) { 00423 return $this->cObj->stdWrap($content, $conf['stdWrap.']); 00424 } 00425 return $content; 00426 } 00427 00428 $imgs = t3lib_div::trimExplode(',', $imgList); 00429 $imgStart = intval($this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.'])); 00430 $imgCount = count($imgs) - $imgStart; 00431 $imgMax = intval($this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.'])); 00432 if ($imgMax) { 00433 $imgCount = t3lib_div::intInRange($imgCount, 0, $conf['imgMax']); // reduce the number of images. 00434 } 00435 00436 $imgPath = $this->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']); 00437 00438 // Global caption 00439 $caption = ''; 00440 if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) { 00441 $caption = $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); 00442 } 00443 00444 // Positioning 00445 $position = $this->cObj->stdWrap($conf['textPos'], $conf['textPos.']); 00446 00447 $imagePosition = $position&7; // 0,1,2 = center,right,left 00448 $contentPosition = $position&24; // 0,8,16,24 (above,below,intext,intext-wrap) 00449 $align = $this->cObj->align[$imagePosition]; 00450 $textMargin = intval($this->cObj->stdWrap($conf['textMargin'],$conf['textMargin.'])); 00451 if (!$conf['textMargin_outOfText'] && $contentPosition < 16) { 00452 $textMargin = 0; 00453 } 00454 00455 $colspacing = intval($this->cObj->stdWrap($conf['colSpace'], $conf['colSpace.'])); 00456 $rowspacing = intval($this->cObj->stdWrap($conf['rowSpace'], $conf['rowSpace.'])); 00457 00458 $border = intval($this->cObj->stdWrap($conf['border'], $conf['border.'])) ? 1:0; 00459 $borderColor = $this->cObj->stdWrap($conf['borderCol'], $conf['borderCol.']); 00460 $borderThickness = intval($this->cObj->stdWrap($conf['borderThick'], $conf['borderThick.'])); 00461 00462 $borderColor = $borderColor?$borderColor:'black'; 00463 $borderThickness = $borderThickness?$borderThickness:1; 00464 $borderSpace = (($conf['borderSpace']&&$border) ? intval($conf['borderSpace']) : 0); 00465 00466 // Generate cols 00467 $cols = intval($this->cObj->stdWrap($conf['cols'],$conf['cols.'])); 00468 $colCount = ($cols > 1) ? $cols : 1; 00469 if ($colCount > $imgCount) {$colCount = $imgCount;} 00470 $rowCount = ceil($imgCount / $colCount); 00471 00472 // Generate rows 00473 $rows = intval($this->cObj->stdWrap($conf['rows'],$conf['rows.'])); 00474 if ($rows>1) { 00475 $rowCount = $rows; 00476 if ($rowCount > $imgCount) {$rowCount = $imgCount;} 00477 $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount; 00478 } 00479 00480 // Max Width 00481 $maxW = intval($this->cObj->stdWrap($conf['maxW'], $conf['maxW.'])); 00482 00483 if ($contentPosition>=16) { // in Text 00484 $maxWInText = intval($this->cObj->stdWrap($conf['maxWInText'],$conf['maxWInText.'])); 00485 if (!$maxWInText) { 00486 // If maxWInText is not set, it's calculated to the 50% of the max 00487 $maxW = round($maxW/100*50); 00488 } else { 00489 $maxW = $maxWInText; 00490 } 00491 } 00492 00493 // All columns have the same width: 00494 $defaultColumnWidth = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*($borderThickness+$borderSpace)*2)/$colCount); 00495 00496 // Specify the maximum width for each column 00497 $columnWidths = array(); 00498 $colRelations = trim($this->cObj->stdWrap($conf['colRelations'],$conf['colRelations.'])); 00499 if (!$colRelations) { 00500 // Default 1:1-proportion, all columns same width 00501 for ($a=0;$a<$colCount;$a++) { 00502 $columnWidths[$a] = $defaultColumnWidth; 00503 } 00504 } else { 00505 // We need another proportion 00506 $rel_parts = explode(':',$colRelations); 00507 $rel_total = 0; 00508 for ($a=0;$a<$colCount;$a++) { 00509 $rel_parts[$a] = intval($rel_parts[$a]); 00510 $rel_total+= $rel_parts[$a]; 00511 } 00512 if ($rel_total) { 00513 for ($a=0;$a<$colCount;$a++) { 00514 $columnWidths[$a] = round(($defaultColumnWidth*$colCount)/$rel_total*$rel_parts[$a]); 00515 } 00516 if (min($columnWidths)<=0 || max($rel_parts)/min($rel_parts)>10) { 00517 // The difference in size between the largest and smalles must be within a factor of ten. 00518 for ($a=0;$a<$colCount;$a++) { 00519 $columnWidths[$a] = $defaultColumnWidth; 00520 } 00521 } 00522 } 00523 } 00524 $image_compression = intval($this->cObj->stdWrap($conf['image_compression'],$conf['image_compression.'])); 00525 $image_effects = intval($this->cObj->stdWrap($conf['image_effects'],$conf['image_effects.'])); 00526 $image_frames = intval($this->cObj->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.'])); 00527 00528 // EqualHeight 00529 $equalHeight = intval($this->cObj->stdWrap($conf['equalH'],$conf['equalH.'])); 00530 if ($equalHeight) { 00531 // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's 00532 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 00533 $gifCreator->init(); 00534 $relations_cols = Array(); 00535 for ($a=0; $a<$imgCount; $a++) { 00536 $imgKey = $a+$imgStart; 00537 $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]); 00538 $rel = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height 00539 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. 00540 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$rel; // counts the total width of the row with the new height taken into consideration. 00541 } 00542 } 00543 } 00544 00545 // Fetches pictures 00546 $splitArr = array(); 00547 $splitArr['imgObjNum'] = $conf['imgObjNum']; 00548 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount); 00549 00550 $imageRowsFinalWidths = Array(); // contains the width of every image row 00551 $imgsTag = array(); 00552 $origImages = array(); 00553 for ($a=0; $a<$imgCount; $a++) { 00554 $imgKey = $a+$imgStart; 00555 $totalImagePath = $imgPath.$imgs[$imgKey]; 00556 00557 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a; 00558 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a; 00559 $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $totalImagePath; 00560 00561 $this->cObj->data[$this->cObj->currentValKey] = $totalImagePath; 00562 $imgObjNum = intval($splitArr[$a]['imgObjNum']); 00563 $imgConf = $conf[$imgObjNum.'.']; 00564 00565 if ($equalHeight) { 00566 $scale = 1; 00567 $totalMaxW = $defaultColumnWidth*$colCount; 00568 $rowTotalMaxW = $relations_cols[floor($a/$colCount)]; 00569 if ($rowTotalMaxW > $totalMaxW) { 00570 $scale = $rowTotalMaxW / $totalMaxW; 00571 } 00572 00573 // transfer info to the imageObject. Please note, that 00574 $imgConf['file.']['height'] = round($equalHeight/$scale); 00575 00576 // other stuff will be calculated accordingly: 00577 unset($imgConf['file.']['width']); 00578 unset($imgConf['file.']['maxW']); 00579 unset($imgConf['file.']['maxH']); 00580 unset($imgConf['file.']['minW']); 00581 unset($imgConf['file.']['minH']); 00582 unset($imgConf['file.']['width.']); 00583 unset($imgConf['file.']['maxW.']); 00584 unset($imgConf['file.']['maxH.']); 00585 unset($imgConf['file.']['minW.']); 00586 unset($imgConf['file.']['minH.']); 00587 } else { 00588 $imgConf['file.']['maxW'] = $columnWidths[($a%$colCount)]; 00589 } 00590 00591 $titleInLink = $this->cObj->stdWrap($imgConf['titleInLink'], $imgConf['titleInLink.']); 00592 $titleInLinkAndImg = $this->cObj->stdWrap($imgConf['titleInLinkAndImg'], $imgConf['titleInLinkAndImg.']); 00593 $oldATagParms = $GLOBALS['TSFE']->ATagParams; 00594 if ($titleInLink) { 00595 // Title in A-tag instead of IMG-tag 00596 $titleText = trim($this->cObj->stdWrap($imgConf['titleText'], $imgConf['titleText.'])); 00597 if ($titleText) { 00598 // This will be used by the IMAGE call later: 00599 $GLOBALS['TSFE']->ATagParams .= ' title="'. $titleText .'"'; 00600 } 00601 } 00602 00603 if ($imgConf || $imgConf['file']) { 00604 if ($this->cObj->image_effects[$image_effects]) { 00605 $imgConf['file.']['params'] .= ' '.$this->cObj->image_effects[$image_effects]; 00606 } 00607 if ($image_frames) { 00608 if (is_array($conf['image_frames.'][$image_frames.'.'])) { 00609 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.']; 00610 } 00611 } 00612 if ($image_compression && $imgConf['file'] != 'GIFBUILDER') { 00613 if ($image_compression == 1) { 00614 $tempImport = $imgConf['file.']['import']; 00615 $tempImport_dot = $imgConf['file.']['import.']; 00616 unset($imgConf['file.']); 00617 $imgConf['file.']['import'] = $tempImport; 00618 $imgConf['file.']['import.'] = $tempImport_dot; 00619 } elseif (isset($this->cObj->image_compression[$image_compression])) { 00620 $imgConf['file.']['params'] .= ' '.$this->cObj->image_compression[$image_compression]['params']; 00621 $imgConf['file.']['ext'] = $this->cObj->image_compression[$image_compression]['ext']; 00622 unset($imgConf['file.']['ext.']); 00623 } 00624 } 00625 if ($titleInLink && ! $titleInLinkAndImg) { 00626 // Check if the image will be linked 00627 $link = $this->cObj->imageLinkWrap('', $totalImagePath, $imgConf['imageLinkWrap.']); 00628 if ($link) { 00629 // Title in A-tag only (set above: ATagParams), not in IMG-tag 00630 unset($imgConf['titleText']); 00631 unset($imgConf['titleText.']); 00632 $imgConf['emptyTitleHandling'] = 'removeAttr'; 00633 } 00634 } 00635 $imgsTag[$imgKey] = $this->cObj->IMAGE($imgConf); 00636 } else { 00637 $imgsTag[$imgKey] = $this->cObj->IMAGE(Array('file' => $totalImagePath)); // currentValKey !!! 00638 } 00639 // Restore our ATagParams 00640 $GLOBALS['TSFE']->ATagParams = $oldATagParms; 00641 // Store the original filepath 00642 $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo; 00643 00644 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0]; 00645 } 00646 // How much space will the image-block occupy? 00647 $imageBlockWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*($borderSpace+$borderThickness)*2; 00648 $GLOBALS['TSFE']->register['rowwidth'] = $imageBlockWidth; 00649 $GLOBALS['TSFE']->register['rowWidthPlusTextMargin'] = $imageBlockWidth + $textMargin; 00650 00651 // noRows is in fact just one ROW, with the amount of columns specified, where the images are placed in. 00652 // noCols is just one COLUMN, each images placed side by side on each row 00653 $noRows = $this->cObj->stdWrap($conf['noRows'],$conf['noRows.']); 00654 $noCols = $this->cObj->stdWrap($conf['noCols'],$conf['noCols.']); 00655 if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time. 00656 00657 $rowCount_temp = 1; 00658 $colCount_temp = $colCount; 00659 if ($noRows) { 00660 $rowCount_temp = $rowCount; 00661 $rowCount = 1; 00662 } 00663 if ($noCols) { 00664 $colCount = 1; 00665 $columnWidths = array(); 00666 } 00667 00668 // Edit icons: 00669 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->cObj->editIcons('',$conf['editIcons'],$conf['editIcons.']) : ''; 00670 00671 // If noRows, we need multiple imagecolumn wraps 00672 $imageWrapCols = 1; 00673 if ($noRows) { $imageWrapCols = $colCount; } 00674 00675 // User wants to separate the rows, but only do that if we do have rows 00676 $separateRows = $this->cObj->stdWrap($conf['separateRows'], $conf['separateRows.']); 00677 if ($noRows) { $separateRows = 0; } 00678 if ($rowCount == 1) { $separateRows = 0; } 00679 00680 // Apply optionSplit to the list of classes that we want to add to each image 00681 $addClassesImage = $conf['addClassesImage']; 00682 if ($conf['addClassesImage.']) { 00683 $addClassesImage = $this->cObj->stdWrap($addClassesImageConf, $conf['addClassesImage.']); 00684 } 00685 $addClassesImageConf = $GLOBALS['TSFE']->tmpl->splitConfArray(array('addClassesImage' => $addClassesImage), $colCount); 00686 00687 // Render the images 00688 $images = ''; 00689 for ($c = 0; $c < $imageWrapCols; $c++) { 00690 $tmpColspacing = $colspacing; 00691 if (($c==$imageWrapCols-1 && $imagePosition==2) || ($c==0 && ($imagePosition==1||$imagePosition==0))) { 00692 // Do not add spacing after column if we are first column (left) or last column (center/right) 00693 $tmpColspacing = 0; 00694 } 00695 00696 $thisImages = ''; 00697 $allRows = ''; 00698 $maxImageSpace = 0; 00699 for ($i = $c; $i<count($imgsTag); $i=$i+$imageWrapCols) { 00700 $colPos = $i%$colCount; 00701 if ($separateRows && $colPos == 0) { 00702 $thisRow = ''; 00703 } 00704 00705 // Render one image 00706 $imageSpace = $origImages[$i][0] + $border*($borderSpace+$borderThickness)*2; 00707 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $i; 00708 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $i; 00709 $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $origImages[$i]['origFile']; 00710 $GLOBALS['TSFE']->register['imagewidth'] = $origImages[$i][0]; 00711 $GLOBALS['TSFE']->register['imagespace'] = $imageSpace; 00712 $GLOBALS['TSFE']->register['imageheight'] = $origImages[$i][1]; 00713 if ($imageSpace > $maxImageSpace) { 00714 $maxImageSpace = $imageSpace; 00715 } 00716 $thisImage = ''; 00717 $thisImage .= $this->cObj->stdWrap($imgsTag[$i], $conf['imgTagStdWrap.']); 00718 00719 if ($conf['captionSplit'] || $conf['imageTextSplit']) { 00720 $thisImage .= $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); 00721 } 00722 if ($editIconsHTML) { 00723 $thisImage .= $this->cObj->stdWrap($editIconsHTML, $conf['editIconsStdWrap.']); 00724 } 00725 if ($conf['netprintApplicationLink']) { 00726 $thisImage .= $this->cObj->netprintApplication_offsiteLinkWrap($thisImage, $origImages[$i], $conf['netprintApplicationLink.']); 00727 } 00728 $thisImage = $this->cObj->stdWrap($thisImage, $conf['oneImageStdWrap.']); 00729 $classes = ''; 00730 if ($addClassesImageConf[$colPos]['addClassesImage']) { 00731 $classes = ' ' . $addClassesImageConf[$colPos]['addClassesImage']; 00732 } 00733 $thisImage = str_replace('###CLASSES###', $classes, $thisImage); 00734 00735 if ($separateRows) { 00736 $thisRow .= $thisImage; 00737 } else { 00738 $allRows .= $thisImage; 00739 } 00740 $GLOBALS['TSFE']->register['columnwidth'] = $maxImageSpace + $tmpColspacing; 00741 if ($separateRows && ($colPos == ($colCount-1) || $i+1==count($imgsTag))) { 00742 // Close this row at the end (colCount), or the last row at the final end 00743 $allRows .= $this->cObj->stdWrap($thisRow, $conf['imageRowStdWrap.']); 00744 } 00745 } 00746 if ($separateRows) { 00747 $thisImages .= $allRows; 00748 } else { 00749 $thisImages .= $this->cObj->stdWrap($allRows, $conf['noRowsStdWrap.']); 00750 } 00751 if ($noRows) { 00752 // Only needed to make columns, rather than rows: 00753 $images .= $this->cObj->stdWrap($thisImages, $conf['imageColumnStdWrap.']); 00754 } else { 00755 $images .= $thisImages; 00756 } 00757 } 00758 00759 // Add the global caption, if not split 00760 if ($caption) { 00761 $images .= $caption; 00762 } 00763 00764 // CSS-classes 00765 $captionClass = ''; 00766 $classCaptionAlign = array( 00767 'center' => 'csc-textpic-caption-c', 00768 'right' => 'csc-textpic-caption-r', 00769 'left' => 'csc-textpic-caption-l', 00770 ); 00771 $captionAlign = $this->cObj->stdWrap($conf['captionAlign'], $conf['captionAlign.']); 00772 if ($captionAlign) { 00773 $captionClass = $classCaptionAlign[$captionAlign]; 00774 } 00775 $borderClass = ''; 00776 if ($border) { 00777 $borderClass = 'csc-textpic-border'; 00778 } 00779 00780 // Multiple classes with all properties, to be styled in CSS 00781 $class = ''; 00782 $class .= ($borderClass? ' '.$borderClass:''); 00783 $class .= ($captionClass? ' '.$captionClass:''); 00784 $class .= ($equalHeight? ' csc-textpic-equalheight':''); 00785 $addClasses = $this->cObj->stdWrap($conf['addClasses'], $conf['addClasses.']); 00786 $class .= ($addClasses ? ' '.$addClasses:''); 00787 00788 // Do we need a width in our wrap around images? 00789 $imgWrapWidth = ''; 00790 if ($position == 0 || $position == 8) { 00791 // For 'center' we always need a width: without one, the margin:auto trick won't work 00792 $imgWrapWidth = $imageBlockWidth; 00793 } 00794 if ($rowCount > 1) { 00795 // For multiple rows we also need a width, so that the images will wrap 00796 $imgWrapWidth = $imageBlockWidth; 00797 } 00798 if ($caption) { 00799 // If we have a global caption, we need the width so that the caption will wrap 00800 $imgWrapWidth = $imageBlockWidth; 00801 } 00802 00803 // Wrap around the whole image block 00804 $GLOBALS['TSFE']->register['totalwidth'] = $imgWrapWidth; 00805 if ($imgWrapWidth) { 00806 $images = $this->cObj->stdWrap($images, $conf['imageStdWrap.']); 00807 } else { 00808 $images = $this->cObj->stdWrap($images, $conf['imageStdWrapNoWidth.']); 00809 } 00810 00811 $output = $this->cObj->cObjGetSingle($conf['layout'], $conf['layout.']); 00812 $output = str_replace('###TEXT###', $content, $output); 00813 $output = str_replace('###IMAGES###', $images, $output); 00814 $output = str_replace('###CLASSES###', $class, $output); 00815 00816 if ($conf['stdWrap.']) { 00817 $output = $this->cObj->stdWrap($output, $conf['stdWrap.']); 00818 } 00819 00820 return $output; 00821 } 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 /************************************ 00835 * 00836 * Helper functions 00837 * 00838 ************************************/ 00839 00847 function getTableAttributes($conf,$type) { 00848 00849 // Initializing: 00850 $tableTagParams_conf = $conf['tableParams_'.$type.'.']; 00851 00852 $conf['color.'][200] = ''; 00853 $conf['color.'][240] = 'black'; 00854 $conf['color.'][241] = 'white'; 00855 $conf['color.'][242] = '#333333'; 00856 $conf['color.'][243] = 'gray'; 00857 $conf['color.'][244] = 'silver'; 00858 00859 // Create table attributes array: 00860 $tableTagParams = array(); 00861 $tableTagParams['border'] = $this->cObj->data['table_border'] ? intval($this->cObj->data['table_border']) : $tableTagParams_conf['border']; 00862 $tableTagParams['cellspacing'] = $this->cObj->data['table_cellspacing'] ? intval($this->cObj->data['table_cellspacing']) : $tableTagParams_conf['cellspacing']; 00863 $tableTagParams['cellpadding'] = $this->cObj->data['table_cellpadding'] ? intval($this->cObj->data['table_cellpadding']) : $tableTagParams_conf['cellpadding']; 00864 $tableTagParams['bgcolor'] = isset($conf['color.'][$this->cObj->data['table_bgColor']]) ? $conf['color.'][$this->cObj->data['table_bgColor']] : $conf['color.']['default']; 00865 00866 // Return result: 00867 return $tableTagParams; 00868 } 00869 00876 function &hookRequest($functionName) { 00877 global $TYPO3_CONF_VARS; 00878 00879 // Hook: menuConfig_preProcessModMenu 00880 if ($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]) { 00881 $hookObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]); 00882 if (method_exists ($hookObj, $functionName)) { 00883 $hookObj->pObj = &$this; 00884 return $hookObj; 00885 } 00886 } 00887 } 00888 } 00889 00890 00891 00892 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php']) { 00893 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php']); 00894 } 00895 ?>