From 73ee792c4df74615bbd02dfa2bbbf6755c0d9647 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Fri, 18 Aug 2006 17:30:35 +0000 Subject: [PATCH] * (bug 7044) Introduce "padleft" and "padright" colon functions --- RELEASE-NOTES | 1 + includes/CoreParserFunctions.php | 10 ++++++++++ includes/Parser.php | 2 ++ languages/MessagesEn.php | 2 ++ 4 files changed, 15 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 200051ae34..8084190684 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index 33d81e5643..1392c98e6c 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -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 ); + } + } ?> diff --git a/includes/Parser.php b/includes/Parser.php index e7166e0bdc..3307191874 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 ); diff --git a/languages/MessagesEn.php b/languages/MessagesEn.php index 56591779c6..a75186c100 100644 --- a/languages/MessagesEn.php +++ b/languages/MessagesEn.php @@ -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' ), ); -- 2.20.1