r75891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75890‎ | r75891 | r75892 >
Date:00:25, 3 November 2010
Author:kaldari
Status:deferred
Tags:
Comment:
LandingCheck v1.1
Modified paths:
  • /trunk/extensions/LandingCheck/LandingCheck.php (modified) (history)
  • /trunk/extensions/LandingCheck/SpecialLandingCheck.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LandingCheck/LandingCheck.php
@@ -13,7 +13,7 @@
1414 $wgExtensionCredits['specialpage'][] = array(
1515 'path' => __FILE__,
1616 'name' => 'LandingCheck',
17 - 'version' => '1.0',
 17+ 'version' => '1.1',
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:LandingCheck',
1919 'author' => 'Ryan Kaldari',
2020 'descriptionmsg' => 'landingcheck-desc',
Index: trunk/extensions/LandingCheck/SpecialLandingCheck.php
@@ -19,9 +19,9 @@
2020 public function execute( $sub ) {
2121 global $wgOut, $wgUser, $wgRequest, $wgScript;
2222
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' );
2626
2727 $tracking = wfArrayToCGI( array(
2828 'utm_source' => $wgRequest->getVal( 'utm_source' ),
@@ -30,22 +30,20 @@
3131 'referrer' => $wgRequest->getHeader( 'referer' )
3232 ) );
3333
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 ) {
3845 $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+ }
5048 }
5149 }
5250

Status & tagging log