(Bug 17970) {{PROTECTIONLEVEL}} should be able to return the status for pages besides...
authorPavel Selitskas <p.selitskas@gmail.com>
Fri, 18 Jan 2013 19:03:01 +0000 (22:03 +0300)
committerPavel Selitskas <p.selitskas@gmail.com>
Fri, 18 Jan 2013 19:03:01 +0000 (22:03 +0300)
Change-Id: I4c60a5f25c739583eb087024c5e949ebcd2def72

includes/parser/CoreParserFunctions.php

index 8917b6d..fa934d7 100644 (file)
@@ -672,11 +672,20 @@ class CoreParserFunctions {
        }
 
        /**
-       * Returns the requested protection level for the current page
+        * Returns the requested protection level for the current page
+        *
+        * @param Parser $parser
+        * @param string $type
+        * @param string $title
+        *
         * @return string
         */
-       static function protectionlevel( $parser, $type = '' ) {
-               $restrictions = $parser->mTitle->getRestrictions( strtolower( $type ) );
+       static function protectionlevel( $parser, $type = '', $title = '' ) {
+               $titleObject = Title::newFromText( $title );
+               if ( !( $titleObject instanceof Title ) ) {
+                       $titleObject = $parser->mTitle;
+               }
+               $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
                # Title::getRestrictions returns an array, its possible it may have
                # multiple values in the future
                return implode( $restrictions, ',' );