Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -143,25 +143,14 @@ |
144 | 144 | return true; |
145 | 145 | } |
146 | 146 | |
| 147 | + |
147 | 148 | /** |
148 | | - * Replaces a page with the last stable version if possible |
149 | | - * Adds stable version status/info tags and notes |
150 | | - * Adds a quick review form on the bottom if needed |
| 149 | + * Add a stable link when viewing old versions of an article that |
| 150 | + * have been reviewed. (e.g. for &oldid=x urls) |
151 | 151 | */ |
152 | | - public function setPageContent( &$outputDone, &$pcache ) { |
153 | | - global $wgRequest, $wgOut, $wgUser, $wgLang; |
154 | | - # Only trigger for reviewable pages |
155 | | - if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) { |
156 | | - return true; |
157 | | - } |
158 | | - # Only trigger on article view for content pages, not for protect/delete/hist... |
159 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
160 | | - if( ($action !='view' && $action !='purge') || !$this->parent->exists() ) |
161 | | - return true; |
162 | | - # Do not clutter up diffs any further... |
163 | | - if( $wgRequest->getVal('diff') ) { |
164 | | - return true; |
165 | | - } else if( $wgRequest->getVal('oldid') ) { |
| 152 | + public function addStableLink() { |
| 153 | + global $wgRequest, $wgOut, $wgLang; |
| 154 | + if( $wgRequest->getVal('oldid') ) { |
166 | 155 | # We may have nav links like "direction=prev&oldid=x" |
167 | 156 | $revID = $this->parent->getOldIDFromRequest(); |
168 | 157 | $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID ); |
— | — | @@ -183,8 +172,29 @@ |
184 | 173 | $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>"; |
185 | 174 | $wgOut->addHTML( $tag ); |
186 | 175 | } |
| 176 | + } |
| 177 | + return true; |
| 178 | + } |
| 179 | + |
| 180 | + /** |
| 181 | + * Replaces a page with the last stable version if possible |
| 182 | + * Adds stable version status/info tags and notes |
| 183 | + * Adds a quick review form on the bottom if needed |
| 184 | + */ |
| 185 | + public function setPageContent( &$outputDone, &$pcache ) { |
| 186 | + global $wgRequest, $wgOut, $wgUser, $wgLang; |
| 187 | + # Only trigger for reviewable pages |
| 188 | + if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) { |
187 | 189 | return true; |
188 | 190 | } |
| 191 | + # Only trigger on article view for content pages, not for protect/delete/hist... |
| 192 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 193 | + if( ($action !='view' && $action !='purge') || !$this->parent->exists() ) |
| 194 | + return true; |
| 195 | + # Do not clutter up diffs any further and leave archived versions alone... |
| 196 | + if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) { |
| 197 | + return true; |
| 198 | + } |
189 | 199 | $simpleTag = $old = $stable = false; |
190 | 200 | $tag = $notes = $pending = ''; |
191 | 201 | # Check the newest stable version. |
— | — | @@ -259,13 +269,13 @@ |
260 | 270 | $wgOut->addParserOutput( $parserOut ); |
261 | 271 | $wgOut->setRevisionId( $frev->getRevId() ); |
262 | 272 | $notes = $this->getReviewNotes( $frev ); |
| 273 | + # Index the stable version only |
| 274 | + $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
263 | 275 | # Tell MW that parser output is done |
264 | 276 | $outputDone = true; |
265 | 277 | $pcache = false; |
266 | | - // Looking at some specific old revision or if FlaggedRevs is not |
267 | | - // set to override given the relevant conditions. If the user is |
268 | | - // requesting the stable revision ("&stableid=x"), defer to override |
269 | | - // behavior below, since it is the same as ("&stable=1"). |
| 278 | + // Looking at some specific old revision (&oldid=x) or if FlaggedRevs is not |
| 279 | + // set to override given the relevant conditions (like &action=protect). |
270 | 280 | } else if( !$stable && !$this->pageOverride() ) { |
271 | 281 | $revsSince = FlaggedRevs::getRevCountSince( $this->parent, $frev->getRevId() ); |
272 | 282 | $synced = false; |
— | — | @@ -326,6 +336,8 @@ |
327 | 337 | } |
328 | 338 | } |
329 | 339 | } |
| 340 | + # Index the stable version only |
| 341 | + $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
330 | 342 | // The relevant conditions are met to override the page with the stable version. |
331 | 343 | } else { |
332 | 344 | # We will be looking at the reviewed revision... |
— | — | @@ -662,7 +674,7 @@ |
663 | 675 | return true; |
664 | 676 | |
665 | 677 | $action = $wgRequest->getVal( 'action', 'view' ); |
666 | | - if( $action=='protect' || $action=='unprotect' ) { |
| 678 | + if( $action == 'protect' || $action == 'unprotect' ) { |
667 | 679 | # Check for an overridabe revision |
668 | 680 | $frev = $this->getStableRev( true ); |
669 | 681 | if( !$frev ) |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -2013,6 +2013,7 @@ |
2014 | 2014 | static function onArticleViewHeader( $article, &$outputDone, &$pcache ) { |
2015 | 2015 | $flaggedArticle = FlaggedArticle::getInstance( $article ); |
2016 | 2016 | $flaggedArticle->maybeUpdateMainCache( $outputDone, $pcache ); |
| 2017 | + $flaggedArticle->addStableLink( $outputDone, $pcache ); |
2017 | 2018 | $flaggedArticle->setPageContent( $outputDone, $pcache ); |
2018 | 2019 | $flaggedArticle->addPatrolLink( $outputDone, $pcache ); |
2019 | 2020 | return true; |