[+BUGFIX] Fluid (Core/Widget): AjaxWidgetContextHolder now uses a unique id for the...
authorBastian Waidelich <bastian@typo3.org>
Mon, 15 Nov 2010 16:55:54 +0000 (16:55 +0000)
committerBastian Waidelich <bastian@typo3.org>
Mon, 15 Nov 2010 16:55:54 +0000 (16:55 +0000)
[+BUGFIX] Fluid (Core): The Fluid Widget Bootstrap now initializes the object manager in order to respect "config.tx_extbase.object" configuration.. TODO: this should be somehow refactored to avoid code duplication
[+BUGFIX] Fluid: Reduced the typeNum for the fluidAjaxWidgetResponse page. Apparently 7076857368 was too large ;) TODO: the typeNum should be somehow configurable
[~TASK] Fluid (ViewHelpers/Widget): removed $GLOBALS['TSFE']->additionalHeaderData call from AutocompleteViewHelper as this is not configurable like this. Moved the jQuery includes to Configuration/TypoScript/setup.txt which can be included in your main TS template

typo3/sysext/fluid/Classes/Core/Widget/AjaxWidgetContextHolder.php
typo3/sysext/fluid/Classes/Core/Widget/Bootstrap.php
typo3/sysext/fluid/Classes/Core/Widget/WidgetContext.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Widget/AutocompleteViewHelper.php
typo3/sysext/fluid/Configuration/TypoScript/setup.txt
typo3/sysext/fluid/ext_typoscript_setup.txt

index 4572905..7696d32 100644 (file)
 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.
         *
@@ -77,12 +69,11 @@ class Tx_Fluid_Core_Widget_AjaxWidgetContextHolder implements t3lib_Singleton {
        /**
         * Get the widget context for the given $ajaxWidgetId.
         *
-        * @param integer $ajaxWidgetId
+        * @param string $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);
                }
@@ -98,8 +89,7 @@ class Tx_Fluid_Core_Widget_AjaxWidgetContextHolder implements t3lib_Singleton {
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function store(Tx_Fluid_Core_Widget_WidgetContext $widgetContext) {
-               // TODO persist nextFreeAjaxWidgetId in session
-               $ajaxWidgetId = $this->nextFreeAjaxWidgetId ++;
+               $ajaxWidgetId = md5(uniqid(mt_rand(), TRUE));
                $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
                $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
                $this->storeWidgetContexts();
index d71c478..213c4f2 100644 (file)
@@ -49,6 +49,7 @@ class Tx_Fluid_Core_Widget_Bootstrap {
                $this->initializeClassLoader();
                $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
                $this->initializeConfiguration($configuration);
+               $this->configureObjectManager();
                $ajaxWidgetContextHolder = $this->objectManager->get('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
 
                $widgetIdentifier = t3lib_div::_GET('fluid-widget-id');
@@ -88,6 +89,28 @@ class Tx_Fluid_Core_Widget_Bootstrap {
                $this->configurationManager->setContentObject($contentObject);
                $this->configurationManager->setConfiguration($configuration);
        }
+
+       /**
+        * Configures the object manager object configuration from
+        * config.tx_extbase.objects
+        *
+        * @return void
+        * @see initialize()
+        * @todo this is duplicated code (see Tx_Extbase_Core_Bootstrap::configureObjectManager())
+        */
+       public function configureObjectManager() {
+               $typoScriptSetup = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
+               if (isset($typoScriptSetup['config.']['tx_extbase.']['objects.']) && is_array($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
+                       $objectConfiguration = $typoScriptSetup['config.']['tx_extbase.']['objects.'];
+
+                       foreach ($objectConfiguration as $classNameWithDot => $classConfiguration) {
+                               if (isset($classConfiguration['className'])) {
+                                       $originalClassName = substr($classNameWithDot, 0, -1);
+                                       Tx_Extbase_Object_Container_Container::getContainer()->registerImplementation($originalClassName, $classConfiguration['className']);
+                               }
+                       }
+               }
+       }
 }
 
 ?>
\ No newline at end of file
index 7467108..79ff83f 100644 (file)
@@ -46,7 +46,7 @@ class Tx_Fluid_Core_Widget_WidgetContext {
        /**
         * Per-User unique identifier of the widget, if it is an AJAX widget.
         *
-        * @var integer
+        * @var string
         */
        protected $ajaxWidgetIdentifier;
 
@@ -121,7 +121,7 @@ class Tx_Fluid_Core_Widget_WidgetContext {
        }
 
        /**
-        * @return integer
+        * @return string
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function getAjaxWidgetIdentifier() {
@@ -129,7 +129,7 @@ class Tx_Fluid_Core_Widget_WidgetContext {
        }
 
        /**
-        * @param integer $ajaxWidgetIdentifier
+        * @param string $ajaxWidgetIdentifier
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
index 78aebe3..1f40dc0 100644 (file)
@@ -85,10 +85,12 @@ class Tx_Fluid_ViewHelpers_Link_WidgetViewHelper extends Tx_Fluid_Core_ViewHelpe
                if ($action === NULL) {
                        $action = $this->controllerContext->getRequest()->getControllerActionName();
                }
-               $arguments['action'] = $action;
-               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               $arguments['id'] = $GLOBALS['TSFE']->id;
                // TODO page type should be configurable
-               $arguments['type'] = 7076857368;
+               $arguments['type'] = 7076;
+               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               $arguments['action'] = $action;
+
                return '?' . http_build_query($arguments, NULL, '&');
        }
 
index 3fa6db3..2daf720 100644 (file)
@@ -63,11 +63,12 @@ class Tx_Fluid_ViewHelpers_Uri_WidgetViewHelper extends Tx_Fluid_Core_ViewHelper
                if ($action === NULL) {
                        $action = $this->controllerContext->getRequest()->getControllerActionName();
                }
-               $arguments['action'] = $action;
-               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
                $arguments['id'] = $GLOBALS['TSFE']->id;
                // TODO page type should be configurable
-               $arguments['type'] = 7076857368;
+               $arguments['type'] = 7076;
+               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               $arguments['action'] = $action;
+
                return '?' . http_build_query($arguments, NULL, '&');
        }
 
index 2139a36..d0445b9 100644 (file)
@@ -63,7 +63,6 @@ class Tx_Fluid_ViewHelpers_Widget_AutocompleteViewHelper extends Tx_Fluid_Core_W
         * @return string
         */
        public function render(Tx_Extbase_Persistence_QueryResult $objects, $for, $searchProperty) {
-               $GLOBALS['TSFE']->additionalHeaderData['Tx_Fluid_ViewHelpers_Widget_AutocompleteViewHelper'] ='<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>';
                return $this->initiateSubRequest();
        }
 }
index 4c7f602..3576242 100644 (file)
@@ -1,6 +1,7 @@
- # jQuery library and default styles for Fluid Autocomplete Widget (optional)
-page.headerData.jquery = TEXT
-page.headerData.jquery.value (
+ # includes jQuery library and default styles for Fluid Autocomplete Widget
+page.headerData.998 = TEXT
+page.headerData.998.value (
+       <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" />
index 4941613..162c24c 100644 (file)
@@ -1,6 +1,7 @@
 fluidAjaxWidgetResponse = PAGE
 fluidAjaxWidgetResponse {
-       typeNum = 7076857368 # todo: make page type configurable
+        # todo: make page type configurable
+       typeNum = 7076
        headerData >
        config {
                no_cache=1