* (bug 7044) Introduce "padleft" and "padright" colon functions
authorRob Church <robchurch@users.mediawiki.org>
Fri, 18 Aug 2006 17:30:35 +0000 (17:30 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Fri, 18 Aug 2006 17:30:35 +0000 (17:30 +0000)
RELEASE-NOTES
includes/CoreParserFunctions.php
includes/Parser.php
languages/MessagesEn.php

index 200051a..8084190 100644 (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 ==
 
index 33d81e5..1392c98 100644 (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 );
+       }
+       
 }
 
 ?>
index e7166e0..3307191 100644 (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 );
index 5659177..a75186c 100644 (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' ),
 
 );