Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Class representing a web view of a MediaWiki page |
5 | 5 | */ |
6 | | -class FlaggedPageView { |
| 6 | +class FlaggedPageView extends ContextSource { |
7 | 7 | protected $out = null; |
8 | 8 | protected $article = null; |
9 | 9 | |
— | — | @@ -50,8 +50,7 @@ |
51 | 51 | if ( $this->article == null ) { |
52 | 52 | throw new MWException( 'FlaggedPageView has no context article!' ); |
53 | 53 | } |
54 | | - // @TODO: store whole request context |
55 | | - $this->out = RequestContext::getMain()->getOutput(); |
| 54 | + $this->out = $this->getOutput(); // convenience |
56 | 55 | } |
57 | 56 | } |
58 | 57 | |
— | — | @@ -84,24 +83,25 @@ |
85 | 84 | * @return bool |
86 | 85 | */ |
87 | 86 | protected function showingStableAsDefault() { |
88 | | - global $wgUser, $wgRequest; |
| 87 | + $request = $this->getRequest(); |
| 88 | + $reqUser = $this->getUser(); |
89 | 89 | $this->load(); |
90 | 90 | # This only applies to viewing the default version of pages... |
91 | | - if ( !$this->isDefaultPageView( $wgRequest ) ) { |
| 91 | + if ( !$this->isDefaultPageView( $request ) ) { |
92 | 92 | return false; |
93 | 93 | # ...and the page must be reviewable and have a stable version |
94 | 94 | } elseif ( !$this->article->getStableRev() ) { |
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | # Check user preferences ("show stable by default?") |
98 | | - $pref = (int)$wgUser->getOption( 'flaggedrevsstable' ); |
| 98 | + $pref = (int)$reqUser->getOption( 'flaggedrevsstable' ); |
99 | 99 | if ( $pref == FR_SHOW_STABLE_ALWAYS ) { |
100 | 100 | return true; |
101 | 101 | } elseif ( $pref == FR_SHOW_STABLE_NEVER ) { |
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | # Viewer may be in a group that sees the draft by default |
105 | | - if ( $this->userViewsDraftByDefault( $wgUser ) ) { |
| 105 | + if ( $this->userViewsDraftByDefault( $reqUser ) ) { |
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | # Does the stable version override the draft? |
— | — | @@ -116,15 +116,15 @@ |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | 119 | protected function showingStableByRequest() { |
120 | | - global $wgRequest; |
| 120 | + $request = $this->getRequest(); |
121 | 121 | $this->load(); |
122 | 122 | # Are we explicity requesting the stable version? |
123 | | - if ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) { |
| 123 | + if ( $request->getIntOrNull( 'stable' ) === 1 ) { |
124 | 124 | # This only applies to viewing a version of the page... |
125 | | - if ( !$this->isPageView( $wgRequest ) ) { |
| 125 | + if ( !$this->isPageView( $request ) ) { |
126 | 126 | return false; |
127 | 127 | # ...with no version parameters other than ?stable=1... |
128 | | - } elseif ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'stableid' ) ) { |
| 128 | + } elseif ( $request->getVal( 'oldid' ) || $request->getVal( 'stableid' ) ) { |
129 | 129 | return false; // over-determined |
130 | 130 | # ...and the page must be reviewable and have a stable version |
131 | 131 | } elseif ( !$this->article->getStableRev() ) { |
— | — | @@ -150,8 +150,9 @@ |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | 153 | public function useSimpleUI() { |
154 | | - global $wgUser, $wgSimpleFlaggedRevsUI; |
155 | | - return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) ); |
| 154 | + global $wgSimpleFlaggedRevsUI; |
| 155 | + $reqUser = $this->getUser(); |
| 156 | + return $reqUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) ); |
156 | 157 | } |
157 | 158 | |
158 | 159 | /** |
— | — | @@ -245,9 +246,9 @@ |
246 | 247 | * have been reviewed. (e.g. for &oldid=x urls) |
247 | 248 | */ |
248 | 249 | public function addStableLink() { |
249 | | - global $wgRequest, $wgLang; |
| 250 | + $request = $this->getRequest(); |
250 | 251 | $this->load(); |
251 | | - if ( !$this->article->isReviewable() || !$wgRequest->getVal( 'oldid' ) ) { |
| 252 | + if ( !$this->article->isReviewable() || !$request->getVal( 'oldid' ) ) { |
252 | 253 | return true; |
253 | 254 | } |
254 | 255 | # We may have nav links like "direction=prev&oldid=x" |
— | — | @@ -255,7 +256,7 @@ |
256 | 257 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $revID ); |
257 | 258 | # Give a notice if this rev ID corresponds to a reviewed version... |
258 | 259 | if ( $frev ) { |
259 | | - $time = $wgLang->date( $frev->getTimestamp(), true ); |
| 260 | + $time = $this->getLang()->date( $frev->getTimestamp(), true ); |
260 | 261 | $flags = $frev->getTags(); |
261 | 262 | $quality = FlaggedRevs::isQuality( $flags ); |
262 | 263 | $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source'; |
— | — | @@ -278,8 +279,8 @@ |
279 | 280 | * @return mixed int/false/null |
280 | 281 | */ |
281 | 282 | protected function getRequestedStableId() { |
282 | | - global $wgRequest; |
283 | | - $reqId = $wgRequest->getVal( 'stableid' ); |
| 283 | + $request = $this->getRequest(); |
| 284 | + $reqId = $request->getVal( 'stableid' ); |
284 | 285 | if ( $reqId === "best" ) { |
285 | 286 | $reqId = $this->article->getBestFlaggedRevId(); |
286 | 287 | } |
— | — | @@ -292,10 +293,10 @@ |
293 | 294 | * Adds a quick review form on the bottom if needed |
294 | 295 | */ |
295 | 296 | public function setPageContent( &$outputDone, &$useParserCache ) { |
296 | | - global $wgRequest; |
| 297 | + $request = $this->getRequest(); |
297 | 298 | $this->load(); |
298 | 299 | # Only trigger on page views with no oldid=x param |
299 | | - if ( !$this->isPageView( $wgRequest ) || $wgRequest->getVal( 'oldid' ) ) { |
| 300 | + if ( !$this->isPageView( $request ) || $request->getVal( 'oldid' ) ) { |
300 | 301 | return true; |
301 | 302 | # Only trigger for reviewable pages that exist |
302 | 303 | } elseif ( !$this->article->exists() || !$this->article->isReviewable() ) { |
— | — | @@ -391,11 +392,11 @@ |
392 | 393 | * However, any URL with ?stableid=x should not be indexed (as with ?oldid=x). |
393 | 394 | */ |
394 | 395 | public function setRobotPolicy() { |
395 | | - global $wgRequest; |
| 396 | + $request = $this->getRequest(); |
396 | 397 | if ( $this->article->getStableRev() && $this->article->isStableShownByDefault() ) { |
397 | 398 | if ( $this->showingStable() ) { |
398 | 399 | return; // stable version - index this |
399 | | - } elseif ( !$wgRequest->getVal( 'stableid' ) |
| 400 | + } elseif ( !$request->getVal( 'stableid' ) |
400 | 401 | && $this->out->getRevisionId() == $this->article->getStable() |
401 | 402 | && $this->article->stableVersionIsSynced() ) |
402 | 403 | { |
— | — | @@ -439,13 +440,14 @@ |
440 | 441 | * @return void |
441 | 442 | */ |
442 | 443 | protected function showDraftVersion( FlaggedRevision $srev, &$tag, $prot ) { |
443 | | - global $wgUser, $wgLang, $wgRequest; |
| 444 | + $request = $this->getRequest(); |
| 445 | + $reqUser = $this->getUser(); |
444 | 446 | $this->load(); |
445 | 447 | if ( $this->out->isPrintable() ) { |
446 | 448 | return; // all this function does is add notices; don't show them |
447 | 449 | } |
448 | 450 | $flags = $srev->getTags(); |
449 | | - $time = $wgLang->date( $srev->getTimestamp(), true ); |
| 451 | + $time = $this->getLang()->date( $srev->getTimestamp(), true ); |
450 | 452 | # Get quality level |
451 | 453 | $quality = FlaggedRevs::isQuality( $flags ); |
452 | 454 | # Get stable version sync status |
— | — | @@ -463,10 +465,10 @@ |
464 | 466 | } |
465 | 467 | # Give a "your edit is pending" notice to newer users if |
466 | 468 | # an unreviewed edit was completed... |
467 | | - if ( $wgRequest->getVal( 'shownotice' ) |
468 | | - && $this->article->getUserText( Revision::RAW ) == $wgUser->getName() |
| 469 | + if ( $request->getVal( 'shownotice' ) |
| 470 | + && $this->article->getUserText( Revision::RAW ) == $reqUser->getName() |
469 | 471 | && $this->article->revsArePending() |
470 | | - && !$wgUser->isAllowed( 'review' ) ) |
| 472 | + && !$reqUser->isAllowed( 'review' ) ) |
471 | 473 | { |
472 | 474 | $revsSince = $this->article->getPendingRevCount(); |
473 | 475 | $pending = $prot; |
— | — | @@ -475,7 +477,7 @@ |
476 | 478 | } |
477 | 479 | $pending .= wfMsgExt( 'revreview-edited', |
478 | 480 | 'parseinline', $srev->getRevId(), $revsSince ); |
479 | | - $anchor = $wgRequest->getVal( 'fromsection' ); |
| 481 | + $anchor = $request->getVal( 'fromsection' ); |
480 | 482 | if ( $anchor != null ) { |
481 | 483 | $section = str_replace( '_', ' ', $anchor ); // prettify |
482 | 484 | $pending .= wfMsgExt( 'revreview-edited-section', 'parse', $anchor, $section ); |
— | — | @@ -490,7 +492,7 @@ |
491 | 493 | $revsSince = $this->article->getPendingRevCount(); |
492 | 494 | // Simple icon-based UI |
493 | 495 | if ( $this->useSimpleUI() ) { |
494 | | - if ( !$wgUser->getId() ) { |
| 496 | + if ( !$reqUser->getId() ) { |
495 | 497 | $msgHTML = ''; // Anons just see simple icons |
496 | 498 | } elseif ( $synced ) { |
497 | 499 | $msg = $quality |
— | — | @@ -551,10 +553,10 @@ |
552 | 554 | * @return ParserOutput |
553 | 555 | */ |
554 | 556 | protected function showOldReviewedVersion( FlaggedRevision $frev, &$tag, $prot ) { |
555 | | - global $wgUser, $wgLang; |
| 557 | + $reqUser = $this->getUser(); |
556 | 558 | $this->load(); |
557 | 559 | $flags = $frev->getTags(); |
558 | | - $time = $wgLang->date( $frev->getTimestamp(), true ); |
| 560 | + $time = $this->getLang()->date( $frev->getTimestamp(), true ); |
559 | 561 | # Set display revision ID |
560 | 562 | $this->out->setRevisionId( $frev->getRevId() ); |
561 | 563 | # Get quality level |
— | — | @@ -571,7 +573,7 @@ |
572 | 574 | $icon = FlaggedRevsXML::stableStatusIcon( $quality ); |
573 | 575 | } |
574 | 576 | $revsSince = $this->article->getPendingRevCount(); |
575 | | - if ( !$wgUser->getId() ) { |
| 577 | + if ( !$reqUser->getId() ) { |
576 | 578 | $msgHTML = ''; // Anons just see simple icons |
577 | 579 | } else { |
578 | 580 | $msg = $quality |
— | — | @@ -602,7 +604,7 @@ |
603 | 605 | |
604 | 606 | $text = $frev->getRevText(); |
605 | 607 | # Get the new stable parser output... |
606 | | - $pOpts = $this->article->makeParserOptions( $wgUser ); |
| 608 | + $pOpts = $this->article->makeParserOptions( $reqUser ); |
607 | 609 | $parserOut = FlaggedRevs::parseStableText( |
608 | 610 | $this->article->getTitle(), $text, $frev->getRevId(), $pOpts ); |
609 | 611 | |
— | — | @@ -629,10 +631,10 @@ |
630 | 632 | * @return ParserOutput |
631 | 633 | */ |
632 | 634 | protected function showStableVersion( FlaggedRevision $srev, &$tag, $prot ) { |
633 | | - global $wgLang, $wgUser; |
| 635 | + $reqUser = $this->getUser(); |
634 | 636 | $this->load(); |
635 | 637 | $flags = $srev->getTags(); |
636 | | - $time = $wgLang->date( $srev->getTimestamp(), true ); |
| 638 | + $time = $this->getLang()->date( $srev->getTimestamp(), true ); |
637 | 639 | # Set display revision ID |
638 | 640 | $this->out->setRevisionId( $srev->getRevId() ); |
639 | 641 | # Get quality level |
— | — | @@ -649,7 +651,7 @@ |
650 | 652 | if ( $this->showRatingIcon() ) { |
651 | 653 | $icon = FlaggedRevsXML::stableStatusIcon( $quality ); |
652 | 654 | } |
653 | | - if ( !$wgUser->getId() ) { |
| 655 | + if ( !$reqUser->getId() ) { |
654 | 656 | $msgHTML = ''; // Anons just see simple icons |
655 | 657 | } else { |
656 | 658 | $msg = $quality |
— | — | @@ -685,7 +687,7 @@ |
686 | 688 | } |
687 | 689 | |
688 | 690 | # Get parsed stable version and output HTML |
689 | | - $pOpts = $this->article->makeParserOptions( $wgUser ); |
| 691 | + $pOpts = $this->article->makeParserOptions( $reqUser ); |
690 | 692 | $parserCache = FRParserCacheStable::singleton(); |
691 | 693 | $parserOut = $parserCache->get( $this->article, $pOpts ); |
692 | 694 | |
— | — | @@ -754,9 +756,9 @@ |
755 | 757 | * @return string, the html line (either "" or "<diff toggle><diff div>") |
756 | 758 | */ |
757 | 759 | protected function getTopDiffToggle( FlaggedRevision $srev, $quality ) { |
758 | | - global $wgUser; |
| 760 | + $reqUser = $this->getUser(); |
759 | 761 | $this->load(); |
760 | | - if ( !$wgUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) { |
| 762 | + if ( !$reqUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) { |
761 | 763 | return false; // nothing to do here |
762 | 764 | } |
763 | 765 | # Diff should only show for the draft |
— | — | @@ -835,15 +837,15 @@ |
836 | 838 | * |
837 | 839 | * If no stable version is required, the reference parameters will not be set |
838 | 840 | * |
839 | | - * Depends on $wgRequest |
| 841 | + * Depends on $request |
840 | 842 | */ |
841 | 843 | public function imagePageFindFile( &$normalFile, &$displayFile ) { |
842 | | - global $wgRequest; |
| 844 | + $request = $this->getRequest(); |
843 | 845 | $this->load(); |
844 | 846 | # Determine timestamp. A reviewed version may have explicitly been requested... |
845 | 847 | $frev = null; |
846 | 848 | $time = false; |
847 | | - $reqId = $wgRequest->getVal( 'stableid' ); |
| 849 | + $reqId = $request->getVal( 'stableid' ); |
848 | 850 | if ( $reqId ) { |
849 | 851 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId ); |
850 | 852 | } elseif ( $this->showingStable() ) { |
— | — | @@ -867,7 +869,7 @@ |
868 | 870 | } |
869 | 871 | if ( !$time ) { |
870 | 872 | # Try request parameter |
871 | | - $time = $wgRequest->getVal( 'filetimestamp', false ); |
| 873 | + $time = $request->getVal( 'filetimestamp', false ); |
872 | 874 | } |
873 | 875 | |
874 | 876 | if ( !$time ) { |
— | — | @@ -913,7 +915,8 @@ |
914 | 916 | * Adds stable version tags to page when editing |
915 | 917 | */ |
916 | 918 | public function addToEditView( EditPage $editPage ) { |
917 | | - global $wgUser, $wgParser; |
| 919 | + global $wgParser; |
| 920 | + $reqUser = $this->getUser(); |
918 | 921 | $this->load(); |
919 | 922 | # Must be reviewable. UI may be limited to unobtrusive patrolling system. |
920 | 923 | if ( !$this->article->isReviewable() ) { |
— | — | @@ -932,7 +935,7 @@ |
933 | 936 | $revId = $editPage->oldid ? $editPage->oldid : $latestId; |
934 | 937 | # Let new users know about review procedure a tag. |
935 | 938 | # If the log excerpt was shown this is redundant. |
936 | | - if ( !$log && !$wgUser->getId() && $this->article->isStableShownByDefault() ) { |
| 939 | + if ( !$log && !$reqUser->getId() && $this->article->isStableShownByDefault() ) { |
937 | 940 | $items[] = wfMsgExt( 'revreview-editnotice', 'parseinline' ); |
938 | 941 | } |
939 | 942 | # Add a notice if there are pending edits... |
— | — | @@ -943,7 +946,7 @@ |
944 | 947 | # Show diff to stable, to make things less confusing. |
945 | 948 | # This can be disabled via user preferences and other conditions... |
946 | 949 | if ( $frev->getRevId() < $latestId // changes were made |
947 | | - && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs |
| 950 | + && $reqUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs |
948 | 951 | && $revId == $latestId // only for current rev |
949 | 952 | && $editPage->section != 'new' // not for new sections |
950 | 953 | && $editPage->formtype != 'diff' // not "show changes" |
— | — | @@ -1030,9 +1033,9 @@ |
1031 | 1034 | * Add unreviewed pages links |
1032 | 1035 | */ |
1033 | 1036 | public function addToCategoryView() { |
1034 | | - global $wgUser; |
| 1037 | + $reqUser = $this->getUser(); |
1035 | 1038 | $this->load(); |
1036 | | - if ( !$wgUser->isAllowed( 'review' ) ) { |
| 1039 | + if ( !$reqUser->isAllowed( 'review' ) ) { |
1037 | 1040 | return true; |
1038 | 1041 | } |
1039 | 1042 | if ( !FlaggedRevs::useOnlyIfProtected() ) { |
— | — | @@ -1056,13 +1059,14 @@ |
1057 | 1060 | * @param mixed string|OutputPage |
1058 | 1061 | */ |
1059 | 1062 | public function addReviewForm( &$output ) { |
1060 | | - global $wgRequest, $wgUser; |
| 1063 | + $request = $this->getRequest(); |
| 1064 | + $reqUser = $this->getUser(); |
1061 | 1065 | $this->load(); |
1062 | 1066 | if ( $this->out->isPrintable() ) { |
1063 | 1067 | return false; // Must be on non-printable output |
1064 | 1068 | } |
1065 | 1069 | # User must have review rights |
1066 | | - if ( !$wgUser->isAllowed( 'review' ) ) { |
| 1070 | + if ( !$reqUser->isAllowed( 'review' ) ) { |
1067 | 1071 | return true; |
1068 | 1072 | } |
1069 | 1073 | # Page must exist and be reviewable |
— | — | @@ -1070,7 +1074,7 @@ |
1071 | 1075 | return true; |
1072 | 1076 | } |
1073 | 1077 | # Must be a page view action... |
1074 | | - if ( !$this->isPageViewOrDiff( $wgRequest ) ) { |
| 1078 | + if ( !$this->isPageViewOrDiff( $request ) ) { |
1075 | 1079 | return true; |
1076 | 1080 | } |
1077 | 1081 | # Get the revision being displayed |
— | — | @@ -1082,7 +1086,7 @@ |
1083 | 1087 | } |
1084 | 1088 | # Build the review form as needed |
1085 | 1089 | if ( $rev && ( !$this->diffRevs || $this->isReviewableDiff ) ) { |
1086 | | - $form = new RevisionReviewFormUI( $wgUser, $this->article, $rev ); |
| 1090 | + $form = new RevisionReviewFormUI( $reqUser, $this->article, $rev ); |
1087 | 1091 | # Default tags and existence of "reject" button depend on context |
1088 | 1092 | if ( $this->diffRevs ) { |
1089 | 1093 | $form->setDiffPriorRev( $this->diffRevs['old'] ); |
— | — | @@ -1107,7 +1111,7 @@ |
1108 | 1112 | # $wgOut may not already have the inclusion IDs, such as for diffonly=1. |
1109 | 1113 | # RevisionReviewForm will fetch them as needed however. |
1110 | 1114 | list( $tmpVers, $fileVers ) = |
1111 | | - FRInclusionCache::getRevIncludes( $this->article, $rev, $wgUser ); |
| 1115 | + FRInclusionCache::getRevIncludes( $this->article, $rev, $reqUser ); |
1112 | 1116 | } |
1113 | 1117 | $form->setIncludeVersions( $tmpVers, $fileVers ); |
1114 | 1118 | |
— | — | @@ -1127,7 +1131,7 @@ |
1128 | 1132 | * Add link to stable version setting to protection form |
1129 | 1133 | */ |
1130 | 1134 | public function addStabilizationLink() { |
1131 | | - global $wgRequest; |
| 1135 | + $request = $this->getRequest(); |
1132 | 1136 | $this->load(); |
1133 | 1137 | if ( FlaggedRevs::useProtectionLevels() ) { |
1134 | 1138 | return true; // simple custom levels set for action=protect |
— | — | @@ -1136,7 +1140,7 @@ |
1137 | 1141 | if ( !FlaggedRevs::inReviewNamespace( $this->article->getTitle() ) ) { |
1138 | 1142 | return true; |
1139 | 1143 | } |
1140 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
| 1144 | + $action = $request->getVal( 'action', 'view' ); |
1141 | 1145 | if ( $action == 'protect' || $action == 'unprotect' ) { |
1142 | 1146 | $title = SpecialPage::getTitleFor( 'Stabilization' ); |
1143 | 1147 | # Give a link to the page to configure the stable version |
— | — | @@ -1163,7 +1167,7 @@ |
1164 | 1168 | * SkinTemplateTabs, to inlude flagged revs UI elements |
1165 | 1169 | */ |
1166 | 1170 | public function setActionTabs( $skin, array &$actions ) { |
1167 | | - global $wgUser; |
| 1171 | + $reqUser = $this->getUser(); |
1168 | 1172 | $this->load(); |
1169 | 1173 | if ( FlaggedRevs::useProtectionLevels() ) { |
1170 | 1174 | return true; // simple custom levels set for action=protect |
— | — | @@ -1178,7 +1182,7 @@ |
1179 | 1183 | is_array( $actions ) && |
1180 | 1184 | !isset( $actions['protect'] ) && |
1181 | 1185 | !isset( $actions['unprotect'] ) && |
1182 | | - $wgUser->isAllowed( 'stablesettings' ) && |
| 1186 | + $reqUser->isAllowed( 'stablesettings' ) && |
1183 | 1187 | $title->exists() ) |
1184 | 1188 | { |
1185 | 1189 | $stableTitle = SpecialPage::getTitleFor( 'Stabilization' ); |
— | — | @@ -1231,7 +1235,7 @@ |
1232 | 1236 | |
1233 | 1237 | // Add "pending changes" tab and set tab selection CSS |
1234 | 1238 | protected function addDraftTab( array &$views, FlaggedRevision $srev, $type ) { |
1235 | | - global $wgRequest; |
| 1239 | + $request = $this->getRequest(); |
1236 | 1240 | $title = $this->article->getTitle(); // convenience |
1237 | 1241 | $tabs = array( |
1238 | 1242 | 'read' => array( // view stable |
— | — | @@ -1246,10 +1250,10 @@ |
1247 | 1251 | ), |
1248 | 1252 | ); |
1249 | 1253 | // Set tab selection CSS |
1250 | | - if ( $this->showingStable() || $wgRequest->getVal( 'stableid' ) ) { |
| 1254 | + if ( $this->showingStable() || $request->getVal( 'stableid' ) ) { |
1251 | 1255 | // We are looking a the stable version or an old reviewed one |
1252 | 1256 | $tabs['read']['class'] = 'selected'; |
1253 | | - } elseif ( $this->isPageViewOrDiff( $wgRequest ) ) { |
| 1257 | + } elseif ( $this->isPageViewOrDiff( $request ) ) { |
1254 | 1258 | $ts = null; |
1255 | 1259 | if ( $this->out->getRevisionId() ) { // @TODO: avoid same query in Skin.php |
1256 | 1260 | $ts = ( $this->out->getRevisionId() == $this->article->getLatest() ) |
— | — | @@ -1316,12 +1320,12 @@ |
1317 | 1321 | * @return bool |
1318 | 1322 | */ |
1319 | 1323 | protected function pageWriteOpRequested() { |
1320 | | - global $wgRequest; |
| 1324 | + $request = $this->getRequest(); |
1321 | 1325 | # Hack for bug 16734 (some actions update and view all at once) |
1322 | | - $action = $wgRequest->getVal( 'action' ); |
| 1326 | + $action = $request->getVal( 'action' ); |
1323 | 1327 | if ( $action === 'rollback' ) { |
1324 | 1328 | return true; |
1325 | | - } elseif ( $action === 'delete' && $wgRequest->wasPosted() ) { |
| 1329 | + } elseif ( $action === 'delete' && $request->wasPosted() ) { |
1326 | 1330 | return true; |
1327 | 1331 | } |
1328 | 1332 | return false; |
— | — | @@ -1339,9 +1343,8 @@ |
1340 | 1344 | * @return void |
1341 | 1345 | */ |
1342 | 1346 | public function setPendingNotice( FlaggedRevision $srev, $diffToggle = '' ) { |
1343 | | - global $wgLang; |
1344 | 1347 | $this->load(); |
1345 | | - $time = $wgLang->date( $srev->getTimestamp(), true ); |
| 1348 | + $time = $this->getLang()->date( $srev->getTimestamp(), true ); |
1346 | 1349 | $revsSince = $this->article->getPendingRevCount(); |
1347 | 1350 | $msg = $srev->getQuality() |
1348 | 1351 | ? 'revreview-newest-quality' |
— | — | @@ -1363,7 +1366,9 @@ |
1364 | 1367 | * (ii) List any template/file changes pending review |
1365 | 1368 | */ |
1366 | 1369 | public function addToDiffView( $diff, $oldRev, $newRev ) { |
1367 | | - global $wgRequest, $wgUser, $wgMemc, $wgParserCacheExpireTime; |
| 1370 | + global $wgMemc, $wgParserCacheExpireTime; |
| 1371 | + $request = $this->getRequest(); |
| 1372 | + $reqUser = $this->getUser(); |
1368 | 1373 | $this->load(); |
1369 | 1374 | # Exempt printer-friendly output |
1370 | 1375 | if ( $this->out->isPrintable() ) { |
— | — | @@ -1400,7 +1405,7 @@ |
1401 | 1406 | } |
1402 | 1407 | # Otherwise, check for includes pending on top of edits pending... |
1403 | 1408 | } else { |
1404 | | - $incs = FRInclusionCache::getRevIncludes( $this->article, $newRev, $wgUser ); |
| 1409 | + $incs = FRInclusionCache::getRevIncludes( $this->article, $newRev, $reqUser ); |
1405 | 1410 | $this->oldRevIncludes = $incs; // process cache |
1406 | 1411 | # Add a list of links to each changed template... |
1407 | 1412 | $changeList = self::fetchTemplateChanges( $srev, $incs[0] ); |
— | — | @@ -1410,11 +1415,11 @@ |
1411 | 1416 | # If there are pending revs or templates/files changes, notify the user... |
1412 | 1417 | if ( $this->article->revsArePending() || count( $changeList ) ) { |
1413 | 1418 | # If the user can review then prompt them to review them... |
1414 | | - if ( $wgUser->isAllowed( 'review' ) ) { |
| 1419 | + if ( $reqUser->isAllowed( 'review' ) ) { |
1415 | 1420 | // Reviewer just edited... |
1416 | | - if ( $wgRequest->getInt( 'shownotice' ) |
| 1421 | + if ( $request->getInt( 'shownotice' ) |
1417 | 1422 | && $newRev->isCurrent() |
1418 | | - && $newRev->getRawUserText() == $wgUser->getName() ) |
| 1423 | + && $newRev->getRawUserText() == $reqUser->getName() ) |
1419 | 1424 | { |
1420 | 1425 | $title = $this->article->getTitle(); // convenience |
1421 | 1426 | // @TODO: make diff class cache this |
— | — | @@ -1439,7 +1444,7 @@ |
1440 | 1445 | } |
1441 | 1446 | # template/file change list |
1442 | 1447 | if ( $changeText != '' ) { |
1443 | | - if ( $wgUser->isAllowed( 'review' ) ) { |
| 1448 | + if ( $reqUser->isAllowed( 'review' ) ) { |
1444 | 1449 | $this->diffIncChangeBox = "<p>$changeText</p>"; |
1445 | 1450 | } else { |
1446 | 1451 | $css = 'flaggedrevs_diffnotice plainlinks'; |
— | — | @@ -1498,7 +1503,7 @@ |
1499 | 1504 | protected static function diffToStableLink( |
1500 | 1505 | FlaggedPage $article, $oldRev, Revision $newRev |
1501 | 1506 | ) { |
1502 | | - global $wgUser; |
| 1507 | + $reqUser = $this->getUser(); |
1503 | 1508 | $srev = $article->getStableRev(); |
1504 | 1509 | if ( !$srev ) { |
1505 | 1510 | return ''; // nothing to do |
— | — | @@ -1510,7 +1515,7 @@ |
1511 | 1516 | # Make a link to the full diff-to-stable if: |
1512 | 1517 | # (a) Actual revs are pending and (b) We are not viewing the full diff-to-stable |
1513 | 1518 | if ( $article->revsArePending() && !$fullStableDiff ) { |
1514 | | - $review = $wgUser->getSkin()->linkKnown( |
| 1519 | + $review = $reqUser->getSkin()->linkKnown( |
1515 | 1520 | $article->getTitle(), |
1516 | 1521 | wfMsgHtml( 'review-diff2stable' ), |
1517 | 1522 | array(), |
— | — | @@ -1573,8 +1578,8 @@ |
1574 | 1579 | // Fetch template changes for a reviewed revision since review |
1575 | 1580 | // @return array |
1576 | 1581 | protected static function fetchTemplateChanges( FlaggedRevision $frev, $newTemplates = null ) { |
1577 | | - global $wgUser; |
1578 | | - $skin = $wgUser->getSkin(); |
| 1582 | + $reqUser = $this->getUser(); |
| 1583 | + $skin = $reqUser->getSkin(); |
1579 | 1584 | $diffLinks = array(); |
1580 | 1585 | if ( $newTemplates === null ) { |
1581 | 1586 | $changes = $frev->findPendingTemplateChanges(); |
— | — | @@ -1599,8 +1604,8 @@ |
1600 | 1605 | // Fetch file changes for a reviewed revision since review |
1601 | 1606 | // @return array |
1602 | 1607 | protected static function fetchFileChanges( FlaggedRevision $frev, $newFiles = null ) { |
1603 | | - global $wgUser; |
1604 | | - $skin = $wgUser->getSkin(); |
| 1608 | + $reqUser = $this->getUser(); |
| 1609 | + $skin = $reqUser->getSkin(); |
1605 | 1610 | $diffLinks = array(); |
1606 | 1611 | if ( $newFiles === null ) { |
1607 | 1612 | $changes = $frev->findPendingFileChanges( 'noForeign' ); |
— | — | @@ -1664,7 +1669,7 @@ |
1665 | 1670 | * Only for people who can review and for pages that have a stable version. |
1666 | 1671 | */ |
1667 | 1672 | public function injectPostEditURLParams( &$sectionAnchor, &$extraQuery ) { |
1668 | | - global $wgUser; |
| 1673 | + $reqUser = $this->getUser(); |
1669 | 1674 | $this->load(); |
1670 | 1675 | $this->article->loadPageData( 'fromdbmaster' ); |
1671 | 1676 | # Get the stable version from the master |
— | — | @@ -1675,7 +1680,7 @@ |
1676 | 1681 | $params = array(); |
1677 | 1682 | // If the edit was not autoreviewed, and the user can actually make a |
1678 | 1683 | // new stable version, then go to the diff... |
1679 | | - if ( $frev->userCanSetFlags( $wgUser ) ) { |
| 1684 | + if ( $frev->userCanSetFlags( $reqUser ) ) { |
1680 | 1685 | $params += array( 'oldid' => $frev->getRevId(), 'diff' => 'cur', 'shownotice' => 1 ); |
1681 | 1686 | $params += FlaggedRevs::diffOnlyCGI(); |
1682 | 1687 | // ...otherwise, go to the draft revision after completing an edit. |
— | — | @@ -1683,7 +1688,7 @@ |
1684 | 1689 | } else { |
1685 | 1690 | $params += array( 'stable' => 0 ); |
1686 | 1691 | // Show a notice at the top of the page for non-reviewers... |
1687 | | - if ( !$wgUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) { |
| 1692 | + if ( !$reqUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) { |
1688 | 1693 | $params += array( 'shownotice' => 1 ); |
1689 | 1694 | if ( $sectionAnchor ) { |
1690 | 1695 | // Pass a section parameter in the URL as needed to add a link to |
— | — | @@ -1737,11 +1742,11 @@ |
1738 | 1743 | * @return bool |
1739 | 1744 | */ |
1740 | 1745 | protected function editWillRequireReview( EditPage $editPage ) { |
1741 | | - global $wgRequest; |
| 1746 | + $request = $this->getRequest(); |
1742 | 1747 | $title = $this->article->getTitle(); // convenience |
1743 | 1748 | if ( !$this->editRequiresReview( $editPage ) ) { |
1744 | 1749 | return false; // edit will go live immediatly |
1745 | | - } elseif ( $wgRequest->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) { |
| 1750 | + } elseif ( $request->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) { |
1746 | 1751 | return false; // edit checked off to be reviewed on save |
1747 | 1752 | } |
1748 | 1753 | return true; // edit needs review |
— | — | @@ -1793,7 +1798,7 @@ |
1794 | 1799 | * (b) this is an unreviewed page (bug 23970) |
1795 | 1800 | */ |
1796 | 1801 | public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) { |
1797 | | - global $wgRequest; |
| 1802 | + $request = $this->getRequest(); |
1798 | 1803 | $title = $this->article->getTitle(); // convenience |
1799 | 1804 | if ( !$this->article->isReviewable() || !$title->userCan( 'review' ) ) { |
1800 | 1805 | return true; // not needed |
— | — | @@ -1807,7 +1812,7 @@ |
1808 | 1813 | # Note: check not shown when editing old revisions, which is confusing. |
1809 | 1814 | $checkbox = Xml::check( |
1810 | 1815 | 'wpReviewEdit', |
1811 | | - $wgRequest->getCheck( 'wpReviewEdit' ), |
| 1816 | + $request->getCheck( 'wpReviewEdit' ), |
1812 | 1817 | array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' ) |
1813 | 1818 | ); |
1814 | 1819 | $attribs = array( 'for' => 'wpReviewEdit' ); |
— | — | @@ -1856,17 +1861,17 @@ |
1857 | 1862 | * @return int |
1858 | 1863 | */ |
1859 | 1864 | protected static function getBaseRevId( EditPage $editPage ) { |
1860 | | - global $wgRequest; |
| 1865 | + $request = $this->getRequest(); |
1861 | 1866 | if ( !isset( $editPage->fr_baseRevId ) ) { |
1862 | 1867 | $article = $editPage->getArticle(); // convenience |
1863 | 1868 | $latestId = $article->getLatest(); // current rev |
1864 | | - $undo = $wgRequest->getIntOrNull( 'undo' ); |
| 1869 | + $undo = $request->getIntOrNull( 'undo' ); |
1865 | 1870 | # Undoing consecutive top edits... |
1866 | 1871 | if ( $undo && $undo === $latestId ) { |
1867 | 1872 | # Treat this like a revert to a base revision. |
1868 | 1873 | # We are undoing all edits *after* some rev ID (undoafter). |
1869 | 1874 | # If undoafter is not given, then it is the previous rev ID. |
1870 | | - $revId = $wgRequest->getInt( 'undoafter', |
| 1875 | + $revId = $request->getInt( 'undoafter', |
1871 | 1876 | $article->getTitle()->getPreviousRevisionID( $latestId, Title::GAID_FOR_UPDATE ) ); |
1872 | 1877 | # Undoing other edits... |
1873 | 1878 | } elseif ( $undo ) { |
— | — | @@ -1877,7 +1882,7 @@ |
1878 | 1883 | # Otherwise, check if the client specified the ID (bug 23098). |
1879 | 1884 | $revId = $article->getOldID() |
1880 | 1885 | ? $article->getOldID() |
1881 | | - : $wgRequest->getInt( 'baseRevId' ); // e.g. "show changes"/"preview" |
| 1886 | + : $request->getInt( 'baseRevId' ); // e.g. "show changes"/"preview" |
1882 | 1887 | } |
1883 | 1888 | # Zero oldid => draft revision |
1884 | 1889 | if ( !$revId ) { |