* implemented support for additional header data
authorJochen Rau <j.rau@web.de>
Wed, 4 Feb 2009 21:17:28 +0000 (21:17 +0000)
committerJochen Rau <j.rau@web.de>
Wed, 4 Feb 2009 21:17:28 +0000 (21:17 +0000)
* deleted Web Request Builder and merged necessary code to Dispatcher

typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_Request.php
typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_RequestBuilder.php [deleted file]
typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_Response.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index 130b723..d6f670a 100755 (executable)
@@ -82,11 +82,11 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        /**
         * Sets the request URI
         *
-        * @param F3_FLOW3_Property_DataType_URI $requestURI URI of this web request
+        * @param string $requestURI URI of this web request
         * @return void
         * @author Robert Lemke <robert@typo3.org>
         */
-       public function setRequestURI(F3_FLOW3_Property_DataType_URI $requestURI) {
+       public function setRequestURI($requestURI) {
                $this->requestURI = clone $requestURI;
                $this->baseURI = $this->detectBaseURI($requestURI);
        }
@@ -104,11 +104,11 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        /**
         * Sets the base URI for this request.
         *
-        * @param F3_FLOW3_Property_DataType_URI $baseURI New base URI
+        * @param string $baseURI New base URI
         * @return void
         * @author Robert Lemke <robert@typo3.org>
         */
-       public function setBaseURI(F3_FLOW3_Property_DataType_URI $baseURI) {
+       public function setBaseURI($baseURI) {
                $this->baseURI = clone $baseURI;
        }
 
@@ -125,11 +125,11 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        /**
         * Tries to detect the base URI of this request and returns it.
         *
-        * @param F3_FLOW3_Property_DataType_URI $requestURI URI of this web request
-        * @return F3_FLOW3_Property_DataType_URI The detected base URI
+        * @param string $requestURI URI of this web request
+        * @return string The detected base URI
         * @author Robert Lemke <robert@typo3.org>
         */
-       protected function detectBaseURI(F3_FLOW3_Property_DataType_URI $requestURI) {
+       protected function detectBaseURI($requestURI) {
                $baseURI = clone $requestURI;
                $baseURI->setQuery(NULL);
                $baseURI->setFragment(NULL);
diff --git a/typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_RequestBuilder.php b/typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_RequestBuilder.php
deleted file mode 100644 (file)
index cb60119..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * 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 a web request object from the raw HTTP information
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class TX_EXTMVC_Web_RequestBuilder {
-
-       /**
-        * @var TX_EXTMVC_Configuration_Manager
-        */
-       protected $configurationManager;
-
-       /**
-        * Injects the configuration manager
-        *
-        * @param TX_EXTMVC_Configuration_Manager $configurationManager A reference to the configuration manager
-        * @return void
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function injectConfigurationManager(TX_EXTMVC_Configuration_Manager $configurationManager) {
-               $this->configurationManager = $configurationManager;
-       }
-
-       /**
-        * Builds a web request object from the raw HTTP information
-        *
-        * @return TX_EXTMVC_Web_Request The web request as an object
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function build() {
-               $request = t3lib_div::makeInstance('TX_EXTMVC_Web_Request');
-               // $request->injectEnvironment($this->environment);
-               // $request->setRequestURI($this->environment->getRequestURI());
-               // $request->setMethod($this->environment->getRequestMethod());
-               // 
-               // $routesConfiguration = $this->configurationManager->getSpecialConfiguration(TX_EXTMVC_Configuration_Manager::CONFIGURATION_TYPE_ROUTES);
-               // $this->router->setRoutesConfiguration($routesConfiguration);
-               // $this->router->route($request);
-
-               return $request;
-       }
-}
-?>
\ No newline at end of file
index 172ed49..36b99e4 100755 (executable)
@@ -31,11 +31,11 @@ declare(ENCODING = 'utf-8');
 class TX_EXTMVC_Web_Response extends TX_EXTMVC_Response {
 
        /**
-        * The HTTP headers which will be sent in the response
+        * Additional header tags
         *
         * @var array
         */
-       protected $headers = array();
+       protected $additionalHeaderTags = array();
 
        /**
         * The HTTP status code
@@ -131,40 +131,26 @@ class TX_EXTMVC_Web_Response extends TX_EXTMVC_Response {
        }
 
        /**
-        * Sets the specified HTTP header
+        * Adds an additional header tag (something like
+        * '<script src="myext/Resources/JavaScript/my.js" type="text/javascript"></script>'
+        * )
         *
-        * @param string $name Name of the header, for example "Location", "Content-Description" etc.
-        * @param mixed $value The value of the given header
-        * @param boolean $replaceExistingHeader If a header with the same name should be replaced. Default is TRUE.
+        * @param string $headerString The value additonal header
         * @return void
-        * @author Robert Lemke <robert@typo3.org>
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function setHeader($name, $value, $replaceExistingHeader = TRUE) {
-               if (strtoupper(substr($name, 0, 4)) == 'HTTP') throw new InvalidArgumentException('The HTTP status header must be set via setStatus().', 1220541963);
-               if ($replaceExistingHeader === TRUE || !isset($this->headers[$name])) {
-                       $this->headers[$name] = array($value);
-               } else {
-                       $this->headers[$name][] = $value;
-               }
+       public function addAdditionalHeaderTag($headerTag) {
+               $this->additionalHeaderTags[] = $headerTag;
        }
 
        /**
-        * Returns the HTTP headers - including the status header - of this web response
+        * Returns the additional header tags
         *
-        * @return string The HTTP headers
-        * @author Robert Lemke <robert@typo3.org>
+        * @return array The additional header tags
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function getHeaders() {
-               $preparedHeaders = array();
-               $statusHeader = 'HTTP/1.1 ' . $this->statusCode . ' ' . $this->statusMessage;
-
-               $preparedHeaders[] = $statusHeader;
-               foreach ($this->headers as $name => $values) {
-                       foreach ($values as $value) {
-                               $preparedHeaders[] = $name . ': ' . $value;
-                       }
-               }
-               return $preparedHeaders;
+       public function getAdditionalHeaderTags() {
+               return $this->additionalHeaderTags;
        }
 
 }
index 3ff5202..7c54012 100644 (file)
@@ -23,7 +23,6 @@ declare(ENCODING = 'utf-8');
 
 // TODO these statements become obsolete with the new autoloader -> remove them
 
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Web/TX_EXTMVC_Web_RequestBuilder.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_Request.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Web/TX_EXTMVC_Web_Request.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_Response.php');
@@ -91,8 +90,7 @@ class TX_EXTMVC_Dispatcher {
                // debug($configuration);
                // TODO instantiate the configurationManager
                
-               $requestBuilder = t3lib_div::makeInstance('TX_EXTMVC_Web_RequestBuilder');
-               $request = $requestBuilder->build();
+               $request = t3lib_div::makeInstance('TX_EXTMVC_Web_Request');
                $request->setControllerExtensionKey($configuration['extension']);
                $request->setControllerName($configuration['controller']);
                $request->setControllerActionName($configuration['action']);
@@ -115,6 +113,8 @@ class TX_EXTMVC_Dispatcher {
                $session->commit();
                $session->clear();
                
+               $GLOBALS['TSFE']->additionalHeaderData[$request->getControllerExtensionKey()] = implode("\n", $response->getAdditionalHeaderTags());
+               
                return $response->getContent();
        }