[TASK] Make BaseViewHelper Compilable 31/37431/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 1 Mar 2015 19:47:09 +0000 (20:47 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 1 Mar 2015 20:58:18 +0000 (21:58 +0100)
Change-Id: If0d763b4fb79ffb1584ea5c60804af63d4da3d7b
Resolves: #65440
Releases: master
Reviewed-on: http://review.typo3.org/37431
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/fluid/Classes/ViewHelpers/BaseViewHelper.php

index 6f221ed..7533b40 100644 (file)
@@ -10,6 +10,11 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+
 /**
  * View helper which creates a <base href="..."></base> tag. The Base URI
  * is taken from the current request.
@@ -27,7 +32,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *
  * @api
  */
-class BaseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class BaseViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Render the "Base" tag by outputting $request->getBaseUri()
@@ -39,7 +44,29 @@ class BaseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
         * @api
         */
        public function render() {
-               return '<base href="' . $this->controllerContext->getRequest()->getBaseUri() . '" />';
+               return self::renderStatic(
+                       array(),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * Render the "Base" tag by outputting $request->getBaseUri()
+        *
+        * Note: renders as <base></base>, because IE6 will else refuse to display
+        * the page...
+        *
+        * @param array $arguments
+        * @param \Closure $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string "base"-Tag.
+        * @api
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $controllerContext = $renderingContext->getControllerContext();
+               return '<base href="' . htmlspecialchars($controllerContext->getRequest()->getBaseUri()) . '" />';
        }
 
 }