r96630 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96629‎ | r96630 | r96631 >
Date:23:37, 8 September 2011
Author:aaron
Status:ok
Tags:
Comment:
* Moved $view->addStabilizationLink to BeforePageDisplay hook so it actually works. Output page no longer seems to accept changes this late.
* Call addReviewForm() from both BeforePageDisplay and SkinAfterContent hooks as needed. This fixes a similar problem with prepending to OutputPage too late.
* Removed old dead reviewNotes code (this feature was removed).
* Avoided use of $wgOut in FlaggedPageView.
Modified paths:
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
@@ -101,7 +101,15 @@
102102 public static function onBeforePageDisplay( &$out, &$skin ) {
103103 if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) {
104104 $view = FlaggedPageView::singleton();
 105+ $view->addStabilizationLink(); // link on protect form
105106 $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+ }
106114 $view->setRobotPolicy(); // set indexing policy
107115 self::injectStyleAndJS(); // full CSS/JS
108116 } else {
@@ -323,9 +331,11 @@
324332 && FlaggedPageView::globalArticleInstance() != null )
325333 {
326334 $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+ }
330340 }
331341 return true;
332342 }
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -12,7 +12,6 @@
1313 protected $isDiffFromStable = false;
1414 protected $isMultiPageDiff = false;
1515 protected $reviewNotice = '';
16 - protected $reviewNotes = '';
1716 protected $diffNoticeBox = '';
1817 protected $reviewFormRev = false;
1918
@@ -44,20 +43,20 @@
4544 * Load the global FlaggedPage instance
4645 */
4746 protected function load() {
48 - global $wgOut;
4947 if ( !$this->loaded ) {
5048 $this->loaded = true;
5149 $this->article = self::globalArticleInstance();
5250 if ( $this->article == null ) {
5351 throw new MWException( 'FlaggedPageView has no context article!' );
5452 }
55 - $this->out = $wgOut;
 53+ $this->out = RequestContext::getMain()->getOutput();
5654 }
5755 }
5856
5957 /**
6058 * Get the FlaggedPage instance associated with $wgTitle,
6159 * or false if there isn't such a title
 60+ * @return FlaggedPage|null
6261 */
6362 public static function globalArticleInstance() {
6463 $title = RequestContext::getMain()->getTitle();
@@ -67,6 +66,14 @@
6867 return null;
6968 }
7069
 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+
7178 /**
7279 * Is this web response for a request to view a page where both:
7380 * (a) no specific page version was requested via URL params
@@ -1048,10 +1055,12 @@
10491056 }
10501057
10511058 /**
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
10541063 */
1055 - public function addReviewForm( &$data ) {
 1064+ public function addReviewForm( &$output ) {
10561065 global $wgRequest, $wgUser;
10571066 $this->load();
10581067 if ( $this->out->isPrintable() ) {
@@ -1108,11 +1117,11 @@
11091118
11101119 list( $html, $status ) = $form->getHtml();
11111120 # 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 );
11141123 # View action: place the form at the bottom of the page
11151124 } else {
1116 - $data .= $html;
 1125+ $output .= $html;
11171126 }
11181127 }
11191128 return true;
@@ -1121,7 +1130,7 @@
11221131 /**
11231132 * Add link to stable version setting to protection form
11241133 */
1125 - public function addStabilizationLink( &$data ) {
 1134+ public function addStabilizationLink() {
11261135 global $wgRequest;
11271136 $this->load();
11281137 if ( FlaggedRevs::useProtectionLevels() ) {
@@ -1885,16 +1894,4 @@
18861895 }
18871896 return $editPage->fr_baseRevId;
18881897 }
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 - }
19011898 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r97272REL1_18 MFT r96560, r96630reedy14:17, 16 September 2011

Status & tagging log