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