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
This commit is contained in:
Happy-melon 2011-01-27 17:34:37 +00:00
parent 65e9e69202
commit 7ec54c6cfc
4 changed files with 14 additions and 17 deletions

View file

@ -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]]";
}
}

View file

@ -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' ),

View file

@ -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';

View file

@ -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;