Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -45,6 +45,10 @@ |
46 | 46 | # Patrollable namespaces |
47 | 47 | $wgFlaggedRevsPatrolNamespaces = array( NS_CATEGORY, NS_IMAGE, NS_TEMPLATE ); |
48 | 48 | |
| 49 | +# Pages exempt from reviewing |
| 50 | +$wgFlaggedRevsWhitelist = array(); |
| 51 | +# $wgFlaggedRevsWhitelist = array( 'Main_Page' ); |
| 52 | + |
49 | 53 | # Do flagged revs override the default view? |
50 | 54 | $wgFlaggedRevsOverride = true; |
51 | 55 | # Do quality revisions show instead of sighted if present by default? |
— | — | @@ -343,6 +347,9 @@ |
344 | 348 | # Set aliases |
345 | 349 | $wgHooks['LanguageGetSpecialPageAliases'][] = 'FlaggedRevs::addLocalizedSpecialPageNames'; |
346 | 350 | |
| 351 | +# File cache |
| 352 | +$wgHooks['IsFileCacheable'][] = 'FlaggedRevs::isFileCacheable'; |
| 353 | + |
347 | 354 | # Duplicate flagged* tables in parserTests.php |
348 | 355 | $wgHooks['ParserTestTables'][] = 'FlaggedRevs::onParserTestTables'; |
349 | 356 | |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -401,7 +401,7 @@ |
402 | 402 | # Add revision notes |
403 | 403 | $wgOut->mBodytext = $wgOut->mBodytext . $notes; |
404 | 404 | // Add "no reviewed version" tag, but not for main page or printable output. |
405 | | - } else if( !$wgOut->isPrintable() && !FlaggedRevs::isMainPage( $this->parent->getTitle() ) ) { |
| 405 | + } else if( !$wgOut->isPrintable() ) { |
406 | 406 | // Simple icon-based UI |
407 | 407 | if( FlaggedRevs::useSimpleUI() ) { |
408 | 408 | $msg = $old ? 'revreview-quick-invalid' : 'revreview-quick-none'; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -147,6 +147,15 @@ |
148 | 148 | return empty(self::$dimensions); |
149 | 149 | } |
150 | 150 | |
| 151 | + /** |
| 152 | + * Do anons see the stable version by default? |
| 153 | + * @returns bool |
| 154 | + */ |
| 155 | + public static function publicViewStableByDefault() { |
| 156 | + global $wgFlaggedRevsOverride, $wgFlaggedRevsExceptions; |
| 157 | + return ($wgFlaggedRevsOverride && !in_array('*',$wgFlaggedRevsExceptions) ); |
| 158 | + } |
| 159 | + |
151 | 160 | ################# Parsing functions ################# |
152 | 161 | |
153 | 162 | /** |
— | — | @@ -699,14 +708,6 @@ |
700 | 709 | ################# Other utility functions ################# |
701 | 710 | |
702 | 711 | /** |
703 | | - * @param Title $title |
704 | | - * @return bool, is $title the main page? |
705 | | - */ |
706 | | - public static function isMainPage( $title ) { |
707 | | - return $title->equals( Title::newMainPage() ); |
708 | | - } |
709 | | - |
710 | | - /** |
711 | 712 | * @param Array $flags |
712 | 713 | * @return bool, is this revision at quality condition? |
713 | 714 | */ |
— | — | @@ -748,9 +749,14 @@ |
749 | 750 | * @return bool |
750 | 751 | */ |
751 | 752 | public static function isPageReviewable( $title ) { |
752 | | - global $wgFlaggedRevsNamespaces; |
| 753 | + global $wgFlaggedRevsNamespaces, $wgFlaggedRevsWhitelist; |
753 | 754 | # FIXME: Treat NS_MEDIA as NS_IMAGE |
754 | 755 | $ns = ( $title->getNamespace() == NS_MEDIA ) ? NS_IMAGE : $title->getNamespace(); |
| 756 | + # Check whitelist for exempt pages |
| 757 | + var_dump( $title->getPrefixedDBKey() ); |
| 758 | + if( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) { |
| 759 | + return false; |
| 760 | + } |
755 | 761 | return ( in_array($ns,$wgFlaggedRevsNamespaces) && !$title->isTalkPage() && $ns != NS_MEDIAWIKI ); |
756 | 762 | } |
757 | 763 | |
— | — | @@ -2112,6 +2118,19 @@ |
2113 | 2119 | } |
2114 | 2120 | return true; |
2115 | 2121 | } |
| 2122 | + |
| 2123 | + public static function isFileCacheable( $article ) { |
| 2124 | + $fa = FlaggedArticle::getInstance( $article ); |
| 2125 | + # If the stable is the default, and we are viewing it...cache it! |
| 2126 | + if( self::publicViewStableByDefault() ) { |
| 2127 | + return ( $fa->pageOverride() && $fa->getStableRev( true ) ); |
| 2128 | + # If the draft is the default, and we are viewing it...cache it! |
| 2129 | + } else { |
| 2130 | + global $wgRequest; |
| 2131 | + # We don't want to cache the pending edit notice though |
| 2132 | + return !( $fa->pageOverride() && $fa->getStableRev( true ) ) && !$wgRequest->getVal('shownotice'); |
| 2133 | + } |
| 2134 | + } |
2116 | 2135 | |
2117 | 2136 | public static function onParserTestTables( &$tables ) { |
2118 | 2137 | $tables[] = 'flaggedpages'; |