r68548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68547‎ | r68548 | r68549 >
Date:03:29, 25 June 2010
Author:demon
Status:deferred
Tags:
Comment:
(bug 23903) Add parserfunc for number of pages using pending changes. {{#pagesusingpendingchanges:}} takes one optional param for the namespace number
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
@@ -536,6 +536,9 @@
537537 $wgHooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsHooks::insertStabilityLog';
538538 # Save stability settings
539539 $wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave';
 540+ # Parser stuff
 541+ $wgHooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit';
 542+ $wgHooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic';
540543 }
541544 # Give bots the 'autoreview' right (here so it triggers after CentralAuth)
542545 # @TODO: better way to ensure hook order
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -676,6 +676,52 @@
677677 return true;
678678 }
679679
 680+ public static function onParserFirstCallInit( &$parser ) {
 681+ $parser->setFunctionHook( 'pagesusingpendingchanges',
 682+ 'FlaggedRevsHooks::parserPagesUsingPendingChanges' );
 683+ return true;
 684+ }
 685+
 686+ public static function onLanguageGetMagic( &$magicWords, $langCode ) {
 687+ $magicWords['pagesusingpendingchanges'] =
 688+ array( 0, 'pagesusingpendingchanges' );
 689+ return true;
 690+ }
 691+
 692+ public static function parserPagesUsingPendingChanges( &$parser, $ns = '' ) {
 693+ $nsList = FlaggedRevs::getReviewNamespaces();
 694+
 695+
 696+ if( !$nsList ) {
 697+ return 0;
 698+ }
 699+
 700+ if( $ns !== '' ) {
 701+ $ns = intval( $ns );
 702+ if( !in_array( $ns , $nsList ) ) {
 703+ return 0;
 704+ }
 705+ }
 706+
 707+ static $pcCounts = null;
 708+ if( !$pcCounts ) {
 709+ $dbr = wfGetDB( DB_SLAVE );
 710+ $res = $dbr->select( 'flaggedrevs_stats', '*', array(), __METHOD__ );
 711+ $totalCount = 0;
 712+ foreach( $res as $row ) {
 713+ $nsList[ "ns-{$row->namespace}" ] = $row->reviewed;
 714+ $totalCount += $row->reviewed;
 715+ }
 716+ $nsList[ 'all' ] = $totalCount;
 717+ }
 718+
 719+ if( $ns === '' || $ns === '*' ) {
 720+ return $nsList['all'];
 721+ } else {
 722+ return $nsList[ "ns-$ns" ];
 723+ }
 724+ }
 725+
680726 /**
681727 * Insert image timestamps/SHA-1s into page output
682728 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r68549Folowup r68548, spacing and rm leftover test for all namespacesdemon03:31, 25 June 2010

Status & tagging log