Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -138,7 +138,8 @@ |
139 | 139 | * @returns bool |
140 | 140 | */ |
141 | 141 | public function lowProfileUI() { |
142 | | - return FlaggedRevs::lowProfileUI() && FlaggedRevs::showStableByDefault() == $this->showStableByDefault(); |
| 142 | + return FlaggedRevs::lowProfileUI() && |
| 143 | + FlaggedRevs::showStableByDefault() == $this->showStableByDefault(); |
143 | 144 | } |
144 | 145 | |
145 | 146 | /** |
— | — | @@ -193,26 +194,27 @@ |
194 | 195 | */ |
195 | 196 | public function addStableLink() { |
196 | 197 | global $wgRequest, $wgOut, $wgLang; |
197 | | - if( $wgRequest->getVal('oldid') ) { |
198 | | - # We may have nav links like "direction=prev&oldid=x" |
199 | | - $revID = $this->parent->getOldIDFromRequest(); |
200 | | - $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID ); |
201 | | - # Give a notice if this rev ID corresponds to a reviewed version... |
202 | | - if( !is_null($frev) ) { |
203 | | - wfLoadExtensionMessages( 'FlaggedRevs' ); |
204 | | - $time = $wgLang->date( $frev->getTimestamp(), true ); |
205 | | - $flags = $frev->getTags(); |
206 | | - $quality = FlaggedRevs::isQuality( $flags ); |
207 | | - $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source'; |
208 | | - $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time ); |
209 | | - # Hide clutter |
210 | | - if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) { |
211 | | - $tag .= " " . FlaggedRevsXML::ratingToggle() . "<span id='mw-revisionratings' style='display:block;'>" . |
212 | | - "<br/>" . wfMsgHtml('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
213 | | - } |
214 | | - $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>"; |
215 | | - $wgOut->addHTML( $tag ); |
| 198 | + if( !$wgRequest->getVal('oldid') ) |
| 199 | + return true; # Only for viewing old versions |
| 200 | + # We may have nav links like "direction=prev&oldid=x" |
| 201 | + $revID = $this->parent->getOldIDFromRequest(); |
| 202 | + $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID ); |
| 203 | + # Give a notice if this rev ID corresponds to a reviewed version... |
| 204 | + if( !is_null($frev) ) { |
| 205 | + wfLoadExtensionMessages( 'FlaggedRevs' ); |
| 206 | + $time = $wgLang->date( $frev->getTimestamp(), true ); |
| 207 | + $flags = $frev->getTags(); |
| 208 | + $quality = FlaggedRevs::isQuality( $flags ); |
| 209 | + $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source'; |
| 210 | + $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time ); |
| 211 | + # Hide clutter |
| 212 | + if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) { |
| 213 | + $tag .= " " . FlaggedRevsXML::ratingToggle() . |
| 214 | + "<span id='mw-revisionratings' style='display:block;'><br/>" . |
| 215 | + wfMsgHtml('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
216 | 216 | } |
| 217 | + $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>"; |
| 218 | + $wgOut->addHTML( $tag ); |
217 | 219 | } |
218 | 220 | return true; |
219 | 221 | } |
— | — | @@ -414,7 +416,6 @@ |
415 | 417 | $msg = $synced ? "{$msg}-same" : $msg; |
416 | 418 | $html = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" . |
417 | 419 | wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $revsSince ); |
418 | | - |
419 | 420 | $tag = FlaggedRevsXML::prettyRatingBox( $frev, $html, $revsSince, true, $synced ); |
420 | 421 | // Standard UI |
421 | 422 | } else { |
— | — | @@ -521,8 +522,7 @@ |
522 | 523 | } |
523 | 524 | |
524 | 525 | if( !$time ) { |
525 | | - // Use the default behaviour |
526 | | - return; |
| 526 | + return; // Use the default behaviour |
527 | 527 | } |
528 | 528 | |
529 | 529 | $title = $this->parent->getTitle(); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -212,10 +212,11 @@ |
213 | 213 | 1 => 'quality', |
214 | 214 | 2 => 'pristine' |
215 | 215 | ); |
216 | | - if ( isset( $levelText[$level] ) ) |
| 216 | + if( isset( $levelText[$level] ) ) { |
217 | 217 | return $levelText[$level]; |
218 | | - else |
219 | | - return ''; |
| 218 | + } else { |
| 219 | + return ''; |
| 220 | + } |
220 | 221 | } |
221 | 222 | |
222 | 223 | ################# Parsing functions ################# |
— | — | @@ -236,7 +237,8 @@ |
237 | 238 | $options = self::makeParserOptions(); |
238 | 239 | $outputText = $wgParser->preprocess( $text, $title, $options, $id ); |
239 | 240 | $out =& $wgParser->mOutput; |
240 | | - $data = array( $outputText, $out->mTemplates, $out->mTemplateIds, $out->fr_includeErrors, $out->fr_newestTemplateID ); |
| 241 | + $data = array( $outputText, $out->mTemplates, $out->mTemplateIds, |
| 242 | + $out->fr_includeErrors, $out->fr_newestTemplateID ); |
241 | 243 | # Done! |
242 | 244 | $wgParser->fr_isStable = false; |
243 | 245 | # Return data array |
— | — | @@ -258,7 +260,6 @@ |
259 | 261 | $wgParser->fr_isStable = true; |
260 | 262 | # Don't show section-edit links, they can be old and misleading |
261 | 263 | $options = self::makeParserOptions(); |
262 | | - #$options->setEditSection( $id == $title->getLatestRevID(GAID_FOR_UPDATE) ); |
263 | 264 | # Parse the new body, wikitext -> html |
264 | 265 | $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id ); |
265 | 266 | # Done with parser! |
— | — | @@ -286,7 +287,6 @@ |
287 | 288 | */ |
288 | 289 | public static function getPageCache( $article ) { |
289 | 290 | global $wgUser, $parserMemc, $wgCacheEpoch; |
290 | | - |
291 | 291 | wfProfileIn( __METHOD__ ); |
292 | 292 | # Make sure it is valid |
293 | 293 | if( !$article->getId() ) |
— | — | @@ -326,7 +326,6 @@ |
327 | 327 | } |
328 | 328 | |
329 | 329 | wfProfileOut( __METHOD__ ); |
330 | | - |
331 | 330 | return $value; |
332 | 331 | } |
333 | 332 | |
— | — | @@ -471,6 +470,7 @@ |
472 | 471 | * This function is pretty expensive... |
473 | 472 | */ |
474 | 473 | public static function stableVersionIsSynced( $srev, $article, $stableOutput=null, $currentOutput=null ) { |
| 474 | + global $wgMemc, $wgEnableParserCache; |
475 | 475 | # Must be the same revision |
476 | 476 | if( $srev->getRevId() != $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ) { |
477 | 477 | return false; |
— | — | @@ -481,7 +481,6 @@ |
482 | 482 | return false; |
483 | 483 | } |
484 | 484 | } |
485 | | - global $wgMemc, $wgEnableParserCache; |
486 | 485 | # Try the cache... |
487 | 486 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() ); |
488 | 487 | $value = self::getMemcValue( $wgMemc->get($key), $article ); |
— | — | @@ -606,11 +605,9 @@ |
607 | 606 | if( !$article->getId() ) |
608 | 607 | return true; // no bogus entries |
609 | 608 | |
610 | | - wfProfileIn( __METHOD__ ); |
611 | 609 | $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
612 | | - |
| 610 | + # Get the highest quality revision (not necessarily this one) |
613 | 611 | $dbw = wfGetDB( DB_MASTER ); |
614 | | - # Get the highest quality revision (not necessarily this one). |
615 | 612 | $maxQuality = $dbw->selectField( array('flaggedrevs','revision'), |
616 | 613 | 'fr_quality', |
617 | 614 | array( 'fr_page_id' => $article->getId(), |
— | — | @@ -641,7 +638,6 @@ |
642 | 639 | # Updates the count cache |
643 | 640 | $count = self::getRevCountSince( $article, $revId, true ); |
644 | 641 | |
645 | | - wfProfileOut( __METHOD__ ); |
646 | 642 | return true; |
647 | 643 | } |
648 | 644 | |
— | — | @@ -754,8 +750,8 @@ |
755 | 751 | $row = $db->selectRow( 'flaggedpage_config', |
756 | 752 | array( 'fpc_select', 'fpc_override', 'fpc_expiry' ), |
757 | 753 | array( 'fpc_page_id' => $title->getArticleID() ), |
758 | | - __METHOD__ ); |
759 | | - |
| 754 | + __METHOD__ |
| 755 | + ); |
760 | 756 | if( $row ) { |
761 | 757 | $now = wfTimestampNow(); |
762 | 758 | # This code should be refactored, now that it's being used more generally. |
— | — | @@ -775,8 +771,8 @@ |
776 | 772 | $select = $wgFlaggedRevsPrecedence ? FLAGGED_VIS_NORMAL : FLAGGED_VIS_LATEST; |
777 | 773 | return array('select' => $select, 'override' => $override, 'expiry' => 'infinity'); |
778 | 774 | } |
779 | | - |
780 | | - return array('select' => $row->fpc_select, 'override' => $row->fpc_override, 'expiry' => $row->fpc_expiry); |
| 775 | + return array('select' => $row->fpc_select, 'override' => $row->fpc_override, |
| 776 | + 'expiry' => $row->fpc_expiry ); |
781 | 777 | } |
782 | 778 | |
783 | 779 | /** |
— | — | @@ -786,7 +782,8 @@ |
787 | 783 | $dbw = wfGetDB( DB_MASTER ); |
788 | 784 | $dbw->delete( 'flaggedpage_config', |
789 | 785 | array( 'fpc_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), |
790 | | - __METHOD__ ); |
| 786 | + __METHOD__ |
| 787 | + ); |
791 | 788 | } |
792 | 789 | |
793 | 790 | ################# Other utility functions ################# |
— | — | @@ -797,15 +794,11 @@ |
798 | 795 | */ |
799 | 796 | public static function isQuality( $flags ) { |
800 | 797 | global $wgFlaggedRevTags; |
801 | | - |
802 | | - if( empty($flags) ) |
803 | | - return false; |
804 | | - |
| 798 | + if( empty($flags) ) return false; |
805 | 799 | foreach( $wgFlaggedRevTags as $f => $v ) { |
806 | 800 | if( !isset($flags[$f]) || $v > $flags[$f] ) |
807 | 801 | return false; |
808 | 802 | } |
809 | | - |
810 | 803 | return true; |
811 | 804 | } |
812 | 805 | |
— | — | @@ -815,15 +808,11 @@ |
816 | 809 | */ |
817 | 810 | public static function isPristine( $flags ) { |
818 | 811 | global $wgFlaggedRevTags, $wgFlaggedRevPristine; |
819 | | - |
820 | | - if( empty($flags) ) |
821 | | - return false; |
822 | | - |
| 812 | + if( empty($flags) ) return false; |
823 | 813 | foreach( $wgFlaggedRevTags as $f => $v ) { |
824 | 814 | if( !isset($flags[$f]) || $flags[$f] < $wgFlaggedRevPristine ) |
825 | 815 | return false; |
826 | 816 | } |
827 | | - |
828 | 817 | return true; |
829 | 818 | } |
830 | 819 | |