r98376 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98375‎ | r98376 | r98377 >
Date:22:39, 28 September 2011
Author:dasch
Status:ok
Tags:
Comment:
added new Feature to FormatNum (see Extension page)
cleanup tab/space mix in FormatNum.php
removed unused global in RelationLinks.php
Modified paths:
  • /trunk/extensions/FormatNum/FormatNum.php (modified) (history)
  • /trunk/extensions/RelationLinks/RelationLinks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RelationLinks/RelationLinks.php
@@ -28,7 +28,6 @@
2929 $wgHooks['BeforePageDisplay'][] = 'addRelationLinks';
3030
3131 function addRelationLinks( &$out, &$sk ) {
32 - global $wgArticlePath;
3332 $rlMainpage = Title::newFromText(wfMsg('Mainpage'));
3433 $out->addLink( array(
3534 'rel' => 'start',
Index: trunk/extensions/FormatNum/FormatNum.php
@@ -4,21 +4,21 @@
55 */
66 // Check environment
77 if ( !defined( 'MEDIAWIKI' ) ) {
8 - echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
9 - die( -1 );
 8+ echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
 9+ die( -1 );
1010 }
1111
1212 /* Configuration */
1313
1414 // Credits
1515 $wgExtensionCredits['parserhook'][] = array (
16 - 'path'=> __FILE__ ,
17 - 'name'=>'FormatNum',
18 - 'url'=>'http://www.mediawiki.org/wiki/Extension:FormatNum',
19 - 'description'=>'Passes formatnum to php number_format',
20 - 'descriptionmsg' => 'formatnum-desc',
21 - 'author'=>'[http://www.dasch-tour.de DaSch]',
22 - 'version'=>'0.1.1',
 16+ 'path'=> __FILE__ ,
 17+ 'name'=>'FormatNum',
 18+ 'url'=>'http://www.mediawiki.org/wiki/Extension:FormatNum',
 19+ 'description'=>'Passes formatnum to php number_format',
 20+ 'descriptionmsg' => 'formatnum-desc',
 21+ 'author'=>'[http://www.dasch-tour.de DaSch]',
 22+ 'version'=>'0.2.0',
2323 );
2424 $dir = dirname( __FILE__ ) . '/';
2525
@@ -31,9 +31,9 @@
3232 $wgHooks['LanguageGetMagic'][] = 'efFormatNumParserFunction_Magic';
3333
3434 function efFormatNumParserFunction_Setup( $parser ) {
35 - # Set a function hook associating the "example" magic word with our function
36 - $parser->setFunctionHook( 'formatnum', 'efFormatNumParserFunction_Render' );
37 - return true;
 35+ # Set a function hook associating the "example" magic word with our function
 36+ $parser->setFunctionHook( 'formatnum', 'efFormatNumParserFunction_Render' );
 37+ return true;
3838 }
3939
4040 function efFormatNumParserFunction_Magic( &$magicWords, $langCode ) {
@@ -49,9 +49,17 @@
5050 # The parser function itself
5151 # The input parameters are wikitext with templates expanded
5252 # The output should be wikitext too
53 - if ($param4 == '_') {
54 - $param4 = ' ';
 53+ if ($param4 == '_' ){
 54+ $param4 = ' ';
5555 }
5656 $output = number_format($param1, $param2, $param3, $param4);
 57+ switch ($param4) {
 58+ case 't':
 59+ $output = str_replace ( 't' , ' ' , $output);
 60+ break;
 61+ case 'n':
 62+ $output = str_replace ( 'n' , ' ' , $output);
 63+ break;
 64+ }
5765 return $output;
5866 }
\ No newline at end of file

Status & tagging log