Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -160,6 +160,18 @@ |
161 | 161 | } |
162 | 162 | return true; |
163 | 163 | } |
| 164 | + |
| 165 | + /** |
| 166 | + * @returns mixed int/false/null |
| 167 | + */ |
| 168 | + protected function getRequestedStableId() { |
| 169 | + global $wgRequest; |
| 170 | + $reqId = $wgRequest->getVal('stableid'); |
| 171 | + if( $reqId === "best" ) { |
| 172 | + $reqId = FlaggedRevs::getPrimeFlaggedRevId( $this->article ); |
| 173 | + } |
| 174 | + return $reqId; |
| 175 | + } |
164 | 176 | |
165 | 177 | /** |
166 | 178 | * Replaces a page with the last stable version if possible |
— | — | @@ -184,31 +196,35 @@ |
185 | 197 | $simpleTag = $old = $stable = false; |
186 | 198 | $tag = $prot = ''; |
187 | 199 | # Check the newest stable version. |
188 | | - $frev = $srev = $this->article->getStableRev(); |
189 | | - $stableId = $frev ? $frev->getRevId() : 0; |
190 | | - # Also, check for any explicitly requested old stable version... |
191 | | - $reqId = $wgRequest->getVal('stableid'); |
192 | | - if( $reqId === "best" ) { |
193 | | - $reqId = FlaggedRevs::getPrimeFlaggedRevId( $this->article ); |
194 | | - } |
195 | | - if( $stableId && $reqId ) { |
| 200 | + $srev = $this->article->getStableRev(); |
| 201 | + $stableId = $srev ? $srev->getRevId() : 0; |
| 202 | + $frev = $srev; // $frev is the revision we are looking at |
| 203 | + # Check for any explicitly requested old stable version... |
| 204 | + $reqId = $this->getRequestedStableId(); |
| 205 | + if( $reqId ) { |
| 206 | + if( !$stableId ) { |
| 207 | + $reqId = false; // must be invalid |
196 | 208 | # Treat requesting the stable version by ID as &stable=1 |
197 | | - if( $reqId != $stableId ) { |
| 209 | + } else if( $reqId != $stableId ) { |
| 210 | + $old = true; // old reviewed version requested by ID |
198 | 211 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), |
199 | 212 | $reqId, FR_TEXT ); |
200 | | - $old = true; // old reviewed version requested by ID |
201 | 213 | if( !$frev ) { |
202 | | - $wgOut->addWikiText( wfMsg('revreview-invalid') ); |
203 | | - $wgOut->returnToMain( false, $this->article->getTitle() ); |
204 | | - # Tell MW that parser output is done |
205 | | - $outputDone = true; |
206 | | - $pcache = false; |
207 | | - return true; |
| 214 | + $reqId = false; // invalid ID given |
208 | 215 | } |
209 | 216 | } else { |
210 | 217 | $stable = true; // stable version requested by ID |
211 | 218 | } |
212 | 219 | } |
| 220 | + // $reqId is null if nothing requested, false if invalid |
| 221 | + if( $reqId === false ) { |
| 222 | + $wgOut->addWikiText( wfMsg('revreview-invalid') ); |
| 223 | + $wgOut->returnToMain( false, $this->article->getTitle() ); |
| 224 | + # Tell MW that parser output is done |
| 225 | + $outputDone = true; |
| 226 | + $pcache = false; |
| 227 | + return true; |
| 228 | + } |
213 | 229 | // Is the page config altered? |
214 | 230 | if( $this->article->isPageLocked() ) { |
215 | 231 | $prot = "<span class='fr-icon-locked' title=\"". |
— | — | @@ -217,28 +233,10 @@ |
218 | 234 | $prot = "<span class='fr-icon-unlocked' title=\"". |
219 | 235 | wfMsgHtml('revreview-unlocked-title')."\"></span>"; |
220 | 236 | } |
221 | | - // RTL langauges |
222 | | - $rtl = $wgContLang->isRTL() ? " rtl" : ""; |
223 | 237 | // Is there no stable version? |
224 | 238 | if( is_null($frev) ) { |
225 | | - // Add "no reviewed version" tag, but not for printable output. |
226 | | - if( !$wgOut->isPrintable() ) { |
227 | | - // Simple icon-based UI |
228 | | - if( FlaggedRevs::useSimpleUI() ) { |
229 | | - $msg = $old ? 'revreview-quick-invalid' : 'revreview-quick-none'; |
230 | | - $tag .= "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
231 | | - wfMsgExt($msg,array('parseinline')); |
232 | | - $tag = "<div id='mw-revisiontag' class='flaggedrevs_short{$rtl} plainlinks noprint'>$tag</div>"; |
233 | | - $this->reviewNotice .= $tag; |
234 | | - // Standard UI |
235 | | - } else { |
236 | | - $msg = $old ? 'revreview-invalid' : 'revreview-noflagged'; |
237 | | - $tag = "<div id='mw-revisiontag' class='flaggedrevs_notice plainlinks noprint'>" . |
238 | | - "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
239 | | - wfMsgExt($msg, array('parseinline')) . "</div>"; |
240 | | - $this->reviewNotice .= $tag; |
241 | | - } |
242 | | - } |
| 239 | + # Add "no reviewed version" tag, but not for printable output |
| 240 | + $this->showUnreviewedPage( $tag, $prot ); |
243 | 241 | # Show notice bar/icon |
244 | 242 | $this->displayTag(); |
245 | 243 | return true; |
— | — | @@ -267,7 +265,7 @@ |
268 | 266 | // set to override given the relevant conditions (like &stable=0) or there |
269 | 267 | // is no stable version. |
270 | 268 | } else { |
271 | | - $this->showRegularVersion( $srev, $tag, $prot ); |
| 269 | + $this->showDraftVersion( $srev, $tag, $prot ); |
272 | 270 | } |
273 | 271 | # Some checks for which tag CSS to use |
274 | 272 | if( FlaggedRevs::useSimpleUI() ) $tagClass = 'flaggedrevs_short'; |
— | — | @@ -277,7 +275,9 @@ |
278 | 276 | else $tagClass = 'flaggedrevs_basic'; |
279 | 277 | # Wrap tag contents in a div |
280 | 278 | if( $tag != '' ) { |
281 | | - $tag = "<div id='mw-revisiontag' class='{$tagClass}{$rtl} plainlinks noprint'>$tag</div>"; |
| 279 | + $rtl = $wgContLang->isRTL() ? " rtl" : ""; // RTL langauges |
| 280 | + $tag = "<div id='mw-revisiontag' class='{$tagClass}{$rtl} plainlinks noprint'>" . |
| 281 | + "$tag</div>"; |
282 | 282 | $this->reviewNotice .= $tag; |
283 | 283 | } |
284 | 284 | # Show notice bar/icon |
— | — | @@ -285,6 +285,34 @@ |
286 | 286 | |
287 | 287 | return true; |
288 | 288 | } |
| 289 | + |
| 290 | + /** |
| 291 | + * @param $tag review box/bar info |
| 292 | + * @param $prot protection notice |
| 293 | + * Tag output function must be called by caller |
| 294 | + */ |
| 295 | + protected function showUnreviewedPage( $tag, $prot ) { |
| 296 | + global $wgOut, $wgContLang; |
| 297 | + if( $wgOut->isPrintable() ) |
| 298 | + return; |
| 299 | + // Simple icon-based UI |
| 300 | + if( FlaggedRevs::useSimpleUI() ) { |
| 301 | + // RTL langauges |
| 302 | + $rtl = $wgContLang->isRTL() ? " rtl" : ""; |
| 303 | + $msg = 'revreview-quick-none'; |
| 304 | + $tag .= "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
| 305 | + wfMsgExt($msg,array('parseinline')); |
| 306 | + $tag = "<div id='mw-revisiontag' class='flaggedrevs_short{$rtl} plainlinks noprint'>$tag</div>"; |
| 307 | + $this->reviewNotice .= $tag; |
| 308 | + // Standard UI |
| 309 | + } else { |
| 310 | + $msg = 'revreview-noflagged'; |
| 311 | + $tag = "<div id='mw-revisiontag' class='flaggedrevs_notice plainlinks noprint'>" . |
| 312 | + "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
| 313 | + wfMsgExt($msg, array('parseinline')) . "</div>"; |
| 314 | + $this->reviewNotice .= $tag; |
| 315 | + } |
| 316 | + } |
289 | 317 | |
290 | 318 | /** |
291 | 319 | * @param $srev stable version |
— | — | @@ -293,7 +321,7 @@ |
294 | 322 | * Tag output function must be called by caller |
295 | 323 | * Parser cache control deferred to caller |
296 | 324 | */ |
297 | | - protected function showRegularVersion( $srev, &$tag, $prot ) { |
| 325 | + protected function showDraftVersion( $srev, &$tag, $prot ) { |
298 | 326 | global $wgUser, $wgOut, $wgLang, $wgRequest; |
299 | 327 | $this->load(); |
300 | 328 | $flags = $srev->getTags(); |