r55008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55007‎ | r55008 | r55009 >
Date:11:25, 14 August 2009
Author:siebrand
Status:deferred (Comments)
Tags:todo 
Comment:
* Babel, CategoryTree, MagicNoNumberedHeadings, RegexFunctions and SmoothGallery: new style magic words
* MagicNoNumberedHeadings: add extension description in i18n file, reindent
* bump versions where applicable
Modified paths:
  • /trunk/extensions/Babel/Babel.i18n.magic.php (added) (history)
  • /trunk/extensions/Babel/Babel.php (modified) (history)
  • /trunk/extensions/Babel/BabelStatic.class.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.i18n.magic.php (added) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.magic.php (added) (history)
  • /trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.php (added) (history)
  • /trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.php (modified) (history)
  • /trunk/extensions/RegexFunctions/RegexFunctions.i18n.magic.php (added) (history)
  • /trunk/extensions/RegexFunctions/RegexFunctions.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.i18n.magic.php (added) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -35,7 +35,7 @@
3636 $wgExtensionCredits['other'][] = array(
3737 'path' => __FILE__,
3838 'name' => 'SmoothGallery parser extension',
39 - 'version' => '1.1e',
 39+ 'version' => '1.1f',
4040 'author' => 'Ryan Lane',
4141 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery',
4242 'descriptionmsg' => 'smoothgallery-desc',
@@ -45,10 +45,10 @@
4646 $wgExtensionFunctions[] = "efSmoothGallery";
4747
4848 $wgHooks['OutputPageParserOutput'][] = 'smoothGalleryParserOutput';
49 -$wgHooks['LanguageGetMagic'][] = 'smoothGalleryLanguageGetMagic';
5049
5150 $dir = dirname( __FILE__ ) . '/';
5251 $wgExtensionMessagesFiles['SmoothGallery'] = $dir . 'SmoothGallery.i18n.php';
 52+$wgExtensionMessagesFiles['SmoothGalleryMagic'] = $dir . 'SmoothGallery.i18n.magic.php';
5353 $wgAutoloadClasses['SmoothGallery'] = $dir . 'SmoothGalleryClass.php';
5454 $wgAutoloadClasses['SmoothGalleryParser'] = $dir . 'SmoothGalleryParser.php';
5555
@@ -142,12 +142,3 @@
143143 }
144144 return true;
145145 }
146 -
147 -/**
148 - * We ignore langCode - parser function names can be translated but
149 - * we are not using this feature
150 - */
151 -function smoothGalleryLanguageGetMagic( &$magicWords, $langCode ) {
152 - $magicWords['sgallery'] = array( 0, 'sgallery' );
153 - return true;
154 -}
Index: trunk/extensions/SmoothGallery/SmoothGallery.i18n.magic.php
@@ -0,0 +1,7 @@
 2+<?php
 3+
 4+$magicWords = array();
 5+
 6+$magicWords['en'] = array(
 7+ 'sgallery' => array( 0, 'sgallery' ),
 8+);
Property changes on: trunk/extensions/SmoothGallery/SmoothGallery.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
19 + native
Added: svn:keywords
210 + Id
Index: trunk/extensions/Babel/BabelStatic.class.php
@@ -19,17 +19,6 @@
2020 }
2121
2222 /**
23 - * Registers the parser function magic word.
24 - * @param $magicWords Array: Magic words on the wiki.
25 - * @param $langCode String: Content language code of the wiki.
26 - * @return Boolean: True.
27 - */
28 - public static function Magic( array $magicWords, $langCode ) {
29 - $magicWords[ 'babel' ] = array( 0, 'babel' );
30 - return true;
31 - }
32 -
33 - /**
3423 * Return Babel tower, initializing the Babel object if necessery,
3524 * @param $parser Object: Parser.
3625 * @return String: Babel tower.
@@ -40,5 +29,4 @@
4130 $arguments = func_get_args();
4231 return call_user_func_array( array( $wgBabel, 'render' ), $arguments );
4332 }
44 -
4533 }
Index: trunk/extensions/Babel/Babel.i18n.magic.php
@@ -0,0 +1,13 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalisation file for Babel extension.
 6+ *
 7+ * @addtogroup Extensions
 8+*/
 9+
 10+$magicWords = array();
 11+
 12+$magicWords['en'] = array(
 13+ 'babel' => array( 0, 'babel' ),
 14+);
Property changes on: trunk/extensions/Babel/Babel.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
115 + native
Added: svn:keywords
216 + Id
Index: trunk/extensions/Babel/Babel.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * Babel Extension
65 *
@@ -22,10 +21,10 @@
2322 $wgExtensionCredits[ 'parserhook' ][] = array(
2423 'path' => __FILE__,
2524 'name' => 'Babel',
26 - 'version' => '1.3.0',
 25+ 'version' => '1.4.0',
2726 'author' => 'Robert Leverington',
2827 'url' => 'http://www.mediawiki.org/wiki/Extension:Babel',
29 - 'description' => 'Adds a parser function to allow automated generation of a babel userbox column with the ability to include custom templates.',
 28+ 'description' => 'Adds a parser function to allow automated generation of a babel userbox column with the ability to include custom templates',
3029 'descriptionmsg' => 'babel-desc',
3130 );
3231
@@ -37,13 +36,13 @@
3837 }
3938
4039 // Register required hooks.
41 -$wgHooks[ 'LanguageGetMagic' ][] = 'BabelStatic::Magic';
4240 $wgHooks[ 'AbortNewAccount' ][] = 'BabelAutoCreate::RegisterAbort';
4341
4442 $dir = dirname( __FILE__ );
4543
4644 // Register internationalisation file.
4745 $wgExtensionMessagesFiles[ 'Babel' ] = $dir . '/Babel.i18n.php';
 46+$wgExtensionMessagesFiles[ 'BabelMagic' ] = $dir . '/Babel.i18n.magic.php';
4847
4948 // Register autoload classes.
5049 $wgAutoloadClasses[ 'Babel' ] = $dir . '/Babel.class.php';
Index: trunk/extensions/RegexFunctions/RegexFunctions.i18n.magic.php
@@ -0,0 +1,9 @@
 2+<?php
 3+
 4+$magicWords = array();
 5+
 6+$magicWords['en'] = array(
 7+ 'rmatch' => array( 0, 'rmatch' ),
 8+ 'rsplit' => array( 0, 'rsplit' ),
 9+ 'rreplace' => array( 0, 'rreplace' ),
 10+);
Property changes on: trunk/extensions/RegexFunctions/RegexFunctions.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
111 + native
Added: svn:keywords
212 + Id
Index: trunk/extensions/RegexFunctions/RegexFunctions.php
@@ -1,8 +1,8 @@
22 <?php
33 /*
4 -* RegexFunctions extension by Ryan Schmidt
5 -* Regular Expression parser functions
6 -*/
 4+ * RegexFunctions extension by Ryan Schmidt
 5+ * Regular Expression parser functions
 6+ */
77
88 if( !defined( 'MEDIAWIKI' ) ) {
99 echo "This file is an extension of the MediaWiki software and cannot be used standalone\n";
@@ -17,13 +17,14 @@
1818 'name' => 'RegexFunctions',
1919 'author' => 'Ryan Schmidt',
2020 'url' => 'http://www.mediawiki.org/wiki/Extension:RegexFunctions',
21 - 'version' => '1.3',
 21+ 'version' => '1.4',
2222 'description' => 'Regular Expression parser functions',
2323 'descriptionmsg' => 'regexfunctions-desc',
2424 );
2525
26 -$wgExtensionMessagesFiles['RegexFunctions'] = dirname(__FILE__) . '/RegexFunctions.i18n.php';
27 -$wgHooks['LanguageGetMagic'][] = 'wfRegexFunctionsLanguageGetMagic';
 26+$dir = dirname(__FILE__) . '/';
 27+$wgExtensionMessagesFiles['RegexFunctions'] = $dir . 'RegexFunctions.i18n.php';
 28+$wgExtensionMessagesFiles['RegexFunctionsMagic'] = $dir . 'RegexFunctions.i18n.magic.php';
2829
2930 //default globals
3031 //how many functions are allowed in a single page? Keep this at least above 3 for usability
@@ -50,16 +51,6 @@
5152 $wgParser->setFunctionHook( 'rreplace', array(&$wgExtRegexFunctions, 'rreplace') );
5253 }
5354
54 -function wfRegexFunctionsLanguageGetMagic( &$magicWords, $langCode ) {
55 - switch ( $langCode ) {
56 - default:
57 - $magicWords['rmatch'] = array( 0, 'rmatch' );
58 - $magicWords['rsplit'] = array( 0, 'rsplit' );
59 - $magicWords['rreplace'] = array( 0, 'rreplace' );
60 - }
61 - return true;
62 -}
63 -
6455 class ExtRegexFunctions {
6556 var $num = 0;
6657 var $modifiers = array('i', 'm', 's', 'x', 'A', 'D', 'S', 'U', 'X', 'J', 'u', 'e');
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.magic.php
@@ -0,0 +1,15 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for extension CategoryTree.
 5+ *
 6+ * @addtogroup Extensions
 7+ * @author Daniel Kinzler, brightbyte.de
 8+ * @copyright © 2006-2008 Daniel Kinzler
 9+ * @license GNU General Public Licence 2.0 or later
 10+ */
 11+
 12+$magicWords = array();
 13+
 14+$magicWords['en'] = array(
 15+ 'categorytree' => array( 0, 'categorytree' ),
 16+);
Property changes on: trunk/extensions/CategoryTree/CategoryTree.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
117 + native
Added: svn:keywords
218 + Id
Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -129,6 +129,11 @@
130130 * Register the special page
131131 */
132132 $dir = dirname(__FILE__) . '/';
 133+
 134+if ( $wgUseAjax && $wgCategoryTreeAllowTag ) {
 135+ $wgExtensionMessagesFiles['CategoryTreeMagic'] = $dir . 'CategoryTree.i18n.magic.php';
 136+}
 137+
133138 $wgExtensionMessagesFiles['CategoryTree'] = $dir . 'CategoryTree.i18n.php';
134139 $wgAutoloadClasses['CategoryTreePage'] = $dir . 'CategoryTreePage.php';
135140 $wgAutoloadClasses['CategoryTree'] = $dir . 'CategoryTreeFunctions.php';
@@ -137,7 +142,6 @@
138143 $wgSpecialPageGroups['CategoryTree'] = 'pages';
139144 #$wgHooks['SkinTemplateTabs'][] = 'efCategoryTreeInstallTabs';
140145 $wgHooks['ArticleFromTitle'][] = 'efCategoryTreeArticleFromTitle';
141 -$wgHooks['LanguageGetMagic'][] = 'efCategoryTreeGetMagic';
142146
143147 /**
144148 * register Ajax function
@@ -206,20 +210,6 @@
207211 }
208212
209213 /**
210 -* Hook magic word
211 -*/
212 -function efCategoryTreeGetMagic( &$magicWords, $langCode ) {
213 - global $wgUseAjax, $wgCategoryTreeAllowTag;
214 -
215 - if ( $wgUseAjax && $wgCategoryTreeAllowTag ) {
216 - //XXX: should we allow a local alias?
217 - $magicWords['categorytree'] = array( 0, 'categorytree' );
218 - }
219 -
220 - return true;
221 -}
222 -
223 -/**
224214 * Entry point for Ajax, registered in $wgAjaxExportList.
225215 * The $enc parameter determins how the $options is decoded into a PHP array.
226216 * If $enc is not given, '' is asumed, which simulates the old call interface,
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -48,9 +48,7 @@
4949 Author Protect
5050
5151 Babel
52 -ignored = babel-box-cellspacing, babel-category-prefix, babel-category-suffix
53 -ignored = babel-portal-prefix, babel-portal-suffix, babel-template-prefix
54 -ignored = babel-template-suffix, babel-footer
 52+magicfile = Babel/Babel.i18n.magic.php
5553 optional = babel-directionality
5654 optional = babel-0-female, babel-1-female, babel-2-female, babel-3-female
5755 optional = babel-4-female, babel-5-female, babel-N-female, babel-0-n-female
@@ -60,6 +58,9 @@
6159 optional = babel-N-male, babel-0-n-male, babel-1-n-male, babel-2-n-male
6260 optional = babel-3-n-male, babel-4-n-male, babel-5-n-male, babel-N-n-male
6361 optional = babel-autocreate-user
 62+ignored = babel-box-cellspacing, babel-category-prefix, babel-category-suffix
 63+ignored = babel-portal-prefix, babel-portal-suffix, babel-template-prefix
 64+ignored = babel-template-suffix, babel-footer
6465
6566 Back and Forth
6667 file = BackAndForth/BackAndForth.i18n.php
@@ -99,6 +100,7 @@
100101
101102 Category Tree
102103 aliasfile = CategoryTree/CategoryTree.alias.php
 104+magicfile = CategoryTree/CategoryTree.i18n.magic.php
103105 ignored = categorytree-collapse-bullet, categorytree-expand-bullet,
104106 ignored = categorytree-empty-bullet,categorytree-page-bullet
105107 ignored = categorytree-member-num
@@ -546,6 +548,9 @@
547549 Lua
548550 descmsg = lua_desc
549551
 552+Magic No Numbered Headings
 553+magicfile = MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.magic.php
 554+
550555 Maintenance
551556 aliasfile = Maintenance/Maintenance.alias.php
552557 ignored = maintenance-initEditCount, maintenance-runJobs, maintenance-showJobs
@@ -786,7 +791,8 @@
787792 file = regexBlock/regexBlock.i18n.php
788793 aliasfile = regexBlock/regexBlock.alias.php
789794
790 -RegexFunctions
 795+Regex Functions
 796+magicfile = RegexFunctions/RegexFunctions.i8n.magic.phh
791797
792798 Rename User
793799 file = Renameuser/SpecialRenameuser.i18n.php
@@ -896,6 +902,8 @@
897903 optional = slippymap_tagname, slippymap_extname
898904
899905 Smooth Gallery
 906+magicfile = SmoothGallery/SmoothGallery.i18n.magic.php
 907+
900908 ignored = smoothgallery-pagetext
901909
902910 Social Profile - System Gifts
Index: trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.magic.php
@@ -0,0 +1,15 @@
 2+<?php
 3+
 4+$magicWords = array();
 5+
 6+$magicWords['en'] = array(
 7+ 'MAG_NONUMBEREDHEADINGS' => array( 0, '__NONUMBEREDHEADINGS__' ),
 8+);
 9+
 10+$magicWords['de'] = array(
 11+ 'MAG_NONUMBEREDHEADINGS' => array( '0', '__KEINEÜERSCHRIFTENNUMMERIERUNG__', '__NONUMBEREDHEADINGS__' ),
 12+);
 13+
 14+$magicWords['ksh'] = array(
 15+ 'MAG_NONUMBEREDHEADINGS' => array( '0', '__ÖVERSCHRIFTENITNUMMERIERE__', '__NONUMBEREDHEADINGS__' ),
 16+);
Property changes on: trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
117 + native
Added: svn:keywords
218 + Id
Index: trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.php
@@ -0,0 +1,7 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+$messages['en'] = array(
 7+ 'magicnonumberedheadings-desc' => 'Adds magic word "<nowiki>__NONUMBEREDHEADINGS__</nowiki>"',
 8+);
Property changes on: trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.i18n.php
___________________________________________________________________
Added: svn:eol-style
19 + native
Added: svn:keywords
210 + Id
Index: trunk/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.php
@@ -25,66 +25,39 @@
2626 * This extension realizes a new MagicWord __NONUMBEREDHEADINGS__.
2727 * If an article contains this MagicWord, numbering of the
2828 * headings is disabled regardless of the user preference setting.
29 - *
 29+ *
3030 * How to use:
3131 * * include this extension in LocalSettings.php:
3232 * require_once($IP.'/extensions/MagicNoNumberedHeadings/MagicNoNumberedHeadings.php');
3333 * * Add "__NONUMBEREDHEADINGS__" to any article of your choice.
3434 *
3535 * @author Purodha Blissenbach
36 - * @version $Revision: 1.11 $
3736 */
3837
3938 if (!defined('MEDIAWIKI')) {
40 - die("This requires the MediaWiki enviroment.");
 39+ die("This requires the MediaWiki enviroment.");
4140 }
4241
4342 $wgExtensionCredits['parserhook'][] = array(
4443 'path' => __FILE__,
45 - 'name' => 'MagicNoNumberedHeadings',
46 - 'version' => '$Revision: 1.11 $',
47 - 'author' => 'Purodha Blissenbach',
48 - 'url' => 'http://www.mediawiki.org/wiki/Extension:MagicNoNumberedHeadings',
49 - 'description' => 'Add MagicWord "<nowiki>__NONUMBEREDHEADINGS__</nowiki>".',
 44+ 'name' => 'MagicNoNumberedHeadings',
 45+ 'version' => '1.12',
 46+ 'author' => 'Purodha Blissenbach',
 47+ 'url' => 'http://www.mediawiki.org/wiki/Extension:MagicNoNumberedHeadings',
 48+ 'descriptionmsg' => 'magicnonumberedheadings-desc',
5049 );
51 -$wgHooks['MagicWordMagicWords'][] = 'MagicNoNumberedHeadingsMagicWordMagicWords';
52 -$wgHooks['MagicWordwgVariableIDs'][] = 'MagicNoNumberedHeadingsMagicWordwgVariableIDs';
53 -$wgHooks['LanguageGetMagic'][] = 'MagicNoNumberedHeadingsLanguageGetMagic';
54 -$wgHooks['ParserBeforeInternalParse'][] = 'MagicNoNumberedHeadingsParserBeforeInternalParse';
5550
56 -function MagicNoNumberedHeadingsMagicWordMagicWords(&$magicWords)
57 -{
58 - $magicWords[] = 'MAG_NONUMBEREDHEADINGS';
59 - return true;
60 -}
 51+$dir = dirname(__FILE__) . '/';
 52+$wgExtensionMessagesFiles['RegexFunctions'] = $dir . 'RegexFunctions.i18n.php';
 53+$wgExtensionMessagesFiles['RegexFunctionsMagic'] = $dir . 'RegexFunctions.i18n.magic.php';
6154
62 -function MagicNoNumberedHeadingsMagicWordwgVariableIDs(&$wgVariableIDs)
63 -{
64 - $wgVariableIDs[] = MAG_NONUMBEREDHEADINGS;
65 - return true;
66 -}
 55+$wgHooks['ParserBeforeInternalParse'][] = 'MagicNoNumberedHeadingsParserBeforeInternalParse';
6756
68 -function MagicNoNumberedHeadingsLanguageGetMagic(&$magicWords, $langCode)
69 -{
70 - switch($langCode)
71 - {
72 - case 'de' :
73 - $magicWords[MAG_NONUMBEREDHEADINGS] = array( 0, '__KEINEÜERSCHRIFTENNUMMERIERUNG__', '__NONUMBEREDHEADINGS__' );
74 - break;
75 - case 'ksh' :
76 - $magicWords[MAG_NONUMBEREDHEADINGS] = array( 0, '__ÖVERSCHRIFTENITNUMMERIERE__', '__NONUMBEREDHEADINGS__' );
77 - break;
78 - default :
79 - $magicWords[MAG_NONUMBEREDHEADINGS] = array( 0, '__NONUMBEREDHEADINGS__' );
80 - }
81 - return true;
82 -}
83 -
8457 function MagicNoNumberedHeadingsParserBeforeInternalParse($parser, $text, $stripState)
8558 {
86 - if (MagicWord::get( MAG_NONUMBEREDHEADINGS )->matchAndRemove( $text ) )
87 - {
88 - $parser->mOptions->mNumberHeadings = (FALSE);
89 - }
90 - return true;
 59+ if (MagicWord::get( 'MAG_NONUMBEREDHEADINGS' )->matchAndRemove( $text ) )
 60+ {
 61+ $parser->mOptions->mNumberHeadings = (FALSE);
 62+ }
 63+ return true;
9164 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r55009Fix formatting issue from r55008siebrand11:36, 14 August 2009
r60769Fix copy/paste and no replace error in r55008siebrand06:54, 7 January 2010

Comments

#Comment by Ryan lane (talk | contribs)   14:18, 27 August 2009

Can the SmoothGallery change be done in a backwards compliant way? I'm getting bug reports from users.

#Comment by Nikerabbit (talk | contribs)   15:33, 27 August 2009

Since extensions are branched, people usually don't bother and even remove bc code for oldest versions at times.

#Comment by Ryan lane (talk | contribs)   15:49, 27 August 2009

The 1.15 snapshot of SmoothGallery is 1.1c, which is fairly old (current version is 1.1e). It must not have been branched properly. I don't generally branch my extensions, as I like the newest version of the code to work with as many versions of MediaWiki as possible. I usually try to ensure backwards compatibility.

Giving people a choice between a really outdated version of my plugin, and one that doesn't work with any stable version of MediaWiki kind of sucks.

#Comment by Werdna (talk | contribs)   18:16, 27 August 2009

Does not block deployment.

Status & tagging log