r68830 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68829‎ | r68830 | r68831 >
Date:13:30, 1 July 2010
Author:demon
Status:deferred
Tags:
Comment:
(bug 24004) Add magic word like {{protectionlevel}} for pending changes. So here's {{pendingchangelevel}}
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -539,6 +539,8 @@
540540 # Parser stuff
541541 $wgHooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit';
542542 $wgHooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic';
 543+ $wgHooks['ParserGetVariableValueSwitch'][] = 'FlaggedRevsHooks::onParserGetVariableValueSwitch';
 544+ $wgHooks['MagicWordwgVariableIDs'][] = 'FlaggedRevsHooks::onMagicWordwgVariableIDs';
543545 }
544546 # Give bots the 'autoreview' right (here so it triggers after CentralAuth)
545547 # @TODO: better way to ensure hook order
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -632,9 +632,29 @@
633633 public static function onLanguageGetMagic( &$magicWords, $langCode ) {
634634 $magicWords['pagesusingpendingchanges'] =
635635 array( 0, 'pagesusingpendingchanges' );
 636+ $magicWords['pendingchangelevel'] =
 637+ array( 0, 'pendingchangelevel' );
636638 return true;
637639 }
638640
 641+ public static function onParserGetVariableValueSwitch( &$parser, &$cache, &$word, &$ret ) {
 642+ if( $word == 'pendingchangelevel' ) {
 643+ $title = $parser->getTitle();
 644+ if( !FlaggedRevs::inReviewNamespace( $title ) ) {
 645+ $ret = '';
 646+ } else {
 647+ $config = FlaggedRevs::getPageVisibilitySettings( $title );
 648+ $ret = $config['autoreview'];
 649+ }
 650+ }
 651+ return true;
 652+ }
 653+
 654+ public static function onMagicWordwgVariableIDs( &$words ) {
 655+ $words[] = 'pendingchangelevel';
 656+ return true;
 657+ }
 658+
639659 public static function parserPagesUsingPendingChanges( &$parser, $ns = '' ) {
640660 $nsList = FlaggedRevs::getReviewNamespaces();
641661

Status & tagging log