- added Feature #59437: 6.2 Compatibility
authorchristian.futterlieb <christian.futterlieb@735d13b6-9817-0410-8766-e36946ffe9aa>
Fri, 20 Jun 2014 09:18:30 +0000 (09:18 +0000)
committerchristian.futterlieb <christian.futterlieb@735d13b6-9817-0410-8766-e36946ffe9aa>
Fri, 20 Jun 2014 09:18:30 +0000 (09:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/pagenotfoundehandling/trunk@85672 735d13b6-9817-0410-8766-e36946ffe9aa

Classes/Controller/PagenotfoundController.php
Configuration/TCA/Overrides/TcaAdditions.php
ext_conf_template.txt
ext_tables.sql
locallang_db.xml

index cbf433f..54e17e6 100644 (file)
@@ -151,6 +151,13 @@ class Tx_Pagenotfoundhandling_Controller_PagenotfoundController
      */
     protected $_passthroughContentTypeHeader = false;
 
+    /**
+     * Addtional HTTP headers to be sent with the 404/403 page
+     *
+     * @var array
+     */
+    protected $_additionalHeaders = array();
+
        /**
         * Main method called through tslib_fe::pageErrorHandler()
         *
@@ -288,6 +295,7 @@ class Tx_Pagenotfoundhandling_Controller_PagenotfoundController
                     $this->_forceLanguage = (int) $row['tx_pagenotfoundhandling_forceLanguage'];
                     $this->_languageParam = $row['tx_pagenotfoundhandling_languageParam'];
                     $this->_passthroughContentTypeHeader = (bool) $row['tx_pagenotfoundhandling_passthroughContentTypeHeader'];
+                    $this->_additionalHeaders = \t3lib_div::trimExplode('|', $row['tx_pagenotfoundhandling_additionalHeaders'], true);
 
                     // override 404 page with its 403 equivalent (if needed and configured so)
                     if($this->_isForbiddenError) {
@@ -368,6 +376,10 @@ class Tx_Pagenotfoundhandling_Controller_PagenotfoundController
         if(isset($conf['passthroughContentTypeHeader'])) {
             $this->_passthroughContentTypeHeader = (bool) $conf['passthroughContentTypeHeader'];
         }
+
+        if(isset($conf['additionalHeaders'])) {
+            $this->_additionalHeaders = \t3lib_div::trimExplode('|', $conf['additionalHeaders'], true);
+        }
     }
 
     /**
@@ -436,6 +448,16 @@ class Tx_Pagenotfoundhandling_Controller_PagenotfoundController
                        }
        }
 
+       // send additional HTTP headers
+        if (count($this->_additionalHeaders)) {
+            // disallow sending 'Location' header (redirecting)
+            foreach ($this->_additionalHeaders as $header) {
+                if (!preg_match('/^Location:/i', $header, $matches)) {
+                    header($header);
+                }
+            }
+        }
+
        if(!is_null($html)) {
                return $this->_processMarkers($html);
        }
index 7af55d1..fff0012 100644 (file)
@@ -161,6 +161,15 @@ if(!isset($conf['disableDomainConfig']) || empty($conf['disableDomainConfig']))
                 'default' => '0',
             )
         ),
+        'tx_pagenotfoundhandling_additionalHeaders' => array(
+            'exclude' => 1,
+            'label' => 'LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.sys_domain.additionalHeaders',
+            'displayCond' => 'FIELD:tx_pagenotfoundhandling_enable:REQ:true',
+            'config' => array (
+                'type' => 'input',
+                'default' => '',
+            )
+        ),
     );
 
     $GLOBALS['TCA']['sys_domain']['ctrl']['dividers2tabs'] = 1;
@@ -200,6 +209,7 @@ if(!isset($conf['disableDomainConfig']) || empty($conf['disableDomainConfig']))
         tx_pagenotfoundhandling_ignoreLanguage;;;;1-1-1,
         tx_pagenotfoundhandling_forceLanguage;;;;1-1-1,
         tx_pagenotfoundhandling_languageParam;;;;1-1-1,
-        tx_pagenotfoundhandling_passthroughContentTypeHeader;;;;1-1-1');
+        tx_pagenotfoundhandling_passthroughContentTypeHeader;;;;1-1-1,
+        tx_pagenotfoundhandling_additionalHeaders;;;;1-1-1');
 }
 
index 0712418..2dd8389 100644 (file)
@@ -19,12 +19,15 @@ additional403GetParams =
 # cat=basic/enable; type=options[Default (Do not send special headers)=0, HTTP/1.1 400 Bad Request=1, HTTP/1.1 401 Unauthorized=2, HTTP/1.1 402 Payment Required=3, HTTP/1.1 403 Forbidden=4]; label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.default403Header
 default403Header = 4
 
-# cat=basic/enable; type=boolean; Label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.disableDomainConfig
+# cat=basic/enable; type=boolean; label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.disableDomainConfig
 disableDomainConfig = 0
 
-# cat=basic/enable; type=boolean; Label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.passthroughContentTypeHeader
+# cat=basic/enable; type=boolean; label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.passthroughContentTypeHeader
 passthroughContentTypeHeader = 0
 
+# cat=basic/enable; type=string; label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.additionalHeaders
+additionalHeaders = X-404PageBy: pagenotfoundhandling
+
 # cat=basic/language; type=boolean; label=LLL:EXT:pagenotfoundhandling/locallang_db.xml:pagenotfoundhandling.constants.ignoreLanguage
 ignoreLanguage = 0
 
index cef974e..db93c7c 100644 (file)
@@ -11,4 +11,5 @@ CREATE TABLE sys_domain (
     tx_pagenotfoundhandling_forceLanguage int(11) DEFAULT '0' NOT NULL,
     tx_pagenotfoundhandling_languageParam varchar(45) DEFAULT 'L' NOT NULL,
     tx_pagenotfoundhandling_passthroughContentTypeHeader tinyint(3) DEFAULT '0' NOT NULL
+    tx_pagenotfoundhandling_additionalHeaders text,
 );
\ No newline at end of file
index 07d6404..75de4cb 100644 (file)
@@ -18,6 +18,7 @@
             <label index="pagenotfoundhandling.sys_domain.forceLanguage">Force language</label>
             <label index="pagenotfoundhandling.sys_domain.languageParam">Language parameter</label>
             <label index="pagenotfoundhandling.sys_domain.passthroughContentTypeHeader">Passthrough content-type header</label>
+            <label index="pagenotfoundhandling.sys_domain.additionalHeaders">Additional HTTP headers</label>
             
             <label index="pagenotfoundhandling.constants.forceLanguage">Force language: This language is used to fetch default404Page and/or marker substitution in defaultTemplateFile. Default: ''</label>
             <label index="pagenotfoundhandling.constants.default404Page">Default 404 Page:An uid of a page out of the page tree that will be returned as 404 page. '0' disables this feature. Default: '0'.</label>
@@ -33,6 +34,7 @@
             <label index="pagenotfoundhandling.constants.defaultLanguageKey">Default language key: Use this if your default (or single) language is not TYPO3 default (english). Default: 'default'</label>
             <label index="pagenotfoundhandling.constants.languageParam">Language parameter: This should be the same as config.linkVars. Default: 'L'</label>
             <label index="pagenotfoundhandling.constants.passthroughContentTypeHeader">Passthrough content-type header: When a 404 page is defined, the HTTP header 'Content-Type' will be captured and sent with the 404 page. Default: '0'</label>
+            <label index="pagenotfoundhandling.constants.additionalHeaders">Additional HTTP headers: Send additional HTTP headers with the 404/403 page. Separate headers with '|'. Default: ''</label>
         </languageKey>
         <languageKey index="de" type="array">
             <label index="pagenotfoundhandling.sys_domain.tcasheet.title">404 Behandlung</label>
@@ -47,6 +49,7 @@
             <label index="pagenotfoundhandling.sys_domain.forceLanguage">Sprache erzwingen</label>
             <label index="pagenotfoundhandling.sys_domain.languageParam">Sprachparameter</label>
             <label index="pagenotfoundhandling.sys_domain.passthroughContentTypeHeader">Content-type header weitergeben</label>
+            <label index="pagenotfoundhandling.sys_domain.additionalHeaders">Zusätzliche HTTP header</label>
             
             <label index="pagenotfoundhandling.constants.forceLanguage">Sprache erzwingen: Diese Sprache wird für die Ersetzung der Marker verwendet. Standard: ''</label>
             <label index="pagenotfoundhandling.constants.default404Page">Standard 404 Seite:Die Uid einer Seite im TYPO3 Seitenbaum, die als 404 Seite ausgegeben werden soll. '0' deaktiviert diese Funktion. Standard: '0'.</label>
@@ -62,6 +65,7 @@
             <label index="pagenotfoundhandling.constants.defaultLanguageKey">Standard Sprache: Diese kann gesetzt werden, wenn die als Standard benutzte (oder einzige verwendete) Sprache nicht dem TYPO3 Standard (Englisch) entspricht. Standard: 'default'</label>
             <label index="pagenotfoundhandling.constants.languageParam">Sprachparameter: Sollte dasselbe beinhalten, wie config.linkVars. Standard: 'L'</label>
             <label index="pagenotfoundhandling.constants.passthroughContentTypeHeader">Content-type header weitergeben: Wenn eine 404 Seite definiert ist, kann der HTTP header 'Content-Type' weiter an die Ausgabe gesendet werden. Standard: '0'</label>
+            <label index="pagenotfoundhandling.constants.additionalHeaders">Zusätzliche HTTP header: Sendet die hier definierten HTTP headers mit der 404/403 Seite. Mehrere headers mit '|' trennen. Standard: ''</label>
         </languageKey>
     </data>
 </T3locallang>
\ No newline at end of file