Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php |
— | — | @@ -961,10 +961,13 @@ |
962 | 962 | 'wgScriptPath' => $wgScriptPath, |
963 | 963 | 'isFilePage' => $isFilePage, |
964 | 964 | 'zeroRatedBanner' => self::$zeroRatedBanner, |
965 | | - 'useFormatCookieName' => 'stopMobileRedirect', |
966 | | - 'useFormatCookieDuration' => $this->getUseFormatCookieDuration(), |
| 965 | + 'stopMobileRedirectCookieName' => 'stopMobileRedirect', |
| 966 | + 'stopMobileRedirectCookieDuration' => $this->getUseFormatCookieDuration(), |
| 967 | + 'stopMobileRedirectCookieDomain' => $this->getBaseDomain(), |
| 968 | + 'useFormatCookieName' => $this->getUseFormatCookieName(), |
| 969 | + 'useFormatCookieDuration' => -1, |
967 | 970 | 'useFormatCookiePath' => $wgCookiePath, |
968 | | - 'useFormatCookieDomain' => $this->getBaseDomain(), |
| 971 | + 'useFormatCookieDomain' => $_SERVER['HTTP_HOST'], |
969 | 972 | ); |
970 | 973 | $applicationTemplate->setByArray( $options ); |
971 | 974 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1280,8 +1283,8 @@ |
1281 | 1284 | } |
1282 | 1285 | |
1283 | 1286 | // check cookies for what to display |
1284 | | - $useFormatCookie = $this->getUseFormatCookie(); |
1285 | | - if ( $useFormatCookie == 'mobile' ) { |
| 1287 | + $useMobileFormat = $this->getUseFormatCookie(); |
| 1288 | + if ( $useMobileFormat == 'true' ) { |
1286 | 1289 | return true; |
1287 | 1290 | } |
1288 | 1291 | $stopMobileRedirect = $this->getStopMobileRedirectCookie(); |
— | — | @@ -1392,7 +1395,7 @@ |
1393 | 1396 | * @param int $string The expiration to set |
1394 | 1397 | * @param bool $force Whether or not to force the cookie getting set |
1395 | 1398 | */ |
1396 | | - public function setUseFormatCookie( $cookieFormat, $expiry = null, $force = false ) { |
| 1399 | + public function setUseFormatCookie( $cookieFormat = 'true', $expiry = null, $force = false ) { |
1397 | 1400 | global $wgCookiePath, $wgCookieSecure; |
1398 | 1401 | |
1399 | 1402 | // sanity check before setting the cookie |
— | — | @@ -1404,7 +1407,7 @@ |
1405 | 1408 | $expiry = $this->getUseFormatCookieExpiry(); |
1406 | 1409 | } |
1407 | 1410 | |
1408 | | - setcookie( $this->getUseFormatCookieName(), $cookieFormat, $expiry, $wgCookiePath, $this->getBaseDomain(), $wgCookieSecure ); |
| 1411 | + setcookie( $this->getUseFormatCookieName(), $cookieFormat, $expiry, $wgCookiePath, $_SERVER['HTTP_HOST'], $wgCookieSecure ); |
1409 | 1412 | wfIncrStats( 'mobile.useformat_' . $cookieFormat . '_cookie_set' ); |
1410 | 1413 | } |
1411 | 1414 | |
— | — | @@ -1420,7 +1423,7 @@ |
1421 | 1424 | |
1422 | 1425 | public function getUseFormatCookieName() { |
1423 | 1426 | if ( !isset( self::$useFormatCookieName ) ) { |
1424 | | - self::$useFormatCookieName = 'mf_useformat'; |
| 1427 | + self::$useFormatCookieName = 'mf_mobileFormat'; |
1425 | 1428 | } |
1426 | 1429 | return self::$useFormatCookieName; |
1427 | 1430 | } |
— | — | @@ -1506,7 +1509,7 @@ |
1507 | 1510 | |
1508 | 1511 | // if no mobileurl template, set mobile cookie |
1509 | 1512 | if ( !strlen( trim( $wgMobileUrlTemplate ) ) ) { |
1510 | | - if ( !$temporary ) $this->setUseFormatCookie( $view ); |
| 1513 | + if ( !$temporary ) $this->setUseFormatCookie(); |
1511 | 1514 | $this->setUseFormat( $view ); |
1512 | 1515 | } else { |
1513 | 1516 | // else redirect to mobile domain |
— | — | @@ -1517,12 +1520,16 @@ |
1518 | 1521 | } |
1519 | 1522 | } elseif ( $view == 'desktop' ) { |
1520 | 1523 | // set stopMobileRedirect cookie |
1521 | | - if ( !$temporary ) $this->setStopMobileRedirectCookie(); |
| 1524 | + if ( !$temporary ) { |
| 1525 | + $this->setStopMobileRedirectCookie(); |
| 1526 | + // unset useformat cookie |
| 1527 | + if ( $this->getUseFormatCookie() == "true" ) { |
| 1528 | + $this->unsetUseFormatCookie(); |
| 1529 | + } |
| 1530 | + } |
1522 | 1531 | |
1523 | 1532 | // if no mobileurl template, unset useformat cookie |
1524 | 1533 | if ( !strlen( trim( $wgMobileUrlTemplate ) ) ) { |
1525 | | - // unset useformat cookie |
1526 | | - if ( !$temporary ) $this->unsetUseFormatCookie(); |
1527 | 1534 | $this->setUseFormat( $view ); |
1528 | 1535 | } else { |
1529 | 1536 | // if mobileurl template, redirect to desktop domain |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -36,16 +36,28 @@ |
37 | 37 | utilities( document.getElementById( 'logo' ) ).bind( 'click', logoClick ); |
38 | 38 | |
39 | 39 | function desktopViewClick() { |
40 | | - var cookieName = MobileFrontend.setting( 'useFormatCookieName' ); |
41 | | - var cookieDuration = MobileFrontend.setting( 'useFormatCookieDuration' ); |
| 40 | + // get mf_mobileFormat cookie info |
| 41 | + var formatCookieName = MobileFrontend.setting( 'useFormatCookieName' ); |
| 42 | + var formatCookieDuration = MobileFrontend.setting( 'useFormatCookieDuration' ); |
42 | 43 | var cookiePath = MobileFrontend.setting( 'useFormatCookiePath' ); |
43 | | - var cookieDomain = MobileFrontend.setting( 'useFormatCookieDomain' ); |
44 | | - |
| 44 | + var formatCookieDomain = MobileFrontend.setting( 'useFormatCookieDomain' ); |
| 45 | + |
45 | 46 | // convert from seconds to days |
46 | | - cookieDuration = cookieDuration / ( 24 * 60 * 60 ); |
| 47 | + formatCookieDuration = formatCookieDuration / ( 24 * 60 * 60 ); |
47 | 48 | |
48 | | - // get the top part of the domain to make the cookie work across subdomains |
49 | | - MobileFrontend.banner.writeCookie( cookieName, 'true', cookieDuration, cookiePath, cookieDomain ); |
| 49 | + // expire the mf_mobileFormat cookie |
| 50 | + MobileFrontend.banner.writeCookie( formatCookieName, '', formatCookieDuration, cookiePath, formatCookieDomain ); |
| 51 | + |
| 52 | + // get stopMobileRedirect cookie info |
| 53 | + var stopMobileRedirectCookieName = MobileFrontend.setting( 'stopMobileRedirectCookieName' ); |
| 54 | + var stopMobileRedirectCookieDuration = MobileFrontend.setting( 'stopMobileRedirectCookieDuration' ); |
| 55 | + var stopMobileRedirectCookieDomain = MobileFrontend.setting( 'stopMobileRedirectCookieDomain' ); |
| 56 | + |
| 57 | + // convert from seconds to days |
| 58 | + stopMobileRedirectCookieDuration = stopMobileRedirectCookieDuration / ( 24 * 60 *60 ); |
| 59 | + |
| 60 | + // set the stopMobileRedirect cookie |
| 61 | + MobileFrontend.banner.writeCookie( stopMobileRedirectCookieName, 'true', stopMobileRedirectCookieDuration, cookiePath, stopMobileRedirectCookieDomain ); |
50 | 62 | } |
51 | 63 | utilities( document.getElementById( 'mf-display-toggle' ) ).bind( 'click', desktopViewClick ); |
52 | 64 | |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php |
— | — | @@ -50,6 +50,9 @@ |
51 | 51 | 'useFormatCookieDuration' => ( $this->data['useFormatCookieDuration'] ), |
52 | 52 | 'useFormatCookieDomain' => ( $this->data['useFormatCookieDomain'] ), |
53 | 53 | 'useFormatCookiePath' => ( $this->data['useFormatCookiePath'] ), |
| 54 | + 'stopMobileRedirectCookieName' => ( $this->data['stopMobileRedirectCookieName'] ), |
| 55 | + 'stopMobileRedirectCookieDuration' => ( $this->data['stopMobileRedirectCookieDuration'] ), |
| 56 | + 'stopMobileRedirectCookieDomain' => ( $this->data['stopMobileRedirectCookieDomain'] ), |
54 | 57 | ), |
55 | 58 | ); |
56 | 59 | if ( $this->data['title']->isMainPage() ) { |