[+FEATURE] First step of "Fluid widget" backport
authorBastian Waidelich <bastian@typo3.org>
Fri, 5 Nov 2010 11:10:06 +0000 (11:10 +0000)
committerBastian Waidelich <bastian@typo3.org>
Fri, 5 Nov 2010 11:10:06 +0000 (11:10 +0000)
This is the first step of the Widget backport (#8773). This contains all the core classes that are required for the widget implementation and two exemplary Widget ViewHelpers "widget.paginate" and "widget.autocomplete".
Note: Ajax widgets are not yet working!!

Relates to: #8773
Relates to: #10568

80 files changed:
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php
typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetController.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/AjaxWidgetContextHolder.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/Exception/MissingControllerException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/Exception/RenderingContextNotFoundException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetContextNotFoundException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetRequestNotFoundException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/WidgetContext.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/WidgetRequest.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestBuilder.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestHandler.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/TemplateView.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/RenderChildrenViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/AutocompleteViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/AutocompleteController.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Autocomplete/Index.html [new file with mode: 0644]
typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html [new file with mode: 0644]
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/TemplateParserPatternTest.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/TagBasedViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/Core/TagBuilderTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/AbstractViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ArgumentDefinitionTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ConditionViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/TemplateVariableContainerTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperVariableContainerTest.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetControllerTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/AjaxWidgetContextHolderTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetContextTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestBuilderTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/AbstractTemplateViewTest.php
typo3/sysext/fluid/Tests/Unit/View/TemplateViewTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/AliasViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/BaseViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/CountViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/CycleViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ElseViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ForViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormFieldViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/CheckboxViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/ErrorsViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/HiddenViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/RadioViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SubmitViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextareaViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextboxViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/UploadViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/CurrencyViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/DateViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/Nl2brViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/NumberViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/PaddingViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/PrintfViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/GroupedForViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/IfViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/ExternalViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/RenderChildrenViewHelperTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/RenderViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ThenViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Uri/ExternalViewHelperTest.php

index 860f8fd..50810d8 100644 (file)
@@ -42,7 +42,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
 
        /**
         * The ViewHelper associated with this node
-        * @var Tx_Fluid_Core_ViewHelper_ViewHelperInterface
+        * @var Tx_Fluid_Core_ViewHelper_AbstractViewHelper
         */
        protected $uninitializedViewHelper = NULL;
 
@@ -85,12 +85,12 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
        /**
         * Constructor.
         *
-        * @param Tx_Fluid_Core_ViewHelper_ViewHelperInterface $viewHelper The view helper
+        * @param Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper The view helper
         * @param array $arguments Arguments of view helper - each value is a RootNode.
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
-       public function __construct(Tx_Fluid_Core_ViewHelper_ViewHelperInterface $viewHelper, array $arguments) {
+       public function __construct(Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper, array $arguments) {
                $this->uninitializedViewHelper = $viewHelper;
                $this->viewHelpersByContext = t3lib_div::makeInstance('Tx_Extbase_Persistence_ObjectStorage');
                $this->arguments = $arguments;
@@ -179,14 +179,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parse
                        $viewHelper->setChildNodes($this->childNodes);
                }
 
-               $viewHelper->validateArguments();
-               $viewHelper->initialize();
-               try {
-                       $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();
-               }
+               $output = $viewHelper->initializeArgumentsAndRender($renderMethodParameters);
 
                return $output;
        }
index a1bb9b6..d84a51e 100644 (file)
@@ -101,7 +101,7 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper extends Tx_Fl
         * Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()
         *
         * @param string $name Name of tag attribute
-        * @param strgin $type Type of the tag attribute
+        * @param string $type Type of the tag attribute
         * @param string $description Description of tag attribute
         * @param boolean $required set to TRUE if tag attribute is required. Defaults to FALSE.
         * @return void
index cdac69d..b1167e0 100644 (file)
@@ -27,7 +27,7 @@
  * @api
  * @scope prototype
  */
-abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_Core_ViewHelper_ViewHelperInterface {
+abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
 
        /**
         * TRUE if arguments have already been initialized
@@ -220,6 +220,35 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
        }
 
        /**
+        * Initialize the arguments of the ViewHelper, and call the render() method of the ViewHelper.
+        *
+        * @param array $renderMethodParameters the parameters of the render() method.
+        * @return string the rendered ViewHelper.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initializeArgumentsAndRender(array $renderMethodParameters) {
+               $this->validateArguments();
+               $this->initialize();
+               return $this->callRenderMethod($renderMethodParameters);
+       }
+
+       /**
+        * Call the render() method and handle errors.
+        *
+        * @param array $renderMethodParameters the parameters of the render() method.
+        * @return string the rendered ViewHelper
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function callRenderMethod(array $renderMethodParameters) {
+               try {
+                       return call_user_func_array(array($this, 'render'), $renderMethodParameters);
+               } catch (Tx_Fluid_Core_ViewHelper_Exception $exception) {
+                               // @todo [BW] rethrow exception, log, ignore.. depending on the current context
+                       return $exception->getMessage();
+               }
+       }
+
+       /**
         * Initializes the view helper before invoking the render method.
         *
         * Override this method to solve tasks before the view helper content is rendered.
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetController.php b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetController.php
new file mode 100644 (file)
index 0000000..a48e9ea
--- /dev/null
@@ -0,0 +1,69 @@
+<?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 is the base class for all widget controllers.
+ * Basically, it is an ActionController, and it additionally
+ * has $this->widgetConfiguration set to the Configuration of the current Widget.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+abstract class Tx_Fluid_Core_Widget_AbstractWidgetController extends Tx_Extbase_MVC_Controller_ActionController {
+
+       /**
+        * @var array
+        */
+       protected $supportedRequestTypes = array('Tx_Fluid_Core_Widget_WidgetRequest');
+
+       /**
+        * Configuration for this widget.
+        *
+        * @var array
+        * @api
+        */
+       protected $widgetConfiguration;
+
+       /**
+        * Handles a request. The result output is returned by altering the given response.
+        *
+        * @param Tx_Extbase_MVC_RequestInterface $request The request object
+        * @param Tx_Extbase_MVC_ResponseInterface $response The response, modified by this handler
+        * @return void
+        * @api
+        */
+       public function processRequest(Tx_Extbase_MVC_RequestInterface $request, Tx_Extbase_MVC_ResponseInterface $response) {
+               $this->widgetConfiguration = $request->getWidgetContext()->getWidgetConfiguration();
+               parent::processRequest($request, $response);
+       }
+
+       /**
+        * @param Tx_Extbase_MVC_View_ViewInterface $view
+        * @return void
+        * @todo implement logic for overriding widget template paths (tx_extension.view.widget.<WidgetViewHelperClassName>.templateRootPath...)
+        */
+       protected function setViewConfiguration(Tx_Extbase_MVC_View_ViewInterface $view) {
+               return;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php
new file mode 100644 (file)
index 0000000..811ee41
--- /dev/null
@@ -0,0 +1,212 @@
+<?php
+declare(ENCODING = 'utf-8') ;
+
+/*                                                                        *
+ * 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!                         *
+ *                                                                        */
+
+/**
+ * @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_Widget_AbstractWidgetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
+
+       /**
+        * The Controller associated to this widget.
+        * This needs to be filled by the individual subclass by an @inject
+        * annotation.
+        *
+        * @var Tx_Fluid_Core_Widget_AbstractWidgetController
+        * @api
+        */
+       protected $controller;
+
+       /**
+        * If set to TRUE, it is an AJAX widget.
+        *
+        * @var boolean
+        * @api
+        */
+       protected $ajaxWidget = FALSE;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
+        */
+       private $ajaxWidgetContextHolder;
+
+       /**
+        * @var Tx_Fluid_Compatibility_ObjectManager
+        */
+       private $objectManager;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetContext
+        */
+       private $widgetContext;
+
+       /**
+        * @param Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectAjaxWidgetContextHolder(Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder) {
+               $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
+       }
+
+       /**
+        * @param Tx_Fluid_Compatibility_ObjectManager $objectManager
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectObjectManager(Tx_Fluid_Compatibility_ObjectManager $objectManager) {
+               $this->objectManager = $objectManager;
+               $this->widgetContext = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetContext');
+       }
+
+       /**
+        * Initialize the arguments of the ViewHelper, and call the render() method of the ViewHelper.
+        *
+        * @param array $renderMethodParameters the parameters of the render() method.
+        * @return string the rendered ViewHelper.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initializeArgumentsAndRender(array $renderMethodParameters) {
+               $this->validateArguments();
+               $this->initialize();
+               $this->initializeWidgetContext();
+
+               return $this->callRenderMethod($renderMethodParameters);
+       }
+
+       /**
+        * Initialize the Widget Context, before the Render method is called.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       private function initializeWidgetContext() {
+               if ($this->ajaxWidget === TRUE) {
+                       $this->ajaxWidgetContextHolder->store($this->widgetContext);
+               }
+
+               $this->widgetContext->setWidgetConfiguration($this->getWidgetConfiguration());
+               $this->initializeWidgetIdentifier();
+
+               $controllerObjectName = ($this->controller instanceof Tx_Fluid_AOP_ProxyInterface) ? $this->controller->FLOW3_AOP_Proxy_getProxyTargetClassName() : get_class($this->controller);
+               $this->widgetContext->setControllerObjectName($controllerObjectName);
+
+               $pluginSignature = strtolower($this->controllerContext->getRequest()->getControllerExtensionName() . '_' . $this->controllerContext->getRequest()->getPluginName());
+               $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespaceByPluginSignature($pluginSignature);
+               $this->widgetContext->setParentPluginNamespace($pluginNamespace);
+
+               $this->widgetContext->setWidgetViewHelperClassName(get_class($this));
+       }
+
+       /**
+        * Stores the syntax tree child nodes in the Widget Context, so they can be
+        * rendered with <f:widget.renderChildren> lateron.
+        *
+        * @param array $childNodes The SyntaxTree Child nodes of this ViewHelper.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setChildNodes(array $childNodes) {
+               $rootNode = $this->objectManager->create('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
+               foreach ($childNodes as $childNode) {
+                       $rootNode->addChildNode($childNode);
+               }
+               $this->widgetContext->setViewHelperChildNodes($rootNode, $this->getRenderingContext());
+       }
+
+       /**
+        * Generate the configuration for this widget. Override to adjust.
+        *
+        * @return array
+        * @api
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetConfiguration() {
+               return $this->arguments;
+       }
+
+       /**
+        * Initiate a sub request to $this->controller. Make sure to fill $this->controller
+        * via Dependency Injection.
+        *
+        * @return Tx_Extbase_MVC_Response the response of this request.
+        * @api
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function initiateSubRequest() {
+               if (!($this->controller instanceof Tx_Fluid_Core_Widget_AbstractWidgetController)) {
+                       throw new Tx_Fluid_Core_Widget_Exception_MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add the @inject annotation in your widget class.', 1284401632);
+               }
+
+               $subRequest = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetRequest');
+               $subRequest->setWidgetContext($this->widgetContext);
+               $this->passArgumentsToSubRequest($subRequest);
+
+               $subResponse = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
+               $this->controller->processRequest($subRequest, $subResponse);
+               return $subResponse;
+       }
+
+       /**
+        * Pass the arguments of the widget to the subrequest.
+        *
+        * @param Tx_Fluid_Core_Widget_WidgetRequest $subRequest
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       private function passArgumentsToSubRequest(Tx_Fluid_Core_Widget_WidgetRequest $subRequest) {
+               $arguments = $this->controllerContext->getRequest()->getArguments();
+               $widgetIdentifier = $this->widgetContext->getWidgetIdentifier();
+               if (isset($arguments[$widgetIdentifier])) {
+                       if (isset($arguments[$widgetIdentifier]['action'])) {
+                               $subRequest->setControllerActionName($arguments[$widgetIdentifier]['action']);
+                               unset($arguments[$widgetIdentifier]['action']);
+                       }
+                       $subRequest->setArguments($arguments[$widgetIdentifier]);
+               }
+       }
+
+       /**
+        * The widget identifier is unique on the current page, and is used
+        * in the URI as a namespace for the widget's arguments.
+        *
+        * @return string the widget identifier for this widget
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @return void
+        * @todo clean up, and make it somehow more routing compatible.
+        */
+       private function initializeWidgetIdentifier() {
+               if (!$this->viewHelperVariableContainer->exists('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber')) {
+                       $widgetCounter = 0;
+               } else {
+                       $widgetCounter = $this->viewHelperVariableContainer->get('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber');
+               }
+               $widgetIdentifier = '__widget_' . $widgetCounter;
+               $this->viewHelperVariableContainer->addOrUpdate('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber', $widgetCounter + 1);
+
+               $this->widgetContext->setWidgetIdentifier($widgetIdentifier);
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/AjaxWidgetContextHolder.php b/typo3/sysext/fluid/Classes/Core/Widget/AjaxWidgetContextHolder.php
new file mode 100644 (file)
index 0000000..4a7289c
--- /dev/null
@@ -0,0 +1,81 @@
+<?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 object stores the WidgetContext for the currently active widgets
+ * of the current user, to make sure the WidgetContext is available in
+ * Widget AJAX requests.
+ *
+ * This class is only used internally by the widget framework.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope session
+ */
+class Tx_Fluid_Core_Widget_AjaxWidgetContextHolder implements t3lib_Singleton {
+
+       /**
+        * Counter which points to the next free Ajax Widget ID which
+        * can be used.
+        *
+        * @var integer
+        */
+       protected $nextFreeAjaxWidgetId = 0;
+
+       /**
+        * An array $ajaxWidgetIdentifier => $widgetContext
+        * which stores the widget context.
+        *
+        * @var array
+        */
+       protected $widgetContexts = array();
+
+    /**
+        * Get the widget context for the given $ajaxWidgetId.
+        *
+        * @param integer $ajaxWidgetId
+        * @return Tx_Fluid_Core_Widget_WidgetContext
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function get($ajaxWidgetId) {
+               $ajaxWidgetId = (int) $ajaxWidgetId;
+               if (!isset($this->widgetContexts[$ajaxWidgetId])) {
+                       throw new Tx_Fluid_Core_Widget_Exception_WidgetContextNotFoundException('No widget context was found for the Ajax Widget Identifier "' . $ajaxWidgetId . '". This only happens if AJAX URIs are called without including the widget on a page.', 1284793775);
+               }
+               return $this->widgetContexts[$ajaxWidgetId];
+       }
+
+       /**
+        * Stores the WidgetContext inside the Context, and sets the
+        * AjaxWidgetIdentifier inside the Widget Context correctly.
+        *
+        * @param Tx_Fluid_Core_Widget_WidgetContext $widgetContext
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function store(Tx_Fluid_Core_Widget_WidgetContext $widgetContext) {
+               $ajaxWidgetId = $this->nextFreeAjaxWidgetId++;
+               $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
+               $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/Exception.php b/typo3/sysext/fluid/Classes/Core/Widget/Exception.php
new file mode 100644 (file)
index 0000000..db0e9a6
--- /dev/null
@@ -0,0 +1,32 @@
+<?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 Fluid Widget exception.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_Core_Widget_Exception extends Tx_Fluid_Core_Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/Exception/MissingControllerException.php b/typo3/sysext/fluid/Classes/Core/Widget/Exception/MissingControllerException.php
new file mode 100644 (file)
index 0000000..db2bc3f
--- /dev/null
@@ -0,0 +1,30 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * An exception if the controller is missing.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_Widget_Exception_MissingControllerException extends Tx_Fluid_Core_Widget_Exception {
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/Exception/RenderingContextNotFoundException.php b/typo3/sysext/fluid/Classes/Core/Widget/Exception/RenderingContextNotFoundException.php
new file mode 100644 (file)
index 0000000..0e2e584
--- /dev/null
@@ -0,0 +1,30 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * An exception if no widget context could be found inside the AjaxWidgetContextHolder.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_Widget_Exception_RenderingContextNotFoundException extends Tx_Fluid_Core_Widget_Exception {
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetContextNotFoundException.php b/typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetContextNotFoundException.php
new file mode 100644 (file)
index 0000000..c236908
--- /dev/null
@@ -0,0 +1,30 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * An exception if no widget context could be found inside the AjaxWidgetContextHolder.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_Widget_Exception_WidgetContextNotFoundException extends Tx_Fluid_Core_Widget_Exception {
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetRequestNotFoundException.php b/typo3/sysext/fluid/Classes/Core/Widget/Exception/WidgetRequestNotFoundException.php
new file mode 100644 (file)
index 0000000..4390f70
--- /dev/null
@@ -0,0 +1,30 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * An exception if no widget Request could be found inside <f:renderChildren>.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_Widget_Exception_WidgetRequestNotFoundException extends Tx_Fluid_Core_Widget_Exception {
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/WidgetContext.php b/typo3/sysext/fluid/Classes/Core/Widget/WidgetContext.php
new file mode 100644 (file)
index 0000000..6cdb32f
--- /dev/null
@@ -0,0 +1,229 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * The WidgetContext stores all information a widget needs to know about the
+ * environment.
+ *
+ * The WidgetContext can be fetched from the current WidgetRequest, and is thus
+ * available throughout the whole sub-request of the widget. It is used internally
+ * by various ViewHelpers (like <f:link.widget>, <f:uri.widget>, <f:widget.renderChildren>),
+ * to get knowledge over the current widget's configuration.
+ *
+ * It is a purely internal class which should not be used outside of Fluid.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Widget_WidgetContext {
+
+       /**
+        * Uniquely idenfies a Widget Instance on a certain page.
+        *
+        * @var string
+        */
+       protected $widgetIdentifier;
+
+       /**
+        * Per-User unique identifier of the widget, if it is an AJAX widget.
+        *
+        * @var integer
+        */
+       protected $ajaxWidgetIdentifier;
+
+       /**
+        * User-supplied widget configuration, available inside the widget
+        * controller as $this->widgetConfiguration.
+        *
+        * @var array
+        */
+       protected $widgetConfiguration;
+
+       /**
+        * The fully qualified object name of the Controller which this widget uses.
+        *
+        * @var string
+        */
+       protected $controllerObjectName;
+
+       /**
+        * The child nodes of the Widget ViewHelper.
+        * Only available inside non-AJAX requests.
+        *
+        * @var Tx_Fluid_Core_Parser_SyntaxTree_RootNode
+        * @transient
+        */
+       protected $viewHelperChildNodes; // TODO: rename to something more meaningful.
+
+       /**
+        * The rendering context of the ViewHelperChildNodes.
+        * Only available inside non-AJAX requests.
+        *
+        * @var Tx_Fluid_Core_Rendering_RenderingContextInterface
+        * @transient
+        */
+       protected $viewHelperChildNodeRenderingContext;
+
+       /**
+        * @var string
+        */
+       protected $parentPluginNamespace;
+
+       /**
+        * @var string
+        */
+       protected $widgetViewHelperClassName;
+
+       /**
+        * @return string
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getWidgetIdentifier() {
+               return $this->widgetIdentifier;
+       }
+
+       /**
+        * @param string $widgetIdentifier
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setWidgetIdentifier($widgetIdentifier) {
+               $this->widgetIdentifier = $widgetIdentifier;
+       }
+
+       /**
+        * @return integer
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getAjaxWidgetIdentifier() {
+               return $this->ajaxWidgetIdentifier;
+       }
+
+       /**
+        * @param integer $ajaxWidgetIdentifier
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setAjaxWidgetIdentifier($ajaxWidgetIdentifier) {
+               $this->ajaxWidgetIdentifier = $ajaxWidgetIdentifier;
+       }
+
+       /**
+        * Sets the URI namespace of the plugin that contains the widget
+        *
+        * @param string $parentPluginNamespace
+        * @return void
+        */
+       public function setParentPluginNamespace($parentPluginNamespace) {
+               $this->parentPluginNamespace = $parentPluginNamespace;
+       }
+
+       /**
+        * Returns the URI namespace of the plugin that contains the widget
+        *
+        * @return string
+        */
+       public function getParentPluginNamespace() {
+               return $this->parentPluginNamespace;
+       }
+
+       /**
+        * Sets the fully qualified class name of the view helper this context belongs to
+        *
+        * @param string $widgetViewHelperClassName
+        * @return void
+        */
+       public function setWidgetViewHelperClassName($widgetViewHelperClassName) {
+               $this->widgetViewHelperClassName = $widgetViewHelperClassName;
+       }
+
+       /**
+        * Returns the fully qualified class name of the view helper this context belongs to
+        *
+        * @return string
+        */
+       public function getWidgetViewHelperClassName() {
+               return $this->widgetViewHelperClassName;
+       }
+
+       /**
+        * @return array
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getWidgetConfiguration() {
+               return $this->widgetConfiguration;
+       }
+
+       /**
+        * @param array $widgetConfiguration
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setWidgetConfiguration($widgetConfiguration) {
+               $this->widgetConfiguration = $widgetConfiguration;
+       }
+
+       /**
+        * @return string
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getControllerObjectName() {
+               return $this->controllerObjectName;
+       }
+
+       /**
+        * @param string $controllerObjectName
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setControllerObjectName($controllerObjectName) {
+               $this->controllerObjectName = $controllerObjectName;
+       }
+
+       /**
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_RootNode $viewHelperChildNodes
+        * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $viewHelperChildNodeRenderingContext
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setViewHelperChildNodes(Tx_Fluid_Core_Parser_SyntaxTree_RootNode $viewHelperChildNodes, Tx_Fluid_Core_Rendering_RenderingContextInterface $viewHelperChildNodeRenderingContext) {
+               $this->viewHelperChildNodes = $viewHelperChildNodes;
+               $this->viewHelperChildNodeRenderingContext = $viewHelperChildNodeRenderingContext;
+       }
+
+       /**
+        * @return Tx_Fluid_Core_Parser_SyntaxTree_RootNode
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getViewHelperChildNodes() {
+               return $this->viewHelperChildNodes;
+       }
+
+       /**
+        * @return Tx_Fluid_Core_Rendering_RenderingContextInterface
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getViewHelperChildNodeRenderingContext() {
+               return $this->viewHelperChildNodeRenderingContext;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequest.php b/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequest.php
new file mode 100644 (file)
index 0000000..b7da24c
--- /dev/null
@@ -0,0 +1,62 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Represents a widget request.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Widget_WidgetRequest extends Tx_Extbase_MVC_Web_Request {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetContext
+        */
+       protected $widgetContext;
+
+       /**
+        * @return Tx_Fluid_Core_Widget_WidgetContext
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getWidgetContext() {
+               return $this->widgetContext;
+       }
+
+       /**
+        * @param Tx_Fluid_Core_Widget_WidgetContext $widgetContext
+        * @return void
+        */
+       public function setWidgetContext(Tx_Fluid_Core_Widget_WidgetContext $widgetContext) {
+               $this->widgetContext = $widgetContext;
+               $this->setControllerObjectName($widgetContext->getControllerObjectName());
+       }
+
+       /**
+        * Returns the unique URI namespace for this widget in the format pluginNamespace[widgetIdentifier]
+        *
+        * @return string
+        */
+       public function getArgumentPrefix() {
+               return $this->widgetContext->getParentPluginNamespace() . '[' . $this->widgetContext->getWidgetIdentifier() . ']';
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestBuilder.php b/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestBuilder.php
new file mode 100644 (file)
index 0000000..94ee6e7
--- /dev/null
@@ -0,0 +1,69 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Builds the WidgetRequest if an AJAX widget is called.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Widget_WidgetRequestBuilder extends Tx_Extbase_MVC_Web_RequestBuilder {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
+        */
+       private $ajaxWidgetContextHolder;
+
+       /**
+        * @param Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectAjaxWidgetContextHolder(Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder) {
+               $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
+       }
+
+       /**
+        * Builds a widget request object from the raw HTTP information
+        *
+        * @return Tx_Fluid_Core_Widget_WidgetRequest The widget request as an object
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function build() {
+               $request = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetRequest');
+               $request->injectEnvironment($this->environment);
+               $request->setMethod($this->environment->getRequestMethod());
+               $this->setArgumentsFromRawRequestData($request);
+
+               $rawGetArguments = $this->environment->getRawGetArguments();
+                       // TODO: rename to @action, to be consistent with normal naming?
+               if (isset($rawGetArguments['action'])) {
+                       $request->setControllerActionName($rawGetArguments['action']);
+               }
+
+               $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['f3-fluid-widget-id']);
+               $request->setWidgetContext($widgetContext);
+               return $request;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestHandler.php b/typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestHandler.php
new file mode 100644 (file)
index 0000000..3993b5b
--- /dev/null
@@ -0,0 +1,54 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Widget request handler, which handles the request if
+ * f3-fluid-widget-id is found.
+ *
+ * This Request Handler gets the WidgetRequestBuilder injected.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Widget_WidgetRequestHandler extends Tx_Extbase_MVC_Web_RequestHandler {
+
+       /**
+        * @return boolean TRUE if it is an AJAX widget request
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function canHandleRequest() {
+               $rawGetArguments = $this->environment->getRawGetArguments();
+               return isset($rawGetArguments['f3-fluid-widget-id']);
+       }
+
+       /**
+        * This request handler has a higher priority than the default request handler.
+        *
+        * @return integer
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getPriority() {
+               return 200;
+       }
+}
+
+?>
\ No newline at end of file
index b2a2f7e..5fdf53d 100644 (file)
@@ -69,13 +69,13 @@ class Tx_Fluid_View_TemplateView extends Tx_Fluid_View_AbstractTemplateView {
         * File pattern for resolving the template file
         * @var string
         */
-       protected $templatePathAndFilenamePattern = '@templateRoot/@controller/@action.@format';
+       protected $templatePathAndFilenamePattern = '@templateRoot/@subpackage/@controller/@action.@format';
 
        /**
         * Directory pattern for global partials. Not part of the public API, should not be changed for now.
         * @var string
         */
-       private $partialPathAndFilenamePattern = '@partialRoot/@partial.@format';
+       private $partialPathAndFilenamePattern = '@partialRoot/@subpackage/@partial.@format';
 
        /**
         * File pattern for resolving the layout
@@ -103,7 +103,7 @@ class Tx_Fluid_View_TemplateView extends Tx_Fluid_View_AbstractTemplateView {
 
                public function initializeView() {
                }
-                                       
+
        // Here, the backporter can insert a constructor method, which is needed for Fluid v4.
 
        /**
@@ -374,10 +374,10 @@ class Tx_Fluid_View_TemplateView extends Tx_Fluid_View_AbstractTemplateView {
                $pattern = str_replace('@partialRoot', $this->getPartialRootPath(), $pattern);
                $pattern = str_replace('@layoutRoot', $this->getLayoutRootPath(), $pattern);
 
-               $subPackageKey = '';
+               $subpackageKey = $this->controllerContext->getRequest()->getControllerSubpackageKey();
                $controllerName = $this->controllerContext->getRequest()->getControllerName();
 
-               $subpackageParts = ($subPackageKey !== '') ? explode(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR, $subPackageKey) : array();
+               $subpackageParts = ($subpackageKey !== NULL) ? explode(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR, $subpackageKey) : array();
 
                $results = array();
 
@@ -397,7 +397,6 @@ class Tx_Fluid_View_TemplateView extends Tx_Fluid_View_AbstractTemplateView {
                        }
 
                } while($i++ < count($subpackageParts) && $bubbleControllerAndSubpackage);
-
                return $results;
        }
 
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php
new file mode 100644 (file)
index 0000000..d722396
--- /dev/null
@@ -0,0 +1,120 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Link_WidgetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'a';
+
+       /**
+        * Initialize arguments
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function initializeArguments() {
+               $this->registerUniversalTagAttributes();
+               $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
+               $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
+               $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
+               $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
+       }
+
+       /**
+        * Render the link.
+        *
+        * @param string $action Target action
+        * @param array $arguments Arguments
+        * @param string $section The anchor to be added to the URI
+        * @param string $format The requested format, e.g. ".html"
+        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
+        * @return string The rendered link
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
+               if ($ajax === TRUE) {
+                       $uri = $this->getAjaxUri();
+               } else {
+                       $uri = $this->getWidgetUri();
+               }
+               $this->tag->addAttribute('href', $uri);
+               $this->tag->setContent($this->renderChildren());
+
+               return $this->tag->render();
+       }
+
+       /**
+        * Get the URI for an AJAX Request.
+        *
+        * @return string the AJAX URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getAjaxUri() {
+               $action = $this->arguments['action'];
+               $arguments = $this->arguments['arguments'];
+
+               if ($action === NULL) {
+                       $action = $this->controllerContext->getRequest()->getControllerActionName();
+               }
+               $arguments['action'] = $action;
+               $arguments['f3-fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               return '?' . http_build_query($arguments, NULL, '&');
+       }
+
+       /**
+        * Get the URI for a non-AJAX Request.
+        *
+        * @return string the Widget URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo argumentsToBeExcludedFromQueryString does not work yet, needs to be fixed.
+        */
+       protected function getWidgetUri() {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+
+               $argumentsToBeExcludedFromQueryString = array(
+                       '@extension',
+                       '@subpackage',
+                       '@controller'
+               );
+
+               return $uriBuilder
+                       ->reset()
+                       ->setArgumentPrefix($this->controllerContext->getRequest()->getArgumentPrefix())
+                       ->setSection($this->arguments['section'])
+                       ->setCreateAbsoluteUri(TRUE)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
+                       ->setFormat($this->arguments['format'])
+                       ->uriFor($this->arguments['action'], $this->arguments['arguments'], '', '', '');
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/RenderChildrenViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/RenderChildrenViewHelper.php
new file mode 100644 (file)
index 0000000..64a2d0f
--- /dev/null
@@ -0,0 +1,115 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Render the inner parts of a Widget.
+ * This ViewHelper can only be used in a template which belongs to a Widget Controller.
+ *
+ * It renders everything inside the Widget ViewHelper, and you can pass additional
+ * arguments.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_RenderChildrenViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * @param array $arguments
+        * @return string
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function render(array $arguments = array()) {
+               $renderingContext = $this->getWidgetRenderingContext();
+               $widgetChildNodes = $this->getWidgetChildNodes();
+
+               $this->addArgumentsToTemplateVariableContainer($arguments);
+               $output = $widgetChildNodes->evaluate($renderingContext);
+               $this->removeArgumentsFromTemplateVariableContainer($arguments);
+
+               return $output;
+       }
+
+       /**
+        * Get the widget rendering context, or throw an exception if it cannot be found.
+        *
+        * @return Tx_Fluid_Core_Rendering_RenderingContextInterface
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetRenderingContext() {
+               $renderingContext = $this->getWidgetContext()->getViewHelperChildNodeRenderingContext();
+               if (!($renderingContext instanceof Tx_Fluid_Core_Rendering_RenderingContextInterface)) {
+                       throw new Tx_Fluid_Core_Widget_Exception_RenderingContextNotFoundException('Rendering Context not found inside Widget. <f:renderChildren> has been used in an AJAX Request, but is only usable in non-ajax mode.', 1284986604);
+               }
+               return $renderingContext;
+       }
+
+       /**
+        * @return Tx_Fluid_Core_Parser_SyntaxTree_RootNode
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetChildNodes() {
+               return $this->getWidgetContext()->getViewHelperChildNodes();
+       }
+
+       /**
+        * @return Tx_Fluid_Core_Widget_WidgetContext
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetContext() {
+               $request = $this->controllerContext->getRequest();
+               if (!($request instanceof Tx_Fluid_Core_Widget_WidgetRequest)) {
+                       throw new Tx_Fluid_Core_Widget_Exception_WidgetRequestNotFoundException('The Request is not a WidgetRequest! <f:renderChildren> must be called inside a Widget Template.', 1284986120);
+               }
+
+               return $request->getWidgetContext();
+       }
+
+       /**
+        * Add the given arguments to the TemplateVariableContainer of the widget.
+        *
+        * @param array $arguments
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function addArgumentsToTemplateVariableContainer(array $arguments) {
+               $templateVariableContainer = $this->getWidgetRenderingContext()->getTemplateVariableContainer();
+               foreach ($arguments as $identifier => $value) {
+                       $templateVariableContainer->add($identifier, $value);
+               }
+       }
+
+       /**
+        * Remove the given arguments from the TemplateVariableContainer of the widget.
+        *
+        * @param array $arguments
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function removeArgumentsFromTemplateVariableContainer(array $arguments) {
+               $templateVariableContainer = $this->getWidgetRenderingContext()->getTemplateVariableContainer();
+               foreach ($arguments as $identifier => $value) {
+                       $templateVariableContainer->remove($identifier);
+               }
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php
new file mode 100644 (file)
index 0000000..640e092
--- /dev/null
@@ -0,0 +1,98 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Uri_WidgetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * Render the Uri.
+        *
+        * @param string $action Target action
+        * @param array $arguments Arguments
+        * @param string $section The anchor to be added to the URI
+        * @param string $format The requested format, e.g. ".html"
+        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
+        * @return string The rendered link
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
+               if ($ajax === TRUE) {
+                       return $this->getAjaxUri();
+               } else {
+                       return $this->getWidgetUri();
+               }
+       }
+
+       /**
+        * Get the URI for an AJAX Request.
+        *
+        * @return string the AJAX URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getAjaxUri() {
+               $action = $this->arguments['action'];
+               $arguments = $this->arguments['arguments'];
+
+               if ($action === NULL) {
+                       $action = $this->controllerContext->getRequest()->getControllerActionName();
+               }
+               $arguments['action'] = $action;
+               $arguments['f3-fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               return '?' . http_build_query($arguments, NULL, '&');
+       }
+
+       /**
+        * Get the URI for a non-AJAX Request.
+        *
+        * @return string the Widget URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo argumentsToBeExcludedFromQueryString does not work yet, needs to be fixed.
+        */
+       protected function getWidgetUri() {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+
+               $argumentsToBeExcludedFromQueryString = array(
+                       '@extension',
+                       '@subpackage',
+                       '@controller'
+               );
+
+               return $uriBuilder
+                       ->reset()
+                       ->setArgumentPrefix($this->controllerContext->getRequest()->getArgumentPrefix())
+                       ->setSection($this->arguments['section'])
+                       ->setCreateAbsoluteUri(TRUE)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
+                       ->setFormat($this->arguments['format'])
+                       ->uriFor($this->arguments['action'], $this->arguments['arguments'], '', '', '');
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/AutocompleteViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/AutocompleteViewHelper.php
new file mode 100644 (file)
index 0000000..bc67706
--- /dev/null
@@ -0,0 +1,62 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Usage:
+ * <f:input id="name" ... />
+ * <f:widget.autocomplete for="name" objects="{posts}" searchProperty="author">
+ *
+ * Make sure to include jQuery and jQuery UI in the HTML, like that:
+ *    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ *    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
+ *    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css" type="text/css" media="all" />
+ *    <link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Widget_AutocompleteViewHelper extends Tx_Fluid_Core_Widget_AbstractWidgetViewHelper {
+
+       /**
+        * @var bool
+        */
+       protected $ajaxWidget = TRUE;
+
+       /**
+        * @inject
+        * @var Tx_Fluid_ViewHelpers_Widget_Controller_AutocompleteController
+        */
+       protected $controller;
+
+       /**
+        *
+        * @param Tx_Extbase_Persistence_QueryResult $objects
+        * @param string $for
+        * @param string $searchProperty
+        * @return string
+        */
+       public function render(Tx_Extbase_Persistence_QueryResult $objects, $for, $searchProperty) {
+               return $this->initiateSubRequest();
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/AutocompleteController.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/AutocompleteController.php
new file mode 100644 (file)
index 0000000..3cc9938
--- /dev/null
@@ -0,0 +1,70 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_ViewHelpers_Widget_Controller_AutocompleteController extends Tx_Fluid_Core_Widget_AbstractWidgetController {
+
+       /**
+        * @return void
+        */
+       public function indexAction() {
+               $this->view->assign('id', $this->widgetConfiguration['for']);
+       }
+
+       /**
+        * @param string $term
+        * @return string
+        */
+       public function autocompleteAction($term) {
+               $searchProperty = $this->widgetConfiguration['searchProperty'];
+               $query = $this->widgetConfiguration['objects']->getQuery();
+               $constraint = $query->getConstraint();
+
+               if ($constraint !== NULL) {
+                       $query->matching($query->logicalAnd(
+                               $constraint,
+                               $query->like($searchProperty, '%' . $term . '%', FALSE)
+                       ));
+               } else {
+                       $query->matching(
+                               $query->like($searchProperty, '%' . $term . '%', FALSE)
+                       );
+               }
+
+               $results = $query->execute();
+
+               $output = array();
+               foreach ($results as $singleResult) {
+                       $val = Tx_Extbase_Reflection_ObjectAccess::getProperty($singleResult, $searchProperty);
+                       $output[] = array(
+                               'id' => $val,
+                               'label' => $val,
+                               'value' => $val
+                       );
+               }
+               return json_encode($output);
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php
new file mode 100644 (file)
index 0000000..6c76775
--- /dev/null
@@ -0,0 +1,103 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_ViewHelpers_Widget_Controller_PaginateController extends Tx_Fluid_Core_Widget_AbstractWidgetController {
+
+       /**
+        * @var array
+        */
+       protected $configuration = array('itemsPerPage' => 10, 'insertAbove' => FALSE, 'insertBelow' => TRUE);
+
+       /**
+        * @var integer
+        */
+       protected $currentPage = 1;
+
+       /**
+        * @var integer
+        */
+       protected $numberOfPages = 1;
+
+       /**
+        * @param integer $currentPage
+        * @return void
+        */
+       public function indexAction($currentPage = 1) {
+               $objects = $this->widgetConfiguration['objects'];
+               $as = $this->widgetConfiguration['as'];
+               $this->configuration = t3lib_div::array_merge_recursive_overrule($this->configuration, $this->widgetConfiguration['configuration'], TRUE);
+               $itemsPerPage = (integer)$this->configuration['itemsPerPage'];
+
+                       // calculate number of pages and set current page
+               $this->numberOfPages = ceil(count($objects) / $itemsPerPage);
+               if ($currentPage < 1) {
+                       $this->currentPage = 1;
+               } elseif ($currentPage > $this->numberOfPages) {
+                       $this->currentPage = $this->numberOfPages;
+               } else {
+                       $this->currentPage = $currentPage;
+               }
+
+                       // modify query
+               $query = $objects->getQuery();
+               $query->setLimit($itemsPerPage);
+               if ($currentPage > 1) {
+                       $query->setOffset($itemsPerPage * ($currentPage - 1));
+               }
+               $modifiedObjects = $query->execute();
+
+               $this->view->assign('contentArguments', array(
+                       $as => $modifiedObjects
+               ));
+               $this->view->assign('configuration', $this->configuration);
+
+               $page = array(
+                       'list' => $this->buildPages(),
+                       'current' => $this->currentPage
+               );
+
+               if ($this->currentPage < $this->numberOfPages) {
+                       $page['next'] = $this->currentPage + 1;
+               }
+               if ($this->currentPage > 1) {
+                       $page['previous'] = $this->currentPage - 1;
+               }
+
+               $this->view->assign('page', $page);
+       }
+
+       /**
+        * @return array
+        */
+       protected function buildPages() {
+               $pages = array();
+               for ($i = 1; $i <= $this->numberOfPages; $i++) {
+                       $pages[] = array('number' => $i, 'isCurrent' => ($i === $this->currentPage));
+               }
+               return $pages;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php
new file mode 100644 (file)
index 0000000..05a53ef
--- /dev/null
@@ -0,0 +1,75 @@
+<?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 ViewHelper renders a Pagination of objects.
+ *
+ * = Examples =
+ *
+ * <code>
+ * <f:widget.paginate itemsPerPage="10" objects="{blogs}" as="paginatedBlogs">
+ *   // use {paginatedBlogs} as you used {blogs} before, most certainly inside
+ *   // a <f:for> loop.
+ * </f:widget.paginate>
+ * </code>
+ *
+ * = Performance characteristics =
+ *
+ * In the above example, it looks like {blogs} contains all Blog objects, thus
+ * you might wonder if all objects were fetched from the database.
+ * However, the blogs are NOT fetched from the database until you actually use them,
+ * so the paginate ViewHelper will adjust the query sent to the database and receive
+ * only the small subset of objects.
+ * So, there is no negative performance overhead in using the Paginate Widget.
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Widget_PaginateViewHelper extends Tx_Fluid_Core_Widget_AbstractWidgetViewHelper {
+
+       /**
+        * @var Tx_Fluid_ViewHelpers_Widget_Controller_PaginateController
+        */
+       protected $controller;
+
+       /**
+        * @param Tx_Fluid_ViewHelpers_Widget_Controller_PaginateController $controller
+        * @return void
+        */
+       public function injectController(Tx_Fluid_ViewHelpers_Widget_Controller_PaginateController $controller) {
+               $this->controller = $controller;
+       }
+
+       /**
+        *
+        * @param Tx_Extbase_Persistence_QueryResult $objects
+        * @param string $as
+        * @param array $configuration
+        * @return string
+        */
+       public function render(Tx_Extbase_Persistence_QueryResult $objects, $as, array $configuration = array('itemsPerPage' => 10, 'insertAbove' => FALSE, 'insertBelow' => TRUE)) {
+               return $this->initiateSubRequest();
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Autocomplete/Index.html b/typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Autocomplete/Index.html
new file mode 100644 (file)
index 0000000..fc56fa9
--- /dev/null
@@ -0,0 +1,8 @@
+<script type="text/javascript">
+jQuery(function() {
+       jQuery("#{id}").autocomplete(<![CDATA[{]]>
+               source: "{f:uri.widget(action:'autocomplete', ajax: 1)}",
+               minLength: 2
+       });
+});
+</script>
diff --git a/typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html b/typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html
new file mode 100644 (file)
index 0000000..06c230c
--- /dev/null
@@ -0,0 +1,29 @@
+<f:if condition="{configuration.insertAbove}">
+       <f:render section="paginator" arguments="{page: page}" />
+</f:if>
+
+<f:renderChildren arguments="{contentArguments}" />
+
+<f:if condition="{configuration.insertBelow}">
+       <f:render section="paginator" arguments="{page: page}" />
+</f:if>
+
+<f:section name="paginator">
+       <ul class="f3-widget-paginator">
+               <f:if condition="{page.previous}">
+                       <li class="previous">
+                               <f:link.widget arguments="{currentPage: page.previous}">previous</f:link.widget>
+                       </li>
+               </f:if>
+               <f:for each="{page.list}" as="singlePage" iteration="iteraton">
+                       <li{f:if(condition:'{singlePage.number} == {page.current}', then: ' class="current"')}>
+                               <f:link.widget arguments="{currentPage: singlePage.number}">{singlePage.number}</f:link.widget>
+                       </li>
+               </f:for>
+               <f:if condition="{page.next}">
+                       <li class="next">
+                               <f:link.widget arguments="{currentPage: page.next}">next</f:link.widget>
+                       </li>
+               </f:if>
+       </ul>
+</f:section>
index 79e646f..66f163c 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_ParsingStateTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * Parsing state
index 6fe431e..19e92c2 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_SyntaxTree_AbstractNodeTest extends Tx_Extbase_BaseTestCase {
 
        protected $renderingContext;
 
index f0a7cf1..adbd9fb 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_SyntaxTree_TextNodeTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index a8fc8e4..2218446 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_SyntaxTree_ViewHelperNodeComparatorTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @var Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
index 0d81457..fa2ab2a 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/../../Fixtures/TestViewHelper.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * Rendering Context
@@ -84,7 +84,7 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function constructorSetsViewHelperAndArguments() {
-               $viewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperInterface');
+               $viewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper');
                $arguments = array('foo' => 'bar');
                $viewHelperNode = $this->getAccessibleMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array('dummy'), array($viewHelper, $arguments));
 
@@ -119,9 +119,9 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function validateArgumentsIsCalledByViewHelperNode() {
-               $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('render', 'validateArguments', 'prepareArguments'));
-               $mockViewHelper->expects($this->once())->method('validateArguments');
+       public function initializeArgumentsAndRenderIsCalledByViewHelperNode() {
+               $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('initializeArgumentsAndRender', 'prepareArguments'));
+               $mockViewHelper->expects($this->once())->method('initializeArgumentsAndRender');
 
                $mockViewHelperArguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
 
@@ -137,16 +137,16 @@ class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNodeTest extends Tx_Extbase_Base
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function renderMethodIsCalledWithCorrectArguments() {
+       public function initializeArgumentsAndRenderIsCalledWithCorrectArguments() {
                $arguments = array(
                        'param0' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param1', 'string', 'Hallo', TRUE, null, FALSE),
                        'param1' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param1', 'string', 'Hallo', TRUE, null, TRUE),
                        'param2' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param2', 'string', 'Hallo', TRUE, null, TRUE)
                );
 
-               $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('render', 'validateArguments', 'prepareArguments'));
+               $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('initializeArgumentsAndRender', 'prepareArguments'));
                $mockViewHelper->expects($this->any())->method('prepareArguments')->will($this->returnValue($arguments));
-               $mockViewHelper->expects($this->once())->method('render')->with('a', 'b');
+               $mockViewHelper->expects($this->once())->method('initializeArgumentsAndRender')->with(array('param1' => 'a', 'param2' => 'b'));
 
                $mockViewHelperArguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
 
index f30756a..7b31c02 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_Parser_TemplateParserPatternTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_Parser_TemplateParserPatternTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
@@ -45,7 +45,7 @@ class Tx_Fluid_Core_Parser_TemplateParserPatternTest extends Tx_Extbase_BaseTest
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function testSPLIT_PATTERN_DYNAMICTAGS() {
-               $pattern = $this->insertNamespaceIntoRegularExpression(Tx_Fluid_Core_Parser_TemplateParser::$SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS, array('f3', 't3'));
+               $pattern = $this->insertNamespaceIntoRegularExpression(Tx_Fluid_Core_Parser_TemplateParser::$SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS, array('f3', 't3', 'f'));
 
                $source = '<html><head> <f3:a.testing /> <f3:blablubb> {testing}</f4:blz> </t3:hi.jo>';
                $expected = array('<html><head> ','<f3:a.testing />', ' ', '<f3:blablubb>', ' {testing}</f4:blz> ', '</t3:hi.jo>');
@@ -71,6 +71,11 @@ class Tx_Fluid_Core_Parser_TemplateParserPatternTest extends Tx_Extbase_BaseTest
                $expected = array('Hallo ', '<f3:testing>', '<![CDATA[<f3:notparsed>]]>', '</f3:testing>');
                $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected, 'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if there is a CDATA section the parser should ignore.');
 
+               $veryLongViewHelper ='<f:form enctype="multipart/form-data" onsubmit="void(0)" onreset="void(0)" action="someAction" arguments="{arg1: \'val1\', arg2: \'val2\'}" controller="someController" package="somePackage" subpackage="someSubpackage" section="someSection" format="txt" additionalParams="{param1: \'val1\', param2: \'val2\'}" absolute="true" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: \'foo\'}" />';
+               $source = $veryLongViewHelper . 'Begin' . $veryLongViewHelper . 'End';
+               $expected = array($veryLongViewHelper, 'Begin', $veryLongViewHelper, 'End');
+               $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected, 'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if the VH has lots of arguments.');
+
        }
 
        /**
index f287d1c..e21c7b2 100644 (file)
@@ -30,7 +30,7 @@ require_once(dirname(__FILE__) . '/Fixtures/PostParseFacetViewHelper.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Parser_TemplateParserTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
@@ -312,8 +312,8 @@ class Tx_Fluid_Core_Parser_TemplateParserTest extends Tx_Extbase_BaseTestCase {
         * @test
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
-       public function initializeViewHelperAndAddItToStackhandlesPostParseFacets() {
-               $mockViewHelper = $this->getMock('Tx_Fluid_Core_Parser_Fixtures_PostParseFacetViewHelper');
+       public function initializeViewHelperAndAddItToStackHandlesPostParseFacets() {
+               $mockViewHelper = $this->getMock('Tx_Fluid_Core_Parser_Fixtures_PostParseFacetViewHelper', array('prepareArguments'));
                $mockViewHelperNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', array(), array(), '', FALSE);
 
                $mockNodeOnStack = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface');
index ab12d83..e34ae48 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_Core_Rendering_RenderingContextTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * Parsing state
index bfb6f94..ff4f281 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_AbstractTagBasedViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_AbstractTagBasedViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        public function setUp() {
                $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper', array('dummy'), array(), '', FALSE);
index 6cb6cc0..1af4cc5 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_TagBuilderTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_TagBuilderTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index f53a16f..d52af13 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../Fixtures/TestViewHelper.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_ViewHelper_AbstractViewHelperTest extends Tx_Extbase_BaseTestCase {
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
@@ -268,5 +268,19 @@ class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest extends Tx_Extbase_BaseTes
                $this->assertSame($viewHelper->_get('viewHelperVariableContainer'), $viewHelperVariableContainer);
        }
 
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initializeArgumentsAndRenderCallsTheCorrectSequenceOfMethods() {
+               $viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('validateArguments', 'initialize', 'callRenderMethod'));
+               $viewHelper->expects($this->at(0))->method('validateArguments');
+               $viewHelper->expects($this->at(1))->method('initialize');
+               $viewHelper->expects($this->at(2))->method('callRenderMethod')->with(array('argument1' => 'value1'))->will($this->returnValue('Output'));
+
+               $expectedOutput = 'Output';
+               $actualOutput = $viewHelper->initializeArgumentsAndRender(array('argument1' => 'value1'));
+               $this->assertEquals($expectedOutput, $actualOutput);
+       }
 }
 ?>
\ No newline at end of file
index 1113f03..4ed40ff 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_ArgumentDefinitionTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_ViewHelper_ArgumentDefinitionTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index 4d59a84..2008241 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../../ViewHelpers/ViewHelperBaseTestcase.php'
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_ViewHelper_AbstractConditionViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_Core_ViewHelper_AbstractConditionViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_Core_ViewHelper_AbstractConditionViewHelper
index 5cd5d82..ec74a47 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_ViewHelper_TemplateVariableContainerTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_ViewHelper_TemplateVariableContainerTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index 73b8629..8a8d5ec 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../Fixtures/TestViewHelper.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainerTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_Core_ViewHelper_ViewHelperVariableContainerTest extends Tx_Extbase_BaseTestCase {
 
        /**
         *
@@ -104,7 +104,7 @@ class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainerTest extends Tx_Extbas
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function viewCanBeReadOutAgain() {
-               $view = $this->getMock('Tx_Fluid_View_AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'hasTemplate'));
+               $view = $this->getMock('Tx_Fluid_View_AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'hasTemplate', 'canRender'));
                $this->viewHelperVariableContainer->setView($view);
                $this->assertSame($view, $this->viewHelperVariableContainer->getView());
        }
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetControllerTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetControllerTest.php
new file mode 100644 (file)
index 0000000..8217c96
--- /dev/null
@@ -0,0 +1,63 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for AbstractWidgetController
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_AbstractWidgetControllerTest extends Tx_Extbase_BaseTestCase {
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function canHandleWidgetRequest() {
+               $request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array('dummy'), array(), '', FALSE);
+               $abstractWidgetController = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array('dummy'), array(), '', FALSE);
+               $this->assertTrue($abstractWidgetController->canProcessRequest($request));
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function processRequestSetsWidgetConfiguration() {
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext', array('getWidgetConfiguration'));
+               $widgetContext->expects($this->once())->method('getWidgetConfiguration')->will($this->returnValue('myConfiguration'));
+
+               $request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array('getWidgetContext', 'getControllerObjectName', 'getControllerActionName'), array(), '', FALSE);
+               $request->expects($this->once())->method('getWidgetContext')->will($this->returnValue($widgetContext));
+
+               $response = $this->getMock('Tx_Fluid_MVC_ResponseInterface');
+
+               $abstractWidgetController = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array('initializeUriBuilder', 'resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'mapRequestArgumentsToControllerArguments', 'resolveView', 'callActionMethod'), array(), '', FALSE);
+
+               $objectManager = $this->getMock('Tx_Fluid_Compatibility_ObjectManager');
+               $abstractWidgetController->_set('objectManager', $objectManager);
+
+               $abstractWidgetController->processRequest($request, $response);
+
+               $widgetConfiguration = $abstractWidgetController->_get('widgetConfiguration');
+               $this->assertEquals('myConfiguration', $widgetConfiguration);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php
new file mode 100644 (file)
index 0000000..7876470
--- /dev/null
@@ -0,0 +1,203 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for AbstractWidgetViewHelper
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_AbstractWidgetViewHelperTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_AbstractWidgetViewHelper
+        */
+       protected $viewHelper;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
+        */
+       protected $ajaxWidgetContextHolder;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetContext
+        */
+       protected $widgetContext;
+
+       /**
+        * @var Tx_Fluid_Compatibility_ObjectManager
+        */
+       protected $objectManager;
+
+       /**
+        * @var Tx_Extbase_MVC_Controller_ControllerContext
+        */
+       protected $controllerContext;
+
+       /**
+        * @var Tx_Extbase_MVC_Web_Request
+        */
+       protected $request;
+
+       /**
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setUp() {
+               $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', array('validateArguments', 'initialize', 'callRenderMethod', 'getWidgetConfiguration', 'getRenderingContext'));
+
+               $this->ajaxWidgetContextHolder = $this->getMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
+               $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder);
+
+               $this->widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
+               $this->viewHelper->injectWidgetContext($this->widgetContext);
+
+               new Tx_Fluid_Compatibility_ObjectManager() = $this->getMock('Tx_Fluid_Compatibility_ObjectManager');
+               $this->viewHelper->injectObjectManager(new Tx_Fluid_Compatibility_ObjectManager());
+
+               $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
+               $this->viewHelper->_set('controllerContext', $this->controllerContext);
+
+               $this->request = $this->getMock('Tx_Extbase_MVC_Web_Request');
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initializeArgumentsAndRenderCallsTheRightSequenceOfMethods() {
+               $this->callViewHelper();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initializeArgumentsAndRenderStoresTheWidgetContextIfInAjaxMode() {
+               $this->viewHelper->_set('ajaxWidget', TRUE);
+               $this->ajaxWidgetContextHolder->expects($this->once())->method('store')->with($this->widgetContext);
+
+               $this->callViewHelper();
+       }
+
+       /**
+        * Calls the ViewHelper, and emulates a rendering.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function callViewHelper() {
+               $viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
+               $this->viewHelper->setViewHelperVariableContainer($viewHelperVariableContainer);
+
+               $this->viewHelper->expects($this->once())->method('getWidgetConfiguration')->will($this->returnValue('Some Widget Configuration'));
+               $this->widgetContext->expects($this->once())->method('setWidgetConfiguration')->with('Some Widget Configuration');
+
+               $this->widgetContext->expects($this->once())->method('setWidgetIdentifier')->with('__widget_0');
+
+               $this->viewHelper->_set('controller', new stdClass());
+               $this->widgetContext->expects($this->once())->method('setControllerObjectName')->with('stdClass');
+
+               $this->viewHelper->expects($this->once())->method('validateArguments');
+               $this->viewHelper->expects($this->once())->method('initialize');
+               $this->viewHelper->expects($this->once())->method('callRenderMethod')->with(array('arg1' => 'val1'))->will($this->returnValue('renderedResult'));
+               $output = $this->viewHelper->initializeArgumentsAndRender(array('arg1' => 'val1'));
+               $this->assertEquals('renderedResult', $output);
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setChildNodesAddsChildNodesToWidgetContext() {
+               $node1 = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode');
+               $node2 = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_TextNode', array(), array(), '', FALSE);
+               $node3 = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode');
+
+               $rootNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
+               $rootNode->expects($this->at(0))->method('addChildNode')->with($node1);
+               $rootNode->expects($this->at(1))->method('addChildNode')->with($node2);
+               $rootNode->expects($this->at(2))->method('addChildNode')->with($node3);
+
+               new Tx_Fluid_Compatibility_ObjectManager()->expects($this->once())->method('create')->with('Tx_Fluid_Core_Parser_SyntaxTree_RootNode')->will($this->returnValue($rootNode));
+
+               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
+               $this->viewHelper->expects($this->once())->method('getRenderingContext')->will($this->returnValue($renderingContext));
+
+               $this->widgetContext->expects($this->once())->method('setViewHelperChildNodes')->with($rootNode, $renderingContext);
+               $this->viewHelper->setChildNodes(array($node1, $node2, $node3));
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Fluid_Core_Widget_Exception_MissingControllerException
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initiateSubRequestThrowsExceptionIfControllerIsNoWidgetController() {
+               $controller = $this->getMock('Tx_Fluid_MVC_Controller_ControllerInterface');
+               $this->viewHelper->_set('controller', $controller);
+
+               $this->viewHelper->_call('initiateSubRequest');
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function initiateSubRequestBuildsRequestProperly() {
+               $controller = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array(), array(), '', FALSE);
+               $this->viewHelper->_set('controller', $controller);
+
+               // Initial Setup
+               $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
+               $response = $this->getMock('Tx_Fluid_MVC_Web_Response');
+               new Tx_Fluid_Compatibility_ObjectManager()->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($widgetRequest));
+               new Tx_Fluid_Compatibility_ObjectManager()->expects($this->at(1))->method('create')->with('Tx_Fluid_MVC_Web_Response')->will($this->returnValue($response));
+
+               // Widget Context is set
+               $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext);
+
+               // The namespaced arguments are passed to the sub-request
+               // and the action name is exctracted from the namespace.
+               $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
+               $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1'));
+               $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array(
+                       'k1' => 'k2',
+                       'widget-1' => array(
+                               'arg1' => 'val1',
+                               'arg2' => 'val2',
+                               'action' => 'myAction'
+                       )
+               )));
+               $widgetRequest->expects($this->once())->method('setArguments')->with(array(
+                       'arg1' => 'val1',
+                       'arg2' => 'val2'
+               ));
+               $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction');
+
+               // Controller is called
+               $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response);
+               $output = $this->viewHelper->_call('initiateSubRequest');
+
+               // SubResponse is returned
+               $this->assertSame($response, $output);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AjaxWidgetContextHolderTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AjaxWidgetContextHolderTest.php
new file mode 100644 (file)
index 0000000..7465dfa
--- /dev/null
@@ -0,0 +1,69 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for AjaxWidgetContextHolder
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_AjaxWidgetContextHolderTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function storeSetsTheAjaxWidgetIdentifierInContextAndIncreasesIt() {
+               $ajaxWidgetContextHolder = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder', array('dummy'));
+               $ajaxWidgetContextHolder->_set('nextFreeAjaxWidgetId', 123);
+
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext', array('setAjaxWidgetIdentifier'));
+               $widgetContext->expects($this->once())->method('setAjaxWidgetIdentifier')->with(123);
+
+               $ajaxWidgetContextHolder->store($widgetContext);
+               $this->assertEquals(124, $ajaxWidgetContextHolder->_get('nextFreeAjaxWidgetId'));
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function storedWidgetContextCanBeRetrievedAgain() {
+               $ajaxWidgetContextHolder = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder', array('dummy'));
+               $ajaxWidgetContextHolder->_set('nextFreeAjaxWidgetId', 123);
+
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext', array('setAjaxWidgetIdentifier'));
+               $ajaxWidgetContextHolder->store($widgetContext);
+
+               $this->assertSame($widgetContext, $ajaxWidgetContextHolder->get('123'));
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @expectedException Tx_Fluid_Core_Widget_Exception_WidgetContextNotFoundException
+        */
+       public function getThrowsExceptionIfWidgetContextIsNotFound() {
+               $ajaxWidgetContextHolder = new Tx_Fluid_Core_Widget_AjaxWidgetContextHolder();
+               $ajaxWidgetContextHolder->get(42);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetContextTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetContextTest.php
new file mode 100644 (file)
index 0000000..85beb5a
--- /dev/null
@@ -0,0 +1,91 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for WidgetContext
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_WidgetContextTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetContext
+        */
+       protected $widgetContext;
+
+       /**
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setUp() {
+               $this->widgetContext = new Tx_Fluid_Core_Widget_WidgetContext();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function widgetIdentifierCanBeReadAgain() {
+               $this->widgetContext->setWidgetIdentifier('myWidgetIdentifier');
+               $this->assertEquals('myWidgetIdentifier', $this->widgetContext->getWidgetIdentifier());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function ajaxWidgetIdentifierCanBeReadAgain() {
+               $this->widgetContext->setAjaxWidgetIdentifier(42);
+               $this->assertEquals(42, $this->widgetContext->getAjaxWidgetIdentifier());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function widgetConfigurationCanBeReadAgain() {
+               $this->widgetContext->setWidgetConfiguration(array('key' => 'value'));
+               $this->assertEquals(array('key' => 'value'), $this->widgetContext->getWidgetConfiguration());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function controllerObjectNameCanBeReadAgain() {
+               $this->widgetContext->setControllerObjectName('Tx_Fluid_Object_Name');
+               $this->assertEquals('Tx_Fluid_Object_Name', $this->widgetContext->getControllerObjectName());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function viewHelperChildNodesCanBeReadAgain() {
+               $viewHelperChildNodes = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
+               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
+
+               $this->widgetContext->setViewHelperChildNodes($viewHelperChildNodes, $renderingContext);
+               $this->assertSame($viewHelperChildNodes, $this->widgetContext->getViewHelperChildNodes());
+               $this->assertSame($renderingContext, $this->widgetContext->getViewHelperChildNodeRenderingContext());
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestBuilderTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestBuilderTest.php
new file mode 100644 (file)
index 0000000..2cae288
--- /dev/null
@@ -0,0 +1,147 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for WidgetRequestBuilder
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_WidgetRequestBuilderTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetRequestBuilder
+        */
+       protected $widgetRequestBuilder;
+
+       /**
+        * @var Tx_Fluid_Compatibility_ObjectManager
+        */
+       protected $mockObjectManager;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetRequest
+        */
+       protected $mockWidgetRequest;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
+        */
+       protected $mockAjaxWidgetContextHolder;
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetContext
+        */
+       protected $mockWidgetContext;
+
+       /**
+        * @var Tx_Fluid_Utility_Environment
+        */
+       protected $mockEnvironment;
+
+       /**
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setUp() {
+               $this->widgetRequestBuilder = $this->getAccessibleMock('Tx_Fluid_Core_Widget_WidgetRequestBuilder', array('setArgumentsFromRawRequestData'));
+
+               $this->mockWidgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
+
+               $this->mockObjectManager = $this->getMock('Tx_Fluid_Compatibility_ObjectManager');
+               $this->mockObjectManager->expects($this->once())->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
+
+               $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
+
+               $this->mockWidgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
+
+               $this->mockAjaxWidgetContextHolder = $this->getMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
+               $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
+               $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
+
+               $this->mockEnvironment = $this->getMock('Tx_Fluid_Utility_Environment');
+               $this->widgetRequestBuilder->_set('environment', $this->mockEnvironment);
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildInjectsEnvironmentInRequest() {
+               $this->mockWidgetRequest->expects($this->once())->method('injectEnvironment')->with($this->mockEnvironment);
+
+               $this->widgetRequestBuilder->build();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildSetsRequestMethodFromEnvironment() {
+               $this->mockEnvironment->expects($this->once())->method('getRequestMethod')->will($this->returnValue('POST'));
+               $this->mockWidgetRequest->expects($this->once())->method('setMethod')->with('POST');
+
+               $this->widgetRequestBuilder->build();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildCallsSetArgumentsFromRawRequestData() {
+               $this->widgetRequestBuilder->expects($this->once())->method('setArgumentsFromRawRequestData')->with($this->mockWidgetRequest);
+
+               $this->widgetRequestBuilder->build();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildSetsControllerActionNameFromGetArguments() {
+               $this->mockEnvironment->expects($this->once())->method('getRawGetArguments')->will($this->returnValue(array('action' => 'myaction', 'f3-fluid-widget-id' => '')));
+               $this->mockWidgetRequest->expects($this->once())->method('setControllerActionName')->with('myaction');
+
+               $this->widgetRequestBuilder->build();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildSetsWidgetContext() {
+               $this->mockEnvironment->expects($this->once())->method('getRawGetArguments')->will($this->returnValue(array('f3-fluid-widget-id' => '123')));
+               $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->with('123')->will($this->returnValue($this->mockWidgetContext));
+               $this->mockWidgetRequest->expects($this->once())->method('setWidgetContext')->with($this->mockWidgetContext);
+
+               $this->widgetRequestBuilder->build();
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function buildReturnsRequest() {
+               $expected = $this->mockWidgetRequest;
+               $actual = $this->widgetRequestBuilder->build();
+               $this->assertSame($expected, $actual);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php
new file mode 100644 (file)
index 0000000..a62499d
--- /dev/null
@@ -0,0 +1,77 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for WidgetRequestHandler
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_WidgetRequestHandlerTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @var Tx_Fluid_Core_Widget_WidgetRequestHandler
+        */
+       protected $widgetRequestHandler;
+
+       /**
+        * @var Tx_Fluid_Utility_Environment
+        */
+       protected $mockEnvironment;
+       
+       /**
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setUp() {
+               $this->mockEnvironment = $this->getMock('Tx_Fluid_Utility_Environment');
+
+               $this->widgetRequestHandler = $this->getAccessibleMock('Tx_Fluid_Core_Widget_WidgetRequestHandler', array('dummy'), array(), '', FALSE);
+               $this->widgetRequestHandler->_set('environment', $this->mockEnvironment);
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function canHandleRequestReturnsTrueIfCorrectGetParameterIsSet() {
+               $this->mockEnvironment->expects($this->once())->method('getRawGetArguments')->will($this->returnValue(array('f3-fluid-widget-id' => '123')));
+               $this->assertTrue($this->widgetRequestHandler->canHandleRequest());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function canHandleRequestReturnsFalsefGetParameterIsNotSet() {
+               $this->mockEnvironment->expects($this->once())->method('getRawGetArguments')->will($this->returnValue(array('some-other-id' => '123')));
+               $this->assertFalse($this->widgetRequestHandler->canHandleRequest());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function priorityIsHigherThanDefaultRequestHandler() {
+               $defaultWebRequestHandler = $this->getMock('Tx_Extbase_MVC_Web_RequestHandler', array('dummy'), array(), '', FALSE);
+               $this->assertTrue($this->widgetRequestHandler->getPriority() > $defaultWebRequestHandler->getPriority());
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestTest.php
new file mode 100644 (file)
index 0000000..bea6dc6
--- /dev/null
@@ -0,0 +1,57 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Testcase for WidgetRequest
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_Core_Widget_WidgetRequestTest extends Tx_Extbase_BaseTestCase {
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setWidgetContextAlsoSetsControllerObjectName() {
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext', array('getControllerObjectName'));
+               $widgetContext->expects($this->once())->method('getControllerObjectName')->will($this->returnValue('Tx_Fluid_ControllerObjectName'));
+
+               $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array('setControllerObjectName'));
+               $widgetRequest->expects($this->once())->method('setControllerObjectName')->with('Tx_Fluid_ControllerObjectName');
+
+               $widgetRequest->setWidgetContext($widgetContext);
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+        public function widgetContextCanBeReadAgain() {
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
+
+               $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array('setControllerObjectName'));
+               $widgetRequest->setWidgetContext($widgetContext);
+
+               $this->assertSame($widgetContext, $widgetRequest->getWidgetContext());
+        }
+}
+?>
\ No newline at end of file
index d5c6289..097cbcf 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_View_AbstractTemplateViewTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_View_AbstractTemplateViewTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @var Tx_Fluid_View_AbstractTemplateView
@@ -57,7 +57,7 @@ class Tx_Fluid_View_AbstractTemplateViewTest extends Tx_Extbase_BaseTestCase {
                $this->renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext', array('getViewHelperVariableContainer', 'getTemplateVariableContainer'));
                $this->renderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->viewHelperVariableContainer));
                $this->renderingContext->expects($this->any())->method('getTemplateVariableContainer')->will($this->returnValue($this->templateVariableContainer));
-               $this->view = $this->getMock('Tx_Fluid_View_AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'hasTemplate'));
+               $this->view = $this->getMock('Tx_Fluid_View_AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'canRender'));
                $this->view->setRenderingContext($this->renderingContext);
        }
 
index 07d06fc..3fd0c42 100644 (file)
@@ -28,7 +28,7 @@ include_once(dirname(__FILE__) . '/Fixtures/TemplateViewFixture.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_View_TemplateViewTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index 9af02f9..a86e275 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_ViewHelpers_AliasViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index abb9699..5a82220 100644 (file)
@@ -23,7 +23,7 @@
 require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 /**
  */
-class Tx_Fluid_ViewHelpers_BaseViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_BaseViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index d9ac7b9..51bfefc 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_CountViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_CountViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_CountViewHelper
index d0b4f5b..af63c55 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_CycleViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_CycleViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_CycleViewHelper
index 7e2a5c7..dee82e0 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_ElseViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_ElseViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index e8a8461..a42dbcd 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_ViewHelpers_ForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index 02e07c0..25d3a3b 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_AbstractFormFieldViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index 6632007..fe7807f 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_AbstractFormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_AbstractFormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index 2949843..0431577 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_CheckboxViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_CheckboxViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper
index 59088d4..cca49f7 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Form_ErrorsViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_ErrorsViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
        /**
         * @test
         * @author Christopher Hlubek <hlubek@networkteam.com>
index 2513ced..5aaf9fa 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_HiddenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_HiddenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_HiddenViewHelper
index 22147a8..508ef0f 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_RadioViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_RadioViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_RadioViewHelper
index 5fc7be1..c6e59c2 100644 (file)
@@ -29,7 +29,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_SelectViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_SelectViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_SelectViewHelper
index 54af57d..b227999 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_SubmitViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_SubmitViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_ubmitViewHelper
index a5c34fa..9fb4c1a 100644 (file)
@@ -29,7 +29,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_TextareaViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_TextareaViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_TextareaViewHelper
index 608f2b6..d2559f0 100644 (file)
@@ -29,7 +29,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_TextboxViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_TextboxViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_TextboxViewHelper
index 188c5de..3178c5d 100644 (file)
@@ -29,7 +29,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Form_UploadViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Form_UploadViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Form_UploadViewHelper
index 2afb7b6..0638230 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 
 /**
  */
-class Tx_Fluid_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
@@ -202,10 +202,8 @@ class Tx_Fluid_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewH
         * @test
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function renderAddsDefaultFieldNamePrefixToTemplateVariableContainerIfNoPrefixIsSpecified() {
-               $expectedPrefix = 'tx_someextension_someplugin';
-               $this->request->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('SomeExtension'));
-               $this->request->expects($this->once())->method('getPluginName')->will($this->returnValue('SomePlugin'));
+       public function renderAddsNoFieldNamePrefixToTemplateVariableContainerIfNoPrefixIsSpecified() {
+               $expectedPrefix = '';
 
                $viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_FormViewHelper', array('renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields', 'renderRequestHashField', 'addFormFieldNamesToViewHelperVariableContainer', 'removeFormFieldNamesFromViewHelperVariableContainer'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($viewHelper);
index b0ce4bc..475589a 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_CurrencyViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_CurrencyViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index 16bb98e..c72cb8b 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_DateViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_DateViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index e946b52..fb8d040 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_Nl2brViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_Nl2brViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index 9a048e2..6a8da58 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_NumberViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_NumberViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index 3446c49..9c66971 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_PaddingViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_PaddingViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index d76802b..3f83a3f 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  */
-class Tx_Fluid_ViewHelpers_Format_PrintfViewHelperTest extends Tx_Extbase_BaseTestCase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Format_PrintfViewHelperTest extends Tx_Extbase_BaseTestCase {
 
        /**
         * @test
index b83731d..451b769 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_GroupedForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_GroupedForViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_GroupedForViewHelper
index 8e01bad..da5c149 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @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 {
+class Tx_Fluid_Tests_Unit_ViewHelpers_IfViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_IfViewHelper
index 7021c32..fa94d24 100644 (file)
@@ -25,7 +25,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
 /**
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_Link_ExternalViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Link_ExternalViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Link_EmailViewHelper
diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/RenderChildrenViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/RenderChildrenViewHelperTest.php
new file mode 100644 (file)
index 0000000..f1fe339
--- /dev/null
@@ -0,0 +1,110 @@
+<?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__) . '/ViewHelperBaseTestcase.php');
+
+/**
+ * Testcase for CycleViewHelper
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Tests_Unit_ViewHelpers_RenderChildrenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+
+       /**
+        * var Tx_Fluid_ViewHelpers_RenderChildrenViewHelper
+        */
+       protected $viewHelper;
+
+       /**
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setUp() {
+               $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
+               $this->viewHelper = $this->getMock('Tx_Fluid_ViewHelpers_RenderChildrenViewHelper', array('renderChildren'));
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function renderCallsEvaluateOnTheRootNodeAndRegistersTheArguments() {
+               $this->request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
+               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
+               $this->viewHelper->setControllerContext($this->controllerContext);
+               $this->viewHelper->initializeArguments();
+
+               $templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
+               $templateVariableContainer->expects($this->at(0))->method('add')->with('k1', 'v1');
+               $templateVariableContainer->expects($this->at(1))->method('add')->with('k2', 'v2');
+               $templateVariableContainer->expects($this->at(2))->method('remove')->with('k1');
+               $templateVariableContainer->expects($this->at(3))->method('remove')->with('k2');
+
+               $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
+               $renderingContext->expects($this->any())->method('getTemplateVariableContainer')->will($this->returnValue($templateVariableContainer));
+
+               $rootNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
+
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
+               $this->request->expects($this->any())->method('getWidgetContext')->will($this->returnValue($widgetContext));
+               $widgetContext->expects($this->any())->method('getViewHelperChildNodeRenderingContext')->will($this->returnValue($renderingContext));
+               $widgetContext->expects($this->any())->method('getViewHelperChildNodes')->will($this->returnValue($rootNode));
+
+               $rootNode->expects($this->any())->method('evaluate')->with($renderingContext)->will($this->returnValue('Rendered Results'));
+
+               $output = $this->viewHelper->render(array('k1' => 'v1', 'k2' => 'v2'));
+               $this->assertEquals('Rendered Results', $output);
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Fluid_Core_Widget_Exception_WidgetRequestNotFoundException
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function renderThrowsExceptionIfTheRequestIsNotAWidgetRequest() {
+               $this->request = $this->getMock('Tx_Fluid_MVC_Request');
+               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
+               $this->viewHelper->setControllerContext($this->controllerContext);
+               $this->viewHelper->initializeArguments();
+
+               $output = $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Fluid_Core_Widget_Exception_RenderingContextNotFoundException
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function renderThrowsExceptionIfTheChildNodeRenderingContextIsNotThere() {
+               $this->request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
+               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
+               $this->viewHelper->setControllerContext($this->controllerContext);
+               $this->viewHelper->initializeArguments();
+
+               $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
+               $this->request->expects($this->any())->method('getWidgetContext')->will($this->returnValue($widgetContext));
+               $widgetContext->expects($this->any())->method('getViewHelperChildNodeRenderingContext')->will($this->returnValue(NULL));
+               $widgetContext->expects($this->any())->method('getViewHelperChildNodes')->will($this->returnValue(NULL));
+
+               $output = $this->viewHelper->render();
+       }
+}
+?>
\ No newline at end of file
index 2b51de7..be91a4a 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_RenderViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_RenderViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_RenderViewHelper
index 1685350..917fb56 100644 (file)
@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_ViewHelpers_ThenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_ThenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * @test
index 11ef23f..6e3f303 100644 (file)
@@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class Tx_Fluid_ViewHelpers_Uri_ExternalViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+class Tx_Fluid_Tests_Unit_ViewHelpers_Uri_ExternalViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
 
        /**
         * var Tx_Fluid_ViewHelpers_Uri_ExternalViewHelper