2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Plugin 'Content rendering' for the 'css_styled_content' extension.
32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 * [CLASS/FUNCTION INDEX of SCRIPT]
39 * 68: class tx_cssstyledcontent_pi1 extends tslib_pibase
41 * SECTION: Rendering of Content Elements:
42 * 96: function render_bullets($content,$conf)
43 * 141: function render_table($content,$conf)
44 * 283: function render_uploads($content,$conf)
45 * 395: function render_textpic($content, $conf)
47 * SECTION: Helper functions
48 * 832: function getTableAttributes($conf,$type)
49 * 861: function &hookRequest($functionName)
52 * (This index is automatically created/updated by the extension "extdeveval")
56 require_once(PATH_tslib
.'class.tslib_pibase.php');
61 * Plugin class - instantiated from TypoScript.
62 * Rendering some content elements from tt_content table.
64 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
66 * @subpackage tx_cssstyledcontent
68 class tx_cssstyledcontent_pi1
extends tslib_pibase
{
70 // Default plugin variables:
71 var $prefixId = 'tx_cssstyledcontent_pi1'; // Same as class name
72 var $scriptRelPath = 'pi1/class.tx_cssstyledcontent_pi1.php'; // Path to this script relative to the extension dir.
73 var $extKey = 'css_styled_content'; // The extension key.
82 /***********************************
84 * Rendering of Content Elements:
86 ***********************************/
89 * Rendering the "Bulletlist" type content element, called from TypoScript (tt_content.bullets.20)
91 * @param string Content input. Not used, ignore.
92 * @param array TypoScript configuration
93 * @return string HTML output.
96 function render_bullets($content,$conf) {
98 // Look for hook before running default code for function
99 if ($hookObj = &$this->hookRequest('render_bullets')) {
100 return $hookObj->render_bullets($content,$conf);
103 // Get bodytext field content, returning blank if empty:
104 $content = trim($this->cObj
->data
['bodytext']);
105 if (!strcmp($content,'')) return '';
107 // Split into single lines:
108 $lines = t3lib_div
::trimExplode(chr(10),$content);
109 while(list($k)=each($lines)) {
111 <li>'.$this->cObj
->stdWrap($lines[$k],$conf['innerStdWrap.']).'</li>';
115 $type = intval($this->cObj
->data
['layout']);
119 <ul class="csc-bulletlist csc-bulletlist-'.$type.'">'.
124 if ($conf['stdWrap.']) {
125 $out = $this->cObj
->stdWrap($out, $conf['stdWrap.']);
134 * Rendering the "Table" type content element, called from TypoScript (tt_content.table.20)
136 * @param string Content input. Not used, ignore.
137 * @param array TypoScript configuration
138 * @return string HTML output.
141 function render_table($content,$conf) {
143 // Look for hook before running default code for function
144 if ($hookObj = &$this->hookRequest('render_table')) {
145 return $hookObj->render_table($content,$conf);
147 // Init FlexForm configuration
148 $this->pi_initPIflexForm();
150 // Get bodytext field content
151 $content = trim($this->cObj
->data
['bodytext']);
152 if (!strcmp($content,'')) return '';
154 // get flexform values
155 $caption = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_caption')));
156 $summary = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_summary')));
157 $useTfoot = trim($this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_tfoot'));
158 $headerPos = $this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_headerpos');
159 $noStyles = $this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_nostyles');
160 $tableClass = $this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'acctables_tableclass');
162 $delimiter = trim($this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'tableparsing_delimiter','s_parsing'));
164 $delimiter = chr(intval($delimiter));
168 $quotedInput = trim($this->pi_getFFvalue($this->cObj
->data
['pi_flexform'], 'tableparsing_quote','s_parsing'));
170 $quotedInput = chr(intval($quotedInput));
175 // generate id prefix for accessible header
176 $headerScope = ($headerPos=='top'?
'col':'row');
177 $headerIdPrefix = $headerScope.$this->cObj
->data
['uid'].'-';
179 // Split into single lines (will become table-rows):
180 $rows = t3lib_div
::trimExplode(chr(10),$content);
182 // Find number of columns to render:
183 $cols = t3lib_div
::intInRange($this->cObj
->data
['cols']?
$this->cObj
->data
['cols']:count(explode($delimiter,current($rows))),0,100);
185 // Traverse rows (rendering the table here)
186 $rCount = count($rows);
187 foreach($rows as $k => $v) {
188 $cells = explode($delimiter,$v);
190 for($a=0;$a<$cols;$a++
) {
191 // remove quotes if needed
192 if ($quotedInput && substr($cells[$a],0,1) == $quotedInput && substr($cells[$a],-1,1) == $quotedInput) {
193 $cells[$a] = substr($cells[$a],1,-1);
196 if (!strcmp(trim($cells[$a]),'')) $cells[$a]=' ';
197 $cellAttribs = ($noStyles?
'':($a>0 && ($cols-1)==$a) ?
' class="td-last td-'.$a.'"' : ' class="td-'.$a.'"');
198 if (($headerPos == 'top' && !$k) ||
($headerPos == 'left' && !$a)) {
199 $scope = ' scope="'.$headerScope.'"';
200 $scope .= ' id="'.$headerIdPrefix.(($headerScope=='col')?
$a:$k).'"';
203 <th'.$cellAttribs.$scope.'>'.$this->cObj
->stdWrap($cells[$a],$conf['innerStdWrap.']).'</th>';
205 if (empty($headerPos)) {
206 $accessibleHeader = '';
208 $accessibleHeader = ' headers="'.$headerIdPrefix.(($headerScope=='col')?
$a:$k).'"';
211 <td'.$cellAttribs.$accessibleHeader.'>'.$this->cObj
->stdWrap($cells[$a],$conf['innerStdWrap.']).'</td>';
215 $oddEven = $k%2 ?
'tr-odd' : 'tr-even';
216 $rowAttribs = ($k>0 && ($rCount-1)==$k) ?
' class="'.$oddEven.' tr-last"' : ' class="'.$oddEven.' tr-'.$k.'"';
219 <tr'.$rowAttribs.'>'.implode('',$newCells).'
227 <caption>'.$caption.'</caption>';
229 if ($headerPos == 'top' && $rows[0]) {
230 $tableContents .= '<thead>'. $rows[0] .'
237 <tfoot>'.$rows[$rCount-1].'</tfoot>';
238 unset($rows[$rCount-1]);
241 $tmpTable = implode('',$rows);
243 $tmpTable = '<tbody>'.$tmpTable.'</tbody>';
245 $tableContents .= $tmpTable;
248 $type = intval($this->cObj
->data
['layout']);
251 $tableTagParams = $this->getTableAttributes($conf,$type);
253 $tableTagParams['class'] = 'contenttable contenttable-'.$type.($tableClass?
' '.$tableClass:'');
254 } elseif ($tableClass) {
255 $tableTagParams['class'] = $tableClass;
259 // Compile table output:
261 <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.
266 if ($conf['stdWrap.']) {
267 $out = $this->cObj
->stdWrap($out, $conf['stdWrap.']);
276 * Rendering the "Filelinks" type content element, called from TypoScript (tt_content.uploads.20)
278 * @param string Content input. Not used, ignore.
279 * @param array TypoScript configuration
280 * @return string HTML output.
283 function render_uploads($content,$conf) {
285 // Look for hook before running default code for function
286 if ($hookObj = &$this->hookRequest('render_uploads')) {
287 return $hookObj->render_uploads($content,$conf);
293 $type = intval($this->cObj
->data
['layout']);
295 // Get the list of files (using stdWrap function since that is easiest)
297 $lConf['override.']['filelist.']['field'] = 'select_key';
298 $fileList = $this->cObj
->stdWrap($this->cObj
->data
['media'],$lConf);
300 // Explode into an array:
301 $fileArray = t3lib_div
::trimExplode(',',$fileList,1);
303 // If there were files to list...:
304 if (count($fileArray)) {
306 // Get the path from which the images came:
307 $selectKeyValues = explode('|',$this->cObj
->data
['select_key']);
308 $path = trim($selectKeyValues[0]) ?
trim($selectKeyValues[0]) : 'uploads/media/';
310 // Get the descriptions for the files (if any):
311 $descriptions = t3lib_div
::trimExplode(chr(10),$this->cObj
->data
['imagecaption']);
313 // Adding hardcoded TS to linkProc configuration:
314 $conf['linkProc.']['path.']['current'] = 1;
315 $conf['linkProc.']['icon'] = 1; // Always render icon - is inserted by PHP if needed.
316 $conf['linkProc.']['icon.']['wrap'] = ' | //**//'; // Temporary, internal split-token!
317 $conf['linkProc.']['icon_link'] = 1; // ALways link the icon
318 $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.
320 // Traverse the files found:
321 $filesData = array();
322 foreach($fileArray as $key => $fileName) {
323 $absPath = t3lib_div
::getFileAbsFileName($path.$fileName);
324 if (@is_file
($absPath)) {
325 $fI = pathinfo($fileName);
326 $filesData[$key] = array();
328 $filesData[$key]['filename'] = $fileName;
329 $filesData[$key]['path'] = $path;
330 $filesData[$key]['filesize'] = filesize($absPath);
331 $filesData[$key]['fileextension'] = strtolower($fI['extension']);
332 $filesData[$key]['description'] = trim($descriptions[$key]);
334 $this->cObj
->setCurrentVal($path);
335 $GLOBALS['TSFE']->register
['ICON_REL_PATH'] = $path.$fileName;
336 $filesData[$key]['linkedFilenameParts'] = explode('//**//',$this->cObj
->filelink($fileName, $conf['linkProc.']));
340 // Now, lets render the list!
342 foreach($filesData as $key => $fileD) {
344 // Setting class of table row for odd/even rows:
345 $oddEven = $key%2 ?
'tr-odd' : 'tr-even';
347 // Render row, based on the "layout" setting
349 <tr class="'.$oddEven.'">'.($type>0 ?
'
350 <td class="csc-uploads-icon">
351 '.$fileD['linkedFilenameParts'][0].'
353 <td class="csc-uploads-fileName">
354 <p>'.$fileD['linkedFilenameParts'][1].'</p>'.
355 ($fileD['description'] ?
'
356 <p class="csc-uploads-description">'.htmlspecialchars($fileD['description']).'</p>' : '').'
357 </td>'.($this->cObj
->data
['filelink_size'] ?
'
358 <td class="csc-uploads-fileSize">
359 <p>'.t3lib_div
::formatSize($fileD['filesize']).'</p>
365 $tableTagParams = $this->getTableAttributes($conf,$type);
366 $tableTagParams['class'] = 'csc-uploads csc-uploads-'.$type;
369 // Compile it all into table tags:
371 <table '.t3lib_div
::implodeAttributes($tableTagParams).'>
372 '.implode('',$tRows).'
377 if ($conf['stdWrap.']) {
378 $out = $this->cObj
->stdWrap($out, $conf['stdWrap.']);
387 * Rendering the IMGTEXT content element, called from TypoScript (tt_content.textpic.20)
389 * @param string Content input. Not used, ignore.
390 * @param array TypoScript configuration. See TSRef "IMGTEXT". This function aims to be compatible.
391 * @return string HTML output.
393 * @coauthor Ernesto Baschny <ernst@cron-it.de>
395 function render_textpic($content, $conf) {
396 // Look for hook before running default code for function
397 if (method_exists($this, 'hookRequest') && $hookObj = &$this->hookRequest('render_textpic')) {
398 return $hookObj->render_textpic($content,$conf);
401 $renderMethod = $this->cObj
->stdWrap($conf['renderMethod'], $conf['renderMethod.']);
403 // Render using the default IMGTEXT code (table-based)
404 if (!$renderMethod ||
$renderMethod == 'table') {
405 return $this->cObj
->IMGTEXT($conf);
408 // Specific configuration for the chosen rendering method
409 if (is_array($conf['rendering.'][$renderMethod . '.'])) {
410 $conf = $this->cObj
->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']);
413 // Image or Text with Image?
414 if (is_array($conf['text.'])) {
415 $content = $this->cObj
->stdWrap($this->cObj
->cObjGet($conf['text.'], 'text.'), $conf['text.']);
418 $imgList = trim($this->cObj
->stdWrap($conf['imgList'], $conf['imgList.']));
421 // No images, that's easy
422 if (is_array($conf['stdWrap.'])) {
423 return $this->cObj
->stdWrap($content, $conf['stdWrap.']);
428 $imgs = t3lib_div
::trimExplode(',', $imgList);
429 $imgStart = intval($this->cObj
->stdWrap($conf['imgStart'], $conf['imgStart.']));
430 $imgCount = count($imgs) - $imgStart;
431 $imgMax = intval($this->cObj
->stdWrap($conf['imgMax'], $conf['imgMax.']));
433 $imgCount = t3lib_div
::intInRange($imgCount, 0, $imgMax); // reduce the number of images.
436 $imgPath = $this->cObj
->stdWrap($conf['imgPath'], $conf['imgPath.']);
440 if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) {
441 $caption = $this->cObj
->stdWrap($this->cObj
->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
445 $position = $this->cObj
->stdWrap($conf['textPos'], $conf['textPos.']);
447 $imagePosition = $position&7; // 0,1,2 = center,right,left
448 $contentPosition = $position&24; // 0,8,16,24 (above,below,intext,intext-wrap)
449 $align = $this->cObj
->align
[$imagePosition];
450 $textMargin = intval($this->cObj
->stdWrap($conf['textMargin'],$conf['textMargin.']));
451 if (!$conf['textMargin_outOfText'] && $contentPosition < 16) {
455 $colspacing = intval($this->cObj
->stdWrap($conf['colSpace'], $conf['colSpace.']));
456 $rowspacing = intval($this->cObj
->stdWrap($conf['rowSpace'], $conf['rowSpace.']));
458 $border = intval($this->cObj
->stdWrap($conf['border'], $conf['border.'])) ?
1:0;
459 $borderColor = $this->cObj
->stdWrap($conf['borderCol'], $conf['borderCol.']);
460 $borderThickness = intval($this->cObj
->stdWrap($conf['borderThick'], $conf['borderThick.']));
462 $borderColor = $borderColor?
$borderColor:'black';
463 $borderThickness = $borderThickness?
$borderThickness:1;
464 $borderSpace = (($conf['borderSpace']&&$border) ?
intval($conf['borderSpace']) : 0);
467 $cols = intval($this->cObj
->stdWrap($conf['cols'],$conf['cols.']));
468 $colCount = ($cols > 1) ?
$cols : 1;
469 if ($colCount > $imgCount) {$colCount = $imgCount;}
470 $rowCount = ceil($imgCount / $colCount);
473 $rows = intval($this->cObj
->stdWrap($conf['rows'],$conf['rows.']));
476 if ($rowCount > $imgCount) {$rowCount = $imgCount;}
477 $colCount = ($rowCount>1) ?
ceil($imgCount / $rowCount) : $imgCount;
481 $maxW = intval($this->cObj
->stdWrap($conf['maxW'], $conf['maxW.']));
483 if ($contentPosition>=16) { // in Text
484 $maxWInText = intval($this->cObj
->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
486 // If maxWInText is not set, it's calculated to the 50% of the max
487 $maxW = round($maxW/100*50);
493 // All columns have the same width:
494 $defaultColumnWidth = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*($borderThickness+
$borderSpace)*2)/$colCount);
496 // Specify the maximum width for each column
497 $columnWidths = array();
498 $colRelations = trim($this->cObj
->stdWrap($conf['colRelations'],$conf['colRelations.']));
499 if (!$colRelations) {
500 // Default 1:1-proportion, all columns same width
501 for ($a=0;$a<$colCount;$a++
) {
502 $columnWidths[$a] = $defaultColumnWidth;
505 // We need another proportion
506 $rel_parts = explode(':',$colRelations);
508 for ($a=0;$a<$colCount;$a++
) {
509 $rel_parts[$a] = intval($rel_parts[$a]);
510 $rel_total+
= $rel_parts[$a];
513 for ($a=0;$a<$colCount;$a++
) {
514 $columnWidths[$a] = round(($defaultColumnWidth*$colCount)/$rel_total*$rel_parts[$a]);
516 if (min($columnWidths)<=0 ||
max($rel_parts)/min($rel_parts)>10) {
517 // The difference in size between the largest and smalles must be within a factor of ten.
518 for ($a=0;$a<$colCount;$a++
) {
519 $columnWidths[$a] = $defaultColumnWidth;
524 $image_compression = intval($this->cObj
->stdWrap($conf['image_compression'],$conf['image_compression.']));
525 $image_effects = intval($this->cObj
->stdWrap($conf['image_effects'],$conf['image_effects.']));
526 $image_frames = intval($this->cObj
->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
529 $equalHeight = intval($this->cObj
->stdWrap($conf['equalH'],$conf['equalH.']));
531 // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
532 $gifCreator = t3lib_div
::makeInstance('tslib_gifbuilder');
534 $relations_cols = Array();
535 for ($a=0; $a<$imgCount; $a++
) {
536 $imgKey = $a+
$imgStart;
537 $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
538 $rel = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
539 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.
540 $relations_cols[floor($a/$colCount)] +
= $imgInfo[0]/$rel; // counts the total width of the row with the new height taken into consideration.
547 $splitArr['imgObjNum'] = $conf['imgObjNum'];
548 $splitArr = $GLOBALS['TSFE']->tmpl
->splitConfArray($splitArr, $imgCount);
550 $imageRowsFinalWidths = Array(); // contains the width of every image row
551 $imgsTag = array(); // array index 0 will be the first shown image
552 $origImages = array();
553 for ($a=0; $a<$imgCount; $a++
) {
554 $imgKey = $a+
$imgStart;
555 $totalImagePath = $imgPath.$imgs[$imgKey];
557 $GLOBALS['TSFE']->register
['IMAGE_NUM'] = $a;
558 $GLOBALS['TSFE']->register
['IMAGE_NUM_CURRENT'] = $a;
559 $GLOBALS['TSFE']->register
['ORIG_FILENAME'] = $totalImagePath;
561 $this->cObj
->data
[$this->cObj
->currentValKey
] = $totalImagePath;
562 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
563 $imgConf = $conf[$imgObjNum.'.'];
567 $totalMaxW = $defaultColumnWidth*$colCount;
568 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
569 if ($rowTotalMaxW > $totalMaxW) {
570 $scale = $rowTotalMaxW / $totalMaxW;
573 // transfer info to the imageObject. Please note, that
574 $imgConf['file.']['height'] = round($equalHeight/$scale);
576 // other stuff will be calculated accordingly:
577 unset($imgConf['file.']['width']);
578 unset($imgConf['file.']['maxW']);
579 unset($imgConf['file.']['maxH']);
580 unset($imgConf['file.']['minW']);
581 unset($imgConf['file.']['minH']);
582 unset($imgConf['file.']['width.']);
583 unset($imgConf['file.']['maxW.']);
584 unset($imgConf['file.']['maxH.']);
585 unset($imgConf['file.']['minW.']);
586 unset($imgConf['file.']['minH.']);
588 $imgConf['file.']['maxW'] = $columnWidths[($a%
$colCount)];
591 $titleInLink = $this->cObj
->stdWrap($imgConf['titleInLink'], $imgConf['titleInLink.']);
592 $titleInLinkAndImg = $this->cObj
->stdWrap($imgConf['titleInLinkAndImg'], $imgConf['titleInLinkAndImg.']);
593 $oldATagParms = $GLOBALS['TSFE']->ATagParams
;
595 // Title in A-tag instead of IMG-tag
596 $titleText = trim($this->cObj
->stdWrap($imgConf['titleText'], $imgConf['titleText.']));
598 // This will be used by the IMAGE call later:
599 $GLOBALS['TSFE']->ATagParams
.= ' title="'. $titleText .'"';
603 if ($imgConf ||
$imgConf['file']) {
604 if ($this->cObj
->image_effects
[$image_effects]) {
605 $imgConf['file.']['params'] .= ' '.$this->cObj
->image_effects
[$image_effects];
608 if (is_array($conf['image_frames.'][$image_frames.'.'])) {
609 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
612 if ($image_compression && $imgConf['file'] != 'GIFBUILDER') {
613 if ($image_compression == 1) {
614 $tempImport = $imgConf['file.']['import'];
615 $tempImport_dot = $imgConf['file.']['import.'];
616 unset($imgConf['file.']);
617 $imgConf['file.']['import'] = $tempImport;
618 $imgConf['file.']['import.'] = $tempImport_dot;
619 } elseif (isset($this->cObj
->image_compression
[$image_compression])) {
620 $imgConf['file.']['params'] .= ' '.$this->cObj
->image_compression
[$image_compression]['params'];
621 $imgConf['file.']['ext'] = $this->cObj
->image_compression
[$image_compression]['ext'];
622 unset($imgConf['file.']['ext.']);
625 if ($titleInLink && ! $titleInLinkAndImg) {
626 // Check if the image will be linked
627 $link = $this->cObj
->imageLinkWrap('', $totalImagePath, $imgConf['imageLinkWrap.']);
629 // Title in A-tag only (set above: ATagParams), not in IMG-tag
630 unset($imgConf['titleText']);
631 unset($imgConf['titleText.']);
632 $imgConf['emptyTitleHandling'] = 'removeAttr';
635 $imgsTag[$a] = $this->cObj
->IMAGE($imgConf);
637 $imgsTag[$a] = $this->cObj
->IMAGE(Array('file' => $totalImagePath)); // currentValKey !!!
639 // Restore our ATagParams
640 $GLOBALS['TSFE']->ATagParams
= $oldATagParms;
641 // Store the original filepath
642 $origImages[$a] = $GLOBALS['TSFE']->lastImageInfo
;
644 $imageRowsFinalWidths[floor($a/$colCount)] +
= $GLOBALS['TSFE']->lastImageInfo
[0];
646 // How much space will the image-block occupy?
647 $imageBlockWidth = max($imageRowsFinalWidths)+
$colspacing*($colCount-1) +
$colCount*$border*($borderSpace+
$borderThickness)*2;
648 $GLOBALS['TSFE']->register
['rowwidth'] = $imageBlockWidth;
649 $GLOBALS['TSFE']->register
['rowWidthPlusTextMargin'] = $imageBlockWidth +
$textMargin;
651 // noRows is in fact just one ROW, with the amount of columns specified, where the images are placed in.
652 // noCols is just one COLUMN, each images placed side by side on each row
653 $noRows = $this->cObj
->stdWrap($conf['noRows'],$conf['noRows.']);
654 $noCols = $this->cObj
->stdWrap($conf['noCols'],$conf['noCols.']);
655 if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time.
658 $colCount_temp = $colCount;
660 $rowCount_temp = $rowCount;
665 $columnWidths = array();
669 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ?
$this->cObj
->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
671 // If noRows, we need multiple imagecolumn wraps
673 if ($noRows) { $imageWrapCols = $colCount; }
675 // User wants to separate the rows, but only do that if we do have rows
676 $separateRows = $this->cObj
->stdWrap($conf['separateRows'], $conf['separateRows.']);
677 if ($noRows) { $separateRows = 0; }
678 if ($rowCount == 1) { $separateRows = 0; }
680 // Apply optionSplit to the list of classes that we want to add to each image
681 $addClassesImage = $conf['addClassesImage'];
682 if ($conf['addClassesImage.']) {
683 $addClassesImage = $this->cObj
->stdWrap($addClassesImage, $conf['addClassesImage.']);
685 $addClassesImageConf = $GLOBALS['TSFE']->tmpl
->splitConfArray(array('addClassesImage' => $addClassesImage), $colCount);
689 for ($c = 0; $c < $imageWrapCols; $c++
) {
690 $tmpColspacing = $colspacing;
691 if (($c==$imageWrapCols-1 && $imagePosition==2) ||
($c==0 && ($imagePosition==1||
$imagePosition==0))) {
692 // Do not add spacing after column if we are first column (left) or last column (center/right)
699 for ($i = $c; $i<count($imgsTag); $i=$i+
$imageWrapCols) {
700 $colPos = $i%
$colCount;
701 if ($separateRows && $colPos == 0) {
706 $imageSpace = $origImages[$i][0] +
$border*($borderSpace+
$borderThickness)*2;
707 $GLOBALS['TSFE']->register
['IMAGE_NUM'] = $i;
708 $GLOBALS['TSFE']->register
['IMAGE_NUM_CURRENT'] = $i;
709 $GLOBALS['TSFE']->register
['ORIG_FILENAME'] = $origImages[$i]['origFile'];
710 $GLOBALS['TSFE']->register
['imagewidth'] = $origImages[$i][0];
711 $GLOBALS['TSFE']->register
['imagespace'] = $imageSpace;
712 $GLOBALS['TSFE']->register
['imageheight'] = $origImages[$i][1];
713 if ($imageSpace > $maxImageSpace) {
714 $maxImageSpace = $imageSpace;
717 $thisImage .= $this->cObj
->stdWrap($imgsTag[$i], $conf['imgTagStdWrap.']);
719 if ($conf['captionSplit'] ||
$conf['imageTextSplit']) {
720 $thisImage .= $this->cObj
->stdWrap($this->cObj
->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
722 if ($editIconsHTML) {
723 $thisImage .= $this->cObj
->stdWrap($editIconsHTML, $conf['editIconsStdWrap.']);
725 $thisImage = $this->cObj
->stdWrap($thisImage, $conf['oneImageStdWrap.']);
727 if ($addClassesImageConf[$colPos]['addClassesImage']) {
728 $classes = ' ' . $addClassesImageConf[$colPos]['addClassesImage'];
730 $thisImage = str_replace('###CLASSES###', $classes, $thisImage);
733 $thisRow .= $thisImage;
735 $allRows .= $thisImage;
737 $GLOBALS['TSFE']->register
['columnwidth'] = $maxImageSpace +
$tmpColspacing;
738 if ($separateRows && ($colPos == ($colCount-1) ||
$i+
1==count($imgsTag))) {
739 // Close this row at the end (colCount), or the last row at the final end
740 $allRows .= $this->cObj
->stdWrap($thisRow, $conf['imageRowStdWrap.']);
744 $thisImages .= $allRows;
746 $thisImages .= $this->cObj
->stdWrap($allRows, $conf['noRowsStdWrap.']);
749 // Only needed to make columns, rather than rows:
750 $images .= $this->cObj
->stdWrap($thisImages, $conf['imageColumnStdWrap.']);
752 $images .= $thisImages;
756 // Add the global caption, if not split
763 $classCaptionAlign = array(
764 'center' => 'csc-textpic-caption-c',
765 'right' => 'csc-textpic-caption-r',
766 'left' => 'csc-textpic-caption-l',
768 $captionAlign = $this->cObj
->stdWrap($conf['captionAlign'], $conf['captionAlign.']);
770 $captionClass = $classCaptionAlign[$captionAlign];
774 $borderClass = 'csc-textpic-border';
777 // Multiple classes with all properties, to be styled in CSS
779 $class .= ($borderClass?
' '.$borderClass:'');
780 $class .= ($captionClass?
' '.$captionClass:'');
781 $class .= ($equalHeight?
' csc-textpic-equalheight':'');
782 $addClasses = $this->cObj
->stdWrap($conf['addClasses'], $conf['addClasses.']);
783 $class .= ($addClasses ?
' '.$addClasses:'');
785 // Do we need a width in our wrap around images?
787 if ($position == 0 ||
$position == 8) {
788 // For 'center' we always need a width: without one, the margin:auto trick won't work
789 $imgWrapWidth = $imageBlockWidth;
792 // For multiple rows we also need a width, so that the images will wrap
793 $imgWrapWidth = $imageBlockWidth;
796 // If we have a global caption, we need the width so that the caption will wrap
797 $imgWrapWidth = $imageBlockWidth;
800 // Wrap around the whole image block
801 $GLOBALS['TSFE']->register
['totalwidth'] = $imgWrapWidth;
803 $images = $this->cObj
->stdWrap($images, $conf['imageStdWrap.']);
805 $images = $this->cObj
->stdWrap($images, $conf['imageStdWrapNoWidth.']);
808 $output = $this->cObj
->cObjGetSingle($conf['layout'], $conf['layout.']);
809 $output = str_replace('###TEXT###', $content, $output);
810 $output = str_replace('###IMAGES###', $images, $output);
811 $output = str_replace('###CLASSES###', $class, $output);
813 if ($conf['stdWrap.']) {
814 $output = $this->cObj
->stdWrap($output, $conf['stdWrap.']);
831 /************************************
835 ************************************/
838 * Returns table attributes for uploads / tables.
840 * @param array TypoScript configuration array
841 * @param integer The "layout" type
842 * @return array Array with attributes inside.
844 function getTableAttributes($conf,$type) {
847 $tableTagParams_conf = $conf['tableParams_'.$type.'.'];
849 $conf['color.'][200] = '';
850 $conf['color.'][240] = 'black';
851 $conf['color.'][241] = 'white';
852 $conf['color.'][242] = '#333333';
853 $conf['color.'][243] = 'gray';
854 $conf['color.'][244] = 'silver';
856 // Create table attributes array:
857 $tableTagParams = array();
858 $tableTagParams['border'] = $this->cObj
->data
['table_border'] ?
intval($this->cObj
->data
['table_border']) : $tableTagParams_conf['border'];
859 $tableTagParams['cellspacing'] = $this->cObj
->data
['table_cellspacing'] ?
intval($this->cObj
->data
['table_cellspacing']) : $tableTagParams_conf['cellspacing'];
860 $tableTagParams['cellpadding'] = $this->cObj
->data
['table_cellpadding'] ?
intval($this->cObj
->data
['table_cellpadding']) : $tableTagParams_conf['cellpadding'];
861 $tableTagParams['bgcolor'] = isset($conf['color.'][$this->cObj
->data
['table_bgColor']]) ?
$conf['color.'][$this->cObj
->data
['table_bgColor']] : $conf['color.']['default'];
864 return $tableTagParams;
868 * Returns an object reference to the hook object if any
870 * @param string Name of the function you want to call / hook key
871 * @return object Hook object, if any. Otherwise null.
873 function &hookRequest($functionName) {
874 global $TYPO3_CONF_VARS;
876 // Hook: menuConfig_preProcessModMenu
877 if ($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]) {
878 $hookObj = &t3lib_div
::getUserObj($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]);
879 if (method_exists ($hookObj, $functionName)) {
880 $hookObj->pObj
= &$this;
889 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php']) {
890 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php']);