From 7ec54c6cfccf8aa686931d43d2de63f61e4e006b Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Thu, 27 Jan 2011 17:34:37 +0000 Subject: [PATCH] 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 --- Convert.php | 10 +++++----- ParserFunctions.i18n.magic.php | 12 ++++++------ ParserFunctions.php | 3 +++ ParserFunctions_body.php | 6 ------ 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Convert.php b/Convert.php index 48656c49..0ce570de 100644 --- a/Convert.php +++ b/Convert.php @@ -135,8 +135,8 @@ class ConvertParser { if( $this->targetUnit->dimension->value != $this->sourceUnit->dimension->value ){ throw new ConvertError( 'dimensionmismatch', - $this->sourceUnit->dimension->getName(true), - $this->targetUnit->dimension->getName(true) + $this->sourceUnit->dimension->getLocalisedName(true), + $this->targetUnit->dimension->getLocalisedName(true) ); } @@ -206,8 +206,8 @@ class ConvertParser { } else { # Need to round to a similar accuracy as the original value. To do that we # select the accuracy which will as closely as possible preserve the maximum - # percentage error in the value. So 36ft = 36 ± 0.5 ft, so the uncertainty - # is ±0.5/36 = ±1.4%. In metres this is 10.9728 ± 1.4%, or 10.9728 ± 0.154 + # percentage error in the value. So 36ft = 36 ± 0.5 ft, so the uncertainty + # is ±0.5/36 = ±1.4%. In metres this is 10.9728 ± 1.4%, or 10.9728 ± 0.154 # we take the stance of choosing the limit which is *more* precise than the # original value. @@ -698,7 +698,7 @@ class ConvertUnit { if( $link && !wfEmptyMsg( "$msg-link" ) ){ $title = Title::newFromText( wfMsgForContentNoTrans( "$msg-link" ) ); if( $title instanceof Title ){ - $msgText = "[[$title|$msgText]]"; + $msgText = "[[{$title->getFullText()}|$msgText]]"; } } diff --git a/ParserFunctions.i18n.magic.php b/ParserFunctions.i18n.magic.php index 594d5104..76ed9603 100644 --- a/ParserFunctions.i18n.magic.php +++ b/ParserFunctions.i18n.magic.php @@ -23,12 +23,12 @@ $magicWords['en'] = array( 'rel2abs' => array( 0, 'rel2abs' ), 'titleparts' => array( 0, 'titleparts' ), 'convert' => array( 0, 'convert' ), - 'sourceunit' => array( 0, '#sourceunit' ), - 'targetunit' => array( 0, '#targetunit' ), - 'linkunit' => array( 0, '#linkunit' ), - 'decimalplaces' => array( 0, '#dp' ), - 'significantfigures' => array( 0, '#sf' ), - 'abbreviate' => array( 0, '#abbreviate' ), + 'sourceunit' => array( 0, '#sourceunit' ), + 'targetunit' => array( 0, '#targetunit' ), + 'linkunit' => array( 0, '#linkunit' ), + 'decimalplaces' => array( 0, '#dp' ), + 'significantfigures' => array( 0, '#sf' ), + 'abbreviate' => array( 0, '#abbreviate' ), 'len' => array( 0, 'len' ), 'pos' => array( 0, 'pos' ), 'rpos' => array( 0, 'rpos' ), diff --git a/ParserFunctions.php b/ParserFunctions.php index 341bc344..c4bc264a 100644 --- a/ParserFunctions.php +++ b/ParserFunctions.php @@ -41,6 +41,9 @@ $wgExtensionCredits['parserhook'][] = array( ); $wgAutoloadClasses['ExtParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions_body.php'; +$wgAutoloadClasses['ExprParser'] = dirname( __FILE__ ) . '/Expr.php'; +$wgAutoloadClasses['ConvertParser'] = dirname( __FILE__ ) . '/Convert.php'; + $wgExtensionMessagesFiles['ParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.php'; $wgExtensionMessagesFiles['ParserFunctionsMagic'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.magic.php'; diff --git a/ParserFunctions_body.php b/ParserFunctions_body.php index a78b3a36..92f4c015 100644 --- a/ParserFunctions_body.php +++ b/ParserFunctions_body.php @@ -52,9 +52,6 @@ class ExtParserFunctions { */ function &getExprParser() { if ( !isset( $this->mExprParser ) ) { - if ( !class_exists( 'ExprParser' ) ) { - require( dirname( __FILE__ ) . '/Expr.php' ); - } $this->mExprParser = new ExprParser; } return $this->mExprParser; @@ -518,9 +515,6 @@ class ExtParserFunctions { */ protected function &getConvertParser() { if ( !isset( $this->mConvertParser ) ) { - if ( !class_exists( 'ConvertParser' ) ) { - require( dirname( __FILE__ ) . '/Convert.php' ); - } $this->mConvertParser = new ConvertParser; } return $this->mConvertParser;