Fluid in v5 and v4 are now synchronized again!
authorSebastian Kurfürst <sebastian@typo3.org>
Mon, 12 Jul 2010 20:18:26 +0000 (20:18 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Mon, 12 Jul 2010 20:18:26 +0000 (20:18 +0000)
[+FEATURE] Fluid: The TemplateVariableContainer now provides a method to retrieve all variables.
[~TASK] Fluid (Core): Introduced a RenderingContextInterface to more cleanly decouple Fluid's rendering context from the TypoScript rendering context. Note that view helpers (and other code) should now refer to that interface instead of the concrete Fluid implementation!
[!!!][+BUGFIX] Fluid (Core): Refactored all Condition-ViewHelpers like f:if, f:security.if* to use a newly created base class F3\Fluid\Core\ViewHelper\ConditionViewHelper. This greatly simplifies the implementation of custom conditions. However, THIS IS A BREAKING CHANGE in case you copied the f:if ViewHelper to create a custom condition ViewHelper, as the internal workings changed. Please check the new f:if ViewHelper to see how to adjust your ViewHelper -- you basically just have to throw away a lot of code. Resolves #8824.
[!!!][-API] Fluid (TemplateView): Removed renderSection() and renderWithLayout() from public API in Tx_Fluid_View_TemplateView, as this should only be called from inside Fluid.
[!!!][TASK] Fluid (ViewHelpers): the <f:section />-ViewHelper now does NOT render itself anymore when encountered in a normal template. Example: Before the change, the template "before <f:section name='...'> middle </f:section> after" was rendered as "before middle after", but now it is only rendered as "before after". Although this is a breaking change, it is quite unlikely that anybody relied on this behavior, as it was inconsistent beforehand.
[TASK] Fluid (TemplateView): Major refactoring of the layout, partial and section rendering mechanism. This also induces a speedup as retundant rendering is eliminated.
[+FEATURE] Fluid (ViewHelpers): The <f:render>-ViewHelper can be now used to render sections in the same partial and template. In these cases, all arguments need to be specified explicitely. Additionally, it can now be used to render a section recursively.
[~TASK] Fluid (Core): Removed some non-API-methods which were never called.

83 files changed:
typo3/sysext/fluid/Classes/Compatibility/ObjectManager.php
typo3/sysext/fluid/Classes/Core/Exception.php
typo3/sysext/fluid/Classes/Core/Parser/Configuration.php
typo3/sysext/fluid/Classes/Core/Parser/Exception.php
typo3/sysext/fluid/Classes/Core/Parser/Interceptor/Escape.php
typo3/sysext/fluid/Classes/Core/Parser/ParsedTemplateInterface.php
typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ArrayNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/NodeInterface.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RenderingContextAwareInterface.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RootNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/TextNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php
typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContextInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/ArgumentDefinition.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Arguments.php
typo3/sysext/fluid/Classes/Core/ViewHelper/ConditionViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Exception.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Exception/InvalidVariableException.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Exception/RenderingContextNotAccessibleException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/ChildNodeAccessInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/PostParseInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBasedViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TemplateVariableContainer.php
typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperVariableContainer.php
typo3/sysext/fluid/Classes/Service/DocbookGenerator.php
typo3/sysext/fluid/Classes/View/AbstractTemplateView.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/Exception.php
typo3/sysext/fluid/Classes/View/Exception/InvalidSectionException.php
typo3/sysext/fluid/Classes/View/TemplateView.php
typo3/sysext/fluid/Classes/View/TemplateViewInterface.php
typo3/sysext/fluid/Classes/ViewHelpers/AliasViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/BaseViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/CycleViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/ElseViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/ForViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/ErrorsViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextboxViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/PrintfViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/GroupedForViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/LayoutViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/SectionViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/ThenViewHelper.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/ParsingStateTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/AbstractNodeTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/TextNodeTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/ViewHelperNodeComparatorTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/ViewHelperNodeTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/TemplateParserTest.php
typo3/sysext/fluid/Tests/Unit/Core/Rendering/RenderingContextTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/AbstractViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ConditionViewHelperTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperVariableContainerTest.php
typo3/sysext/fluid/Tests/Unit/View/Fixtures/TransparentSyntaxTreeNode.php
typo3/sysext/fluid/Tests/Unit/View/TemplateViewTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/AliasViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Fixtures/ConstraintSyntaxTreeNode.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ForViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/IfViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ViewHelperBaseTestcase.php

index a6febc1..4e93ef8 100644 (file)
@@ -39,11 +39,14 @@ class Tx_Fluid_Compatibility_ObjectManager implements t3lib_Singleton {
                'Tx_Fluid_Core_Parser_ParsingState' => array(
                        'injectVariableContainer' => 'Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'
                ),
+
                'Tx_Fluid_Core_Parser_TemplateParser' => array(
                        'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager'
                ),
-               'Tx_Fluid_Core_Rendering_RenderingContext' => array(
-                       'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager'
+               'Tx_Fluid_Core_Rendering_RenderingContextInterface' => array(
+                       'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager',
+                       'injectTemplateVariableContainer' => 'Tx_Fluid_Core_ViewHelper_TemplateVariableContainer',
+                       'injectViewHelperVariableContainer' => 'Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer'
                ),
                'Tx_Fluid_Core_Parser_Interceptor_Escape' => array(
                        'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager'
index e090682..7b9ba20 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A generic Fluid Core exception.
  *
- * @version $Id$
+ * @version $Id: Exception.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 81c17d3..7894148 100644 (file)
@@ -24,7 +24,7 @@
  * The parser configuration. Contains all configuration needed to configure
  * the building of a SyntaxTree.
  *
- * @version $Id: Configuration.php 4628 2010-06-24 14:34:08Z k-fish $
+ * @version $Id: Configuration.php 4665 2010-06-29 15:16:56Z k-fish $
  * @package Fluid
  * @subpackage Core\Parser
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -57,25 +57,9 @@ class Tx_Fluid_Core_Parser_Configuration {
        }
 
        /**
-        * Removes an interceptor to apply to values coming from object accessors.
-        *
-        * @param Tx_Fluid_Core_Parser_InterceptorInterface $interceptor
-        * @return void
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function removeInterceptor($interceptor) {
-               foreach ($interceptor->getInterceptionPoints() as $interceptionPoint) {
-                       if ($this->interceptors[$interceptionPoint]->contains($interceptor)) {
-                               $this->interceptors[$interceptionPoint]->detach($interceptor);
-                       }
-               }
-               
-       }
-
-       /**
         * Returns all interceptors for a given Interception Point.
         *
-        * @param int $interceptionPoint one of the Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_* constants,
+        * @param integer $interceptionPoint one of the Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_* constants,
         * @return \SplObjectStorage<Tx_Fluid_Core_Parser_InterceptorInterface>
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
index 2416013..37c174b 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A Parsing Exception
  *
- * @version $Id$
+ * @version $Id: Exception.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\Parser
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 8d65999..08df627 100644 (file)
@@ -67,7 +67,7 @@ class Tx_Fluid_Core_Parser_Interceptor_Escape implements Tx_Fluid_Core_Parser_In
         */
        public function process(Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface $node, $interceptorPosition) {
                if ($interceptorPosition === Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
-                       if (!$node->getViewHelper()->isEscapingInterceptorEnabled()) {
+                       if (!$node->getUninitializedViewHelper()->isEscapingInterceptorEnabled()) {
                                $this->interceptorEnabled = FALSE;
                                $this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
                        }
index bde3705..8e44102 100644 (file)
@@ -24,7 +24,7 @@
  * This interface is returned by Tx_Fluid_Core_Parser_TemplateParser->parse()
  * method and is a parsed template
  *
- * @version $Id$
+ * @version $Id: ParsedTemplateInterface.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -34,10 +34,10 @@ interface Tx_Fluid_Core_Parser_ParsedTemplateInterface {
        /**
         * Render the parsed template with rendering context
         *
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext The rendering context to use
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext The rendering context to use
         * @return Rendered string
         */
-       public function render(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext);
+       public function render(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext);
 
        /**
         * Returns a variable container used in the PostParse Facet.
index 952be9f..4c6b8c8 100644 (file)
@@ -25,7 +25,7 @@
  * and the current stack of open nodes (nodeStack) and a variable container used
  * for PostParseFacets.
  *
- * @version $Id$
+ * @version $Id: ParsingState.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -88,12 +88,11 @@ class Tx_Fluid_Core_Parser_ParsingState implements Tx_Fluid_Core_Parser_ParsedTe
        /**
         * Render the parsed template with rendering context
         *
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext The rendering context to use
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext The rendering context to use
         * @return Rendered string
         */
-       public function render(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
-               $this->rootNode->setRenderingContext($renderingContext);
-               return $this->rootNode->evaluate();
+       public function render(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               return $this->rootNode->evaluate($renderingContext);
        }
 
        /**
index 71b01a5..ef035d1 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Abstract node in the syntax tree which has been built.
  *
- * @version $Id$
+ * @version $Id: AbstractNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -38,40 +38,24 @@ abstract class Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode implements Tx_Fluid_
        protected $childNodes = array();
 
        /**
-        * The rendering context containing everything to correctly render the subtree
-        * @var Tx_Fluid_Core_Rendering_RenderingContext
-        */
-       protected $renderingContext;
-
-       /**
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext Rendering Context to be used for this evaluation
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
-               $this->renderingContext = $renderingContext;
-       }
-
-       /**
         * Evaluate all child nodes and return the evaluated results.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned.
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function evaluateChildNodes() {
+       public function evaluateChildNodes(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
                $output = NULL;
                foreach ($this->childNodes as $subNode) {
-                       $subNode->setRenderingContext($this->renderingContext);
-
                        if ($output === NULL) {
-                               $output = $subNode->evaluate();
+                               $output = $subNode->evaluate($renderingContext);
                        } else {
                                if (is_object($output) && !method_exists($output, '__toString')) {
                                        throw new Tx_Fluid_Core_Parser_Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140);
                                }
                                $output = (string)$output;
-                               $subNodeOutput = $subNode->evaluate();
+                               $subNodeOutput = $subNode->evaluate($renderingContext);
 
                                if (is_object($subNodeOutput) && !method_exists($subNodeOutput, '__toString')) {
                                        throw new Tx_Fluid_Core_Parser_Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083);
index 0b5f667..304a542 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Array Syntax Tree Node. Handles JSON-like arrays.
  *
- * @version $Id$
+ * @version $Id: ArrayNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -50,19 +50,16 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ArrayNode extends Tx_Fluid_Core_Parser_Syn
        /**
         * Evaluate the array and return an evaluated array
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return array An associative array with literal values
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function evaluate() {
-               if ($this->renderingContext === NULL) {
-                       throw new Tx_Fluid_Core_Parser_Exception('Rendering Context is null in ArrayNode, but necessary. If this error appears, please report a bug!', 1242668976);
-               }
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
                $arrayToBuild = array();
                foreach ($this->internalArray as $key => $value) {
                        if ($value instanceof Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode) {
-                               $value->setRenderingContext($this->renderingContext);
-                               $arrayToBuild[$key] = $value->evaluate();
+                               $arrayToBuild[$key] = $value->evaluate($renderingContext);
                        } else {
                                // TODO - this case should not happen!
                                $arrayToBuild[$key] = $value;
index 7eae719..0b0a001 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Node in the syntax tree.
  *
- * @version $Id: NodeInterface.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: NodeInterface.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
 interface Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface {
 
        /**
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext Rendering Context to be used for this evaluation
-        * @return void
-        */
-       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext);
-
-       /**
         * Evaluate all child nodes and return the evaluated results.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned.
         */
-       public function evaluateChildNodes();
+       public function evaluateChildNodes(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext);
 
        /**
         * Returns all child nodes for a given node.
@@ -62,9 +57,10 @@ interface Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface {
        /**
         * Evaluates the node - can return not only strings, but arbitary objects.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return mixed Evaluated node
         */
-       public function evaluate();
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext);
 }
 
 ?>
\ No newline at end of file
index 2e0e22a..d78c11c 100644 (file)
@@ -25,7 +25,7 @@
  * marked with this interface will get the current rendering context injected
  * by the ObjectAccessorNode on trying to evaluate them.
  *
- * @version $Id$
+ * @version $Id: NodeInterface.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -35,10 +35,10 @@ interface Tx_Fluid_Core_Parser_SyntaxTree_RenderingContextAwareInterface {
        /**
         * Sets the current rendering context
         *
-        * @param $renderingContext
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return void
         */
-       public function setRenderingContext($renderingContext);
+       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext);
 
 }
 
index 8aa8735..e27d1af 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Root node of every syntax tree.
  *
- * @version $Id$
+ * @version $Id: RootNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -34,15 +34,12 @@ class Tx_Fluid_Core_Parser_SyntaxTree_RootNode extends Tx_Fluid_Core_Parser_Synt
        /**
         * Evaluate the root node, by evaluating the subtree.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return mixed Evaluated subtree
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function evaluate() {
-               if ($this->renderingContext === NULL) {
-                       throw new Tx_Fluid_Core_Parser_Exception('Rendering Context is NULL in RootNode, but necessary. If this error appears, please report a bug!', 1242669004);
-               }
-               $result = $this->evaluateChildNodes();
-               return $result;
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               return $this->evaluateChildNodes($renderingContext);
        }
 }
 
index 29fe169..a23b17c 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Text Syntax Tree Node - is a container for strings.
  *
- * @version $Id$
+ * @version $Id: TextNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -54,11 +54,23 @@ class Tx_Fluid_Core_Parser_SyntaxTree_TextNode extends Tx_Fluid_Core_Parser_Synt
         * Return the text associated to the syntax tree. Text from child nodes is
         * appended to the text in the node's own text.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return string the text stored in this node/subtree.
         * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo TextNode shouldn't have child nodes
         */
-       public function evaluate() {
-               return $this->text . $this->evaluateChildNodes();
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               return $this->text . $this->evaluateChildNodes($renderingContext);
+       }
+
+       /**
+        * Getter for text
+        *
+        * @return string The text of this node
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function getText() {
+               return $this->text;
        }
 }
 
index d9eddb3..f932d19 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Node which will call a ViewHelper associated with this node.
  *
- * @version $Id$
+ * @version $Id: ViewHelperNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Parser\SyntaxTree
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -47,7 +47,14 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
         * The ViewHelper associated with this node
         * @var Tx_Fluid_Core_ViewHelper_ViewHelperInterface
         */
-       protected $viewHelper = NULL;
+       protected $uninitializedViewHelper = NULL;
+
+       /**
+        * A mapping RenderingContext -> ViewHelper to only re-initialize ViewHelpers
+        * when a context change occurs.
+        * @var \SplObjectStorage
+        */
+       protected $viewHelpersByContext = NULL;
 
        /**
         * List of comparators which are supported in the boolean expression language.
@@ -83,24 +90,25 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function __construct(Tx_Fluid_Core_ViewHelper_ViewHelperInterface $viewHelper, array $arguments) {
-               $this->viewHelper = $viewHelper;
+               $this->uninitializedViewHelper = $viewHelper;
+               $this->viewHelpersByContext = new SplObjectStorage();
                $this->arguments = $arguments;
 
-               if (FALSE /*FIXME*/) {
-                       $this->viewHelperClassName = $this->viewHelper->FLOW3_AOP_Proxy_getProxyTargetClassName();
+               if ($this->uninitializedViewHelper instanceof Tx_Fluid_AOP_ProxyInterface) {
+                       $this->viewHelperClassName = $this->uninitializedViewHelper->FLOW3_AOP_Proxy_getProxyTargetClassName();
                } else {
-                       $this->viewHelperClassName = get_class($this->viewHelper);
+                       $this->viewHelperClassName = get_class($this->uninitializedViewHelper);
                }
        }
 
        /**
-        * Returns the attached ViewHelper for this ViewHelperNode.
+        * Returns the attached (but still uninitialized) ViewHelper for this ViewHelperNode.
         * We need this method because sometimes Interceptors need to ask some information from the ViewHelper.
         *
         * @return Tx_Fluid_Core_ViewHelper_AbstractViewHelper the attached ViewHelper, if it is initialized
         */
-       public function getViewHelper() {
-               return $this->viewHelper;
+       public function getUninitializedViewHelper() {
+               return $this->uninitializedViewHelper;
        }
 
        /**
@@ -123,32 +131,30 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
         *
         * Afterwards, checks that the view helper did not leave a variable lying around.
         *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return object evaluated node after the view helper has been called.
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Karsten Dambekalns <karsten@typo3.org>
         * @todo check recreation of viewhelper when revisiting caching
         */
-       public function evaluate() {
-               if ($this->renderingContext === NULL) {
-                       throw new Tx_Fluid_Core_Parser_Exception('RenderingContext is null in ViewHelperNode, but necessary. If this error appears, please report a bug!', 1242669031);
-               }
-
-               $objectManager = $this->renderingContext->getObjectManager();
-               $contextVariables = $this->renderingContext->getTemplateVariableContainer()->getAllIdentifiers();
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               $objectManager = $renderingContext->getObjectManager();
+               $contextVariables = $renderingContext->getTemplateVariableContainer()->getAllIdentifiers();
 
-               if ($this->viewHelper === NULL) {
-                               // we have been resurrected from the cache
-                       $this->viewHelper = $objectManager->create($this->viewHelperClassName);
+               if ($this->viewHelpersByContext->contains($renderingContext)) {
+                       $viewHelper = $this->viewHelpersByContext[$renderingContext];
+               } else {
+                       $viewHelper = clone $this->uninitializedViewHelper;
+                       $this->viewHelpersByContext->attach($renderingContext, $viewHelper);
                }
 
                $evaluatedArguments = array();
                $renderMethodParameters = array();
-               if (count($this->viewHelper->prepareArguments())) {
-                       foreach ($this->viewHelper->prepareArguments() as $argumentName => $argumentDefinition) {
+               if (count($viewHelper->prepareArguments())) {
+                       foreach ($viewHelper->prepareArguments() as $argumentName => $argumentDefinition) {
                                if (isset($this->arguments[$argumentName])) {
                                        $argumentValue = $this->arguments[$argumentName];
-                                       $argumentValue->setRenderingContext($this->renderingContext);
-                                       $evaluatedArguments[$argumentName] = $this->convertArgumentValue($argumentValue, $argumentDefinition->getType());
+                                       $evaluatedArguments[$argumentName] = $this->convertArgumentValue($argumentValue, $argumentDefinition->getType(), $renderingContext);
                                } else {
                                        $evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue();
                                }
@@ -159,34 +165,28 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
                }
 
                $viewHelperArguments = $objectManager->create('Tx_Fluid_Core_ViewHelper_Arguments', $evaluatedArguments);
-               $this->viewHelper->setArguments($viewHelperArguments);
-               $this->viewHelper->setTemplateVariableContainer($this->renderingContext->getTemplateVariableContainer());
-               if ($this->renderingContext->getControllerContext() !== NULL) {
-                       $this->viewHelper->setControllerContext($this->renderingContext->getControllerContext());
+               $viewHelper->setArguments($viewHelperArguments);
+               $viewHelper->setTemplateVariableContainer($renderingContext->getTemplateVariableContainer());
+               if ($renderingContext->getControllerContext() !== NULL) {
+                       $viewHelper->setControllerContext($renderingContext->getControllerContext());
                }
-               $this->viewHelper->setViewHelperVariableContainer($this->renderingContext->getViewHelperVariableContainer());
-               $this->viewHelper->setViewHelperNode($this);
+               $viewHelper->setViewHelperVariableContainer($renderingContext->getViewHelperVariableContainer());
+               $viewHelper->setViewHelperNode($this);
+               $viewHelper->setRenderingContext($renderingContext);
 
-               if ($this->viewHelper instanceof Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface) {
-                       $this->viewHelper->setChildNodes($this->childNodes);
-                       $this->viewHelper->setRenderingContext($this->renderingContext);
+               if ($viewHelper instanceof Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface) {
+                       $viewHelper->setChildNodes($this->childNodes);
                }
 
-               $this->viewHelper->validateArguments();
-               $this->viewHelper->initialize();
+               $viewHelper->validateArguments();
+               $viewHelper->initialize();
                try {
-                       $output = call_user_func_array(array($this->viewHelper, 'render'), $renderMethodParameters);
+                       $output = call_user_func_array(array($viewHelper, 'render'), $renderMethodParameters);
                } catch (Tx_Fluid_Core_ViewHelper_Exception $exception) {
                                // @todo [BW] rethrow exception, log, ignore.. depending on the current context
                        $output = $exception->getMessage();
                }
 
-               if ($contextVariables != $this->renderingContext->getTemplateVariableContainer()->getAllIdentifiers()) {
-                       $endContextVariables = $this->renderingContext->getTemplateVariableContainer();
-                       $diff = array_intersect($endContextVariables, $contextVariables);
-
-                       throw new RuntimeException('The following context variable has been changed after the view helper "' . $this->viewHelperClassName . '" has been called: ' .implode(', ', $diff), 1236081302);
-               }
                return $output;
        }
 
@@ -199,11 +199,11 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       protected function convertArgumentValue(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode, $type) {
+       protected function convertArgumentValue(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode, $type, Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
                if ($type === 'boolean') {
-                       return $this->evaluateBooleanExpression($syntaxTreeNode);
+                       return $this->evaluateBooleanExpression($syntaxTreeNode, $renderingContext);
                }
-               return $syntaxTreeNode->evaluate();
+               return $syntaxTreeNode->evaluate($renderingContext);
        }
 
        /**
@@ -229,23 +229,22 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
         * Then, we evaluate the obtained left and right side using the given comparator. This is done inside the evaluateComparator method.
         *
         * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode Value to be converted
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
         * @return boolean Evaluated value
         * @throws Tx_Fluid_Core_Parser_Exception
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       protected function evaluateBooleanExpression(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode) {
+       protected function evaluateBooleanExpression(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode, Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
                $childNodes = $syntaxTreeNode->getChildNodes();
                if (count($childNodes) > 3) {
-                       throw new Tx_Fluid_Core_Parser_Exception('The expression "' . $syntaxTreeNode->evaluate() . '" has more than tree parts.', 1244201848);
+                       throw new Tx_Fluid_Core_Parser_Exception('The expression "' . $syntaxTreeNode->evaluate($renderingContext) . '" has more than tree parts.', 1244201848);
                }
 
                $leftSide = NULL;
                $rightSide = NULL;
                $comparator = NULL;
                foreach ($childNodes as $childNode) {
-                       $childNode->setRenderingContext($this->renderingContext);
-
-                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_TextNode && !preg_match(str_replace('COMPARATORS', implode('|', self::$comparators), self::$booleanExpressionTextNodeCheckerRegularExpression), $childNode->evaluate())) {
+                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_TextNode && !preg_match(str_replace('COMPARATORS', implode('|', self::$comparators), self::$booleanExpressionTextNodeCheckerRegularExpression), $childNode->evaluate($renderingContext))) {
                                $comparator = NULL;
                                        // skip loop and fall back to classical to boolean conversion.
                                break;
@@ -254,14 +253,14 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
                        if ($comparator !== NULL) {
                                        // comparator already set, we are evaluating the right side of the comparator
                                if ($rightSide === NULL) {
-                                       $rightSide = $childNode->evaluate();
+                                       $rightSide = $childNode->evaluate($renderingContext);
                                } else {
-                                       $rightSide .= $childNode->evaluate();
+                                       $rightSide .= $childNode->evaluate($renderingContext);
                                }
                        } elseif ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_TextNode
-                               && ($comparator = $this->getComparatorFromString($childNode->evaluate()))) {
+                               && ($comparator = $this->getComparatorFromString($childNode->evaluate($renderingContext)))) {
                                        // comparator in current string segment
-                               $explodedString = explode($comparator, $childNode->evaluate());
+                               $explodedString = explode($comparator, $childNode->evaluate($renderingContext));
                                if (isset($explodedString[0]) && trim($explodedString[0]) !== '') {
                                        $leftSide .= trim($explodedString[0]);
                                }
@@ -271,9 +270,9 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
                        } else {
                                        // comparator not found yet, on the left side of the comparator
                                if ($leftSide === NULL) {
-                                       $leftSide = $childNode->evaluate();
+                                       $leftSide = $childNode->evaluate($renderingContext);
                                } else {
-                                       $leftSide .= $childNode->evaluate();
+                                       $leftSide .= $childNode->evaluate($renderingContext);
                                }
                        }
                }
@@ -281,8 +280,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
                if ($comparator !== NULL) {
                        return $this->evaluateComparator($comparator, $leftSide, $rightSide);
                } else {
-                       $syntaxTreeNode->setRenderingContext($this->renderingContext);
-                       return $this->convertToBoolean($syntaxTreeNode->evaluate());
+                       return $this->convertToBoolean($syntaxTreeNode->evaluate($renderingContext));
                }
        }
 
index 3da14ac..29058e2 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Template parser building up an object syntax tree
  *
- * @version $Id$
+ * @version $Id: TemplateParser.php 4663 2010-06-29 10:45:48Z k-fish $
  * @package Fluid
  * @subpackage Core\Parser
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -269,7 +269,7 @@ class Tx_Fluid_Core_Parser_TemplateParser {
 
        /**
         * Set the configuration for the parser.
-        *h
+        *
         * @param Tx_Fluid_Core_Parser_Configuration $configuration
         * @return void
         * @author Karsten Dambekalns <karsten@typo3.org>
index 61181e6..13b54ef 100644 (file)
 /**
  *
  *
- * @version $Id$
+ * @version $Id: RenderingContext.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage Core\Rendering
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class Tx_Fluid_Core_Rendering_RenderingContext {
+class Tx_Fluid_Core_Rendering_RenderingContext implements Tx_Fluid_Core_Rendering_RenderingContextInterface {
 
        /**
         * Template Variable Container. Contains all variables available through object accessors in the template
+        *
         * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
         */
        protected $templateVariableContainer;
@@ -40,18 +41,21 @@ class Tx_Fluid_Core_Rendering_RenderingContext {
        /**
         * Object manager which is bubbled through. The ViewHelperNode cannot get an ObjectManager injected because
         * the whole syntax tree should be cacheable
+        *
         * @var Tx_Fluid_Compatibility_ObjectManager
         */
        protected $objectManager;
 
        /**
         * Controller context being passed to the ViewHelper
+        *
         * @var Tx_Extbase_MVC_Controller_ControllerContext
         */
        protected $controllerContext;
 
        /**
         * ViewHelper Variable Container
+        *
         * @var Tx_Fluid_Core_ViewHelpers_ViewHelperVariableContainer
         */
        protected $viewHelperVariableContainer;
@@ -77,13 +81,13 @@ class Tx_Fluid_Core_Rendering_RenderingContext {
        }
 
        /**
-        * Sets the template variable container containing all variables available through ObjectAccessors
+        * Injects the template variable container containing all variables available through ObjectAccessors
         * in the template
         *
         * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer The template variable container to set
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function setTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
+       public function injectTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
                $this->templateVariableContainer = $templateVariableContainer;
        }
 
@@ -124,7 +128,7 @@ class Tx_Fluid_Core_Rendering_RenderingContext {
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function setViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
+       public function injectViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
                $this->viewHelperVariableContainer = $viewHelperVariableContainer;
        }
 
diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContextInterface.php b/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContextInterface.php
new file mode 100644 (file)
index 0000000..5813f76
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ *
+ *
+ * @version $Id: RenderingContext.php 4653 2010-06-28 18:52:33Z sebastian $
+ * @package Fluid
+ * @subpackage Core\Rendering
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_Rendering_RenderingContextInterface {
+
+       /**
+        * Returns the object manager. Only the ViewHelperNode should do this.
+        *
+        * @param Tx_Fluid_Compatibility_ObjectManager $objectManager
+        */
+       public function getObjectManager();
+
+       /**
+        * Injects the template variable container containing all variables available through ObjectAccessors
+        * in the template
+        *
+        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer The template variable container to set
+        */
+       public function injectTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer);
+
+       /**
+        * Get the template variable container
+        *
+        * @return Tx_Fluid_Core_ViewHelper_TemplateVariableContainer The Template Variable Container
+        */
+       public function getTemplateVariableContainer();
+
+       /**
+        * Set the controller context which will be passed to the ViewHelper
+        *
+        * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext The controller context to set
+        */
+       public function setControllerContext(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext);
+
+       /**
+        * Get the controller context which will be passed to the ViewHelper
+        *
+        * @return Tx_Extbase_MVC_Controller_ControllerContext The controller context to set
+        */
+       public function getControllerContext();
+
+       /**
+        * Set the ViewHelperVariableContainer
+        *
+        * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer
+        * @return void
+        */
+       public function injectViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer);
+
+       /**
+        * Get the ViewHelperVariableContainer
+        *
+        * @return Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
+        */
+       public function getViewHelperVariableContainer();
+}
+?>
\ No newline at end of file
index 33e55af..72a4601 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * The abstract base class for all view helpers.
  *
- * @version $Id$
+ * @version $Id: AbstractViewHelper.php 4836 2010-07-12 18:12:29Z sebastian $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -72,6 +72,11 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
        protected $controllerContext;
 
        /**
+        * @var Tx_Fluid_Core_Rendering_RenderingContextInterface
+        */
+       private $renderingContext;
+
+       /**
         * ViewHelper Variable Container
         * @var Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
         * @api
@@ -120,6 +125,16 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
        }
 
        /**
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+        $this->renderingContext = $renderingContext;
+       }
+
+
+       /**
         * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
@@ -206,7 +221,7 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
         * @api
         */
        protected function renderChildren() {
-               return $this->viewHelperNode->evaluateChildNodes();
+               return $this->viewHelperNode->evaluateChildNodes($this->renderingContext);
        }
 
        /**
@@ -333,6 +348,21 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
         * @api
         */
        //abstract public function render();
+
+       /**
+        * Get the rendering context interface.
+        * THIS METHOD IS NO PUBLIC API AND ONLY CALLABLE INSIDE THE FRAMEWORK!
+        *
+        * @return Tx_Fluid_Core_Rendering_RenderingContextInterface
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getRenderingContext() {
+               if ($this instanceof Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface) {
+                       return $this->renderingContext;
+               } else {
+                       throw new Tx_Fluid_Core_ViewHelper_Exception_RenderingContextNotAccessibleException('It is forbidden to call getRenderingContext() if you do not implement Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface. But beware, this interface is NO PUBLIC API! If you want to implement conditions, you should subclass Tx_Fluid_Core_ViewHelper_ConditionViewHelper.', 127895038);
+               }
+       }
 }
 
 ?>
\ No newline at end of file
index 7fb51cd..b5dd226 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Argument definition of each view helper argument
  *
- * @version $Id$
+ * @version $Id: ArgumentDefinition.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 661c9c8..84cb32c 100644 (file)
@@ -25,7 +25,7 @@
  * Is available inside every view helper as $this->arguments - and you use it as if it was an array.
  * However, you can only read, and not write to it.
  *
- * @version $Id$
+ * @version $Id: Arguments.php 4483 2010-06-10 13:57:32Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/ConditionViewHelper.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/ConditionViewHelper.php
new file mode 100644 (file)
index 0000000..9159b6c
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * This view helper is an abstract ViewHelper which implements an if/else condition.
+ * @see Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode::convertArgumentValue() to find see how boolean arguments are evaluated
+ *
+ * = Usage =
+ *
+ * To create a custom Condition ViewHelper, you need to subclass this class, and
+ * implement your own render() method. Inside there, you should call $this->renderThenChild()
+ * if the condition evaluated to TRUE, and $this->renderElseChild() if the condition evaluated
+ * to FALSE.
+ *
+ * Every Condition ViewHelper has a "then" and "else" argument, so it can be used like:
+ * <[aConditionViewHelperName] .... then="condition true" else="condition false" />,
+ * or as well use the "then" and "else" child nodes.
+ *
+ * @see Tx_Fluid_ViewHelpers_IfViewHelper for a more detailed explanation and a simple usage example.
+ * Make sure to NOT OVERRIDE the constructor.
+ *
+ * @version $Id: IfViewHelper.php 4671 2010-06-30 08:25:50Z robert $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+abstract class Tx_Fluid_Core_ViewHelper_ConditionViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
+
+       /**
+        * An array of Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode
+        * @var array
+        */
+       private $childNodes = array();
+
+       /**
+        * Setter for ChildNodes - as defined in ChildNodeAccessInterface
+        *
+        * @param array $childNodes Child nodes of this syntax tree node
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setChildNodes(array $childNodes) {
+               $this->childNodes = $childNodes;
+       }
+
+       /**
+        * Initializes the "then" and "else" arguments
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct() {
+               $this->registerArgument('then', 'mixed', 'Value to be returned if the condition if met.', FALSE);
+               $this->registerArgument('else', 'mixed', 'Value to be returned if the condition if not met.', FALSE);
+       }
+
+       /**
+        * Returns value of "then" attribute.
+        * If then attribute is not set, iterates through child nodes and renders ThenViewHelper.
+        * If then attribute is not set and no ThenViewHelper is found, all child nodes are rendered
+        *
+        * @return string rendered ThenViewHelper or contents of <f:if> if no ThenViewHelper was found
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       protected function renderThenChild() {
+               if ($this->arguments->hasArgument('then')) {
+                       return $this->arguments['then'];
+               }
+               foreach ($this->childNodes as $childNode) {
+                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'Tx_Fluid_ViewHelpers_ThenViewHelper') {
+                               $data = $childNode->evaluate($this->getRenderingContext());
+                               return $data;
+                       }
+               }
+               return $this->renderChildren();
+       }
+
+       /**
+        * Returns value of "else" attribute.
+        * If else attribute is not set, iterates through child nodes and renders ElseViewHelper.
+        * If else attribute is not set and no ElseViewHelper is found, an empty string will be returned.
+        *
+        * @return string rendered ElseViewHelper or an empty string if no ThenViewHelper was found
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       protected function renderElseChild() {
+               foreach ($this->childNodes as $childNode) {
+                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'Tx_Fluid_ViewHelpers_ElseViewHelper') {
+                               return $childNode->evaluate($this->getRenderingContext());
+                       }
+               }
+               if ($this->arguments->hasArgument('else')) {
+                       return $this->arguments['else'];
+               }
+               return '';
+       }
+}
+
+?>
\ No newline at end of file
index d5fcb71..1e1048f 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A ViewHelper Exception
  *
- * @version $Id$
+ * @version $Id: Exception.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 0c88b2b..0c858fa 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A "Invalid Variable" exception.
  *
- * @version $Id$
+ * @version $Id: InvalidVariableException.php 4483 2010-06-10 13:57:32Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper\Exception
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/Exception/RenderingContextNotAccessibleException.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/Exception/RenderingContextNotAccessibleException.php
new file mode 100644 (file)
index 0000000..76bf440
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A "Rendering Context not Accessible" exception.
+ *
+ * @version $Id: InvalidVariableException.php 4483 2010-06-10 13:57:32Z k-fish $
+ * @package Fluid
+ * @subpackage Core\ViewHelper\Exception
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_Core_ViewHelper_Exception_RenderingContextNotAccessibleException extends Tx_Fluid_Core_ViewHelper_Exception {
+}
+
+?>
\ No newline at end of file
index 7f8312a..9ad53f4 100644 (file)
  * need access to the direct children in the Syntax Tree at rendering-time.
  * This might happen if you only want to selectively render a part of the syntax
  * tree depending on some conditions.
+ * To render subnodes, you can fetch the RenderingContext via $this->getRenderingContext().
  *
- * In most cases, you will not need this view helper.
+ * In most cases, you will not need this facet, and it is NO PUBLIC API!
+ * Right now it is only used internally for conditions, so by subclassing Tx_Fluid_Core_ViewHelpers_ConditionViewHelper, this should be all you need.
  *
  * See Tx_Fluid_ViewHelpers_IfViewHelper for an example how it is used.
  *
- * @version $Id$
+ * @version $Id: ChildNodeAccessInterface.php 4836 2010-07-12 18:12:29Z sebastian $
  * @package Fluid
  * @subpackage Core\ViewHelper\Facets
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 interface Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
-
        /**
         * Sets the direct child nodes of the current syntax tree node.
         *
@@ -44,15 +45,6 @@ interface Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
         * @return void
         */
        public function setChildNodes(array $childNodes);
-
-       /**
-        * Sets the rendering context which needs to be passed on to child nodes
-        *
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext the renderingcontext to use
-        * @return void
-        */
-       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext);
-
 }
 
 ?>
\ No newline at end of file
index 71aeb1f..f7b9199 100644 (file)
@@ -32,7 +32,7 @@
  *
  * Normally, this facet is not needed, except in really really rare cases.
  *
- * @version $Id$
+ * @version $Id: PostParseInterface.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper\Facets
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index f58baa2..46fae53 100644 (file)
@@ -25,7 +25,7 @@
  * Sould be used as the base class for all view helpers which output simple tags, as it provides some
  * convenience methods to register default attributes, ...
  *
- * @version $Id$
+ * @version $Id: TagBasedViewHelper.php 3950 2010-03-15 18:54:23Z sebastian $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 61d9839..7bc92ac 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Tag builder. Can be easily accessed in TagBasedViewHelper
  *
- * @version $Id$
+ * @version $Id: TagBuilder.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index c451719..f117d8d 100644 (file)
@@ -27,7 +27,7 @@
  * 1) Holds the current variables in the template
  * 2) Holds variables being set during Parsing (set in view helpers implementing the PostParse facet)
  *
- * @version $Id$
+ * @version $Id: TemplateVariableContainer.php 4678 2010-06-30 14:31:14Z robert $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -112,6 +112,16 @@ class Tx_Fluid_Core_ViewHelper_TemplateVariableContainer implements ArrayAccess
        }
 
        /**
+        * Returns the variables array.
+        *
+        * @return array Identifiers and values of all variables
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function getAll() {
+               return $this->variables;
+       }
+
+       /**
         * Checks if this property exists in the VariableContainer.
         *
         * @param string $identifier
index 688dde1..d10e441 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id$
+ * @version $Id: ViewHelperInterface.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index b74c80f..1c7c433 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id$
+ * @version $Id: ViewHelperVariableContainer.php 4483 2010-06-10 13:57:32Z k-fish $
  * @package Fluid
  * @subpackage Core\ViewHelper
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -39,7 +39,7 @@ class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer {
 
        /**
         *
-        * @var Tx_Extbase_MVC_View_ViewInterface
+        * @var Tx_Fluid_View_AbstractTemplateView
         */
        protected $view;
 
@@ -126,11 +126,11 @@ class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer {
        /**
         * Set the view to pass it to ViewHelpers.
         *
-        * @param Tx_Extbase_MVC_View_ViewInterface $view View to set
+        * @param Tx_Fluid_View_AbstractTemplateView $view View to set
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function setView(Tx_Extbase_MVC_View_ViewInterface $view) {
+       public function setView(Tx_Fluid_View_AbstractTemplateView $view) {
                $this->view = $view;
        }
 
@@ -139,7 +139,7 @@ class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer {
         *
         * !!! This is NOT a public API and might still change!!!
         *
-        * @return Tx_Extbase_MVC_View_ViewInterface The View
+        * @return Tx_Fluid_View_AbstractTemplateView The View
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function getView() {
index 2400bde..908e705 100644 (file)
@@ -24,7 +24,7 @@
  * XML Schema (XSD) Generator. Will generate an XML schema which can be used for autocompletion
  * in schema-aware editors like Eclipse XML editor.
  *
- * @version $Id$
+ * @version $Id: DocbookGenerator.php 3835 2010-02-22 15:15:17Z robert $
  * @package Fluid
  * @subpackage Service
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
diff --git a/typo3/sysext/fluid/Classes/View/AbstractTemplateView.php b/typo3/sysext/fluid/Classes/View/AbstractTemplateView.php
new file mode 100644 (file)
index 0000000..4e22618
--- /dev/null
@@ -0,0 +1,385 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Abstract Fluid Template View.
+ *
+ * Contains the fundamental methods which any Fluid based template view needs.
+ *
+ * @version $Id: TemplateView.php 4607 2010-06-22 06:02:55Z sebastian $
+ * @package Fluid
+ * @subpackage View
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class Tx_Fluid_View_AbstractTemplateView implements Tx_Fluid_View_TemplateViewInterface {
+
+       /**
+        * Constants defining possible rendering types
+        */
+       const RENDERING_TEMPLATE = 1;
+       const RENDERING_PARTIAL = 2;
+       const RENDERING_LAYOUT = 3;
+
+       /**
+        * @var \Tx_Extbase_MVC_Controller_ControllerContext
+        */
+       protected $controllerContext;
+
+       /**
+        * @var \Tx_Fluid_Compatibility_ObjectManager
+        */
+       protected $objectManager;
+
+       /**
+        * @var Tx_Fluid_Core_Parser_TemplateParser
+        */
+       protected $templateParser;
+
+       /**
+        * The initial rendering context for this template view.
+        * Due to the rendering stack, another rendering context might be active
+        * at certain points while rendering the template.
+        *
+        * @var Tx_Fluid_Core_Rendering_RenderingContextInterface
+        */
+       protected $baseRenderingContext;
+
+       /**
+        * Stack containing the current rendering type, the current rendering context, and the current parsed template
+        * Do not manipulate directly, instead use the methods"getCurrent*()", "startRendering(...)" and "stopRendering()"
+        * @var array
+        */
+       protected $renderingStack = array();
+
+       /**
+        * Injects the Object Manager
+        *
+        * @param Tx_Fluid_Compatibility_ObjectManager $objectManager
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function injectObjectManager(Tx_Fluid_Compatibility_ObjectManager $objectManager) {
+               $this->objectManager = $objectManager;
+       }
+
+       /**
+        * Inject the Template Parser
+        *
+        * @param Tx_Fluid_Core_Parser_TemplateParser $templateParser The template parser
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectTemplateParser(Tx_Fluid_Core_Parser_TemplateParser $templateParser) {
+               $this->templateParser = $templateParser;
+       }
+
+       /**
+        * Injects a fresh rendering context
+        *
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               $this->baseRenderingContext = $renderingContext;
+               $this->baseRenderingContext->getViewHelperVariableContainer()->setView($this);
+               $this->controllerContext = $renderingContext->getControllerContext();
+       }
+
+       /**
+        * Sets the current controller context
+        *
+        * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        * @api
+        */
+       public function setControllerContext(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext) {
+               $this->controllerContext = $controllerContext;
+       }
+
+       /**
+        * Assign a value to the variable container.
+        *
+        * @param string $key The key of a view variable to set
+        * @param mixed $value The value of the view variable
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        * @api
+        */
+       public function assign($key, $value) {
+               $templateVariableContainer = $this->baseRenderingContext->getTemplateVariableContainer();
+               if ($templateVariableContainer->exists($key)) {
+                       $templateVariableContainer->remove($key);
+               }
+               $templateVariableContainer->add($key, $value);
+       }
+
+       /**
+        * Assigns multiple values to the JSON output.
+        * However, only the key "value" is accepted.
+        *
+        * @param array $values Keys and values - only a value with key "value" is considered
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        * @api
+        */
+       public function assignMultiple(array $values) {
+               $templateVariableContainer = $this->baseRenderingContext->getTemplateVariableContainer();
+               foreach ($values as $key => $value) {
+                       if ($templateVariableContainer->exists($key)) {
+                               $templateVariableContainer->remove($key);
+                       }
+                       $templateVariableContainer->add($key, $value);
+               }
+       }
+
+       /**
+        * Loads the template source and render the template.
+        * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
+        *
+        * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
+        * @return string Rendered Template
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Robert Lemke <robert@typo3.org>
+        * @api
+        */
+       public function render($actionName = NULL) {
+               $this->baseRenderingContext->setControllerContext($this->controllerContext);
+               $this->templateParser->setConfiguration($this->buildParserConfiguration());
+               $parsedTemplate = $this->templateParser->parse($this->getTemplateSource($actionName));
+
+               if ($this->isLayoutDefinedInTemplate($parsedTemplate)) {
+                       $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext);
+                       $parsedLayout = $this->templateParser->parse($this->getLayoutSource($this->getLayoutNameInTemplate($parsedTemplate)));
+                       $output = $parsedLayout->render($this->baseRenderingContext);
+                       $this->stopRendering();
+               } else {
+                       $this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext);
+                       $output = $parsedTemplate->render($this->baseRenderingContext);
+                       $this->stopRendering();
+               }
+
+               return $output;
+       }
+
+       /**
+        * Renders a given section.
+        *
+        * @param string $sectionName Name of section to render
+        * @param array the variables to use.
+        * @return string rendered template for the section
+        * @throws Tx_Fluid_View_Exception_InvalidSectionException
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderSection($sectionName, array $variables) {
+               $parsedTemplate = $this->getCurrentParsedTemplate();
+
+               $sections = $parsedTemplate->getVariableContainer()->get('sections');
+               if(!array_key_exists($sectionName, $sections)) {
+                       throw new Tx_Fluid_View_Exception_InvalidSectionException('The given section does not exist!', 1227108982);
+               }
+               $section = $sections[$sectionName];
+
+               $renderingContext = $this->getCurrentRenderingContext();
+               if ($this->getCurrentRenderingType() === self::RENDERING_LAYOUT) {
+                       // in case we render a layout right now, we will render a section inside a TEMPLATE.
+                       $renderingTypeOnNextLevel = self::RENDERING_TEMPLATE;
+               } else {
+                       $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
+                       $renderingContext = clone $renderingContext;
+                       $renderingContext->injectTemplateVariableContainer($variableContainer);
+                       $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
+               }
+
+               $renderingContext->getViewHelperVariableContainer()->add('Tx_Fluid_ViewHelpers_SectionViewHelper', 'isCurrentlyRenderingSection', 'TRUE');
+
+               $this->startRendering($renderingTypeOnNextLevel, $parsedTemplate, $renderingContext);
+               $output = $section->evaluate($renderingContext);
+               $this->stopRendering();
+
+               return $output;
+       }
+
+       /**
+        * Renders a partial.
+        *
+        * @param string $partialName
+        * @param string $sectionName
+        * @param array $variables
+        * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer the View Helper Variable container to use.
+        * @return string
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function renderPartial($partialName, $sectionName, array $variables) {
+               $partial = $this->templateParser->parse($this->getPartialSource($partialName));
+               $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
+               $renderingContext = clone $this->getCurrentRenderingContext();
+               $renderingContext->injectTemplateVariableContainer($variableContainer);
+
+               $this->startRendering(self::RENDERING_PARTIAL, $partial, $renderingContext);
+               if ($sectionName !== NULL) {
+                       $output = $this->renderSection($sectionName, $variables);
+               } else {
+                       $output = $partial->render($renderingContext);
+               }
+               $this->stopRendering();
+
+               return $output;
+       }
+
+       /**
+        * Resolve the template path and filename for the given action. If $actionName
+        * is NULL, looks into the current request.
+        *
+        * @param string $actionName Name of the action. If NULL, will be taken from request.
+        * @return string Full path to template
+        * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException in case the template was not found
+        */
+       abstract protected function getTemplateSource($actionName);
+
+       /**
+        * Resolve the path and file name of the layout file, based on
+        * $this->layoutPathAndFilename and $this->layoutPathAndFilenamePattern.
+        *
+        * In case a layout has already been set with setLayoutPathAndFilename(),
+        * this method returns that path, otherwise a path and filename will be
+        * resolved using the layoutPathAndFilenamePattern.
+        *
+        * @param string $layoutName Name of the layout to use. If none given, use "default"
+        * @return string Path and filename of layout file
+        * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
+        */
+       abstract protected function getLayoutSource($layoutName = 'default');
+
+       /**
+        * Figures out which partial to use.
+        *
+        * @param string $partialName The name of the partial
+        * @return string the full path which should be used. The path definitely exists.
+        * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
+        */
+       abstract protected function getPartialSource($partialName);
+
+       /**
+        * Build parser configuration
+        *
+        * @return Tx_Fluid_Core_Parser_Configuration
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       protected function buildParserConfiguration() {
+               $parserConfiguration = $this->objectManager->create('Tx_Fluid_Core_Parser_Configuration');
+               if ($this->controllerContext->getRequest()->getFormat() === 'html') {
+                       $parserConfiguration->addInterceptor($this->objectManager->get('Tx_Fluid_Core_Parser_Interceptor_Escape'));
+                       
+               }
+               return $parserConfiguration;
+       }
+
+       /**
+        * Returns TRUE if there is a layout defined in the given template via a <f:layout name="..." /> tag.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate
+        * @return boolean TRUE if a layout has been defined, FALSE otherwise.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function isLayoutDefinedInTemplate(Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate) {
+               $variableContainer = $parsedTemplate->getVariableContainer();
+               return ($variableContainer !== NULL && $variableContainer->exists('layoutName'));
+       }
+
+       /**
+        * Returns the name of the layout defined in the template, if one exists.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate
+        * @return string the Layout name
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getLayoutNameInTemplate(Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate) {
+               if ($this->isLayoutDefinedInTemplate($parsedTemplate)) {
+                       return $parsedTemplate->getVariableContainer()->get('layoutName');
+               }
+               return NULL;
+       }
+
+       /**
+        * Start a new nested rendering. Pushes the given information onto the $renderingStack.
+        *
+        * @param int $type one of the RENDERING_* constants
+        * @param Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function startRendering($type, Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate, Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
+               array_push($this->renderingStack, array('type' => $type, 'parsedTemplate' => $parsedTemplate, 'renderingContext' => $renderingContext));
+       }
+
+       /**
+        * Stops the current rendering. Removes one element from the $renderingStack. Make sure to always call this
+        * method pair-wise with startRendering().
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function stopRendering() {
+               array_pop($this->renderingStack);
+       }
+
+       /**
+        * Get the current rendering type.
+        *
+        * @return one of RENDERING_* constants
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getCurrentRenderingType() {
+               $currentRendering = end($this->renderingStack);
+               return $currentRendering['type'];
+       }
+
+       /**
+        * Get the parsed template which is currently being rendered.
+        *
+        * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getCurrentParsedTemplate() {
+               $currentRendering = end($this->renderingStack);
+               return $currentRendering['parsedTemplate'];
+       }
+
+       /**
+        * Get the rendering context which is currently used.
+        *
+        * @return Tx_Fluid_Core_Rendering_RenderingContextInterface
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getCurrentRenderingContext() {
+               $currentRendering = end($this->renderingStack);
+               return $currentRendering['renderingContext'];
+       }
+}
+
+?>
\ No newline at end of file
index b43d394..8434b88 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A generic Fluid View exception.
  *
- * @version $Id$
+ * @version $Id: Exception.php 3431 2009-11-03 11:18:01Z robert $
  * @package Fluid
  * @subpackage View
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 15db8b8..650361d 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * An "Invalid Section" exception
  *
- * @version $Id$
+ * @version $Id: InvalidSectionException.php 4483 2010-06-10 13:57:32Z k-fish $
  * @package Fluid
  * @subpackage View\Exception
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 048020a..0dff007 100644 (file)
 /**
  * The main template view. Should be used as view if you want Fluid Templating
  *
- * @version $Id$
+ * @version $Id: TemplateView.php 4653 2010-06-28 18:52:33Z sebastian $
  * @package Fluid
  * @subpackage View
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @api
  * @scope prototype
  */
-class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implements Tx_Fluid_View_TemplateViewInterface {
-
-       /**
-        * @var Tx_Fluid_Core_Parser_TemplateParser
-        */
-       protected $templateParser;
+class Tx_Fluid_View_TemplateView extends Tx_Fluid_View_AbstractTemplateView {
 
        /**
         * Pattern to be resolved for @templateRoot in the other patterns.
@@ -104,31 +99,15 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
        protected $layoutPathAndFilename = NULL;
 
        public function __construct() {
-                                               $this->templateParser = Tx_Fluid_Compatibility_TemplateParserBuilder::build();
-                                               $this->objectManager = t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectManager');
-                                       }
-       // Here, the backporter can insert a constructor method, which is needed for Fluid v4.
-
-       /**
-        * Inject the template parser
-        *
-        * @param Tx_Fluid_Core_Parser_TemplateParser $templateParser The template parser
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       public function injectTemplateParser(Tx_Fluid_Core_Parser_TemplateParser $templateParser) {
-               $this->templateParser = $templateParser;
-       }
+                       $this->injectTemplateParser(Tx_Fluid_Compatibility_TemplateParserBuilder::build());
+                       $this->injectObjectManager(t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectManager'));
+                       $this->setRenderingContext($this->objectManager->create('Tx_Fluid_Core_Rendering_RenderingContext'));
+               }
 
-       /**
-        * Initialize view
-        *
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @api
-        */
-       public function initializeView() {
-       }
+               public function initializeView() {
+               }
+                                       
+       // Here, the backporter can insert a constructor method, which is needed for Fluid v4.
 
        /**
         * Sets the path and name of of the template file. Effectively overrides the
@@ -156,66 +135,33 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
        }
 
        /**
-        * Build the rendering context
-        *
-        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer
-        * @return Tx_Fluid_Core_Rendering_RenderingContext
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function buildRenderingContext(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer = NULL) {
-               if ($variableContainer === NULL) {
-                       $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $this->variables);
-               }
-
-               $renderingContext = $this->objectManager->create('Tx_Fluid_Core_Rendering_RenderingContext');
-               $renderingContext->setTemplateVariableContainer($variableContainer);
-               if ($this->controllerContext !== NULL) {
-                       $renderingContext->setControllerContext($this->controllerContext);
-               }
-
-               $viewHelperVariableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
-               $viewHelperVariableContainer->setView($this);
-               $renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
-
-               return $renderingContext;
-       }
-
-       /**
-        * Build parser configuration
+        * Checks whether a template can be resolved for the current request context.
         *
-        * @return Tx_Fluid_Core_Parser_Configuration
+        * @return boolean
         * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
         */
-       protected function buildParserConfiguration() {
-               $parserConfiguration = $this->objectManager->create('Tx_Fluid_Core_Parser_Configuration');
-               if ($this->controllerContext->getRequest()->getFormat() === 'html') {
-                       $parserConfiguration->addInterceptor($this->objectManager->get('Tx_Fluid_Core_Parser_Interceptor_Escape'));
-                       
+       public function hasTemplate() {
+               try {
+                       $this->getTemplateSource();
+                       return TRUE;
+               } catch (Tx_Fluid_View_Exception_InvalidTemplateResourceException $e) {
+                       return FALSE;
                }
-               return $parserConfiguration;
        }
 
-       /**
-        * Find the XHTML template according to $this->templatePathAndFilenamePattern and render the template.
-        * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
+               /**
+        * Set the root path to the templates.
+        * If set, overrides the one determined from $this->templateRootPathPattern
         *
-        * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
-        * @return string Rendered Template
+        * @param string $templateRootPath Root path to the templates. If set, overrides the one determined from $this->templateRootPathPattern
+        * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @api
         */
-       public function render($actionName = NULL) {
-               $templatePathAndFilename = $this->resolveTemplatePathAndFilename($actionName);
-
-               $this->templateParser->setConfiguration($this->buildParserConfiguration());
-               $parsedTemplate = $this->parseTemplate($templatePathAndFilename);
-
-               $variableContainer = $parsedTemplate->getVariableContainer();
-               if ($variableContainer !== NULL && $variableContainer->exists('layoutName')) {
-                       return $this->renderWithLayout($variableContainer->get('layoutName'));
-               }
-
-               return $parsedTemplate->render($this->buildRenderingContext());
+       public function setTemplateRootPath($templateRootPath) {
+               $this->templateRootPath = $templateRootPath;
        }
 
        /**
@@ -227,68 +173,39 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
         * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       protected function resolveTemplatePathAndFilename($actionName = NULL) {
+       protected function getTemplateSource($actionName = NULL) {
                if ($this->templatePathAndFilename !== NULL) {
-                       return $this->templatePathAndFilename;
-               }
-
-               $actionName = ($actionName !== NULL ? $actionName : $this->controllerContext->getRequest()->getControllerActionName());
-               $actionName = ucfirst($actionName);
-
-               $paths = $this->expandGenericPathPattern($this->templatePathAndFilenamePattern, FALSE, FALSE);
-
-               foreach ($paths as &$path) {
-                       // TODO remove fallback to lower case template files after grace period
-                       $fallbackPath = str_replace('@action', strtolower($actionName), $path);
-                       $path = str_replace('@action', $actionName, $path);
-                       if (file_exists($path)) {
-                               return $path;
-                       } else {
-                               if (file_exists($fallbackPath)) {
-                                       t3lib_div::deprecationLog('the template filename "' . $fallbackPath . '" is lowercase. This is deprecated since TYPO3 4.4. Please rename the template to "' . basename($path) . '"');
-                                       return $fallbackPath;
+                       $templatePathAndFilename = $this->templatePathAndFilename;
+               } else {
+                       $actionName = ($actionName !== NULL ? $actionName : $this->controllerContext->getRequest()->getControllerActionName());
+                       $actionName = ucfirst($actionName);
+
+                       $paths = $this->expandGenericPathPattern($this->templatePathAndFilenamePattern, FALSE, FALSE);
+                       $found = FALSE;
+                       foreach ($paths as &$templatePathAndFilename) {
+                               // These tokens are replaced by the Backporter for the graceful fallback in version 4.
+                               $fallbackPath = str_replace('@action', strtolower($actionName), $templatePathAndFilename);
+                               $templatePathAndFilename = str_replace('@action', $actionName, $templatePathAndFilename);
+                               if (file_exists($templatePathAndFilename)) {
+                                       $found = TRUE;
+                                       break;
+                               }  elseif (file_exists($fallbackPath)) {
+                                       $found = TRUE;
+                                       $templatePathAndFilename = $fallbackPath;
+                                       t3lib_div::deprecationLog('the template filename "' . $fallbackPath . '" is lowercase. This is deprecated since TYPO3 4.4. Please rename the template to "' . basename($templatePathAndFilename) . '"');
+                                       break;
                                }
                        }
+                       if (!$found) {
+                               throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('Template could not be loaded. I tried "' . implode('", "', $paths) . '"', 1225709595);
+                       }
                }
-               throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('Template could not be loaded. I tried "' . implode('", "', $paths) . '"', 1225709595);
-       }
 
-       /**
-        * Renders a given section.
-        *
-        * @param string $sectionName Name of section to render
-        * @return string rendered template for the section
-        * @throws Tx_Fluid_View_Exception_InvalidSectionException
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function renderSection($sectionName) {
-               $parsedTemplate = $this->parseTemplate($this->resolveTemplatePathAndFilename());
-
-               $sections = $parsedTemplate->getVariableContainer()->get('sections');
-               if(!array_key_exists($sectionName, $sections)) {
-                       throw new Tx_Fluid_View_Exception_InvalidSectionException('The given section does not exist!', 1227108982);
+               $templateSource = file_get_contents($templatePathAndFilename);
+               if ($templateSource === FALSE) {
+                       throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
                }
-               $section = $sections[$sectionName];
-
-               $renderingContext = $this->buildRenderingContext();
-               $section->setRenderingContext($renderingContext);
-               return $section->evaluate();
-       }
-
-       /**
-        * Render a template with a given layout.
-        *
-        * @param string $layoutName Name of layout
-        * @return string rendered HTML
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function renderWithLayout($layoutName) {
-               $parsedTemplate = $this->parseTemplate($this->resolveLayoutPathAndFilename($layoutName));
-
-               $renderingContext = $this->buildRenderingContext();
-               return $parsedTemplate->render($renderingContext);
+               return $templateSource;
        }
 
        /**
@@ -304,41 +221,30 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
         * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       protected function resolveLayoutPathAndFilename($layoutName = 'default') {
-               if ($this->layoutPathAndFilename) {
-                       return $this->layoutPathAndFilename;
-               }
+       protected function getLayoutSource($layoutName = 'default') {
+               if ($this->layoutPathAndFilename !== NULL) {
+                        $layoutPathAndFilename = $this->layoutPathAndFilename;
+               } else {
+                       $paths = $this->expandGenericPathPattern($this->layoutPathAndFilenamePattern, TRUE, TRUE);
+                       $found = FALSE;
+                       foreach ($paths as &$layoutPathAndFilename) {
+                               $layoutPathAndFilename = str_replace('@layout', $layoutName, $layoutPathAndFilename);
+                               if (file_exists($layoutPathAndFilename)) {
+                                       $found = TRUE;
+                                       break;
+                               }
+                       }
 
-               $paths = $this->expandGenericPathPattern($this->layoutPathAndFilenamePattern, TRUE, TRUE);
-               foreach ($paths as &$path) {
-                       $path = str_replace('@layout', $layoutName, $path);
-                       if (file_exists($path)) {
-                               return $path;
+                       if (!$found) {
+                               throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
                        }
                }
-               throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
-       }
 
-       /**
-        * Renders a partial.
-        *
-        * @param string $partialName
-        * @param string $sectionToRender
-        * @param array $variables
-        * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer the View Helper Variable container to use.
-        * @return string
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function renderPartial($partialName, $sectionToRender, array $variables, $viewHelperVariableContainer = NULL) {
-               $partial = $this->parseTemplate($this->resolvePartialPathAndFilename($partialName));
-               $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
-               $renderingContext = $this->buildRenderingContext($variableContainer);
-               if ($viewHelperVariableContainer !== NULL) {
-                       $renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
+               $layoutSource = file_get_contents($layoutPathAndFilename);
+               if ($layoutSource === FALSE) {
+                       throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('"' . $layoutPathAndFilename . '" is not a valid template resource URI.', 1257246929);
                }
-               return $partial->render($renderingContext);
+               return $layoutSource;
        }
 
        /**
@@ -349,63 +255,24 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
         * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       protected function resolvePartialPathAndFilename($partialName) {
+       protected function getPartialSource($partialName) {
                $paths = $this->expandGenericPathPattern($this->partialPathAndFilenamePattern, TRUE, TRUE);
-               foreach ($paths as &$path) {
-                       $path = str_replace('@partial', $partialName, $path);
-                       if (file_exists($path)) {
-                               return $path;
+               $found = FALSE;
+               foreach ($paths as &$partialPathAndFilename) {
+                       $partialPathAndFilename = str_replace('@partial', $partialName, $partialPathAndFilename);
+                       if (file_exists($partialPathAndFilename)) {
+                               $found = TRUE;
+                               break;
                        }
                }
-               throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
-       }
-
-       /**
-        * Checks whether a template can be resolved for the current request context.
-        *
-        * @return boolean
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @api
-        */
-       public function hasTemplate() {
-               try {
-                       $this->resolveTemplatePathAndFilename();
-                       return TRUE;
-               } catch (Tx_Fluid_View_Exception_InvalidTemplateResourceException $e) {
-                       return FALSE;
+               if (!$found) {
+                       throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
                }
-       }
-
-       /**
-        * Parse the given template and return it.
-        *
-        * Will cache the results for one call.
-        *
-        * @param string $templatePathAndFilename absolute filename of the template to be parsed
-        * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface the parsed template tree
-        * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function parseTemplate($templatePathAndFilename) {
-               $templateSource = file_get_contents($templatePathAndFilename);
-               if ($templateSource === FALSE) {
-                       throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
+               $partialSource = file_get_contents($partialPathAndFilename);
+               if ($partialSource === FALSE) {
+                       throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('"' . $partialPathAndFilename . '" is not a valid template resource URI.', 1257246929);
                }
-               return $this->templateParser->parse($templateSource);
-       }
-
-       /**
-        * Set the root path to the templates.
-        * If set, overrides the one determined from $this->templateRootPathPattern
-        *
-        * @param string $templateRootPath Root path to the templates. If set, overrides the one determined from $this->templateRootPathPattern
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @api
-        */
-       public function setTemplateRootPath($templateRootPath) {
-               $this->templateRootPath = $templateRootPath;
+               return $partialSource;
        }
 
        /**
@@ -535,6 +402,7 @@ class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implem
 
                return $results;
        }
+
 }
 
 ?>
\ No newline at end of file
index 5efd040..b9ab38b 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Interface of Fluids Template view
  *
- * @version $Id$
+ * @version $Id: TemplateViewInterface.php 4653 2010-06-28 18:52:33Z sebastian $
  * @package Fluid
  * @subpackage View
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
 interface Tx_Fluid_View_TemplateViewInterface extends Tx_Extbase_MVC_View_ViewInterface {
 
        /**
-        * Sets the path and name of of the template file. Effectively overrides the
-        * dynamic resolving of a template file.
-        *
-        * @param string $templatePathAndFilename Template file path
-        * @return void
-        * @api
-        */
-       public function setTemplatePathAndFilename($templatePathAndFilename);
-
-       /**
-        * Sets the path and name of the layout file. Overrides the dynamic resolving of the layout file.
-        *
-        * @param string $layoutPathAndFilename Path and filename of the layout file
-        * @return void
-        * @api
-        */
-       public function setLayoutPathAndFilename($layoutPathAndFilename);
-
-       /**
-        * Renders a given section.
-        *
-        * @param string $sectionName Name of section to render
-        * @return rendered template for the section
-        * @api
-        */
-       public function renderSection($sectionName);
-
-       /**
-        * Render a template with a given layout.
-        *
-        * @param string $layoutName Name of layout
-        * @return string rendered HTML
-        * @api
-        */
-       public function renderWithLayout($layoutName);
-
-       /**
         * Checks whether a template can be resolved for the current request context.
         *
         * @return boolean
index 82bf779..0bdddb4 100644 (file)
@@ -46,7 +46,7 @@
  * depending on {foo.bar.baz}
  * </output>
  *
- * @version $Id$
+ * @version $Id: AliasViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 8184052..3e3e16c 100644 (file)
@@ -35,7 +35,7 @@
  * (depending on your domain)
  * </output>
  *
- * @version $Id$
+ * @version $Id: BaseViewHelper.php 3954 2010-03-16 08:36:26Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index a018415..2dad183 100644 (file)
@@ -66,11 +66,6 @@ class Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper extends Tx_Fluid_Core_V
        protected $childNodes = array();
 
        /**
-        * @var Tx_Fluid_Core_Rendering_RenderingContext
-        */
-       protected $renderingContext;
-
-       /**
         * Setter for ChildNodes - as defined in ChildNodeAccessInterface
         *
         * @param array $childNodes Child nodes of this syntax tree node
@@ -83,15 +78,6 @@ class Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper extends Tx_Fluid_Core_V
        }
 
        /**
-        * Sets the rendering context which needs to be passed on to child nodes
-        *
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext the renderingcontext to use
-        */
-       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
-               $this->renderingContext = $renderingContext;
-       }
-
-       /**
         * Render FunctionMenu
         *
         * @param string $defaultController
@@ -102,8 +88,7 @@ class Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper extends Tx_Fluid_Core_V
                $options = '';
                foreach ($this->childNodes as $childNode) {
                        if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode) {
-                               $childNode->setRenderingContext($this->renderingContext);
-                               $options .= $childNode->evaluate();
+                               $options .= $childNode->evaluate($this->getRenderingContext());
                        }
                }
                $this->tag->setContent($options);
index c8cf295..008918c 100644 (file)
@@ -51,7 +51,7 @@
  * </ul>
  * </output>
  *
- * @version $Id$
+ * @version $Id: CycleViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index e469ef0..b0d57a0 100644 (file)
@@ -25,7 +25,7 @@
  * 
  * @see Tx_Fluid_ViewHelpers_IfViewHelper
  *
- * @version $Id$
+ * @version $Id: ElseViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 89c0c49..46f7aa5 100644 (file)
@@ -49,7 +49,7 @@
  * </ul>
  * </output>
  *
- * @version $Id$
+ * @version $Id: ForViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index ece9739..4621ca5 100644 (file)
@@ -26,7 +26,7 @@
  * If you set the "property" attribute to the name of the property to resolve from the object, this class will
  * automatically set the name and value of a form element.
  *
- * @version $Id$
+ * @version $Id: AbstractFormFieldViewHelper.php 3617 2010-01-13 16:32:09Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 7f4b891..20c7528 100644 (file)
@@ -26,7 +26,7 @@
  * If you set the "property" attribute to the name of the property to resolve from the object, this class will
  * automatically set the name and value of a form element.
  *
- * @version $Id$
+ * @version $Id: AbstractFormViewHelper.php 3830 2010-02-18 22:32:37Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 34b8a1c..d6d20bc 100644 (file)
@@ -38,7 +38,7 @@
  *   <li>1234567890: Validation errors for argument "newBlog"</li>
  * </ul>
  *
- * @version $Id$
+ * @version $Id: ForViewHelper.php 2378 2009-05-25 20:47:00Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index eb695a4..e458f2f 100644 (file)
@@ -35,7 +35,7 @@
  * You can also use the "property" attribute if you have bound an object to the form.
  * See <f:form> for more documentation.
  *
- * @version $Id$
+ * @version $Id: HiddenViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 7e0a4d4..4013444 100644 (file)
@@ -32,7 +32,7 @@
  * Output:
  * <input type="password" name="myPassword" value="default value" />
  *
- * @version $Id$
+ * @version $Id: TextboxViewHelper.php 3109 2009-08-31 17:22:46Z bwaidelich $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 7f1163e..ac713f4 100644 (file)
@@ -50,7 +50,7 @@
  * <input type="radio" name="user[newsletter]" value="0" /> no
  * (depending on property "newsletter")
  *
- * @version $Id$
+ * @version $Id: RadioViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 7bda959..c587f77 100644 (file)
@@ -60,7 +60,7 @@
  *
  * The "value" property now expects a domain object, and tests for object equivalence.
  *
- * @version $Id$
+ * @version $Id: SelectViewHelper.php 4630 2010-06-24 18:10:18Z bwaidelich $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 59e65ff..e8bd4b3 100644 (file)
@@ -39,7 +39,7 @@
   * Output:
  * <input type="submit" name="mySubmit" value="Send Mail" />
  *
- * @version $Id$
+ * @version $Id: SubmitViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 55994b5..259c0b4 100644 (file)
@@ -33,7 +33,7 @@
  * Output:
  * <textarea name="myTextArea">This is shown inside the textarea</textarea>
  *
- * @version $Id$
+ * @version $Id: TextareaViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 0dc81ab..617172b 100644 (file)
@@ -34,7 +34,7 @@
  * Output:
  * <input type="text" name="myTextBox" value="default value" />
  *
- * @version $Id$
+ * @version $Id: TextboxViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index cb6e58d..77d6f01 100644 (file)
@@ -33,7 +33,7 @@
  * Output:
  * <input type="file" name="file" />
  *
- * @version $Id$
+ * @version $Id: UploadViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Form
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index edfb535..e2ffcca 100644 (file)
@@ -39,7 +39,7 @@
  * Output:
  * 54,321.00 $
  *
- * @version $Id$
+ * @version $Id: CurrencyViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index c69c24d..db949bf 100644 (file)
@@ -57,7 +57,7 @@
  * 1980-12-13
  * (depending on the current date)
  *
- * @version $Id$
+ * @version $Id: DateViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 6329130..7031502 100644 (file)
@@ -33,7 +33,7 @@
  * Output:
  * text with line breaks replaced by <br />
  *
- * @version $Id$
+ * @version $Id: Nl2brViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 165496f..3b502ec 100644 (file)
@@ -40,7 +40,7 @@
  * Output:
  * 423.423,2
  *
- * @version $Id$
+ * @version $Id: NumberViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index e87597c..ff183a2 100644 (file)
@@ -40,7 +40,7 @@
  * Output:
  * TYPO3-=-=-
  *
- * @version $Id$
+ * @version $Id: PaddingViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index abc9555..f21c183 100644 (file)
@@ -48,7 +48,7 @@
  * Output:
  * We love TYPO3
  *
- * @version $Id$
+ * @version $Id: PrintfViewHelper.php 3346 2009-10-22 17:26:10Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers\Format
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 783ab2c..bb7d618 100644 (file)
@@ -74,7 +74,7 @@
  *   </li>
  * </ul>
  *
- * @version $Id$
+ * @version $Id: GroupedForViewHelper.php 4620 2010-06-24 10:03:16Z bwaidelich $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 8093c3f..34ba4c4 100644 (file)
  * Otherwise, everything the value of the "else"-attribute is displayed.
  *
  *
- * @version $Id$
+ * @version $Id: IfViewHelper.php 4836 2010-07-12 18:12:29Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @api
  * @scope prototype
  */
-class Tx_Fluid_ViewHelpers_IfViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
-
-       /**
-        * An array of Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode
-        * @var array
-        */
-       protected $childNodes = array();
-
-       /**
-        * @var Tx_Fluid_Core_Rendering_RenderingContext
-        */
-       protected $renderingContext;
-
-       /**
-        * Setter for ChildNodes - as defined in ChildNodeAccessInterface
-        *
-        * @param array $childNodes Child nodes of this syntax tree node
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @api
-        */
-       public function setChildNodes(array $childNodes) {
-               $this->childNodes = $childNodes;
-       }
-
-       /**
-        * Sets the rendering context which needs to be passed on to child nodes
-        *
-        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext the renderingcontext to use
-        */
-       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
-               $this->renderingContext = $renderingContext;
-       }
+class Tx_Fluid_ViewHelpers_IfViewHelper extends Tx_Fluid_Core_ViewHelper_ConditionViewHelper {
 
        /**
         * renders <f:then> child if $condition is true, otherwise renders <f:else> child.
         *
         * @param boolean $condition View helper condition
-        * @param string $then String to be returned if the condition is met
-        * @param string $else String to be returned if the condition is not met
         * @return string the rendered string
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         * @api
         */
-       public function render($condition, $then = NULL, $else = NULL) {
+       public function render($condition) {
                if ($condition) {
                        return $this->renderThenChild();
                } else {
                        return $this->renderElseChild();
                }
        }
-
-       /**
-        * Returns value of "then" attribute.
-        * If then attribute is not set, iterates through child nodes and renders ThenViewHelper.
-        * If then attribute is not set and no ThenViewHelper is found, all child nodes are rendered
-        *
-        * @return string rendered ThenViewHelper or contents of <f:if> if no ThenViewHelper was found
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       protected function renderThenChild() {
-               if ($this->arguments->hasArgument('then')) {
-                       return $this->arguments['then'];
-               }
-               foreach ($this->childNodes as $childNode) {
-                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
-                               && $childNode->getViewHelperClassName() === 'Tx_Fluid_ViewHelpers_ThenViewHelper') {
-                               $childNode->setRenderingContext($this->renderingContext);
-                               $data = $childNode->evaluate();
-                               return $data;
-                       }
-               }
-               return $this->renderChildren();
-       }
-
-       /**
-        * Returns value of "else" attribute.
-        * If else attribute is not set, iterates through child nodes and renders ElseViewHelper.
-        * If else attribute is not set and no ElseViewHelper is found, an empty string will be returned.
-        *
-        * @return string rendered ElseViewHelper or an empty string if no ThenViewHelper was found
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       protected function renderElseChild() {
-               foreach ($this->childNodes as $childNode) {
-                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
-                               && $childNode->getViewHelperClassName() === 'Tx_Fluid_ViewHelpers_ElseViewHelper') {
-                               $childNode->setRenderingContext($this->renderingContext);
-                               return $childNode->evaluate();
-                       }
-               }
-               if ($this->arguments->hasArgument('else')) {
-                       return $this->arguments['else'];
-               }
-               return '';
-       }
 }
-
 ?>
index d6d53b7..dcd2923 100644 (file)
@@ -26,7 +26,7 @@
  * 
  *
  *
- * @version $Id$
+ * @version $Id: LayoutViewHelper.php 4653 2010-06-28 18:52:33Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -58,8 +58,7 @@ class Tx_Fluid_ViewHelpers_LayoutViewHelper extends Tx_Fluid_Core_ViewHelper_Abs
         */
        static public function postParseEvent(Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
                if (isset($viewHelperArguments['name'])) {
-                       $viewHelperArguments['name']->setRenderingContext(new Tx_Fluid_Core_Rendering_RenderingContext());
-                       $layoutName = $viewHelperArguments['name']->evaluate();
+                       $layoutName = $viewHelperArguments['name']->getText();
                } else {
                        $layoutName = 'default';
                }
index 5d3aa66..57ace64 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  *
- * @version $Id$
+ * @version $Id: RenderViewHelper.php 4607 2010-06-22 06:02:55Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -41,11 +41,11 @@ class Tx_Fluid_ViewHelpers_RenderViewHelper extends Tx_Fluid_Core_ViewHelper_Abs
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @api
         */
-       public function render($section = '', $partial = '', $arguments = array()) {
-               if ($partial !== '') {
-                       return $this->viewHelperVariableContainer->getView()->renderPartial($partial, $section, $arguments, $this->viewHelperVariableContainer);
-               } elseif ($section !== '') {
-                       return $this->viewHelperVariableContainer->getView()->renderSection($section);
+       public function render($section = NULL, $partial = NULL, $arguments = array()) {
+               if ($partial !== NULL) {
+                       return $this->viewHelperVariableContainer->getView()->renderPartial($partial, $section, $arguments);
+               } elseif ($section !== NULL) {
+                       return $this->viewHelperVariableContainer->getView()->renderSection($section, $arguments);
                }
                return '';
        }
index f627ba1..769d4f9 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * A Section view helper
  *
- * @version $Id$
+ * @version $Id: SectionViewHelper.php 4653 2010-06-28 18:52:33Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -54,9 +54,7 @@ class Tx_Fluid_ViewHelpers_SectionViewHelper extends Tx_Fluid_Core_ViewHelper_Ab
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        static public function postParseEvent(Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
-               $viewHelperArguments['name']->setRenderingContext(new Tx_Fluid_Core_Rendering_RenderingContext());
-
-               $sectionName = $viewHelperArguments['name']->evaluate();
+               $sectionName = $viewHelperArguments['name']->getText();
                if (!$variableContainer->exists('sections')) {
                        $variableContainer->add('sections', array());
                }
@@ -74,7 +72,11 @@ class Tx_Fluid_ViewHelpers_SectionViewHelper extends Tx_Fluid_Core_ViewHelper_Ab
         * @api
         */
        public function render() {
-               return $this->renderChildren();
+               if ($this->viewHelperVariableContainer->exists('Tx_Fluid_ViewHelpers_SectionViewHelper', 'isCurrentlyRenderingSection')) {
+                       $this->viewHelperVariableContainer->remove('Tx_Fluid_ViewHelpers_SectionViewHelper', 'isCurrentlyRenderingSection');
+                       return $this->renderChildren();
+               }
+               return '';
        }
 }
 
index b453fd7..0f2fa49 100644 (file)
@@ -24,7 +24,7 @@
  * "THEN" -> only has an effect inside of "IF". See If-ViewHelper for documentation.
  * @see Tx_Fluid_ViewHelpers_IfViewHelper
  *
- * @version $Id$
+ * @version $Id: ThenViewHelper.php 3751 2010-01-22 15:56:47Z k-fish $
  * @package Fluid
  * @subpackage ViewHelpers
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
index 5fa0838..c93c256 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Testcase for ParsingState
  *
- * @version $Id: ParsingStateTest.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: ParsingStateTest.php 4671 2010-06-30 08:25:50Z robert $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_ParsingStateTest extends Tx_Extbase_BaseTestCase {
@@ -67,12 +67,10 @@ class Tx_Fluid_Core_Parser_ParsingStateTest extends Tx_Extbase_BaseTestCase {
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function renderCallsTheRightMethodsOnTheRootNode() {
-               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
+               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
 
                $rootNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
-               $rootNode->expects($this->once())->method('setRenderingContext')->with($renderingContext);
-
-               $rootNode->expects($this->once())->method('evaluate')->will($this->returnValue('T3DD09 Rock!'));
+               $rootNode->expects($this->once())->method('evaluate')->with($renderingContext)->will($this->returnValue('T3DD09 Rock!'));
                $this->parsingState->setRootNode($rootNode);
                $renderedValue = $this->parsingState->render($renderingContext);
                $this->assertEquals($renderedValue, 'T3DD09 Rock!', 'The rendered value of the Root Node is not returned by the ParsingState.');
index d70802f..6c5567c 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id: AbstractNodeTest.php 3350 2009-10-27 12:01:08Z k-fish $
+ * @version $Id: AbstractNodeTest.php 4653 2010-06-28 18:52:33Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_SyntaxTree_AbstractNodeTest extends Tx_Extbase_BaseTestCase {
@@ -36,7 +36,6 @@ class Tx_Fluid_Core_Parser_SyntaxTree_AbstractNodeTest extends Tx_Extbase_BaseTe
                $this->renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext', array(), array(), '', FALSE);
 
                $this->abstractNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode', array('evaluate'));
-               $this->abstractNode->setRenderingContext($this->renderingContext);
 
                $this->childNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode');
                $this->abstractNode->addChildNode($this->childNode);
@@ -47,8 +46,8 @@ class Tx_Fluid_Core_Parser_SyntaxTree_AbstractNodeTest extends Tx_Extbase_BaseTe
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function evaluateChildNodesPassesRenderingContextToChildNodes() {
-               $this->childNode->expects($this->once())->method('setRenderingContext')->with($this->renderingContext);
-               $this->abstractNode->evaluateChildNodes();
+               $this->childNode->expects($this->once())->method('evaluate')->with($this->renderingContext);
+               $this->abstractNode->evaluateChildNodes($this->renderingContext);
        }
 
        /**
index 570d50c..313c08f 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Testcase for TextNode
  *
- * @version $Id: TextNodeTest.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: TextNodeTest.php 4653 2010-06-28 18:52:33Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_SyntaxTree_TextNodeTest extends Tx_Extbase_BaseTestCase {
@@ -35,7 +35,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_TextNodeTest extends Tx_Extbase_BaseTestCa
        public function renderReturnsSameStringAsGivenInConstructor() {
                $string = 'I can work quite effectively in a train!';
                $node = new Tx_Fluid_Core_Parser_SyntaxTree_TextNode($string);
-               $this->assertEquals($node->evaluate(), $string, 'The rendered string of a text node is not the same as the string given in the constructor.');
+               $this->assertEquals($node->evaluate($this->getMock('Tx_Fluid_Core_Rendering_RenderingContext')), $string, 'The rendered string of a text node is not the same as the string given in the constructor.');
        }
 
        /**
index af1c181..0af9fb1 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Testcase for ViewHelperNode's evaluateBooleanExpression()
  *
- * @version $Id: ViewHelperNodeComparatorTest.php 4483 2010-06-10 13:57:32Z k-fish $
+ * @version $Id: ViewHelperNodeComparatorTest.php 4671 2010-06-30 08:25:50Z robert $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Extbase_BaseTestCase {
@@ -34,12 +34,17 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
        protected $viewHelperNode;
 
        /**
+        * @var Tx_Fluid_Core_Rendering_RenderingContextInterface
+        */
+       protected $renderingContext;
+
+       /**
         * Setup fixture
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function setUp() {
                $this->viewHelperNode = $this->getAccessibleMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('dummy'), array(), '', FALSE);
-               $this->viewHelperNode->setRenderingContext(new Tx_Fluid_Core_Rendering_RenderingContext());
+               $this->renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
        }
 
        /**
@@ -51,7 +56,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
                $rootNode->expects($this->once())->method('getChildNodes')->will($this->returnValue(array(1,2,3,4)));
 
-               $this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode);
+               $this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext);
        }
 
        /**
@@ -64,7 +69,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('=='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('5'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -77,7 +82,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('=='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('3'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -90,7 +95,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('!='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('5'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -103,7 +108,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('!='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('3'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -116,7 +121,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('%'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('2'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -129,7 +134,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('%'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('2'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -142,7 +147,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('>'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('9'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -155,7 +160,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('>'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -168,7 +173,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('>='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('9'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -181,7 +186,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('>='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -194,7 +199,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('>='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('11'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -207,7 +212,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('<'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -220,7 +225,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('<'));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -233,7 +238,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('<='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -246,7 +251,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('<='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertTrue($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
        /**
@@ -259,7 +264,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Ex
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('<='));
                $rootNode->addChildNode(new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('10'));
 
-               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode));
+               $this->assertFalse($this->viewHelperNode->_call('evaluateBooleanExpression', $rootNode, $this->renderingContext));
        }
 
 }
index eeac250..017fa96 100644 (file)
@@ -26,7 +26,7 @@ require_once(dirname(__FILE__) . '/../../Fixtures/TestViewHelper.php');
 /**
  * Testcase for [insert classname here]
  *
- * @version $Id: ViewHelperNodeTest.php 4005 2010-03-23 14:28:15Z k-fish $
+ * @version $Id: ViewHelperNodeTest.php 4653 2010-06-28 18:52:33Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_BaseTestCase {
@@ -71,13 +71,13 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
                $this->renderingContext->injectObjectManager($this->mockObjectManager);
 
                $this->templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
-               $this->renderingContext->setTemplateVariableContainer($this->templateVariableContainer);
+               $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
 
                $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
                $this->renderingContext->setControllerContext($this->controllerContext);
 
                $this->viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
-               $this->renderingContext->setViewHelperVariableContainer($this->viewHelperVariableContainer);
+               $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
        }
 
        /**
@@ -101,7 +101,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
        public function childNodeAccessFacetWorksAsExpected() {
                $childNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_TextNode', array(), array('foo'));
 
-               $mockViewHelper = $this->getMock('Tx_Fluid_Core_Parser_Fixtures_ChildNodeAccessFacetViewHelper', array('setChildNodes', 'initializeArguments', 'render', 'prepareArguments', 'setRenderingContext'));
+               $mockViewHelper = $this->getMock('Tx_Fluid_Core_Parser_Fixtures_ChildNodeAccessFacetViewHelper', array('setChildNodes', 'initializeArguments', 'render', 'prepareArguments'));
 
                $mockViewHelperArguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
 
@@ -112,8 +112,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
 
                $mockViewHelper->expects($this->once())->method('setChildNodes')->with($this->equalTo(array($childNode)));
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -131,8 +130,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
 
                $viewHelperNode = new Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode($mockViewHelper, array());
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -160,8 +158,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
                        'param1' => new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('a'),
                ));
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -177,8 +174,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
 
                $this->mockObjectManager->expects($this->once())->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -194,8 +190,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
 
                $this->mockObjectManager->expects($this->once())->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -212,9 +207,8 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
                $this->mockObjectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
                $this->mockObjectManager->expects($this->at(1))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
 
-               $viewHelperNode->setRenderingContext($this->renderingContext);
-               $viewHelperNode->evaluate();
-               $viewHelperNode->evaluate();
+               $viewHelperNode->evaluate($this->renderingContext);
+               $viewHelperNode->evaluate($this->renderingContext);
        }
 
        /**
@@ -223,13 +217,12 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
         */
        public function convertArgumentValueCallsConvertToBooleanForArgumentsOfTypeBoolean() {
                $viewHelperNode = $this->getAccessibleMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('convertToBoolean'), array(), '', FALSE);
-               $viewHelperNode->_set('renderingContext', $this->renderingContext);
                $argumentViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode', array('evaluate'), array(), '', FALSE);
                $argumentViewHelperNode->expects($this->once())->method('evaluate')->will($this->returnValue('foo'));
 
                $viewHelperNode->expects($this->once())->method('convertToBoolean')->with('foo')->will($this->returnValue('bar'));
 
-               $actualResult = $viewHelperNode->_call('convertArgumentValue', $argumentViewHelperNode, 'boolean');
+               $actualResult = $viewHelperNode->_call('convertArgumentValue', $argumentViewHelperNode, 'boolean', $this->renderingContext);
                $this->assertEquals('bar', $actualResult);
        }
 
index 8fd5a40..05bca58 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/Fixtures/PostParseFacetViewHelper.php');
  * This is to at least half a system test, as it compares rendered results to
  * expectations, and does not strictly check the parsing...
  *
- * @version $Id: TemplateParserTest.php 3952 2010-03-16 08:00:53Z sebastian $
+ * @version $Id: TemplateParserTest.php 4170 2010-04-15 22:10:27Z k-fish $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Parser_TemplateParserTest extends Tx_Extbase_BaseTestCase {
@@ -495,14 +495,6 @@ class Tx_Fluid_Core_Parser_TemplateParserTest extends Tx_Extbase_BaseTestCase {
        }
 
        /**
-        * @test
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function viewHelperArgumentsAreNotRunThroughValueInterceptors() {
-               $this->markTestIncomplete('Needs implementation!');
-       }
-
-       /**
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function argumentsStrings() {
index f753d1e..e482a90 100644 (file)
 /**
  * Testcase for ParsingState
  *
- * @version $Id: RenderingContextTest.php 4005 2010-03-23 14:28:15Z k-fish $
+ * @version $Id: RenderingContextTest.php 4671 2010-06-30 08:25:50Z robert $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Core_Rendering_RenderingContextTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * Parsing state
-        * @var Tx_Fluid_Core_Rendering_RenderingContext
+        * @var Tx_Fluid_Core_Rendering_RenderingContextInterface
         */
        protected $renderingContext;
 
@@ -44,7 +44,7 @@ class Tx_Fluid_Core_Rendering_RenderingContextTest extends Tx_Extbase_BaseTestCa
         */
        public function templateVariableContainerCanBeReadCorrectly() {
                $templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
-               $this->renderingContext->setTemplateVariableContainer($templateVariableContainer);
+               $this->renderingContext->injectTemplateVariableContainer($templateVariableContainer);
                $this->assertSame($this->renderingContext->getTemplateVariableContainer(), $templateVariableContainer, 'Template Variable Container could not be read out again.');
        }
 
@@ -64,7 +64,7 @@ class Tx_Fluid_Core_Rendering_RenderingContextTest extends Tx_Extbase_BaseTestCa
         */
        public function viewHelperVariableContainerCanBeReadCorrectly() {
                $viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
-               $this->renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
+               $this->renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
                $this->assertSame($viewHelperVariableContainer, $this->renderingContext->getViewHelperVariableContainer());
        }
 }
index a38be3d..be92b47 100644 (file)
@@ -190,7 +190,7 @@ class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest extends Tx_Extbase_BaseTes
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @expectedException InvalidArgumentException
+        * @expectedException \InvalidArgumentException
         */
        public function validateArgumentsCallsTheRightValidatorsAndThrowsExceptionIfValidationIsWrong() {
                $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ConditionViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ConditionViewHelperTest.php
new file mode 100644 (file)
index 0000000..ac4e8c0
--- /dev/null
@@ -0,0 +1,166 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(dirname(__FILE__) . '/../../ViewHelpers/ViewHelperBaseTestcase.php');
+
+/**
+ * Testcase for Condition ViewHelper
+ *
+ * @version $Id: IfViewHelperTest.php 4671 2010-06-30 08:25:50Z robert $
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_ViewHelper_ConditionViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+
+       /**
+        * var Tx_Fluid_Core_ViewHelper_ConditionViewHelper
+        */
+       protected $viewHelper;
+
+       /**
+        * var Tx_Fluid_Core_ViewHelper_Arguments
+        */
+       protected $mockArguments;
+
+       public function setUp() {
+               parent::setUp();
+               $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_ViewHelper_ConditionViewHelper', array('getRenderingContext', 'renderChildren'));
+               $this->viewHelper->expects($this->any())->method('getRenderingContext')->will($this->returnValue($this->renderingContext));
+               $this->injectDependenciesIntoViewHelper($this->viewHelper);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function renderThenChildReturnsAllChildrenIfNoThenViewHelperChildExists() {
+               $this->viewHelper->expects($this->at(0))->method('renderChildren')->will($this->returnValue('foo'));
+
+               $actualResult = $this->viewHelper->_call('renderThenChild');
+               $this->assertEquals('foo', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function renderThenChildReturnsThenViewHelperChildIfConditionIsTrueAndThenViewHelperChildExists() {
+               $mockThenViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate'), array(), '', FALSE);
+               $mockThenViewHelperNode->expects($this->at(0))->method('getViewHelperClassName')->will($this->returnValue('Tx_Fluid_ViewHelpers_ThenViewHelper'));
+               $mockThenViewHelperNode->expects($this->at(1))->method('evaluate')->with($this->renderingContext)->will($this->returnValue('ThenViewHelperResults'));
+
+               $this->viewHelper->setChildNodes(array($mockThenViewHelperNode));
+               $actualResult = $this->viewHelper->_call('renderThenChild');
+               $this->assertEquals('ThenViewHelperResults', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderElseChildReturnsEmptyStringIfConditionIsFalseAndNoElseViewHelperChildExists() {
+               $actualResult = $this->viewHelper->_call('renderElseChild');
+               $this->assertEquals('', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderElseChildRendersElseViewHelperChildIfConditionIsFalseAndNoThenViewHelperChildExists() {
+               $mockElseViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
+               $mockElseViewHelperNode->expects($this->at(0))->method('getViewHelperClassName')->will($this->returnValue('Tx_Fluid_ViewHelpers_ElseViewHelper'));
+               $mockElseViewHelperNode->expects($this->at(1))->method('evaluate')->with($this->renderingContext)->will($this->returnValue('ElseViewHelperResults'));
+
+               $this->viewHelper->setChildNodes(array($mockElseViewHelperNode));
+               $actualResult = $this->viewHelper->_call('renderElseChild');
+               $this->assertEquals('ElseViewHelperResults', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderThenChildReturnsValueOfThenArgumentIfConditionIsTrue() {
+               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('then')->will($this->returnValue(TRUE));
+               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('then')->will($this->returnValue('ThenArgument'));
+
+               $actualResult = $this->viewHelper->_call('renderThenChild');
+               $this->assertEquals('ThenArgument', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function thenArgumentHasPriorityOverChildNodesIfConditionIsTrue() {
+               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
+
+               $mockThenViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
+               $mockThenViewHelperNode->expects($this->never())->method('evaluate');
+
+               $this->viewHelper->setChildNodes(array($mockThenViewHelperNode));
+               $this->viewHelper->setRenderingContext($mockRenderingContext);
+
+               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('then')->will($this->returnValue(TRUE));
+               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('then')->will($this->returnValue('ThenArgument'));
+
+               $actualResult = $this->viewHelper->_call('renderThenChild');
+               $this->assertEquals('ThenArgument', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderReturnsValueOfElseArgumentIfConditionIsFalse() {
+               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('else')->will($this->returnValue(TRUE));
+               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('else')->will($this->returnValue('ElseArgument'));
+
+               $actualResult = $this->viewHelper->_call('renderElseChild');
+               $this->assertEquals('ElseArgument', $actualResult);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function elseArgumentHasPriorityOverChildNodesIfConditionIsFalse() {
+               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
+
+               $mockElseViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
+               $mockElseViewHelperNode->expects($this->never())->method('evaluate');
+
+               $this->viewHelper->setChildNodes(array($mockElseViewHelperNode));
+               $this->viewHelper->setRenderingContext($mockRenderingContext);
+
+               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('else')->will($this->returnValue(TRUE));
+               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('else')->will($this->returnValue('ElseArgument'));
+
+               $actualResult = $this->viewHelper->_call('renderElseChild');
+               $this->assertEquals('ElseArgument', $actualResult);
+       }
+
+}
+
+?>
\ No newline at end of file
index 4b61a4d..e40e4b1 100644 (file)
@@ -105,7 +105,7 @@ class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainerTest extends Tx_Extbas
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function viewCanBeReadOutAgain() {
-               $view = $this->getMock('Tx_Extbase_MVC_View_ViewInterface');
+               $view = $this->getMock('Tx_Fluid_View_AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'hasTemplate'));
                $this->viewHelperVariableContainer->setView($view);
                $this->assertSame($view, $this->viewHelperVariableContainer->getView());
        }
index af64957..397e9a3 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * [Enter description here]
  *
- * @version $Id: TransparentSyntaxTreeNode.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: TransparentSyntaxTreeNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage View\Fixture
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -31,7 +31,7 @@
 class Tx_Fluid_View_Fixture_TransparentSyntaxTreeNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
        public $variableContainer;
        
-       public function evaluate() {
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
        }
 }
 
index 54e009d..fa8dde7 100644 (file)
@@ -26,7 +26,7 @@ include_once(dirname(__FILE__) . '/Fixtures/TemplateViewFixture.php');
 /**
  * Testcase for the TemplateView
  *
- * @version $Id: TemplateViewTest.php 4334 2010-05-28 10:06:01Z robert $
+ * @version $Id: TemplateViewTest.php 4671 2010-06-30 08:25:50Z robert $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
@@ -179,72 +179,11 @@ class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function renderCallsRenderOnParsedTemplateInterface() {
-               $templateView = $this->getAccessibleMock('Tx_Fluid_View_TemplateView', array('parseTemplate', 'resolveTemplatePathAndFilename', 'buildParserConfiguration'), array(), '', FALSE);
-               $parsedTemplate = $this->getMock('Tx_Fluid_Core_Parser_ParsedTemplateInterface');
-               $objectManager = $this->getMock('Tx_Fluid_Compatibility_ObjectManager');
-               $controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
-
-               $variableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
-               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext', array(), array(), '', FALSE);
-
-               $viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
-               $objectManager->expects($this->exactly(3))->method('create')->will($this->onConsecutiveCalls($variableContainer, $renderingContext, $viewHelperVariableContainer));
-
-               $templateView->_set('objectManager', $objectManager);
-               $templateView->injectTemplateParser($this->getMock('Tx_Fluid_Core_Parser_TemplateParser'));
-               $templateView->setControllerContext($controllerContext);
-
-               $templateView->expects($this->once())->method('parseTemplate')->will($this->returnValue($parsedTemplate));
-
-                       // Real expectations
-               $parsedTemplate->expects($this->once())->method('render')->with($renderingContext)->will($this->returnValue('Hello World'));
-
-               $this->assertEquals('Hello World', $templateView->render(), 'The output of the ParsedTemplates render Method is not returned by the TemplateView');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function parseTemplateReadsTheGivenTemplateAndReturnsTheParsedResult() {
-               $mockTemplateParser = $this->getMock('Tx_Fluid_Core_Parser_TemplateParser', array('parse'));
-               $mockTemplateParser->expects($this->once())->method('parse')->with('Unparsed Template')->will($this->returnValue('Parsed Template'));
-
-               $templateView = $this->getAccessibleMock('Tx_Fluid_View_TemplateView', array('dummy'), array(), '', FALSE);
-               $templateView->injectTemplateParser($mockTemplateParser);
-
-               $parsedTemplate = $templateView->_call('parseTemplate', dirname(__FILE__) . '/Fixtures/UnparsedTemplateFixture.html');
-               $this->assertSame('Parsed Template', $parsedTemplate);
-       }
-
-       /**
-        * @test
-        * @expectedException Tx_Fluid_View_Exception_InvalidTemplateResourceException
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function parseTemplateThrowsAnExceptionIfTheSpecifiedTemplateResourceDoesNotExist() {
-               $templateView = $this->getAccessibleMock('Tx_Fluid_View_TemplateView', array('dummy'), array(), '', FALSE);
-               $templateView->_call('parseTemplate', 'foo');
-       }
-
-       /**
-        * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
        public function pathToPartialIsResolvedCorrectly() {
-               $this->markTestSkipped('Needs proper implementation.');
-               $mockRequest = $this->getMock('Tx_Fluid_MVC_Request', array('getControllerPackageKey', ''));
-               $mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue('DummyPackageKey'));
-               $mockControllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array('getRequest'));
-               $mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
-
-               $mockPackage = $this->getMock('Tx_Fluid_Package_PackageInterface', array('getPackagePath'));
-               $mockPackage->expects($this->any())->method('getPackagePath')->will($this->returnValue('/ExamplePackagePath/'));
-               $mockPackageManager = $this->getMock('Tx_Fluid_Package_PackageManagerInterface', array('getPackage'));
-               $mockPackageManager->expects($this->any())->method('getPackage')->with('DummyPackageKey')->will($this->returnValue($mockPackage));
-
+               $this->markTestSkipped('Needs to be finished');
                vfsStreamWrapper::register();
+               mkdir('vfs://MyTemplates');
+               file_put_contents('vfs://MyTemplates/MyCoolAction.html', 'contentsOfMyCoolAction');
                $mockRootDirectory = vfsStreamDirectory::create('ExamplePackagePath/Resources/Private/Partials');
                $mockRootDirectory->getChild('Resources/Private/Partials')->addChild('Partials');
                vfsStreamWrapper::setRoot($mockRootDirectory);
@@ -256,60 +195,15 @@ class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function viewIsPlacedInVariableContainer() {
-               $this->markTestSkipped('view will be placed in ViewHelperContext soon');
-               $packageManager = t3lib_div::makeInstance('Tx_Fluid_Package_PackageManagerInterface');
-               $resourceManager = t3lib_div::makeInstance('Tx_Fluid_Resource_ResourceManager');
-
-               $syntaxTreeNode = new Tx_Fluid_View_Fixture_TransparentSyntaxTreeNode();
-
-               $parsingState = new Tx_Fluid_Core_Parser_ParsingState();
-               $parsingState->setRootNode($syntaxTreeNode);
-
-               $templateParserMock = $this->getMock('Tx_Fluid_Core_Parser_TemplateParser', array('parse'));
-               $templateParserMock->expects($this->any())->method('parse')->will($this->returnValue($parsingState));
-
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Request');
-               $mockRequest->expects($this->any())->method('getControllerActionName')->will($this->returnValue('index'));
-               $mockRequest->expects($this->any())->method('getControllerObjectName')->will($this->returnValue('Tx_Fluid_Foo_Bar_Controller_BazController'));
-               $mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue('Fluid'));
-               $mockControllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array('getRequest'), array(), '', FALSE);
-               $mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
-
-               $templateView = new Tx_Fluid_View_Fixture_TemplateViewFixture(new Tx_Fluid_Compatibility_ObjectManager(), $packageManager, $resourceManager, new Tx_Fluid_Compatibility_ObjectManager());
-               $templateView->injectTemplateParser($templateParserMock);
-               $templateView->setTemplatePathAndFilename(dirname(__FILE__) . '/Fixtures/TemplateViewSectionFixture.html');
-               $templateView->setLayoutPathAndFilename(dirname(__FILE__) . '/Fixtures/LayoutFixture.html');
-               $templateView->setControllerContext($mockControllerContext);
-               $templateView->initializeObject();
-               $templateView->addVariable('name', 'value');
-               $templateView->render();
-
-               $this->assertSame($templateView, $syntaxTreeNode->variableContainer->get('view'), 'The view has not been placed in the variable container.');
-               $this->assertEquals('value', $syntaxTreeNode->variableContainer->get('name'), 'Context variable has been set.');
-       }
-
-       /**
-        * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       public function renderSingleSectionWorks() {
-               $this->markTestSkipped('needs refactoring - this is a functional test with too many side effects');
+       public function viewIsPlacedInViewHelperVariableContainer() {
                $templateView = new Tx_Fluid_View_TemplateView();
-               $templateView->setTemplatePathAndFilename(dirname(__FILE__) . '/Fixtures/TemplateViewSectionFixture.html');
-               $this->assertEquals($templateView->renderSection('mySection'), 'Output', 'Specific section was not rendered correctly!');
-       }
 
-       /**
-        * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       public function layoutEngineMergesTemplateAndLayout() {
-               $this->markTestSkipped('needs refactoring - this is a functional test with too many side effects');
-               $templateView = new Tx_Fluid_View_TemplateView();
-               $templateView->setTemplatePathAndFilename(dirname(__FILE__) . '/Fixtures/TemplateViewSectionFixture.html');
-               $templateView->setLayoutPathAndFilename(dirname(__FILE__) . '/Fixtures/LayoutFixture.html');
-               $this->assertEquals($templateView->renderWithLayout('LayoutFixture'), '<div>Output</div>', 'Specific section was not rendered correctly!');
+               $mockViewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer', array('setView'));
+               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext', array('getViewHelperVariableContainer'));
+               $mockRenderingContext->expects($this->once())->method('getViewHelperVariableContainer')->will($this->returnValue($mockViewHelperVariableContainer));
+
+               $mockViewHelperVariableContainer->expects($this->once())->method('setView')->with($templateView);
+               $templateView->setRenderingContext($mockRenderingContext);
        }
 
        /**
@@ -317,10 +211,9 @@ class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function resolveTemplatePathAndFilenameChecksDifferentPathPatternsAndReturnsTheFirstPathWhichExists() {
-               $this->markTestSkipped('vfs not yet supported in v4');
                vfsStreamWrapper::register();
                mkdir('vfs://MyTemplates');
-               file_put_contents('vfs://MyTemplates/MyCoolAction.html', '');
+               file_put_contents('vfs://MyTemplates/MyCoolAction.html', 'contentsOfMyCoolAction');
 
                $paths = array(
                         'vfs://NonExistantDir/UnknowFile.html',
@@ -334,7 +227,7 @@ class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
                $templateView->setPartialRootPath('MyPartials');
                $templateView->setLayoutRootPath('MyLayouts');
 
-               $this->assertSame('vfs://MyTemplates/MyCoolAction.html', $templateView->_call('resolveTemplatePathAndFilename', 'myCoolAction'));
+               $this->assertSame('contentsOfMyCoolAction', $templateView->_call('getTemplateSource', 'myCoolAction'));
                
        }
 
@@ -343,10 +236,14 @@ class Tx_Fluid_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function resolveTemplatePathAndFilenameReturnsTheExplicitlyConfiguredTemplatePathAndFilename() {
+               vfsStreamWrapper::register();
+               mkdir('vfs://MyTemplates');
+               file_put_contents('vfs://MyTemplates/MyCoolAction.html', 'contentsOfMyCoolAction');
+
                $templateView = $this->getAccessibleMock('Tx_Fluid_View_TemplateView', array('dummy'), array(), '', FALSE);
-               $templateView->_set('templatePathAndFilename', 'Foo/Bar/Baz.html');
+               $templateView->_set('templatePathAndFilename', 'vfs://MyTemplates/MyCoolAction.html');
 
-               $this->assertSame('Foo/Bar/Baz.html', $templateView->_call('resolveTemplatePathAndFilename'));
+               $this->assertSame('contentsOfMyCoolAction', $templateView->_call('getTemplateSource'));
        }
 }
 
index 8f4bd39..4f225e3 100644 (file)
@@ -25,7 +25,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 /**
  * Testcase for AliasViewHelper
  *
- * @version $Id: AliasViewHelperTest.php 3350 2009-10-27 12:01:08Z k-fish $
+ * @version $Id: AliasViewHelperTest.php 4653 2010-06-28 18:52:33Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_ViewHelpers_AliasViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
@@ -45,6 +45,7 @@ class Tx_Fluid_ViewHelpers_AliasViewHelperTest extends Tx_Fluid_ViewHelpers_View
 
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
                $viewHelper->setViewHelperNode($mockViewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('someAlias' => 'someValue'));
        }
 
@@ -65,6 +66,7 @@ class Tx_Fluid_ViewHelpers_AliasViewHelperTest extends Tx_Fluid_ViewHelpers_View
 
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
                $viewHelper->setViewHelperNode($mockViewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('someAlias' => 'someValue', 'someOtherAlias' => 'someOtherValue'));
        }
 
@@ -83,6 +85,7 @@ class Tx_Fluid_ViewHelpers_AliasViewHelperTest extends Tx_Fluid_ViewHelpers_View
 
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
                $viewHelper->setViewHelperNode($mockViewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
 
                $this->assertEquals('foo', $viewHelper->render(array()));
        }
index a21968a..cce389f 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * [Enter description here]
  *
- * @version $Id: ConstraintSyntaxTreeNode.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: ConstraintSyntaxTreeNode.php 4671 2010-06-30 08:25:50Z robert $
  * @package Fluid
  * @subpackage ViewHelpers\Fixtures
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
@@ -35,7 +35,7 @@ class Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode extends Tx_Fluid_Co
                $this->variableContainer = $variableContainer;
        }
        
-       public function evaluateChildNodes() {
+       public function evaluateChildNodes(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
                $identifiers = $this->variableContainer->getAllIdentifiers();
                $callElement = array();
                foreach ($identifiers as $identifier) {
@@ -44,7 +44,7 @@ class Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode extends Tx_Fluid_Co
                $this->callProtocol[] = $callElement;
        }
        
-       public function evaluate() {}
+       public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {}
 }
 
 
index ac12e7c..3f00dba 100644 (file)
@@ -26,7 +26,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 /**
  * Testcase for ForViewHelper
  *
- * @version $Id: ForViewHelperTest.php 3751 2010-01-22 15:56:47Z k-fish $
+ * @version $Id: ForViewHelperTest.php 4653 2010-06-28 18:52:33Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
@@ -44,6 +44,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array(0,1,2,3), 'innerVariable');
 
                $expectedCallProtocol = array(
@@ -67,6 +68,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('key1' => 'value1', 'key2' => 'value2'), 'innerVariable', 'someKey');
 
                $expectedCallProtocol = array(
@@ -119,6 +121,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
 
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
                $viewHelper->setViewHelperNode($mockViewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('foo' => 'bar', 'FLOW3' => 'Fluid'), 'innerVariable');
        }
 
@@ -142,6 +145,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $this->templateVariableContainer->expects($this->at(7))->method('remove')->with('someKey');
 
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->setViewHelperNode($mockViewHelperNode);
                $viewHelper->render(array('foo' => 'bar', 'FLOW3' => 'Fluid'), 'innerVariable', 'someKey');
        }
@@ -158,6 +162,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array(0,1,2,3), 'innerVariable', '', TRUE);
 
                $expectedCallProtocol = array(
@@ -181,6 +186,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('key1' => 'value1', 'key2' => 'value2'), 'innerVariable', 'someKey', TRUE);
 
                $expectedCallProtocol = array(
@@ -208,6 +214,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('foo', 'bar', 'baz'), 'innerVariable', 'someKey');
 
                $expectedCallProtocol = array(
@@ -239,6 +246,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->render(array('foo', 'bar', 'baz'), 'innerVariable', 'someKey', TRUE);
 
                $expectedCallProtocol = array(
@@ -283,6 +291,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $traversableObject = new ArrayObject(array('key1' => 'value1', 'key2' => 'value2'));
                $viewHelper->render($traversableObject, 'innerVariable');
 
@@ -305,6 +314,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $iteratorObject = new ArrayIterator(array('key1' => 'value1', 'key2' => 'value2'));
                $viewHelper->render($iteratorObject, 'innerVariable', 'someKey');
 
@@ -333,6 +343,7 @@ class Tx_Fluid_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHe
                $viewHelperNode = new Tx_Fluid_ViewHelpers_Fixtures_ConstraintSyntaxTreeNode($variableContainer);
                $viewHelper->setTemplateVariableContainer($variableContainer);
                $viewHelper->setViewHelperNode($viewHelperNode);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $splObjectStorageObject = new SplObjectStorage();
                $object1 = new stdClass();
                $splObjectStorageObject->attach($object1);
index d84a04c..d7375f9 100644 (file)
@@ -25,7 +25,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 /**
  * Testcase for IfViewHelper
  *
- * @version $Id: IfViewHelperTest.php 3835 2010-02-22 15:15:17Z robert $
+ * @version $Id: IfViewHelperTest.php 4836 2010-07-12 18:12:29Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_ViewHelpers_IfViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
@@ -42,132 +42,33 @@ class Tx_Fluid_ViewHelpers_IfViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHel
 
        public function setUp() {
                parent::setUp();
-               $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_IfViewHelper', array('renderChildren'));
+               $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_IfViewHelper', array('renderThenChild', 'renderElseChild'));
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
                $this->viewHelper->initializeArguments();
        }
 
        /**
         * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function viewHelperRendersChildrenIfConditionIsTrueAndNoThenViewHelperChildExists() {
-               $this->viewHelper->expects($this->at(0))->method('renderChildren')->will($this->returnValue('foo'));
+       public function viewHelperRendersThenChildIfConditionIsTrue() {
+               $this->viewHelper->expects($this->at(0))->method('renderThenChild')->will($this->returnValue('foo'));
 
                $actualResult = $this->viewHelper->render(TRUE);
                $this->assertEquals('foo', $actualResult);
        }
 
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function viewHelperRendersThenViewHelperChildIfConditionIsTrueAndThenViewHelperChildExists() {
-               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
-
-               $mockThenViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
-               $mockThenViewHelperNode->expects($this->at(0))->method('getViewHelperClassName')->will($this->returnValue('Tx_Fluid_ViewHelpers_ThenViewHelper'));
-               $mockThenViewHelperNode->expects($this->at(1))->method('setRenderingContext')->with($mockRenderingContext);
-               $mockThenViewHelperNode->expects($this->at(2))->method('evaluate')->will($this->returnValue('ThenViewHelperResults'));
-
-               $this->viewHelper->setChildNodes(array($mockThenViewHelperNode));
-               $this->viewHelper->setRenderingContext($mockRenderingContext);
-               $actualResult = $this->viewHelper->render(TRUE);
-               $this->assertEquals('ThenViewHelperResults', $actualResult);
-       }
-
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function renderReturnsEmptyStringIfConditionIsFalseAndNoThenViewHelperChildExists() {
-               $actualResult = $this->viewHelper->render(FALSE);
-               $this->assertEquals('', $actualResult);
-       }
 
        /**
         * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function viewHelperRendersElseViewHelperChildIfConditionIsFalseAndNoThenViewHelperChildExists() {
-               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
-
-               $mockElseViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
-               $mockElseViewHelperNode->expects($this->at(0))->method('getViewHelperClassName')->will($this->returnValue('Tx_Fluid_ViewHelpers_ElseViewHelper'));
-               $mockElseViewHelperNode->expects($this->at(1))->method('setRenderingContext')->with($mockRenderingContext);
-               $mockElseViewHelperNode->expects($this->at(2))->method('evaluate')->will($this->returnValue('ElseViewHelperResults'));
-
-               $this->viewHelper->setChildNodes(array($mockElseViewHelperNode));
-               $this->viewHelper->setRenderingContext($mockRenderingContext);
+       public function viewHelperRendersElseChildIfConditionIsFalse() {
+               $this->viewHelper->expects($this->at(0))->method('renderElseChild')->will($this->returnValue('foo'));
 
                $actualResult = $this->viewHelper->render(FALSE);
-               $this->assertEquals('ElseViewHelperResults', $actualResult);
-       }
-
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function renderReturnsValueOfThenArgumentIfConditionIsTrue() {
-               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('then')->will($this->returnValue(TRUE));
-               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('then')->will($this->returnValue('ThenArgument'));
-
-               $actualResult = $this->viewHelper->render(TRUE);
-               $this->assertEquals('ThenArgument', $actualResult);
-       }
-
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function thenArgumentHasPriorityOverChildNodesIfConditionIsTrue() {
-               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
-
-               $mockThenViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
-               $mockThenViewHelperNode->expects($this->never())->method('evaluate');
-
-               $this->viewHelper->setChildNodes(array($mockThenViewHelperNode));
-               $this->viewHelper->setRenderingContext($mockRenderingContext);
-
-               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('then')->will($this->returnValue(TRUE));
-               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('then')->will($this->returnValue('ThenArgument'));
-
-               $actualResult = $this->viewHelper->render(TRUE);
-               $this->assertEquals('ThenArgument', $actualResult);
-       }
-
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function renderReturnsValueOfElseArgumentIfConditionIsFalse() {
-               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('else')->will($this->returnValue(TRUE));
-               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('else')->will($this->returnValue('ElseArgument'));
-
-               $actualResult = $this->viewHelper->render(FALSE);
-               $this->assertEquals('ElseArgument', $actualResult);
-       }
-
-       /**
-        * @test
-        * @author Bastian Waidelich <bastian@typo3.org>
-        */
-       public function elseArgumentHasPriorityOverChildNodesIfConditionIsFalse() {
-               $mockRenderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
-
-               $mockElseViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE);
-               $mockElseViewHelperNode->expects($this->never())->method('evaluate');
-
-               $this->viewHelper->setChildNodes(array($mockElseViewHelperNode));
-               $this->viewHelper->setRenderingContext($mockRenderingContext);
-
-               $this->arguments->expects($this->atLeastOnce())->method('hasArgument')->with('else')->will($this->returnValue(TRUE));
-               $this->arguments->expects($this->atLeastOnce())->method('offsetGet')->with('else')->will($this->returnValue('ElseArgument'));
-
-               $actualResult = $this->viewHelper->render(FALSE);
-               $this->assertEquals('ElseArgument', $actualResult);
+               $this->assertEquals('foo', $actualResult);
        }
-
 }
 
 ?>
index 1e752e3..9a42792 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id: ViewHelperBaseTestcase.php 4005 2010-03-23 14:28:15Z k-fish $
+ * @version $Id: ViewHelperBaseTestcase.php 4653 2010-06-28 18:52:33Z sebastian $
  * @package Fluid
  * @subpackage ViewHelpers
  */
@@ -63,6 +63,11 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
        protected $request;
 
        /**
+        * @var Tx_Fluid_Core_Rendering_RenderingContext
+        */
+       protected $renderingContext;
+
+       /**
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
@@ -88,6 +93,7 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
                $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
                $this->tagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder');
                $this->arguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
+               $this->renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
        }
 
        /**
@@ -99,6 +105,7 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
                $viewHelper->setViewHelperVariableContainer($this->viewHelperVariableContainer);
                $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
                $viewHelper->setControllerContext($this->controllerContext);
+               $viewHelper->setRenderingContext($this->renderingContext);
                $viewHelper->setArguments($this->arguments);
                if ($viewHelper instanceof Tx_Fluid_Core_ViewHelper_TagBasedViewHelper) {
                        $viewHelper->injectTagBuilder($this->tagBuilder);