[TASK] Remove superfluous parenthesis in sysext frontend
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / ImageTextContentObject.php
1 <?php
2 namespace TYPO3\CMS\Frontend\ContentObject;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch>
8 * (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * Contains IMAGE class object.
32 *
33 * @author Xavier Perseguers <typo3@perseguers.ch>
34 * @author Steffen Kamper <steffen@typo3.org>
35 */
36 class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject {
37
38 /**
39 * Rendering the cObject, IMAGE
40 *
41 * @param array $conf Array of TypoScript properties
42 * @return string Output
43 */
44 public function render($conf = array()) {
45 $content = '';
46 if (isset($conf['text.'])) {
47 $text = $this->cObj->cObjGet($conf['text.'], 'text.');
48 // this gets the surrounding content
49 $content .= $this->cObj->stdWrap($text, $conf['text.']);
50 }
51 $imgList = isset($conf['imgList.']) ? trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])) : trim($conf['imgList']);
52 if ($imgList) {
53 $imgs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $imgList);
54 $imgStart = isset($conf['imgStart.']) ? intval($this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.'])) : intval($conf['imgStart']);
55 $imgCount = count($imgs) - $imgStart;
56 $imgMax = isset($conf['imgMax.']) ? intval($this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.'])) : intval($conf['imgMax']);
57 if ($imgMax) {
58 // Reduces the number of images.
59 $imgCount = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($imgCount, 0, $imgMax);
60 }
61 $imgPath = isset($conf['imgPath.']) ? $this->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']) : $conf['imgPath'];
62 // initialisation
63 $caption = '';
64 $captionArray = array();
65 if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && isset($conf['caption.'])) {
66 $caption = $this->cObj->cObjGet($conf['caption.'], 'caption.');
67 // Global caption, no splitting
68 $caption = $this->cObj->stdWrap($caption, $conf['caption.']);
69 }
70 if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
71 $legacyCaptionSplit = 1;
72 $capSplit = isset($conf['captionSplit.']['token.']) ? $this->cObj->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']) : $conf['captionSplit.']['token'];
73 if (!$capSplit) {
74 $capSplit = LF;
75 }
76 $captionArray = explode($capSplit, $this->cObj->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
77 foreach ($captionArray as $ca_key => $ca_val) {
78 $captionArray[$ca_key] = isset($conf['captionSplit.']['stdWrap.']) ? $this->cObj->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']) : trim($captionArray[$ca_key]);
79 }
80 }
81 $tablecode = '';
82 $position = isset($conf['textPos.']) ? $this->cObj->stdWrap($conf['textPos'], $conf['textPos.']) : $conf['textPos'];
83 $tmppos = $position & 7;
84 $contentPosition = $position & 24;
85 $align = $this->cObj->align[$tmppos];
86 $cap = $caption ? 1 : 0;
87 $txtMarg = isset($conf['textMargin.']) ? intval($this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.'])) : intval($conf['textMargin']);
88 if (!$conf['textMargin_outOfText'] && $contentPosition < 16) {
89 $txtMarg = 0;
90 }
91 $cols = isset($conf['cols.']) ? intval($this->cObj->stdWrap($conf['cols'], $conf['cols.'])) : intval($conf['cols']);
92 $rows = isset($conf['rows.']) ? intval($this->cObj->stdWrap($conf['rows'], $conf['rows.'])) : intval($conf['rows']);
93 $colspacing = isset($conf['colSpace.']) ? intval($this->cObj->stdWrap($conf['colSpace'], $conf['colSpace.'])) : intval($conf['colSpace']);
94 $rowspacing = isset($conf['rowSpace.']) ? intval($this->cObj->stdWrap($conf['rowSpace'], $conf['rowSpace.'])) : intval($conf['rowSpace']);
95 $border = isset($conf['border.']) ? intval($this->cObj->stdWrap($conf['border'], $conf['border.'])) : intval($conf['border']);
96 $border = $border ? 1 : 0;
97 if ($border) {
98 $borderColor = isset($conf['borderCol.']) ? $this->cObj->stdWrap($conf['borderCol'], $conf['borderCol.']) : $conf['borderCol'];
99 if (!$borderColor) {
100 $borderColor = 'black';
101 }
102 $borderThickness = isset($conf['borderThick.']) ? intval($this->cObj->stdWrap($conf['borderThick'], $conf['borderThick.'])) : intval($conf['borderThick']);
103 if (!$borderThickness) {
104 $borderThickness = 'black';
105 }
106 }
107 $caption_align = isset($conf['captionAlign.']) ? $this->cObj->stdWrap($conf['captionAlign'], $conf['captionAlign.']) : $conf['captionAlign'];
108 if (!$caption_align) {
109 $caption_align = $align;
110 }
111 // Generate cols
112 $colCount = $cols > 1 ? $cols : 1;
113 if ($colCount > $imgCount) {
114 $colCount = $imgCount;
115 }
116 $rowCount = $colCount > 1 ? ceil($imgCount / $colCount) : $imgCount;
117 // Generate rows
118 if ($rows > 1) {
119 $rowCount = $rows;
120 if ($rowCount > $imgCount) {
121 $rowCount = $imgCount;
122 }
123 $colCount = $rowCount > 1 ? ceil($imgCount / $rowCount) : $imgCount;
124 }
125 // Max Width
126 $colRelations = isset($conf['colRelations.']) ? trim($this->cObj->stdWrap($conf['colRelations'], $conf['colRelations.'])) : trim($conf['colRelations']);
127 $maxW = isset($conf['maxW.']) ? intval($this->cObj->stdWrap($conf['maxW'], $conf['maxW.'])) : intval($conf['maxW']);
128 $maxWInText = isset($conf['maxWInText.']) ? intval($this->cObj->stdWrap($conf['maxWInText'], $conf['maxWInText.'])) : intval($conf['maxWInText']);
129 // If maxWInText is not set, it's calculated to the 50 % of the max...
130 if (!$maxWInText) {
131 $maxWInText = round($maxW / 2);
132 }
133 // inText
134 if ($maxWInText && $contentPosition >= 16) {
135 $maxW = $maxWInText;
136 }
137 // If there is a max width and if colCount is greater than column
138 if ($maxW && $colCount > 0) {
139 $maxW = ceil(($maxW - $colspacing * ($colCount - 1) - $colCount * $border * $borderThickness * 2) / $colCount);
140 }
141 // Create the relation between rows
142 $colMaxW = array();
143 if ($colRelations) {
144 $rel_parts = explode(':', $colRelations);
145 $rel_total = 0;
146 for ($a = 0; $a < $colCount; $a++) {
147 $rel_parts[$a] = intval($rel_parts[$a]);
148 $rel_total += $rel_parts[$a];
149 }
150 if ($rel_total) {
151 for ($a = 0; $a < $colCount; $a++) {
152 $colMaxW[$a] = round($maxW * $colCount / $rel_total * $rel_parts[$a]);
153 }
154 // The difference in size between the largest and smalles must be within a factor of ten.
155 if (min($colMaxW) <= 0 || max($rel_parts) / min($rel_parts) > 10) {
156 $colMaxW = array();
157 }
158 }
159 }
160 $image_compression = isset($conf['image_compression.']) ? intval($this->cObj->stdWrap($conf['image_compression'], $conf['image_compression.'])) : intval($conf['image_compression']);
161 $image_effects = isset($conf['image_effects.']) ? intval($this->cObj->stdWrap($conf['image_effects'], $conf['image_effects.'])) : intval($conf['image_effects']);
162 $image_frames = isset($conf['image_frames.']['key.']) ? intval($this->cObj->stdWrap($conf['image_frames.']['key'], $conf['image_frames.']['key.'])) : intval($conf['image_frames.']['key']);
163 // Fetches pictures
164 $splitArr = array();
165 $splitArr['imgObjNum'] = $conf['imgObjNum'];
166 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount);
167 // EqualHeight
168 $equalHeight = isset($conf['equalH.']) ? intval($this->cObj->stdWrap($conf['equalH'], $conf['equalH.'])) : intval($conf['equalH']);
169 // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
170 if ($equalHeight) {
171 $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_gifbuilder');
172 $gifCreator->init();
173 $relations = array();
174 $relations_cols = array();
175 $totalMaxW = $maxW * $colCount;
176 for ($a = 0; $a < $imgCount; $a++) {
177 $imgKey = $a + $imgStart;
178 $imgInfo = $gifCreator->getImageDimensions($imgPath . $imgs[$imgKey]);
179 // relationship between the original height and the wished height
180 $relations[$a] = $imgInfo[1] / $equalHeight;
181 // if relations is zero, then the addition of this value is omitted as
182 // the image is not expected to display because of some error.
183 if ($relations[$a]) {
184 // Counts the total width of the row with the new height taken into consideration.
185 $relations_cols[floor($a / $colCount)] += $imgInfo[0] / $relations[$a];
186 }
187 }
188 }
189 // Contains the width of every image row
190 $imageRowsFinalWidths = array();
191 $imageRowsMaxHeights = array();
192 $imgsTag = array();
193 $origImages = array();
194 for ($a = 0; $a < $imgCount; $a++) {
195 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
196 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
197 $imgKey = $a + $imgStart;
198 $totalImagePath = $imgPath . $imgs[$imgKey];
199 $this->cObj->data[$this->cObj->currentValKey] = $totalImagePath;
200 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
201 $imgConf = $conf[$imgObjNum . '.'];
202 if ($equalHeight) {
203 $scale = 1;
204 if ($totalMaxW) {
205 $rowTotalMaxW = $relations_cols[floor($a / $colCount)];
206 if ($rowTotalMaxW > $totalMaxW) {
207 $scale = $rowTotalMaxW / $totalMaxW;
208 }
209 }
210 // Transfer info to the imageObject. Please note, that
211 $imgConf['file.']['height'] = round($equalHeight / $scale);
212 unset($imgConf['file.']['width'], $imgConf['file.']['maxW'], $imgConf['file.']['maxH'], $imgConf['file.']['minW'], $imgConf['file.']['minH'], $imgConf['file.']['width.'], $imgConf['file.']['maxW.'], $imgConf['file.']['maxH.'], $imgConf['file.']['minW.'], $imgConf['file.']['minH.']);
213 // Setting this to zero, so that it doesn't disturb
214 $maxW = 0;
215 }
216 if ($maxW) {
217 if (count($colMaxW)) {
218 $imgConf['file.']['maxW'] = $colMaxW[$a % $colCount];
219 } else {
220 $imgConf['file.']['maxW'] = $maxW;
221 }
222 }
223 // Image Object supplied:
224 if (is_array($imgConf)) {
225 if ($this->cObj->image_effects[$image_effects]) {
226 $imgConf['file.']['params'] .= ' ' . $this->cObj->image_effects[$image_effects];
227 }
228 if ($image_frames) {
229 if (is_array($conf['image_frames.'][$image_frames . '.'])) {
230 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames . '.'];
231 }
232 }
233 if ($image_compression && $imgConf['file'] != 'GIFBUILDER') {
234 if ($image_compression == 1) {
235 $tempImport = $imgConf['file.']['import'];
236 $tempImport_dot = $imgConf['file.']['import.'];
237 unset($imgConf['file.']);
238 $imgConf['file.']['import'] = $tempImport;
239 $imgConf['file.']['import.'] = $tempImport_dot;
240 } elseif (isset($this->cObj->image_compression[$image_compression])) {
241 $imgConf['file.']['params'] .= ' ' . $this->cObj->image_compression[$image_compression]['params'];
242 $imgConf['file.']['ext'] = $this->cObj->image_compression[$image_compression]['ext'];
243 unset($imgConf['file.']['ext.']);
244 }
245 }
246 // "alt", "title" and "longdesc" attributes:
247 if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
248 $imgConf['altText'] = $conf['altText'];
249 $imgConf['altText.'] = $conf['altText.'];
250 }
251 if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
252 $imgConf['titleText'] = $conf['titleText'];
253 $imgConf['titleText.'] = $conf['titleText.'];
254 }
255 if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
256 $imgConf['longdescURL'] = $conf['longdescURL'];
257 $imgConf['longdescURL.'] = $conf['longdescURL.'];
258 }
259 } else {
260 $imgConf = array(
261 'altText' => $conf['altText'],
262 'titleText' => $conf['titleText'],
263 'longdescURL' => $conf['longdescURL'],
264 'file' => $totalImagePath
265 );
266 }
267 $imgsTag[$imgKey] = $this->cObj->IMAGE($imgConf);
268 // Store the original filepath
269 $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo;
270 $imageRowsFinalWidths[floor($a / $colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
271 if ($GLOBALS['TSFE']->lastImageInfo[1] > $imageRowsMaxHeights[floor($a / $colCount)]) {
272 $imageRowsMaxHeights[floor($a / $colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
273 }
274 }
275 // Calculating the tableWidth:
276 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
277 $tableWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * $borderThickness * 2;
278 // Make table for pictures
279 $index = ($imgIndex = $imgStart);
280 $noRows = isset($conf['noRows.']) ? $this->cObj->stdWrap($conf['noRows'], $conf['noRows.']) : $conf['noRows'];
281 $noCols = isset($conf['noCols.']) ? $this->cObj->stdWrap($conf['noCols'], $conf['noCols.']) : $conf['noCols'];
282 if ($noRows) {
283 $noCols = 0;
284 }
285 // noRows overrides noCols. They cannot exist at the same time.
286 if ($equalHeight) {
287 $noCols = 1;
288 $noRows = 0;
289 }
290 $rowCount_temp = 1;
291 $colCount_temp = $colCount;
292 if ($noRows) {
293 $rowCount_temp = $rowCount;
294 $rowCount = 1;
295 }
296 if ($noCols) {
297 $colCount = 1;
298 }
299 // col- and rowspans calculated
300 $colspan = $colspacing ? $colCount * 2 - 1 : $colCount;
301 $rowspan = ($rowspacing ? $rowCount * 2 - 1 : $rowCount) + $cap;
302 // Edit icons:
303 if (!is_array($conf['editIcons.'])) {
304 $conf['editIcons.'] = array();
305 }
306 $editIconsHTML = $conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin ? $this->cObj->editIcons('', $conf['editIcons'], $conf['editIcons.']) : '';
307 // Strech out table:
308 $tablecode = '';
309 $flag = 0;
310 $noStretchAndMarginCells = isset($conf['noStretchAndMarginCells.']) ? $this->cObj->stdWrap($conf['noStretchAndMarginCells'], $conf['noStretchAndMarginCells.']) : $conf['noStretchAndMarginCells'];
311 if ($noStretchAndMarginCells != 1) {
312 $tablecode .= '<tr>';
313 if ($txtMarg && $align == 'right') {
314 // If right aligned, the textborder is added on the right side
315 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' . ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
316 $editIconsHTML = '';
317 $flag = 1;
318 }
319 $tablecode .= '<td colspan="' . $colspan . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $tableWidth . '" height="1" alt="" /></td>';
320 if ($txtMarg && $align == 'left') {
321 // If left aligned, the textborder is added on the left side
322 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' . ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
323 $editIconsHTML = '';
324 $flag = 1;
325 }
326 if ($flag) {
327 $tableWidth += $txtMarg + 1;
328 }
329 $tablecode .= '</tr>';
330 }
331 // draw table
332 // Looping through rows. If 'noRows' is set, this is '1 time', but $rowCount_temp will hold the actual number of rows!
333 for ($c = 0; $c < $rowCount; $c++) {
334 // If this is NOT the first time in the loop AND if space is required, a row-spacer is added. In case of "noRows" rowspacing is done further down.
335 if ($c && $rowspacing) {
336 $tablecode .= '<tr><td colspan="' . $colspan . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $rowspacing . '"' . $this->cObj->getBorderAttr(' border="0"') . ' alt="" title="" /></td></tr>';
337 }
338 // starting row
339 $tablecode .= '<tr>';
340 // Looping through the columns
341 for ($b = 0; $b < $colCount_temp; $b++) {
342 // If this is NOT the first iteration AND if column space is required. In case of "noCols", the space is done without a separate cell.
343 if ($b && $colspacing) {
344 if (!$noCols) {
345 $tablecode .= '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $colspacing . '" height="1"' . $this->cObj->getBorderAttr(' border="0"') . ' alt="" title="" /></td>';
346 } else {
347 $colSpacer = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . ($border ? $colspacing - 6 : $colspacing) . '" height="' . ($imageRowsMaxHeights[$c] + ($border ? $borderThickness * 2 : 0)) . '"' . $this->cObj->getBorderAttr(' border="0"') . ' align="' . ($border ? 'left' : 'top') . '" alt="" title="" />';
348 $colSpacer = '<td valign="top">' . $colSpacer . '</td>';
349 // added 160301, needed for the new "noCols"-table...
350 $tablecode .= $colSpacer;
351 }
352 }
353 if (!$noCols || $noCols && !$b) {
354 // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
355 $tablecode .= '<td valign="top">';
356 if ($noCols) {
357 $tablecode .= '<table width="' . $imageRowsFinalWidths[$c] . '" border="0" cellpadding="0" cellspacing="0"><tr>';
358 }
359 }
360 // Looping through the rows IF "noRows" is set. "noRows" means that the rows of images is not rendered
361 // by physical table rows but images are all in one column and spaced apart with clear-gifs. This loop is
362 // only one time if "noRows" is not set.
363 for ($a = 0; $a < $rowCount_temp; $a++) {
364 // register previous imgIndex
365 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex;
366 $imgIndex = $index + $a * $colCount_temp;
367 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
368 if ($imgsTag[$imgIndex]) {
369 // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
370 if ($rowspacing && $noRows && $a) {
371 $tablecode .= '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $rowspacing . '" alt="" title="" /><br />';
372 }
373 if ($legacyCaptionSplit) {
374 $thisCaption = $captionArray[$imgIndex];
375 } elseif (($conf['captionSplit'] || $conf['imageTextSplit']) && isset($conf['caption.'])) {
376 $thisCaption = $this->cObj->cObjGet($conf['caption.'], 'caption.');
377 $thisCaption = $this->cObj->stdWrap($thisCaption, $conf['caption.']);
378 }
379 $imageHTML = $imgsTag[$imgIndex] . '<br />';
380 // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
381 $Talign = !trim($thisCaption) && !$noRows ? ' align="left"' : '';
382 if ($border) {
383 $imageHTML = '<table border="0" cellpadding="' . $borderThickness . '" cellspacing="0" bgcolor="' . $borderColor . '"' . $Talign . '><tr><td>' . $imageHTML . '</td></tr></table>';
384 }
385 $imageHTML .= $editIconsHTML;
386 $editIconsHTML = '';
387 // Adds caption.
388 $imageHTML .= $thisCaption;
389 if ($noCols) {
390 $imageHTML = '<td valign="top">' . $imageHTML . '</td>';
391 }
392 // If noCols, put in table cell.
393 $tablecode .= $imageHTML;
394 }
395 }
396 $index++;
397 if (!$noCols || $noCols && $b + 1 == $colCount_temp) {
398 if ($noCols) {
399 $tablecode .= '</tr></table>';
400 }
401 // In case of "noCols" we must finish the table that surrounds the images in the row.
402 $tablecode .= '</td>';
403 }
404 }
405 // ending row
406 $tablecode .= '</tr>';
407 }
408 if ($c) {
409 switch ($contentPosition) {
410 case '0':
411
412 case '8':
413 // below
414 switch ($align) {
415 case 'center':
416 $table_align = 'margin-left: auto; margin-right: auto';
417 break;
418 case 'right':
419 $table_align = 'margin-left: auto; margin-right: 0px';
420 break;
421 default:
422 // Most of all: left
423 $table_align = 'margin-left: 0px; margin-right: auto';
424 }
425 $table_align = 'style="' . $table_align . '"';
426 break;
427 case '16':
428 // in text
429 $table_align = 'align="' . $align . '"';
430 break;
431 default:
432 $table_align = '';
433 }
434 // Table-tag is inserted
435 $tablecode = '<table' . ($tableWidth ? ' width="' . $tableWidth . '"' : '') . ' border="0" cellspacing="0" cellpadding="0" ' . $table_align . ' class="imgtext-table">' . $tablecode;
436 // If this value is not long since reset.
437 if ($editIconsHTML) {
438 $tablecode .= '<tr><td colspan="' . $colspan . '">' . $editIconsHTML . '</td></tr>';
439 $editIconsHTML = '';
440 }
441 if ($cap) {
442 $tablecode .= '<tr><td colspan="' . $colspan . '" align="' . $caption_align . '">' . $caption . '</td></tr>';
443 }
444 $tablecode .= '</table>';
445 if (isset($conf['tableStdWrap.'])) {
446 $tablecode = $this->cObj->stdWrap($tablecode, $conf['tableStdWrap.']);
447 }
448 }
449 $spaceBelowAbove = isset($conf['spaceBelowAbove.']) ? intval($this->cObj->stdWrap($conf['spaceBelowAbove'], $conf['spaceBelowAbove.'])) : intval($conf['spaceBelowAbove']);
450 switch ($contentPosition) {
451 case '0':
452 // above
453 $output = '<div style="text-align:' . $align . ';">' . $tablecode . '</div>' . $this->cObj->wrapSpace($content, ($spaceBelowAbove . '|0'));
454 break;
455 case '8':
456 // below
457 $output = $this->cObj->wrapSpace($content, ('0|' . $spaceBelowAbove)) . '<div style="text-align:' . $align . ';">' . $tablecode . '</div>';
458 break;
459 case '16':
460 // in text
461 $output = $tablecode . $content;
462 break;
463 case '24':
464 // in text, no wrap
465 $theResult = '';
466 $theResult .= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
467 if ($align == 'right') {
468 $theResult .= '<td valign="top">' . $content . '</td><td valign="top">' . $tablecode . '</td>';
469 } else {
470 $theResult .= '<td valign="top">' . $tablecode . '</td><td valign="top">' . $content . '</td>';
471 }
472 $theResult .= '</tr></table>';
473 $output = $theResult;
474 break;
475 }
476 } else {
477 $output = $content;
478 }
479 if (isset($conf['stdWrap.'])) {
480 $output = $this->cObj->stdWrap($output, $conf['stdWrap.']);
481 }
482 return $output;
483 }
484
485 }
486
487
488 ?>