Пример #1
0
 /**
  * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
  * @return boolean the boolean value
  */
 public function evaluate(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 {
     if ($this->comparator !== NULL) {
         return self::evaluateComparator($this->comparator, $this->leftSide->evaluate($renderingContext), $this->rightSide->evaluate($renderingContext));
     } else {
         $value = $this->syntaxTreeNode->evaluate($renderingContext);
         return self::convertToBoolean($value);
     }
 }
Пример #2
0
 /**
  * Returns the name of the layout that is defined within the current template via <f:layout name="..." />
  * If no layout is defined, this returns NULL
  * This requires the current rendering context in order to be able to evaluate the layout name
  *
  * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
  * @return string
  * @throws \TYPO3\CMS\Fluid\View\Exception
  */
 public function getLayoutName(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 {
     if (!$this->hasLayout()) {
         return NULL;
     }
     $layoutName = $this->layoutNameNode->evaluate($renderingContext);
     if (!empty($layoutName)) {
         return $layoutName;
     }
     throw new \TYPO3\CMS\Fluid\View\Exception('The layoutName could not be evaluated to a string', 1296805368);
 }
 /**
  * The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure.
  * These contain closures which are be executed to render the then(), respectively else() case.
  *
  * @param string $argumentsVariableName
  * @param string $renderChildrenClosureVariableName
  * @param string $initializationPhpCode
  * @param \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode
  * @param \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler
  * @return string
  * @internal
  */
 public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 {
     foreach ($syntaxTreeNode->getChildNodes() as $childNode) {
         if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ThenViewHelper') {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
         }
         if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__elseClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
         }
     }
     return \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION;
 }
Пример #4
0
 /**
  * @param \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $node
  * @return array
  * @see convert()
  */
 public function convertListOfSubNodes(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $node)
 {
     switch (count($node->getChildNodes())) {
         case 0:
             return array('initialization' => '', 'execution' => 'NULL');
         case 1:
             $converted = $this->convert(current($node->getChildNodes()));
             return $converted;
         default:
             $outputVariableName = $this->variableName('output');
             $initializationPhpCode = sprintf('%s = \'\';', $outputVariableName) . chr(10);
             foreach ($node->getChildNodes() as $childNode) {
                 $converted = $this->convert($childNode);
                 $initializationPhpCode .= $converted['initialization'] . chr(10);
                 $initializationPhpCode .= sprintf('%s .= %s;', $outputVariableName, $converted['execution']) . chr(10);
             }
             return array('initialization' => $initializationPhpCode, 'execution' => $outputVariableName);
     }
 }
 /**
  * The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure.
  * These contain closures which are be executed to render the then(), respectively else() case.
  *
  * @param string $argumentsVariableName
  * @param string $renderChildrenClosureVariableName
  * @param string $initializationPhpCode
  * @param \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode
  * @param \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler
  * @return string
  * @internal
  */
 public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 {
     foreach ($syntaxTreeNode->getChildNodes() as $childNode) {
         if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === ThenViewHelper::class) {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . LF;
         }
         if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === ElseViewHelper::class) {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__elseClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . LF;
         }
     }
     return sprintf('%s::renderStatic(%s, %s, $renderingContext)', get_class($this), $argumentsVariableName, $renderChildrenClosureVariableName);
 }