[TASK] Clean up phpDoc comments in typo3/sysext/
[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 // offset, x
38 var $offX = 0;
39 // offset, y
40 var $offY = 0;
41 // top menu
42 var $tm = '';
43 // left menu
44 var $lm = '';
45 // right menu
46 var $rm = '';
47 // bottom menu
48 var $bm = '';
49 // content
50 var $content = '';
51 // top menu TDparams
52 var $tmTDparams = 'valign="top"';
53 // left menu TDparams
54 var $lmTDparams = 'valign="top"';
55 // right menu TDparams
56 var $rmTDparams = 'valign="top"';
57 // bottom menu TDparams
58 var $bmTDparams = 'valign="top"';
59 // content TDparams
60 var $contentTDparams = 'valign="top"';
61 // content margin, left
62 var $cMl = 1;
63 // content margin, right
64 var $cMr = 1;
65 // content margin, top
66 var $cMt = 0;
67 // content margin, bottom
68 var $cMb = 1;
69 // Places a little gif-spacer in the bottom of the content frame
70 var $contentW = 0;
71
72 var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
73
74 /**
75 * Wrapping internal vars ->tm, ->lm, ->rm, ->bm and ->content in a table where each content part is stored in a cell.
76 * The two arguments to this function defines some offsets and margins to use in the arrangement of the content in the table.
77 *
78 * @param string $offset List of offset parameters; x,y
79 * @param string $cMargins List of margin parameters; left, top, right, bottom
80 * @return string The content strings wrapped in a <table> as the parameters defined
81 * @see tslib_cObj::CTABLE()
82 */
83 function start($offset, $cMargins) {
84 $offArr = t3lib_div::intExplode(',', $offset);
85 $cMargArr = t3lib_div::intExplode(',', $cMargins);
86
87 $cols = 0;
88 $rows = 0;
89
90 if ($this->lm) {
91 $cols++;
92 }
93
94 if ($this->rm) {
95 $cols++;
96 }
97
98 if ($cMargArr[0]) {
99 $cols++;
100 }
101
102 if ($cMargArr[2]) {
103 $cols++;
104 }
105
106 if ($cMargArr[1] || $cMargArr[3] || $this->tm || $this->bm || $this->content || $this->contentW) {
107 $cols++;
108 }
109
110 if ($cMargArr[1]) {
111 $rows++;
112 }
113
114 if ($cMargArr[3]) {
115 $rows++;
116 }
117
118 if ($this->tm) {
119 $rows++;
120 }
121
122 if ($this->bm) {
123 $rows++;
124 }
125
126 if ($this->content) {
127 $rows++;
128 }
129
130 if ($this->contentW) {
131 $rows++;
132 }
133
134 if (!$rows && $cols) {
135 // If there are no rows in the middle but still som columns...
136 $rows = 1;
137 }
138
139 if ($rows && $cols) {
140 $res = LF . '<table ' . $this->tableParams . '>';
141 // Top offset:
142 if ($offArr[1]) {
143 $xoff = $offArr[0] ? 1 : 0;
144 if ($cols + $xoff > 1) {
145 $colspan = ' colspan="' . ($cols + $xoff) . '"';
146 }
147 $res .= '<tr><td' . $colspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
148 'clear.gif" width="1" height="' . $offArr[1] . '" alt="" title="" /></td></tr>';
149 }
150 // The rows:
151 if ($rows > 1) {
152 $rowspan = ' rowspan="' . ($rows) . '"';
153 }
154 $res .= '<tr>';
155 if ($offArr[0]) {
156 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
157 'clear.gif" height="1" width="' . $offArr[0] . '" alt="" title="" /></td>';
158 }
159 if ($this->lm) {
160 $res .= '<td' . $rowspan . ' ' . $this->lmTDparams . '>' . $this->lm . '</td>';
161 }
162 if ($cMargArr[0]) {
163 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
164 'clear.gif" height="1" width="' . $cMargArr[0] . '" alt="" title="" /></td>';
165 }
166 // Content...
167 $middle = array();
168 if ($this->tm) {
169 $middle[] = '<td ' . $this->tmTDparams . '>' . $this->tm . '</td>';
170 }
171 if ($cMargArr[1]) {
172 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
173 'clear.gif" width="1" height="' . $cMargArr[1] . '" alt="" title="" /></td>';
174 }
175 if ($this->content) {
176 $middle[] = '<td ' . $this->contentTDparams . '>' . $this->content . '</td>';
177 }
178 if ($cMargArr[3]) {
179 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
180 'clear.gif" width="1" height="' . $cMargArr[3] . '" alt="" title="" /></td>';
181 }
182 if ($this->bm) {
183 $middle[] = '<td ' . $this->bmTDparams . '>' . $this->bm . '</td>';
184 }
185 if ($this->contentW) {
186 $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix .
187 'clear.gif" height="1" width="' . $this->contentW . '" alt="" title="" /></td>';
188 }
189 if (isset($middle[0])) {
190 $res .= $middle[0];
191 }
192
193 // Left of content
194 if ($cMargArr[2]) {
195 $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix .
196 'clear.gif" height="1" width="' . $cMargArr[2] . '" alt="" title="" /></td>';
197 }
198 if ($this->rm) {
199 $res .= '<td' . $rowspan . ' ' . $this->rmTDparams . '>' . $this->rm . '</td>';
200 }
201 $res .= '</tr>';
202
203 // More than the two rows
204 $mCount = count($middle);
205 for ($a = 1; $a < $mCount; $a++) {
206 $res .= '<tr>' . $middle[$a] . '</tr>';
207 }
208 $res .= '</table>';
209 return $res;
210 }
211 }
212 }
213 ?>