(bug 9947) Add PROTECTIONLEVEL parser function to return the protection level for...
authorAlex Z <mrzman@users.mediawiki.org>
Thu, 8 Jan 2009 23:21:06 +0000 (23:21 +0000)
committerAlex Z <mrzman@users.mediawiki.org>
Thu, 8 Jan 2009 23:21:06 +0000 (23:21 +0000)
RELEASE-NOTES
includes/MagicWord.php
includes/parser/CoreParserFunctions.php
languages/messages/MessagesEn.php

index b281efc..beec495 100644 (file)
@@ -29,7 +29,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added "Advanced search" link to the search form
 * Special:Upload can now have a custom upload message instead of uploadtext by
   passing "uploadmsg" parameter in the url
-
+* (bug 9947) Add PROTECTIONLEVEL parser funtion to return the protection level
+  for the current page for a given action
+  
 === Bug fixes in 1.15 ===
 
 
index 5b5b77f..6eefd7a 100644 (file)
@@ -109,6 +109,7 @@ class MagicWord {
                'index',
                'noindex',
                'numberingroup',
+               'protectionlevel',
        );
 
        /* Array of caching hints for ParserCache */
index a3b5189..2dfd34b 100644 (file)
@@ -45,6 +45,7 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'filepath',         array( __CLASS__, 'filepath'         ), SFH_NO_HASH );
                $parser->setFunctionHook( 'pagesincategory',  array( __CLASS__, 'pagesincategory'  ), SFH_NO_HASH );
                $parser->setFunctionHook( 'pagesize',         array( __CLASS__, 'pagesize'         ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'protectionlevel',  array( __CLASS__, 'protectionlevel'  ), SFH_NO_HASH );
                $parser->setFunctionHook( 'tag',              array( __CLASS__, 'tagObj'           ), SFH_OBJECT_ARGS );
 
                if ( $wgAllowDisplayTitle ) {
@@ -292,6 +293,16 @@ class CoreParserFunctions {
                }       
                return self::formatRaw( $length, $raw );
        }
+       
+       /**
+       * Returns the requested protection level for the current page
+       */
+       static function protectionlevel( $parser, $type = '' ) {
+               $restrictions = $parser->mTitle->getRestrictions( strtolower( $type ) );
+               # Title::getRestrictions returns an array, its possible it may have
+               # multiple values in the future
+               return implode( $restrictions, ',' );
+       }
 
        static function language( $parser, $arg = '' ) {
                global $wgContLang;
index ebabc4b..e7acf03 100644 (file)
@@ -333,6 +333,7 @@ $magicWords = array(
        'noindex'                => array( 1,    '__NOINDEX__'            ),
        'numberingroup'          => array( 1,    'NUMBERINGROUP', 'NUMINGROUP' ),
        'staticredirect'         => array( 1,    '__STATICREDIRECT__'     ),
+       'protectionlevel'        => array( 1,    'PROTECTIONLEVEL'        ),
 );
 
 /**