Index: trunk/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.1', |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:LandingCheck', |
19 | 19 | 'author' => 'Ryan Kaldari', |
20 | 20 | 'descriptionmsg' => 'landingcheck-desc', |
Index: trunk/extensions/LandingCheck/SpecialLandingCheck.php |
— | — | @@ -19,9 +19,9 @@ |
20 | 20 | public function execute( $sub ) { |
21 | 21 | global $wgOut, $wgUser, $wgRequest, $wgScript; |
22 | 22 | |
23 | | - $language = $wgRequest->getText( 'language', 'en' ); |
24 | | - $country = $wgRequest->getText( 'country', 'US' ); |
25 | | - $landingPage = $wgRequest->getText( 'landing_page', 'Donate' ); |
| 23 | + $language = $wgRequest->getVal( 'language', 'en' ); |
| 24 | + $country = $wgRequest->getVal( 'country', 'US' ); |
| 25 | + $landingPage = $wgRequest->getVal( 'landing_page', 'Donate' ); |
26 | 26 | |
27 | 27 | $tracking = wfArrayToCGI( array( |
28 | 28 | 'utm_source' => $wgRequest->getVal( 'utm_source' ), |
— | — | @@ -30,22 +30,20 @@ |
31 | 31 | 'referrer' => $wgRequest->getHeader( 'referer' ) |
32 | 32 | ) ); |
33 | 33 | |
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() ) { |
| 34 | + if ( strval( $landingPage ) !== '' ) { |
| 35 | + $targetTexts = array( |
| 36 | + $landingPage . '/' . $language . '/' . $country, |
| 37 | + $landingPage . '/' . $language |
| 38 | + ); |
| 39 | + if ( $language != 'en' ) { |
| 40 | + $targetTexts[] = $landingPage . '/en'; |
| 41 | + } |
| 42 | + foreach ( $targetTexts as $targetText ) { |
| 43 | + $target = Title::newFromText( $targetText ); |
| 44 | + if ( $target && $target->isKnown() && $target->getNamespace() == NS_MAIN ) { |
38 | 45 | $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 | | - } |
| 46 | + return; |
| 47 | + } |
50 | 48 | } |
51 | 49 | } |
52 | 50 | |