Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php |
— | — | @@ -101,7 +101,15 @@ |
102 | 102 | public static function onBeforePageDisplay( &$out, &$skin ) { |
103 | 103 | if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) { |
104 | 104 | $view = FlaggedPageView::singleton(); |
| 105 | + $view->addStabilizationLink(); // link on protect form |
105 | 106 | $view->displayTag(); // show notice bar/icon in subtitle |
| 107 | + if ( $out->isArticleRelated() ) { |
| 108 | + // Only use this hook if we want to prepend the form. |
| 109 | + // We prepend the form for diffs, so only handle that case here. |
| 110 | + if ( $view->diffRevsAreSet() ) { |
| 111 | + $view->addReviewForm( $out ); // form to be prepended |
| 112 | + } |
| 113 | + } |
106 | 114 | $view->setRobotPolicy(); // set indexing policy |
107 | 115 | self::injectStyleAndJS(); // full CSS/JS |
108 | 116 | } else { |
— | — | @@ -323,9 +331,11 @@ |
324 | 332 | && FlaggedPageView::globalArticleInstance() != null ) |
325 | 333 | { |
326 | 334 | $view = FlaggedPageView::singleton(); |
327 | | - $view->addReviewNotes( $data ); |
328 | | - $view->addReviewForm( $data ); |
329 | | - $view->addStabilizationLink( $data ); |
| 335 | + // Only use this hook if we want to append the form. |
| 336 | + // We *prepend* the form for diffs, so skip that case here. |
| 337 | + if ( !$view->diffRevsAreSet() ) { |
| 338 | + $view->addReviewForm( $data ); // form to be appended |
| 339 | + } |
330 | 340 | } |
331 | 341 | return true; |
332 | 342 | } |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php |
— | — | @@ -12,7 +12,6 @@ |
13 | 13 | protected $isDiffFromStable = false; |
14 | 14 | protected $isMultiPageDiff = false; |
15 | 15 | protected $reviewNotice = ''; |
16 | | - protected $reviewNotes = ''; |
17 | 16 | protected $diffNoticeBox = ''; |
18 | 17 | protected $reviewFormRev = false; |
19 | 18 | |
— | — | @@ -44,20 +43,20 @@ |
45 | 44 | * Load the global FlaggedPage instance |
46 | 45 | */ |
47 | 46 | protected function load() { |
48 | | - global $wgOut; |
49 | 47 | if ( !$this->loaded ) { |
50 | 48 | $this->loaded = true; |
51 | 49 | $this->article = self::globalArticleInstance(); |
52 | 50 | if ( $this->article == null ) { |
53 | 51 | throw new MWException( 'FlaggedPageView has no context article!' ); |
54 | 52 | } |
55 | | - $this->out = $wgOut; |
| 53 | + $this->out = RequestContext::getMain()->getOutput(); |
56 | 54 | } |
57 | 55 | } |
58 | 56 | |
59 | 57 | /** |
60 | 58 | * Get the FlaggedPage instance associated with $wgTitle, |
61 | 59 | * or false if there isn't such a title |
| 60 | + * @return FlaggedPage|null |
62 | 61 | */ |
63 | 62 | public static function globalArticleInstance() { |
64 | 63 | $title = RequestContext::getMain()->getTitle(); |
— | — | @@ -67,6 +66,14 @@ |
68 | 67 | return null; |
69 | 68 | } |
70 | 69 | |
| 70 | + /* |
| 71 | + * Check if the old and new diff revs are set for this page view |
| 72 | + * @return bool |
| 73 | + */ |
| 74 | + public function diffRevsAreSet() { |
| 75 | + return (bool)$this->diffRevs; |
| 76 | + } |
| 77 | + |
71 | 78 | /** |
72 | 79 | * Is this web response for a request to view a page where both: |
73 | 80 | * (a) no specific page version was requested via URL params |
— | — | @@ -1048,10 +1055,12 @@ |
1049 | 1056 | } |
1050 | 1057 | |
1051 | 1058 | /** |
1052 | | - * Add review form to pages when necessary |
1053 | | - * on a regular page view (action=view) |
| 1059 | + * Add review form to pages when necessary on a regular page view (action=view). |
| 1060 | + * If $output is an OutputPage then this prepends the form onto it. |
| 1061 | + * If $output is a string then this appends the review form to it. |
| 1062 | + * @param mixed string|OutputPage |
1054 | 1063 | */ |
1055 | | - public function addReviewForm( &$data ) { |
| 1064 | + public function addReviewForm( &$output ) { |
1056 | 1065 | global $wgRequest, $wgUser; |
1057 | 1066 | $this->load(); |
1058 | 1067 | if ( $this->out->isPrintable() ) { |
— | — | @@ -1108,11 +1117,11 @@ |
1109 | 1118 | |
1110 | 1119 | list( $html, $status ) = $form->getHtml(); |
1111 | 1120 | # Diff action: place the form at the top of the page |
1112 | | - if ( $this->diffRevs ) { |
1113 | | - $this->out->prependHTML( $html ); |
| 1121 | + if ( $output instanceof OutputPage ) { |
| 1122 | + $output->prependHTML( $html ); |
1114 | 1123 | # View action: place the form at the bottom of the page |
1115 | 1124 | } else { |
1116 | | - $data .= $html; |
| 1125 | + $output .= $html; |
1117 | 1126 | } |
1118 | 1127 | } |
1119 | 1128 | return true; |
— | — | @@ -1121,7 +1130,7 @@ |
1122 | 1131 | /** |
1123 | 1132 | * Add link to stable version setting to protection form |
1124 | 1133 | */ |
1125 | | - public function addStabilizationLink( &$data ) { |
| 1134 | + public function addStabilizationLink() { |
1126 | 1135 | global $wgRequest; |
1127 | 1136 | $this->load(); |
1128 | 1137 | if ( FlaggedRevs::useProtectionLevels() ) { |
— | — | @@ -1885,16 +1894,4 @@ |
1886 | 1895 | } |
1887 | 1896 | return $editPage->fr_baseRevId; |
1888 | 1897 | } |
1889 | | - |
1890 | | - /** |
1891 | | - * Adds brief review notes to a page. |
1892 | | - * @param OutputPage $out |
1893 | | - */ |
1894 | | - public function addReviewNotes( &$data ) { |
1895 | | - $this->load(); |
1896 | | - if ( $this->reviewNotes ) { |
1897 | | - $data .= $this->reviewNotes; |
1898 | | - } |
1899 | | - return true; |
1900 | | - } |
1901 | 1898 | } |