Index: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.i18n.php |
— | — | @@ -12,6 +12,31 @@ |
13 | 13 | * @author Ryan Kaldari |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | | - 'landingcheck-desc' => 'This extension facilitates the use of geotargeted localized landing pages. It is a replacement for GeoLite.', |
| 16 | + 'landingcheck-desc' => 'Facilitates the use of geotargeted localized landing pages', |
17 | 17 | 'landingcheck' => 'LandingCheck', |
18 | 18 | ); |
| 19 | + |
| 20 | +/** German (Deutsch) |
| 21 | + * @author Kghbln |
| 22 | + */ |
| 23 | +$messages['de'] = array( |
| 24 | + 'landingcheck-desc' => 'Ermöglicht eine erleichterte Nutzung von mit geografischen Daten verknüpften Zielwebsites in jeweils verfügbaren Sprachen', |
| 25 | + 'landingcheck' => 'Websitezielprüfung', |
| 26 | +); |
| 27 | + |
| 28 | +/** Interlingua (Interlingua) |
| 29 | + * @author McDutchie |
| 30 | + */ |
| 31 | +$messages['ia'] = array( |
| 32 | + 'landingcheck-desc' => 'Facilita le uso de paginas de arrivata specific al position geographic e lingua del usator', |
| 33 | + 'landingcheck' => 'Arrivata localisate', |
| 34 | +); |
| 35 | + |
| 36 | +/** Slovenian (Slovenščina) |
| 37 | + * @author Dbc334 |
| 38 | + */ |
| 39 | +$messages['sl'] = array( |
| 40 | + 'landingcheck-desc' => 'Omogoča uporabo jezikovno prilagojenih ciljnih strani glede na geolokacijo', |
| 41 | + 'landingcheck' => 'PreverjanjePristajališča', |
| 42 | +); |
| 43 | + |
Index: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | $wgExtensionCredits['specialpage'][] = array( |
15 | 15 | 'path' => __FILE__, |
16 | 16 | 'name' => 'LandingCheck', |
17 | | - 'version' => '1.0', |
| 17 | + 'version' => '1.2', |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:LandingCheck', |
19 | 19 | 'author' => 'Ryan Kaldari', |
20 | 20 | 'descriptionmsg' => 'landingcheck-desc', |
— | — | @@ -23,5 +23,6 @@ |
24 | 24 | |
25 | 25 | $wgAutoloadClasses['SpecialLandingCheck'] = $dir . 'SpecialLandingCheck.php'; |
26 | 26 | $wgExtensionMessagesFiles['LandingCheck'] = $dir . 'LandingCheck.i18n.php'; |
| 27 | +$wgExtensionAliasesFiles['LandingCheck'] = $dir . 'LandingCheck.alias.php'; |
27 | 28 | $wgSpecialPages['LandingCheck'] = 'SpecialLandingCheck'; |
28 | 29 | $wgSpecialPageGroups['LandingCheck'] = 'contribution'; |
Index: branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php |
— | — | @@ -5,9 +5,9 @@ |
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
9 | | - * This page checks to see if a version of a landing page exists for the user's language and |
10 | | - * country. If not, it looks for a version localized for the user's language. If that doesn't exist |
11 | | - * either, it looks for the English version. If any of those exist, it then redirects the user. |
| 9 | + * This checks to see if a version of a landing page exists for the user's language and country. |
| 10 | + * If not, it looks for a version localized for the user's language. If that doesn't exist either, |
| 11 | + * it looks for the English version. If any of those exist, it then redirects the user. |
12 | 12 | */ |
13 | 13 | class SpecialLandingCheck extends SpecialPage { |
14 | 14 | |
— | — | @@ -17,12 +17,14 @@ |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function execute( $sub ) { |
21 | | - global $wgOut, $wgUser, $wgRequest, $wgScript; |
| 21 | + global $wgOut, $wgRequest; |
22 | 22 | |
23 | | - $language = $wgRequest->getText( 'language', 'en' ); |
24 | | - $country = $wgRequest->getText( 'country', 'US' ); |
25 | | - $landingPage = $wgRequest->getText( 'landing_page', 'Donate' ); |
| 23 | + // Pull in query string parameters |
| 24 | + $language = $wgRequest->getVal( 'language', 'en' ); |
| 25 | + $country = $wgRequest->getVal( 'country', 'US' ); |
| 26 | + $landingPage = $wgRequest->getVal( 'landing_page', 'Donate' ); |
26 | 27 | |
| 28 | + // Construct new query string for tracking |
27 | 29 | $tracking = wfArrayToCGI( array( |
28 | 30 | 'utm_source' => $wgRequest->getVal( 'utm_source' ), |
29 | 31 | 'utm_medium' => $wgRequest->getVal( 'utm_medium' ), |
— | — | @@ -30,24 +32,26 @@ |
31 | 33 | 'referrer' => $wgRequest->getHeader( 'referer' ) |
32 | 34 | ) ); |
33 | 35 | |
34 | | - if ( $landingPage ) { |
35 | | - if ( strpos( $landingPage, 'Special:' ) === false ) { // landing page is not a special page |
36 | | - $target = Title::newFromText( $landingPage . '/' . $language . '/' . $country ); |
37 | | - if( $target->isKnown() ) { |
38 | | - $wgOut->redirect( $target->getLocalURL( $tracking ) ); |
39 | | - } else { |
40 | | - $target = Title::newFromText( $landingPage . '/' . $language ); |
41 | | - if( $target->isKnown() ) { |
42 | | - $wgOut->redirect( $target->getLocalURL( $tracking ) ); |
43 | | - } elseif ( $language != 'en' ) { |
44 | | - $target = Title::newFromText( $landingPage . '/en' ); |
45 | | - if( $target->isKnown() ) { |
46 | | - $wgOut->redirect( $target->getLocalURL( $tracking ) ); |
47 | | - } |
48 | | - } |
49 | | - } |
50 | | - } |
| 36 | + // Build array of landing pages to check for |
| 37 | + $targetTexts = array( |
| 38 | + $landingPage . '/' . $language . '/' . $country, |
| 39 | + $landingPage . '/' . $language |
| 40 | + ); |
| 41 | + // Add fallback languages |
| 42 | + $code = $language; |
| 43 | + while ( $code !== 'en' ) { |
| 44 | + $code = Language::getFallbackFor( $code ); |
| 45 | + $targetTexts[] = $landingPage . '/' . $code; |
51 | 46 | } |
52 | 47 | |
| 48 | + // Go through the possible landing pages and redirect the user as soon as one is found to exist |
| 49 | + foreach ( $targetTexts as $targetText ) { |
| 50 | + $target = Title::newFromText( $targetText ); |
| 51 | + if ( $target && $target->isKnown() && $target->getNamespace() == NS_MAIN ) { |
| 52 | + $wgOut->redirect( $target->getLocalURL( $tracking ) ); |
| 53 | + return; |
| 54 | + } |
| 55 | + } |
| 56 | + |
53 | 57 | } |
54 | 58 | } |
Index: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.alias.php |
— | — | @@ -0,0 +1,21 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for Special:LandingCheck |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$specialPageAliases = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Ryan Kaldari |
| 14 | + */ |
| 15 | +$specialPageAliases['en'] = array( |
| 16 | + 'LandingCheck' => array( 'LandingCheck' ), |
| 17 | +); |
| 18 | + |
| 19 | +/** |
| 20 | + * For backwards compatibility with MediaWiki 1.15 and earlier. |
| 21 | + */ |
| 22 | +$aliases =& $specialPageAliases; |
\ No newline at end of file |
Property changes on: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 23 | + native |