/** * @param string $argumentsVariableName * @param string $renderChildrenClosureVariableName * @param string $initializationPhpCode * @param \TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode * @param \TYPO3\Fluid\Core\Compiler\TemplateCompiler $templateCompiler * @return string */ public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\Fluid\Core\Compiler\TemplateCompiler $templateCompiler) { $valueVariableName = $templateCompiler->variableName('value'); $initializationPhpCode .= sprintf('%s = (%s[\'value\'] !== NULL ? %s[\'value\'] : %s());', $valueVariableName, $argumentsVariableName, $argumentsVariableName, $renderChildrenClosureVariableName) . chr(10); return sprintf('(!is_string(%s) ? %s : htmlspecialchars(%s, (%s[\'keepQuotes\'] ? ENT_NOQUOTES : ENT_COMPAT), %s[\'encoding\'], %s[\'doubleEncode\']))', $valueVariableName, $valueVariableName, $valueVariableName, $argumentsVariableName, $argumentsVariableName, $argumentsVariableName); }
/** * This ViewHelper is used a *lot* because it is used by the escape interceptor. * Therefore we render it to raw PHP code during compilation * * @param string $argumentsVariableName * @param string $renderChildrenClosureVariableName * @param string $initializationPhpCode * @param AbstractNode $syntaxTreeNode * @param TemplateCompiler $templateCompiler * @return string */ public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, AbstractNode $syntaxTreeNode, TemplateCompiler $templateCompiler) { $valueVariableName = $templateCompiler->variableName('value'); $initializationPhpCode .= sprintf('%1$s = (%2$s[\'value\'] !== NULL ? %2$s[\'value\'] : %3$s());', $valueVariableName, $argumentsVariableName, $renderChildrenClosureVariableName) . chr(10); return sprintf('!is_string(%1$s) && !(is_object(%1$s) && method_exists(%1$s, \'__toString\')) ? %1$s : htmlspecialchars(%1$s, (%2$s[\'keepQuotes\'] ? ENT_NOQUOTES : ENT_COMPAT), %2$s[\'encoding\'], %2$s[\'doubleEncode\'])', $valueVariableName, $argumentsVariableName); }