r103165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103164‎ | r103165 | r103166 >
Date:13:18, 15 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
'#fornumargs' arguments more consistent with '#forargs', first parameter can be omitted and set as second instead.
Modified paths:
  • /trunk/extensions/Loops/Loops.php (modified) (history)
  • /trunk/extensions/Loops/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Loops/Loops.php
@@ -201,6 +201,8 @@
202202
203203 /**
204204 * #fornumargs: keyVarName | valVarName | code
 205+ * or (since 0.4 for more consistency)
 206+ * #fornumargs: | keyVarName | valVarName | code
205207 */
206208 public static function pfObj_fornumargs( Parser &$parser, $frame, $args ) {
207209 /*
@@ -216,6 +218,12 @@
217219 }
218220 ksort( $tNumArgs ); // sort from lowest to highest
219221
 222+ if( count( $args ) > 3 ) {
 223+ // compatbility to pre 0.4 but consistency with other Loop functions.
 224+ // this way the first argument can be ommitted like '#fornumargs: |varKey |varVal |code'
 225+ array_shift( $args );
 226+ }
 227+
220228 return self::perform_forargs( $parser, $frame, $args, $tNumArgs, '' );
221229 }
222230
Index: trunk/extensions/Loops/RELEASE-NOTES
@@ -6,9 +6,11 @@
77 counter, for example including an special page in wikitext. This has been solved now.
88 - Language file clean-up.
99 - Internal structure changed, ExtLoops now works as a static class.
 10+ - '#fornumargs' parameter 1 can be empty to make it more consistent with other Loop parser
 11+ functions. E.g. '{{#fornumargs: | keyVarName | valVarName | code }}' istead of
 12+ '{{#fornumargs: keyVarName | valVarName | code }}' (which still works as well).
1013 @ToDo: Open points for final 0.4 release:
1114 - Compatbility to Variables Version 2.0.
12 - - '#fornumargs' parameter 1 optional to make it more consistent with other functions.
1315
1416 * November 15, 2011 -- Version 0.3.2 by Daniel Werner
1517 - Bug solved where '#loop' didn't create variables with name or starting index '0'.

Status & tagging log