Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -408,12 +408,10 @@ |
409 | 409 | $wgHooks['GetPreferences'][] = 'FlaggedRevsHooks::onGetPreferences'; |
410 | 410 | # Show unreviewed pages links |
411 | 411 | $wgHooks['CategoryPageView'][] = 'FlaggedRevsHooks::onCategoryPageView'; |
412 | | -# Backlog notice |
413 | | -$wgHooks['SiteNoticeAfter'][] = 'FlaggedRevsHooks::addBacklogNotice'; |
414 | 412 | # Review/stability log links |
415 | 413 | $wgHooks['LogLine'][] = 'FlaggedRevsHooks::logLineLinks'; |
416 | 414 | |
417 | | -# Add CSS/JS and review notice |
| 415 | +# Add review notice, backlog notices and CSS/JS and set robots |
418 | 416 | $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::onBeforePageDisplay'; |
419 | 417 | # Add global JS vars |
420 | 418 | $wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars'; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -166,6 +166,7 @@ |
167 | 167 | $view->setRobotPolicy(); // set indexing policy |
168 | 168 | self::injectStyleAndJS(); // full CSS/JS |
169 | 169 | } else { |
| 170 | + self::maybeAddBacklogNotice( $out ); // RC/Watchlist notice |
170 | 171 | self::injectStyleForSpecial( $out ); // try special page CSS |
171 | 172 | } |
172 | 173 | return true; |
— | — | @@ -1835,36 +1836,36 @@ |
1836 | 1837 | return true; |
1837 | 1838 | } |
1838 | 1839 | |
1839 | | - public static function addBacklogNotice( &$notice ) { |
1840 | | - global $wgUser, $wgTitle; |
1841 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
1842 | | - if ( !count( $namespaces ) ) { |
1843 | | - return true; // nothing to have a backlog on |
1844 | | - } elseif ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) { |
1845 | | - return true; // nothing to do here |
1846 | | - } elseif ( !$wgUser->isAllowed( 'review' ) ) { |
| 1840 | + protected static function maybeAddBacklogNotice( OutputPage &$out ) { |
| 1841 | + global $wgUser; |
| 1842 | + if ( !$wgUser->isAllowed( 'review' ) ) { |
1847 | 1843 | return true; // not relevant to user |
1848 | 1844 | } |
1849 | | - $watchlist = SpecialPage::getTitleFor( 'Watchlist' ); |
1850 | | - $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' ); |
1851 | | - if ( $wgTitle->equals( $watchlist ) || $wgTitle->equals( $recentchanges ) ) { |
1852 | | - $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); |
1853 | | - $watchedOutdated = $dbr->selectField( |
1854 | | - array( 'watchlist', 'page', 'flaggedpages' ), |
1855 | | - '1', // existence |
1856 | | - array( 'wl_user' => $wgUser->getId(), // this user |
1857 | | - 'wl_namespace' => $namespaces, // reviewable |
1858 | | - 'wl_namespace = page_namespace', |
1859 | | - 'wl_title = page_title', |
1860 | | - 'fp_page_id = page_id', |
1861 | | - 'fp_reviewed' => 0, // edits pending |
1862 | | - ), __METHOD__ |
1863 | | - ); |
1864 | | - # Give a notice if pages on the wachlist are outdated |
1865 | | - if ( $watchedOutdated ) { |
1866 | | - $css = 'plainlinks fr-watchlist-pending-notice'; |
1867 | | - $notice .= "<div id='mw-fr-watchlist-pending-notice' class='$css'>" . |
1868 | | - wfMsgExt( 'flaggedrevs-watched-pending', 'parseinline' ) . "</div>"; |
| 1845 | + $title = $out->getTitle(); |
| 1846 | + $namespaces = FlaggedRevs::getReviewNamespaces(); |
| 1847 | + if ( $title->getNamespace() == NS_SPECIAL && $namespaces ) { |
| 1848 | + $watchlist = SpecialPage::getTitleFor( 'Watchlist' ); |
| 1849 | + $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' ); |
| 1850 | + # Notice applies only to RC/watchlists |
| 1851 | + if ( $title->equals( $watchlist ) || $title->equals( $recentchanges ) ) { |
| 1852 | + $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); // consistency with watchlist |
| 1853 | + $watchedOutdated = $dbr->selectField( |
| 1854 | + array( 'watchlist', 'page', 'flaggedpages' ), |
| 1855 | + '1', // existence |
| 1856 | + array( 'wl_user' => $wgUser->getId(), // this user |
| 1857 | + 'wl_namespace' => $namespaces, // reviewable |
| 1858 | + 'wl_namespace = page_namespace', |
| 1859 | + 'wl_title = page_title', |
| 1860 | + 'fp_page_id = page_id', |
| 1861 | + 'fp_reviewed' => 0, // edits pending |
| 1862 | + ), __METHOD__ |
| 1863 | + ); |
| 1864 | + # Give a notice if pages on the users's wachlist have pending edits |
| 1865 | + if ( $watchedOutdated ) { |
| 1866 | + $css = 'plainlinks fr-watchlist-pending-notice'; |
| 1867 | + $out->prependHTML( "<div id='mw-fr-watchlist-pending-notice' class='$css'>" . |
| 1868 | + wfMsgExt( 'flaggedrevs-watched-pending', 'parseinline' ) . "</div>" ); |
| 1869 | + } |
1869 | 1870 | } |
1870 | 1871 | } |
1871 | 1872 | return true; |