[FEATURE] Include jQuery via TypoScript settings
authorLars Peipmann <lars@peipmann.de>
Thu, 5 Jul 2012 13:30:07 +0000 (15:30 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 7 Jul 2012 19:05:24 +0000 (21:05 +0200)
Use function in page renderer to include jQuery via TypoScript settings
with options to change the version and source.

Change-Id: I7fc130bc5fc7ce5e27b8b58998af3406b26ce45d
Releases: 6.0
Resolves: #38678
Reviewed-on: http://review.typo3.org/12630
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/cms/tslib/class.tslib_pagegen.php

index 75efcc3..804eee3 100644 (file)
@@ -620,6 +620,26 @@ class TSpagegen {
                                        $pageRenderer->enableExtCoreDebug();
                                }
                        }
+                               // Include jQuery into the page renderer
+                       if (!empty($GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery'])) {
+                               $jQueryTS = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery.'];
+                                       // Check if version / source is set, if not set variable to "NULL" to use the default of the page renderer
+                               $version = isset($jQueryTS['version']) ? $jQueryTS['version'] : NULL;
+                               $source = isset($jQueryTS['source']) ? $jQueryTS['source'] : NULL;
+                                       // When "noConflict" is not set or "1" use the default namespace of the page renderer, otherwise disable the namespace
+                               if (!isset($jQueryTS['noConflict']) || !empty($jQueryTS['noConflict'])) {
+                                               // Set namespace to the "noConflict.namespace" value if "noConflict.namespace" has a value
+                                       if (!empty($jQueryTS['noConflict.']['namespace'])) {
+                                               $namespace = $jQueryTS['noConflict.']['namespace'];
+                                       } else {
+                                               $namespace = NULL;
+                                       }
+                               } else {
+                                       $namespace = FALSE;
+                               }
+                               $pageRenderer->loadJQuery($version, $source, $namespace);
+                       }
+
                        if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
                                $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
                                $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;