r75956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75955‎ | r75956 | r75957 >
Date:20:46, 3 November 2010
Author:nimishg
Status:ok
Tags:
Comment:
mft r75952 and r7591
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.alias.php (added) (history)
  • /branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.i18n.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.i18n.php
@@ -12,6 +12,31 @@
1313 * @author Ryan Kaldari
1414 */
1515 $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',
1717 'landingcheck' => 'LandingCheck',
1818 );
 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 @@
1414 $wgExtensionCredits['specialpage'][] = array(
1515 'path' => __FILE__,
1616 'name' => 'LandingCheck',
17 - 'version' => '1.0',
 17+ 'version' => '1.2',
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:LandingCheck',
1919 'author' => 'Ryan Kaldari',
2020 'descriptionmsg' => 'landingcheck-desc',
@@ -23,5 +23,6 @@
2424
2525 $wgAutoloadClasses['SpecialLandingCheck'] = $dir . 'SpecialLandingCheck.php';
2626 $wgExtensionMessagesFiles['LandingCheck'] = $dir . 'LandingCheck.i18n.php';
 27+$wgExtensionAliasesFiles['LandingCheck'] = $dir . 'LandingCheck.alias.php';
2728 $wgSpecialPages['LandingCheck'] = 'SpecialLandingCheck';
2829 $wgSpecialPageGroups['LandingCheck'] = 'contribution';
Index: branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php
@@ -5,9 +5,9 @@
66 }
77
88 /**
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.
1212 */
1313 class SpecialLandingCheck extends SpecialPage {
1414
@@ -17,12 +17,14 @@
1818 }
1919
2020 public function execute( $sub ) {
21 - global $wgOut, $wgUser, $wgRequest, $wgScript;
 21+ global $wgOut, $wgRequest;
2222
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' );
2627
 28+ // Construct new query string for tracking
2729 $tracking = wfArrayToCGI( array(
2830 'utm_source' => $wgRequest->getVal( 'utm_source' ),
2931 'utm_medium' => $wgRequest->getVal( 'utm_medium' ),
@@ -30,24 +32,26 @@
3133 'referrer' => $wgRequest->getHeader( 'referer' )
3234 ) );
3335
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;
5146 }
5247
 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+
5357 }
5458 }
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
123 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r92647MFT r75956 - r92645 for LandingCheck.i18n.ph, r78862 - r92646 for SpecialLand...awjrichards17:54, 20 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r7591reset irctrmsrv's comdat properly before parsingkateturner09:19, 6 March 2005
r75952support for chained fallback languageskaldari19:06, 3 November 2010

Status & tagging log