[TASK] Get rid of "clear.gif" usages
[Packages/TYPO3.CMS.git] / typo3 / sysext / compatibility6 / Classes / ContentObject / TableRenderer.php
1 <?php
2 namespace TYPO3\CMS\Compatibility6\ContentObject;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Rendering of tables for content positioning
19 *
20 * @see ContentObjectRenderer::CTABLE()
21 */
22 class TableRenderer {
23
24 /**
25 * offset, x
26 *
27 * @var int
28 */
29 public $offX = 0;
30
31 /**
32 * offset, y
33 *
34 * @var int
35 */
36 public $offY = 0;
37
38 /**
39 * top menu
40 *
41 * @var string
42 */
43 public $tm = '';
44
45 /**
46 * left menu
47 *
48 * @var string
49 */
50 public $lm = '';
51
52 /**
53 * right menu
54 *
55 * @var string
56 */
57 public $rm = '';
58
59 /**
60 * bottom menu
61 *
62 * @var string
63 */
64 public $bm = '';
65
66 /**
67 * content
68 *
69 * @var string
70 */
71 public $content = '';
72
73 /**
74 * top menu TDparams
75 *
76 * @var string
77 */
78 public $tmTDparams = 'valign="top"';
79
80 /**
81 * left menu TDparams
82 *
83 * @var string
84 */
85 public $lmTDparams = 'valign="top"';
86
87 /**
88 * right menu TDparams
89 *
90 * @var string
91 */
92 public $rmTDparams = 'valign="top"';
93
94 /**
95 * bottom menu TDparams
96 *
97 * @var string
98 */
99 public $bmTDparams = 'valign="top"';
100
101 /**
102 * content TDparams
103 *
104 * @var string
105 */
106 public $contentTDparams = 'valign="top"';
107
108 /**
109 * content margin, left
110 *
111 * @var int
112 */
113 public $cMl = 1;
114
115 /**
116 * content margin, right
117 *
118 * @var int
119 */
120 public $cMr = 1;
121
122 /**
123 * content margin, top
124 *
125 * @var int
126 */
127 public $cMt = 0;
128
129 /**
130 * content margin, bottom
131 *
132 * @var int
133 */
134 public $cMb = 1;
135
136 /**
137 * Places a little gif-spacer in the bottom of the content frame
138 *
139 * @var int
140 */
141 public $contentW = 0;
142
143 /**
144 * @var string
145 */
146 public $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
147
148 /**
149 * Wrapping internal vars ->tm, ->lm, ->rm, ->bm and ->content in a table where each content part is stored in a cell.
150 * The two arguments to this function defines some offsets and margins to use in the arrangement of the content in the table.
151 *
152 * @param string $offset List of offset parameters; x,y
153 * @param string $cMargins List of margin parameters; left, top, right, bottom
154 * @return string The content strings wrapped in a <table> as the parameters defined
155 * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::CTABLE()
156 */
157 public function start($offset, $cMargins) {
158 $offArr = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $offset);
159 $cMargArr = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $cMargins);
160 $cols = 0;
161 $rows = 0;
162 if ($this->lm) {
163 $cols++;
164 }
165 if ($this->rm) {
166 $cols++;
167 }
168 if ($cMargArr[0]) {
169 $cols++;
170 }
171 if ($cMargArr[2]) {
172 $cols++;
173 }
174 if ($cMargArr[1] || $cMargArr[3] || $this->tm || $this->bm || $this->content || $this->contentW) {
175 $cols++;
176 }
177 if ($cMargArr[1]) {
178 $rows++;
179 }
180 if ($cMargArr[3]) {
181 $rows++;
182 }
183 if ($this->tm) {
184 $rows++;
185 }
186 if ($this->bm) {
187 $rows++;
188 }
189 if ($this->content) {
190 $rows++;
191 }
192 if ($this->contentW) {
193 $rows++;
194 }
195 if (!$rows && $cols) {
196 // If there are no rows in the middle but still som columns...
197 $rows = 1;
198 }
199 if ($rows && $cols) {
200 $res = LF . '<table ' . $this->tableParams . '>';
201 // Top offset:
202 if ($offArr[1]) {
203 $xoff = $offArr[0] ? 1 : 0;
204 if ($cols + $xoff > 1) {
205 $colspan = ' colspan="' . ($cols + $xoff) . '"';
206 }
207 $res .= '<tr><td' . $colspan . '><span style="width: 1px; height: ' . $offArr[1] . 'px;"></span></td></tr>';
208 }
209 // The rows:
210 if ($rows > 1) {
211 $rowspan = ' rowspan="' . $rows . '"';
212 }
213 $res .= '<tr>';
214 if ($offArr[0]) {
215 $res .= '<td' . $rowspan . '><span style="width: ' . $offArr[0] . 'px; height: 1px;"></span></td>';
216 }
217 if ($this->lm) {
218 $res .= '<td' . $rowspan . ' ' . $this->lmTDparams . '>' . $this->lm . '</td>';
219 }
220 if ($cMargArr[0]) {
221 $res .= '<td' . $rowspan . '><span style="width: ' . $cMargArr[0] . 'px; height: 1px;"></span></td>';
222 }
223 // Content...
224 $middle = array();
225 if ($this->tm) {
226 $middle[] = '<td ' . $this->tmTDparams . '>' . $this->tm . '</td>';
227 }
228 if ($cMargArr[1]) {
229 $middle[] = '<td><span style="width: 1px; height: ' . $cMargArr[1] . 'px;"></span></td>';
230 }
231 if ($this->content) {
232 $middle[] = '<td ' . $this->contentTDparams . '>' . $this->content . '</td>';
233 }
234 if ($cMargArr[3]) {
235 $middle[] = '<td><span style="width: 1px; height: ' . $cMargArr[3] . 'px;"></span></td>';
236 }
237 if ($this->bm) {
238 $middle[] = '<td ' . $this->bmTDparams . '>' . $this->bm . '</td>';
239 }
240 if ($this->contentW) {
241 $middle[] = '<td><span style="width: ' . $this->contentW . 'px; height: 1px;"></span></td>';
242 }
243 if (isset($middle[0])) {
244 $res .= $middle[0];
245 }
246 // Left of content
247 if ($cMargArr[2]) {
248 $res .= '<td' . $rowspan . '><span style="width: ' . $cMargArr[2] . 'px; height: 1px;"></span></td>';
249 }
250 if ($this->rm) {
251 $res .= '<td' . $rowspan . ' ' . $this->rmTDparams . '>' . $this->rm . '</td>';
252 }
253 $res .= '</tr>';
254 // More than the two rows
255 $mCount = count($middle);
256 for ($a = 1; $a < $mCount; $a++) {
257 $res .= '<tr>' . $middle[$a] . '</tr>';
258 }
259 $res .= '</table>';
260 return $res;
261 }
262 }
263
264 }