Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -536,6 +536,9 @@ |
537 | 537 | $wgHooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsHooks::insertStabilityLog'; |
538 | 538 | # Save stability settings |
539 | 539 | $wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave'; |
| 540 | + # Parser stuff |
| 541 | + $wgHooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit'; |
| 542 | + $wgHooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic'; |
540 | 543 | } |
541 | 544 | # Give bots the 'autoreview' right (here so it triggers after CentralAuth) |
542 | 545 | # @TODO: better way to ensure hook order |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -676,6 +676,52 @@ |
677 | 677 | return true; |
678 | 678 | } |
679 | 679 | |
| 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 | + |
680 | 726 | /** |
681 | 727 | * Insert image timestamps/SHA-1s into page output |
682 | 728 | */ |