Corrected handling of multiple domains, resolves #43393
authorfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 28 Nov 2012 15:07:22 +0000 (15:07 +0000)
committerfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 28 Nov 2012 15:07:22 +0000 (15:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/rsgoogleanalytics/trunk@68065 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_rsgoogleanalytics.php

index 53b0d19..c0de8e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * Removed usage of deprecated method setAllowHash, resolves #43390\r
        * Changed usage of setAllowLinker to use boolean value, resolves #43391\r
        * Corrected handling of anonymizeIp to use global gat object, resolves #39038\r
+       * Corrected handling of multiple domains, resolves #43393\r
 \r
 2012-05-09 Francois Suter  <typo3@cobweb.ch>\r
 \r
index afe8c72..0e380bb 100644 (file)
@@ -143,10 +143,29 @@ class tx_rsgoogleanalytics implements t3lib_singleton {
         * @return void
         */
        protected function makeDomainConfiguration() {
+                       // If the domain configuration has already been handled, this array will not be empty
+                       // With this check we avoid handling the configuration twice
                if (count($this->domainConfig) == 0) {
                        if ($this->modConfig['multipleDomains'] && $this->modConfig['multipleDomains'] != 'false') {
-                               $this->domainConfig['multiple'] = t3lib_div::trimExplode(',', $this->modConfig['multipleDomains.']['domainNames'], 1);
-                               $this->commands[10] = $this->buildCommand('setDomainName', array('none'));
+                                       // Extract the list of domains
+                               $this->domainConfig['multiple'] = t3lib_div::trimExplode(',', $this->modConfig['multipleDomains.']['domainNames'], TRUE);
+                               $selectedDomain = 'none';
+                               $numberOfDomains = count($this->domainConfig['multiple']);
+                                       // If there's only one, use it as is
+                               if ($numberOfDomains == 1) {
+                                       $selectedDomain = $this->domainConfig['multiple'][0];
+
+                                       // If there are more than one, try to match to the current domain
+                               } elseif ($numberOfDomains > 1) {
+                                       $currentDomain = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
+                                       for ($i = 0; $i < $numberOfDomains; $i++) {
+                                               if (strstr($currentDomain, $this->domainConfig['multiple'][$i]) == $this->domainConfig['multiple'][$i]) {
+                                                       $selectedDomain = $this->domainConfig['multiple'][$i];
+                                                       break;
+                                               }
+                                       }
+                               }
+                               $this->commands[10] = $this->buildCommand('setDomainName', array($selectedDomain));
                                $this->commands[11] = $this->buildCommand('setAllowLinker', array(TRUE));
 
                        } elseif ($this->modConfig['trackSubDomains'] && $this->modConfig['trackSubDomains'] != 'false') {
@@ -193,7 +212,8 @@ class tx_rsgoogleanalytics implements t3lib_singleton {
 
        /**
         * Generates Commands for e-commerce tracking
-        * @return
+        *
+        * @return void
         */
        protected function makeECommerceTracking() {
                if (!$this->modConfig['eCommerce.']['enableTracking']) {
@@ -393,7 +413,10 @@ class tx_rsgoogleanalytics implements t3lib_singleton {
         * @return void
         */
        function linkPostProcess(&$params, $reference) {
-               if (!$this->isActive()) return;
+               if (!$this->isActive()) {
+                       return;
+               }
+                       // Make sure the domain configuration has been handled
                $this->makeDomainConfiguration();
 
                $function = FALSE;