r24566 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24565‎ | r24566 | r24567 >
Date:18:18, 3 August 2007
Author:robchurch
Status:old
Tags:
Comment:
Support special page aliases, with correct English fallback and English aliases available regardless of language
Modified paths:
  • /trunk/extensions/Duplicator/Duplicator.i18n.php (modified) (history)
  • /trunk/extensions/Duplicator/Duplicator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Duplicator/Duplicator.i18n.php
@@ -7,6 +7,12 @@
88 * @author Rob Church <robchur@gmail.com>
99 */
1010
 11+/**
 12+ * Get a two-dimensional array of extension messages, indexed
 13+ * by language code, then message key
 14+ *
 15+ * @return array
 16+ */
1117 function efDuplicatorMessages() {
1218 $messages = array(
1319
@@ -510,5 +516,25 @@
511517
512518 }
513519
 520+/**
 521+ * Get an array of special page aliases
 522+ *
 523+ * @param string $lang Language code
 524+ * @return array
 525+ */
 526+function efDuplicatorAliases( $lang ) {
 527+ $aliases = array(
 528+
 529+/**
 530+ * English
 531+ */
 532+'en' => array(
 533+ 'Duplicator',
 534+ 'Duplicate',
 535+),
514536
515 -
 537+ );
 538+ return isset( $aliases[$lang] ) && $lang != 'en'
 539+ ? array_merge( $aliases[$lang], $aliases['en'] )
 540+ : $aliases['en'];
 541+}
\ No newline at end of file
Index: trunk/extensions/Duplicator/Duplicator.php
@@ -10,6 +10,10 @@
1111
1212 if( defined( 'MEDIAWIKI' ) ) {
1313
 14+ $wgAutoloadClasses['SpecialDuplicator'] = dirname( __FILE__ ) . '/Duplicator.page.php';
 15+ $wgSpecialPages['Duplicator'] = 'SpecialDuplicator';
 16+ $wgHooks['LangugeGetSpecialPageAliases'][] = 'efDuplicatorSetupAliases';
 17+
1418 $wgExtensionCredits['specialpage'][] = array(
1519 'name' => 'Duplicator',
1620 'author' => 'Rob Church',
@@ -18,9 +22,6 @@
1923 );
2024 $wgExtensionFunctions[] = 'efDuplicator';
2125
22 - $wgAutoloadClasses['SpecialDuplicator'] = dirname( __FILE__ ) . '/Duplicator.page.php';
23 - $wgSpecialPages['Duplicator'] = 'SpecialDuplicator';
24 -
2526 /**
2627 * User permissions
2728 */
@@ -42,6 +43,22 @@
4344 $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'efDuplicatorNavigation';
4445 $wgHooks['MonoBookTemplateToolboxEnd'][] = 'efDuplicatorToolbox';
4546 }
 47+
 48+ /**
 49+ * Set up special page aliases
 50+ *
 51+ * @param array $aliases Special page aliases
 52+ * @param string $lang Language code
 53+ * @return bool
 54+ */
 55+ function efDuplicatorSetupAliases( &$aliases, $lang ) {
 56+ $ours = efDuplicatorAliases( $lang );
 57+ if( count( $ours ) > 0 ) {
 58+ print_r( $ours );
 59+ $aliases['Duplicator'] = $ours;
 60+ }
 61+ return true;
 62+ }
4663
4764 /**
4865 * Build the link to be shown in the toolbox if appropriate

Status & tagging log