Jackmcbarn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/106898


Change subject: Allow PENDINGCHANGELEVEL to work on other pages
......................................................................

Allow PENDINGCHANGELEVEL to work on other pages

Add an optional parameter to {{PENDINGCHANGELEVEL}} to allow it to work on
pages other than the current one.

Bug: 56863
Change-Id: Ib461e0a1aa4d26163b3a8e5feb29b7e088382a26
---
M backend/FlaggedRevs.hooks.php
1 file changed, 16 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/98/106898/1

diff --git a/backend/FlaggedRevs.hooks.php b/backend/FlaggedRevs.hooks.php
index cb07a64..01ac177 100644
--- a/backend/FlaggedRevs.hooks.php
+++ b/backend/FlaggedRevs.hooks.php
@@ -233,18 +233,14 @@
        public static function onParserFirstCallInit( &$parser ) {
                $parser->setFunctionHook( 'pagesusingpendingchanges',
                        'FlaggedRevsHooks::parserPagesUsingPendingChanges' );
+               $parser->setFunctionHook( 'pendingchangelevel',
+                       'FlaggedRevsHooks::parserPendingChangeLevel', 
SFH_NO_HASH );
                return true;
        }
 
        public static function onParserGetVariableValueSwitch( &$parser, 
&$cache, &$word, &$ret ) {
                if ( $word == 'pendingchangelevel' ) {
-                       $title = $parser->getTitle();
-                       if ( !FlaggedRevs::inReviewNamespace( $title ) ) {
-                               $ret = '';
-                       } else {
-                               $config = FRPageConfig::getStabilitySettings( 
$title );
-                               $ret = $config['autoreview'];
-                       }
+                       $ret = FlaggedRevsHooks::parserPendingChangeLevel( 
$parser );
                }
                return true;
        }
@@ -286,6 +282,19 @@
                }
        }
 
+       public static function parserPendingChangeLevel( &$parser, $page = '' ) 
{
+               $title = Title::newFromText( $page );
+               if( !( $title instanceof Title ) ) {
+                       $title = $parser->mTitle;
+               }
+               if ( !FlaggedRevs::inReviewNamespace( $title ) ) {
+                       return '';
+               } else {
+                       $config = FRPageConfig::getStabilitySettings( $title );
+                       return $config['autoreview'];
+               }
+       }
+
        /**
         * Detect if a ParserOutput object was added without mImageTimeKeys set.
         * This is needed for older, cached, ParserOutput objects.

-- 
To view, visit https://gerrit.wikimedia.org/r/106898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib461e0a1aa4d26163b3a8e5feb29b7e088382a26
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to