FormatViewHelper.php 1.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
namespace TYPO3\CMS\Cshmanual\ViewHelpers;

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

17
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
19
20
21
22
23
24

/**
 * Format the given content
 *
 * @internal
 */
25
class FormatViewHelper extends AbstractViewHelper
26
27
{
    /**
28
     * Disable the output escaping interceptor
29
30
31
     *
     * @var bool
     */
32
33
34
35
36
37
38
39
    protected $escapeOutput = false;

    /**
     * Disable the children escaping interceptor
     *
     * @var bool
     */
    protected $escapeChildren = false;
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    /**
     * Format the content
     *
     * @param string $content
     * @return string
     */
    public function render($content = '')
    {
        return self::renderStatic(
            array(
                'content' => $content,
            ),
            $this->buildRenderChildrenClosure(),
            $this->renderingContext
        );
    }
57

58
59
    /**
     * @param array $arguments
60
     * @param \Closure $renderChildrenClosure
61
62
63
64
65
66
67
68
69
70
71
     * @param RenderingContextInterface $renderingContext
     *
     * @return string
     */
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        if (empty($content)) {
            $content = $renderChildrenClosure();
        }
        return nl2br(trim(strip_tags($content, '<strong><em><b><i>')));
    }
72
}