diff --git a/ChangeLog b/ChangeLog index 3e5cc94..61f4e68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,11 @@ - No features added, support for Typo3 4.x dropped. Please use version 1.4.4 if you still use 4.x! - However some renaming took place +2014-12-03 Hannes Lau + * Prepare for next release + - A standard cookie will not force a redirect from the mobile to the standard version anymore. Instead the cookies just serve to prevent an automatic redirection from standard to mobile. + - Allow to configure the cookie domain + 2014-09-29 Carsten Windler * Version 1.4.4 released: - Feature #61801: Ensure compatibility with Typo3 6.2.x diff --git a/Classes/Main.php b/Classes/Main.php index 2302d56..dff332d 100755 --- a/Classes/Main.php +++ b/Classes/Main.php @@ -321,7 +321,7 @@ public function checkRedirect() } // here the real detection begins - if ($this->detectMobile() && $this->conf['redirection_enabled']) { + if ($this->conf['redirection_enabled'] && !$this->isStandardAccepted() && $this->detectMobile()) { $this->redirectToMobileUrl(false); } @@ -445,8 +445,13 @@ protected function setExtensionCookie($cookieValue) { if ($this->conf['use_cookie']) { $this->debugLog('Setting cookie', array('cookie_value' => $cookieValue)); - - return setcookie($this->conf['cookie_name'], $cookieValue, time()+$this->conf['cookie_lifetime'], "/"); + return setcookie( + $this->conf['cookie_name'], + $cookieValue, + time()+$this->conf['cookie_lifetime'], + "/", // path + trim($this->conf['cookie_domain']) // domain + ); } else { return false; } @@ -474,7 +479,7 @@ public function isStandardUrlRequested() /** * Determine if the standard mode is forced - * (checks Cookie and GET params) + * (checks GET params) * * @return boolean - true if standard mode is forced, false otherwise * @@ -486,12 +491,7 @@ public function isStandardForced() $this->debugLog(print_r($_GET, 1)); $this->debugLog("--------------- isStandardForced END ----------------------"); - return ((isset($_COOKIE[$this->conf['cookie_name']]) && - $_COOKIE[$this->conf['cookie_name']] == self::MOBILEREDIRECT_COOKIE_STANDARD && - !isset($_GET[$this->conf['is_mobile_name']])) || - (!empty($this->conf['no_mobile_name']) && isset($_GET[$this->conf['no_mobile_name']]))) - ? true - : false; + return (!empty($this->conf['no_mobile_name']) && isset($_GET[$this->conf['no_mobile_name']])) ? true : false; } /** @@ -507,12 +507,30 @@ public function isMobileForced() $this->debugLog(print_r($_GET, 1)); $this->debugLog("--------------- isMobileForced END ----------------------"); - return ((isset($_COOKIE[$this->conf['cookie_name']]) && - $_COOKIE[$this->conf['cookie_name']] == self::MOBILEREDIRECT_COOKIE_MOBILE && - !isset($_GET[$this->conf['no_mobile_name']])) || - (!empty($this->conf['is_mobile_name']) && isset($_GET[$this->conf['is_mobile_name']]))) - ? true - : false; + return (!empty($this->conf['is_mobile_name']) && isset($_GET[$this->conf['is_mobile_name']])) ? true : false; + } + + + + /** + * Determine if the standard mode is accepted + * (checks Cookie) + * + * @return boolean - true if the standard is forced OR a standard cookie is set + */ + public function isStandardAccepted() + { + $this->debugLog("--------------- isMobileAccepted BEGIN ----------------------"); + $this->debugLog(print_r($_COOKIE,1)); + $this->debugLog("--------------- isMobileAccepted END ----------------------"); + + return + $this->isStandardForced() + || ( + !$this->isMobileForced() + && ((isset($_COOKIE[$this->conf['cookie_name']]) && $_COOKIE[$this->conf['cookie_name']] == self::MOBILEREDIRECT_COOKIE_STANDARD)) + ) + ; } /** diff --git a/composer.json b/composer.json index f2c5c68..bf31473 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "license": "GPL-2.0+", "require": { - "typo3/cms-core": "^6.2.0|^7.6.0" + "typo3/cms-core": "^6.2.0|^7.6.0|^8" }, "require-dev": { "mikey179/vfsStream": "1.4.*@dev", diff --git a/ext_conf_template.txt b/ext_conf_template.txt index 40583fd..4ffff50 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -16,6 +16,9 @@ cookie_name = tx_cwmobileredirect # cat=basic; type=text; label=Cookie lifetime:Seconds until the Cookie expires cookie_lifetime = 3600 +# cat=basic; type=text; label=Cookie domain:Domain for which the cookie will be valid. Defaults to hostname. +cookie_domain = + # cat=basic; type=text; label=is mobile GET name:GET-Parameter to force mobile version (e.g. www.domain.com?isMobile) is_mobile_name = isMobile diff --git a/ext_emconf.php b/ext_emconf.php index 4a49ce3..12096d0 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -24,7 +24,7 @@ array ( 'depends' => array ( - 'typo3' => '7.5.0-7.99.99', + 'typo3' => '7.5.0-8.99.99', ), 'conflicts' => array (