Documentation TYPO3 par Ameos

class.tx_cssstyledcontent_pi1.php

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]='&nbsp;';
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['ORIG_FILENAME'] = $totalImagePath;
00559 
00560                         $this->cObj->data[$this->cObj->currentValKey] = $totalImagePath;
00561                         $imgObjNum = intval($splitArr[$a]['imgObjNum']);
00562                         $imgConf = $conf[$imgObjNum.'.'];
00563 
00564                         if ($equalHeight)       {
00565                                 $scale = 1;
00566                                 $totalMaxW = $defaultColumnWidth*$colCount;
00567                                 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
00568                                 if ($rowTotalMaxW > $totalMaxW) {
00569                                         $scale = $rowTotalMaxW / $totalMaxW;
00570                                 }
00571 
00572                                         // transfer info to the imageObject. Please note, that
00573                                 $imgConf['file.']['height'] = round($equalHeight/$scale);
00574 
00575                                         // other stuff will be calculated accordingly:
00576                                 unset($imgConf['file.']['width']);
00577                                 unset($imgConf['file.']['maxW']);
00578                                 unset($imgConf['file.']['maxH']);
00579                                 unset($imgConf['file.']['minW']);
00580                                 unset($imgConf['file.']['minH']);
00581                                 unset($imgConf['file.']['width.']);
00582                                 unset($imgConf['file.']['maxW.']);
00583                                 unset($imgConf['file.']['maxH.']);
00584                                 unset($imgConf['file.']['minW.']);
00585                                 unset($imgConf['file.']['minH.']);
00586                         } else {
00587                                 $imgConf['file.']['maxW'] = $columnWidths[($a%$colCount)];
00588                         }
00589 
00590                         $titleInLink = $this->cObj->stdWrap($imgConf['titleInLink'], $imgConf['titleInLink.']);
00591                         $titleInLinkAndImg = $this->cObj->stdWrap($imgConf['titleInLinkAndImg'], $imgConf['titleInLinkAndImg.']);
00592                         $oldATagParms = $GLOBALS['TSFE']->ATagParams;
00593                         if ($titleInLink)       {
00594                                         // Title in A-tag instead of IMG-tag
00595                                 $titleText = trim($this->cObj->stdWrap($imgConf['titleText'], $imgConf['titleText.']));
00596                                 if ($titleText) {
00597                                                 // This will be used by the IMAGE call later:
00598                                         $GLOBALS['TSFE']->ATagParams .= ' title="'. $titleText .'"';
00599                                 }
00600                         }
00601 
00602                         if ($imgConf || $imgConf['file'])       {
00603                                 if ($this->cObj->image_effects[$image_effects]) {
00604                                         $imgConf['file.']['params'] .= ' '.$this->cObj->image_effects[$image_effects];
00605                                 }
00606                                 if ($image_frames)      {
00607                                         if (is_array($conf['image_frames.'][$image_frames.'.']))        {
00608                                                 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
00609                                         }
00610                                 }
00611                                 if ($image_compression && $imgConf['file'] != 'GIFBUILDER')     {
00612                                         if ($image_compression == 1)    {
00613                                                 $tempImport = $imgConf['file.']['import'];
00614                                                 $tempImport_dot = $imgConf['file.']['import.'];
00615                                                 unset($imgConf['file.']);
00616                                                 $imgConf['file.']['import'] = $tempImport;
00617                                                 $imgConf['file.']['import.'] = $tempImport_dot;
00618                                         } elseif (isset($this->cObj->image_compression[$image_compression])) {
00619                                                 $imgConf['file.']['params'] .= ' '.$this->cObj->image_compression[$image_compression]['params'];
00620                                                 $imgConf['file.']['ext'] = $this->cObj->image_compression[$image_compression]['ext'];
00621                                                 unset($imgConf['file.']['ext.']);
00622                                         }
00623                                 }
00624                                 if ($titleInLink && ! $titleInLinkAndImg)       {
00625                                                 // Check if the image will be linked
00626                                         $link = $this->cObj->imageLinkWrap('', $totalImagePath, $imgConf['imageLinkWrap.']);
00627                                         if ($link)      {
00628                                                         // Title in A-tag only (set above: ATagParams), not in IMG-tag
00629                                                 unset($imgConf['titleText']);
00630                                                 unset($imgConf['titleText.']);
00631                                                 $imgConf['emptyTitleHandling'] = 'removeAttr';
00632                                         }
00633                                 }
00634                                 $imgsTag[$imgKey] = $this->cObj->IMAGE($imgConf);
00635                         } else {
00636                                 $imgsTag[$imgKey] = $this->cObj->IMAGE(Array('file' => $totalImagePath));       // currentValKey !!!
00637                         }
00638                                 // Restore our ATagParams
00639                         $GLOBALS['TSFE']->ATagParams = $oldATagParms;
00640                                 // Store the original filepath
00641                         $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo;
00642 
00643                         $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
00644                 }
00645                         // How much space will the image-block occupy?
00646                 $imageBlockWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*($borderSpace+$borderThickness)*2;
00647                 $GLOBALS['TSFE']->register['rowwidth'] = $imageBlockWidth;
00648 
00649                         // noRows is in fact just one ROW, with the amount of columns specified, where the images are placed in.
00650                         // noCols is just one COLUMN, each images placed side by side on each row
00651                 $noRows = $this->cObj->stdWrap($conf['noRows'],$conf['noRows.']);
00652                 $noCols = $this->cObj->stdWrap($conf['noCols'],$conf['noCols.']);
00653                 if ($noRows) {$noCols=0;}       // noRows overrides noCols. They cannot exist at the same time.
00654 
00655                 $rowCount_temp = 1;
00656                 $colCount_temp = $colCount;
00657                 if ($noRows)    {
00658                         $rowCount_temp = $rowCount;
00659                         $rowCount = 1;
00660                 }
00661                 if ($noCols)    {
00662                         $colCount = 1;
00663                         $columnWidths = array();
00664                 }
00665 
00666                         // Edit icons:
00667                 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->cObj->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
00668 
00669                         // If noRows, we need multiple imagecolumn wraps
00670                 $imageWrapCols = 1;
00671                 if ($noRows)    { $imageWrapCols = $colCount; }
00672 
00673                         // User wants to separate the rows, but only do that if we do have rows
00674                 $separateRows = $this->cObj->stdWrap($conf['separateRows'], $conf['separateRows.']);
00675                 if ($noRows)    { $separateRows = 0; }
00676                 if ($rowCount == 1)     { $separateRows = 0; }
00677 
00678                         // Apply optionSplit to the list of classes that we want to add to each image
00679                 $addClassesImage = $conf['addClassesImage'];
00680                 if ($conf['addClassesImage.'])  {
00681                         $addClassesImage = $this->cObj->stdWrap($addClassesImageConf, $conf['addClassesImage.']);
00682                 }
00683                 $addClassesImageConf = $GLOBALS['TSFE']->tmpl->splitConfArray(array('addClassesImage' => $addClassesImage), $colCount);
00684 
00685                         // Render the images
00686                 $images = '';
00687                 for ($c = 0; $c < $imageWrapCols; $c++) {
00688                         $tmpColspacing = $colspacing;
00689                         if (($c==$imageWrapCols-1 && $imagePosition==2) || ($c==0 && $imagePosition==1)) {
00690                                 $tmpColspacing = 0;
00691                         }
00692                         $GLOBALS['TSFE']->register['columnwidth'] = $columnWidths[$c] + $tmpColspacing + $border*($borderSpace+$borderThickness)*2;
00693                         $thisImages = '';
00694                         $allRows = '';
00695                         for ($i = $c; $i<count($imgsTag); $i=$i+$imageWrapCols) {
00696                                 $colPos = $i%$colCount;
00697                                 if ($separateRows && $colPos == 0) {
00698                                         $thisRow = '';
00699                                 }
00700 
00701                                         // Render one image
00702                                 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $i;
00703                                 $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $origImages[$i]['origFile'];
00704                                 $GLOBALS['TSFE']->register['imagewidth'] = $origImages[$i][0];
00705                                 $GLOBALS['TSFE']->register['imagespace'] = $origImages[$i][0] + $border*($borderSpace+$borderThickness)*2;
00706                                 $GLOBALS['TSFE']->register['imageheight'] = $origImages[$i][1];
00707 
00708                                 $thisImage = '';
00709                                 $thisImage .= $this->cObj->stdWrap($imgsTag[$i], $conf['imgTagStdWrap.']);
00710 
00711                                 if ($conf['captionSplit'] || $conf['imageTextSplit'])   {
00712                                         $thisImage .= $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
00713                                 }
00714                                 if ($editIconsHTML)     {
00715                                         $thisImage .= $this->cObj->stdWrap($editIconsHTML, $conf['editIconsStdWrap.']);
00716                                 }
00717                                 if ($conf['netprintApplicationLink'])   {
00718                                         $thisImage .= $this->cObj->netprintApplication_offsiteLinkWrap($thisImage, $origImages[$i], $conf['netprintApplicationLink.']);
00719                                 }
00720                                 $thisImage = $this->cObj->stdWrap($thisImage, $conf['oneImageStdWrap.']);
00721                                 $classes = '';
00722                                 if ($addClassesImageConf[$colPos]['addClassesImage'])   {
00723                                         $classes = ' ' . $addClassesImageConf[$colPos]['addClassesImage'];
00724                                 }
00725                                 $thisImage = str_replace('###CLASSES###', $classes, $thisImage);
00726 
00727                                 if ($separateRows)      {
00728                                         $thisRow .= $thisImage;
00729                                 } else {
00730                                         $allRows .= $thisImage;
00731                                 }
00732                                 if ($separateRows && ($colPos == ($colCount-1) || $i+1==count($imgsTag)))       {
00733                                         // Close this row at the end (colCount), or the last row at the final end
00734                                         $allRows .= $this->cObj->stdWrap($thisRow, $conf['imageRowStdWrap.']);
00735                                 }
00736                         }
00737                         if ($separateRows)      {
00738                                 $thisImages .= $allRows;
00739                         } else {
00740                                 $thisImages .= $this->cObj->stdWrap($allRows, $conf['noRowsStdWrap.']);
00741                         }
00742                         if ($noRows)    {
00743                                         // Only needed to make columns, rather than rows:
00744                                 $images .= $this->cObj->stdWrap($thisImages, $conf['imageColumnStdWrap.']);
00745                         } else {
00746                                 $images .= $thisImages;
00747                         }
00748                 }
00749 
00750                         // Add the global caption, if not split
00751                 if ($caption)   {
00752                         $images .= $caption;
00753                 }
00754 
00755                         // CSS-classes
00756                 $captionClass = '';
00757                 $classCaptionAlign = array(
00758                         'center' => 'csc-textpic-caption-c',
00759                         'right' => 'csc-textpic-caption-r',
00760                         'left' => 'csc-textpic-caption-l',
00761                 );
00762                 $captionAlign = $this->cObj->stdWrap($conf['captionAlign'], $conf['captionAlign.']);
00763                 if ($captionAlign)      {
00764                         $captionClass = $classCaptionAlign[$captionAlign];
00765                 }
00766                 $borderClass = '';
00767                 if ($border)    {
00768                         $borderClass = 'csc-textpic-border';
00769                 }
00770 
00771                         // Multiple classes with all properties, to be styled in CSS
00772                 $class = '';
00773                 $class .= ($borderClass? ' '.$borderClass:'');
00774                 $class .= ($captionClass? ' '.$captionClass:'');
00775                 $class .= ($equalHeight? ' csc-textpic-equalheight':'');
00776                 $addClasses = $this->cObj->stdWrap($conf['addClasses'], $conf['addClasses.']);
00777                 $class .= ($addClasses ? ' '.$addClasses:'');
00778 
00779                         // Do we need a width in our wrap around images?
00780                 $imgWrapWidth = '';
00781                 if ($position == 0 || $position == 8)   {
00782                                 // For 'center' we always need a width: without one, the margin:auto trick won't work
00783                         $imgWrapWidth = $imageBlockWidth;
00784                 }
00785                 if ($rowCount > 1)      {
00786                                 // For multiple rows we also need a width, so that the images will wrap
00787                         $imgWrapWidth = $imageBlockWidth;
00788                 }
00789                 if ($caption)   {
00790                                 // If we have a global caption, we need the width so that the caption will wrap
00791                         $imgWrapWidth = $imageBlockWidth;
00792                 }
00793 
00794                         // Wrap around the whole image block
00795                 $GLOBALS['TSFE']->register['totalwidth'] = $imgWrapWidth;
00796                 if ($imgWrapWidth)      {
00797                         $images = $this->cObj->stdWrap($images, $conf['imageStdWrap.']);
00798                 } else {
00799                         $images = $this->cObj->stdWrap($images, $conf['imageStdWrapNoWidth.']);
00800                 }
00801 
00802                 $output = $this->cObj->cObjGetSingle($conf['layout'], $conf['layout.']);
00803                 $output = str_replace('###TEXT###', $content, $output);
00804                 $output = str_replace('###IMAGES###', $images, $output);
00805                 $output = str_replace('###CLASSES###', $class, $output);
00806 
00807                 if ($conf['stdWrap.'])  {
00808                         $output = $this->cObj->stdWrap($output, $conf['stdWrap.']);
00809                 }
00810 
00811                 return $output;
00812         }
00813 
00814 
00815 
00816 
00817 
00818 
00819 
00820 
00821 
00822 
00823 
00824 
00825         /************************************
00826          *
00827          * Helper functions
00828          *
00829          ************************************/
00830 
00838         function getTableAttributes($conf,$type)        {
00839 
00840                         // Initializing:
00841                 $tableTagParams_conf = $conf['tableParams_'.$type.'.'];
00842 
00843                 $conf['color.'][200] = '';
00844                 $conf['color.'][240] = 'black';
00845                 $conf['color.'][241] = 'white';
00846                 $conf['color.'][242] = '#333333';
00847                 $conf['color.'][243] = 'gray';
00848                 $conf['color.'][244] = 'silver';
00849 
00850                         // Create table attributes array:
00851                 $tableTagParams = array();
00852                 $tableTagParams['border'] =  $this->cObj->data['table_border'] ? intval($this->cObj->data['table_border']) : $tableTagParams_conf['border'];
00853                 $tableTagParams['cellspacing'] =  $this->cObj->data['table_cellspacing'] ? intval($this->cObj->data['table_cellspacing']) : $tableTagParams_conf['cellspacing'];
00854                 $tableTagParams['cellpadding'] =  $this->cObj->data['table_cellpadding'] ? intval($this->cObj->data['table_cellpadding']) : $tableTagParams_conf['cellpadding'];
00855                 $tableTagParams['bgcolor'] =  isset($conf['color.'][$this->cObj->data['table_bgColor']]) ? $conf['color.'][$this->cObj->data['table_bgColor']] : $conf['color.']['default'];
00856 
00857                         // Return result:
00858                 return $tableTagParams;
00859         }
00860 
00867         function &hookRequest($functionName)    {
00868                 global $TYPO3_CONF_VARS;
00869 
00870                         // Hook: menuConfig_preProcessModMenu
00871                 if ($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]) {
00872                         $hookObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]);
00873                         if (method_exists ($hookObj, $functionName)) {
00874                                 $hookObj->pObj = &$this;
00875                                 return $hookObj;
00876                         }
00877                 }
00878         }
00879 }
00880 
00881 
00882 
00883 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php'])    {
00884         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php']);
00885 }
00886 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6