r104308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104307‎ | r104308 | r104309 >
Date:21:28, 26 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
'#hashprint' will use the local languages comma separator instead of hard-coded ', ' as default delimiter.
Modified paths:
  • /trunk/extensions/HashTables/HashTables.php (modified) (history)
  • /trunk/extensions/HashTables/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/HashTables/HashTables.php
@@ -17,14 +17,12 @@
1818 *
1919 * @ToDo:
2020 * ======
21 - * - binding one hash tables instance per initialized parser instead of having one global one.
2221 * Thinking about:
2322 * - Sort function
2423 * - Search function
25 - *
2624 */
2725
28 -if ( ! defined( 'MEDIAWIKI' ) ) { die(); }
 26+if( ! defined( 'MEDIAWIKI' ) ) { die(); }
2927
3028 $wgExtensionCredits['parserhook'][] = array(
3129 'path' => __FILE__,
@@ -120,8 +118,7 @@
121119 * @return boolean
122120 */
123121 public static function getDir() {
124 - static $dir = null;
125 -
 122+ static $dir = null;
126123 if( $dir === null ) {
127124 $dir = dirname( __FILE__ );
128125 }
@@ -149,17 +146,17 @@
150147
151148 if( $value !== '' ) {
152149 // Build delimiters:
153 - if ( ! self::isValidRegEx($itemsDelimiter,'/') ) {
 150+ if( ! self::isValidRegEx($itemsDelimiter,'/') ) {
154151 $itemsDelimiter = '/\s*' . preg_quote( $itemsDelimiter, '/' ) . '\s*/';
155152 }
156153
157 - if ( ! self::isValidRegEx($innerDelimiter,'/') ) {
 154+ if( ! self::isValidRegEx($innerDelimiter,'/') ) {
158155 $innerDelimiter = '/\s*' . preg_quote( $innerDelimiter, '/' ) . '\s*/';
159156 }
160157
161158 $items = preg_split( $itemsDelimiter, $value ); // All hash Items
162159
163 - foreach ( $items as $item ) {
 160+ foreach( $items as $item ) {
164161 $hashPair = preg_split( $innerDelimiter, $item, 2 );
165162
166163 if( count($hashPair) < 2 ) {
@@ -250,7 +247,10 @@
251248
252249 // parameter validation:
253250
254 - $seperator = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : ', ';
 251+ global $wgLang;
 252+ $seperator = isset( $args[1] )
 253+ ? trim( $frame->expand( $args[1] ) )
 254+ : $wgLang->getMessageFromDB( 'comma-separator' ); // use local languages default, for English ', '
255255 /*
256256 * PPFrame::NO_ARGS and PPFrame::NO_TEMPLATES for expansion make a lot of sense here since the patterns getting replaced
257257 * in $subject before $subject is being parsed. So any template or argument influence in the patterns wouldn't make any
@@ -333,7 +333,7 @@
334334
335335 $templateArgs = $frame->getArguments();
336336
337 - foreach ( $templateArgs as $argName => $argVal ) {
 337+ foreach( $templateArgs as $argName => $argVal ) {
338338 // one hash value for each parameter
339339 $store->setHashValue( $hashId, $argName, $argVal );
340340 }
Index: trunk/extensions/HashTables/RELEASE-NOTES
@@ -9,6 +9,7 @@
1010 - Inclusion of special pages in the middle of the page won't reset all defined hash tables anymore.
1111 - arrayprint will handle <includeonly>/<noinclude> correct in case it's used in a template.
1212 - '#hashvalue' will only expand its default when required.
 13+ - '#hashprint' will use the languages default comma separator instead of hard-coded ', ' as default.
1314
1415
1516 * November 4, 2011 -- Version 0.7

Status & tagging log