Index: extensions/ParserFunctions/ParserFunctions.php =================================================================== --- extensions/ParserFunctions/ParserFunctions.php (revision 20533) +++ extensions/ParserFunctions/ParserFunctions.php (arbetskopia) @@ -38,37 +38,37 @@ function expr( &$parser, $expr = '' ) { try { - return $this->getExprParser()->doExpression( $expr ); + return array(0 => $this->getExprParser()->doExpression( $expr ), 'noargs' => true); } catch(ExprError $e) { - return $e->getMessage(); + return array(0 => $e->getMessage(), 'noargs' => true); } } function ifexpr( &$parser, $expr = '', $then = '', $else = '' ) { try{ if($this->getExprParser()->doExpression( $expr )) { - return $then; + return array(0 => $then, 'noargs' => true); } else { - return $else; + return array(0 => $else, 'noargs' => true); } } catch (ExprError $e){ - return $e->getMessage(); + return array(0 => $e->getMessage(), 'noargs' => true); } } function ifHook( &$parser, $test = '', $then = '', $else = '' ) { if ( $test !== '' ) { - return $then; + return array(0 => $then, 'noargs' => true); } else { - return $else; + return array(0 => $else, 'noargs' => true); } } function ifeq( &$parser, $left = '', $right = '', $then = '', $else = '' ) { if ( $left == $right ) { - return $then; + return array(0 => $then, 'noargs' => true); } else { - return $else; + return array(0 => $else, 'noargs' => true); } } @@ -83,7 +83,7 @@ $parts = array_map( 'trim', explode( '=', $arg, 2 ) ); if ( count( $parts ) == 2 ) { if ( $found || $parts[0] == $value ) { - return $parts[1]; + return array(0 => $parts[1], 'noargs' => true); } else { $mwDefault =& MagicWord::get( 'default' ); if ( $mwDefault->matchStartAndRemove( $parts[0] ) ) { @@ -101,11 +101,11 @@ # Default case # Check if the last item had no = sign, thus specifying the default case if ( count( $parts ) == 1) { - return $parts[0]; + return array(0 => $parts[0], 'noargs' => true); } elseif ( !is_null( $default ) ) { - return $default; + return array(0 => $default, 'noargs' => true); } else { - return ''; + return array(0 => '', 'noargs' => true); } } @@ -127,7 +127,7 @@ // if we have an empty path, or just one containing a dot if( $to == '' || $to == '.' ) { - return $from; + return array(0 => $from, 'noargs' => true); } // if the path isn't relative @@ -156,7 +156,7 @@ if( $current == '..' ) { // removing one level if( !count( $newExploded ) ){ // attempted to access a node above root node - return wfMsgForContent( 'pfunc_rel2abs_invalid_depth', $fullPath ); + return array(0 => wfMsgForContent( 'pfunc_rel2abs_invalid_depth', $fullPath ), 'noargs' => true); } // remove last level from the stack array_pop( $newExploded ); @@ -167,7 +167,7 @@ } // we can now join it again - return implode( '/' , $newExploded ); + return array(0 => implode( '/' , $newExploded ), 'noargs' => true); } function ifexist( &$parser, $title = '', $then = '', $else = '' ) { @@ -176,16 +176,16 @@ $id = $title->getArticleID(); $parser->mOutput->addLink( $title, $id ); if ( $id ) { - return $then; + return array(0 => $then, 'noargs' => true); } } - return $else; + return array(0 => $else, 'noargs' => true); } function time( &$parser, $format = '', $date = '' ) { global $wgContLang; if ( isset( $this->mTimeCache[$format][$date] ) ) { - return $this->mTimeCache[$format][$date]; + return array(0 => $this->mTimeCache[$format][$date], 'noargs' => true); } if ( $date !== '' ) { @@ -199,7 +199,7 @@ } else { $this->mTimeChars += strlen( $format ); if ( $this->mTimeChars > $this->mMaxTimeChars ) { - return wfMsgForContent( 'pfunc_time_too_long' ); + return array(0 => wfMsgForContent( 'pfunc_time_too_long' ), 'noargs' => true); } else { $ts = wfTimestamp( TS_MW, $unix ); if ( method_exists( $wgContLang, 'sprintfDate' ) ) { @@ -214,7 +214,7 @@ } } $this->mTimeCache[$format][$date] = $result; - return $result; + return array(0 => $result, 'noargs' => true); } } Index: includes/CoreParserFunctions.php =================================================================== --- includes/CoreParserFunctions.php (revision 20533) +++ includes/CoreParserFunctions.php (arbetskopia) @@ -29,40 +29,48 @@ } } if ( $found ) { - return $text; + return array(0 => $text, 'noargs' => true); } else { return array( 'found' => false ); } } static function urlencode( $parser, $s = '' ) { - return urlencode( $s ); + return array(0 => urlencode( $s ), 'noargs' => true); } static function lcfirst( $parser, $s = '' ) { global $wgContLang; - return $wgContLang->lcfirst( $s ); + return array(0 => $wgContLang->lcfirst( $s ), 'noargs' => true); } static function ucfirst( $parser, $s = '' ) { global $wgContLang; - return $wgContLang->ucfirst( $s ); + return array(0 => $wgContLang->ucfirst( $s ), 'noargs' => true); } static function lc( $parser, $s = '' ) { global $wgContLang; - return $wgContLang->lc( $s ); + return array(0 => $wgContLang->lc( $s ), 'noargs' => true); } static function uc( $parser, $s = '' ) { global $wgContLang; - return $wgContLang->uc( $s ); + return array(0 => $wgContLang->uc( $s ), 'noargs' => true); } - static function localurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getLocalURL', $s, $arg ); } - static function localurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeLocalURL', $s, $arg ); } - static function fullurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getFullURL', $s, $arg ); } - static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); } + static function localurl( $parser, $s = '', $arg = null ) { + return array(0 => self::urlFunction( 'getLocalURL', $s, $arg ), 'noargs' => true); + } + static function localurle( $parser, $s = '', $arg = null ) { + return array(0 => self::urlFunction( 'escapeLocalURL', $s, $arg ), 'noargs' => true); + } + static function fullurl( $parser, $s = '', $arg = null ) { + return array(0 => self::urlFunction( 'getFullURL', $s, $arg ), 'noargs' => true); + } + static function fullurle( $parser, $s = '', $arg = null ) { + return array(0 => self::urlFunction( 'escapeFullURL', $s, $arg ), 'noargs' => true); + } static function urlFunction( $func, $s = '', $arg = null ) { $title = Title::newFromText( $s ); @@ -85,16 +93,16 @@ } static function formatNum( $parser, $num = '' ) { - return $parser->getFunctionLang()->formatNum( $num ); + return array(0 => $parser->getFunctionLang()->formatNum( $num ), 'noargs' => true); } static function grammar( $parser, $case = '', $word = '' ) { - return $parser->getFunctionLang()->convertGrammar( $word, $case ); + return array(0 => $parser->getFunctionLang()->convertGrammar( $word, $case ), 'noargs' => true); } static function plural( $parser, $text = '', $arg0 = null, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null ) { $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); - return $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 ); + return array(0 => $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 ), 'noargs' => true); } static function displaytitle( $parser, $param = '' ) { @@ -130,26 +138,36 @@ } } - static function numberofpages( $parser, $raw = null ) { return self::statisticsFunction( 'pages', $raw ); } - static function numberofusers( $parser, $raw = null ) { return self::statisticsFunction( 'users', $raw ); } - static function numberofarticles( $parser, $raw = null ) { return self::statisticsFunction( 'articles', $raw ); } - static function numberoffiles( $parser, $raw = null ) { return self::statisticsFunction( 'images', $raw ); } - static function numberofadmins( $parser, $raw = null ) { return self::statisticsFunction( 'admins', $raw ); } + static function numberofpages( $parser, $raw = null ) { + return array(0 => self::statisticsFunction( 'pages', $raw ), 'noargs' => true); + } + static function numberofusers( $parser, $raw = null ) { + return array(0 => self::statisticsFunction( 'users', $raw ), 'noargs' => true); + } + static function numberofarticles( $parser, $raw = null ) { + return array(0 => self::statisticsFunction( 'articles', $raw ), 'noargs' => true); + } + static function numberoffiles( $parser, $raw = null ) { + return array(0 => self::statisticsFunction( 'images', $raw ), 'noargs' => true); + } + static function numberofadmins( $parser, $raw = null ) { + return array(0 => self::statisticsFunction( 'admins', $raw ), 'noargs' => true); + } static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) { $count = SiteStats::pagesInNs( intval( $namespace ) ); if ( self::isRaw( $raw ) ) { global $wgContLang; - return $wgContLang->formatNum( $count ); + return array(0 => $wgContLang->formatNum( $count ), 'noargs' => true); } else { - return $count; + return array(0 => $count, 'noargs' => true); } } static function language( $parser, $arg = '' ) { global $wgContLang; $lang = $wgContLang->getLanguageName( strtolower( $arg ) ); - return $lang != '' ? $lang : $arg; + return array(0 => $lang != '' ? $lang : $arg, 'noargs' => true); } static function pad( $string = '', $length = 0, $char = 0, $direction = STR_PAD_RIGHT ) { @@ -161,23 +179,23 @@ } static function padleft( $parser, $string = '', $length = 0, $char = 0 ) { - return self::pad( $string, $length, $char, STR_PAD_LEFT ); + return array(0 => self::pad( $string, $length, $char, STR_PAD_LEFT ), 'noargs' => true); } static function padright( $parser, $string = '', $length = 0, $char = 0 ) { - return self::pad( $string, $length, $char ); + return array(0 => self::pad( $string, $length, $char ), 'noargs' => true); } static function anchorencode( $parser, $text ) { - return strtr( urlencode( $text ) , array( '%' => '.' , '+' => '_' ) ); + return array(0 => strtr( urlencode( $text ) , array( '%' => '.' , '+' => '_' ) ), 'noargs' => true); } static function special( $parser, $text ) { $title = SpecialPage::getTitleForAlias( $text ); if ( $title ) { - return $title->getPrefixedText(); + return array(0 => $title->getPrefixedText(), 'noargs' => true); } else { - return wfMsgForContent( 'nosuchspecialpage' ); + return array(0 => wfMsgForContent( 'nosuchspecialpage' ), 'noargs' => true); } } @@ -185,7 +203,7 @@ $text = trim( $text ); if( strlen( $text ) > 0 ) $parser->setDefaultSort( $text ); - return ''; + return array(0 => '', 'noargs' => true); } } ?>