‪TYPO3CMS  9.5
HtmlentitiesDecodeViewHelper.php
Go to the documentation of this file.
1 <?php
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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
19 
50 {
51  use CompileWithContentArgumentAndRenderStatic;
52 
58  protected ‪$escapeChildren = false;
59 
65  protected ‪$escapeOutput = false;
66 
70  public function ‪initializeArguments()
71  {
72  parent::initializeArguments();
73  $this->registerArgument('value', 'string', 'string to format');
74  $this->registerArgument('keepQuotes', 'bool', 'If TRUE, single and double quotes won\'t be replaced (sets ENT_NOQUOTES flag).', false, false);
75  $this->registerArgument('encoding', 'string', '');
76  }
77 
88  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
89  {
90  $value = $renderChildrenClosure();
91  $encoding = $arguments['encoding'];
92  $keepQuotes = $arguments['keepQuotes'];
93 
94  if (!is_string($value)) {
95  return $value;
96  }
97  if ($encoding === null) {
98  $encoding = ‪self::resolveDefaultEncoding();
99  }
100  $flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
101  return html_entity_decode($value, $flags, $encoding);
102  }
103 }
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper
Definition: HtmlentitiesDecodeViewHelper.php:50
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\initializeArguments
‪initializeArguments()
Definition: HtmlentitiesDecodeViewHelper.php:67
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: HtmlentitiesDecodeViewHelper.php:62
‪TYPO3\CMS\Fluid\ViewHelpers\Format\AbstractEncodingViewHelper
Definition: AbstractEncodingViewHelper.php:24
‪TYPO3\CMS\Fluid\ViewHelpers\Format\AbstractEncodingViewHelper\resolveDefaultEncoding
‪static string resolveDefaultEncoding()
Definition: AbstractEncodingViewHelper.php:34
‪TYPO3\CMS\Fluid\ViewHelpers\Format
Definition: AbstractEncodingViewHelper.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: HtmlentitiesDecodeViewHelper.php:85
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: HtmlentitiesDecodeViewHelper.php:56