r32150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32149‎ | r32150 | r32151 >
Date:00:54, 19 March 2008
Author:aaron
Status:old
Tags:
Comment:
Fix old stable version viewer so it actually works ;)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -14,7 +14,7 @@
1515 $wgExtensionCredits['specialpage'][] = array(
1616 'name' => 'Flagged Revisions',
1717 'author' => array( 'Aaron Schulz', 'Joerg Baach' ),
18 - 'version' => '1.019',
 18+ 'version' => '1.02',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs',
2020 'descriptionmsg' => 'flaggedrevs-desc',
2121 );
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -133,7 +133,6 @@
134134 }
135135 $simpleTag = $old = $stable = false;
136136 $tag = $notes = $pending = '';
137 - $same = true;
138137 # Check the newest stable version.
139138 $frev = $this->getStableRev( true );
140139 $stableId = $frev ? $frev->getRevId() : 0;
@@ -158,12 +157,58 @@
159158 # Get quality level
160159 $quality = FlaggedRevs::isQuality( $flags );
161160 $pristine = FlaggedRevs::isPristine( $flags );
162 - // Looking at some specific old rev or if flagged revs are not
 161+ // Looking at some specific old stable revision ("&stableid=x")
163162 // set to override given the relevant conditions. If the user is
164163 // requesting the stable revision ("&stableid=x"), defer to override
165164 // behavior below, since it is the same as ("&stable=1").
166 - if( !$stable && !$this->pageOverride() ) {
 165+ if( $old ) {
167166 $revs_since = FlaggedRevs::getRevCountSince( $article, $frev->getRevId() );
 167+ global $wgUseStableTemplates;
 168+ if( $wgUseStableTemplates ) {
 169+ $rev = Revision::newFromId( $frev->getRevId() );
 170+ $text = $rev->getText();
 171+ } else {
 172+ $text = $frev->getText();
 173+ }
 174+ $parserOut = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() );
 175+ # Construct some tagging for non-printable outputs. Note that the pending
 176+ # notice has all this info already, so don't do this if we added that already.
 177+ if( !$wgOut->isPrintable() ) {
 178+ $css = 'fr-icon-current'; // default
 179+ // Simple icon-based UI
 180+ if( FlaggedRevs::useSimpleUI() ) {
 181+ $msg = $quality ? 'revreview-quick-quality-old' : 'revreview-quick-basic-old';
 182+ $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
 183+ $tag .= "<span class='{$css}'></span>" .
 184+ wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time ) .
 185+ $this->prettyRatingBox( $frev, $revs_since, true, $synced, $old );
 186+ // Standard UI
 187+ } else {
 188+ $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old';
 189+ $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
 190+ $tag .= "<span class='{$css}'></span>" .
 191+ wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
 192+ # Hide clutter
 193+ if( !empty($flags) ) {
 194+ $tag .= " <span id='mw-revisiontoggle' class='flaggedrevs_toggle' style='display:none; cursor:pointer;'" .
 195+ " onclick='toggleRevRatings()'>" . wfMsg( 'revreview-toggle' ) . "</span>";
 196+ $tag .= "<span id='mw-revisionratings' style='display:block;'>" .
 197+ wfMsgHtml('revreview-oldrating') . $this->addTagRatings( $flags ) . '</span>';
 198+ }
 199+ }
 200+ }
 201+ # Output HTML
 202+ $wgOut->addParserOutput( $parserOut );
 203+ $notes = $this->ReviewNotes( $frev );
 204+ # Tell MW that parser output is done
 205+ $outputDone = true;
 206+ $pcache = false;
 207+ // Looking at some specific old revision or if FlaggedRevs is not
 208+ // set to override given the relevant conditions. If the user is
 209+ // requesting the stable revision ("&stableid=x"), defer to override
 210+ // behavior below, since it is the same as ("&stable=1").
 211+ } else if( !$stable && !$this->pageOverride() ) {
 212+ $revs_since = FlaggedRevs::getRevCountSince( $article, $frev->getRevId() );
168213 $synced = FlaggedRevs::flaggedRevIsSynced( $frev, $article, null, null );
169214 # Give notice to newewer users if an unreviewed edit was completed...
170215 if( $wgRequest->getVal('shownotice') && !$synced && !$wgUser->isAllowed('review') ) {
@@ -175,7 +220,7 @@
176221 $this->reviewNotice = $pending;
177222 }
178223 # If they are synced, do special styling
179 - $simpleTag = !$synced && !$old;
 224+ $simpleTag = !$synced;
180225 # Construct some tagging for non-printable outputs. Note that the pending
181226 # notice has all this info already, so don't do this if we added that already.
182227 if( !$wgOut->isPrintable() && !$pending ) {
@@ -186,26 +231,18 @@
187232 $msg = $quality ? 'revreview-quick-quality-same' : 'revreview-quick-basic-same';
188233 $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
189234 $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $revs_since );
190 - } else if( $old ) {
191 - $msg = $quality ? 'revreview-quick-quality-old' : 'revreview-quick-basic-old';
192 - $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
193 - $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
194235 } else {
195236 $msg = $quality ? 'revreview-quick-see-quality' : 'revreview-quick-see-basic';
196237 $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $revs_since );
197238 }
198239 $tag .= "<span class='{$css}'></span>" . $msgHTML .
199 - $this->prettyRatingBox( $frev, $revs_since, $synced || $old, $synced, $old );
 240+ $this->prettyRatingBox( $frev, $revs_since, $synced, $synced, $old );
200241 // Standard UI
201242 } else {
202243 if( $synced ) {
203244 $msg = $quality ? 'revreview-quality-same' : 'revreview-basic-same';
204245 $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
205246 $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since );
206 - } else if( $old ) {
207 - $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old';
208 - $css = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
209 - $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
210247 } else {
211248 $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
212249 $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since );
@@ -220,7 +257,7 @@
221258 }
222259 }
223260 }
224 - // Viewing the page normally: override the page
 261+ // The relevant conditions are met to override the page with the stable version.
225262 } else {
226263 # We will be looking at the reviewed revision...
227264 $revs_since = FlaggedRevs::getRevCountSince( $article, $frev->getRevId() );
@@ -245,7 +282,7 @@
246283 // Simple icon-based UI
247284 if( FlaggedRevs::useSimpleUI() ) {
248285 $msg = $quality ? 'revreview-quick-quality' : 'revreview-quick-basic';
249 - $msg = $synced ? $msg . '-same' : $msg;
 286+ $msg = $synced ? "{$msg}-same" : $msg;
250287
251288 $tag = "<span class='{$css}'></span>" .
252289 wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $revs_since );
@@ -253,7 +290,7 @@
254291 // Standard UI
255292 } else {
256293 $msg = $quality ? 'revreview-quality' : 'revreview-basic';
257 - $msg = $synced ? $msg . '-same' : $msg;
 294+ $msg = $synced ? "{$msg}-same" : $msg;
258295
259296 $tag = "<span class='{$css} plainlinks'></span>" .
260297 wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since );

Status & tagging log