r68602 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68601‎ | r68602 | r68603 >
Date:08:16, 26 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Simple redirector page to help with page translation feature.

Any ides for better name?
Modified paths:
  • /trunk/extensions/Translate/SpecialMyLanguage.php (added) (history)
  • /trunk/extensions/Translate/Translate.alias.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/_autoload.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialMyLanguage.php
@@ -0,0 +1,38 @@
 2+<?php
 3+
 4+/**
 5+ * Special page just to redirect the user to translated version if page,
 6+ * if it exists.
 7+ *
 8+ * Usage: [[Special:MyLanguage/Page name|link text]]
 9+ *
 10+ * @author Niklas Laxström
 11+ * @copyright Copyright © 2010 Niklas Laxström, Siebrand Mazeland
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ */
 14+class SpecialMyLanguage extends SpecialPage {
 15+ public function __construct() {
 16+ parent::__construct( 'MyLanguage' );
 17+ $this->setListed( false );
 18+ }
 19+
 20+ public function execute( $par ) {
 21+ global $wgOut, $wgLang;
 22+ if ( strval($par) !== '' ) {
 23+ $title = Title::newFromText( $par );
 24+ if ( $title && $title->exists() ) {
 25+ $local = Title::newFromText( "$par/" . $wgLang->getCode() );
 26+ if ( $local && $local->exists() ) {
 27+ $title = $local;
 28+ }
 29+ }
 30+ }
 31+
 32+ // Go to the main page if given invalid title
 33+ if ( !$title ) {
 34+ $title = Title::newMainPage();
 35+ }
 36+
 37+ $wgOut->redirect( $title->getLocalURL() );
 38+ }
 39+}
Property changes on: trunk/extensions/Translate/SpecialMyLanguage.php
___________________________________________________________________
Name: svn:eol-style
140 + native
Index: trunk/extensions/Translate/Translate.php
@@ -43,6 +43,7 @@
4444 $wgSpecialPages['ImportTranslations'] = 'SpecialImportTranslations';
4545 $wgSpecialPages['FirstSteps'] = 'SpecialFirstSteps';
4646 $wgSpecialPages['SupportedLanguages'] = 'SpecialSupportedLanguages';
 47+$wgSpecialPages['MyLanguage'] = 'SpecialMyLanguage';
4748 $wgSpecialPageGroups['Magic'] = 'wiki';
4849 $wgSpecialPageGroups['Translate'] = 'wiki';
4950 $wgSpecialPageGroups['Translations'] = 'pages';
Index: trunk/extensions/Translate/_autoload.php
@@ -50,6 +50,7 @@
5151 $wgAutoloadClasses['SpecialImportTranslations'] = $dir . 'SpecialImportTranslations.php';
5252 $wgAutoloadClasses['SpecialFirstSteps'] = $dir . 'SpecialFirstSteps.php';
5353 $wgAutoloadClasses['SpecialSupportedLanguages'] = $dir . 'SpecialSupportedLanguages.php';
 54+$wgAutoloadClasses['SpecialMyLanguage'] = $dir . 'SpecialMyLanguage.php';
5455
5556 $wgAutoloadClasses['SimpleFormatReader'] = $dir . 'ffs/Simple.php';
5657 $wgAutoloadClasses['SimpleFormatWriter'] = $dir . 'ffs/Simple.php';
Index: trunk/extensions/Translate/Translate.alias.php
@@ -21,6 +21,7 @@
2222 'ImportTranslations' => array( 'ImportTranslations' ),
2323 'FirstSteps' => array( 'FirstSteps' ),
2424 'SupportedLanguages' => array( 'SupportedLanguages' ),
 25+ 'MyLanguage' => array( 'MyLanguage' ),
2526 );
2627
2728 /** Afrikaans (Afrikaans) */

Status & tagging log