[TASK] Remove superfluous parenthesis in sysext frontend
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / OffsetTableContentObject.php
1 <?php
2 namespace TYPO3\CMS\Frontend\ContentObject;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2012 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Rendering of tables for offset
31 *
32 * @see tslib_cObj::OTABLE(), tslib_cObj::stdWrap()
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @package TYPO3
35 * @subpackage tslib
36 */
37 class OffsetTableContentObject {
38
39 /**
40 * @todo Define visibility
41 */
42 public $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
43
44 /**
45 * @todo Define visibility
46 */
47 public $default_tableParams = 'border="0" cellspacing="0" cellpadding="0"';
48
49 /**
50 * @todo Define visibility
51 */
52 public $tdParams = ' width="99%" valign="top"';
53
54 /**
55 * Wrapping the input content string in a table which will space it out from top/left/right/bottom
56 *
57 * @param string $content The HTML content string
58 * @param string $offset List of offset parameters; x,y,r,b,w,h
59 * @return string The HTML content string being wrapped in a <table> offsetting the content as the $offset parameters defined
60 * @todo Define visibility
61 */
62 public function start($content, $offset) {
63 $valPairs = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $offset . ',,,,,');
64 if ($valPairs[0] || $valPairs[1] || $valPairs[2] || $valPairs[3] || $valPairs[4] || $valPairs[5]) {
65 // If width is defined AND there has been no change to the default table params,
66 // then extend them to a tablewidth of 1
67 if ($valPairs[4] && $this->default_tableParams == $this->tableParams) {
68 $this->tableParams .= ' width="1"';
69 }
70 // Init:
71 $this->begin = LF . '<table ' . $this->tableParams . '>';
72 $this->end = '</table>';
73 $rows = array();
74 $widthImg = '';
75 $heightImg = '';
76 // If width is required, set so bottom column will display for sure
77 if ($valPairs[4]) {
78 if (!$valPairs[3]) {
79 $valPairs[3] = 1;
80 }
81 $widthImg = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $valPairs[4] . '" height="1" alt="" title="" />';
82 }
83 // If height is required, set so right column will display for sure
84 if ($valPairs[5]) {
85 if (!$valPairs[2]) {
86 $valPairs[2] = 1;
87 }
88 $valPairs[2] = 1;
89 $heightImg = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $valPairs[5] . '" alt="" title="" />';
90 }
91 // First row:
92 // top
93 if ($valPairs[1]) {
94 $rows[1] .= '<tr>';
95 $rows[1] .= '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . ($valPairs[0] ? $valPairs[0] : 1) . '" height="' . $valPairs[1] . '" alt="" title="" /></td>';
96 if ($valPairs[0]) {
97 $rows[1] .= '<td></td>';
98 }
99 if ($valPairs[2]) {
100 $rows[1] .= '<td></td>';
101 }
102 $rows[1] .= '</tr>';
103 }
104 // Middle row:
105 $rows[2] .= '<tr>';
106 if ($valPairs[0]) {
107 $rows[2] .= $valPairs[1] ? '<td></td>' : '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $valPairs[0] . '" height="1" alt="" title="" /></td>';
108 }
109 $rows[2] .= '<td' . $this->tdParams . '>' . $content . '</td>';
110 if ($valPairs[2]) {
111 $rows[2] .= $valPairs[3] ? '<td>' . $heightImg . '</td>' : '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $valPairs[2] . '" height="' . ($valPairs[5] ? $valPairs[5] : 1) . '" alt="" title="" /></td>';
112 }
113 $rows[2] .= '</tr>';
114 // Bottom row:
115 if ($valPairs[3]) {
116 $rows[3] .= '<tr>';
117 if ($valPairs[0]) {
118 $rows[3] .= '<td></td>';
119 }
120 if ($valPairs[2]) {
121 $rows[3] .= '<td>' . $widthImg . '</td>';
122 }
123 $rows[3] .= '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . ($valPairs[2] ? $valPairs[2] : ($valPairs[4] ? $valPairs[4] : 1)) . '" height="' . $valPairs[3] . '" alt="" title="" /></td>';
124 $rows[3] .= '</tr>';
125 }
126 return $this->begin . implode('', $rows) . $this->end;
127 } else {
128 return $content;
129 }
130 }
131
132 }
133
134
135 ?>