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