‪TYPO3CMS  11.5
HtmlViewHelper.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 
21 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
25 
75 class ‪HtmlViewHelper extends AbstractViewHelper
76 {
77  use CompileWithRenderStatic;
78 
82  protected static ‪$tsfeBackup;
83 
89  protected ‪$escapeChildren = false;
90 
96  protected ‪$escapeOutput = false;
97 
103  public function ‪initializeArguments()
104  {
105  $this->registerArgument('parseFuncTSPath', 'string', ' path to TypoScript parseFunc setup.', false, 'lib.parseFunc_RTE');
106  }
107 
115  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
116  {
117  $parseFuncTSPath = $arguments['parseFuncTSPath'];
118  $request = $renderingContext->getRequest();
119  $isBackendRequest = $request->getAttribute('applicationType')
120  && ‪ApplicationType::fromRequest($request)->isBackend();
121  if ($isBackendRequest) {
123  }
124  $value = $renderChildrenClosure() ?? '';
125  $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
126  $contentObject->start([]);
127  $content = $contentObject->parseFunc($value, [], '< ' . $parseFuncTSPath);
128  if ($isBackendRequest) {
130  }
131  return $content;
132  }
133 
138  protected static function ‪simulateFrontendEnvironment()
139  {
140  self::$tsfeBackup = ‪$GLOBALS['TSFE'] ?? null;
141  ‪$GLOBALS['TSFE'] = new \stdClass();
142  ‪$GLOBALS['TSFE']->tmpl = new \stdClass();
143  $configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
144  ‪$GLOBALS['TSFE']->tmpl->setup = $configurationManager->getConfiguration(‪ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
145  }
146 
152  protected static function ‪resetFrontendEnvironment()
153  {
155  }
156 }
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\resetFrontendEnvironment
‪static resetFrontendEnvironment()
Definition: HtmlViewHelper.php:148
‪TYPO3\CMS\Core\Http\ApplicationType\fromRequest
‪static static fromRequest(ServerRequestInterface $request)
Definition: ApplicationType.php:62
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\initializeArguments
‪initializeArguments()
Definition: HtmlViewHelper.php:99
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: HtmlViewHelper.php:111
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper
Definition: HtmlViewHelper.php:76
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: HtmlViewHelper.php:92
‪TYPO3\CMS\Core\Http\ApplicationType
Definition: ApplicationType.php:52
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\$tsfeBackup
‪static TYPO3 CMS Frontend Controller TypoScriptFrontendController $tsfeBackup
Definition: HtmlViewHelper.php:80
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\simulateFrontendEnvironment
‪static simulateFrontendEnvironment()
Definition: HtmlViewHelper.php:134
‪TYPO3\CMS\Fluid\ViewHelpers\Format
Definition: AbstractEncodingViewHelper.php:16
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FULL_TYPOSCRIPT
‪const CONFIGURATION_TYPE_FULL_TYPOSCRIPT
Definition: ConfigurationManagerInterface.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: HtmlViewHelper.php:86
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50