r81095 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81094‎ | r81095 | r81096 >
Date:17:34, 27 January 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Follow-up r81074 CR:
* Use autoloader for ConvertParser, and ExprParser which the code was cloned from
* Fix PHP 5.1 compatibility, while there's no requirement for us to keep it, there's also no need to break it unnecessarily, and it's a really trivial fix in this case.
* Tidy whitespace
* Use ConvertDimension::getLocalisedName() for the dimensionmismatch error, as intended
Modified paths:
  • /trunk/extensions/ParserFunctions/Convert.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.i18n.magic.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/Convert.php
@@ -135,8 +135,8 @@
136136 if( $this->targetUnit->dimension->value != $this->sourceUnit->dimension->value ){
137137 throw new ConvertError(
138138 'dimensionmismatch',
139 - $this->sourceUnit->dimension->getName(true),
140 - $this->targetUnit->dimension->getName(true)
 139+ $this->sourceUnit->dimension->getLocalisedName(true),
 140+ $this->targetUnit->dimension->getLocalisedName(true)
141141 );
142142 }
143143
@@ -206,8 +206,8 @@
207207 } else {
208208 # Need to round to a similar accuracy as the original value. To do that we
209209 # select the accuracy which will as closely as possible preserve the maximum
210 - # percentage error in the value. So 36ft = 36 � 0.5 ft, so the uncertainty
211 - # is �0.5/36 = �1.4%. In metres this is 10.9728 � 1.4%, or 10.9728 � 0.154
 210+ # percentage error in the value. So 36ft = 36 ± 0.5 ft, so the uncertainty
 211+ # is ±0.5/36 = ±1.4%. In metres this is 10.9728 ± 1.4%, or 10.9728 ± 0.154
212212 # we take the stance of choosing the limit which is *more* precise than the
213213 # original value.
214214
@@ -698,7 +698,7 @@
699699 if( $link && !wfEmptyMsg( "$msg-link" ) ){
700700 $title = Title::newFromText( wfMsgForContentNoTrans( "$msg-link" ) );
701701 if( $title instanceof Title ){
702 - $msgText = "[[$title|$msgText]]";
 702+ $msgText = "[[{$title->getFullText()}|$msgText]]";
703703 }
704704 }
705705
Index: trunk/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
@@ -23,12 +23,12 @@
2424 'rel2abs' => array( 0, 'rel2abs' ),
2525 'titleparts' => array( 0, 'titleparts' ),
2626 'convert' => array( 0, 'convert' ),
27 - 'sourceunit' => array( 0, '#sourceunit' ),
28 - 'targetunit' => array( 0, '#targetunit' ),
29 - 'linkunit' => array( 0, '#linkunit' ),
30 - 'decimalplaces' => array( 0, '#dp' ),
31 - 'significantfigures' => array( 0, '#sf' ),
32 - 'abbreviate' => array( 0, '#abbreviate' ),
 27+ 'sourceunit' => array( 0, '#sourceunit' ),
 28+ 'targetunit' => array( 0, '#targetunit' ),
 29+ 'linkunit' => array( 0, '#linkunit' ),
 30+ 'decimalplaces' => array( 0, '#dp' ),
 31+ 'significantfigures' => array( 0, '#sf' ),
 32+ 'abbreviate' => array( 0, '#abbreviate' ),
3333 'len' => array( 0, 'len' ),
3434 'pos' => array( 0, 'pos' ),
3535 'rpos' => array( 0, 'rpos' ),
Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -52,9 +52,6 @@
5353 */
5454 function &getExprParser() {
5555 if ( !isset( $this->mExprParser ) ) {
56 - if ( !class_exists( 'ExprParser' ) ) {
57 - require( dirname( __FILE__ ) . '/Expr.php' );
58 - }
5956 $this->mExprParser = new ExprParser;
6057 }
6158 return $this->mExprParser;
@@ -518,9 +515,6 @@
519516 */
520517 protected function &getConvertParser() {
521518 if ( !isset( $this->mConvertParser ) ) {
522 - if ( !class_exists( 'ConvertParser' ) ) {
523 - require( dirname( __FILE__ ) . '/Convert.php' );
524 - }
525519 $this->mConvertParser = new ConvertParser;
526520 }
527521 return $this->mConvertParser;
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -41,6 +41,9 @@
4242 );
4343
4444 $wgAutoloadClasses['ExtParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions_body.php';
 45+$wgAutoloadClasses['ExprParser'] = dirname( __FILE__ ) . '/Expr.php';
 46+$wgAutoloadClasses['ConvertParser'] = dirname( __FILE__ ) . '/Convert.php';
 47+
4548 $wgExtensionMessagesFiles['ParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.php';
4649 $wgExtensionMessagesFiles['ParserFunctionsMagic'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.magic.php';
4750

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81074(bug 235) parser function for conversion of units of measurement....happy-melon00:13, 27 January 2011

Status & tagging log