Passed
Push — master ( d71159...795102 )
by
unknown
12:41
created

renderPageModulePreviewContent()   B

Complexity

Conditions 7
Paths 6

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 27
rs 8.8333
cc 7
nc 6
nop 1
1
<?php
2
3
declare(strict_types=1);
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
namespace TYPO3\CMS\Frontend\Preview;
18
19
use TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer;
20
use TYPO3\CMS\Backend\Utility\BackendUtility;
21
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
22
23
/**
24
 * Contains a preview rendering for the page module of CType="textmedia"
25
 * @internal this is a concrete TYPO3 hook implementation and solely used for EXT:frontend and not part of TYPO3's Core API.
26
 */
27
class TextmediaPreviewRenderer extends StandardContentPreviewRenderer
28
{
29
    public function renderPageModulePreviewContent(GridColumnItem $item): string
30
    {
31
        $content = '';
32
        $row = $item->getRecord();
33
        if ($row['bodytext']) {
34
            $content = $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
35
        }
36
37
        if ($row['assets']) {
38
            $content .= $this->linkEditContent(BackendUtility::thumbCode($row, 'tt_content', 'assets', '', '', null, 0, '', '', false), $row);
39
40
            $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'assets', $row);
41
42
            if (!empty($fileReferences)) {
43
                $linkedContent = '';
44
45
                foreach ($fileReferences as $fileReference) {
46
                    $description = $fileReference->getDescription();
47
                    if ($description !== null && $description !== '') {
48
                        $linkedContent .= htmlspecialchars($description) . '<br />';
49
                    }
50
                }
51
52
                $content .= $this->linkEditContent($linkedContent, $row);
53
            }
54
        }
55
        return $content;
56
    }
57
}
58