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 |
1 | 40 | + native |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | $wgSpecialPages['ImportTranslations'] = 'SpecialImportTranslations'; |
45 | 45 | $wgSpecialPages['FirstSteps'] = 'SpecialFirstSteps'; |
46 | 46 | $wgSpecialPages['SupportedLanguages'] = 'SpecialSupportedLanguages'; |
| 47 | +$wgSpecialPages['MyLanguage'] = 'SpecialMyLanguage'; |
47 | 48 | $wgSpecialPageGroups['Magic'] = 'wiki'; |
48 | 49 | $wgSpecialPageGroups['Translate'] = 'wiki'; |
49 | 50 | $wgSpecialPageGroups['Translations'] = 'pages'; |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -50,6 +50,7 @@ |
51 | 51 | $wgAutoloadClasses['SpecialImportTranslations'] = $dir . 'SpecialImportTranslations.php'; |
52 | 52 | $wgAutoloadClasses['SpecialFirstSteps'] = $dir . 'SpecialFirstSteps.php'; |
53 | 53 | $wgAutoloadClasses['SpecialSupportedLanguages'] = $dir . 'SpecialSupportedLanguages.php'; |
| 54 | +$wgAutoloadClasses['SpecialMyLanguage'] = $dir . 'SpecialMyLanguage.php'; |
54 | 55 | |
55 | 56 | $wgAutoloadClasses['SimpleFormatReader'] = $dir . 'ffs/Simple.php'; |
56 | 57 | $wgAutoloadClasses['SimpleFormatWriter'] = $dir . 'ffs/Simple.php'; |
Index: trunk/extensions/Translate/Translate.alias.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | 'ImportTranslations' => array( 'ImportTranslations' ), |
23 | 23 | 'FirstSteps' => array( 'FirstSteps' ), |
24 | 24 | 'SupportedLanguages' => array( 'SupportedLanguages' ), |
| 25 | + 'MyLanguage' => array( 'MyLanguage' ), |
25 | 26 | ); |
26 | 27 | |
27 | 28 | /** Afrikaans (Afrikaans) */ |