‪TYPO3CMS  10.4
HtmlentitiesDecodeViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
20 
51 {
52  use CompileWithContentArgumentAndRenderStatic;
53 
59  protected ‪$escapeChildren = false;
60 
66  protected ‪$escapeOutput = false;
67 
71  public function ‪initializeArguments()
72  {
73  parent::initializeArguments();
74  $this->registerArgument('value', 'string', 'string to format');
75  $this->registerArgument('keepQuotes', 'bool', 'If TRUE, single and double quotes won\'t be replaced (sets ENT_NOQUOTES flag).', false, false);
76  $this->registerArgument('encoding', 'string', 'Define the encoding used when converting characters (Default: UTF-8).');
77  }
78 
89  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
90  {
91  $value = $renderChildrenClosure();
92  $encoding = $arguments['encoding'];
93  $keepQuotes = $arguments['keepQuotes'];
94 
95  if (!is_string($value)) {
96  return $value;
97  }
98  if ($encoding === null) {
99  $encoding = ‪self::resolveDefaultEncoding();
100  }
101  $flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
102  return html_entity_decode($value, $flags, $encoding);
103  }
104 }
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper
Definition: HtmlentitiesDecodeViewHelper.php:51
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\initializeArguments
‪initializeArguments()
Definition: HtmlentitiesDecodeViewHelper.php:68
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: HtmlentitiesDecodeViewHelper.php:63
‪TYPO3\CMS\Fluid\ViewHelpers\Format\AbstractEncodingViewHelper
Definition: AbstractEncodingViewHelper.php:25
‪TYPO3\CMS\Fluid\ViewHelpers\Format\AbstractEncodingViewHelper\resolveDefaultEncoding
‪static string resolveDefaultEncoding()
Definition: AbstractEncodingViewHelper.php:35
‪TYPO3\CMS\Fluid\ViewHelpers\Format
Definition: AbstractEncodingViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: HtmlentitiesDecodeViewHelper.php:86
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: HtmlentitiesDecodeViewHelper.php:57