* (bug 7044) Introduce "padleft" and "padright" colon functions

This commit is contained in:
Rob Church 2006-08-18 17:30:35 +00:00
parent 57f87f7093
commit 73ee792c4d
4 changed files with 15 additions and 0 deletions

View file

@ -144,6 +144,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* Avoid duplicate revision imports with Special:Import
* (bug 7054) Validate email address before sending email confirmation message
* (bug 7061) Format title on "from (page)" links on Special:Allpages
* (bug 7044) Introduce "padleft" and "padright" colon functions
== Languages updated ==

View file

@ -5,6 +5,7 @@
*/
class CoreParserFunctions {
static function ns( $parser, $part1 = '' ) {
global $wgContLang;
$found = false;
@ -145,6 +146,15 @@ class CoreParserFunctions {
$lang = $wgContLang->getLanguageName( strtolower( $arg ) );
return $lang != '' ? $lang : $arg;
}
function padleft( $parser, $string, $length, $char = 0 ) {
return str_pad( $string, $length, (string)$char, STR_PAD_LEFT );
}
function padright( $parser, $string, $length, $char = 0 ) {
return str_pad( $string, $length, (string)$char, STR_PAD_RIGHT );
}
}
?>

View file

@ -158,6 +158,8 @@ class Parser
$this->setFunctionHook( 'numberoffiles', array( 'CoreParserFunctions', 'numberoffiles' ), SFH_NO_HASH );
$this->setFunctionHook( 'numberofadmins', array( 'CoreParserFunctions', 'numberofadmins' ), SFH_NO_HASH );
$this->setFunctionHook( 'language', array( 'CoreParserFunctions', 'language' ), SFH_NO_HASH );
$this->setFunctionHook( 'padleft', array( 'CoreParserFunctions', 'padleft' ), SFH_NO_HASH );
$this->setFunctionHook( 'padright', array( 'CoreParserFunctions', 'padright' ), SFH_NO_HASH );
if ( $wgAllowDisplayTitle ) {
$this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH );

View file

@ -277,6 +277,8 @@ $magicWords = array(
'pagesinnamespace' => array( 1, 'PAGESINNAMESPACE:', 'PAGESINNS:' ),
'numberofadmins' => array( 1, 'NUMBEROFADMINS' ),
'formatnum' => array( 0, 'FORMATNUM' ),
'padleft' => array( 0, 'PADLEFT' ),
'padright' => array( 0, 'PADRIGHT' ),
);