TYPO3 API  SVNRelease
class.tslib_content_columns.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch>
00006  *  (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
00007  *  All rights reserved
00008  *
00009  *  This script is part of the TYPO3 project. The TYPO3 project is
00010  *  free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  The GNU General Public License can be found at
00016  *  http://www.gnu.org/copyleft/gpl.html.
00017  *  A copy is found in the textfile GPL.txt and important notices to the license
00018  *  from the author is found in LICENSE.txt distributed with these scripts.
00019  *
00020  *
00021  *  This script is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  This copyright notice MUST APPEAR in all copies of the script!
00027  ***************************************************************/
00028 
00029 /**
00030  * Contains COLUMNS class object.
00031  *
00032  * $Id: class.tslib_content.php 7905 2010-06-13 14:42:33Z ohader $
00033  * @author Xavier Perseguers <typo3@perseguers.ch>
00034  * @author Steffen Kamper <steffen@typo3.org>
00035  */
00036 class tslib_content_Columns extends tslib_content_Abstract {
00037 
00038     /**
00039      * Rendering the cObject, COLUMNS
00040      *
00041      * @param   array       Array of TypoScript properties
00042      * @return  string      Output
00043      */
00044     public function render($conf = array()) {
00045         $content = '';
00046         if (is_array($conf) && $this->cObj->checkIf($conf['if.'])) {
00047             $tdRowCount = 0;
00048             $tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
00049             $tableParams = $tableParams ? ' ' . $tableParams : ' border="0" cellspacing="0" cellpadding="0"';
00050             $TDParams = isset($conf['TDParams.']) ? $this->cObj->stdWrap($conf['TDParams'], $conf['TDParams.']) : $conf['TDParams'];
00051             $TDparams = $TDparams ? ' ' . $TDparams : ' valign="top"';
00052             $rows = isset($conf['rows.']) ? $this->cObj->stdWrap($conf['rows'], $conf['rows.']) : $conf['rows'];
00053             $rows = t3lib_div::intInRange($rows, 2, 20);
00054             $totalWidth = isset($conf['totalWidth.']) ? intval($this->cObj->stdWrap($conf['totalWidth'], $conf['totalWidth.'])) : intval($conf['totalWidth']);
00055             $columnWidth = 0;
00056 
00057             $totalGapWidth = 0;
00058             $gapData = array(
00059                 'gapWidth' => isset($conf['gapWidth.']) ? $this->cObj->stdWrap($conf['gapWidth'], $conf['gapWidth.']) : $conf['gapWidth'],
00060                 'gapBgCol' => isset($conf['gapBgCol.']) ? $this->cObj->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']) : $conf['gapBgCol'],
00061                 'gapLineThickness' => isset($conf['gapLineThickness.']) ? $this->cObj->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']) : $conf['gapLineThickness'],
00062                 'gapLineCol' => isset($conf['gapLineCol.']) ? $this->cObj->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']) : $conf['gapLineCol'],
00063             );
00064             $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
00065             foreach ($gapData as $val) {
00066                 $totalGapWidth += intval($val['gapWidth']);
00067             }
00068 
00069             if ($totalWidth) {
00070                 $columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
00071                 $TDparams .= ' width="' . $columnWidth . '"';
00072                 $tableParams .= ' width="' . $totalWidth . '"';
00073             } else {
00074                 $TDparams .= ' width="' . floor(100 / $rows) . '%"';
00075                 $tableParams .= ' width="100%"';
00076             }
00077 
00078             for ($a = 1; $a <= $rows; $a++) {
00079                 $tdRowCount++;
00080                 $content .= '<td' . $TDparams . '>';
00081                 $content .= $this->cObj->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
00082                 $content .= '</td>';
00083                 if ($a < $rows) {
00084                     $gapConf = $gapData[($a - 1)];
00085                     $gapWidth = intval($gapConf['gapWidth']);
00086                     if ($gapWidth) {
00087                         $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
00088                         $gapLine = intval($gapConf['gapLineThickness']);
00089                         if ($gapLine) {
00090                             $gapSurround = t3lib_div::intInRange(($gapWidth - $gapLine) / 2, 1, 1000);
00091                             // right gap
00092                             $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
00093                                 $gapSurround . '" height="1" alt="" title="" /></td>';
00094                             $tdRowCount++;
00095                             // line:
00096                             $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
00097                             $content .= '<td' . $GtdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
00098                                 $gapLine . '" height="1" alt="" title="" /></td>';
00099                             $tdRowCount++;
00100                             // left gap
00101                             $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
00102                                 $gapSurround . '" height="1" alt="" title="" /></td>';
00103                             $tdRowCount++;
00104                         } else {
00105                             $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
00106                                 $gapWidth . '" height="1" alt="" title="" /></td>';
00107                             $tdRowCount++;
00108                         }
00109                     }
00110                 }
00111             }
00112             $content = '<tr>' . $content . '</tr>';
00113             $content = '<table' . $tableParams . '>' . $content . '</table>';
00114             if($conf['after'] || isset($conf['after.'])) {
00115                 $content .= $this->cObj->cObjGetSingle($conf['after'], $conf['after.'], 'after');
00116             }
00117             if (isset($conf['stdWrap.'])) {
00118                 $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
00119             }
00120         }
00121         return $content;
00122     }
00123 
00124 }
00125 
00126 
00127 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_columns.php'])) {
00128     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_columns.php']);
00129 }
00130 
00131 ?>