2e605a93a6d0255f54a5a71fa18038757067dc89
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_controltable.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2012 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Rendering of tables for content positioning
30 *
31 * @see tslib_cObj::CTABLE()
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * @package TYPO3
34 * @subpackage tslib
35 */
36 class tslib_controlTable {
37 var $offX = 0; // offset, x
38 var $offY = 0; // offset, y
39
40
41 var $tm = ''; // top menu
42 var $lm = ''; // left menu
43 var $rm = ''; // right menu
44 var $bm = ''; // bottom menu
45 var $content = ''; // content
46
47
48 var $tmTDparams = 'valign="top"'; // top menu TDparams
49 var $lmTDparams = 'valign="top"'; // left menu TDparams
50 var $rmTDparams = 'valign="top"'; // right menu TDparams
51 var $bmTDparams = 'valign="top"'; // bottom menu TDparams
52 var $contentTDparams = 'valign="top"'; // content TDparams
53
54
55 var $cMl = 1; // content margin, left
56 var $cMr = 1; // content margin, right
57 var $cMt = 0; // content margin, top
58 var $cMb = 1; // content margin, bottom
59
60
61 var $contentW = 0; // Places a little gif-spacer in the bottom of the content frame
62
63
64 var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
65
66 /**
67 * Wrapping internal vars ->tm, ->lm, ->rm, ->bm and ->content in a table where each content part is stored in a cell.
68 * The two arguments to this function defines some offsets and margins to use in the arrangement of the content in the table.
69 *
70 * @param string List of offset parameters; x,y
71 * @param string List of margin parameters; left, top, right, bottom
72 * @return string The content strings wrapped in a <table> as the parameters defined
73 * @see tslib_cObj::CTABLE()
74 */
75 function start($offset, $cMargins) {
76 $offArr = t3lib_div::intExplode(',', $offset);
77 $cMargArr = t3lib_div::intExplode(',', $cMargins);
78
79 $cols = 0;
80 $rows = 0;
81
82 if ($this->lm)
83 $cols++;
84 if ($this->rm)
85 $cols++;
86 if ($cMargArr[0])
87 $cols++;
88 if ($cMargArr[2])
89 $cols++;
90 if ($cMargArr[1] || $cMargArr[3] || $this->tm || $this->bm || $this->content || $this->contentW)
91 $cols++;
92
93 if ($cMargArr[1])
94 $rows++;
95 if ($cMargArr[3])
96 $rows++;
97 if ($this->tm)
98 $rows++;
99 if ($this->bm)
100 $rows++;
101 if ($this->content)
102 $rows++;
103 if ($this->contentW)
104 $rows++;
105 if (!$rows && $cols)
106 $rows = 1; // If there are no rows in the middle but still som columns...
107
108
109 if ($rows && $cols) {
110 $res = LF . '<table ' . $this->tableParams . '>';
111 // top offset:
112 if ($offArr[1]) {
113 $xoff = $offArr[0] ? 1 : 0;
114 if ($cols + $xoff > 1) {
115 $colspan = ' colspan="' . ($cols + $xoff) . '"';
116 }
117 $res .= '<tr><td' . $colspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
118 'clear.gif" width="1" height="' . $offArr[1] . '" alt="" title="" /></td></tr>';
119 }
120 // The rows:
121 if ($rows > 1) {
122 $rowspan = ' rowspan="' . ($rows) . '"';
123 }
124 $res .= '<tr>';
125 if ($offArr[0]) {
126 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
127 'clear.gif" height="1" width="' . $offArr[0] . '" alt="" title="" /></td>';
128 }
129 if ($this->lm) {
130 $res .= '<td' . $rowspan . ' ' . $this->lmTDparams . '>' . $this->lm . '</td>';
131 }
132 if ($cMargArr[0]) {
133 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
134 'clear.gif" height="1" width="' . $cMargArr[0] . '" alt="" title="" /></td>';
135 }
136 // content...
137
138
139 $middle = array();
140 if ($this->tm) {
141 $middle[] = '<td ' . $this->tmTDparams . '>' . $this->tm . '</td>';
142 }
143 if ($cMargArr[1]) {
144 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
145 'clear.gif" width="1" height="' . $cMargArr[1] . '" alt="" title="" /></td>';
146 }
147 if ($this->content) {
148 $middle[] = '<td ' . $this->contentTDparams . '>' . $this->content . '</td>';
149 }
150 if ($cMargArr[3]) {
151 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
152 'clear.gif" width="1" height="' . $cMargArr[3] . '" alt="" title="" /></td>';
153 }
154 if ($this->bm) {
155 $middle[] = '<td ' . $this->bmTDparams . '>' . $this->bm . '</td>';
156 }
157 if ($this->contentW) {
158 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
159 'clear.gif" height="1" width="' . $this->contentW . '" alt="" title="" /></td>';
160 }
161 if (isset($middle[0])) {
162 $res .= $middle[0];
163 }
164
165 // Left of content
166 if ($cMargArr[2]) {
167 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
168 'clear.gif" height="1" width="' . $cMargArr[2] . '" alt="" title="" /></td>';
169 }
170 if ($this->rm) {
171 $res .= '<td' . $rowspan . ' ' . $this->rmTDparams . '>' . $this->rm . '</td>';
172 }
173 $res .= '</tr>';
174
175 // More than the two rows
176 $mCount = count($middle);
177 for ($a = 1; $a < $mCount; $a++) {
178 $res .= '<tr>' . $middle[$a] . '</tr>';
179 }
180 $res .= '</table>';
181 return $res;
182 }
183 }
184 }
185 ?>