r61707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61706‎ | r61707 | r61708 >
Date:08:05, 30 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Removed redundant isArticleRelated() check
* Removed redundant limitedUI() function
* Removed reviewform=1 param, mostly redundant and mostly set useless keys. Replaced with reviewing=1 param where actually needed.
* Fixed unreviewed pages spacing
* Various smaller cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -40,14 +40,6 @@
4141 $config = $this->getVisibilitySettings();
4242 return (bool)$config['override'];
4343 }
44 -
45 - /**
46 - * Is most of the UI on this page to be hidden?
47 - * @returns bool
48 - */
49 - public function limitedUI() {
50 - return ( FlaggedRevs::forDefaultVersionOnly() && !$this->isStableShownByDefault() );
51 - }
5244
5345 /**
5446 * Is this page less open than the site defaults?
Index: trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php
@@ -92,10 +92,11 @@
9393 public function formatRow( $row ) {
9494 global $wgLang, $wgUser, $wgMemc;
9595
 96+ $stxt = $underReview = $watching = '';
9697 $title = Title::newFromRow( $row );
97 - $link = $this->skin->makeKnownLinkObj( $title, null, 'redirect=no&reviewform=1' );
98 - $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
99 - $stxt = $review = $underReview = $watching = '';
 98+ $link = $this->skin->makeKnownLinkObj( $title, null, 'redirect=no&reviewing=1' );
 99+ $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ),
 100+ 'action=history&reviewing=1' );
100101 if ( !is_null( $size = $row->page_len ) ) {
101102 $stxt = ( $size == 0 )
102103 ? wfMsgHtml( 'historyempty' )
@@ -110,13 +111,13 @@
111112 // After three days, just use days
112113 if ( $hours > ( 3 * 24 ) ) {
113114 $days = round( $hours / 24, 0 );
114 - $age = wfMsgExt( 'unreviewed-days', array( 'parsemag' ), $days );
 115+ $age = ' ' . wfMsgExt( 'unreviewed-days', array( 'parsemag' ), $days );
115116 // If one or more hours, use hours
116117 } elseif ( $hours >= 1 ) {
117118 $hours = round( $hours, 0 );
118 - $age = wfMsgExt( 'unreviewed-hours', array( 'parsemag' ), $hours );
 119+ $age = ' ' . wfMsgExt( 'unreviewed-hours', array( 'parsemag' ), $hours );
119120 } else {
120 - $age = wfMsg( 'unreviewed-recent' ); // hot off the press :)
 121+ $age = ' ' . wfMsg( 'unreviewed-recent' ); // hot off the press :)
121122 }
122123 if ( $wgUser->isAllowed( 'unwatchedpages' ) ) {
123124 $uw = self::usersWatching( $title );
@@ -133,13 +134,13 @@
134135 $key = wfMemcKey( 'unreviewedPages', 'underReview', $pageId );
135136 $val = $wgMemc->get( $key );
136137 # Show if a user is looking at this page
137 - if ( ( $val = $wgMemc->get( $key ) ) ) {
 138+ if ( $val ) {
138139 $underReview = " <b class='fr-under-review'>" .
139140 wfMsgHtml( 'unreviewed-viewing' ) . '</b>';
140141 }
141142
142143 return( "<li{$css}>{$link} {$stxt} ({$hist})" .
143 - "{$review}{$age}{$watching}{$underReview}</li>" );
 144+ "{$age}{$watching}{$underReview}</li>" );
144145 }
145146
146147 /**
Index: trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php
@@ -206,8 +206,9 @@
207207 $link = $this->skin->makeKnownLinkObj( $title );
208208 $css = $stxt = $review = $quality = $underReview = '';
209209 $stxt = ChangesList::showCharacterDifference( $row->rev_len, $row->page_len );
210 - $review = $this->skin->makeKnownLinkObj( $title, wfMsg( 'oldreviewed-diff' ),
211 - "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" );
 210+ $review = $this->skin->makeKnownLinkObj( $title,
 211+ wfMsg( 'oldreviewed-diff' ),
 212+ 'diff=cur&oldid='.intval($row->stable).'&diffonly=0' );
212213 # Show quality level if there are several
213214 if ( FlaggedRevs::qualityVersions() ) {
214215 $quality = $row->quality ?
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php
@@ -174,11 +174,12 @@
175175 public function formatRow( $row ) {
176176 global $wgLang, $wgUser, $wgMemc;
177177
 178+ $css = $stxt = $quality = $underReview = '';
178179 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
179180 $link = $this->skin->makeKnownLinkObj( $title );
180 - $css = $stxt = $review = $quality = $underReview = '';
181 - $review = $this->skin->makeKnownLinkObj( $title, wfMsg( 'oldreviewed-diff' ),
182 - "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" );
 181+ $review = $this->skin->makeKnownLinkObj( $title,
 182+ wfMsg( 'oldreviewed-diff' ),
 183+ 'diff=cur&oldid='.intval($row->stable).'&diffonly=0' );
183184 # Show quality level if there are several
184185 if ( FlaggedRevs::qualityVersions() ) {
185186 $quality = $row->quality ?
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -4,12 +4,10 @@
55 /**
66 * Add FlaggedRevs css/js.
77 */
8 - public static function injectStyleAndJS() {
 8+ protected static function injectStyleAndJS() {
99 global $wgOut, $wgUser;
10 - if ( $wgOut->hasHeadItem( 'FlaggedRevs' ) )
 10+ if ( $wgOut->hasHeadItem( 'FlaggedRevs' ) ) {
1111 return true; # Don't double-load
12 - if ( !$wgOut->isArticleRelated() ) {
13 - return self::InjectStyleForSpecial(); // try special page CSS?
1412 }
1513 $fa = FlaggedArticleView::globalArticleInstance();
1614 # Try to only add to relevant pages
@@ -38,6 +36,7 @@
3937 $head .= "\n<script type=\"{$wgJsMimeType}\">" .
4038 "FlaggedRevs.messages = " . Xml::encodeJsVar( $msgs ) . ";</script>\n";
4139 $wgOut->addHeadItem( 'FlaggedRevs', $head );
 40+
4241 return true;
4342 }
4443
@@ -76,7 +75,7 @@
7776 /**
7877 * Add FlaggedRevs css for relevant special pages.
7978 */
80 - public static function InjectStyleForSpecial() {
 79+ protected static function injectStyleForSpecial() {
8180 global $wgTitle, $wgOut;
8281 if ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
8382 return true;
@@ -108,21 +107,18 @@
109108 $view->setRobotPolicy(); // set indexing policy
110109 self::injectStyleAndJS(); // full CSS/JS
111110 } else {
112 - self::InjectStyleForSpecial(); // try special page CSS
 111+ self::injectStyleForSpecial(); // try special page CSS
113112 }
114113 return true;
115114 }
116115
117116 public static function markUnderReview( $output, $article, $title, $user, $request ) {
118 - $action = $request->getVal( 'action', 'view' );
119 - $reviewing = ( $action == 'history' ); // default
120 - if ( $action == 'view'
121 - && ( $request->getInt( 'reviewform' ) || $request->getInt( 'rcid' ) ) )
122 - {
123 - $reviewing = true;
 117+ if( !$user->isAllowed( 'review' ) ) {
 118+ return true; // user cannot review
124119 }
125 - # Set a key to note that someone is viewing this
126 - if ( $reviewing && $user->isAllowed( 'review' ) ) {
 120+ # Set a key to note when someone is reviewing this.
 121+ # NOTE: diff-to-stable views already handled elsewhere.
 122+ if ( $request->getInt( 'reviewing' ) || $request->getInt( 'rcid' ) ) {
127123 global $wgMemc;
128124 $key = wfMemcKey( 'unreviewedPages', 'underReview', $title->getArticleId() );
129125 $wgMemc->set( $key, '1', 20 * 60 ); // 20 min
@@ -1896,7 +1892,7 @@
18971893 return true; // not needed
18981894 }
18991895 $fa = FlaggedArticleView::globalArticleInstance();
1900 - if ( $fa->isReviewable() && !$fa->limitedUI() ) {
 1896+ if ( $fa->isReviewable() ) {
19011897 $srev = $fa->getStableRev();
19021898 # For pages with either no stable version, or an outdated one, let
19031899 # the user decide if he/she wants it reviewed on the spot. One might
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -121,8 +121,8 @@
122122 public function displayTag() {
123123 global $wgOut, $wgRequest;
124124 $this->load();
125 - // UI may be limited to unobtrusive patrolling system
126 - if ( $wgRequest->getVal( 'stableid' ) || !$this->article->limitedUI() ) {
 125+ // Sanity check that this is in reviewable namespace
 126+ if ( $this->article->isReviewable( true ) ) {
127127 $wgOut->appendSubtitle( $this->reviewNotice );
128128 }
129129 return true;
@@ -136,9 +136,9 @@
137137 public function addStableLink() {
138138 global $wgRequest, $wgOut, $wgLang;
139139 $this->load();
140 - # Only for viewing old versions. UI may be limited to unobtrusive patrolling system.
141 - if ( !$wgRequest->getVal( 'oldid' ) || $this->article->limitedUI() )
 140+ if ( !$this->article->isReviewable() || !$wgRequest->getVal( 'oldid' ) ) {
142141 return true;
 142+ }
143143 # We may have nav links like "direction=prev&oldid=x"
144144 $revID = $this->article->getOldIDFromRequest();
145145 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $revID );
@@ -721,7 +721,7 @@
722722 global $wgOut;
723723 $this->load();
724724 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
725 - if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 725+ if ( !$this->article->isReviewable() ) {
726726 return true;
727727 }
728728 # Add a notice if there are pending edits...
@@ -743,7 +743,7 @@
744744 global $wgRequest, $wgOut, $wgLang, $wgUser;
745745 $this->load();
746746 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
747 - if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 747+ if ( !$this->article->isReviewable() ) {
748748 return true;
749749 }
750750 $items = array();
@@ -912,10 +912,6 @@
913913 {
914914 return true;
915915 }
916 - # Unobtrusive patrolling UI only shows forms if requested
917 - if ( !$wgRequest->getInt( 'reviewform' ) && $this->article->limitedUI() ) {
918 - return true;
919 - }
920916 # Avoid multi-page diffs that are useless and misbehave (bug 19327)
921917 if ( $this->isMultiPageDiff ) {
922918 return true;
@@ -1014,7 +1010,7 @@
10151011 $fa = FlaggedArticle::getTitleInstance( $title );
10161012
10171013 $action = $wgRequest->getVal( 'action', 'view' );
1018 - if ( !$fa->isReviewable() || $fa->limitedUI() ) {
 1014+ if ( !$fa->isReviewable() ) {
10191015 return true; // Not a reviewable page or the UI is hidden
10201016 }
10211017 $flags = ( $action == 'rollback' ) ? FR_MASTER : 0;
@@ -1126,7 +1122,7 @@
11271123 return true;
11281124 }
11291125 # Page must be reviewable. UI may be limited to unobtrusive patrolling system.
1130 - if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 1126+ if ( !$this->article->isReviewable() ) {
11311127 return true;
11321128 }
11331129 # Check if this might be the diff to stable. If so, enhance it.

Status & tagging log