r61044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61043‎ | r61044 | r61045 >
Date:05:11, 14 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Ran stylize.php and broke long lines
* Removed unused 'global $wgFlaggedRevPristine'
Modified paths:
  • /trunk/extensions/FlaggedRevs/FRCacheUpdate.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsLogs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsXML.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/QualityOversight_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/StablePages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/UnstablePages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -18,41 +18,41 @@
1919 http://www.gnu.org/copyleft/gpl.html
2020 */
2121
22 -if( !defined('MEDIAWIKI') ) {
 22+if ( !defined( 'MEDIAWIKI' ) ) {
2323 echo "FlaggedRevs extension\n";
2424 exit( 1 );
2525 }
2626
2727 # This messes with dump HTML...
28 -if( defined('MW_HTML_FOR_DUMP') ) {
 28+if ( defined( 'MW_HTML_FOR_DUMP' ) ) {
2929 return;
3030 }
3131
3232 # Quality -> Sighted (default)
33 -if( !defined('FLAGGED_VIS_QUALITY') )
34 - define('FLAGGED_VIS_QUALITY',0);
 33+if ( !defined( 'FLAGGED_VIS_QUALITY' ) )
 34+ define( 'FLAGGED_VIS_QUALITY', 0 );
3535 # No precedence
36 -if( !defined('FLAGGED_VIS_LATEST') )
37 - define('FLAGGED_VIS_LATEST',1);
 36+if ( !defined( 'FLAGGED_VIS_LATEST' ) )
 37+ define( 'FLAGGED_VIS_LATEST', 1 );
3838 # Pristine -> Quality -> Sighted
39 -if( !defined('FLAGGED_VIS_PRISTINE') )
40 - define('FLAGGED_VIS_PRISTINE',2);
 39+if ( !defined( 'FLAGGED_VIS_PRISTINE' ) )
 40+ define( 'FLAGGED_VIS_PRISTINE', 2 );
4141
4242 # SELECT parameters...
43 -if( !defined('FR_FOR_UPDATE') )
44 - define('FR_FOR_UPDATE',1);
45 -if( !defined('FR_MASTER') )
46 - define('FR_MASTER',2);
47 -if( !defined('FR_TEXT') )
48 - define('FR_TEXT',3);
 43+if ( !defined( 'FR_FOR_UPDATE' ) )
 44+ define( 'FR_FOR_UPDATE', 1 );
 45+if ( !defined( 'FR_MASTER' ) )
 46+ define( 'FR_MASTER', 2 );
 47+if ( !defined( 'FR_TEXT' ) )
 48+ define( 'FR_TEXT', 3 );
4949
5050 # Level constants...
51 -if( !defined('FR_SIGHTED') )
52 - define('FR_SIGHTED',0);
53 -if( !defined('FR_QUALITY') )
54 - define('FR_QUALITY',1);
55 -if( !defined('FR_PRISTINE') )
56 - define('FR_PRISTINE',2);
 51+if ( !defined( 'FR_SIGHTED' ) )
 52+ define( 'FR_SIGHTED', 0 );
 53+if ( !defined( 'FR_QUALITY' ) )
 54+ define( 'FR_QUALITY', 1 );
 55+if ( !defined( 'FR_PRISTINE' ) )
 56+ define( 'FR_PRISTINE', 2 );
5757
5858 $wgExtensionCredits['specialpage'][] = array(
5959 'path' => __FILE__,
@@ -62,7 +62,7 @@
6363 'descriptionmsg' => 'flaggedrevs-desc',
6464 );
6565
66 -#########
 66+# ########
6767 # IMPORTANT: DO NOT EDIT THIS FILE
6868 # When configuring globals, set them at LocalSettings.php instead
6969
@@ -227,11 +227,11 @@
228228 */
229229
230230 # Special:Userrights settings
231 -## Basic rights for Sysops
 231+# # Basic rights for Sysops
232232 $wgAddGroups['sysop'][] = 'editor';
233233 $wgRemoveGroups['sysop'][] = 'editor';
234 -## Extra ones for Bureaucrats
235 -## Add UI page rights just in case we have non-sysop bcrats
 234+# # Extra ones for Bureaucrats
 235+# # Add UI page rights just in case we have non-sysop bcrats
236236 $wgAddGroups['bureaucrat'][] = 'reviewer';
237237 $wgRemoveGroups['bureaucrat'][] = 'reviewer';
238238
@@ -270,7 +270,7 @@
271271 $wgUseCurrentImages = true;
272272
273273 # End of configuration variables.
274 -#########
 274+# ########
275275
276276 # Bots are granted autoreview via hooks, mark in rights
277277 # array so that it shows up in sp:ListGroupRights...
@@ -290,17 +290,17 @@
291291
292292 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
293293
294 -$dir = dirname(__FILE__) . '/';
 294+$dir = dirname( __FILE__ ) . '/';
295295 $langDir = $dir . 'language/';
296296
297297 $wgSvgGraphDir = $dir . 'svggraph';
298298 $wgPHPlotDir = $dir . 'phplot-5.0.5';
299299
300 -$wgAutoloadClasses['FlaggedRevs'] = $dir.'FlaggedRevs.class.php';
301 -$wgAutoloadClasses['FlaggedRevsHooks'] = $dir.'FlaggedRevs.hooks.php';
302 -$wgAutoloadClasses['FlaggedRevsLogs'] = $dir.'FlaggedRevsLogs.php';
303 -$wgAutoloadClasses['FRCacheUpdate'] = $dir.'FRCacheUpdate.php';
304 -$wgAutoloadClasses['FRCacheUpdateJob'] = $dir.'FRCacheUpdate.php';
 300+$wgAutoloadClasses['FlaggedRevs'] = $dir . 'FlaggedRevs.class.php';
 301+$wgAutoloadClasses['FlaggedRevsHooks'] = $dir . 'FlaggedRevs.hooks.php';
 302+$wgAutoloadClasses['FlaggedRevsLogs'] = $dir . 'FlaggedRevsLogs.php';
 303+$wgAutoloadClasses['FRCacheUpdate'] = $dir . 'FRCacheUpdate.php';
 304+$wgAutoloadClasses['FRCacheUpdateJob'] = $dir . 'FRCacheUpdate.php';
305305
306306 # Special case cache invalidations
307307 $wgJobClasses['flaggedrevs_CacheUpdate'] = 'FRCacheUpdateJob';
@@ -359,7 +359,7 @@
360360 $wgExtensionMessagesFiles['ValidationStatistics'] = $langDir . 'ValidationStatistics.i18n.php';
361361 $wgSpecialPageGroups['ValidationStatistics'] = 'quality';
362362 # API Modules
363 -$wgAutoloadClasses['FlaggedRevsApiHooks'] = $dir.'api/FlaggedRevsApi.hooks.php';
 363+$wgAutoloadClasses['FlaggedRevsApiHooks'] = $dir . 'api/FlaggedRevsApi.hooks.php';
364364 # OldReviewedPages for API
365365 $wgAutoloadClasses['ApiQueryOldreviewedpages'] = $dir . 'api/ApiQueryOldreviewedpages.php';
366366 $wgAPIListModules['oldreviewedpages'] = 'ApiQueryOldreviewedpages';
@@ -377,13 +377,13 @@
378378 $wgAPIModules['flagconfig'] = 'ApiFlagConfig';
379379
380380 # Page review module for API
381 -$wgAutoloadClasses['ApiReview'] = $dir.'api/ApiReview.php';
 381+$wgAutoloadClasses['ApiReview'] = $dir . 'api/ApiReview.php';
382382 $wgAPIModules['review'] = 'ApiReview';
383383 # Stability config module for API
384 -$wgAutoloadClasses['ApiStabilize'] = $dir.'api/ApiStabilize.php';
 384+$wgAutoloadClasses['ApiStabilize'] = $dir . 'api/ApiStabilize.php';
385385 $wgAPIModules['stabilize'] = 'ApiStabilize';
386386
387 -######### Hook attachments #########
 387+# ######## Hook attachments #########
388388 # Autopromote Editors
389389 $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeMakeEditor';
390390 # Adds table link references to include ones from the stable version
@@ -487,23 +487,23 @@
488488
489489 # Stable dump hook
490490 $wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery';
491 -#########
 491+# ########
492492
493493 function efLoadFlaggedRevs() {
494494 global $wgUseRCPatrol, $wgFlaggedRevsNamespaces, $wgFlaggedRevsVisible;
495495 # If patrolling is already on, then we know that it
496496 # was intended to have all namespaces patrollable.
497 - if( $wgUseRCPatrol ) {
 497+ if ( $wgUseRCPatrol ) {
498498 global $wgFlaggedRevsPatrolNamespaces, $wgCanonicalNamespaceNames;
499499 $wgFlaggedRevsPatrolNamespaces = array_keys( $wgCanonicalNamespaceNames );
500500 }
501501 # Use RC Patrolling to check for vandalism
502502 # When revisions are flagged, they count as patrolled
503 - if( !empty($wgFlaggedRevsNamespaces) ) {
 503+ if ( !empty( $wgFlaggedRevsNamespaces ) ) {
504504 $wgUseRCPatrol = true;
505505 }
506506 # Visibility - experimental
507 - if( !empty($wgFlaggedRevsVisible) ) {
 507+ if ( !empty( $wgFlaggedRevsVisible ) ) {
508508 global $wgHooks;
509509 $wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanView';
510510 }
@@ -520,23 +520,23 @@
521521 global $wgSpecialPages, $wgUseTagFilter;
522522 global $wgFlaggedRevsNamespaces, $wgFlaggedRevsOverride, $wgFlaggedRevsProtectLevels;
523523 // Show special pages only if FlaggedRevs is enabled on some namespaces
524 - if( !empty($wgFlaggedRevsNamespaces) ) {
 524+ if ( !empty( $wgFlaggedRevsNamespaces ) ) {
525525 $list['RevisionReview'] = $wgSpecialPages['RevisionReview'] = 'RevisionReview';
526526 $list['ReviewedVersions'] = $wgSpecialPages['ReviewedVersions'] = 'ReviewedVersions';
527527 // Protect levels define allowed stability settings
528 - if( empty($wgFlaggedRevsProtectLevels) ) {
 528+ if ( empty( $wgFlaggedRevsProtectLevels ) ) {
529529 $list['Stabilization'] = $wgSpecialPages['Stabilization'] = 'Stabilization';
530530 }
531531 $list['UnreviewedPages'] = $wgSpecialPages['UnreviewedPages'] = 'UnreviewedPages';
532532 $list['OldReviewedPages'] = $wgSpecialPages['OldReviewedPages'] = 'OldReviewedPages';
533533 // Show tag filtered pending edit page if there are tags
534 - if( $wgUseTagFilter && ChangeTags::listDefinedTags() ) {
 534+ if ( $wgUseTagFilter && ChangeTags::listDefinedTags() ) {
535535 $list['ProblemChanges'] = $wgSpecialPages['ProblemChanges'] = 'ProblemChanges';
536536 }
537537 $list['ReviewedPages'] = $wgSpecialPages['ReviewedPages'] = 'ReviewedPages';
538538 $list['QualityOversight'] = $wgSpecialPages['QualityOversight'] = 'QualityOversight';
539539 $list['ValidationStatistics'] = $wgSpecialPages['ValidationStatistics'] = 'ValidationStatistics';
540 - if( !$wgFlaggedRevsOverride ) {
 540+ if ( !$wgFlaggedRevsOverride ) {
541541 $list['StablePages'] = $wgSpecialPages['StablePages'] = 'StablePages';
542542 } else {
543543 $list['UnstablePages'] = $wgSpecialPages['UnstablePages'] = 'UnstablePages';
@@ -580,9 +580,9 @@
581581 $wgSpecialPageCacheUpdates[] = 'efFlaggedRevsUnreviewedPagesUpdate';
582582
583583 function efFlaggedRevsUnreviewedPagesUpdate() {
584 - $base = dirname(__FILE__);
 584+ $base = dirname( __FILE__ );
585585 require_once( "$base/maintenance/updateQueryCache.inc" );
586 - update_flaggedrevs_querycache();
 586+ update_flaggedrevs_querycache();
587587 require_once( "$base/maintenance/updateStats.inc" );
588588 update_flaggedrevs_stats();
589589 }
@@ -595,11 +595,11 @@
596596
597597 function efFlaggedRevsSchemaUpdates() {
598598 global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables;
599 - $base = dirname(__FILE__);
600 - if( $wgDBtype == 'mysql' ) {
 599+ $base = dirname( __FILE__ );
 600+ if ( $wgDBtype == 'mysql' ) {
601601 $wgExtNewTables[] = array( 'flaggedrevs', "$base/FlaggedRevs.sql" ); // Initial install tables
602602 $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_expiry', "$base/archives/patch-fpc_expiry.sql" );
603 - $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" );
 603+ $wgExtNewIndexes[] = array( 'flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" );
604604 $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" );
605605 $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" );
606606 $wgExtNewFields[] = array( 'flaggedrevs', 'fr_img_name', "$base/archives/patch-fr_img_name.sql" );
@@ -607,16 +607,16 @@
608608 $wgExtNewFields[] = array( 'flaggedpages', 'fp_pending_since', "$base/archives/patch-fp_pending_since.sql" );
609609 $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_level', "$base/archives/patch-fpc_level.sql" );
610610 $wgExtNewTables[] = array( 'flaggedpage_pending', "$base/archives/patch-flaggedpage_pending.sql" );
611 - } elseif( $wgDBtype == 'postgres' ) {
 611+ } elseif ( $wgDBtype == 'postgres' ) {
612612 $wgExtNewTables[] = array( 'flaggedrevs', "$base/FlaggedRevs.pg.sql" ); // Initial install tables
613 - $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" );
614 - $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" );
 613+ $wgExtPGNewFields[] = array( 'flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" );
 614+ $wgExtNewIndexes[] = array( 'flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" );
615615 $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/postgres/patch-flaggedrevs_promote.sql" );
616616 $wgExtNewTables[] = array( 'flaggedpages', "$base/postgres/patch-flaggedpages.sql" );
617 - $wgExtNewIndexes[] = array('flaggedrevs', 'fr_img_sha1', "$base/postgres/patch-fr_img_name.sql" );
 617+ $wgExtNewIndexes[] = array( 'flaggedrevs', 'fr_img_sha1', "$base/postgres/patch-fr_img_name.sql" );
618618 $wgExtNewTables[] = array( 'flaggedrevs_tracking', "$base/postgres/patch-flaggedrevs_tracking.sql" );
619 - $wgExtNewIndexes[] = array('flaggedpages', 'fp_pending_since', "$base/postgres/patch-fp_pending_since.sql" );
620 - $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_level', "TEXT NULL" );
 619+ $wgExtNewIndexes[] = array( 'flaggedpages', 'fp_pending_since', "$base/postgres/patch-fp_pending_since.sql" );
 620+ $wgExtPGNewFields[] = array( 'flaggedpage_config', 'fpc_level', "TEXT NULL" );
621621 $wgExtNewTables[] = array( 'flaggedpage_pending', "$base/postgres/patch-flaggedpage_pending.sql" );
622622 }
623623 return true;
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -18,7 +18,7 @@
1919 */
2020 public static function getTitleInstance( Title $title ) {
2121 // Check if there is already an instance on this title
22 - if( !isset( $title->flaggedRevsArticle ) ) {
 22+ if ( !isset( $title->flaggedRevsArticle ) ) {
2323 $title->flaggedRevsArticle = new self( $title );
2424 }
2525 return $title->flaggedRevsArticle;
@@ -79,9 +79,9 @@
8080 * @param bool $titleOnly, only check if title is in reviewable namespace
8181 */
8282 public function isReviewable( $titleOnly = false ) {
83 - if( !FlaggedRevs::isPageReviewable( $this->getTitle() ) ) {
 83+ if ( !FlaggedRevs::isPageReviewable( $this->getTitle() ) ) {
8484 return false;
85 - } elseif( !$titleOnly && FlaggedRevs::forDefaultVersionOnly()
 85+ } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly()
8686 && !$this->isStableShownByDefault() )
8787 {
8888 return false;
@@ -95,9 +95,9 @@
9696 * @return bool
9797 */
9898 public function isPatrollable( $titleOnly = false ) {
99 - if( FlaggedRevs::isPagePatrollable( $this->getTitle() ) ) {
 99+ if ( FlaggedRevs::isPagePatrollable( $this->getTitle() ) ) {
100100 return true;
101 - } elseif( !$titleOnly && FlaggedRevs::forDefaultVersionOnly()
 101+ } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly()
102102 && !$this->isStableShownByDefault() )
103103 {
104104 return true;
@@ -111,16 +111,16 @@
112112 * @return Row
113113 */
114114 public function getStableRev( $flags = 0 ) {
115 - if( $this->stableRev === false ) {
 115+ if ( $this->stableRev === false ) {
116116 return null; // We already looked and found nothing...
117117 }
118118 # Cached results available?
119 - if( !is_null($this->stableRev) ) {
 119+ if ( !is_null( $this->stableRev ) ) {
120120 return $this->stableRev;
121121 }
122122 # Do we have one?
123123 $srev = FlaggedRevision::newFromStable( $this->getTitle(), $flags );
124 - if( $srev ) {
 124+ if ( $srev ) {
125125 $this->stableRev = $srev;
126126 $this->flags[$srev->getRevId()] = $srev->getTags();
127127 return $srev;
@@ -137,7 +137,7 @@
138138 */
139139 public function getVisibilitySettings( $forUpdate = false ) {
140140 # Cached results available?
141 - if( !is_null($this->pageConfig) ) {
 141+ if ( !is_null( $this->pageConfig ) ) {
142142 return $this->pageConfig;
143143 }
144144 # Get the content page, skip talk
@@ -153,13 +153,13 @@
154154 */
155155 public function getFlagsForRevision( $revId ) {
156156 # Cached results?
157 - if( isset($this->flags[$revId]) ) {
 157+ if ( isset( $this->flags[$revId] ) ) {
158158 return $this->flags[$revId];
159159 }
160160 # Get the flags
161161 $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $revId );
162162 # Don't let cache get too big
163 - if( count($this->flags) >= self::CACHE_MAX ) {
 163+ if ( count( $this->flags ) >= self::CACHE_MAX ) {
164164 $this->flags = array();
165165 }
166166 # Try to cache results
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -26,66 +26,66 @@
2727
2828 public static function load() {
2929 global $wgFlaggedRevTags;
30 - if( self::$loaded ) return true;
 30+ if ( self::$loaded ) return true;
3131 # Assume true, then set to false if needed
32 - if( !empty($wgFlaggedRevTags) ) {
 32+ if ( !empty( $wgFlaggedRevTags ) ) {
3333 self::$qualityVersions = true;
3434 self::$pristineVersions = true;
35 - self::$binaryFlagging = (count($wgFlaggedRevTags) <= 1);
 35+ self::$binaryFlagging = ( count( $wgFlaggedRevTags ) <= 1 );
3636 }
37 - foreach( $wgFlaggedRevTags as $tag => $levels ) {
 37+ foreach ( $wgFlaggedRevTags as $tag => $levels ) {
3838 # Sanity checks
39 - $safeTag = htmlspecialchars($tag);
40 - if( !preg_match('/^[a-zA-Z]{1,20}$/',$tag) || $safeTag !== $tag ) {
 39+ $safeTag = htmlspecialchars( $tag );
 40+ if ( !preg_match( '/^[a-zA-Z]{1,20}$/', $tag ) || $safeTag !== $tag ) {
4141 throw new MWException( 'FlaggedRevs given invalid tag name!' );
4242 }
4343 # Define "quality" and "pristine" reqs
44 - if( is_array($levels) ) {
 44+ if ( is_array( $levels ) ) {
4545 $minQL = $levels['quality'];
4646 $minPL = $levels['pristine'];
4747 $ratingLevels = $levels['levels'];
4848 # B/C, $levels is just an integer (minQL)
4949 } else {
5050 global $wgFlaggedRevPristine, $wgFlaggedRevValues;
51 - $ratingLevels = isset($wgFlaggedRevValues) ?
 51+ $ratingLevels = isset( $wgFlaggedRevValues ) ?
5252 $wgFlaggedRevValues : 1;
5353 $minQL = $levels; // an integer
54 - $minPL = isset($wgFlaggedRevPristine) ?
55 - $wgFlaggedRevPristine : $ratingLevels+1;
 54+ $minPL = isset( $wgFlaggedRevPristine ) ?
 55+ $wgFlaggedRevPristine : $ratingLevels + 1;
5656 }
5757 # Set FlaggedRevs tags
5858 self::$dimensions[$tag] = array();
59 - for( $i=0; $i <= $ratingLevels; $i++ ) {
 59+ for ( $i = 0; $i <= $ratingLevels; $i++ ) {
6060 self::$dimensions[$tag][$i] = "{$tag}-{$i}";
6161 }
62 - if( $ratingLevels > 1 ) {
 62+ if ( $ratingLevels > 1 ) {
6363 self::$binaryFlagging = false; // more than one level
6464 }
6565 # Sanity checks
66 - if( !is_integer($minQL) || !is_integer($minPL) ) {
 66+ if ( !is_integer( $minQL ) || !is_integer( $minPL ) ) {
6767 throw new MWException( 'FlaggedRevs given invalid tag value!' );
6868 }
69 - if( $minQL > $ratingLevels ) {
 69+ if ( $minQL > $ratingLevels ) {
7070 self::$qualityVersions = false;
7171 self::$pristineVersions = false;
7272 }
73 - if( $minPL > $ratingLevels ) {
 73+ if ( $minPL > $ratingLevels ) {
7474 self::$pristineVersions = false;
7575 }
76 - self::$minQL[$tag] = max($minQL,1);
77 - self::$minPL[$tag] = max($minPL,1);
 76+ self::$minQL[$tag] = max( $minQL, 1 );
 77+ self::$minPL[$tag] = max( $minPL, 1 );
7878 self::$minSL[$tag] = 1;
7979 }
8080 global $wgFlaggedRevsProtectLevels;
8181 $wgFlaggedRevsProtectLevels = (array)$wgFlaggedRevsProtectLevels;
82 - foreach( $wgFlaggedRevsProtectLevels as $level => $config ) {
 82+ foreach ( $wgFlaggedRevsProtectLevels as $level => $config ) {
8383 # Sanity check that the config is complete
84 - if( !isset($config['select']) || !isset($config['override'])
85 - || !isset($config['autoreview'])
 84+ if ( !isset( $config['select'] ) || !isset( $config['override'] )
 85+ || !isset( $config['autoreview'] )
8686 ) {
8787 throw new MWException( 'FlaggedRevs given incomplete $wgFlaggedRevsProtectLevels value!' );
8888 # Disallow reserved level names
89 - } else if( $level == 'invalid' || $level == 'none' ) {
 89+ } else if ( $level == 'invalid' || $level == 'none' ) {
9090 throw new MWException( 'FlaggedRevs given reserved $wgFlaggedRevsProtectLevels key!' );
9191 }
9292 $config['override'] = intval( $config['override'] ); // Type cleanup
@@ -93,16 +93,16 @@
9494 }
9595 global $wgFlaggedRevsRestrictionLevels;
9696 # Make sure that there is a "none" level
97 - self::$restrictionLevels = array_unique($wgFlaggedRevsRestrictionLevels);
98 - if( !in_array('',self::$restrictionLevels) ) {
99 - self::$restrictionLevels = array('') + self::$restrictionLevels;
 97+ self::$restrictionLevels = array_unique( $wgFlaggedRevsRestrictionLevels );
 98+ if ( !in_array( '', self::$restrictionLevels ) ) {
 99+ self::$restrictionLevels = array( '' ) + self::$restrictionLevels;
100100 }
101101 # Make sure no talk namespaces are in review namespace
102102 global $wgFlaggedRevsNamespaces;
103 - foreach( $wgFlaggedRevsNamespaces as $ns ) {
104 - if( MWNamespace::isTalk($ns) ) {
 103+ foreach ( $wgFlaggedRevsNamespaces as $ns ) {
 104+ if ( MWNamespace::isTalk( $ns ) ) {
105105 throw new MWException( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' );
106 - } else if( $ns == NS_MEDIAWIKI ) {
 106+ } else if ( $ns == NS_MEDIAWIKI ) {
107107 throw new MWException( 'FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!' );
108108 }
109109 }
@@ -116,12 +116,12 @@
117117 self::$loaded = true;
118118 }
119119
120 - ################# Basic accessors #################
 120+ # ################ Basic accessors #################
121121
122122 /**
123123 * Is there only one tag and it has only one level?
124124 * @returns bool
125 - */
 125+ */
126126 public static function binaryFlagging() {
127127 self::load();
128128 return self::$binaryFlagging;
@@ -130,13 +130,13 @@
131131 /**
132132 * If there only one tag and it has only one level, return it
133133 * @returns string
134 - */
 134+ */
135135 public static function binaryTagName() {
136 - if( !self::binaryFlagging() ) {
 136+ if ( !self::binaryFlagging() ) {
137137 return null;
138138 }
139 - $tags = array_keys(self::$dimensions);
140 - return empty($tags) ? null : $tags[0];
 139+ $tags = array_keys( self::$dimensions );
 140+ return empty( $tags ) ? null : $tags[0];
141141 }
142142
143143 /**
@@ -164,7 +164,7 @@
165165 */
166166 public static function useSimpleUI() {
167167 global $wgUser, $wgSimpleFlaggedRevsUI;
168 - return $wgUser->getOption( 'flaggedrevssimpleui', intval($wgSimpleFlaggedRevsUI) );
 168+ return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) );
169169 }
170170
171171 /**
@@ -216,7 +216,7 @@
217217 /**
218218 * Does FLaggedRevs only show for pages that have been set to do so?
219219 * @returns bool
220 - */
 220+ */
221221 public static function stableOnlyIfConfigured() {
222222 return self::forDefaultVersionOnly() && !self::isStableShownByDefault();
223223 }
@@ -228,10 +228,10 @@
229229 public static function ignoreDefaultVersion() {
230230 global $wgFlaggedRevsExceptions, $wgUser;
231231 # Viewer sees current by default (editors, insiders, ect...) ?
232 - foreach( $wgFlaggedRevsExceptions as $group ) {
233 - if( $group == 'user' ) {
 232+ foreach ( $wgFlaggedRevsExceptions as $group ) {
 233+ if ( $group == 'user' ) {
234234 return ( !$wgUser->isAnon() );
235 - } elseif( in_array( $group, $wgUser->getGroups() ) ) {
 235+ } elseif ( in_array( $group, $wgUser->getGroups() ) ) {
236236 return true;
237237 }
238238 }
@@ -276,12 +276,12 @@
277277 unset( $defaultConfig['expiry'] );
278278 unset( $config['expiry'] );
279279 # Check if the page is not protected at all
280 - if( $config == $defaultConfig ) {
 280+ if ( $config == $defaultConfig ) {
281281 return "none";
282282 }
283283 # Otherwise, find the protection level
284 - foreach( $validLevels as $level => $settings ) {
285 - if( $config == $settings ) {
 284+ foreach ( $validLevels as $level => $settings ) {
 285+ if ( $config == $settings ) {
286286 return $level;
287287 }
288288 }
@@ -291,7 +291,7 @@
292292 /**
293293 * Get the autoreview restriction levels available
294294 * @returns array
295 - */
 295+ */
296296 public static function getRestrictionLevels() {
297297 self::load();
298298 return self::$restrictionLevels;
@@ -369,7 +369,7 @@
370370 */
371371 public static function getTagLevels( $tag ) {
372372 self::load();
373 - return isset(self::$dimensions[$tag]) ?
 373+ return isset( self::$dimensions[$tag] ) ?
374374 self::$dimensions[$tag] : array();
375375 }
376376
@@ -381,9 +381,9 @@
382382 */
383383 public static function getTagValueMsg( $tag, $value ) {
384384 self::load();
385 - if( !isset(self::$dimensions[$tag]) )
 385+ if ( !isset( self::$dimensions[$tag] ) )
386386 return '';
387 - if( !isset(self::$dimensions[$tag][$value]) )
 387+ if ( !isset( self::$dimensions[$tag][$value] ) )
388388 return '';
389389 # Return empty string if not there
390390 return wfMsgExt( 'revreview-' . self::$dimensions[$tag][$value],
@@ -396,7 +396,7 @@
397397 */
398398 public static function dimensionsEmpty() {
399399 self::load();
400 - return empty(self::$dimensions);
 400+ return empty( self::$dimensions );
401401 }
402402
403403 /**
@@ -411,7 +411,7 @@
412412 1 => 'quality',
413413 2 => 'pristine'
414414 );
415 - if( isset( $levelText[$level] ) ) {
 415+ if ( isset( $levelText[$level] ) ) {
416416 return $levelText[$level];
417417 } else {
418418 return '';
@@ -428,7 +428,7 @@
429429 */
430430 public static function getPrecedence( $config = null ) {
431431 global $wgFlaggedRevsPrecedence;
432 - if( is_null($config) ) {
 432+ if ( is_null( $config ) ) {
433433 $config = (int)$wgFlaggedRevsPrecedence;
434434 }
435435 switch( $config )
@@ -471,7 +471,7 @@
472472 $minLevels = self::$minSL;
473473 }
474474 $flags = array();
475 - foreach( self::getDimensions() as $tag => $x ) {
 475+ foreach ( self::getDimensions() as $tag => $x ) {
476476 $flags[$tag] = $minLevels[$tag];
477477 }
478478 return $flags;
@@ -483,33 +483,33 @@
484484 * @return mixed array or null
485485 */
486486 public static function getAutoReviewTags( $quality, $config = array() ) {
487 - if( !FlaggedRevs::autoReviewEdits() )
 487+ if ( !FlaggedRevs::autoReviewEdits() )
488488 return null; // shouldn't happen
489489 # Find the maximum auto-review quality level
490 - $qal = min(FlaggedRevs::autoReviewEdits()-1,$quality);
 490+ $qal = min( FlaggedRevs::autoReviewEdits() - 1, $quality );
491491 # Pristine auto-review?
492 - if( $qal == FR_PRISTINE ) {
 492+ if ( $qal == FR_PRISTINE ) {
493493 $flags = self::quickTags( FR_PRISTINE );
494494 # If tags are available and user can set them, we are done...
495 - if( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
 495+ if ( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
496496 return $flags;
497497 }
498498 $qal = FR_QUALITY; // try lower level
499499 }
500500 # Quality auto-review?
501 - if( $qal == FR_QUALITY ) {
 501+ if ( $qal == FR_QUALITY ) {
502502 $flags = self::quickTags( FR_QUALITY );
503503 # If tags are available and user can set them, we are done...
504 - if( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
 504+ if ( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
505505 return $flags;
506506 }
507507 $qal = FR_SIGHTED; // try lower level
508508 }
509509 # Sighted auto-review?
510 - if( $qal == FR_SIGHTED ) {
 510+ if ( $qal == FR_SIGHTED ) {
511511 $flags = self::quickTags( FR_SIGHTED );
512512 # If tags are available and user can set them, we are done...
513 - if( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
 513+ if ( self::userCanAutoSetFlags( $flags, array(), $config ) ) {
514514 return $flags;
515515 }
516516 }
@@ -527,26 +527,26 @@
528528 */
529529 public static function userCanAutoSetFlags( $flags, $oldflags = array(), $config = array() ) {
530530 global $wgUser;
531 - if( !$wgUser->isAllowed('autoreview') ) {
 531+ if ( !$wgUser->isAllowed( 'autoreview' ) ) {
532532 return false;
533533 }
534534 # Check if all of the required site flags have a valid value
535535 # that the user is allowed to set.
536 - foreach( FlaggedRevs::getDimensions() as $qal => $levels ) {
537 - $level = isset($flags[$qal]) ? $flags[$qal] : 0;
538 - $highest = count($levels) - 1; // highest valid level
 536+ foreach ( FlaggedRevs::getDimensions() as $qal => $levels ) {
 537+ $level = isset( $flags[$qal] ) ? $flags[$qal] : 0;
 538+ $highest = count( $levels ) - 1; // highest valid level
539539 # Levels may not apply for some pages
540 - if( $level > 0 && !RevisionReview::levelAvailable( $qal, $level, $config ) ) {
 540+ if ( $level > 0 && !RevisionReview::levelAvailable( $qal, $level, $config ) ) {
541541 return false;
542542 # Sanity check numeric range
543 - } elseif( $level < 0 || $level > $highest ) {
 543+ } elseif ( $level < 0 || $level > $highest ) {
544544 return false;
545545 }
546546 }
547547 return true;
548548 }
549549
550 - ################# Parsing functions #################
 550+ # ################ Parsing functions #################
551551
552552 /**
553553 * @param string $text
@@ -555,7 +555,7 @@
556556 * @return array( string, array, array, array, int )
557557 * All included pages/arguments are expanded out
558558 */
559 - public static function expandText( $text='', $title, $id ) {
 559+ public static function expandText( $text = '', $title, $id ) {
560560 global $wgParser;
561561 # Make our hooks trigger (force unstub so setting doesn't get lost)
562562 $wgParser->firstCallInit();
@@ -564,7 +564,7 @@
565565 $options = self::makeParserOptions();
566566 $outputText = $wgParser->preprocess( $text, $title, $options, $id );
567567 $out =& $wgParser->mOutput;
568 - $data = array( $outputText, $out->mTemplates, $out->mTemplateIds,
 568+ $data = array( $outputText, $out->mTemplates, $out->mTemplateIds,
569569 $out->fr_includeErrors, $out->fr_newestTemplateID );
570570 # Done!
571571 $wgParser->fr_isStable = false;
@@ -579,7 +579,7 @@
580580 * @param int $id
581581 * @return ParserOutput
582582 */
583 - public static function parseStableText( $article, $text='', $id ) {
 583+ public static function parseStableText( $article, $text = '', $id ) {
584584 global $wgParser;
585585 $title = $article->getTitle(); // avoid pass-by-reference error
586586 # Make our hooks trigger (force unstub so setting doesn't get lost)
@@ -620,7 +620,7 @@
621621 global $parserMemc, $wgCacheEpoch;
622622 wfProfileIn( __METHOD__ );
623623 # Make sure it is valid
624 - if( !$article->getId() ) {
 624+ if ( !$article->getId() ) {
625625 wfProfileOut( __METHOD__ );
626626 return null;
627627 }
@@ -629,14 +629,14 @@
630630 # Get the cached HTML
631631 wfDebug( "Trying parser cache $key\n" );
632632 $value = $parserMemc->get( $key );
633 - if( is_object( $value ) ) {
 633+ if ( is_object( $value ) ) {
634634 wfDebug( "Found.\n" );
635635 # Delete if article has changed since the cache was made
636636 $canCache = $article->checkTouched();
637637 $cacheTime = $value->getCacheTime();
638638 $touched = $article->mTouched;
639 - if( !$canCache || $value->expired( $touched ) ) {
640 - if( !$canCache ) {
 639+ if ( !$canCache || $value->expired( $touched ) ) {
 640+ if ( !$canCache ) {
641641 wfIncrStats( "pcache_miss_invalid" );
642642 wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
643643 } else {
@@ -646,7 +646,7 @@
647647 $parserMemc->delete( $key );
648648 $value = false;
649649 } else {
650 - if( isset( $value->mTimestamp ) ) {
 650+ if ( isset( $value->mTimestamp ) ) {
651651 $article->mTimestamp = $value->mTimestamp;
652652 }
653653 wfIncrStats( "pcache_hit" );
@@ -676,10 +676,10 @@
677677 * @param parserOutput $parserOut
678678 * Updates the stable cache of a page with the given $parserOut
679679 */
680 - public static function updatePageCache( $article, $user, $parserOut=null ) {
 680+ public static function updatePageCache( $article, $user, $parserOut = null ) {
681681 global $parserMemc, $wgParserCacheExpireTime, $wgEnableParserCache;
682682 # Make sure it is valid and $wgEnableParserCache is enabled
683 - if( !$wgEnableParserCache || is_null($parserOut) )
 683+ if ( !$wgEnableParserCache || is_null( $parserOut ) )
684684 return false;
685685
686686 $parserCache = ParserCache::singleton();
@@ -691,7 +691,7 @@
692692 $parserOut->mTimestamp = $article->getTimestamp();
693693 $parserOut->mText .= "\n<!-- Saved in stable version parser cache with key $key and timestamp $now -->";
694694 # Set expire time
695 - if( $parserOut->containsOldMagic() ){
 695+ if ( $parserOut->containsOldMagic() ) {
696696 $expire = 3600; // 1 hour
697697 } else {
698698 $expire = $wgParserCacheExpireTime;
@@ -720,8 +720,8 @@
721721 */
722722 public static function clearIncludeVersionCache( $revId ) {
723723 self::load();
724 - if( isset(self::$includeVersionCache[$revId]) ) {
725 - unset(self::$includeVersionCache[$revId]);
 724+ if ( isset( self::$includeVersionCache[$revId] ) ) {
 725+ unset( self::$includeVersionCache[$revId] );
726726 }
727727 }
728728
@@ -730,7 +730,7 @@
731731 */
732732 public static function useProcessCache( $revId ) {
733733 self::load();
734 - if( isset(self::$includeVersionCache[$revId]) ) {
 734+ if ( isset( self::$includeVersionCache[$revId] ) ) {
735735 return true;
736736 }
737737 return false;
@@ -745,9 +745,9 @@
746746 */
747747 public static function getTemplateIdFromCache( $revId, $namespace, $dbKey ) {
748748 self::load();
749 - if( isset(self::$includeVersionCache[$revId]) ) {
750 - if( isset(self::$includeVersionCache[$revId]['templates'][$namespace]) ) {
751 - if( isset(self::$includeVersionCache[$revId]['templates'][$namespace][$dbKey]) ) {
 749+ if ( isset( self::$includeVersionCache[$revId] ) ) {
 750+ if ( isset( self::$includeVersionCache[$revId]['templates'][$namespace] ) ) {
 751+ if ( isset( self::$includeVersionCache[$revId]['templates'][$namespace][$dbKey] ) ) {
752752 return self::$includeVersionCache[$revId]['templates'][$namespace][$dbKey];
753753 }
754754 }
@@ -764,22 +764,22 @@
765765 */
766766 public static function getFileVersionFromCache( $revId, $dbKey ) {
767767 self::load();
768 - if( isset(self::$includeVersionCache[$revId]) ) {
 768+ if ( isset( self::$includeVersionCache[$revId] ) ) {
769769 # All NS_FILE, no need to check namespace
770 - if( isset(self::$includeVersionCache[$revId]['files'][$dbKey]) ) {
 770+ if ( isset( self::$includeVersionCache[$revId]['files'][$dbKey] ) ) {
771771 $time_SHA1 = self::$includeVersionCache[$revId]['files'][$dbKey];
772 - foreach( $time_SHA1 as $time => $sha1 ) {
 772+ foreach ( $time_SHA1 as $time => $sha1 ) {
773773 // Should only be one, but this is an easy check
774 - return array($time,$sha1);
 774+ return array( $time, $sha1 );
775775 }
776 - return array(false,""); // missing?
 776+ return array( false, "" ); // missing?
777777 }
778778 }
779779 return null; // cache not found
780780 }
781781
782 - ################# Synchronization and link update functions #################
783 -
 782+ # ################ Synchronization and link update functions #################
 783+
784784 /**
785785 * @param FlaggedRevision $srev, the stable revision
786786 * @param Article $article
@@ -788,77 +788,77 @@
789789 * @return bool
790790 * See if a flagged revision is synced with the current.
791791 * This function is pretty expensive...
792 - */
 792+ */
793793 public static function stableVersionIsSynced(
794 - $srev, $article, $stableOutput=null, $currentOutput=null
 794+ $srev, $article, $stableOutput = null, $currentOutput = null
795795 ) {
796796 global $wgMemc, $wgEnableParserCache, $wgUser;
797797 # Must be the same revision as the current
798 - if( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) {
 798+ if ( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) {
799799 return false;
800800 }
801801 # Must have same file
802 - if( $article instanceof ImagePage && $article->getFile() ) {
803 - if( $srev->getFileTimestamp() < $article->getFile()->getTimestamp() ) {
 802+ if ( $article instanceof ImagePage && $article->getFile() ) {
 803+ if ( $srev->getFileTimestamp() < $article->getFile()->getTimestamp() ) {
804804 return false;
805805 }
806806 }
807807 # Try the cache...
808808 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
809 - $value = self::getMemcValue( $wgMemc->get($key), $article );
810 - if( $value === "true" ) {
 809+ $value = self::getMemcValue( $wgMemc->get( $key ), $article );
 810+ if ( $value === "true" ) {
811811 return true;
812 - } elseif( $value === "false" ) {
 812+ } elseif ( $value === "false" ) {
813813 return false;
814814 }
815815 # If parseroutputs not given, fetch them...
816 - if( is_null($stableOutput) || !isset($stableOutput->fr_newestTemplateID) ) {
 816+ if ( is_null( $stableOutput ) || !isset( $stableOutput->fr_newestTemplateID ) ) {
817817 # Get parsed stable version
818818 $anon = new User(); // anon cache most likely to exist
819819 $stableOutput = self::getPageCache( $article, $anon );
820 - if( $stableOutput == false && $wgUser->getId() )
 820+ if ( $stableOutput == false && $wgUser->getId() )
821821 $stableOutput = self::getPageCache( $article, $wgUser );
822822 # Regenerate the parser output as needed...
823 - if( $stableOutput == false ) {
 823+ if ( $stableOutput == false ) {
824824 $text = $srev->getRevText();
825825 $stableOutput = self::parseStableText( $article, $text, $srev->getRevId() );
826826 # Update the stable version cache
827827 self::updatePageCache( $article, $anon, $stableOutput );
828828 }
829829 }
830 - if( is_null($currentOutput) || !isset($currentOutput->fr_newestTemplateID) ) {
 830+ if ( is_null( $currentOutput ) || !isset( $currentOutput->fr_newestTemplateID ) ) {
831831 # Get parsed current version
832832 $parserCache = ParserCache::singleton();
833833 $currentOutput = false;
834834 $anon = new User(); // anon cache most likely to exist
835835 # If $text is set, then the stableOutput is new. In that case,
836836 # the current must also be new to avoid sync goofs.
837 - if( !isset($text) ) {
 837+ if ( !isset( $text ) ) {
838838 $currentOutput = $parserCache->get( $article, $anon );
839 - if( $currentOutput == false && $wgUser->getId() )
 839+ if ( $currentOutput == false && $wgUser->getId() )
840840 $currentOutput = $parserCache->get( $article, $wgUser );
841841 }
842842 # Regenerate the parser output as needed...
843 - if( $currentOutput == false ) {
 843+ if ( $currentOutput == false ) {
844844 global $wgParser;
845845 $rev = Revision::newFromTitle( $article->getTitle() );
846846 $text = $rev ? $rev->getText() : false;
847847 $id = $rev ? $rev->getId() : null;
848848 $title = $article->getTitle();
849 - $options = self::makeParserOptions($anon);
 849+ $options = self::makeParserOptions( $anon );
850850 $currentOutput = $wgParser->parse( $text, $title, $options,
851851 /*$lineStart*/true, /*$clearState*/true, $id );
852852 # Might as well save the cache while we're at it
853 - if( $wgEnableParserCache )
 853+ if ( $wgEnableParserCache )
854854 $parserCache->save( $currentOutput, $article, $anon );
855855 }
856856 }
857857 # Only current of revisions of inclusions can be reviewed. Since the stable and current revisions
858858 # have the same text, the only thing that can make them different is updating a template or image.
859859 # If this is the case, the current revision will have a newer template or image version used somewhere.
860 - if( $currentOutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
 860+ if ( $currentOutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
861861 $synced = false;
862 - } elseif( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) {
 862+ } elseif ( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) {
863863 $synced = false;
864864 } else {
865865 $synced = true;
@@ -889,9 +889,9 @@
890890 * @param Article $article
891891 * @return mixed
892892 * Return memc value if not expired
893 - */
 893+ */
894894 public static function getMemcValue( $data, $article ) {
895 - if( is_object($data) && $data->time >= $article->getTouched() ) {
 895+ if ( is_object( $data ) && $data->time >= $article->getTouched() ) {
896896 return $data->value;
897897 }
898898 return false;
@@ -904,19 +904,19 @@
905905 * @return int
906906 * Get number of revs since the stable revision
907907 */
908 - public static function getRevCountSince( $article, $revId, $forUpdate=false ) {
 908+ public static function getRevCountSince( $article, $revId, $forUpdate = false ) {
909909 global $wgMemc, $wgParserCacheExpireTime;
910910 # Try the cache
911911 $count = null;
912912 $key = wfMemcKey( 'flaggedrevs', 'unreviewedrevs', $article->getId() );
913 - if( !$forUpdate ) {
914 - $val = $wgMemc->get($key);
915 - $count = is_integer($val) ? $val : null;
 913+ if ( !$forUpdate ) {
 914+ $val = $wgMemc->get( $key );
 915+ $count = is_integer( $val ) ? $val : null;
916916 }
917 - if( is_null($count) ) {
 917+ if ( is_null( $count ) ) {
918918 $db = $forUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
919919 $count = (int)$db->selectField( 'revision', 'COUNT(*)',
920 - array('rev_page' => $article->getId(), "rev_id > " . intval($revId) ),
 920+ array( 'rev_page' => $article->getId(), "rev_id > " . intval( $revId ) ),
921921 __METHOD__ );
922922 # Save to cache
923923 $wgMemc->set( $key, $count, $wgParserCacheExpireTime );
@@ -931,32 +931,32 @@
932932 * Updates the tracking tables and pending edit count cache. Called on edit.
933933 */
934934 public static function updateStableVersion( $article, $rev, $latest = null ) {
935 - if( !$article->getId() )
 935+ if ( !$article->getId() )
936936 return true; // no bogus entries
937937 # Get the latest revision ID if not set
938 - if( !$latest )
939 - $latest = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 938+ if ( !$latest )
 939+ $latest = $article->getTitle()->getLatestRevID( GAID_FOR_UPDATE );
940940 # Get the highest quality revision (not necessarily this one)
941941 $dbw = wfGetDB( DB_MASTER );
942 - $maxQuality = $dbw->selectField( array('flaggedrevs','revision'),
 942+ $maxQuality = $dbw->selectField( array( 'flaggedrevs', 'revision' ),
943943 'fr_quality',
944944 array( 'fr_page_id' => $article->getId(),
945945 'rev_id = fr_rev_id',
946946 'rev_page = fr_page_id',
947 - 'rev_deleted & '.Revision::DELETED_TEXT => 0
 947+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
948948 ),
949949 __METHOD__,
950 - array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 )
 950+ array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 )
951951 );
952952 # Get the timestamp of the edit after the stable version (if any)
953953 $revId = $rev->getId();
954 - if( $latest != $revId ) {
 954+ if ( $latest != $revId ) {
955955 # Get the latest revision ID
956956 $timestamp = $rev->getTimestamp();
957957 $nextTimestamp = $dbw->selectField( 'revision',
958958 'rev_timestamp',
959959 array( 'rev_page' => $article->getId(),
960 - "rev_timestamp > ".$dbw->addQuotes( $dbw->timestamp($timestamp) ) ),
 960+ "rev_timestamp > " . $dbw->addQuotes( $dbw->timestamp( $timestamp ) ) ),
961961 __METHOD__,
962962 array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
963963 );
@@ -967,11 +967,11 @@
968968 $dbw->replace( 'flaggedpages',
969969 array( 'fp_page_id' ),
970970 array( 'fp_stable' => $revId,
971 - 'fp_reviewed' => ($latest == $revId) ? 1 : 0,
972 - 'fp_quality' => ($maxQuality === false) ? null : $maxQuality,
 971+ 'fp_reviewed' => ( $latest == $revId ) ? 1 : 0,
 972+ 'fp_quality' => ( $maxQuality === false ) ? null : $maxQuality,
973973 'fp_page_id' => $article->getId(),
974 - 'fp_pending_since' => $nextTimestamp ? $dbw->timestamp($nextTimestamp) : null ),
975 - __METHOD__
 974+ 'fp_pending_since' => $nextTimestamp ? $dbw->timestamp( $nextTimestamp ) : null ),
 975+ __METHOD__
976976 );
977977 # Reset cache of # of unreviewed revs
978978 self::getRevCountSince( $article, $revId, true );
@@ -988,35 +988,35 @@
989989 public static function updatePendingList( $article, $latest = null ) {
990990 $data = array();
991991 $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY;
992 - if( !self::qualityVersions() )
 992+ if ( !self::qualityVersions() )
993993 $level = FR_SIGHTED;
994994 # Get the latest revision ID if not set
995 - if( !$latest ) {
996 - $latest = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 995+ if ( !$latest ) {
 996+ $latest = $article->getTitle()->getLatestRevID( GAID_FOR_UPDATE );
997997 }
998998 $pageId = $article->getId();
999999 # Update pending times for each level, going from highest to lowest
10001000 $dbw = wfGetDB( DB_MASTER );
10011001 $higherLevelId = 0;
10021002 $higherLevelTS = '';
1003 - while( $level >= 0 ) {
 1003+ while ( $level >= 0 ) {
10041004 # Get the latest revision of this level...
1005 - $row = $dbw->selectRow( array('flaggedrevs','revision'),
 1005+ $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
10061006 array( 'fr_rev_id', 'rev_timestamp' ),
10071007 array( 'fr_page_id' => $pageId,
10081008 'fr_quality' => $level,
10091009 'rev_id = fr_rev_id',
10101010 'rev_page = fr_page_id',
1011 - 'rev_deleted & '.Revision::DELETED_TEXT => 0,
1012 - 'rev_id > '.intval($higherLevelId)
 1011+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0,
 1012+ 'rev_id > ' . intval( $higherLevelId )
10131013 ),
10141014 __METHOD__,
1015 - array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
 1015+ array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
10161016 );
10171017 # If there is a revision of this level, track it...
10181018 # Revisions reviewed to one level count as reviewed
10191019 # at the lower levels (i.e. quality -> sighted).
1020 - if( $row ) {
 1020+ if ( $row ) {
10211021 $id = $row->fr_rev_id;
10221022 $ts = $row->rev_timestamp;
10231023 } else {
@@ -1024,11 +1024,11 @@
10251025 $ts = $higherLevelTS; // use previous (quality -> sighted)
10261026 }
10271027 # Get edits that actually are pending...
1028 - if( $id && $latest > $id ) {
 1028+ if ( $id && $latest > $id ) {
10291029 # Get the timestamp of the edit after this version (if any)
10301030 $nextTimestamp = $dbw->selectField( 'revision',
10311031 'rev_timestamp',
1032 - array( 'rev_page' => $pageId, "rev_timestamp > ".$dbw->addQuotes($ts) ),
 1032+ array( 'rev_page' => $pageId, "rev_timestamp > " . $dbw->addQuotes( $ts ) ),
10331033 __METHOD__,
10341034 array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
10351035 );
@@ -1044,7 +1044,7 @@
10451045 $level--;
10461046 }
10471047 # Clear any old junk, and insert new rows
1048 - $dbw->delete( 'flaggedpage_pending', array('fpp_page_id' => $pageId), __METHOD__ );
 1048+ $dbw->delete( 'flaggedpage_pending', array( 'fpp_page_id' => $pageId ), __METHOD__ );
10491049 $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ );
10501050 return true;
10511051 }
@@ -1058,12 +1058,12 @@
10591059 $parserCache = ParserCache::singleton();
10601060 $anon = new User(); // anon cache most likely to exist
10611061 $poutput = $parserCache->get( $article, $anon );
1062 - if( $poutput == false && $wgUser->getId() )
 1062+ if ( $poutput == false && $wgUser->getId() )
10631063 $poutput = $parserCache->get( $article, $wgUser );
1064 - if( $poutput == false ) {
 1064+ if ( $poutput == false ) {
10651065 $text = $article->getContent();
10661066 $options = self::makeParserOptions();
1067 - $poutput = $wgParser->parse($text, $article->getTitle(), $options);
 1067+ $poutput = $wgParser->parse( $text, $article->getTitle(), $options );
10681068 }
10691069 $u = new LinksUpdate( $article->getTitle(), $poutput );
10701070 $u->doUpdate(); // this will trigger our hook to add stable links too...
@@ -1074,11 +1074,11 @@
10751075 * Resets links for a page when changed (other than edits)
10761076 */
10771077 public static function titleLinksUpdate( $title ) {
1078 - return self::articleLinksUpdate( new Article($title) );
 1078+ return self::articleLinksUpdate( new Article( $title ) );
10791079 }
10801080
1081 - ################# Revision functions #################
1082 -
 1081+ # ################ Revision functions #################
 1082+
10831083 /**
10841084 * Get flags for a revision
10851085 * @param Title $title
@@ -1092,7 +1092,7 @@
10931093 'fr_page_id' => $title->getArticleId() ),
10941094 __METHOD__ );
10951095 $tags = $tags ? $tags : "";
1096 - return FlaggedRevision::expandRevisionTags( strval($tags) );
 1096+ return FlaggedRevision::expandRevisionTags( strval( $tags ) );
10971097 }
10981098
10991099 /**
@@ -1102,8 +1102,8 @@
11031103 * @returns mixed (int or false)
11041104 * Get quality of a revision
11051105 */
1106 - public static function getRevQuality( $page_id, $rev_id, $flags=0 ) {
1107 - $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 1106+ public static function getRevQuality( $page_id, $rev_id, $flags = 0 ) {
 1107+ $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
11081108 return $db->selectField( 'flaggedrevs',
11091109 'fr_quality',
11101110 array( 'fr_page_id' => $page_id, 'fr_rev_id' => $rev_id ),
@@ -1119,9 +1119,9 @@
11201120 * @returns bool
11211121 * Useful for quickly pinging to see if a revision is flagged
11221122 */
1123 - public static function revIsFlagged( $title, $rev_id, $flags=0 ) {
 1123+ public static function revIsFlagged( $title, $rev_id, $flags = 0 ) {
11241124 $quality = self::getRevQuality( $title->getArticleId(), $rev_id, $flags );
1125 - return ($quality !== false);
 1125+ return ( $quality !== false );
11261126 }
11271127
11281128 /**
@@ -1133,7 +1133,7 @@
11341134 public static function getPrimeFlaggedRevId( $article ) {
11351135 $dbr = wfGetDB( DB_SLAVE );
11361136 # Get the highest quality revision (not necessarily this one).
1137 - $oldid = $dbr->selectField( array('flaggedrevs','revision'),
 1137+ $oldid = $dbr->selectField( array( 'flaggedrevs', 'revision' ),
11381138 'fr_rev_id',
11391139 array(
11401140 'fr_page_id' => $article->getId(),
@@ -1143,7 +1143,7 @@
11441144 __METHOD__,
11451145 array(
11461146 'ORDER BY' => 'fr_quality DESC, fr_rev_id DESC',
1147 - 'USE INDEX' => array('flaggedrevs' => 'page_qal_rev','revision' => 'PRIMARY')
 1147+ 'USE INDEX' => array( 'flaggedrevs' => 'page_qal_rev', 'revision' => 'PRIMARY' )
11481148 )
11491149 );
11501150 return $oldid;
@@ -1157,7 +1157,7 @@
11581158 public static function markRevisionPatrolled( $rev ) {
11591159 $rcid = $rev->isUnpatrolled();
11601160 # Make sure it is now marked patrolled...
1161 - if( $rcid ) {
 1161+ if ( $rcid ) {
11621162 $dbw = wfGetDB( DB_MASTER );
11631163 $dbw->update( 'recentchanges',
11641164 array( 'rc_patrolled' => 1 ),
@@ -1169,7 +1169,7 @@
11701170 return false;
11711171 }
11721172
1173 - ################# Page configuration functions #################
 1173+ # ################ Page configuration functions #################
11741174
11751175 /**
11761176 * Get visibility restrictions on page
@@ -1177,36 +1177,36 @@
11781178 * @param bool $forUpdate, use master DB?
11791179 * @returns Array (select,override)
11801180 */
1181 - public static function getPageVisibilitySettings( $title, $forUpdate=false ) {
 1181+ public static function getPageVisibilitySettings( $title, $forUpdate = false ) {
11821182 $db = wfGetDB( $forUpdate ? DB_MASTER : DB_SLAVE );
11831183 $row = $db->selectRow( 'flaggedpage_config',
11841184 array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ),
11851185 array( 'fpc_page_id' => $title->getArticleID() ),
11861186 __METHOD__
11871187 );
1188 - if( $row ) {
 1188+ if ( $row ) {
11891189 $now = wfTimestampNow();
11901190 # This code should be refactored, now that it's being used more generally.
11911191 $expiry = Block::decodeExpiry( $row->fpc_expiry );
11921192 # Only apply the settings if they haven't expired
1193 - if( !$expiry || $expiry < $now ) {
 1193+ if ( !$expiry || $expiry < $now ) {
11941194 $row = null;
11951195 self::purgeExpiredConfigurations();
11961196 self::titleLinksUpdate( $title ); // re-find stable version
11971197 $title->invalidateCache(); // purge squid/memcached
11981198 }
11991199 }
1200 - if( !$row ) {
 1200+ if ( !$row ) {
12011201 return self::getDefaultVisibilitySettings();
12021202 }
12031203 $config = array(
1204 - 'select' => intval($row->fpc_select),
 1204+ 'select' => intval( $row->fpc_select ),
12051205 'override' => $row->fpc_override,
12061206 'autoreview' => $row->fpc_level,
12071207 'expiry' => $row->fpc_expiry
12081208 );
12091209 # If there are protection levels defined check if this is valid
1210 - if( self::useProtectionLevels() && self::getProtectionLevel($config) == 'invalid' ) {
 1210+ if ( self::useProtectionLevels() && self::getProtectionLevel( $config ) == 'invalid' ) {
12111211 return self::getDefaultVisibilitySettings(); // revert to none
12121212 }
12131213 return $config;
@@ -1214,16 +1214,16 @@
12151215
12161216 /**
12171217 * Get default page configuration settings
1218 - */
 1218+ */
12191219 public static function getDefaultVisibilitySettings() {
12201220 return array(
12211221 # Keep this consistent across settings:
1222 - ## 2 = pristine -> quality -> stable;
1223 - ## 1 = quality -> stable
1224 - ## 0 = none
 1222+ # # 2 = pristine -> quality -> stable;
 1223+ # # 1 = quality -> stable
 1224+ # # 0 = none
12251225 'select' => self::getPrecedence(),
12261226 # Keep this consistent across settings:
1227 - ## 1 -> override, 0 -> don't
 1227+ # # 1 -> override, 0 -> don't
12281228 'override' => self::isStableShownByDefault() ? 1 : 0,
12291229 'autoreview' => '',
12301230 'expiry' => 'infinity'
@@ -1244,19 +1244,19 @@
12451245 );
12461246 $pageIds = $pagesClearTracking = array();
12471247 $config = self::getDefaultVisibilitySettings(); // config is to be reset
1248 - while( $row = $dbw->fetchObject( $ret ) ) {
 1248+ while ( $row = $dbw->fetchObject( $ret ) ) {
12491249 // If FlaggedRevs got "turned off" for this page (due to not
12501250 // having the stable version as the default), then clear it
12511251 // from the tracking tables...
1252 - if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
 1252+ if ( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
12531253 $pagesClearTracking[] = $row->fpc_page_id; // no stable version
12541254 // Check if the new (default) config has a different way
12551255 // of selecting the stable version of this page...
1256 - } else if( $config['select'] !== intval($row->fpc_select) ) {
 1256+ } else if ( $config['select'] !== intval( $row->fpc_select ) ) {
12571257 $title = Title::newFromId( $row->fpc_page_id, GAID_FOR_UPDATE );
12581258 // Determine the new stable version and update the tracking tables...
12591259 $srev = FlaggedRevision::newFromStable( $title, FR_MASTER, $config );
1260 - if( $srev ) {
 1260+ if ( $srev ) {
12611261 $article = new Article( $title );
12621262 self::updateStableVersion( $article, $srev, $title->getArticleID() );
12631263 } else {
@@ -1266,16 +1266,16 @@
12671267 $pageIds[] = $row->fpc_page_id;
12681268 }
12691269 // Clear the expired config for this pages
1270 - if( count($pageIds) ) {
 1270+ if ( count( $pageIds ) ) {
12711271 $dbw->delete( 'flaggedpage_config', array( 'fpc_page_id' => $pageIds ), __METHOD__ );
12721272 }
12731273 // Clear the tracking rows where needed
1274 - if( count($pagesClearTracking) ) {
 1274+ if ( count( $pagesClearTracking ) ) {
12751275 self::clearTrackingRows( $pagesClearTracking );
12761276 }
12771277 }
12781278
1279 - ################# Other utility functions #################
 1279+ # ################ Other utility functions #################
12801280
12811281 /**
12821282 * @param Array $flags
@@ -1303,9 +1303,9 @@
13041304
13051305 // Checks if $flags meets $reqFlagLevels
13061306 protected static function tagsAtLevel( $flags, $reqFlagLevels ) {
1307 - if( empty($flags) ) return false;
1308 - foreach( self::$dimensions as $f => $x ) {
1309 - if( !isset($flags[$f]) || $reqFlagLevels[$f] > $flags[$f] )
 1307+ if ( empty( $flags ) ) return false;
 1308+ foreach ( self::$dimensions as $f => $x ) {
 1309+ if ( !isset( $flags[$f] ) || $reqFlagLevels[$f] > $flags[$f] )
13101310 return false;
13111311 }
13121312 return true;
@@ -1317,20 +1317,20 @@
13181318 * @return int, flagging tier (-1 for non-sighted)
13191319 */
13201320 public static function getLevelTier( $flags ) {
1321 - if( self::isPristine( $flags ) )
 1321+ if ( self::isPristine( $flags ) )
13221322 return FR_PRISTINE; // 2
1323 - elseif( self::isQuality( $flags ) )
 1323+ elseif ( self::isQuality( $flags ) )
13241324 return FR_QUALITY; // 1
1325 - elseif( self::isSighted( $flags ) )
 1325+ elseif ( self::isSighted( $flags ) )
13261326 return FR_SIGHTED; // 0
13271327 else
1328 - return -1;
 1328+ return - 1;
13291329 }
13301330
13311331 /**
13321332 * Get the list of reviewable namespaces
13331333 * @return array
1334 - */
 1334+ */
13351335 public static function getReviewNamespaces() {
13361336 self::load(); // validates namespaces
13371337 return self::$reviewNamespaces;
@@ -1339,7 +1339,7 @@
13401340 /**
13411341 * Get the list of patrolable namespaces
13421342 * @return array
1343 - */
 1343+ */
13441344 public static function getPatrolNamespaces() {
13451345 self::load(); // validates namespaces
13461346 return self::$patrolNamespaces;
@@ -1358,10 +1358,10 @@
13591359 $ns = ( $title->getNamespace() == NS_MEDIA ) ?
13601360 NS_FILE : $title->getNamespace(); // Treat NS_MEDIA as NS_FILE
13611361 # Check for MW: pages and whitelist for exempt pages
1362 - if( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) {
 1362+ if ( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) {
13631363 return false;
13641364 }
1365 - return ( in_array($ns,$namespaces) );
 1365+ return ( in_array( $ns, $namespaces ) );
13661366 }
13671367
13681368 /**
@@ -1373,7 +1373,7 @@
13741374 $namespaces = self::getPatrolNamespaces();
13751375 $ns = ( $title->getNamespace() == NS_MEDIA ) ?
13761376 NS_FILE : $title->getNamespace(); // Treat NS_MEDIA as NS_FILE
1377 - return ( in_array($ns,$namespaces) );
 1377+ return ( in_array( $ns, $namespaces ) );
13781378 }
13791379
13801380 /**
@@ -1383,32 +1383,32 @@
13841384 * @returns array (string,string)
13851385 */
13861386 public static function markHistoryRow( $title, $row ) {
1387 - if( !isset($row->fr_quality) ) {
1388 - return array("",""); // not reviewed
 1387+ if ( !isset( $row->fr_quality ) ) {
 1388+ return array( "", "" ); // not reviewed
13891389 }
13901390 $css = FlaggedRevsXML::getQualityColor( $row->fr_quality );
13911391 $user = User::whois( $row->fr_user ); // FIXME: o(N)
1392 - $flags = explode(',',$row->fr_flags);
1393 - if( in_array('auto',$flags) ) {
 1392+ $flags = explode( ',', $row->fr_flags );
 1393+ if ( in_array( 'auto', $flags ) ) {
13941394 $msg = 'hist-autoreviewed';
13951395 } else {
1396 - $msg = ($row->fr_quality >= 1) ? 'hist-quality-user' : 'hist-stable-user';
 1396+ $msg = ( $row->fr_quality >= 1 ) ? 'hist-quality-user' : 'hist-stable-user';
13971397 }
13981398 $st = $title->getPrefixedDBkey();
13991399 $link = "<span class='fr-$msg plainlinks'>[" .
1400 - wfMsgExt($msg,array('parseinline'),$st,$row->rev_id,$user) . "]</span>";
1401 - return array($link,$css);
 1400+ wfMsgExt( $msg, array( 'parseinline' ), $st, $row->rev_id, $user ) . "]</span>";
 1401+ return array( $link, $css );
14021402 }
14031403
14041404 /**
14051405 * Clear FlaggedRevs tracking tables for this page
14061406 * @param mixed $pageId (int or array)
1407 - */
 1407+ */
14081408 public static function clearTrackingRows( $pageId ) {
14091409 $dbw = wfGetDB( DB_MASTER );
1410 - $dbw->delete( 'flaggedpages', array('fp_page_id' => $pageId), __METHOD__ );
1411 - $dbw->delete( 'flaggedrevs_tracking', array('ftr_from' => $pageId), __METHOD__ );
1412 - $dbw->delete( 'flaggedpage_pending', array('fpp_page_id' => $pageId), __METHOD__ );
 1410+ $dbw->delete( 'flaggedpages', array( 'fp_page_id' => $pageId ), __METHOD__ );
 1411+ $dbw->delete( 'flaggedrevs_tracking', array( 'ftr_from' => $pageId ), __METHOD__ );
 1412+ $dbw->delete( 'flaggedpage_pending', array( 'fpp_page_id' => $pageId ), __METHOD__ );
14131413 }
14141414
14151415 /**
@@ -1426,23 +1426,23 @@
14271427 );
14281428 # Parse params
14291429 $p = array(); // init
1430 - if( $row ) {
1431 - $flatPars = explode( "\n", trim($row->frp_user_params) );
1432 - foreach( $flatPars as $pair ) {
1433 - $m = explode( '=', trim($pair), 2 );
 1430+ if ( $row ) {
 1431+ $flatPars = explode( "\n", trim( $row->frp_user_params ) );
 1432+ foreach ( $flatPars as $pair ) {
 1433+ $m = explode( '=', trim( $pair ), 2 );
14341434 $key = $m[0];
1435 - $value = isset($m[1]) ? $m[1] : null;
 1435+ $value = isset( $m[1] ) ? $m[1] : null;
14361436 $p[$key] = $value;
14371437 }
14381438 }
14391439 # Initialize fields as needed...
1440 - if( !isset($p['uniqueContentPages']) )
 1440+ if ( !isset( $p['uniqueContentPages'] ) )
14411441 $p['uniqueContentPages'] = '';
1442 - if( !isset($p['totalContentEdits']) )
 1442+ if ( !isset( $p['totalContentEdits'] ) )
14431443 $p['totalContentEdits'] = 0;
1444 - if( !isset($p['editComments']) )
 1444+ if ( !isset( $p['editComments'] ) )
14451445 $p['editComments'] = 0;
1446 - if( !isset($p['revertedEdits']) )
 1446+ if ( !isset( $p['revertedEdits'] ) )
14471447 $p['revertedEdits'] = 0;
14481448
14491449 return $p;
@@ -1457,19 +1457,19 @@
14581458 */
14591459 public static function saveUserParams( $uid, $params, $DBName = false ) {
14601460 $flatParams = '';
1461 - foreach( $params as $key => $value ) {
 1461+ foreach ( $params as $key => $value ) {
14621462 $flatParams .= "{$key}={$value}\n";
14631463 }
14641464 $dbw = wfGetDB( DB_MASTER, array(), $DBName );
1465 - $row = $dbw->replace( 'flaggedrevs_promote',
 1465+ $row = $dbw->replace( 'flaggedrevs_promote',
14661466 array( 'frp_user_id' ),
1467 - array( 'frp_user_id' => $uid, 'frp_user_params' => trim($flatParams) ),
 1467+ array( 'frp_user_id' => $uid, 'frp_user_params' => trim( $flatParams ) ),
14681468 __METHOD__
14691469 );
14701470 return ( $dbw->affectedRows() > 0 );
14711471 }
14721472
1473 - ################# Auto-review function #################
 1473+ # ################ Auto-review function #################
14741474
14751475 /**
14761476 * Automatically review an edit and add a log entry in the review log.
@@ -1485,7 +1485,7 @@
14861486 * If no appropriate tags can be found, then the review will abort.
14871487 */
14881488 public static function autoReviewEdit(
1489 - $article, $user, $text, $rev, $flags=null, $auto=true
 1489+ $article, $user, $text, $rev, $flags = null, $auto = true
14901490 ) {
14911491 wfProfileIn( __METHOD__ );
14921492 $title = $article->getTitle();
@@ -1494,20 +1494,20 @@
14951495 $oldSvId = $oldSv ? $oldSv->getRevId() : 0;
14961496 # Set the auto-review tags from the prior stable version.
14971497 # Normally, this should already be done and given here...
1498 - if( !is_array($flags) ) {
1499 - if( $oldSv ) { // use the last stable version if $flags not given
 1498+ if ( !is_array( $flags ) ) {
 1499+ if ( $oldSv ) { // use the last stable version if $flags not given
15001500 $flags = self::getAutoReviewTags( $oldSv->getQuality() /* available */ );
15011501 } else { // new page? use minimal level
15021502 $flags = self::getAutoReviewTags( FR_SIGHTED );
15031503 }
1504 - if( !is_array($flags) ) {
 1504+ if ( !is_array( $flags ) ) {
15051505 wfProfileOut( __METHOD__ );
15061506 return false; // can't auto-review this revision
15071507 }
15081508 }
15091509 $quality = 0;
1510 - if( self::isQuality($flags) ) {
1511 - $quality = self::isPristine($flags) ? 2 : 1;
 1510+ if ( self::isQuality( $flags ) ) {
 1511+ $quality = self::isPristine( $flags ) ? 2 : 1;
15121512 }
15131513
15141514 $tmpset = $imgset = array();
@@ -1519,8 +1519,8 @@
15201520 $poutput = $editInfo->output;
15211521
15221522 # NS:title -> rev ID mapping
1523 - foreach( $poutput->mTemplateIds as $namespace => $titleAndID ) {
1524 - foreach( $titleAndID as $dbkey => $id ) {
 1523+ foreach ( $poutput->mTemplateIds as $namespace => $titleAndID ) {
 1524+ foreach ( $titleAndID as $dbkey => $id ) {
15251525 $tmpset[] = array(
15261526 'ft_rev_id' => $rev->getId(),
15271527 'ft_namespace' => $namespace,
@@ -1530,8 +1530,8 @@
15311531 }
15321532 }
15331533 # Image -> timestamp mapping
1534 - foreach( $poutput->fr_ImageSHA1Keys as $dbkey => $timeAndSHA1 ) {
1535 - foreach( $timeAndSHA1 as $time => $sha1 ) {
 1534+ foreach ( $poutput->fr_ImageSHA1Keys as $dbkey => $timeAndSHA1 ) {
 1535+ foreach ( $timeAndSHA1 as $time => $sha1 ) {
15361536 $imgset[] = array(
15371537 'fi_rev_id' => $rev->getId(),
15381538 'fi_name' => $dbkey,
@@ -1543,10 +1543,10 @@
15441544
15451545 # If this is an image page, store corresponding file info
15461546 $fileData = array();
1547 - if( $title->getNamespace() == NS_FILE ) {
 1547+ if ( $title->getNamespace() == NS_FILE ) {
15481548 $file = $article instanceof ImagePage ?
1549 - $article->getFile() : wfFindFile($title);
1550 - if( is_object($file) && $file->exists() ) {
 1549+ $article->getFile() : wfFindFile( $title );
 1550+ if ( is_object( $file ) && $file->exists() ) {
15511551 $fileData['name'] = $title->getDBkey();
15521552 $fileData['timestamp'] = $file->getTimestamp();
15531553 $fileData['sha1'] = $file->getSha1();
@@ -1574,11 +1574,11 @@
15751575 # If we know that this is now the new stable version
15761576 # (which it probably is), save it to the cache...
15771577 $sv = FlaggedRevision::newFromStable( $article->getTitle(), FR_MASTER/*consistent*/ );
1578 - if( $sv && $sv->getRevId() == $rev->getId() ) {
 1578+ if ( $sv && $sv->getRevId() == $rev->getId() ) {
15791579 global $wgMemc;
15801580 # Update stable page cache. Don't cache redirects;
15811581 # it would go unused and complicate things.
1582 - if( !Title::newFromRedirect( $text ) ) {
 1582+ if ( !Title::newFromRedirect( $text ) ) {
15831583 FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
15841584 }
15851585 self::updatePageCache( $article, $user, $poutput );
@@ -1589,7 +1589,7 @@
15901590 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
15911591 $data = FlaggedRevs::makeMemcObj( "true" );
15921592 $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
1593 - } else if( $sv ) {
 1593+ } else if ( $sv ) {
15941594 # Update tracking table
15951595 self::updatePendingList( $article, $rev->getId() );
15961596 } else {
@@ -1607,9 +1607,9 @@
16081608 self::load();
16091609 # Param to pass to JS function to know if tags are at quality level
16101610 $tagsJS = array();
1611 - foreach( self::$dimensions as $tag => $x ) {
 1611+ foreach ( self::$dimensions as $tag => $x ) {
16121612 $tagsJS[$tag] = array();
1613 - $tagsJS[$tag]['levels'] = count($x)-1;
 1613+ $tagsJS[$tag]['levels'] = count( $x ) - 1;
16141614 $tagsJS[$tag]['quality'] = self::$minQL[$tag];
16151615 $tagsJS[$tag]['pristine'] = self::$minPL[$tag];
16161616 }
@@ -1627,20 +1627,20 @@
16281628 public static function getIncludeParams( $article, $templateIDs, $imageSHA1Keys ) {
16291629 $templateParams = $imageParams = $fileVersion = '';
16301630 # NS -> title -> rev ID mapping
1631 - foreach( $templateIDs as $namespace => $t ) {
1632 - foreach( $t as $dbKey => $revId ) {
 1631+ foreach ( $templateIDs as $namespace => $t ) {
 1632+ foreach ( $t as $dbKey => $revId ) {
16331633 $temptitle = Title::makeTitle( $namespace, $dbKey );
16341634 $templateParams .= $temptitle->getPrefixedDBKey() . "|" . $revId . "#";
16351635 }
16361636 }
16371637 # Image -> timestamp -> sha1 mapping
1638 - foreach( $imageSHA1Keys as $dbKey => $timeAndSHA1 ) {
1639 - foreach( $timeAndSHA1 as $time => $sha1 ) {
 1638+ foreach ( $imageSHA1Keys as $dbKey => $timeAndSHA1 ) {
 1639+ foreach ( $timeAndSHA1 as $time => $sha1 ) {
16401640 $imageParams .= $dbKey . "|" . $time . "|" . $sha1 . "#";
16411641 }
16421642 }
16431643 # For image pages, note the displayed image version
1644 - if( $article instanceof ImagePage ) {
 1644+ if ( $article instanceof ImagePage ) {
16451645 $file = $article->getDisplayedFile();
16461646 $fileVersion = $file->getTimestamp() . "#" . $file->getSha1();
16471647 }
Index: trunk/extensions/FlaggedRevs/FRCacheUpdate.php
@@ -14,19 +14,19 @@
1515
1616 public function doUpdate() {
1717 global $wgFlaggedRevsCacheUpdates;
18 - if( !isset($wgFlaggedRevsCacheUpdates) ) {
 18+ if ( !isset( $wgFlaggedRevsCacheUpdates ) ) {
1919 $wgFlaggedRevsCacheUpdates = array(); // temp var
2020 }
2121 $key = $this->mTitle->getPrefixedDBKey();
22 - if( isset($wgFlaggedRevsCacheUpdates[$key]) )
 22+ if ( isset( $wgFlaggedRevsCacheUpdates[$key] ) )
2323 return; // No duplicates...
2424 # Fetch the IDs
2525 $dbr = wfGetDB( DB_SLAVE );
2626 $res = $dbr->select( $this->mTable, $this->getFromField(),
2727 $this->getToCondition(), __METHOD__ );
28 - if( $dbr->numRows($res) > 0 ) {
 28+ if ( $dbr->numRows( $res ) > 0 ) {
2929 # Do it right now?
30 - if( $dbr->numRows($res) <= $this->mRowsPerJob ) {
 30+ if ( $dbr->numRows( $res ) <= $this->mRowsPerJob ) {
3131 $this->invalidateIDs( $res );
3232 # Defer to job queue...
3333 } else {
@@ -38,7 +38,7 @@
3939
4040 protected function insertJobs( ResultWrapper $res ) {
4141 $numRows = $res->numRows();
42 - if( !$numRows ) return; // sanity check
 42+ if ( !$numRows ) return; // sanity check
4343 $numBatches = ceil( $numRows / $this->mRowsPerJob );
4444 $realBatchSize = ceil( $numRows / $numBatches );
4545 $start = false;
@@ -46,13 +46,13 @@
4747 do {
4848 $first = $last = false; // first/last page_id of this batch
4949 # Get $realBatchSize items (or less if not enough)...
50 - for( $i = 0; $i < $realBatchSize; $i++ ) {
 50+ for ( $i = 0; $i < $realBatchSize; $i++ ) {
5151 $row = $res->fetchRow();
5252 # Is there another row?
53 - if( $row ) {
 53+ if ( $row ) {
5454 $id = $row[0];
5555 $last = $id; // $id is the last page_id of this batch
56 - if( $first === false )
 56+ if ( $first === false )
5757 $first = $id; // set first page_id of this batch
5858 # Out of rows?
5959 } else {
@@ -61,7 +61,7 @@
6262 }
6363 }
6464 # Insert batch into the queue if there is anything there
65 - if( $first ) {
 65+ if ( $first ) {
6666 $params = array(
6767 'table' => $this->mTable,
6868 'start' => $first,
@@ -70,7 +70,7 @@
7171 $jobs[] = new FRCacheUpdateJob( $this->mTitle, $params );
7272 }
7373 $start = $id; // Where the last ID left off
74 - } while( $start );
 74+ } while ( $start );
7575 Job::batchInsert( $jobs );
7676 }
7777
@@ -88,39 +88,39 @@
8989 */
9090 public function invalidateIDs( ResultWrapper $res ) {
9191 global $wgUseFileCache, $wgUseSquid;
92 - if( $res->numRows() == 0 ) return; // sanity check
 92+ if ( $res->numRows() == 0 ) return; // sanity check
9393
9494 $dbw = wfGetDB( DB_MASTER );
9595 $timestamp = $dbw->timestamp();
9696 $done = false;
9797
98 - while( !$done ) {
 98+ while ( !$done ) {
9999 # Get all IDs in this query into an array
100100 $ids = array();
101 - for( $i = 0; $i < $this->mRowsPerQuery; $i++ ) {
 101+ for ( $i = 0; $i < $this->mRowsPerQuery; $i++ ) {
102102 $row = $res->fetchRow();
103 - if( $row ) {
 103+ if ( $row ) {
104104 $ids[] = $row[0];
105105 } else {
106106 $done = true;
107107 break;
108108 }
109109 }
110 - if( count($ids) == 0 ) break;
 110+ if ( count( $ids ) == 0 ) break;
111111 # Update page_touched
112112 $dbw->update( 'page', array( 'page_touched' => $timestamp ),
113113 array( 'page_id' => $ids ), __METHOD__ );
114114 # Update static caches
115 - if( $wgUseSquid || $wgUseFileCache ) {
 115+ if ( $wgUseSquid || $wgUseFileCache ) {
116116 $titles = Title::newFromIDs( $ids );
117117 # Update squid cache
118 - if( $wgUseSquid ) {
 118+ if ( $wgUseSquid ) {
119119 $u = SquidUpdate::newFromTitles( $titles );
120120 $u->doUpdate();
121121 }
122122 # Update file cache
123 - if( $wgUseFileCache ) {
124 - foreach( $titles as $title ) {
 123+ if ( $wgUseFileCache ) {
 124+ foreach ( $titles as $title ) {
125125 HTMLFileCache::clearFileCache( $title );
126126 }
127127 }
@@ -154,10 +154,10 @@
155155 # Get query conditions
156156 $fromField = $update->getFromField();
157157 $conds = $update->getToCondition();
158 - if( $this->start ) {
 158+ if ( $this->start ) {
159159 $conds[] = "$fromField >= {$this->start}";
160160 }
161 - if( $this->end ) {
 161+ if ( $this->end ) {
162162 $conds[] = "$fromField <= {$this->end}";
163163 }
164164
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -28,13 +28,13 @@
2929 * @param Row $row (from database)
3030 */
3131 public function __construct( $row ) {
32 - if( is_object($row) ) {
 32+ if ( is_object( $row ) ) {
3333 $this->mRevId = intval( $row->fr_rev_id );
3434 $this->mPageId = intval( $row->fr_page_id );
3535 $this->mTimestamp = $row->fr_timestamp;
3636 $this->mComment = $row->fr_comment;
3737 $this->mQuality = intval( $row->fr_quality );
38 - $this->mTags = self::expandRevisionTags( strval($row->fr_tags) );
 38+ $this->mTags = self::expandRevisionTags( strval( $row->fr_tags ) );
3939 # Image page revision relevant params
4040 $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null;
4141 $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null;
@@ -42,18 +42,18 @@
4343 $row->fr_img_timestamp : null;
4444 $this->mUser = intval( $row->fr_user );
4545 # Optional fields
46 - $this->mTitle = isset($row->page_namespace) && isset($row->page_title)
 46+ $this->mTitle = isset( $row->page_namespace ) && isset( $row->page_title )
4747 ? Title::makeTitleSafe( $row->page_namespace, $row->page_title )
4848 : null;
49 - $this->mFlags = isset($row->fr_flags) ?
50 - explode(',',$row->fr_flags) : null;
51 - } elseif( is_array($row) ) {
 49+ $this->mFlags = isset( $row->fr_flags ) ?
 50+ explode( ',', $row->fr_flags ) : null;
 51+ } elseif ( is_array( $row ) ) {
5252 $this->mRevId = intval( $row['fr_rev_id'] );
5353 $this->mPageId = intval( $row['fr_page_id'] );
5454 $this->mTimestamp = $row['fr_timestamp'];
5555 $this->mComment = $row['fr_comment'];
5656 $this->mQuality = intval( $row['fr_quality'] );
57 - $this->mTags = self::expandRevisionTags( strval($row['fr_tags']) );
 57+ $this->mTags = self::expandRevisionTags( strval( $row['fr_tags'] ) );
5858 # Image page revision relevant params
5959 $this->mFileName = $row['fr_img_name'] ? $row['fr_img_name'] : null;
6060 $this->mFileSha1 = $row['fr_img_sha1'] ? $row['fr_img_sha1'] : null;
@@ -61,8 +61,8 @@
6262 $row['fr_img_timestamp'] : null;
6363 $this->mUser = intval( $row['fr_user'] );
6464 # Optional fields
65 - $this->mFlags = isset($row['fr_flags']) ?
66 - explode(',',$row['fr_flags']) : null;
 65+ $this->mFlags = isset( $row['fr_flags'] ) ?
 66+ explode( ',', $row['fr_flags'] ) : null;
6767 } else {
6868 throw new MWException( 'FlaggedRevision constructor passed invalid row format.' );
6969 }
@@ -78,36 +78,36 @@
7979 public static function newFromTitle( Title $title, $revId, $flags = 0 ) {
8080 $columns = self::selectFields();
8181 # If we want the text, then get the text flags too
82 - if( $flags & FR_TEXT ) {
 82+ if ( $flags & FR_TEXT ) {
8383 $columns += self::selectTextFields();
8484 }
8585 $options = array();
8686 # User master/slave as appropriate
87 - if( $flags & FR_FOR_UPDATE || $flags & FR_MASTER ) {
 87+ if ( $flags & FR_FOR_UPDATE || $flags & FR_MASTER ) {
8888 $db = wfGetDB( DB_MASTER );
89 - if( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE';
 89+ if ( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE';
9090 } else {
9191 $db = wfGetDB( DB_SLAVE );
9292 }
9393 $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 );
9494 # Short-circuit query
95 - if( !$pageId ) {
 95+ if ( !$pageId ) {
9696 return null;
9797 }
9898 # Skip deleted revisions
99 - $row = $db->selectRow( array('flaggedrevs','revision'),
 99+ $row = $db->selectRow( array( 'flaggedrevs', 'revision' ),
100100 $columns,
101101 array( 'fr_page_id' => $pageId,
102102 'fr_rev_id' => $revId,
103103 'rev_id = fr_rev_id',
104104 'rev_page = fr_page_id',
105 - 'rev_deleted & '.Revision::DELETED_TEXT => 0
 105+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
106106 ),
107107 __METHOD__,
108108 $options
109109 );
110110 # Sorted from highest to lowest, so just take the first one if any
111 - if( $row ) {
 111+ if ( $row ) {
112112 $frev = new self( $row );
113113 $frev->mTitle = $title;
114114 return $frev;
@@ -125,20 +125,20 @@
126126 public static function newFromStable( Title $title, $flags = 0, $config = array() ) {
127127 $columns = self::selectFields();
128128 # If we want the text, then get the text flags too
129 - if( $flags & FR_TEXT ) {
 129+ if ( $flags & FR_TEXT ) {
130130 $columns += self::selectTextFields();
131131 }
132132 $options = array();
133133 # Short-circuit query
134134 $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 );
135135 # Short-circuit query
136 - if( !$pageId ) {
 136+ if ( !$pageId ) {
137137 return null;
138138 }
139139 # Quick slave queries...
140 - if( !($flags & FR_FOR_UPDATE) && !($flags & FR_MASTER) ) {
 140+ if ( !( $flags & FR_FOR_UPDATE ) && !( $flags & FR_MASTER ) ) {
141141 $dbr = wfGetDB( DB_SLAVE );
142 - $row = $dbr->selectRow( array('flaggedpages','flaggedrevs'),
 142+ $row = $dbr->selectRow( array( 'flaggedpages', 'flaggedrevs' ),
143143 $columns,
144144 array( 'fp_page_id' => $pageId,
145145 'fr_page_id = fp_page_id',
@@ -146,29 +146,29 @@
147147 ),
148148 __METHOD__
149149 );
150 - if( !$row ) return null;
 150+ if ( !$row ) return null;
151151 # Master queries that skip the tracking table...
152152 } else {
153153 $row = null;
154154 # Get visiblity settings...
155 - if( empty($config) ) {
 155+ if ( empty( $config ) ) {
156156 $config = FlaggedRevs::getPageVisibilitySettings( $title, true );
157157 }
158 - if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
 158+ if ( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
159159 return $row; // page is not reviewable; no stable version
160160 }
161161 $dbw = wfGetDB( DB_MASTER );
162162 $options['ORDER BY'] = 'fr_rev_id DESC';
163 - if( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE';
 163+ if ( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE';
164164 # Look for the latest pristine revision...
165 - if( FlaggedRevs::pristineVersions() && $config['select'] != FLAGGED_VIS_LATEST ) {
166 - $prow = $dbw->selectRow( array('flaggedrevs','revision'),
 165+ if ( FlaggedRevs::pristineVersions() && $config['select'] != FLAGGED_VIS_LATEST ) {
 166+ $prow = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
167167 $columns,
168168 array( 'fr_page_id' => $pageId,
169 - 'fr_quality = '.FR_PRISTINE,
 169+ 'fr_quality = ' . FR_PRISTINE,
170170 'rev_id = fr_rev_id',
171171 'rev_page = fr_page_id',
172 - 'rev_deleted & '.Revision::DELETED_TEXT => 0
 172+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
173173 ),
174174 __METHOD__,
175175 $options
@@ -176,20 +176,20 @@
177177 # Looks like a plausible revision
178178 $row = $prow ? $prow : $row;
179179 }
180 - if( $row && $config['select'] == FLAGGED_VIS_PRISTINE ) {
 180+ if ( $row && $config['select'] == FLAGGED_VIS_PRISTINE ) {
181181 // we have what we want already
182182 # Look for the latest quality revision...
183 - } elseif( FlaggedRevs::qualityVersions() && $config['select'] != FLAGGED_VIS_LATEST ) {
 183+ } elseif ( FlaggedRevs::qualityVersions() && $config['select'] != FLAGGED_VIS_LATEST ) {
184184 // If we found a pristine rev above, this one must be newer...
185185 $newerClause = $row ? "fr_rev_id > {$row->fr_rev_id}" : "1 = 1";
186 - $qrow = $dbw->selectRow( array('flaggedrevs','revision'),
 186+ $qrow = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
187187 $columns,
188188 array( 'fr_page_id' => $pageId,
189 - 'fr_quality = '.FR_QUALITY,
 189+ 'fr_quality = ' . FR_QUALITY,
190190 $newerClause,
191191 'rev_id = fr_rev_id',
192192 'rev_page = fr_page_id',
193 - 'rev_deleted & '.Revision::DELETED_TEXT => 0
 193+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
194194 ),
195195 __METHOD__,
196196 $options
@@ -197,18 +197,18 @@
198198 $row = $qrow ? $qrow : $row;
199199 }
200200 # Do we have one? If not, try the latest reviewed revision...
201 - if( !$row ) {
202 - $row = $dbw->selectRow( array('flaggedrevs','revision'),
 201+ if ( !$row ) {
 202+ $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
203203 $columns,
204204 array( 'fr_page_id' => $pageId,
205205 'rev_id = fr_rev_id',
206206 'rev_page = fr_page_id',
207 - 'rev_deleted & '.Revision::DELETED_TEXT => 0
 207+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
208208 ),
209209 __METHOD__,
210210 $options
211211 );
212 - if( !$row ) return null;
 212+ if ( !$row ) return null;
213213 }
214214 }
215215 $frev = new self( $row );
@@ -226,8 +226,8 @@
227227 */
228228 public function insertOn( $tmpRows, $fileRows, $auto = false ) {
229229 $textFlags = 'dynamic';
230 - if( $auto ) $textFlags .= ',auto';
231 - $this->mFlags = explode(',',$textFlags);
 230+ if ( $auto ) $textFlags .= ',auto';
 231+ $this->mFlags = explode( ',', $textFlags );
232232 $dbw = wfGetDB( DB_MASTER );
233233 # Our review entry
234234 $revRow = array(
@@ -245,7 +245,7 @@
246246 'fr_img_sha1' => $this->getFileSha1()
247247 );
248248 # Update flagged revisions table
249 - $dbw->replace( 'flaggedrevs', array( array('fr_page_id','fr_rev_id') ),
 249+ $dbw->replace( 'flaggedrevs', array( array( 'fr_page_id', 'fr_rev_id' ) ),
250250 $revRow, __METHOD__ );
251251 # Clear out any previous garbage.
252252 # We want to be able to use this for tracking...
@@ -254,10 +254,10 @@
255255 $dbw->delete( 'flaggedimages',
256256 array( 'fi_rev_id' => $this->getRevId() ), __METHOD__ );
257257 # Update our versioning params
258 - if( !empty($tmpRows) ) {
 258+ if ( !empty( $tmpRows ) ) {
259259 $dbw->insert( 'flaggedtemplates', $tmpRows, __METHOD__, 'IGNORE' );
260260 }
261 - if( !empty($fileRows) ) {
 261+ if ( !empty( $fileRows ) ) {
262262 $dbw->insert( 'flaggedimages', $fileRows, __METHOD__, 'IGNORE' );
263263 }
264264 return true;
@@ -267,16 +267,16 @@
268268 * @returns Array basic select fields (not including text/text flags)
269269 */
270270 public static function selectFields() {
271 - return array('fr_rev_id','fr_page_id','fr_user','fr_timestamp',
272 - 'fr_comment', 'fr_quality','fr_tags','fr_img_name','fr_img_sha1',
273 - 'fr_img_timestamp');
 271+ return array( 'fr_rev_id', 'fr_page_id', 'fr_user', 'fr_timestamp',
 272+ 'fr_comment', 'fr_quality', 'fr_tags', 'fr_img_name', 'fr_img_sha1',
 273+ 'fr_img_timestamp' );
274274 }
275275
276276 /**
277277 * @returns Array text select fields (text/text flags)
278278 */
279279 public static function selectTextFields() {
280 - return array('fr_flags');
 280+ return array( 'fr_flags' );
281281 }
282282
283283 /**
@@ -290,7 +290,7 @@
291291 * @returns Title title
292292 */
293293 public function getTitle() {
294 - if( is_null($this->mTitle) ) {
 294+ if ( is_null( $this->mTitle ) ) {
295295 $this->mTitle = Title::newFromId( $this->mPageId );
296296 }
297297 return $this->mTitle;
@@ -316,7 +316,7 @@
317317 * @returns Revision
318318 */
319319 public function getRevision() {
320 - if( is_null($this->mRevision) ) {
 320+ if ( is_null( $this->mRevision ) ) {
321321 # Get corresponding revision
322322 $rev = Revision::newFromId( $this->mRevId );
323323 # Save to cache
@@ -398,7 +398,7 @@
399399 /**
400400 * Set template versions array
401401 * @param Array template versions (ns -> dbKey -> rev id)
402 - */
 402+ */
403403 public function setTemplateVersions( $templateVersions ) {
404404 $this->mTemplates = $templateVersions;
405405 }
@@ -406,24 +406,24 @@
407407 /**
408408 * Set file versions array
409409 * @param Array file versions (dbKey -> sha1)
410 - */
 410+ */
411411 public function setFileVersions( $fileVersions ) {
412412 $this->mFiles = $fileVersions;
413413 }
414414
415415 /**
416416 * @returns Array template versions (ns -> dbKey -> rev id)
417 - */
 417+ */
418418 public function getTemplateVersions() {
419 - if( $this->mTemplates == null ) {
 419+ if ( $this->mTemplates == null ) {
420420 $this->mTemplates = array();
421421 $dbr = wfGetDB( DB_SLAVE );
422422 $res = $dbr->select( 'flaggedtemplates', '*',
423423 array( 'ft_rev_id' => $this->getRevId() ),
424424 __METHOD__
425425 );
426 - while( $row = $res->fetchObject() ) {
427 - if( !isset($this->mTemplates[$row->ft_namespace]) ) {
 426+ while ( $row = $res->fetchObject() ) {
 427+ if ( !isset( $this->mTemplates[$row->ft_namespace] ) ) {
428428 $this->mTemplates[$row->ft_namespace] = array();
429429 }
430430 $this->mTemplates[$row->ft_namespace][$row->ft_title] = $row->ft_tmp_rev_id;
@@ -434,16 +434,16 @@
435435
436436 /**
437437 * @returns Array file versions (dbKey -> sha1)
438 - */
 438+ */
439439 public function getFileVersions() {
440 - if( $this->mFiles == null ) {
 440+ if ( $this->mFiles == null ) {
441441 $this->mFiles = array();
442442 $dbr = wfGetDB( DB_SLAVE );
443443 $res = $dbr->select( 'flaggedimages', '*',
444444 array( 'fi_rev_id' => $this->getRevId() ),
445445 __METHOD__
446446 );
447 - while( $row = $res->fetchObject() ) {
 447+ while ( $row = $res->fetchObject() ) {
448448 $this->mFiles[$row->fi_name] = $row->fi_img_sha1;
449449 }
450450 }
@@ -469,21 +469,21 @@
470470 public static function expandRevisionTags( $tags ) {
471471 # Set all flags to zero
472472 $flags = array();
473 - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) {
 473+ foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) {
474474 $flags[$tag] = 0;
475475 }
476 - $tags = str_replace('\n',"\n",$tags); // B/C, old broken rows
477 - $tags = explode("\n",$tags);
478 - foreach( $tags as $tuple ) {
479 - $set = explode(':',$tuple,2);
480 - if( count($set) == 2 ) {
481 - list($tag,$value) = $set;
482 - $value = intval($value);
 476+ $tags = str_replace( '\n', "\n", $tags ); // B/C, old broken rows
 477+ $tags = explode( "\n", $tags );
 478+ foreach ( $tags as $tuple ) {
 479+ $set = explode( ':', $tuple, 2 );
 480+ if ( count( $set ) == 2 ) {
 481+ list( $tag, $value ) = $set;
 482+ $value = intval( $value );
483483 # Add only currently recognized ones
484 - if( isset($flags[$tag]) ) {
 484+ if ( isset( $flags[$tag] ) ) {
485485 # If a level was removed, default to the highest
486 - $flags[$tag] = $value < count($levels) ?
487 - $value : count($levels)-1;
 486+ $flags[$tag] = $value < count( $levels ) ?
 487+ $value : count( $levels ) - 1;
488488 }
489489 }
490490 }
@@ -497,10 +497,10 @@
498498 */
499499 public static function flattenRevisionTags( $tags ) {
500500 $flags = '';
501 - foreach( $tags as $tag => $value ) {
 501+ foreach ( $tags as $tag => $value ) {
502502 # Add only currently recognized ones
503 - if( FlaggedRevs::getTagLevels($tag) ) {
504 - $flags .= $tag . ':' . intval($value) . "\n";
 503+ if ( FlaggedRevs::getTagLevels( $tag ) ) {
 504+ $flags .= $tag . ':' . intval( $value ) . "\n";
505505 }
506506 }
507507 return $flags;
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php
@@ -18,12 +18,12 @@
1919 # Allow unprivileged users to at least view the settings
2020 $this->isAllowed = $wgUser->isAllowed( 'stablesettings' );
2121 # Let anyone view, but not submit...
22 - if( $wgRequest->wasPosted() ) {
23 - if( $wgUser->isBlocked( !$confirm ) ) {
 22+ if ( $wgRequest->wasPosted() ) {
 23+ if ( $wgUser->isBlocked( !$confirm ) ) {
2424 return $wgOut->blockedPage();
25 - } elseif( !$this->isAllowed ) {
 25+ } elseif ( !$this->isAllowed ) {
2626 return $wgOut->permissionRequired( 'stablesettings' );
27 - } elseif( wfReadOnly() ) {
 27+ } elseif ( wfReadOnly() ) {
2828 return $wgOut->readOnlyPage();
2929 }
3030 }
@@ -54,30 +54,32 @@
5555 $isValid = $this->handleParams();
5656
5757 # We need a page...
58 - if( is_null($this->page) ) {
 58+ if ( is_null( $this->page ) ) {
5959 return $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
60 - } elseif( !$this->page->exists() ) {
61 - return $wgOut->addHTML( wfMsgExt( 'stabilization-notexists', array('parseinline'),
 60+ } elseif ( !$this->page->exists() ) {
 61+ return $wgOut->addHTML( wfMsgExt( 'stabilization-notexists', array( 'parseinline' ),
6262 $this->page->getPrefixedText() ) );
63 - } elseif( !FlaggedRevs::isPageReviewable( $this->page ) ) {
64 - return $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array('parseinline'),
 63+ } elseif ( !FlaggedRevs::isPageReviewable( $this->page ) ) {
 64+ return $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array( 'parseinline' ),
6565 $this->page->getPrefixedText() ) );
6666 }
6767
6868 # Users who cannot edit or review the page cannot set this
69 - if( $this->isAllowed && !($this->page->userCan('edit') && $this->page->userCan('review')) ) {
 69+ if ( $this->isAllowed && !( $this->page->userCan( 'edit' )
 70+ && $this->page->userCan( 'review' ) ) )
 71+ {
7072 $this->isAllowed = false;
7173 }
7274 # Disable some elements as needed
7375 $this->disabledAttrib = !$this->isAllowed ?
7476 array( 'disabled' => 'disabled' ) : array();
7577 # Show form or submit...
76 - if( $this->isAllowed && $isValid && $confirm ) {
 78+ if ( $this->isAllowed && $isValid && $confirm ) {
7779 $status = $this->submit();
78 - if( $status === true ) {
 80+ if ( $status === true ) {
7981 $wgOut->redirect( $this->page->getFullUrl( $query ) );
8082 } else {
81 - $this->showSettings( wfMsg($status) );
 83+ $this->showSettings( wfMsg( $status ) );
8284 }
8385 } else {
8486 $this->showSettings();
@@ -92,16 +94,16 @@
9395 # Our target page
9496 $this->page = Title::newFromUrl( $this->target );
9597 # We need a page...
96 - if( is_null($this->page) ) {
 98+ if ( is_null( $this->page ) ) {
9799 return false; // can't continue
98100 }
99101 # Get old config
100102 $this->config = FlaggedRevs::getPageVisibilitySettings( $this->page, true );
101103 # Make user readable date for GET requests
102 - $this->oldExpiry = $this->config['expiry'] !== 'infinity' ?
 104+ $this->oldExpiry = $this->config['expiry'] !== 'infinity' ?
103105 wfTimestamp( TS_RFC2822, $this->config['expiry'] ) : 'infinite';
104106 # If not posted, then fill in existing values/defaults
105 - if( !$this->wasPosted ) {
 107+ if ( !$this->wasPosted ) {
106108 # Get visiblity settings...
107109 $this->select = $this->config['select'];
108110 $this->override = $this->config['override'];
@@ -110,42 +112,43 @@
111113 # Handle submission data
112114 } else {
113115 // Custom expiry takes precedence
114 - $this->expiry = strlen($this->expiry) ?
 116+ $this->expiry = strlen( $this->expiry ) ?
115117 $this->expiry : $this->expirySelection;
116 - if( $this->expiry == 'existing' )
 118+ if ( $this->expiry == 'existing' )
117119 $this->expiry = $this->oldExpiry;
118120 // Custom reason takes precedence
119 - if( $this->reasonSelection != 'other' ) {
 121+ if ( $this->reasonSelection != 'other' ) {
120122 $comment = $this->reasonSelection; // start with dropdown reason
121 - if( $this->reason != '' ) {
122 - $comment .= wfMsgForContent( 'colon-separator' ) . $this->reason; // append custom reason
 123+ if ( $this->reason != '' ) {
 124+ // Append custom reason
 125+ $comment .= wfMsgForContent( 'colon-separator' ) . $this->reason;
123126 }
124127 } else {
125128 $comment = $this->reason; // just use custom reason
126129 }
127130 $this->reason = $comment;
128131 // Make sure default version settings is 0 or 1
129 - if( $this->override !== 0 && $this->override !== 1 ) {
 132+ if ( $this->override !== 0 && $this->override !== 1 ) {
130133 return false;
131134 }
132135 // Validate precedence setting
133 - $allowed = array(FLAGGED_VIS_QUALITY,FLAGGED_VIS_LATEST,FLAGGED_VIS_PRISTINE);
134 - if( $this->select && !in_array( $this->select, $allowed ) ) {
 136+ $allowed = array( FLAGGED_VIS_QUALITY, FLAGGED_VIS_LATEST, FLAGGED_VIS_PRISTINE );
 137+ if ( $this->select && !in_array( $this->select, $allowed ) ) {
135138 return false; // invalid value
136139 }
137140 // Check autoreview setting
138 - if( !self::userCanSetAutoreviewLevel($this->autoreview) ) {
 141+ if ( !self::userCanSetAutoreviewLevel( $this->autoreview ) ) {
139142 return false; // invalid value
140143 }
141144 }
142145 # If we use protection levels, check that settings match one...
143 - if( FlaggedRevs::useProtectionLevels() ) {
 146+ if ( FlaggedRevs::useProtectionLevels() ) {
144147 $config = array(
145148 'select' => $this->select,
146149 'override' => $this->override,
147150 'autoreview' => $this->autoreview
148151 );
149 - if( FlaggedRevs::getProtectionLevel($config) == 'invalid' ) {
 152+ if ( FlaggedRevs::getProtectionLevel( $config ) == 'invalid' ) {
150153 return false; // this is not a valid configuration
151154 }
152155 }
@@ -159,15 +162,15 @@
160163 */
161164 public static function userCanSetAutoreviewLevel( $right ) {
162165 global $wgUser;
163 - if( $right == '' )
 166+ if ( $right == '' )
164167 return true; // no restrictions
165168 # Don't let them choose levels above their own rights
166 - if( $right == 'sysop' ) {
 169+ if ( $right == 'sysop' ) {
167170 // special case, rewrite sysop to protect and editprotected
168 - if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') ) {
 171+ if ( !$wgUser->isAllowed( 'protect' ) && !$wgUser->isAllowed( 'editprotected' ) ) {
169172 return false;
170173 }
171 - } else if( !$wgUser->isAllowed($right) ) {
 174+ } else if ( !$wgUser->isAllowed( $right ) ) {
172175 return false;
173176 }
174177 return true;
@@ -176,24 +179,26 @@
177180 protected function showSettings( $err = null ) {
178181 global $wgOut, $wgLang, $wgUser;
179182 # Add any error messages
180 - if( "" != $err ) {
 183+ if ( "" != $err ) {
181184 $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
182185 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
183186 }
184187 # Add header text
185 - if( !$this->isAllowed ) {
186 - $form = wfMsgExt( 'stabilization-perm', array('parse'), $this->page->getPrefixedText() );
 188+ if ( !$this->isAllowed ) {
 189+ $form = wfMsgExt( 'stabilization-perm', array( 'parse' ),
 190+ $this->page->getPrefixedText() );
187191 } else {
188 - $form = wfMsgExt( 'stabilization-text', array('parse'), $this->page->getPrefixedText() );
 192+ $form = wfMsgExt( 'stabilization-text', array( 'parse' ),
 193+ $this->page->getPrefixedText() );
189194 }
190195 # Add some script for expiry dropdowns
191 - $wgOut->addScript(
 196+ $wgOut->addScript(
192197 "<script type=\"text/javascript\">
193198 function updateStabilizationDropdowns() {
194199 val = document.getElementById('mwExpirySelection').value;
195200 if( val == 'existing' )
196 - document.getElementById('mwStabilize-expiry').value = ".
197 - Xml::encodeJsVar($this->oldExpiry).";
 201+ document.getElementById('mwStabilize-expiry').value = " .
 202+ Xml::encodeJsVar( $this->oldExpiry ) . ";
198203 else if( val != 'othertime' )
199204 document.getElementById('mwStabilize-expiry').value = val;
200205 }
@@ -202,20 +207,20 @@
203208 # Borrow some protection messages for dropdowns
204209 $reasonDropDown = Xml::listDropDown( 'wpReasonSelection',
205210 wfMsgForContent( 'protect-dropdown' ),
206 - wfMsgForContent( 'protect-otherreason-op' ),
 211+ wfMsgForContent( 'protect-otherreason-op' ),
207212 $this->reasonSelection,
208213 'mwStabilize-reason', 4
209214 );
210215 $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' );
211 - $showProtectOptions = ($scExpiryOptions !== '-' && $this->isAllowed);
 216+ $showProtectOptions = ( $scExpiryOptions !== '-' && $this->isAllowed );
212217 # Add the current expiry as an option
213218 $expiryFormOptions = '';
214 - if( $this->config['expiry'] && $this->config['expiry'] != 'infinity' ) {
 219+ if ( $this->config['expiry'] && $this->config['expiry'] != 'infinity' ) {
215220 $timestamp = $wgLang->timeanddate( $this->config['expiry'] );
216221 $d = $wgLang->date( $this->config['expiry'] );
217222 $t = $wgLang->time( $this->config['expiry'] );
218 - $expiryFormOptions .=
219 - Xml::option(
 223+ $expiryFormOptions .=
 224+ Xml::option(
220225 wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ),
221226 'existing',
222227 $this->config['expiry'] == 'existing'
@@ -223,15 +228,16 @@
224229 }
225230 $expiryFormOptions .= Xml::option( wfMsg( 'protect-othertime-op' ), "othertime" ) . "\n";
226231 # Add custom levels (from MediaWiki message)
227 - foreach( explode(',',$scExpiryOptions) as $option ) {
228 - if( strpos($option,":") === false ) {
 232+ foreach ( explode( ',', $scExpiryOptions ) as $option ) {
 233+ if ( strpos( $option, ":" ) === false ) {
229234 $show = $value = $option;
230235 } else {
231 - list($show, $value) = explode(":",$option);
 236+ list( $show, $value ) = explode( ":", $option );
232237 }
233 - $show = htmlspecialchars($show);
234 - $value = htmlspecialchars($value);
235 - $expiryFormOptions .= Xml::option( $show, $value, $this->config['expiry'] === $value ) . "\n";
 238+ $show = htmlspecialchars( $show );
 239+ $value = htmlspecialchars( $value );
 240+ $expiryFormOptions .= Xml::option( $show, $value,
 241+ $this->config['expiry'] === $value ) . "\n";
236242 }
237243 # Add stable version override and selection options
238244 $special = SpecialPage::getTitleFor( 'Stabilization' );
@@ -245,12 +251,15 @@
246252 Xml::closeElement( 'fieldset' ) .
247253
248254 Xml::fieldset( wfMsg( 'stabilization-select' ), false ) .
249 - Xml::radioLabel( wfMsg( 'stabilization-select3' ), 'wpStableconfig-select', FLAGGED_VIS_PRISTINE,
250 - 'stable-select3', FLAGGED_VIS_PRISTINE == $this->select, $this->disabledAttrib ) . '<br />' . "\n" .
251 - Xml::radioLabel( wfMsg( 'stabilization-select1' ), 'wpStableconfig-select', FLAGGED_VIS_QUALITY,
252 - 'stable-select1', FLAGGED_VIS_QUALITY == $this->select, $this->disabledAttrib ) . '<br />' . "\n" .
253 - Xml::radioLabel( wfMsg( 'stabilization-select2' ), 'wpStableconfig-select', FLAGGED_VIS_LATEST,
254 - 'stable-select2', FLAGGED_VIS_LATEST == $this->select, $this->disabledAttrib ) . '<br />' . "\n" .
 255+ Xml::radioLabel( wfMsg( 'stabilization-select3' ), 'wpStableconfig-select',
 256+ FLAGGED_VIS_PRISTINE, 'stable-select3', FLAGGED_VIS_PRISTINE == $this->select,
 257+ $this->disabledAttrib ) . '<br />' . "\n" .
 258+ Xml::radioLabel( wfMsg( 'stabilization-select1' ), 'wpStableconfig-select',
 259+ FLAGGED_VIS_QUALITY, 'stable-select1', FLAGGED_VIS_QUALITY == $this->select,
 260+ $this->disabledAttrib ) . '<br />' . "\n" .
 261+ Xml::radioLabel( wfMsg( 'stabilization-select2' ), 'wpStableconfig-select',
 262+ FLAGGED_VIS_LATEST, 'stable-select2', FLAGGED_VIS_LATEST == $this->select,
 263+ $this->disabledAttrib ) . '<br />' . "\n" .
255264 Xml::closeElement( 'fieldset' ) .
256265
257266 Xml::fieldset( wfMsg( 'stabilization-restrict' ), false ) .
@@ -260,11 +269,11 @@
261270 Xml::fieldset( wfMsg( 'stabilization-leg' ), false ) .
262271 Xml::openElement( 'table' );
263272 # Add expiry dropdown
264 - if( $showProtectOptions && $this->isAllowed ) {
 273+ if ( $showProtectOptions && $this->isAllowed ) {
265274 $form .= "
266275 <tr>
267276 <td class='mw-label'>" .
268 - Xml::label( wfMsg('stabilization-expiry'), 'mwExpirySelection' ) .
 277+ Xml::label( wfMsg( 'stabilization-expiry' ), 'mwExpirySelection' ) .
269278 "</td>
270279 <td class='mw-input'>" .
271280 Xml::tags( 'select',
@@ -283,7 +292,7 @@
284293 $form .= "
285294 <tr>
286295 <td class='mw-label'>" .
287 - Xml::label( wfMsg('stabilization-othertime'), 'mwStabilize-expiry' ) .
 296+ Xml::label( wfMsg( 'stabilization-othertime' ), 'mwStabilize-expiry' ) .
288297 '</td>
289298 <td class="mw-input">' .
290299 Xml::input( "mwStabilize-expiry", 50,
@@ -291,15 +300,17 @@
292301 '</td>
293302 </tr>';
294303 # Add comment input and submit button
295 - if( $this->isAllowed ) {
296 - $watchLabel = wfMsgExt( 'watchthis', array('parseinline') );
297 - $watchAttribs = array('accesskey' => wfMsg( 'accesskey-watch' ), 'id' => 'wpWatchthis');
298 - $watchChecked = ( $wgUser->getOption( 'watchdefault' ) || $this->page->userIsWatching() );
299 - $reviewLabel = wfMsgExt( 'stabilization-review', array('parseinline') );
 304+ if ( $this->isAllowed ) {
 305+ $watchLabel = wfMsgExt( 'watchthis', array( 'parseinline' ) );
 306+ $watchAttribs = array( 'accesskey' => wfMsg( 'accesskey-watch' ),
 307+ 'id' => 'wpWatchthis' );
 308+ $watchChecked = ( $wgUser->getOption( 'watchdefault' )
 309+ || $this->page->userIsWatching() );
 310+ $reviewLabel = wfMsgExt( 'stabilization-review', array( 'parseinline' ) );
300311
301312 $form .= ' <tr>
302313 <td class="mw-label">' .
303 - xml::label( wfMsg('stabilization-comment'), 'wpReasonSelection' ) .
 314+ xml::label( wfMsg( 'stabilization-comment' ), 'wpReasonSelection' ) .
304315 '</td>
305316 <td class="mw-input">' .
306317 $reasonDropDown .
@@ -316,7 +327,8 @@
317328 <tr>
318329 <td></td>
319330 <td class="mw-input">' .
320 - Xml::check( 'wpReviewthis', $this->reviewThis, array('id'=>'wpReviewthis') ) .
 331+ Xml::check( 'wpReviewthis', $this->reviewThis,
 332+ array( 'id' => 'wpReviewthis' ) ) .
321333 "<label for='wpReviewthis'>{$reviewLabel}</label>" .
322334 '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
323335 Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ) .
@@ -340,17 +352,18 @@
341353
342354 $wgOut->addHTML( $form );
343355
344 - $wgOut->addHTML( Xml::element( 'h2', null, htmlspecialchars( LogPage::logName( 'stable' ) ) ) );
 356+ $wgOut->addHTML( Xml::element( 'h2', null,
 357+ htmlspecialchars( LogPage::logName( 'stable' ) ) ) );
345358 LogEventsList::showLogExtract( $wgOut, 'stable', $this->page->getPrefixedText() );
346359 }
347360
348361 protected function buildSelector( $selected ) {
349362 global $wgUser;
350363 $levels = array();
351 - foreach( FlaggedRevs::getRestrictionLevels() as $key ) {
 364+ foreach ( FlaggedRevs::getRestrictionLevels() as $key ) {
352365 # Don't let them choose levels they can't set,
353366 # but *show* them all when the form is disabled.
354 - if( $this->isAllowed && !self::userCanSetAutoreviewLevel($key) ) {
 367+ if ( $this->isAllowed && !self::userCanSetAutoreviewLevel( $key ) ) {
355368 continue;
356369 }
357370 $levels[] = $key;
@@ -363,7 +376,7 @@
364377 ) + $this->disabledAttrib;
365378
366379 $out = Xml::openElement( 'select', $attribs );
367 - foreach( $levels as $key ) {
 380+ foreach ( $levels as $key ) {
368381 $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
369382 }
370383 $out .= Xml::closeElement( 'select' );
@@ -377,12 +390,12 @@
378391 * @return string
379392 */
380393 protected function getOptionLabel( $permission ) {
381 - if( $permission == '' ) {
 394+ if ( $permission == '' ) {
382395 return wfMsg( 'stabilization-restrict-none' );
383396 } else {
384397 $key = "protect-level-{$permission}";
385398 $msg = wfMsg( $key );
386 - if( wfEmptyMsg( $key, $msg ) )
 399+ if ( wfEmptyMsg( $key, $msg ) )
387400 $msg = wfMsg( 'protect-fallback', $permission );
388401 return $msg;
389402 }
@@ -393,23 +406,23 @@
394407 $changed = $reset = false;
395408 $defaultPrecedence = FlaggedRevs::getPrecedence();
396409 $defaultOverride = FlaggedRevs::isStableShownByDefault();
397 - if( $this->select == $defaultPrecedence && $this->override == $defaultOverride )
 410+ if ( $this->select == $defaultPrecedence && $this->override == $defaultOverride )
398411 {
399 - $reset = ($this->autoreview == ''); // we are going back to site defaults
 412+ $reset = ( $this->autoreview == '' ); // we are going back to site defaults
400413 }
401414 # Take this opportunity to purge out expired configurations
402415 FlaggedRevs::purgeExpiredConfigurations();
403416 # Parse expiry time given...
404 - if( $reset || $this->expiry == 'infinite' || $this->expiry == 'indefinite' ) {
 417+ if ( $reset || $this->expiry == 'infinite' || $this->expiry == 'indefinite' ) {
405418 $expiry = Block::infinity();
406419 } else {
407420 # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
408421 $expiry = strtotime( $this->expiry );
409 - if( $expiry < 0 || $expiry === false ) {
 422+ if ( $expiry < 0 || $expiry === false ) {
410423 return 'stabilize_expiry_invalid';
411424 }
412425 $expiry = wfTimestamp( TS_MW, $expiry );
413 - if( $expiry < wfTimestampNow() ) {
 426+ if ( $expiry < wfTimestampNow() ) {
414427 return 'stabilize_expiry_old';
415428 }
416429 }
@@ -423,16 +436,16 @@
424437 __METHOD__
425438 );
426439 # If setting to site default values and there is a row...erase it
427 - if( $row && $reset ) {
 440+ if ( $row && $reset ) {
428441 $dbw->delete( 'flaggedpage_config',
429442 array( 'fpc_page_id' => $this->page->getArticleID() ),
430443 __METHOD__
431444 );
432 - $changed = ($dbw->affectedRows() != 0); // did this do anything?
 445+ $changed = ( $dbw->affectedRows() != 0 ); // did this do anything?
433446 # Otherwise, add a row unless we are just setting it as the site default,
434447 # or it is the same the current one...
435 - } elseif( !$reset ) {
436 - if( !$row // no previous config, or...
 448+ } elseif ( !$reset ) {
 449+ if ( !$row // no previous config, or...
437450 || $row->fpc_select != $this->select // ...precedence changed, or...
438451 || $row->fpc_override != $this->override // ...override changed, or...
439452 || $row->fpc_level != $this->autoreview // ...autoreview level changed, or...
@@ -451,48 +464,48 @@
452465 }
453466 }
454467 // Check if this actually changed anything...
455 - if( $changed ) {
 468+ if ( $changed ) {
456469 $id = $this->page->getArticleId();
457470 $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE );
458471 # Config may have changed to allow stable versions...refresh page
459472 # tracking to account for any hidden reviewed versions.
460473 $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER );
461 - if( $frev ) {
 474+ if ( $frev ) {
462475 FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $latest );
463476 }
464477 # ID, accuracy, depth, style
465478 $set = array();
466479 # @FIXME: do this better
467480 // Precedence
468 - if( FlaggedRevs::qualityVersions() ) {
 481+ if ( FlaggedRevs::qualityVersions() ) {
469482 $set[] = wfMsgForContent( 'stabilization-sel-short' ) .
470483 wfMsgForContent( 'colon-separator' ) .
471 - wfMsgForContent("stabilization-sel-short-{$this->select}");
 484+ wfMsgForContent( "stabilization-sel-short-{$this->select}" );
472485 }
473486 // Default version
474487 $set[] = wfMsgForContent( 'stabilization-def-short' ) .
475488 wfMsgForContent( 'colon-separator' ) .
476 - wfMsgForContent("stabilization-def-short-{$this->override}");
477 - if( strlen($this->autoreview) ) {
 489+ wfMsgForContent( "stabilization-def-short-{$this->override}" );
 490+ if ( strlen( $this->autoreview ) ) {
478491 $set[] = "autoreview={$this->autoreview}";
479492 }
480493 $settings = '[' . $wgContLang->commaList( $set ) . ']';
481494 # Append comment with settings (other than for resets)
482495 $reason = $this->reason;
483 - if( !$reset ) {
 496+ if ( !$reset ) {
484497 $reason = $this->reason ? "{$this->reason} $settings" : "$settings";
485 - $encodedExpiry = Block::encodeExpiry($expiry, $dbw );
486 - if( $encodedExpiry != 'infinity' ) {
 498+ $encodedExpiry = Block::encodeExpiry( $expiry, $dbw );
 499+ if ( $encodedExpiry != 'infinity' ) {
487500 $expiry_description = ' (' . wfMsgForContent( 'stabilize-expiring',
488 - $wgContLang->timeanddate($expiry, false, false) ,
489 - $wgContLang->date($expiry, false, false) ,
490 - $wgContLang->time($expiry, false, false) ) . ')';
 501+ $wgContLang->timeanddate( $expiry, false, false ) ,
 502+ $wgContLang->date( $expiry, false, false ) ,
 503+ $wgContLang->time( $expiry, false, false ) ) . ')';
491504 $reason .= "$expiry_description";
492505 }
493506 }
494507 # Add log entry...
495508 $log = new LogPage( 'stable' );
496 - if( $reset ) {
 509+ if ( $reset ) {
497510 $log->addEntry( 'reset', $this->page, $reason );
498511 $type = "stable-logentry2";
499512 } else {
@@ -500,8 +513,9 @@
501514 $type = "stable-logentry";
502515 }
503516 # Build null-edit comment
504 - $comment = $wgContLang->ucfirst( wfMsgForContent( $type, $this->page->getPrefixedText() ) );
505 - if( $reason ) {
 517+ $comment = $wgContLang->ucfirst(
 518+ wfMsgForContent( $type, $this->page->getPrefixedText() ) );
 519+ if ( $reason ) {
506520 $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
507521 }
508522 # Insert a null revision
@@ -509,7 +523,8 @@
510524 $nullRevId = $nullRevision->insertOn( $dbw );
511525 # Update page record and touch page
512526 $article->updateRevisionOn( $dbw, $nullRevision, $latest );
513 - wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest) );
 527+ wfRunHooks( 'NewRevisionFromEditComplete',
 528+ array( $article, $nullRevision, $latest ) );
514529
515530 $invalidate = true;
516531 # Take the user to the diff if an outdated version is being
@@ -518,10 +533,10 @@
519534 $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER );
520535 $cfLevel = FlaggedRevs::getPrecedence( $this->select ); // desired level
521536 // Is the page out of sync? Is there no stable version?
522 - if( !$frev || $frev->getRevId() != $nullRevId || $frev->getQuality() != $cfLevel ) {
 537+ if ( !$frev || $frev->getRevId() != $nullRevId || $frev->getQuality() != $cfLevel ) {
523538 $flags = FlaggedRevs::quickTags( $cfLevel ); // desired flags
524539 // Try to autoreview to this level...
525 - if( $this->reviewThis && RevisionReview::userCanSetFlags($flags) ) {
 540+ if ( $this->reviewThis && RevisionReview::userCanSetFlags( $flags ) ) {
526541 $text = $nullRevision->getText();
527542 // Invalidate cache if not already done with auto-review
528543 $invalidate = !FlaggedRevs::autoReviewEdit( $article, $wgUser, $text,
@@ -529,14 +544,14 @@
530545 }
531546 }
532547 # Update the links tables as the stable version may now be the default page...
533 - if( $invalidate ) {
 548+ if ( $invalidate ) {
534549 FlaggedRevs::titleLinksUpdate( $this->page );
535550 }
536551 }
537552 # Apply watchlist checkbox value (may be NULL)
538 - if( $this->watchThis === true ) {
 553+ if ( $this->watchThis === true ) {
539554 $wgUser->addWatch( $this->page );
540 - } else if( $this->watchThis === false ) {
 555+ } else if ( $this->watchThis === false ) {
541556 $wgUser->removeWatch( $this->page );
542557 }
543558 return true;
Index: trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php
@@ -13,7 +13,7 @@
1414 public function execute( $par ) {
1515 global $wgRequest, $wgUser, $wgOut;
1616 $this->setHeaders();
17 - if( !$wgUser->isAllowed( 'unreviewedpages' ) ) {
 17+ if ( !$wgUser->isAllowed( 'unreviewedpages' ) ) {
1818 $wgOut->permissionRequired( 'unreviewedpages' );
1919 return;
2020 }
@@ -29,7 +29,7 @@
3030 $namespace = $wgRequest->getIntOrNull( 'namespace', $defaultNS );
3131 $category = trim( $wgRequest->getVal( 'category' ) );
3232 $catTitle = Title::makeTitleSafe( NS_CATEGORY, $category );
33 - $category = is_null($catTitle) ? '' : $catTitle->getText();
 33+ $category = is_null( $catTitle ) ? '' : $catTitle->getText();
3434 $level = $wgRequest->getInt( 'level' );
3535 $hideRedirs = $wgRequest->getBool( 'hideredirs', true );
3636
@@ -43,48 +43,49 @@
4444
4545 $action = htmlspecialchars( $wgScript );
4646 $wgOut->addHTML( "<form action=\"$action\" method=\"get\">\n" .
47 - '<fieldset><legend>' . wfMsg('unreviewed-legend') . '</legend>' .
 47+ '<fieldset><legend>' . wfMsg( 'unreviewed-legend' ) . '</legend>' .
4848 Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . '<p>' );
4949 # Add dropdowns as needed
50 - if( count($namespaces) > 1 ) {
 50+ if ( count( $namespaces ) > 1 ) {
5151 $wgOut->addHTML( FlaggedRevsXML::getNamespaceMenu( $namespace ) . '&nbsp;' );
5252 }
53 - if( FlaggedRevs::qualityVersions() ) {
 53+ if ( FlaggedRevs::qualityVersions() ) {
5454 $wgOut->addHTML( FlaggedRevsXML::getLevelMenu( $level, false, 1 ) . '&nbsp;' );
5555 }
56 - $wgOut->addHTML(
 56+ $wgOut->addHTML(
5757 "<span style='white-space: nowrap;'>" .
58 - Xml::label( wfMsg("unreviewed-category"), 'category' ) . '&nbsp;' .
59 - Xml::input( 'category', 30, $category, array('id' => 'category') ) .
 58+ Xml::label( wfMsg( "unreviewed-category" ), 'category' ) . '&nbsp;' .
 59+ Xml::input( 'category', 30, $category, array( 'id' => 'category' ) ) .
6060 '</span><br />' .
61 - $showhideredirs . '&nbsp;&nbsp;' .
 61+ $showhideredirs . '&nbsp;&nbsp;' .
6262 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
6363 "</fieldset></form>"
6464 );
6565 # This will start to get slower if live...
66 - if( !$live = self::generalQueryOK() ) {
 66+ if ( !$live = self::generalQueryOK() ) {
6767 $dbr = wfGetDB( DB_SLAVE );
68 - $ts = $dbr->selectField( 'querycache_info', 'qci_timestamp',
69 - array( 'qci_type' => 'fr_unreviewedpages'), __METHOD__ );
70 - if( $ts ) {
 68+ $ts = $dbr->selectField( 'querycache_info', 'qci_timestamp',
 69+ array( 'qci_type' => 'fr_unreviewedpages' ), __METHOD__ );
 70+ if ( $ts ) {
7171 global $wgLang;
72 - $ts = wfTimestamp(TS_MW,$ts);
73 - $td = $wgLang->timeanddate($ts);
74 - $d = $wgLang->date($ts);
75 - $t = $wgLang->time($ts);
 72+ $ts = wfTimestamp( TS_MW, $ts );
 73+ $td = $wgLang->timeanddate( $ts );
 74+ $d = $wgLang->date( $ts );
 75+ $t = $wgLang->time( $ts );
7676 $wgOut->addHTML( wfMsg( 'perfcachedts', $td, $d, $t ) );
7777 } else {
7878 $wgOut->addHTML( wfMsg( 'perfcached' ) );
7979 }
8080 }
81 - $pager = new UnreviewedPagesPager( $this, $live, $namespace, !$hideRedirs, $category, $level );
82 - if( $pager->getNumRows() ) {
83 - $wgOut->addHTML( wfMsgExt('unreviewed-list', array('parse') ) );
 81+ $pager = new UnreviewedPagesPager( $this, $live, $namespace,
 82+ !$hideRedirs, $category, $level );
 83+ if ( $pager->getNumRows() ) {
 84+ $wgOut->addHTML( wfMsgExt( 'unreviewed-list', array( 'parse' ) ) );
8485 $wgOut->addHTML( $pager->getNavigationBar() );
8586 $wgOut->addHTML( $pager->getBody() );
8687 $wgOut->addHTML( $pager->getNavigationBar() );
8788 } else {
88 - $wgOut->addHTML( wfMsgExt('unreviewed-none', array('parse') ) );
 89+ $wgOut->addHTML( wfMsgExt( 'unreviewed-none', array( 'parse' ) ) );
8990 }
9091 }
9192
@@ -93,50 +94,52 @@
9495
9596 $title = Title::newFromRow( $row );
9697 $link = $this->skin->makeKnownLinkObj( $title, null, 'redirect=no&reviewform=1' );
97 - $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' );
 98+ $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
9899 $stxt = $review = $underReview = $watching = '';
99 - if( !is_null($size = $row->page_len) ) {
100 - $stxt = ($size == 0)
101 - ? wfMsgHtml('historyempty')
102 - : wfMsgExt('historysize', array('parsemag'), $wgLang->formatNum( $size ) );
 100+ if ( !is_null( $size = $row->page_len ) ) {
 101+ $stxt = ( $size == 0 )
 102+ ? wfMsgHtml( 'historyempty' )
 103+ : wfMsgExt( 'historysize', array( 'parsemag' ), $wgLang->formatNum( $size ) );
103104 $stxt = " <small>$stxt</small>";
104105 }
105106 # Get how long the first unreviewed edit has been waiting...
106107 static $currentTime;
107108 $currentTime = wfTimestamp( TS_UNIX ); // now
108109 $firstPendingTime = wfTimestamp( TS_UNIX, $row->creation );
109 - $hours = ($currentTime - $firstPendingTime)/3600;
 110+ $hours = ( $currentTime - $firstPendingTime ) / 3600;
110111 // After three days, just use days
111 - if( $hours > (3*24) ) {
112 - $days = round($hours/24,0);
113 - $age = wfMsgExt('unreviewed-days',array('parsemag'),$days);
 112+ if ( $hours > ( 3 * 24 ) ) {
 113+ $days = round( $hours / 24, 0 );
 114+ $age = wfMsgExt( 'unreviewed-days', array( 'parsemag' ), $days );
114115 // If one or more hours, use hours
115 - } elseif( $hours >= 1 ) {
116 - $hours = round($hours,0);
117 - $age = wfMsgExt('unreviewed-hours',array('parsemag'),$hours);
 116+ } elseif ( $hours >= 1 ) {
 117+ $hours = round( $hours, 0 );
 118+ $age = wfMsgExt( 'unreviewed-hours', array( 'parsemag' ), $hours );
118119 } else {
119 - $age = wfMsg('unreviewed-recent'); // hot off the press :)
 120+ $age = wfMsg( 'unreviewed-recent' ); // hot off the press :)
120121 }
121 - if( $wgUser->isAllowed('unwatchedpages') ) {
 122+ if ( $wgUser->isAllowed( 'unwatchedpages' ) ) {
122123 $uw = self::usersWatching( $title );
123124 $watching = $uw
124 - ? wfMsgExt( 'unreviewed-watched', array('parsemag'), $uw )
125 - : wfMsgHtml( 'unreviewed-unwatched');
 125+ ? wfMsgExt( 'unreviewed-watched', array( 'parsemag' ), $uw )
 126+ : wfMsgHtml( 'unreviewed-unwatched' );
126127 $watching = " $watching"; // Oh-noes!
127128 } else {
128 - $uw = -1;
 129+ $uw = - 1;
129130 }
130131 $css = self::getLineClass( $hours, $uw );
131132 $css = $css ? " class='$css'" : "";
132 - $pageId = isset($row->page_id) ? $row->page_id : $row->qc_value;
 133+ $pageId = isset( $row->page_id ) ? $row->page_id : $row->qc_value;
133134 $key = wfMemcKey( 'unreviewedPages', 'underReview', $pageId );
134135 $val = $wgMemc->get( $key );
135136 # Show if a user is looking at this page
136 - if( ($val = $wgMemc->get($key)) ) {
137 - $underReview = " <b class='fr-under-review'>".wfMsgHtml('unreviewed-viewing').'</b>';
 137+ if ( ( $val = $wgMemc->get( $key ) ) ) {
 138+ $underReview = " <b class='fr-under-review'>" .
 139+ wfMsgHtml( 'unreviewed-viewing' ) . '</b>';
138140 }
139141
140 - return( "<li{$css}>{$link} {$stxt} ({$hist}) {$review}{$age}{$watching}{$underReview}</li>" );
 142+ return( "<li{$css}>{$link} {$stxt} ({$hist})" .
 143+ "{$review}{$age}{$watching}{$underReview}</li>" );
141144 }
142145
143146 /**
@@ -146,38 +149,39 @@
147150 public static function usersWatching( $title ) {
148151 global $wgMiserMode;
149152 $dbr = wfGetDB( DB_SLAVE );
150 - $count = -1;
151 - if( $wgMiserMode ) {
 153+ $count = - 1;
 154+ if ( $wgMiserMode ) {
152155 # Get a rough idea of size
153156 $count = $dbr->estimateRowCount( 'watchlist', '*',
154 - array( 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey() ),
 157+ array( 'wl_namespace' => $title->getNamespace(),
 158+ 'wl_title' => $title->getDBkey() ),
155159 __METHOD__ );
156160 }
157161 # If it is small, just COUNT() it, otherwise, stick with estimate...
158 - if( $count == -1 || $count <= 100 ) {
 162+ if ( $count == - 1 || $count <= 100 ) {
159163 global $wgCookieExpiration;
160164 # Get number of active editors watchling this
161 - $cutoff = $dbr->timestamp( wfTimestamp( TS_UNIX ) - 2*$wgCookieExpiration );
162 - $res = $dbr->select( array('watchlist','user'), '1',
163 - array( 'wl_namespace' => $title->getNamespace(),
 165+ $cutoff = $dbr->timestamp( wfTimestamp( TS_UNIX ) - 2 * $wgCookieExpiration );
 166+ $res = $dbr->select( array( 'watchlist', 'user' ), '1',
 167+ array( 'wl_namespace' => $title->getNamespace(),
164168 'wl_title' => $title->getDBkey(),
165169 'wl_user = user_id',
166170 // logged in or out
167 - 'user_touched > '.$dbr->addQuotes( $cutoff ) ),
 171+ 'user_touched > ' . $dbr->addQuotes( $cutoff ) ),
168172 __METHOD__,
169 - array( 'USE INDEX' => array('watchlist' => 'namespace_title') )
 173+ array( 'USE INDEX' => array( 'watchlist' => 'namespace_title' ) )
170174 );
171 - $count = $dbr->numRows($res);
 175+ $count = $dbr->numRows( $res );
172176 }
173177 return $count;
174178 }
175179
176180 protected static function getLineClass( $hours, $uw ) {
177 - if( $uw == 0 )
 181+ if ( $uw == 0 )
178182 return 'fr-unreviewed-unwatched';
179 - else if( $hours > 20*24 )
 183+ else if ( $hours > 20 * 24 )
180184 return 'fr-pending-long2';
181 - else if( $hours > 7*24 )
 185+ else if ( $hours > 7 * 24 )
182186 return 'fr-pending-long';
183187 else
184188 return "";
@@ -188,19 +192,19 @@
189193 */
190194 public static function generalQueryOK() {
191195 $namespaces = FlaggedRevs::getReviewNamespaces();
192 - if( !$namespaces || !wfQueriesMustScale() ) {
 196+ if ( !$namespaces || !wfQueriesMustScale() ) {
193197 return true;
194198 }
195199 # Get est. of fraction of pages that are reviewed
196200 $dbr = wfGetDB( DB_SLAVE );
197201 $reviewedpages = $dbr->estimateRowCount( 'flaggedpages', '*', array(), __METHOD__ );
198 - $pages = $dbr->estimateRowCount( 'page', '*',
199 - array('page_namespace' => $namespaces),
 202+ $pages = $dbr->estimateRowCount( 'page', '*',
 203+ array( 'page_namespace' => $namespaces ),
200204 __METHOD__
201205 );
202 - $ratio = $pages/($pages - $reviewedpages);
 206+ $ratio = $pages / ( $pages - $reviewedpages );
203207 # If dist. is equal, # of rows scanned = $ratio * LIMIT (or until list runs out)
204 - return ($ratio <= 400);
 208+ return ( $ratio <= 400 );
205209 }
206210 }
207211
@@ -211,21 +215,23 @@
212216 public $mForm, $mConds;
213217 private $live, $namespace, $category, $showredirs;
214218
215 - function __construct( $form, $live, $namespace, $redirs=false, $category=null, $level=0 ) {
 219+ function __construct(
 220+ $form, $live, $namespace, $redirs = false, $category = null, $level = 0
 221+ ) {
216222 $this->mForm = $form;
217223 $this->live = (bool)$live;
218224 # Must be a content page...
219 -
220 - if( !is_null($namespace) ) {
221 - $namespace = intval($namespace);
 225+
 226+ if ( !is_null( $namespace ) ) {
 227+ $namespace = intval( $namespace );
222228 }
223229 $vnamespaces = FlaggedRevs::getReviewNamespaces();
224 - if( is_null($namespace) || !in_array($namespace,$vnamespaces) ) {
225 - $namespace = !$vnamespaces ? -1 : $vnamespaces[0];
 230+ if ( is_null( $namespace ) || !in_array( $namespace, $vnamespaces ) ) {
 231+ $namespace = !$vnamespaces ? - 1 : $vnamespaces[0];
226232 }
227233 $this->namespace = $namespace;
228 - $this->category = $category ? str_replace(' ','_',$category) : null;
229 - $this->level = intval($level);
 234+ $this->category = $category ? str_replace( ' ', '_', $category ) : null;
 235+ $this->level = intval( $level );
230236 $this->showredirs = (bool)$redirs;
231237 parent::__construct();
232238 // Don't get to expensive
@@ -238,14 +244,14 @@
239245 }
240246
241247 function getQueryInfo() {
242 - if( !$this->live ) {
 248+ if ( !$this->live ) {
243249 return $this->getQueryCacheInfo();
244250 }
245251 $conds = $this->mConds;
246 - $fields = array('page_namespace','page_title','page_len','page_id',
247 - 'MIN(rev_timestamp) AS creation');
 252+ $fields = array( 'page_namespace', 'page_title', 'page_len', 'page_id',
 253+ 'MIN(rev_timestamp) AS creation' );
248254 # Filter by level
249 - if( $this->level == 1 ) {
 255+ if ( $this->level == 1 ) {
250256 $conds[] = "fp_page_id IS NULL OR fp_quality = 0";
251257 } else {
252258 $conds[] = 'fp_page_id IS NULL';
@@ -253,11 +259,11 @@
254260 # Reviewable pages only
255261 $conds['page_namespace'] = $this->namespace;
256262 # No redirects
257 - if( !$this->showredirs ) {
 263+ if ( !$this->showredirs ) {
258264 $conds['page_is_redirect'] = 0;
259265 }
260266 # Filter by category
261 - if( $this->category ) {
 267+ if ( $this->category ) {
262268 $tables = array( 'categorylinks', 'page', 'flaggedpages', 'revision' );
263269 $fields[] = 'cl_sortkey';
264270 $conds['cl_to'] = $this->category;
@@ -278,20 +284,20 @@
279285 'conds' => $conds,
280286 'options' => array( 'USE INDEX' => $useIndex, 'GROUP BY' => $groupBy ),
281287 'join_conds' => array(
282 - 'revision' => array('LEFT JOIN','rev_page=page_id'), // Get creation date
283 - 'flaggedpages' => array('LEFT JOIN','fp_page_id=page_id')
 288+ 'revision' => array( 'LEFT JOIN', 'rev_page=page_id' ), // Get creation date
 289+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id=page_id' )
284290 )
285291 );
286292 }
287293
288294 function getQueryCacheInfo() {
289295 $conds = $this->mConds;
290 - $fields = array('page_namespace','page_title','page_len','qc_value',
291 - 'MIN(rev_timestamp) AS creation');
 296+ $fields = array( 'page_namespace', 'page_title', 'page_len', 'qc_value',
 297+ 'MIN(rev_timestamp) AS creation' );
292298 # Re-join on flaggedpages to double-check since things
293299 # could have changed since the cache date. Also, use
294300 # the proper cache for this level.
295 - if( $this->level == 1 ) {
 301+ if ( $this->level == 1 ) {
296302 $conds['qc_type'] = 'fr_unreviewedpages_q';
297303 $conds[] = "fp_page_id IS NULL OR fp_quality < {$this->level}";
298304 } else {
@@ -301,31 +307,31 @@
302308 # Reviewable pages only
303309 $conds['qc_namespace'] = $this->namespace;
304310 # No redirects
305 - if( !$this->showredirs ) {
 311+ if ( !$this->showredirs ) {
306312 $conds['page_is_redirect'] = 0;
307313 }
308314 $this->mIndexField = 'qc_value'; // page_id
309315 # Filter by category
310 - if( $this->category ) {
 316+ if ( $this->category ) {
311317 $tables = array( 'page', 'categorylinks', 'querycache', 'flaggedpages', 'revision' );
312318 $conds['cl_to'] = $this->category;
313319 $conds[] = 'cl_from = qc_value'; // page_id
314320 } else {
315321 $tables = array( 'page', 'querycache', 'flaggedpages', 'revision' );
316322 }
317 - $useIndex = array('querycache' => 'qc_type','page' => 'PRIMARY',
318 - 'revision' => 'page_timestamp'); // sigh...
 323+ $useIndex = array( 'querycache' => 'qc_type', 'page' => 'PRIMARY',
 324+ 'revision' => 'page_timestamp' ); // sigh...
319325 return array(
320326 'tables' => $tables,
321327 'fields' => $fields,
322328 'conds' => $conds,
323329 'options' => array( 'USE INDEX' => $useIndex, 'GROUP BY' => 'qc_value' ),
324330 'join_conds' => array(
325 - 'querycache' => array('LEFT JOIN','qc_value=page_id'),
326 - 'revision' => array('LEFT JOIN','rev_page=page_id'), // Get creation date
327 - 'flaggedpages' => array('LEFT JOIN','fp_page_id=page_id'),
328 - 'categorylinks' => array('LEFT JOIN',
329 - array('cl_from=page_id','cl_to'=>$this->category) )
 331+ 'querycache' => array( 'LEFT JOIN', 'qc_value=page_id' ),
 332+ 'revision' => array( 'LEFT JOIN', 'rev_page=page_id' ), // Get creation date
 333+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id=page_id' ),
 334+ 'categorylinks' => array( 'LEFT JOIN',
 335+ array( 'cl_from=page_id', 'cl_to' => $this->category ) )
330336 )
331337 );
332338 }
@@ -338,7 +344,7 @@
339345 wfProfileIn( __METHOD__ );
340346 # Do a link batch query
341347 $lb = new LinkBatch();
342 - while( $row = $this->mResult->fetchObject() ) {
 348+ while ( $row = $this->mResult->fetchObject() ) {
343349 $lb->add( $row->page_namespace, $row->page_title );
344350 }
345351 $lb->execute();
Index: trunk/extensions/FlaggedRevs/specialpages/UnstablePages_body.php
@@ -25,13 +25,13 @@
2626 protected function showForm() {
2727 global $wgOut, $wgScript;
2828 $namespaces = FlaggedRevs::getReviewNamespaces();
29 - $wgOut->addHTML( wfMsgExt('unstablepages-text', array('parseinline') ) );
30 - if( count($namespaces) > 1 ) {
 29+ $wgOut->addHTML( wfMsgExt( 'unstablepages-text', array( 'parseinline' ) ) );
 30+ if ( count( $namespaces ) > 1 ) {
3131 $form = Xml::openElement( 'form', array( 'name' => 'unstablepages',
3232 'action' => $wgScript, 'method' => 'get' ) );
33 - $form .= "<fieldset><legend>".wfMsg('unstablepages')."</legend>\n";
 33+ $form .= "<fieldset><legend>" . wfMsg( 'unstablepages' ) . "</legend>\n";
3434 $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . '&nbsp;';
35 - $form .= " ".Xml::submitButton( wfMsg( 'go' ) );
 35+ $form .= " " . Xml::submitButton( wfMsg( 'go' ) );
3636 $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() );
3737 $form .= "</fieldset></form>\n";
3838 $wgOut->addHTML( $form );
@@ -43,12 +43,12 @@
4444 # Take this opportunity to purge out expired configurations
4545 FlaggedRevs::purgeExpiredConfigurations();
4646 $pager = new unstablepagesPager( $this, array(), $this->namespace );
47 - if( $pager->getNumRows() ) {
 47+ if ( $pager->getNumRows() ) {
4848 $wgOut->addHTML( $pager->getNavigationBar() );
4949 $wgOut->addHTML( $pager->getBody() );
5050 $wgOut->addHTML( $pager->getNavigationBar() );
5151 } else {
52 - $wgOut->addHTML( wfMsgExt('unstablepages-none', array('parse') ) );
 52+ $wgOut->addHTML( wfMsgExt( 'unstablepages-none', array( 'parse' ) ) );
5353 }
5454 }
5555
@@ -59,11 +59,11 @@
6060 $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
6161
6262 $stitle = SpecialPage::getTitleFor( 'Stabilization' );
63 - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('unstablepages-config'),
 63+ $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml( 'unstablepages-config' ),
6464 'page=' . $title->getPrefixedUrl() );
65 - $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('unstablepages-stable'),
 65+ $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'unstablepages-stable' ),
6666 'stable=1' );
67 - if( $row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry) ) {
 67+ if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) {
6868 $expiry_description = " (" . wfMsgForContent(
6969 'protect-expiring',
7070 $wgLang->timeanddate( $row->fpc_expiry ),
@@ -84,16 +84,16 @@
8585 class UnstablePagesPager extends AlphabeticPager {
8686 public $mForm, $mConds, $namespace;
8787
88 - function __construct( $form, $conds = array(), $namespace=0 ) {
 88+ function __construct( $form, $conds = array(), $namespace = 0 ) {
8989 $this->mForm = $form;
9090 $this->mConds = $conds;
9191 # Must be a content page...
92 - if( !is_null($namespace) ) {
93 - $namespace = intval($namespace);
 92+ if ( !is_null( $namespace ) ) {
 93+ $namespace = intval( $namespace );
9494 }
9595 $vnamespaces = FlaggedRevs::getReviewNamespaces();
96 - if( is_null($namespace) || !in_array($namespace,$vnamespaces) ) {
97 - $namespace = !$vnamespaces ? -1 : $vnamespaces[0];
 96+ if ( is_null( $namespace ) || !in_array( $namespace, $vnamespaces ) ) {
 97+ $namespace = !$vnamespaces ? - 1 : $vnamespaces[0];
9898 }
9999 $this->namespace = $namespace;
100100 parent::__construct();
@@ -109,7 +109,7 @@
110110 $conds['fpc_override'] = 0;
111111 $conds['page_namespace'] = $this->namespace;
112112 return array(
113 - 'tables' => array('flaggedpage_config','page'),
 113+ 'tables' => array( 'flaggedpage_config', 'page' ),
114114 'fields' => 'page_namespace,page_title,fpc_expiry,fpc_page_id',
115115 'conds' => $conds,
116116 'options' => array()
@@ -124,7 +124,7 @@
125125 wfProfileIn( __METHOD__ );
126126 # Do a link batch query
127127 $lb = new LinkBatch();
128 - while( $row = $this->mResult->fetchObject() ) {
 128+ while ( $row = $this->mResult->fetchObject() ) {
129129 $lb->add( $row->page_namespace, $row->page_title );
130130 }
131131 $lb->execute();
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -1,5 +1,5 @@
22 <?php
3 -#(c) Aaron Schulz, Joerg Baach, 2007 GPL
 3+# (c) Aaron Schulz, Joerg Baach, 2007 GPL
44
55 if ( !defined( 'MEDIAWIKI' ) ) {
66 echo "FlaggedRevs extension\n";
@@ -34,8 +34,8 @@
3535 global $wgRequest, $wgUser, $wgOut;
3636 $confirm = $wgRequest->wasPosted()
3737 && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
38 - if( $wgUser->isAllowed( 'review' ) ) {
39 - if( $wgUser->isBlocked( !$confirm ) ) {
 38+ if ( $wgUser->isAllowed( 'review' ) ) {
 39+ if ( $wgUser->isBlocked( !$confirm ) ) {
4040 $wgOut->blockedPage();
4141 return;
4242 }
@@ -43,15 +43,15 @@
4444 $wgOut->permissionRequired( 'review' );
4545 return;
4646 }
47 - if( wfReadOnly() ) {
 47+ if ( wfReadOnly() ) {
4848 $wgOut->readOnlyPage();
4949 return;
5050 }
5151 $this->setHeaders();
5252 # Our target page
5353 $this->page = Title::newFromUrl( $wgRequest->getVal( 'target' ) );
54 - if( is_null($this->page) ) {
55 - $wgOut->showErrorPage('notargettitle', 'notargettext' );
 54+ if ( is_null( $this->page ) ) {
 55+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
5656 return;
5757 }
5858 # Param for sites with binary flagging
@@ -64,10 +64,10 @@
6565 // implicit dims for binary flag case
6666 public function implicitDims() {
6767 $tag = FlaggedRevs::binaryTagName();
68 - if( $tag ) {
69 - if( $this->approve ) {
 68+ if ( $tag ) {
 69+ if ( $this->approve ) {
7070 return array( $tag => 1 );
71 - } else if( $this->unapprove ) {
 71+ } else if ( $this->unapprove ) {
7272 return array( $tag => 0 );
7373 }
7474 }
@@ -78,18 +78,18 @@
7979 private function markReviewed() {
8080 global $wgRequest, $wgOut, $wgUser;
8181 # Must be in reviewable namespace
82 - if( !FlaggedRevs::isPageReviewable( $this->page ) ) {
83 - $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) );
 82+ if ( !FlaggedRevs::isPageReviewable( $this->page ) ) {
 83+ $wgOut->addHTML( wfMsgExt( 'revreview-main', array( 'parse' ) ) );
8484 return;
8585 }
8686 # Get revision ID
8787 $this->oldid = $wgRequest->getIntOrNull( 'oldid' );
88 - if( !$this->oldid ) {
 88+ if ( !$this->oldid ) {
8989 $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' );
9090 return;
9191 }
9292 # Check if page is protected
93 - if( !$this->page->quickUserCan( 'edit' ) ) {
 93+ if ( !$this->page->quickUserCan( 'edit' ) ) {
9494 $wgOut->permissionRequired( 'badaccess-group0' );
9595 return;
9696 }
@@ -97,32 +97,32 @@
9898 $this->templateParams = $wgRequest->getVal( 'templateParams' );
9999 $this->imageParams = $wgRequest->getVal( 'imageParams' );
100100 $this->fileVersion = $wgRequest->getVal( 'fileVersion' );
101 - $this->validatedParams = $wgRequest->getVal( 'validatedParams' );
 101+ $this->validatedParams = $wgRequest->getVal( 'validatedParams' );
102102 # Special token to discourage fiddling...
103103 $k = self::validationKey( $this->templateParams, $this->imageParams,
104104 $this->fileVersion, $this->oldid );
105 - if( $this->validatedParams !== $k ) {
 105+ if ( $this->validatedParams !== $k ) {
106106 $wgOut->permissionRequired( 'badaccess-group0' );
107107 return;
108108 }
109109 # Log comment
110110 $this->comment = $wgRequest->getText( 'wpReason' );
111111 # Additional notes (displayed at bottom of page)
112 - $this->retrieveNotes( $wgRequest->getText('wpNotes') );
 112+ $this->retrieveNotes( $wgRequest->getText( 'wpNotes' ) );
113113 # Get the revision's current flags, if any
114114 $this->oflags = FlaggedRevs::getRevisionTags( $this->page, $this->oldid );
115115 # Get our accuracy/quality dimensions
116116 $this->dims = array();
117117 $this->unapprovedTags = 0;
118118 # Fill in implicit tag data for binary flag case
119 - if( $iDims = $this->implicitDims() ) {
 119+ if ( $iDims = $this->implicitDims() ) {
120120 $this->dims = $iDims;
121121 } else {
122 - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) {
 122+ foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) {
123123 $this->dims[$tag] = $wgRequest->getIntOrNull( "wp$tag" );
124 - if( $this->dims[$tag] === 0 ) {
 124+ if ( $this->dims[$tag] === 0 ) {
125125 $this->unapprovedTags++;
126 - } elseif( is_null($this->dims[$tag]) ) {
 126+ } elseif ( is_null( $this->dims[$tag] ) ) {
127127 # This happens if we uncheck a checkbox
128128 $this->unapprovedTags++;
129129 $this->dims[$tag] = 0;
@@ -132,38 +132,38 @@
133133 $fa = FlaggedArticle::getTitleInstance( $this->page );
134134 $this->config = $fa->getVisibilitySettings();
135135 # Check permissions and validate
136 - if( !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) {
 136+ if ( !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) {
137137 $wgOut->permissionRequired( 'badaccess-group0' );
138138 return;
139139 }
140140 # We must at least rate each category as 1, the minimum
141141 # Exception: we can rate ALL as unapproved to depreciate a revision
142 - if( $this->unapprovedTags && $this->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) {
 142+ if ( $this->unapprovedTags && $this->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) {
143143 $wgOut->addWikiText( wfMsg( 'revreview-toolow' ) );
144144 $wgOut->returnToMain( false, $this->page );
145145 return;
146 - } elseif( !$wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) {
147 - $wgOut->addWikiText( wfMsg('sessionfailure') );
 146+ } elseif ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
 147+ $wgOut->addWikiText( wfMsg( 'sessionfailure' ) );
148148 $wgOut->returnToMain( false, $this->page );
149149 return;
150150 }
151151 # Submit or display info on failure
152 - if( $wgRequest->wasPosted() ) {
153 - list($approved,$status) = $this->submit();
 152+ if ( $wgRequest->wasPosted() ) {
 153+ list( $approved, $status ) = $this->submit();
154154 // Success for either flagging or unflagging
155 - if( $status === true ) {
156 - $wgOut->setPageTitle( wfMsgHtml('actioncomplete') );
 155+ if ( $status === true ) {
 156+ $wgOut->setPageTitle( wfMsgHtml( 'actioncomplete' ) );
157157 $wgOut->addHTML( $this->showSuccess( $approved, true ) );
158158 // Sync failure for flagging
159 - } elseif( is_array($status) && $approved ) {
160 - $wgOut->setPageTitle( wfMsgHtml('internalerror') );
 159+ } elseif ( is_array( $status ) && $approved ) {
 160+ $wgOut->setPageTitle( wfMsgHtml( 'internalerror' ) );
161161 $wgOut->addHTML( $this->showSyncFailure( $status, true ) );
162162 // Failure for unflagging
163 - } elseif( $status === false && !$approved ) {
 163+ } elseif ( $status === false && !$approved ) {
164164 $wgOut->redirect( $this->page->getFullUrl() );
165165 // Any other fail...
166166 } else {
167 - $wgOut->setPageTitle( wfMsgHtml('internalerror') );
 167+ $wgOut->setPageTitle( wfMsgHtml( 'internalerror' ) );
168168 $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' );
169169 $wgOut->returnToMain( false, $this->page );
170170 }
@@ -172,14 +172,14 @@
173173
174174 private function retrieveNotes( $notes = '' ) {
175175 global $wgUser;
176 - $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ?
 176+ $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) ?
177177 $notes : '';
178178 }
179179
180180 public static function AjaxReview( /*$args...*/ ) {
181181 global $wgUser;
182182 $args = func_get_args();
183 - if( wfReadOnly() ) {
 183+ if ( wfReadOnly() ) {
184184 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
185185 }
186186 $tags = FlaggedRevs::getDimensions();
@@ -187,23 +187,23 @@
188188 $form = new RevisionReview();
189189 // Each ajax url argument is of the form param|val.
190190 // This means that there is no ugly order dependance.
191 - foreach( $args as $x => $arg ) {
192 - $set = explode('|',$arg,2);
193 - if( count($set) != 2 ) {
 191+ foreach ( $args as $x => $arg ) {
 192+ $set = explode( '|', $arg, 2 );
 193+ if ( count( $set ) != 2 ) {
194194 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
195195 }
196 - list($par,$val) = $set;
 196+ list( $par, $val ) = $set;
197197 switch( $par )
198198 {
199199 case "target":
200200 $form->page = Title::newFromUrl( $val );
201 - if( is_null($form->page) || !FlaggedRevs::isPageReviewable( $form->page ) ) {
 201+ if ( is_null( $form->page ) || !FlaggedRevs::isPageReviewable( $form->page ) ) {
202202 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
203203 }
204204 break;
205205 case "oldid":
206206 $form->oldid = intval( $val );
207 - if( !$form->oldid ) {
 207+ if ( !$form->oldid ) {
208208 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
209209 }
210210 break;
@@ -235,15 +235,15 @@
236236 $form->retrieveNotes( $val );
237237 break;
238238 case "wpEditToken":
239 - if( !$wgUser->matchEditToken( $val ) ) {
 239+ if ( !$wgUser->matchEditToken( $val ) ) {
240240 return '<err#>' . wfMsgExt( 'sessionfailure', 'parseinline' );
241241 }
242242 break;
243243 default:
244244 $p = preg_replace( '/^wp/', '', $par ); // kill any "wp" prefix
245 - if( array_key_exists( $p, $tags ) ) {
246 - $form->dims[$p] = intval($val);
247 - if( $form->dims[$p] === 0 ) {
 245+ if ( array_key_exists( $p, $tags ) ) {
 246+ $form->dims[$p] = intval( $val );
 247+ if ( $form->dims[$p] === 0 ) {
248248 $form->unapprovedTags++;
249249 }
250250 }
@@ -251,40 +251,40 @@
252252 }
253253 }
254254 // No page?
255 - if( !$form->page ) {
 255+ if ( !$form->page ) {
256256 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
257257 }
258258 // Basic permission check
259259 $permErrors = $form->page->getUserPermissionsErrors( 'review', $wgUser );
260 - if( !$permErrors ) {
 260+ if ( !$permErrors ) {
261261 // User must be able to edit this page
262262 $permErrors = $form->page->getUserPermissionsErrors( 'edit', $wgUser );
263263 }
264 - if( $permErrors ) {
 264+ if ( $permErrors ) {
265265 global $wgOut;
266266 return '<err#>' . $wgOut->parse(
267267 $wgOut->formatPermissionsErrorMessage( $permErrors, 'review' )
268268 );
269269 }
270270 # Fill in implicit tag data for binary flag case
271 - if( $iDims = $form->implicitDims() ) {
 271+ if ( $iDims = $form->implicitDims() ) {
272272 $form->dims = $iDims;
273273 }
274274 // Missing params?
275 - if( count($form->dims) != count($tags) ) {
 275+ if ( count( $form->dims ) != count( $tags ) ) {
276276 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
277277 }
278278 // Incomplete review?
279 - if( !$form->oldid || is_null($form->page) ) {
 279+ if ( !$form->oldid || is_null( $form->page ) ) {
280280 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
281281 }
282 - if( $form->unapprovedTags && $form->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) {
 282+ if ( $form->unapprovedTags && $form->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) {
283283 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
284 - }
 284+ }
285285 // Doesn't match up?
286286 $k = self::validationKey( $form->templateParams, $form->imageParams,
287287 $form->fileVersion, $form->oldid );
288 - if( $form->validatedParams !== $k ) {
 288+ if ( $form->validatedParams !== $k ) {
289289 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
290290 }
291291 $fa = FlaggedArticle::getTitleInstance( $form->page );
@@ -292,16 +292,16 @@
293293 # Get the revision's current flags, if any
294294 $form->oflags = FlaggedRevs::getRevisionTags( $form->page, $form->oldid );
295295 # Check tag permissions
296 - if( !self::userCanSetFlags($form->dims,$form->oflags,$form->config) ) {
 296+ if ( !self::userCanSetFlags( $form->dims, $form->oflags, $form->config ) ) {
297297 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
298298 }
299 - list($approved,$status) = $form->submit();
300 - if( $status === true ) {
301 - $tier = FlaggedRevs::getLevelTier($form->dims)+1; // shift to 0-3
 299+ list( $approved, $status ) = $form->submit();
 300+ if ( $status === true ) {
 301+ $tier = FlaggedRevs::getLevelTier( $form->dims ) + 1; // shift to 0-3
302302 return "<suc#><t#$tier>" . $form->showSuccess( $approved );
303 - } elseif( $approved && is_array($status) ) {
 303+ } elseif ( $approved && is_array( $status ) ) {
304304 return '<err#>' . $form->showSyncFailure( $status );
305 - } elseif( $approved ) {
 305+ } elseif ( $approved ) {
306306 return '<err#>' . wfMsg( 'revreview-revnotfound' );
307307 } else { // hmmm?
308308 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
@@ -310,16 +310,16 @@
311311
312312 public function isApproval() {
313313 # If all values are set to zero, this has been unapproved
314 - if( FlaggedRevs::dimensionsEmpty() ) {
315 - if( $this->approve && !$this->unapprove )
 314+ if ( FlaggedRevs::dimensionsEmpty() ) {
 315+ if ( $this->approve && !$this->unapprove )
316316 return true; // no tags & approve param given
317 - if( $this->unapprove && !$this->approve )
 317+ if ( $this->unapprove && !$this->approve )
318318 return false;
319319 else
320320 return null; // nothing valid asserted
321321 }
322 - foreach( $this->dims as $quality => $value ) {
323 - if( $value ) return true;
 322+ foreach ( $this->dims as $quality => $value ) {
 323+ if ( $value ) return true;
324324 }
325325 return false;
326326 }
@@ -328,71 +328,71 @@
329329 global $wgUser;
330330 # If all values are set to zero, this has been unapproved
331331 $approved = $this->isApproval();
332 - if( $approved === null ) {
333 - return array(true,false); // user didn't say
 332+ if ( $approved === null ) {
 333+ return array( true, false ); // user didn't say
334334 }
335335 # Double-check permissions
336 - if( !$this->page->quickUserCan('edit')
337 - || !self::userCanSetFlags($this->dims,$this->oflags,$this->config) )
 336+ if ( !$this->page->quickUserCan( 'edit' )
 337+ || !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) )
338338 {
339 - return array($approved,false);
 339+ return array( $approved, false );
340340 }
341341 # We can only approve actual revisions...
342 - if( $approved ) {
 342+ if ( $approved ) {
343343 $rev = Revision::newFromTitle( $this->page, $this->oldid );
344344 # Do not mess with archived/deleted revisions
345 - if( is_null($rev) || $rev->mDeleted ) {
346 - return array($approved,false);
 345+ if ( is_null( $rev ) || $rev->mDeleted ) {
 346+ return array( $approved, false );
347347 }
348348 $status = $this->approveRevision( $rev );
349349 # We can only unapprove approved revisions...
350350 } else {
351351 $frev = FlaggedRevision::newFromTitle( $this->page, $this->oldid );
352352 # If we can't find this flagged rev, return to page???
353 - if( is_null($frev) ) {
354 - return array($approved,true);
 353+ if ( is_null( $frev ) ) {
 354+ return array( $approved, true );
355355 }
356356 $status = $this->unapproveRevision( $frev );
357357 }
358358 # Watch page if set to do so
359 - if( $status === true ) {
360 - if( $wgUser->getOption('flaggedrevswatch') && !$this->page->userIsWatching() ) {
 359+ if ( $status === true ) {
 360+ if ( $wgUser->getOption( 'flaggedrevswatch' ) && !$this->page->userIsWatching() ) {
361361 $dbw = wfGetDB( DB_MASTER );
362362 $dbw->begin();
363363 $wgUser->addWatch( $this->page );
364364 $dbw->commit();
365365 }
366366 }
367 - return array($approved,$status);
 367+ return array( $approved, $status );
368368 }
369369
370 - private function showSuccess( $approved, $showlinks=false ) {
 370+ private function showSuccess( $approved, $showlinks = false ) {
371371 global $wgUser;
372372 # Show success message
373373 $msg = $approved ? 'revreview-successful' : 'revreview-successful2';
374 - $form = "<div class='plainlinks'>" .wfMsgExt( $msg, array('parseinline'),
 374+ $form = "<div class='plainlinks'>" . wfMsgExt( $msg, array( 'parseinline' ),
375375 $this->page->getPrefixedText(), $this->page->getPrefixedUrl() );
376376 $msg = $approved ? 'revreview-stable1' : 'revreview-stable2';
377 - $form .= wfMsgExt( $msg, array('parse'), $this->page->getPrefixedUrl(), $this->oldid );
 377+ $form .= wfMsgExt( $msg, array( 'parse' ), $this->page->getPrefixedUrl(), $this->oldid );
378378 $form .= "</div>";
379379 # Handy links to special pages
380 - if( $showlinks && $wgUser->isAllowed( 'unreviewedpages' ) ) {
 380+ if ( $showlinks && $wgUser->isAllowed( 'unreviewedpages' ) ) {
381381 $form .= '<p>' . wfMsg( 'returnto',
382 - $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'UnreviewedPages' ) ) ).'</p>';
 382+ $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'UnreviewedPages' ) ) ) . '</p>';
383383 $form .= '<p>' . wfMsg( 'returnto',
384 - $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'OldReviewedPages' ) ) ).'</p>';
 384+ $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'OldReviewedPages' ) ) ) . '</p>';
385385 }
386386 return $form;
387387 }
388388
389 - private function showSyncFailure( $status, $showlinks=false ) {
390 - $form = wfMsgExt( 'revreview-changed', array('parse'), $this->page->getPrefixedText() );
 389+ private function showSyncFailure( $status, $showlinks = false ) {
 390+ $form = wfMsgExt( 'revreview-changed', array( 'parse' ), $this->page->getPrefixedText() );
391391 $form .= "<ul>";
392 - foreach( $status as $n => $text ) {
 392+ foreach ( $status as $n => $text ) {
393393 $form .= "<li><i>$text</i></li>\n";
394394 }
395395 $form .= "</ul>";
396 - if( $showlinks ) {
 396+ if ( $showlinks ) {
397397 $form .= wfMsg( 'returnto', $this->skin->makeLinkObj( $this->page ) );
398398 }
399399 return $form;
@@ -410,8 +410,8 @@
411411 $article = new Article( $this->page );
412412
413413 $quality = 0;
414 - if( FlaggedRevs::isQuality($this->dims) ) {
415 - $quality = FlaggedRevs::isPristine($this->dims) ? 2 : 1;
 414+ if ( FlaggedRevs::isQuality( $this->dims ) ) {
 415+ $quality = FlaggedRevs::isPristine( $this->dims ) ? 2 : 1;
416416 }
417417 # Our flags
418418 $flags = $this->dims;
@@ -420,22 +420,22 @@
421421 $lastImgTime = "0";
422422 # Our template version pointers
423423 $tmpset = $tmpParams = array();
424 - $templateMap = explode('#',trim($this->templateParams) );
425 - foreach( $templateMap as $template ) {
426 - if( !$template )
 424+ $templateMap = explode( '#', trim( $this->templateParams ) );
 425+ foreach ( $templateMap as $template ) {
 426+ if ( !$template )
427427 continue;
428428
429 - $m = explode('|',$template,2);
430 - if( !isset($m[0]) || !isset($m[1]) || !$m[0] )
 429+ $m = explode( '|', $template, 2 );
 430+ if ( !isset( $m[0] ) || !isset( $m[1] ) || !$m[0] )
431431 continue;
432432
433 - list($prefixed_text,$rev_id) = $m;
 433+ list( $prefixed_text, $rev_id ) = $m;
434434
435435 $tmp_title = Title::newFromText( $prefixed_text ); // Normalize this to be sure...
436 - if( is_null($tmp_title) )
 436+ if ( is_null( $tmp_title ) )
437437 continue; // Page must be valid!
438438
439 - if( $rev_id > $lastTempId )
 439+ if ( $rev_id > $lastTempId )
440440 $lastTempId = $rev_id;
441441
442442 $tmpset[] = array(
@@ -444,29 +444,29 @@
445445 'ft_title' => $tmp_title->getDBkey(),
446446 'ft_tmp_rev_id' => $rev_id
447447 );
448 - if( !isset($tmpParams[$tmp_title->getNamespace()]) ) {
 448+ if ( !isset( $tmpParams[$tmp_title->getNamespace()] ) ) {
449449 $tmpParams[$tmp_title->getNamespace()] = array();
450450 }
451451 $tmpParams[$tmp_title->getNamespace()][$tmp_title->getDBkey()] = $rev_id;
452452 }
453453 # Our image version pointers
454454 $imgset = $imgParams = array();
455 - $imageMap = explode('#',trim($this->imageParams) );
456 - foreach( $imageMap as $image ) {
457 - if( !$image )
 455+ $imageMap = explode( '#', trim( $this->imageParams ) );
 456+ foreach ( $imageMap as $image ) {
 457+ if ( !$image )
458458 continue;
459 - $m = explode('|',$image,3);
 459+ $m = explode( '|', $image, 3 );
460460 # Expand our parameters ... <name>#<timestamp>#<key>
461 - if( !isset($m[0]) || !isset($m[1]) || !isset($m[2]) || !$m[0] )
 461+ if ( !isset( $m[0] ) || !isset( $m[1] ) || !isset( $m[2] ) || !$m[0] )
462462 continue;
463463
464 - list($dbkey,$timestamp,$key) = $m;
 464+ list( $dbkey, $timestamp, $key ) = $m;
465465
466466 $img_title = Title::makeTitle( NS_IMAGE, $dbkey ); // Normalize
467 - if( is_null($img_title) )
 467+ if ( is_null( $img_title ) )
468468 continue; // Page must be valid!
469469
470 - if( $timestamp > $lastImgTime )
 470+ if ( $timestamp > $lastImgTime )
471471 $lastImgTime = $timestamp;
472472
473473 $imgset[] = array(
@@ -475,16 +475,16 @@
476476 'fi_img_timestamp' => $timestamp,
477477 'fi_img_sha1' => $key
478478 );
479 - if( !isset($imgParams[$img_title->getDBkey()]) ) {
 479+ if ( !isset( $imgParams[$img_title->getDBkey()] ) ) {
480480 $imgParams[$img_title->getDBkey()] = array();
481481 }
482482 $imgParams[$img_title->getDBkey()][$timestamp] = $key;
483483 }
484484 # If this is an image page, store corresponding file info
485485 $fileData = array();
486 - if( $this->page->getNamespace() == NS_IMAGE && $this->fileVersion ) {
487 - $data = explode('#',$this->fileVersion,2);
488 - if( count($data) == 2 ) {
 486+ if ( $this->page->getNamespace() == NS_IMAGE && $this->fileVersion ) {
 487+ $data = explode( '#', $this->fileVersion, 2 );
 488+ if ( count( $data ) == 2 ) {
489489 $fileData['name'] = $this->page->getDBkey();
490490 $fileData['timestamp'] = $data[0];
491491 $fileData['sha1'] = $data[1];
@@ -499,7 +499,7 @@
500500 $flaggedOutput = false;
501501 $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(),
502502 FR_TEXT | FR_MASTER );
503 - if( $oldfrev ) {
 503+ if ( $oldfrev ) {
504504 $flaggedOutput = FlaggedRevs::parseStableText( $article,
505505 $oldfrev->getRevText(), $oldfrev->getRevId() );
506506 }
@@ -507,8 +507,8 @@
508508 # Be looser on includes for templates, since they don't matter much
509509 # and strict checking breaks randomized images/metatemplates...(bug 14580)
510510 global $wgUseCurrentTemplates, $wgUseCurrentImages;
511 - $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE
512 - && $wgUseCurrentTemplates && $wgUseCurrentImages);
 511+ $noMatch = ( $rev->getTitle()->getNamespace() == NS_TEMPLATE
 512+ && $wgUseCurrentTemplates && $wgUseCurrentImages );
513513
514514 # Set our versioning params cache
515515 FlaggedRevs::setIncludeVersionCache( $rev->getId(), $tmpParams, $imgParams );
@@ -516,8 +516,8 @@
517517 $text = $rev->getText();
518518 $stableOutput = FlaggedRevs::parseStableText( $article, $text, $rev->getId() );
519519 $err =& $stableOutput->fr_includeErrors;
520 - if( !$noMatch ) { // template/files must all be specified
521 - if( !empty($err)
 520+ if ( !$noMatch ) { // template/files must all be specified
 521+ if ( !empty( $err )
522522 || $stableOutput->fr_newestImageTime > $lastImgTime
523523 || $stableOutput->fr_newestTemplateID > $lastTempId )
524524 {
@@ -529,22 +529,22 @@
530530 FlaggedRevs::clearIncludeVersionCache( $rev->getId() );
531531
532532 # Is this a duplicate review?
533 - if( $oldfrev && $flaggedOutput ) {
 533+ if ( $oldfrev && $flaggedOutput ) {
534534 $synced = true;
535 - if( $stableOutput->fr_newestImageTime != $flaggedOutput->fr_newestImageTime )
 535+ if ( $stableOutput->fr_newestImageTime != $flaggedOutput->fr_newestImageTime )
536536 $synced = false;
537 - elseif( $stableOutput->fr_newestTemplateID != $flaggedOutput->fr_newestTemplateID )
 537+ elseif ( $stableOutput->fr_newestTemplateID != $flaggedOutput->fr_newestTemplateID )
538538 $synced = false;
539 - elseif( $oldfrev->getTags() != $flags )
 539+ elseif ( $oldfrev->getTags() != $flags )
540540 $synced = false;
541 - elseif( $oldfrev->getFileSha1() != @$fileData['sha1'] )
 541+ elseif ( $oldfrev->getFileSha1() != @$fileData['sha1'] )
542542 $synced = false;
543 - elseif( $oldfrev->getComment() != $this->notes )
 543+ elseif ( $oldfrev->getComment() != $this->notes )
544544 $synced = false;
545 - elseif( $oldfrev->getQuality() != $quality )
 545+ elseif ( $oldfrev->getQuality() != $quality )
546546 $synced = false;
547547 # Don't review if the same
548 - if( $synced ) {
 548+ if ( $synced ) {
549549 wfProfileOut( __METHOD__ );
550550 return true;
551551 }
@@ -579,9 +579,9 @@
580580 # Try using the parser cache first since we didn't actually edit the current version.
581581 $parserCache = ParserCache::singleton();
582582 $poutput = $parserCache->get( $article, $wgUser );
583 - if( !$poutput
584 - || !isset($poutput->fr_newestTemplateID)
585 - || !isset($poutput->fr_newestImageTime) )
 583+ if ( !$poutput
 584+ || !isset( $poutput->fr_newestTemplateID )
 585+ || !isset( $poutput->fr_newestImageTime ) )
586586 {
587587 $options = FlaggedRevs::makeParserOptions();
588588 $poutput = $wgParser->parse( $article->getContent(), $article->mTitle, $options );
@@ -591,19 +591,19 @@
592592 # If we know that this is now the new stable version
593593 # (which it probably is), save it to the stable cache...
594594 $sv = FlaggedRevision::newFromStable( $this->page, FR_MASTER/*consistent*/ );
595 - if( $sv && $sv->getRevId() == $rev->getId() ) {
 595+ if ( $sv && $sv->getRevId() == $rev->getId() ) {
596596 global $wgParserCacheExpireTime;
597597 $this->page->invalidateCache();
598598 # Update stable cache with the revision we reviewed.
599599 # Don't cache redirects; it would go unused and complicate things.
600 - if( !Title::newFromRedirect( $text ) ) {
 600+ if ( !Title::newFromRedirect( $text ) ) {
601601 FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
602602 }
603603 # We can set the sync cache key already
604604 $includesSynced = true;
605 - if( $poutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
 605+ if ( $poutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
606606 $includesSynced = false;
607 - } elseif( $poutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) {
 607+ } elseif ( $poutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) {
608608 $includesSynced = false;
609609 }
610610 $u->fr_stableRev = $sv; // no need to re-fetch this!
@@ -617,7 +617,7 @@
618618 $stableOutput = FlaggedRevs::getPageCache( $article, $wgUser );
619619 # Clear the cache...(for page histories)
620620 $this->page->invalidateCache();
621 - if( $stableOutput !== false ) {
 621+ if ( $stableOutput !== false ) {
622622 # Reset stable cache if it existed, since we know it is the same.
623623 FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
624624 }
@@ -644,7 +644,7 @@
645645 $dbw = wfGetDB( DB_MASTER );
646646 $dbw->begin();
647647 # Delete from flaggedrevs table
648 - $dbw->delete( 'flaggedrevs',
 648+ $dbw->delete( 'flaggedrevs',
649649 array( 'fr_page_id' => $frev->getPage(), 'fr_rev_id' => $frev->getRevId() ) );
650650 # Wipe versioning params
651651 $dbw->delete( 'flaggedtemplates', array( 'ft_rev_id' => $frev->getRevId() ) );
@@ -665,7 +665,7 @@
666666 # may now be the default page.
667667 $parserCache = ParserCache::singleton();
668668 $poutput = $parserCache->get( $article, $wgUser );
669 - if( $poutput == false ) {
 669+ if ( $poutput == false ) {
670670 $text = $article->getContent();
671671 $options = FlaggedRevs::makeParserOptions();
672672 $poutput = $wgParser->parse( $text, $article->mTitle, $options );
@@ -694,12 +694,12 @@
695695 public static function validationKey( $tmpP, $imgP, $imgV, $rid ) {
696696 global $wgReviewCodes;
697697 # Fall back to $wgSecretKey/$wgProxyKey
698 - if( empty($wgReviewCodes) ) {
 698+ if ( empty( $wgReviewCodes ) ) {
699699 global $wgSecretKey, $wgProxyKey;
700700 $key = $wgSecretKey ? $wgSecretKey : $wgProxyKey;
701 - $p = md5($key.$imgP.$tmpP.$rid.$imgV);
 701+ $p = md5( $key . $imgP . $tmpP . $rid . $imgV );
702702 } else {
703 - $p = md5($wgReviewCodes[0].$imgP.$rid.$tmpP.$imgV.$wgReviewCodes[1]);
 703+ $p = md5( $wgReviewCodes[0] . $imgP . $rid . $tmpP . $imgV . $wgReviewCodes[1] );
704704 }
705705 return $p;
706706 }
@@ -716,19 +716,19 @@
717717 $restrictions = FlaggedRevs::getTagRestrictions();
718718 # Levels may not apply for some pages.
719719 # Skip this check if $config is not given.
720 - if( !is_null($config) && !self::levelAvailable($tag,$value,$config) ) {
 720+ if ( !is_null( $config ) && !self::levelAvailable( $tag, $value, $config ) ) {
721721 return false;
722722 }
723723 # No restrictions -> full access
724 - if( !isset($restrictions[$tag]) )
 724+ if ( !isset( $restrictions[$tag] ) )
725725 return true;
726726 # Validators always have full access
727 - if( $wgUser->isAllowed('validate') )
 727+ if ( $wgUser->isAllowed( 'validate' ) )
728728 return true;
729729 # Check if this user has any right that lets him/her set
730730 # up to this particular value
731 - foreach( $restrictions[$tag] as $right => $level ) {
732 - if( $value <= $level && $level > 0 && $wgUser->isAllowed($right) ) {
 731+ foreach ( $restrictions[$tag] as $right => $level ) {
 732+ if ( $value <= $level && $level > 0 && $wgUser->isAllowed( $right ) ) {
733733 return true;
734734 }
735735 }
@@ -746,18 +746,18 @@
747747 */
748748 public static function userCanSetFlags( $flags, $oldflags = array(), $config = null ) {
749749 global $wgUser;
750 - if( !$wgUser->isAllowed('review') )
 750+ if ( !$wgUser->isAllowed( 'review' ) )
751751 return false; // User is not able to review pages
752752 # Check if all of the required site flags have a valid value
753753 # that the user is allowed to set.
754 - foreach( FlaggedRevs::getDimensions() as $qal => $levels ) {
755 - $level = isset($flags[$qal]) ? $flags[$qal] : 0;
756 - $highest = count($levels) - 1; // highest valid level
757 - if( !self::userCan($qal,$level,$config) ) {
 754+ foreach ( FlaggedRevs::getDimensions() as $qal => $levels ) {
 755+ $level = isset( $flags[$qal] ) ? $flags[$qal] : 0;
 756+ $highest = count( $levels ) - 1; // highest valid level
 757+ if ( !self::userCan( $qal, $level, $config ) ) {
758758 return false; // user cannot set proposed flag
759 - } elseif( isset($oldflags[$qal]) && !self::userCan($qal,$oldflags[$qal]) ) {
 759+ } elseif ( isset( $oldflags[$qal] ) && !self::userCan( $qal, $oldflags[$qal] ) ) {
760760 return false; // user cannot change old flag ($config is ignored here)
761 - } elseif( $level < 0 || $level > $highest ) {
 761+ } elseif ( $level < 0 || $level > $highest ) {
762762 return false; // flag range is invalid
763763 }
764764 }
@@ -767,20 +767,20 @@
768768 // Check if a given level for a tag is available in $config
769769 public static function levelAvailable( $tag, $val, $config ) {
770770 global $wgFlagAvailability;
771 - if( $val == 0 )
 771+ if ( $val == 0 )
772772 return true; // unreviewed is always applicable
773 - if( !array_key_exists('select',$config) )
 773+ if ( !array_key_exists( 'select', $config ) )
774774 return true; // missing config
775 - if( isset($wgFlagAvailability[$tag]) && isset($wgFlagAvailability[$tag][$val]) ) {
 775+ if ( isset( $wgFlagAvailability[$tag] ) && isset( $wgFlagAvailability[$tag][$val] ) ) {
776776 $precedence = $wgFlagAvailability[$tag][$val];
777777 return ( $config['select'] === $precedence );
778778 }
779779 return true;
780780 }
781781
782 - public static function updateRecentChanges( $title, $revId, $rcId=false, $patrol=true ) {
 782+ public static function updateRecentChanges( $title, $revId, $rcId = false, $patrol = true ) {
783783 wfProfileIn( __METHOD__ );
784 - $revId = intval($revId);
 784+ $revId = intval( $revId );
785785 $dbw = wfGetDB( DB_MASTER );
786786 # Olders edits be marked as patrolled now...
787787 $dbw->update( 'recentchanges',
@@ -793,7 +793,7 @@
794794 );
795795 # New page patrol may be enabled. If so, the rc_id may be the first
796796 # edit and not this one. If it is different, mark it too.
797 - if( $rcId && $rcId != $revId ) {
 797+ if ( $rcId && $rcId != $revId ) {
798798 $dbw->update( 'recentchanges',
799799 array( 'rc_patrolled' => 1 ),
800800 array( 'rc_id' => $rcId,
Index: trunk/extensions/FlaggedRevs/specialpages/QualityOversight_body.php
@@ -14,7 +14,7 @@
1515 global $wgOut, $wgUser, $wgRequest, $wgFlaggedRevsOversightAge;
1616
1717 $this->setHeaders();
18 - $wgOut->addHTML( wfMsgExt('qualityoversight-list', array('parse') ) );
 18+ $wgOut->addHTML( wfMsgExt( 'qualityoversight-list', array( 'parse' ) ) );
1919
2020 $this->namespace = $wgRequest->getInt( 'namespace' );
2121 $this->level = $wgRequest->getIntOrNull( 'level' );
@@ -29,7 +29,7 @@
3030 $this->showForm();
3131
3232 $actions = $this->getActions();
33 - if( empty($actions) ) {
 33+ if ( empty( $actions ) ) {
3434 $wgOut->addWikiMsg( 'logempty' );
3535 return;
3636 }
@@ -38,7 +38,7 @@
3939 # Get extra query conds
4040 $conds = array( 'log_namespace' => $this->namespace, 'log_action' => $actions );
4141 # Get cutoff time (mainly for performance)
42 - if( !$u ) {
 42+ if ( !$u ) {
4343 $cutoff_unixtime = time() - $wgFlaggedRevsOversightAge;
4444 $cutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) );
4545 $conds[] = "log_timestamp >= $cutoff";
@@ -48,7 +48,7 @@
4949 $pager = new LogPager( $loglist, 'review', $this->user, '', '', $conds );
5050 # Insert list
5151 $logBody = $pager->getBody();
52 - if( $logBody ) {
 52+ if ( $logBody ) {
5353 $wgOut->addHTML(
5454 $pager->getNavigationBar() .
5555 $loglist->beginLogEventsList() .
@@ -63,16 +63,19 @@
6464
6565 private function showForm() {
6666 global $wgOut, $wgScript;
67 - $wgOut->addHTML(
68 - Xml::openElement( 'form', array('name' => 'qualityoversight','action' => $wgScript,'method' => 'get') ) .
69 - '<fieldset><legend>' . wfMsgHtml('qualityoversight-legend') . '</legend><p>' .
 67+ $wgOut->addHTML(
 68+ Xml::openElement( 'form', array( 'name' => 'qualityoversight',
 69+ 'action' => $wgScript, 'method' => 'get' ) ) .
 70+ '<fieldset><legend>' . wfMsgHtml( 'qualityoversight-legend' ) . '</legend><p>' .
7071 Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) .
7172 FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . '&nbsp;' .
72 - ( FlaggedRevs::qualityVersions() ?
73 - FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-all', 1 ) . '&nbsp;'
 73+ ( FlaggedRevs::qualityVersions()
 74+ ? FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-all', 1 ) .
 75+ '&nbsp;'
7476 : ""
7577 ) .
76 - Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 20, $this->user ) . '<br />' .
 78+ Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 20, $this->user ) .
 79+ '<br />' .
7780 FlaggedRevsXML::getStatusFilterMenu( $this->status ) . '&nbsp;' .
7881 FlaggedRevsXML::getAutoFilterMenu( $this->automatic ) . '&nbsp;' .
7982 Xml::submitButton( wfMsg( 'go' ) ) .
@@ -85,32 +88,32 @@
8689 * @returns array
8790 */
8891 private function getActions() {
89 - $actions = array( 'approve' => 1,'approve2' => 1,'approve-a' => 1,'approve-i' => 1,
90 - 'approve-ia' => 1,'approve2-i' => 1,'unapprove' => 1,'unapprove2' => 1 );
91 - if( $this->level === 0 ) { // sighted revisions
 92+ $actions = array( 'approve' => 1, 'approve2' => 1, 'approve-a' => 1, 'approve-i' => 1,
 93+ 'approve-ia' => 1, 'approve2-i' => 1, 'unapprove' => 1, 'unapprove2' => 1 );
 94+ if ( $this->level === 0 ) { // sighted revisions
9295 $actions['approve2'] = 0;
9396 $actions['approve2-i'] = 0;
9497 $actions['unapprove2'] = 0;
95 - } elseif( $this->level === 1 ) { // quality revisions
 98+ } elseif ( $this->level === 1 ) { // quality revisions
9699 $actions['approve'] = 0;
97100 $actions['approve-a'] = 0;
98101 $actions['approve-i'] = 0;
99102 $actions['approve-ia'] = 0;
100103 $actions['unapprove'] = 0;
101104 }
102 - if( $this->status === 1 ) { // approved first time
 105+ if ( $this->status === 1 ) { // approved first time
103106 $actions['approve'] = 0;
104107 $actions['approve-a'] = 0;
105108 $actions['approve2'] = 0;
106109 $actions['unapprove'] = 0;
107110 $actions['unapprove2'] = 0;
108 - } elseif( $this->status === 2 ) { // re-approved
 111+ } elseif ( $this->status === 2 ) { // re-approved
109112 $actions['approve-i'] = 0;
110113 $actions['approve-ia'] = 0;
111114 $actions['approve2-i'] = 0;
112115 $actions['unapprove'] = 0;
113116 $actions['unapprove2'] = 0;
114 - } elseif( $this->status === 3 ) { // depreciated
 117+ } elseif ( $this->status === 3 ) { // depreciated
115118 $actions['approve'] = 0;
116119 $actions['approve-a'] = 0;
117120 $actions['approve-i'] = 0;
@@ -118,10 +121,10 @@
119122 $actions['approve2'] = 0;
120123 $actions['approve2-i'] = 0;
121124 }
122 - if( $this->automatic === 0 ) { // manual review
 125+ if ( $this->automatic === 0 ) { // manual review
123126 $actions['approve-a'] = 0;
124127 $actions['approve-ia'] = 0;
125 - } elseif( $this->automatic === 1 ) { // auto-reviewed
 128+ } elseif ( $this->automatic === 1 ) { // auto-reviewed
126129 $actions['approve'] = 0;
127130 $actions['approve-i'] = 0;
128131 $actions['approve2'] = 0;
@@ -130,8 +133,8 @@
131134 $actions['unapprove2'] = 0;
132135 }
133136 $showActions = array();
134 - foreach( $actions as $action => $show ) {
135 - if( $show )
 137+ foreach ( $actions as $action => $show ) {
 138+ if ( $show )
136139 $showActions[] = $action;
137140 }
138141 return $showActions;
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php
@@ -20,9 +20,9 @@
2121 $this->page = Title::newFromUrl( $this->target );
2222 # Revision ID
2323 $this->oldid = $wgRequest->getVal( 'oldid' );
24 - $this->oldid = ($this->oldid=='best') ? 'best' : intval($this->oldid);
 24+ $this->oldid = ( $this->oldid == 'best' ) ? 'best' : intval( $this->oldid );
2525 # We need a page...
26 - if( is_null($this->page) ) {
 26+ if ( is_null( $this->page ) ) {
2727 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
2828 return;
2929 }
@@ -33,21 +33,21 @@
3434 protected function showStableList() {
3535 global $wgOut, $wgUser;
3636 # Must be a content page
37 - if( !FlaggedRevs::isPageReviewable( $this->page ) ) {
38 - $wgOut->addHTML( wfMsgExt('reviewedversions-none', array('parse'),
 37+ if ( !FlaggedRevs::isPageReviewable( $this->page ) ) {
 38+ $wgOut->addHTML( wfMsgExt( 'reviewedversions-none', array( 'parse' ),
3939 $this->page->getPrefixedText() ) );
4040 return;
4141 }
4242 $pager = new ReviewedVersionsPager( $this, array(), $this->page );
4343 $num = $pager->getNumRows();
44 - if( $num ) {
45 - $wgOut->addHTML( wfMsgExt('reviewedversions-list', array('parse'),
 44+ if ( $num ) {
 45+ $wgOut->addHTML( wfMsgExt( 'reviewedversions-list', array( 'parse' ),
4646 $this->page->getPrefixedText(), $num ) );
4747 $wgOut->addHTML( $pager->getNavigationBar() );
4848 $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" );
4949 $wgOut->addHTML( $pager->getNavigationBar() );
5050 } else {
51 - $wgOut->addHTML( wfMsgExt('reviewedversions-none', array('parse'),
 51+ $wgOut->addHTML( wfMsgExt( 'reviewedversions-none', array( 'parse' ),
5252 $this->page->getPrefixedText() ) );
5353 }
5454 }
@@ -64,9 +64,12 @@
6565 ' ' . $this->skin->userToolLinks( $row->fr_user, $row->user_name ),
6666 $fdate, $ftime, $row->user_name
6767 );
68 - $lev = ( $row->fr_quality >=1 ) ? wfMsgHtml('hist-quality') : wfMsgHtml('hist-stable');
69 - $link = $this->skin->makeKnownLinkObj( $this->page, $rdatim, 'stableid='.$row->fr_rev_id );
70 - return '<li>'.$link.' ('.$review.') <strong>['.$lev.']</strong></li>';
 68+ $lev = ( $row->fr_quality >= 1 )
 69+ ? wfMsgHtml( 'hist-quality' )
 70+ : wfMsgHtml( 'hist-stable' );
 71+ $link = $this->skin->makeKnownLinkObj( $this->page, $rdatim,
 72+ 'stableid=' . $row->fr_rev_id );
 73+ return '<li>' . $link . ' (' . $review . ') <strong>[' . $lev . ']</strong></li>';
7174 }
7275 }
7376
@@ -93,18 +96,18 @@
9497 $conds = $this->mConds;
9598 # Must be in a reviewable namespace
9699 $namespaces = FlaggedRevs::getReviewNamespaces();
97 - if( !in_array($this->namespace, $namespaces) ) {
 100+ if ( !in_array( $this->namespace, $namespaces ) ) {
98101 $conds[] = "1 = 0";
99102 }
100103 $conds["fr_page_id"] = $this->pageID;
101104 $conds[] = "fr_rev_id = rev_id";
102105 $conds[] = "fr_user = user_id";
103 - $conds[] = 'rev_deleted & '.Revision::DELETED_TEXT.' = 0';
 106+ $conds[] = 'rev_deleted & ' . Revision::DELETED_TEXT . ' = 0';
104107 return array(
105 - 'tables' => array('flaggedrevs','revision','user'),
 108+ 'tables' => array( 'flaggedrevs', 'revision', 'user' ),
106109 'fields' => 'fr_rev_id,fr_timestamp,rev_timestamp,fr_quality,fr_user,user_name',
107110 'conds' => $conds,
108 - 'options' => array( 'USE INDEX' => array('flaggedrevs' => 'PRIMARY') )
 111+ 'options' => array( 'USE INDEX' => array( 'flaggedrevs' => 'PRIMARY' ) )
109112 );
110113 }
111114
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php
@@ -24,16 +24,16 @@
2525 $mdt = $this->getMedianReviewWait();
2626 $pt = $this->getMeanPendingWait();
2727 $timestamp = $this->getLastUpdate();
28 - if( $timestamp != '-' ) {
 28+ if ( $timestamp != '-' ) {
2929 $date = $wgLang->date( $timestamp, true );
3030 $time = $wgLang->time( $timestamp, true );
3131 }
3232
33 - $wgOut->addWikiText( wfMsgExt( 'validationstatistics-users', array( 'parsemag' ),
34 - $wgLang->formatnum($ec), $wgLang->formatnum($rc) )
 33+ $wgOut->addWikiText( wfMsgExt( 'validationstatistics-users', array( 'parsemag' ),
 34+ $wgLang->formatnum( $ec ), $wgLang->formatnum( $rc ) )
3535 );
3636 # Most of the output depends on background queries
37 - if( !$this->readyForQuery() ) {
 37+ if ( !$this->readyForQuery() ) {
3838 return false;
3939 }
4040
@@ -41,13 +41,14 @@
4242 $dbCache = wfGetCache( CACHE_DB );
4343 $data = $dbCache->get( $key );
4444 # Is there a review time table available?
45 - if( is_array($data) && count($data) ) {
 45+ if ( is_array( $data ) && count( $data ) ) {
4646 $headerRows = $dataRows = '';
47 - foreach( $data as $percentile => $perValue ) {
48 - $headerRows .= "<th>P<sub>".intval($percentile)."</sub></th>";
49 - $dataRows .= '<td>'.$wgLang->formatTimePeriod($perValue).'</td>';
 47+ foreach ( $data as $percentile => $perValue ) {
 48+ $headerRows .= "<th>P<sub>" . intval( $percentile ) . "</sub></th>";
 49+ $dataRows .= '<td>' . $wgLang->formatTimePeriod( $perValue ) . '</td>';
5050 }
51 - $reviewChart = "<table class='wikitable flaggedrevs_stats_table' style='white-space: nowrap;'>\n";
 51+ $css = 'wikitable flaggedrevs_stats_table';
 52+ $reviewChart = "<table class='$css' style='white-space: nowrap;'>\n";
5253 $reviewChart .= "<tr align='center'>$headerRows</tr>\n";
5354 $reviewChart .= "<tr align='center'>$dataRows</tr>\n";
5455 $reviewChart .= "</table>\n";
@@ -56,45 +57,51 @@
5758 }
5859
5960 # Show review/pending time stats
60 - $wgOut->addWikiText( '<hr/>' . wfMsgExt( 'validationstatistics-time', array( 'parsemag' ),
61 - $wgLang->formatTimePeriod($mt), $wgLang->formatTimePeriod($pt),
62 - $wgLang->formatTimePeriod($mdt), $reviewChart, $date, $time )
 61+ $wgOut->addWikiText( '<hr/>' . wfMsgExt( 'validationstatistics-time', array( 'parsemag' ),
 62+ $wgLang->formatTimePeriod( $mt ), $wgLang->formatTimePeriod( $pt ),
 63+ $wgLang->formatTimePeriod( $mdt ), $reviewChart, $date, $time )
6364 );
6465
65 - $wgOut->addWikiText( wfMsg('validationstatistics-table') );
66 - $wgOut->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable flaggedrevs_stats_table' ) ) );
 66+ $wgOut->addWikiText( wfMsg( 'validationstatistics-table' ) );
 67+ $wgOut->addHTML( Xml::openElement( 'table',
 68+ array( 'class' => 'wikitable flaggedrevs_stats_table' ) ) );
6769 $wgOut->addHTML( "<tr>\n" );
6870 // Headings (for a positive grep result):
6971 // validationstatistics-ns, validationstatistics-total, validationstatistics-stable,
7072 // validationstatistics-latest, validationstatistics-synced, validationstatistics-old
7173 $msgs = array( 'ns', 'total', 'stable', 'latest', 'synced', 'old' ); // our headings
72 - foreach( $msgs as $msg ) {
73 - $wgOut->addHTML( '<th>' . wfMsgExt("validationstatistics-$msg",array('parseinline')) . '</th>' );
 74+ foreach ( $msgs as $msg ) {
 75+ $wgOut->addHTML( '<th>' .
 76+ wfMsgExt( "validationstatistics-$msg", array( 'parseinline' ) ) . '</th>' );
7477 }
7578 $wgOut->addHTML( "</tr>\n" );
7679
7780 $namespaces = FlaggedRevs::getReviewNamespaces();
78 - foreach( $namespaces as $namespace ) {
79 - $row = $this->db->selectRow( 'flaggedrevs_stats', '*', array('namespace' => $namespace) );
 81+ foreach ( $namespaces as $namespace ) {
 82+ $row = $this->db->selectRow( 'flaggedrevs_stats', '*',
 83+ array( 'namespace' => $namespace ) );
8084 $NsText = $wgContLang->getFormattedNsText( $row->namespace );
81 - $NsText = $NsText ? $NsText : wfMsgHTML('blanknamespace');
 85+ $NsText = $NsText ? $NsText : wfMsgHTML( 'blanknamespace' );
8286
8387 $percRev = intval( $row->total ) == 0
8488 ? '-' // devision by zero
8589 : $wgLang->formatnum( wfMsgExt( 'percent', array( 'escapenoentities' ),
86 - sprintf( '%4.2f', 100 * intval( $row->reviewed ) / intval( $row->total ) ) ) );
 90+ sprintf( '%4.2f', 100 * intval( $row->reviewed ) / intval( $row->total ) ) )
 91+ );
8792 $percLatest = intval( $row->total ) == 0
8893 ? '-' // devision by zero
8994 : $wgLang->formatnum( wfMsgExt( 'percent', array( 'escapenoentities' ),
90 - sprintf( '%4.2f', 100 * intval( $row->synced ) / intval( $row->total ) ) ) );
 95+ sprintf( '%4.2f', 100 * intval( $row->synced ) / intval( $row->total ) ) )
 96+ );
9197 $percSynced = intval( $row->reviewed ) == 0
9298 ? '-' // devision by zero
9399 : $wgLang->formatnum( wfMsgExt( 'percent', array( 'escapenoentities' ),
94 - sprintf( '%4.2f', 100 * intval( $row->synced ) / intval( $row->reviewed ) ) ) );
 100+ sprintf( '%4.2f', 100 * intval( $row->synced ) / intval( $row->reviewed ) ) )
 101+ );
95102 $outdated = intval( $row->reviewed ) - intval( $row->synced );
96103 $outdated = $wgLang->formatnum( max( 0, $outdated ) ); // lag between queries
97104
98 - $wgOut->addHTML(
 105+ $wgOut->addHTML(
99106 "<tr align='center'>
100107 <td>" .
101108 htmlspecialchars( $NsText ) .
@@ -103,11 +110,11 @@
104111 htmlspecialchars( $wgLang->formatnum( $row->total ) ) .
105112 "</td>
106113 <td>" .
107 - htmlspecialchars( $wgLang->formatnum( $row->reviewed ) .
 114+ htmlspecialchars( $wgLang->formatnum( $row->reviewed ) .
108115 $wgContLang->getDirMark() ) . " <i>($percRev)</i>
109116 </td>
110117 <td>" .
111 - htmlspecialchars( $wgLang->formatnum( $row->synced ) .
 118+ htmlspecialchars( $wgLang->formatnum( $row->synced ) .
112119 $wgContLang->getDirMark() ) . " <i>($percLatest)</i>
113120 </td>
114121 <td>" .
@@ -124,15 +131,15 @@
125132
126133 $data = $this->getTopFiveReviewers();
127134 # Is there a top 5 user list?
128 - if( is_array($data) && count($data) ) {
 135+ if ( is_array( $data ) && count( $data ) ) {
129136 $wgOut->addWikiMsg( 'validationstatistics-utable' );
130137
131138 $reviewChart = "<table class='wikitable flaggedrevs_stats_table' style='white-space: nowrap;'>\n";
132 - $reviewChart .= '<tr><th>'.wfMsgHtml('validationstatistics-user').
133 - '</th><th>'.wfMsgHtml('validationstatistics-reviews').'</th></tr>';
134 - foreach( $data as $userId => $reviews ) {
135 - $reviewChart .= '<tr><td>'.htmlspecialchars(User::whois($userId)).
136 - '</td><td>'.intval($reviews).'</td></tr>';
 139+ $reviewChart .= '<tr><th>' . wfMsgHtml( 'validationstatistics-user' ) .
 140+ '</th><th>' . wfMsgHtml( 'validationstatistics-reviews' ) . '</th></tr>';
 141+ foreach ( $data as $userId => $reviews ) {
 142+ $reviewChart .= '<tr><td>' . htmlspecialchars( User::whois( $userId ) ) .
 143+ '</td><td>' . intval( $reviews ) . '</td></tr>';
137144 }
138145 $reviewChart .= "</table>\n";
139146 $wgOut->addHTML( $reviewChart );
@@ -141,7 +148,7 @@
142149
143150 protected function maybeUpdate() {
144151 global $wgFlaggedRevsStatsAge;
145 - if( !$wgFlaggedRevsStatsAge ) {
 152+ if ( !$wgFlaggedRevsStatsAge ) {
146153 return false;
147154 }
148155 $dbCache = wfGetCache( CACHE_DB );
@@ -149,14 +156,14 @@
150157 $keySQL = wfMemcKey( 'flaggedrevs', 'statsUpdating' );
151158 // If a cache update is needed, do so asynchronously.
152159 // Don't trigger query while another is running.
153 - if( $dbCache->get( $key ) ) {
 160+ if ( $dbCache->get( $key ) ) {
154161 wfDebugLog( 'ValidationStatistics', __METHOD__ . " skipping, got data" );
155 - } elseif( $dbCache->get( $keySQL ) ) {
 162+ } elseif ( $dbCache->get( $keySQL ) ) {
156163 wfDebugLog( 'ValidationStatistics', __METHOD__ . " skipping, in progress" );
157164 } else {
158165 global $wgPhpCli;
159 - $ext = !empty($wgPhpCli) ? $wgPhpCli : 'php';
160 - $path = wfEscapeShellArg( dirname(__FILE__).'/../maintenance/updateStats.php' );
 166+ $ext = !empty( $wgPhpCli ) ? $wgPhpCli : 'php';
 167+ $path = wfEscapeShellArg( dirname( __FILE__ ) . '/../maintenance/updateStats.php' );
161168 $wiki = wfEscapeShellArg( wfWikiId() );
162169 $devNull = wfIsWindows() ? "NUL:" : "/dev/null";
163170 $commandLine = "$ext $path --wiki=$wiki > $devNull &";
@@ -168,7 +175,7 @@
169176 }
170177
171178 protected function readyForQuery() {
172 - if( !$this->db->tableExists( 'flaggedrevs_stats' ) ) {
 179+ if ( !$this->db->tableExists( 'flaggedrevs_stats' ) ) {
173180 return false;
174181 } else {
175182 return ( 0 != $this->db->selectField( 'flaggedrevs_stats', 'COUNT(*)' ) );
@@ -188,51 +195,51 @@
189196 }
190197
191198 protected function getMeanReviewWait() {
192 - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
 199+ if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
193200 $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_review_time' );
194 - return ($val == false ? '-' : $val );
 201+ return ( $val == false ? '-' : $val );
195202 }
196203
197204 protected function getMedianReviewWait() {
198 - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
 205+ if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
199206 $val = $this->db->selectField( 'flaggedrevs_stats2', 'med_review_time' );
200 - return ($val == false ? '-' : $val );
 207+ return ( $val == false ? '-' : $val );
201208 }
202209
203210 protected function getMeanPendingWait() {
204 - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
 211+ if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-';
205212 $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_pending_time' );
206 - return ($val == false ? '-' : $val );
 213+ return ( $val == false ? '-' : $val );
207214 }
208215
209216 protected function getLastUpdate() {
210 - if( !$this->db->tableExists( 'querycache_info' ) ) return '-';
 217+ if ( !$this->db->tableExists( 'querycache_info' ) ) return '-';
211218 $val = $this->db->selectField( 'querycache_info', 'qci_timestamp',
212 - array('qci_type' => 'validationstats') );
213 - return ($val == false ? '-' : $val );
 219+ array( 'qci_type' => 'validationstats' ) );
 220+ return ( $val == false ? '-' : $val );
214221 }
215222
216223 protected function getTopFiveReviewers() {
217224 $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
218225 $dbCache = wfGetCache( CACHE_DB );
219226 $data = $dbCache->get( $key );
220 - if( is_array($data) )
 227+ if ( is_array( $data ) )
221228 return $data; // cache hit
222 -
 229+
223230 $dbr = wfGetDB( DB_SLAVE );
224231 $cutoff = $dbr->timestamp( time() - 3600 );
225232 $res = $dbr->select( 'logging',
226 - array('log_user','COUNT(*) AS reviews'),
 233+ array( 'log_user', 'COUNT(*) AS reviews' ),
227234 array(
228235 'log_type' => 'review', // page reviews
229 - 'log_action' => array('approve','approve2','approve-i','approve2-i'), // manual approvals
230 - 'log_timestamp >= '.$dbr->addQuotes( $cutoff ) // last hour
 236+ 'log_action' => array( 'approve', 'approve2', 'approve-i', 'approve2-i' ), // manual approvals
 237+ 'log_timestamp >= ' . $dbr->addQuotes( $cutoff ) // last hour
231238 ),
232239 __METHOD__,
233240 array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => 5 )
234241 );
235242 $data = array();
236 - foreach( $res as $row ) {
 243+ foreach ( $res as $row ) {
237244 $data[$row->log_user] = $row->reviews;
238245 }
239246 // Save/cache users
Index: trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php
@@ -16,15 +16,15 @@
1717 $this->setHeaders();
1818 $this->skin = $wgUser->getSkin();
1919 $this->namespace = $wgRequest->getIntOrNull( 'namespace' );
20 - $this->level = $wgRequest->getInt( 'level', -1 );
 20+ $this->level = $wgRequest->getInt( 'level', - 1 );
2121 $this->category = trim( $wgRequest->getVal( 'category' ) );
2222 $catTitle = Title::makeTitleSafe( NS_CATEGORY, $this->category );
23 - $this->category = is_null($catTitle) ? '' : $catTitle->getText();
 23+ $this->category = is_null( $catTitle ) ? '' : $catTitle->getText();
2424 $this->size = $wgRequest->getIntOrNull( 'size' );
2525 $this->watched = $wgRequest->getCheck( 'watched' );
2626 $this->stable = $wgRequest->getCheck( 'stable' );
2727 $feedType = $wgRequest->getVal( 'feed' );
28 - if( $feedType ) {
 28+ if ( $feedType ) {
2929 return $this->feed( $feedType );
3030 }
3131 $this->setSyndicated();
@@ -52,41 +52,44 @@
5353 // Apply limit if transcluded
5454 $pager->mLimit = $limit ? $limit : $pager->mLimit;
5555 // Viewing the page normally...
56 - if( !$this->including() ) {
 56+ if ( !$this->including() ) {
5757 $action = htmlspecialchars( $wgScript );
5858 $wgOut->addHTML(
5959 "<form action=\"$action\" method=\"get\">\n" .
60 - '<fieldset><legend>' . wfMsg('oldreviewedpages-legend') . '</legend>' .
 60+ '<fieldset><legend>' . wfMsg( 'oldreviewedpages-legend' ) . '</legend>' .
6161 Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() )
6262 );
6363 $form =
64 - ( count($namespaces) > 1 ?
 64+ ( count( $namespaces ) > 1 ?
6565 "<span style='white-space: nowrap;'>" .
6666 FlaggedRevsXML::getNamespaceMenu( $this->namespace, '' ) . '</span> '
6767 : ""
6868 ) .
69 - ( FlaggedRevs::qualityVersions() ?
70 - "<span style='white-space: nowrap;'>" .
71 - FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) . '</span> '
 69+ ( FlaggedRevs::qualityVersions()
 70+ ? "<span style='white-space: nowrap;'>" .
 71+ FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) .
 72+ '</span> '
7273 : ""
7374 ) .
74 - ( (!FlaggedRevs::isStableShownByDefault() && !FlaggedRevs::forDefaultVersionOnly()) ?
75 - "<span style='white-space: nowrap;'>" .
76 - Xml::check( 'stable', $this->stable, array( 'id' => 'wpStable' ) ) .
77 - Xml::label( wfMsg('oldreviewed-stable'), 'wpStable' ) . '</span> '
 75+ ( ( !FlaggedRevs::isStableShownByDefault()
 76+ && !FlaggedRevs::forDefaultVersionOnly() )
 77+ ? "<span style='white-space: nowrap;'>" .
 78+ Xml::check( 'stable', $this->stable, array( 'id' => 'wpStable' ) ) .
 79+ Xml::label( wfMsg( 'oldreviewed-stable' ), 'wpStable' ) . '</span> '
7880 : ""
7981 );
80 - if( $form ) $form .= '<br />';
 82+ if ( $form ) $form .= '<br />';
8183 $form .=
82 - Xml::label( wfMsg("oldreviewed-category"), 'wpCategory' ) . '&nbsp;' .
83 - Xml::input( 'category', 30, $this->category, array('id' => 'wpCategory') ) . ' ' .
 84+ Xml::label( wfMsg( "oldreviewed-category" ), 'wpCategory' ) . '&nbsp;' .
 85+ Xml::input( 'category', 30, $this->category,
 86+ array( 'id' => 'wpCategory' ) ) . ' ' .
8487 ( $wgUser->getId() ?
8588 Xml::check( 'watched', $this->watched, array( 'id' => 'wpWatched' ) ) .
86 - Xml::label( wfMsg('oldreviewed-watched'), 'wpWatched' ) . ' '
 89+ Xml::label( wfMsg( 'oldreviewed-watched' ), 'wpWatched' ) . ' '
8790 : ""
8891 );
8992 $form .= '<br />' .
90 - Xml::label( wfMsg('oldreviewed-size'), 'wpSize' ) .
 93+ Xml::label( wfMsg( 'oldreviewed-size' ), 'wpSize' ) .
9194 Xml::input( 'size', 4, $this->size, array( 'id' => 'wpSize' ) ) . ' ' .
9295 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
9396 "</fieldset></form>";
@@ -94,20 +97,20 @@
9598 $wgOut->addHTML( $form );
9699 # Add list output
97100 $num = $pager->getNumRows();
98 - $wgOut->addHTML( wfMsgExt('oldreviewedpages-list', array('parse'), $num ) );
99 - if( $num ) {
 101+ $wgOut->addHTML( wfMsgExt( 'oldreviewedpages-list', array( 'parse' ), $num ) );
 102+ if ( $num ) {
100103 $wgOut->addHTML( $pager->getNavigationBar() );
101104 $wgOut->addHTML( $pager->getBody() );
102105 $wgOut->addHTML( $pager->getNavigationBar() );
103106 } else {
104 - $wgOut->addHTML( wfMsgExt('oldreviewedpages-none', array('parse') ) );
 107+ $wgOut->addHTML( wfMsgExt( 'oldreviewedpages-none', array( 'parse' ) ) );
105108 }
106109 // If this page is transcluded...
107110 } else {
108 - if( $pager->getNumRows() ) {
 111+ if ( $pager->getNumRows() ) {
109112 $wgOut->addHTML( $pager->getBody() );
110113 } else {
111 - $wgOut->addHTML( wfMsgExt('oldreviewedpages-none', array('parse') ) );
 114+ $wgOut->addHTML( wfMsgExt( 'oldreviewedpages-none', array( 'parse' ) ) );
112115 }
113116 }
114117 }
@@ -116,19 +119,19 @@
117120 global $wgLang;
118121 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
119122 $limit = false;
120 - foreach( $bits as $bit ) {
121 - if( is_numeric( $bit ) )
 123+ foreach ( $bits as $bit ) {
 124+ if ( is_numeric( $bit ) )
122125 $limit = intval( $bit );
123126 $m = array();
124 - if( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
125 - $limit = intval($m[1]);
126 - if( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
 127+ if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
 128+ $limit = intval( $m[1] );
 129+ if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
127130 $ns = $wgLang->getNsIndex( $m[1] );
128 - if( $ns !== false ) {
 131+ if ( $ns !== false ) {
129132 $this->namespace = $ns;
130133 }
131134 }
132 - if( preg_match( '/^category=(.+)$/', $bit, $m ) ) {
 135+ if ( preg_match( '/^category=(.+)$/', $bit, $m ) ) {
133136 $this->category = $m[1];
134137 }
135138 }
@@ -141,12 +144,12 @@
142145 */
143146 protected function feed( $type ) {
144147 global $wgFeed, $wgFeedClasses, $wgRequest;
145 - if( !$wgFeed ) {
 148+ if ( !$wgFeed ) {
146149 global $wgOut;
147150 $wgOut->addWikiMsg( 'feed-unavailable' );
148151 return;
149152 }
150 - if( !isset( $wgFeedClasses[$type] ) ) {
 153+ if ( !isset( $wgFeedClasses[$type] ) ) {
151154 global $wgOut;
152155 $wgOut->addWikiMsg( 'feed-invalid' );
153156 return;
@@ -162,8 +165,8 @@
163166 $pager->mLimit = min( $wgFeedLimit, $limit );
164167
165168 $feed->outHeader();
166 - if( $pager->getNumRows() > 0 ) {
167 - while( $row = $pager->mResult->fetchObject() ) {
 169+ if ( $pager->getNumRows() > 0 ) {
 170+ while ( $row = $pager->mResult->fetchObject() ) {
168171 $feed->outItem( $this->feedItem( $row ) );
169172 }
170173 }
@@ -179,7 +182,7 @@
180183
181184 protected function feedItem( $row ) {
182185 $title = Title::MakeTitle( $row->page_namespace, $row->page_title );
183 - if( $title ) {
 186+ if ( $title ) {
184187 $date = $row->pending_since;
185188 $comments = $title->getTalkPage()->getFullURL();
186189 $curRev = Revision::newFromTitle( $title );
@@ -190,7 +193,7 @@
191194 $title->getFullURL(),
192195 $date,
193196 $curRev->getUserText(),
194 - $comments);
 197+ $comments );
195198 } else {
196199 return null;
197200 }
@@ -203,40 +206,41 @@
204207 $link = $this->skin->makeKnownLinkObj( $title );
205208 $css = $stxt = $review = $quality = $underReview = '';
206209 $stxt = ChangesList::showCharacterDifference( $row->rev_len, $row->page_len );
207 - $review = $this->skin->makeKnownLinkObj( $title, wfMsg('oldreviewed-diff'),
 210+ $review = $this->skin->makeKnownLinkObj( $title, wfMsg( 'oldreviewed-diff' ),
208211 "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" );
209212 # Show quality level if there are several
210 - if( FlaggedRevs::qualityVersions() ) {
 213+ if ( FlaggedRevs::qualityVersions() ) {
211214 $quality = $row->quality ?
212 - wfMsgHtml('revreview-lev-quality') : wfMsgHtml('revreview-lev-sighted');
 215+ wfMsgHtml( 'revreview-lev-quality' ) : wfMsgHtml( 'revreview-lev-sighted' );
213216 $quality = " <b>[{$quality}]</b>";
214217 }
215218 # Is anybody watching?
216 - if( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) {
 219+ if ( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) {
217220 $uw = UnreviewedPages::usersWatching( $title );
218 - $watching = $uw ?
219 - wfMsgExt( 'oldreviewedpages-watched', 'parsemag', $uw ) : wfMsgHtml( 'oldreviewedpages-unwatched' );
 221+ $watching = $uw
 222+ ? wfMsgExt( 'oldreviewedpages-watched', 'parsemag', $uw )
 223+ : wfMsgHtml( 'oldreviewedpages-unwatched' );
220224 $watching = " {$watching}";
221225 } else {
222 - $uw = -1;
 226+ $uw = - 1;
223227 $watching = ''; // leave out data
224228 }
225229 # Get how long the first unreviewed edit has been waiting...
226 - if( $row->pending_since ) {
 230+ if ( $row->pending_since ) {
227231 static $currentTime;
228232 $currentTime = wfTimestamp( TS_UNIX ); // now
229233 $firstPendingTime = wfTimestamp( TS_UNIX, $row->pending_since );
230 - $hours = ($currentTime - $firstPendingTime)/3600;
 234+ $hours = ( $currentTime - $firstPendingTime ) / 3600;
231235 // After three days, just use days
232 - if( $hours > (3*24) ) {
233 - $days = round($hours/24,0);
234 - $age = wfMsgExt('oldreviewedpages-days',array('parsemag'),$days);
 236+ if ( $hours > ( 3 * 24 ) ) {
 237+ $days = round( $hours / 24, 0 );
 238+ $age = wfMsgExt( 'oldreviewedpages-days', array( 'parsemag' ), $days );
235239 // If one or more hours, use hours
236 - } elseif( $hours >= 1 ) {
237 - $hours = round($hours,0);
238 - $age = wfMsgExt('oldreviewedpages-hours',array('parsemag'),$hours);
 240+ } elseif ( $hours >= 1 ) {
 241+ $hours = round( $hours, 0 );
 242+ $age = wfMsgExt( 'oldreviewedpages-hours', array( 'parsemag' ), $hours );
239243 } else {
240 - $age = wfMsg('oldreviewedpages-recent'); // hot off the press :)
 244+ $age = wfMsg( 'oldreviewedpages-recent' ); // hot off the press :)
241245 }
242246 // Oh-noes!
243247 $css = self::getLineClass( $hours, $uw );
@@ -246,11 +250,13 @@
247251 }
248252 $key = wfMemcKey( 'stableDiffs', 'underReview', $row->stable, $row->page_latest );
249253 # Show if a user is looking at this page
250 - if( ($val = $wgMemc->get($key)) ) {
251 - $underReview = " <b class='fr-under-review'>".wfMsgHtml('oldreviewedpages-viewing').'</b>';
 254+ if ( ( $val = $wgMemc->get( $key ) ) ) {
 255+ $underReview = " <b class='fr-under-review'>" .
 256+ wfMsgHtml( 'oldreviewedpages-viewing' ) . '</b>';
252257 }
253258
254 - return( "<li{$css}>{$link} {$stxt} ({$review}) <i>{$age}</i>{$quality}{$watching}{$underReview}</li>" );
 259+ return( "<li{$css}>{$link} {$stxt} ({$review}) <i>{$age}</i>" .
 260+ "{$quality}{$watching}{$underReview}</li>" );
255261 }
256262
257263 /**
@@ -272,7 +278,7 @@
273279 }
274280
275281 protected static function getLineClass( $hours, $uw ) {
276 - if( $uw == 0 )
 282+ if ( $uw == 0 )
277283 return 'fr-unreviewed-unwatched';
278284 else
279285 return "";
@@ -286,26 +292,26 @@
287293 public $mForm, $mConds;
288294 private $category, $namespace;
289295
290 - function __construct(
291 - $form, $namespace, $level=-1, $category='', $size=null, $watched=false, $stable=false
292 - ) {
 296+ function __construct( $form, $namespace, $level = - 1, $category = '',
 297+ $size = null, $watched = false, $stable = false )
 298+ {
293299 $this->mForm = $form;
294300 # Must be a content page...
295301 $vnamespaces = FlaggedRevs::getReviewNamespaces();
296 - if( is_null($namespace) ) {
 302+ if ( is_null( $namespace ) ) {
297303 $namespace = $vnamespaces;
298304 } else {
299 - $namespace = intval($namespace);
 305+ $namespace = intval( $namespace );
300306 }
301307 # Sanity check
302 - if( !in_array($namespace,$vnamespaces) ) {
 308+ if ( !in_array( $namespace, $vnamespaces ) ) {
303309 $namespace = $vnamespaces;
304310 }
305311 $this->namespace = $namespace;
306312 # Sanity check level: 0 = sighted; 1 = quality; 2 = pristine
307 - $this->level = ($level >= 0 && $level <= 2) ? $level : -1;
308 - $this->category = $category ? str_replace(' ','_',$category) : null;
309 - $this->size = ($size !== null) ? intval($size) : null;
 313+ $this->level = ( $level >= 0 && $level <= 2 ) ? $level : - 1;
 314+ $this->category = $category ? str_replace( ' ', '_', $category ) : null;
 315+ $this->size = ( $size !== null ) ? intval( $size ) : null;
310316 $this->watched = (bool)$watched;
311317 $this->stable = $stable && !FlaggedRevs::isStableShownByDefault()
312318 && !FlaggedRevs::forDefaultVersionOnly();
@@ -333,9 +339,9 @@
334340 global $wgUser;
335341 $conds = $this->mConds;
336342 $tables = array( 'page', 'revision' );
337 - $fields = array('page_namespace','page_title','page_len','rev_len','page_latest');
 343+ $fields = array( 'page_namespace', 'page_title', 'page_len', 'rev_len', 'page_latest' );
338344 # Show outdated "stable" versions
339 - if( $this->level < 0 ) {
 345+ if ( $this->level < 0 ) {
340346 $tables[] = 'flaggedpages';
341347 $fields[] = 'fp_stable AS stable';
342348 $fields[] = 'fp_quality AS quality';
@@ -344,15 +350,15 @@
345351 # Overconstrain rev_page to force PK use
346352 $conds[] = 'rev_page = page_id AND rev_id = fp_stable';
347353 $conds[] = 'fp_pending_since IS NOT NULL';
348 - $useIndex = array('flaggedpages' => 'fp_pending_since','page' => 'PRIMARY');
 354+ $useIndex = array( 'flaggedpages' => 'fp_pending_since', 'page' => 'PRIMARY' );
349355 # Filter by pages configured to be stable
350 - if( $this->stable ) {
 356+ if ( $this->stable ) {
351357 $tables[] = 'flaggedpage_config';
352358 $conds[] = 'fp_page_id = fpc_page_id';
353359 $conds['fpc_override'] = 1;
354360 }
355361 # Filter by category
356 - if( $this->category ) {
 362+ if ( $this->category ) {
357363 $tables[] = 'categorylinks';
358364 $conds[] = 'cl_from = fp_page_id';
359365 $conds['cl_to'] = $this->category;
@@ -369,17 +375,18 @@
370376 # Overconstrain rev_page to force PK use
371377 $conds[] = 'rev_page = page_id AND rev_id = fpp_rev_id';
372378 $conds[] = 'fpp_pending_since IS NOT NULL';
373 - $useIndex = array('flaggedpage_pending' => 'fpp_quality_pending','page' => 'PRIMARY');
 379+ $useIndex = array( 'flaggedpage_pending' => 'fpp_quality_pending',
 380+ 'page' => 'PRIMARY' );
374381 # Filter by review level
375382 $conds['fpp_quality'] = $this->level;
376383 # Filter by pages configured to be stable
377 - if( $this->stable ) {
 384+ if ( $this->stable ) {
378385 $tables[] = 'flaggedpage_config';
379386 $conds[] = 'fpp_page_id = fpc_page_id';
380387 $conds['fpc_override'] = 1;
381388 }
382389 # Filter by category
383 - if( $this->category != '' ) {
 390+ if ( $this->category != '' ) {
384391 $tables[] = 'categorylinks';
385392 $conds[] = 'cl_from = fpp_page_id';
386393 $conds['cl_to'] = $this->category;
@@ -389,22 +396,22 @@
390397 }
391398 $fields[] = $this->mIndexField; // Pager needs this
392399 # Filter namespace
393 - if( $this->namespace !== null ) {
 400+ if ( $this->namespace !== null ) {
394401 $conds['page_namespace'] = $this->namespace;
395402 }
396403 # Filter by watchlist
397 - if( $this->watched && ($uid = $wgUser->getId()) ) {
 404+ if ( $this->watched && ( $uid = $wgUser->getId() ) ) {
398405 $tables[] = 'watchlist';
399406 $conds[] = "wl_user = '$uid'";
400407 $conds[] = 'page_namespace = wl_namespace';
401408 $conds[] = 'page_title = wl_title';
402409 }
403410 # Filter by bytes changed
404 - if( $this->size !== null && $this->size >= 0 ) {
 411+ if ( $this->size !== null && $this->size >= 0 ) {
405412 # Get absolute difference for comparison. ABS(x-y)
406413 # is broken due to mysql unsigned int design.
407 - $conds[] = 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= '.
408 - intval($this->size);
 414+ $conds[] = 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= ' .
 415+ intval( $this->size );
409416 }
410417 return array(
411418 'tables' => $tables,
@@ -422,7 +429,7 @@
423430 wfProfileIn( __METHOD__ );
424431 # Do a link batch query
425432 $lb = new LinkBatch();
426 - while( $row = $this->mResult->fetchObject() ) {
 433+ while ( $row = $this->mResult->fetchObject() ) {
427434 $lb->add( $row->page_namespace, $row->page_title );
428435 }
429436 $lb->execute();
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php
@@ -15,13 +15,13 @@
1616 global $wgRequest, $wgUser, $wgOut;
1717 $this->setHeaders();
1818 $this->skin = $wgUser->getSkin();
19 - $this->level = $wgRequest->getInt( 'level', -1 );
 19+ $this->level = $wgRequest->getInt( 'level', - 1 );
2020 $this->tag = trim( $wgRequest->getVal( 'tagfilter' ) );
2121 $this->category = trim( $wgRequest->getVal( 'category' ) );
2222 $catTitle = Title::newFromText( $this->category );
23 - $this->category = is_null($catTitle) ? '' : $catTitle->getText();
 23+ $this->category = is_null( $catTitle ) ? '' : $catTitle->getText();
2424 $feedType = $wgRequest->getVal( 'feed' );
25 - if( $feedType ) {
 25+ if ( $feedType ) {
2626 return $this->feed( $feedType );
2727 }
2828 $this->setSyndicated();
@@ -46,45 +46,47 @@
4747 // Apply limit if transcluded
4848 $pager->mLimit = $limit ? $limit : $pager->mLimit;
4949 // Viewing the page normally...
50 - if( !$this->including() ) {
 50+ if ( !$this->including() ) {
5151 $action = htmlspecialchars( $wgScript );
5252 $tagForm = ChangeTags::buildTagFilterSelector( $this->tag );
5353 $wgOut->addHTML(
5454 "<form action=\"$action\" method=\"get\">\n" .
55 - '<fieldset><legend>' . wfMsg('problemchanges-legend') . '</legend>' .
 55+ '<fieldset><legend>' . wfMsg( 'problemchanges-legend' ) . '</legend>' .
5656 Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() )
5757 );
5858 $form =
59 - ( FlaggedRevs::qualityVersions() ?
60 - "<span style='white-space: nowrap;'>" .
61 - FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) . '</span> '
 59+ ( FlaggedRevs::qualityVersions()
 60+ ? "<span style='white-space: nowrap;'>" .
 61+ FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) .
 62+ '</span> '
6263 : ""
6364 );
64 - if( count($tagForm) ) {
 65+ if ( count( $tagForm ) ) {
6566 $form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $tagForm[0] );
6667 $form .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $tagForm[1] );
6768 }
6869 $form .= '<br />' .
69 - Xml::label( wfMsg("problemchanges-category"), 'wpCategory' ) . '&nbsp;' .
70 - Xml::input( 'category', 30, $this->category, array('id' => 'wpCategory') ) . ' ';
 70+ Xml::label( wfMsg( "problemchanges-category" ), 'wpCategory' ) . '&nbsp;' .
 71+ Xml::input( 'category', 30, $this->category,
 72+ array( 'id' => 'wpCategory' ) ) . ' ';
7173 $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
7274 "</fieldset></form>";
7375 # Add filter options
7476 $wgOut->addHTML( $form );
7577 # Add list output
76 - if( $pager->getNumRows() ) {
 78+ if ( $pager->getNumRows() ) {
7779 $wgOut->addHTML( $pager->getNavigationBar() );
7880 $wgOut->addHTML( $pager->getBody() );
7981 $wgOut->addHTML( $pager->getNavigationBar() );
8082 } else {
81 - $wgOut->addHTML( wfMsgExt('problemchanges-none', array('parse') ) );
 83+ $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) );
8284 }
8385 // If this page is transcluded...
8486 } else {
85 - if( $pager->getNumRows() ) {
 87+ if ( $pager->getNumRows() ) {
8688 $wgOut->addHTML( $pager->getBody() );
8789 } else {
88 - $wgOut->addHTML( wfMsgExt('problemchanges-none', array('parse') ) );
 90+ $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) );
8991 }
9092 }
9193 }
@@ -93,15 +95,15 @@
9496 global $wgLang;
9597 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
9698 $limit = false;
97 - foreach( $bits as $bit ) {
98 - if( is_numeric( $bit ) )
 99+ foreach ( $bits as $bit ) {
 100+ if ( is_numeric( $bit ) )
99101 $limit = intval( $bit );
100102 $m = array();
101 - if( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
102 - $limit = intval($m[1]);
103 - if( preg_match( '/^category=(.+)$/', $bit, $m ) )
 103+ if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
 104+ $limit = intval( $m[1] );
 105+ if ( preg_match( '/^category=(.+)$/', $bit, $m ) )
104106 $this->category = $m[1];
105 - if( preg_match( '/^tagfilter=(.+)$/', $bit, $m ) )
 107+ if ( preg_match( '/^tagfilter=(.+)$/', $bit, $m ) )
106108 $this->tag = $m[1];
107109 }
108110 return $limit;
@@ -113,12 +115,12 @@
114116 */
115117 protected function feed( $type ) {
116118 global $wgFeed, $wgFeedClasses, $wgRequest;
117 - if( !$wgFeed ) {
 119+ if ( !$wgFeed ) {
118120 global $wgOut;
119121 $wgOut->addWikiMsg( 'feed-unavailable' );
120122 return;
121123 }
122 - if( !isset( $wgFeedClasses[$type] ) ) {
 124+ if ( !isset( $wgFeedClasses[$type] ) ) {
123125 global $wgOut;
124126 $wgOut->addWikiMsg( 'feed-invalid' );
125127 return;
@@ -134,8 +136,8 @@
135137 $pager->mLimit = min( $wgFeedLimit, $limit );
136138
137139 $feed->outHeader();
138 - if( $pager->getNumRows() > 0 ) {
139 - while( $row = $pager->mResult->fetchObject() ) {
 140+ if ( $pager->getNumRows() > 0 ) {
 141+ while ( $row = $pager->mResult->fetchObject() ) {
140142 $feed->outItem( $this->feedItem( $row ) );
141143 }
142144 }
@@ -151,7 +153,7 @@
152154
153155 protected function feedItem( $row ) {
154156 $title = Title::MakeTitle( $row->page_namespace, $row->page_title );
155 - if( $title ) {
 157+ if ( $title ) {
156158 $date = $row->pending_since;
157159 $comments = $title->getTalkPage()->getFullURL();
158160 $curRev = Revision::newFromTitle( $title );
@@ -175,41 +177,41 @@
176178 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
177179 $link = $this->skin->makeKnownLinkObj( $title );
178180 $css = $stxt = $review = $quality = $underReview = '';
179 - $review = $this->skin->makeKnownLinkObj( $title, wfMsg('oldreviewed-diff'),
 181+ $review = $this->skin->makeKnownLinkObj( $title, wfMsg( 'oldreviewed-diff' ),
180182 "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" );
181183 # Show quality level if there are several
182 - if( FlaggedRevs::qualityVersions() ) {
 184+ if ( FlaggedRevs::qualityVersions() ) {
183185 $quality = $row->quality ?
184 - wfMsgHtml('revreview-lev-quality') : wfMsgHtml('revreview-lev-sighted');
 186+ wfMsgHtml( 'revreview-lev-quality' ) : wfMsgHtml( 'revreview-lev-sighted' );
185187 $quality = " <b>[{$quality}]</b>";
186188 }
187189 # Is anybody watching?
188 - if( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) {
 190+ if ( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) {
189191 $uw = UnreviewedPages::usersWatching( $title );
190192 $watching = $uw
191193 ? wfMsgExt( 'oldreviewedpages-watched', 'parsemag', $uw )
192 - : wfMsgHtml('oldreviewedpages-unwatched');
 194+ : wfMsgHtml( 'oldreviewedpages-unwatched' );
193195 $watching = " {$watching}";
194196 } else {
195 - $uw = -1;
 197+ $uw = - 1;
196198 $watching = ''; // leave out data
197199 }
198200 # Get how long the first unreviewed edit has been waiting...
199 - if( $row->pending_since ) {
 201+ if ( $row->pending_since ) {
200202 static $currentTime;
201203 $currentTime = wfTimestamp( TS_UNIX ); // now
202204 $firstPendingTime = wfTimestamp( TS_UNIX, $row->pending_since );
203 - $hours = ($currentTime - $firstPendingTime)/3600;
 205+ $hours = ( $currentTime - $firstPendingTime ) / 3600;
204206 // After three days, just use days
205 - if( $hours > (3*24) ) {
206 - $days = round($hours/24,0);
207 - $age = wfMsgExt('oldreviewedpages-days',array('parsemag'),$days);
 207+ if ( $hours > ( 3 * 24 ) ) {
 208+ $days = round( $hours / 24, 0 );
 209+ $age = wfMsgExt( 'oldreviewedpages-days', array( 'parsemag' ), $days );
208210 // If one or more hours, use hours
209 - } elseif( $hours >= 1 ) {
210 - $hours = round($hours,0);
211 - $age = wfMsgExt('oldreviewedpages-hours',array('parsemag'),$hours);
 211+ } elseif ( $hours >= 1 ) {
 212+ $hours = round( $hours, 0 );
 213+ $age = wfMsgExt( 'oldreviewedpages-hours', array( 'parsemag' ), $hours );
212214 } else {
213 - $age = wfMsg('oldreviewedpages-recent'); // hot off the press :)
 215+ $age = wfMsg( 'oldreviewedpages-recent' ); // hot off the press :)
214216 }
215217 // Oh-noes!
216218 $css = self::getLineClass( $hours, $uw );
@@ -219,11 +221,13 @@
220222 }
221223 $key = wfMemcKey( 'stableDiffs', 'underReview', $row->stable, $row->page_latest );
222224 # Show if a user is looking at this page
223 - if( ($val = $wgMemc->get($key)) ) {
224 - $underReview = " <b class='fr-under-review'>".wfMsgHtml('oldreviewedpages-viewing').'</b>';
 225+ if ( ( $val = $wgMemc->get( $key ) ) ) {
 226+ $underReview = " <b class='fr-under-review'>" .
 227+ wfMsgHtml( 'oldreviewedpages-viewing' ) . '</b>';
225228 }
226229
227 - return( "<li{$css}>{$link} {$stxt} ({$review}) <i>{$age}</i>{$quality}{$watching}{$underReview}</li>" );
 230+ return( "<li{$css}>{$link} {$stxt} ({$review}) <i>{$age}</i>" .
 231+ "{$quality}{$watching}{$underReview}</li>" );
228232 }
229233
230234 /**
@@ -234,6 +238,7 @@
235239 */
236240 protected function getNextRevisionTimestamp( $revision, $page ) {
237241 $dbr = wfGetDB( DB_SLAVE );
 242+
238243 return $dbr->selectField( 'revision', 'rev_timestamp',
239244 array(
240245 'rev_page' => $page,
@@ -245,7 +250,7 @@
246251 }
247252
248253 protected static function getLineClass( $hours, $uw ) {
249 - if( $uw == 0 )
 254+ if ( $uw == 0 )
250255 return 'fr-unreviewed-unwatched';
251256 else
252257 return "";
@@ -259,15 +264,15 @@
260265 public $mForm, $mConds;
261266 private $category, $namespace, $tag;
262267
263 - function __construct( $form, $level=-1, $category='', $tag='' )
 268+ function __construct( $form, $level = - 1, $category = '', $tag = '' )
264269 {
265270 $this->mForm = $form;
266271 # Must be a content page...
267272 $this->namespace = FlaggedRevs::getReviewNamespaces();
268273 # Sanity check level: 0 = sighted; 1 = quality; 2 = pristine
269 - $this->level = ($level >= 0 && $level <= 2) ? $level : -1;
 274+ $this->level = ( $level >= 0 && $level <= 2 ) ? $level : - 1;
270275 $this->tag = $tag;
271 - $this->category = $category ? str_replace(' ','_',$category) : null;
 276+ $this->category = $category ? str_replace( ' ', '_', $category ) : null;
272277 parent::__construct();
273278 // Don't get to expensive
274279 $this->mLimitsShown = array( 20, 50, 100 );
@@ -289,7 +294,7 @@
290295 $fields = array( 'page_namespace' , 'page_title', 'page_latest' );
291296 $ctIndex = $wgOldChangeTagsIndex ? 'ct_rev_id' : 'change_tag_rev_tag';
292297 # Show outdated "stable" pages
293 - if( $this->level < 0 ) {
 298+ if ( $this->level < 0 ) {
294299 $fields[] = 'fp_stable AS stable';
295300 $fields[] = 'fp_quality AS quality';
296301 $fields[] = 'fp_pending_since AS pending_since';
@@ -298,19 +303,19 @@
299304 $conds[] = 'rev_page = fp_page_id';
300305 $conds[] = 'rev_id > fp_stable';
301306 $conds[] = 'ct_rev_id = rev_id';
302 - if( $this->tag != '' ) {
 307+ if ( $this->tag != '' ) {
303308 $conds['ct_tag'] = $this->tag;
304309 }
305310 $conds[] = 'page_id = fp_page_id';
306 - $useIndex = array('flaggedpages' => 'fp_pending_since', 'change_tag' => $ctIndex);
 311+ $useIndex = array( 'flaggedpages' => 'fp_pending_since', 'change_tag' => $ctIndex );
307312 # Filter by category
308 - if( $this->category != '' ) {
309 - array_unshift($tables,'categorylinks'); // order matters
 313+ if ( $this->category != '' ) {
 314+ array_unshift( $tables, 'categorylinks' ); // order matters
310315 $conds[] = 'cl_from = fp_page_id';
311316 $conds['cl_to'] = $this->category;
312317 $useIndex['categorylinks'] = 'cl_from';
313318 }
314 - array_unshift($tables,'flaggedpages'); // order matters
 319+ array_unshift( $tables, 'flaggedpages' ); // order matters
315320 $this->mIndexField = 'fp_pending_since';
316321 $groupBy = 'fp_pending_since,fp_page_id';
317322 # Show outdated pages for a specific review level
@@ -325,18 +330,18 @@
326331 $conds[] = 'rev_id > fpp_rev_id';
327332 $conds[] = 'rev_id = ct_rev_id';
328333 $conds['ct_tag'] = $this->tag;
329 - $useIndex = array('flaggedpage_pending' => 'fpp_quality_pending',
330 - 'change_tag' => $ctIndex);
 334+ $useIndex = array( 'flaggedpage_pending' => 'fpp_quality_pending',
 335+ 'change_tag' => $ctIndex );
331336 # Filter by review level
332337 $conds['fpp_quality'] = $this->level;
333338 # Filter by category
334 - if( $this->category ) {
335 - array_unshift($tables,'categorylinks'); // order matters
 339+ if ( $this->category ) {
 340+ array_unshift( $tables, 'categorylinks' ); // order matters
336341 $conds[] = 'cl_from = fpp_page_id';
337342 $conds['cl_to'] = $this->category;
338343 $useIndex['categorylinks'] = 'cl_from';
339344 }
340 - array_unshift($tables,'flaggedpage_pending'); // order matters
 345+ array_unshift( $tables, 'flaggedpage_pending' ); // order matters
341346 $this->mIndexField = 'fpp_pending_since';
342347 $groupBy = 'fpp_pending_since,fpp_page_id';
343348 }
@@ -346,7 +351,8 @@
347352 'tables' => $tables,
348353 'fields' => $fields,
349354 'conds' => $conds,
350 - 'options' => array( 'USE INDEX' => $useIndex, 'GROUP BY' => $groupBy, 'STRAIGHT_JOIN' )
 355+ 'options' => array( 'USE INDEX' => $useIndex,
 356+ 'GROUP BY' => $groupBy, 'STRAIGHT_JOIN' )
351357 );
352358 }
353359
@@ -358,7 +364,7 @@
359365 wfProfileIn( __METHOD__ );
360366 # Do a link batch query
361367 $lb = new LinkBatch();
362 - while( $row = $this->mResult->fetchObject() ) {
 368+ while ( $row = $this->mResult->fetchObject() ) {
363369 $lb->add( $row->page_namespace, $row->page_title );
364370 }
365371 $lb->execute();
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php
@@ -11,7 +11,7 @@
1212 }
1313
1414 public function execute( $par ) {
15 - global $wgRequest, $wgUser, $wgFlaggedRevPristine;
 15+ global $wgRequest, $wgUser;
1616
1717 $this->setHeaders();
1818 $this->skin = $wgUser->getSkin();
@@ -19,8 +19,8 @@
2020 # Check if there is a featured level
2121 $maxType = FlaggedRevs::pristineVersions() ? 2 : 1;
2222 $this->namespace = $wgRequest->getInt( 'namespace' );
23 - $this->type = $wgRequest->getInt( 'level', -1 );
24 - $this->type = min($this->type,$maxType);
 23+ $this->type = $wgRequest->getInt( 'level', - 1 );
 24+ $this->type = min( $this->type, $maxType );
2525 $this->hideRedirs = $wgRequest->getBool( 'hideredirs', true );
2626
2727 $this->showForm();
@@ -32,7 +32,7 @@
3333
3434 $form = Xml::openElement( 'form',
3535 array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) );
36 - $form .= "<fieldset><legend>".wfMsg('reviewedpages-leg')."</legend>\n";
 36+ $form .= "<fieldset><legend>" . wfMsg( 'reviewedpages-leg' ) . "</legend>\n";
3737
3838 // show/hide links
3939 $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
@@ -44,17 +44,17 @@
4545
4646 $fields = array();
4747 $namespaces = FlaggedRevs::getReviewNamespaces();
48 - if( count($namespaces) > 1 ) {
 48+ if ( count( $namespaces ) > 1 ) {
4949 $fields[] = FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' ';
5050 }
51 - if( FlaggedRevs::qualityVersions() ) {
 51+ if ( FlaggedRevs::qualityVersions() ) {
5252 $fields[] = FlaggedRevsXML::getLevelMenu( $this->type ) . ' ';
5353 }
54 - $form .= implode(' ',$fields) . ' ';
 54+ $form .= implode( ' ', $fields ) . ' ';
5555 $form .= $showhideredirs;
5656
57 - if( count($fields) ) {
58 - $form .= " ".Xml::submitButton( wfMsg( 'go' ) );
 57+ if ( count( $fields ) ) {
 58+ $form .= " " . Xml::submitButton( wfMsg( 'go' ) );
5959 }
6060 $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() );
6161 $form .= "</fieldset></form>\n";
@@ -65,15 +65,16 @@
6666 protected function showPageList() {
6767 global $wgOut, $wgUser, $wgLang;
6868
69 - $pager = new ReviewedPagesPager( $this, array(), $this->type, $this->namespace, $this->hideRedirs );
 69+ $pager = new ReviewedPagesPager( $this, array(), $this->type,
 70+ $this->namespace, $this->hideRedirs );
7071 $num = $pager->getNumRows();
71 - if( $num ) {
72 - $wgOut->addHTML( wfMsgExt('reviewedpages-list', array('parse'), $num ) );
 72+ if ( $num ) {
 73+ $wgOut->addHTML( wfMsgExt( 'reviewedpages-list', array( 'parse' ), $num ) );
7374 $wgOut->addHTML( $pager->getNavigationBar() );
7475 $wgOut->addHTML( $pager->getBody() );
7576 $wgOut->addHTML( $pager->getNavigationBar() );
7677 } else {
77 - $wgOut->addHTML( wfMsgExt('reviewedpages-none', array('parse') ) );
 78+ $wgOut->addHTML( wfMsgExt( 'reviewedpages-none', array( 'parse' ) ) );
7879 }
7980 }
8081
@@ -84,18 +85,18 @@
8586 $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
8687
8788 $stxt = '';
88 - if( !is_null($size = $row->page_len) ) {
89 - if( $size == 0 )
90 - $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
 89+ if ( !is_null( $size = $row->page_len ) ) {
 90+ if ( $size == 0 )
 91+ $stxt = ' <small>' . wfMsgHtml( 'historyempty' ) . '</small>';
9192 else
92 - $stxt = ' <small>' . wfMsgExt('historysize', array('parsemag'),
 93+ $stxt = ' <small>' . wfMsgExt( 'historysize', array( 'parsemag' ),
9394 $wgLang->formatNum( $size ) ) . '</small>';
9495 }
9596
9697 $SVtitle = SpecialPage::getTitleFor( 'ReviewedVersions' );
97 - $list = $this->skin->makeKnownLinkObj( $SVtitle, wfMsgHtml('reviewedpages-all'),
 98+ $list = $this->skin->makeKnownLinkObj( $SVtitle, wfMsgHtml( 'reviewedpages-all' ),
9899 'page=' . $title->getPrefixedUrl() );
99 - $best = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('reviewedpages-best'),
 100+ $best = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'reviewedpages-best' ),
100101 'stableid=best' );
101102
102103 return "<li>$link $stxt ($list) [$best]</li>";
@@ -108,17 +109,17 @@
109110 class ReviewedPagesPager extends AlphabeticPager {
110111 public $mForm, $mConds, $namespace, $type;
111112
112 - function __construct( $form, $conds = array(), $type=0, $namespace=0, $hideRedirs=1 ) {
 113+ function __construct( $form, $conds = array(), $type = 0, $namespace = 0, $hideRedirs = 1 ) {
113114 $this->mForm = $form;
114115 $this->mConds = $conds;
115116 $this->type = $type;
116117 # Must be a content page...
117 - if( !is_null($namespace) ) {
118 - $namespace = intval($namespace);
 118+ if ( !is_null( $namespace ) ) {
 119+ $namespace = intval( $namespace );
119120 }
120121 $vnamespaces = FlaggedRevs::getReviewNamespaces();
121 - if( is_null($namespace) || !in_array($namespace,$vnamespaces) ) {
122 - $namespace = !$vnamespaces ? -1 : $vnamespaces[0];
 122+ if ( is_null( $namespace ) || !in_array( $namespace, $vnamespaces ) ) {
 123+ $namespace = !$vnamespaces ? - 1 : $vnamespaces[0];
123124 }
124125 $this->namespace = $namespace;
125126 $this->hideRedirs = $hideRedirs;
@@ -134,19 +135,20 @@
135136 $conds = $this->mConds;
136137 $conds[] = 'page_id = fp_page_id';
137138 $index = 'PRIMARY';
138 - if( $this->type >= 0 ) {
 139+ if ( $this->type >= 0 ) {
139140 $conds['fp_quality'] = $this->type;
140141 $index = 'fp_quality_page';
141142 }
142 - if( $this->hideRedirs ) {
 143+ if ( $this->hideRedirs ) {
143144 $conds['page_is_redirect'] = 0;
144145 }
145146 $conds['page_namespace'] = $this->namespace; // Sanity check NS
146147 return array(
147 - 'tables' => array('flaggedpages','page'),
 148+ 'tables' => array( 'flaggedpages', 'page' ),
148149 'fields' => 'page_namespace,page_title,page_len,fp_page_id',
149150 'conds' => $conds,
150 - 'options' => array( 'USE INDEX' => array('flaggedpages' => $index,'page' => 'PRIMARY') )
 151+ 'options' => array( 'USE INDEX' => array( 'flaggedpages' => $index,
 152+ 'page' => 'PRIMARY' ) )
151153 );
152154 }
153155
@@ -158,7 +160,7 @@
159161 wfProfileIn( __METHOD__ );
160162 # Do a link batch query
161163 $lb = new LinkBatch();
162 - while( $row = $this->mResult->fetchObject() ) {
 164+ while ( $row = $this->mResult->fetchObject() ) {
163165 $lb->add( $row->page_namespace, $row->page_title );
164166 }
165167 $lb->execute();
Index: trunk/extensions/FlaggedRevs/specialpages/StablePages_body.php
@@ -25,21 +25,22 @@
2626
2727 protected function showForm() {
2828 global $wgOut, $wgScript;
29 - $wgOut->addHTML( wfMsgExt('stablepages-text', array('parseinline') ) );
 29+ $wgOut->addHTML( wfMsgExt( 'stablepages-text', array( 'parseinline' ) ) );
3030 $fields = array();
3131 $namespaces = FlaggedRevs::getReviewNamespaces();
32 - if( count($namespaces) > 1 ) {
 32+ if ( count( $namespaces ) > 1 ) {
3333 $fields[] = FlaggedRevsXML::getNamespaceMenu( $this->namespace );
3434 }
35 - if( FlaggedRevs::qualityVersions() ) {
36 - $fields[] = Xml::label( wfMsg('stablepages-precedence'), 'wpPrecedence' ) .
 35+ if ( FlaggedRevs::qualityVersions() ) {
 36+ $fields[] = Xml::label( wfMsg( 'stablepages-precedence' ), 'wpPrecedence' ) .
3737 '&nbsp;' . FlaggedRevsXML::getPrecedenceMenu( $this->precedence );
3838 }
39 - if( count($fields) ) {
40 - $form = Xml::openElement( 'form', array( 'name' => 'stablepages', 'action' => $wgScript, 'method' => 'get' ) );
41 - $form .= "<fieldset><legend>".wfMsg('stablepages')."</legend>\n";
42 - $form .= implode('&nbsp;',$fields) . '&nbsp';
43 - $form .= " ".Xml::submitButton( wfMsg( 'go' ) );
 39+ if ( count( $fields ) ) {
 40+ $form = Xml::openElement( 'form', array( 'name' => 'stablepages',
 41+ 'action' => $wgScript, 'method' => 'get' ) );
 42+ $form .= "<fieldset><legend>" . wfMsg( 'stablepages' ) . "</legend>\n";
 43+ $form .= implode( '&nbsp;', $fields ) . '&nbsp';
 44+ $form .= " " . Xml::submitButton( wfMsg( 'go' ) );
4445 $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() );
4546 $form .= "</fieldset>\n";
4647 $form .= Xml::closeElement( 'form' );
@@ -52,12 +53,12 @@
5354 # Take this opportunity to purge out expired configurations
5455 FlaggedRevs::purgeExpiredConfigurations();
5556 $pager = new StablePagesPager( $this, array(), $this->namespace, $this->precedence );
56 - if( $pager->getNumRows() ) {
 57+ if ( $pager->getNumRows() ) {
5758 $wgOut->addHTML( $pager->getNavigationBar() );
5859 $wgOut->addHTML( $pager->getBody() );
5960 $wgOut->addHTML( $pager->getNavigationBar() );
6061 } else {
61 - $wgOut->addHTML( wfMsgExt('stablepages-none', array('parse') ) );
 62+ $wgOut->addHTML( wfMsgExt( 'stablepages-none', array( 'parse' ) ) );
6263 }
6364 }
6465
@@ -68,29 +69,30 @@
6970 $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
7071
7172 $stitle = SpecialPage::getTitleFor( 'Stabilization' );
72 - if( count( FlaggedRevs::getProtectionLevels() ) ) {
73 - $config = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('stablepages-config'),
 73+ if ( count( FlaggedRevs::getProtectionLevels() ) ) {
 74+ $config = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'stablepages-config' ),
7475 'action=protect' );
7576 } else {
76 - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('stablepages-config'),
 77+ $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml( 'stablepages-config' ),
7778 'page=' . $title->getPrefixedUrl() );
7879 }
79 - $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('stablepages-stable'), 'stable=1' );
 80+ $stable = $this->skin->makeKnownLinkObj( $title,
 81+ wfMsgHtml( 'stablepages-stable' ), 'stable=1' );
8082
8183 $type = '';
8284 // Show precedence if there are several possible levels
83 - if( FlaggedRevs::qualityVersions() ) {
84 - if( intval($row->fpc_select) === FLAGGED_VIS_PRISTINE ) {
85 - $type = wfMsgHtml('stablepages-prec-pristine');
86 - } elseif( intval($row->fpc_select) === FLAGGED_VIS_QUALITY ) {
87 - $type = wfMsgHtml('stablepages-prec-quality');
 85+ if ( FlaggedRevs::qualityVersions() ) {
 86+ if ( intval( $row->fpc_select ) === FLAGGED_VIS_PRISTINE ) {
 87+ $type = wfMsgHtml( 'stablepages-prec-pristine' );
 88+ } elseif ( intval( $row->fpc_select ) === FLAGGED_VIS_QUALITY ) {
 89+ $type = wfMsgHtml( 'stablepages-prec-quality' );
8890 } else {
89 - $type = wfMsgHtml('stablepages-prec-none');
 91+ $type = wfMsgHtml( 'stablepages-prec-none' );
9092 }
9193 $type = " (<b>{$type}</b>) ";
9294 }
9395
94 - if( $row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry) ) {
 96+ if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) {
9597 $expiry_description = " (" . wfMsgForContent(
9698 'protect-expiring',
9799 $wgLang->timeanddate( $row->fpc_expiry ),
@@ -111,16 +113,16 @@
112114 class StablePagesPager extends AlphabeticPager {
113115 public $mForm, $mConds, $namespace;
114116
115 - function __construct( $form, $conds = array(), $namespace=0, $precedence=null ) {
 117+ function __construct( $form, $conds = array(), $namespace = 0, $precedence = null ) {
116118 $this->mForm = $form;
117119 $this->mConds = $conds;
118120 # Must be a content page...
119 - if( !is_null($namespace) ) {
120 - $namespace = intval($namespace);
 121+ if ( !is_null( $namespace ) ) {
 122+ $namespace = intval( $namespace );
121123 }
122124 $vnamespaces = FlaggedRevs::getReviewNamespaces();
123 - if( is_null($namespace) || !in_array($namespace,$vnamespaces) ) {
124 - $namespace = !$vnamespaces ? -1 : $vnamespaces[0];
 125+ if ( is_null( $namespace ) || !in_array( $namespace, $vnamespaces ) ) {
 126+ $namespace = !$vnamespaces ? - 1 : $vnamespaces[0];
125127 }
126128 $this->namespace = $namespace;
127129 $this->precedence = $precedence;
@@ -135,12 +137,12 @@
136138 $conds = $this->mConds;
137139 $conds[] = 'page_id = fpc_page_id';
138140 $conds['fpc_override'] = 1;
139 - if( $this->precedence !== null && $this->precedence >= 0 ) {
 141+ if ( $this->precedence !== null && $this->precedence >= 0 ) {
140142 $conds['fpc_select'] = $this->precedence;
141143 }
142144 $conds['page_namespace'] = $this->namespace;
143145 return array(
144 - 'tables' => array('flaggedpage_config','page'),
 146+ 'tables' => array( 'flaggedpage_config', 'page' ),
145147 'fields' => 'page_namespace,page_title,fpc_expiry,fpc_page_id,fpc_select',
146148 'conds' => $conds,
147149 'options' => array()
@@ -155,7 +157,7 @@
156158 wfProfileIn( __METHOD__ );
157159 # Do a link batch query
158160 $lb = new LinkBatch();
159 - while( $row = $this->mResult->fetchObject() ) {
 161+ while ( $row = $this->mResult->fetchObject() ) {
160162 $lb->add( $row->page_namespace, $row->page_title );
161163 }
162164 $lb->execute();
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php
@@ -7,35 +7,35 @@
88 * @param $all Mixed: Value of an item denoting all namespaces, or null to omit
99 * @returns string
1010 */
11 - public static function getNamespaceMenu( $selected=null, $all=null ) {
 11+ public static function getNamespaceMenu( $selected = null, $all = null ) {
1212 global $wgContLang;
1313 $namespaces = FlaggedRevs::getReviewNamespaces();
14 - $s = "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>";
15 - if( $selected !== '' ) {
16 - if( is_null( $selected ) ) {
 14+ $s = "<label for='namespace'>" . wfMsgHtml( 'namespace' ) . "</label>";
 15+ if ( $selected !== '' ) {
 16+ if ( is_null( $selected ) ) {
1717 # No namespace selected; let exact match work without hitting Main
1818 $selected = '';
1919 } else {
2020 # Let input be numeric strings without breaking the empty match.
21 - $selected = intval($selected);
 21+ $selected = intval( $selected );
2222 }
2323 }
2424 $s .= "\n<select id='namespace' name='namespace' class='namespaceselector'>\n";
2525 $arr = $wgContLang->getFormattedNamespaces();
26 - if( !is_null($all) ) {
 26+ if ( !is_null( $all ) ) {
2727 $arr = array( $all => wfMsg( 'namespacesall' ) ) + $arr; // should be first
2828 }
29 - foreach( $arr as $index => $name ) {
 29+ foreach ( $arr as $index => $name ) {
3030 # Content pages only (except 'all')
31 - if( $index !== $all && !in_array($index, $namespaces) ) {
 31+ if ( $index !== $all && !in_array( $index, $namespaces ) ) {
3232 continue;
3333 }
34 - $name = $index !== 0 ? $name : wfMsg('blanknamespace');
35 - if( $index === $selected ) {
36 - $s .= "\t" . Xml::element("option", array("value" => $index,
37 - "selected" => "selected"), $name) . "\n";
 34+ $name = $index !== 0 ? $name : wfMsg( 'blanknamespace' );
 35+ if ( $index === $selected ) {
 36+ $s .= "\t" . Xml::element( "option", array( "value" => $index,
 37+ "selected" => "selected" ), $name ) . "\n";
3838 } else {
39 - $s .= "\t" . Xml::element("option", array("value" => $index), $name) . "\n";
 39+ $s .= "\t" . Xml::element( "option", array( "value" => $index ), $name ) . "\n";
4040 }
4141 }
4242 $s .= "</select>\n";
@@ -49,18 +49,20 @@
5050 * @param int $max max level?
5151 * @returns string
5252 */
53 - public static function getLevelMenu( $selected=null, $all='revreview-filter-all', $max=2 ) {
54 - $s = "<label for='wpLevel'>" . wfMsgHtml('revreview-levelfilter') . "</label>&nbsp;";
55 - $s .= Xml::openElement( 'select', array('name' => 'level','id' => 'wpLevel') );
56 - if( $all !== false )
57 - $s .= Xml::option( wfMsg( $all ), -1, $selected===-1 );
58 - $s .= Xml::option( wfMsg( 'revreview-lev-sighted' ), 0, $selected===0 );
59 - if( FlaggedRevs::qualityVersions() )
60 - $s .= Xml::option( wfMsg( 'revreview-lev-quality' ), 1, $selected===1 );
61 - if( $max >= 2 && FlaggedRevs::pristineVersions() )
62 - $s .= Xml::option( wfMsg( 'revreview-lev-pristine' ), 2, $selected===2 );
 53+ public static function getLevelMenu(
 54+ $selected = null, $all = 'revreview-filter-all', $max = 2
 55+ ) {
 56+ $s = "<label for='wpLevel'>" . wfMsgHtml( 'revreview-levelfilter' ) . "</label>&nbsp;";
 57+ $s .= Xml::openElement( 'select', array( 'name' => 'level', 'id' => 'wpLevel' ) );
 58+ if ( $all !== false )
 59+ $s .= Xml::option( wfMsg( $all ), - 1, $selected === - 1 );
 60+ $s .= Xml::option( wfMsg( 'revreview-lev-sighted' ), 0, $selected === 0 );
 61+ if ( FlaggedRevs::qualityVersions() )
 62+ $s .= Xml::option( wfMsg( 'revreview-lev-quality' ), 1, $selected === 1 );
 63+ if ( $max >= 2 && FlaggedRevs::pristineVersions() )
 64+ $s .= Xml::option( wfMsg( 'revreview-lev-pristine' ), 2, $selected === 2 );
6365 # Note: Pristine not tracked at sp:QualityOversight (counts as quality)
64 - $s .= Xml::closeElement('select')."\n";
 66+ $s .= Xml::closeElement( 'select' ) . "\n";
6567 return $s;
6668 }
6769
@@ -68,18 +70,19 @@
6971 * Get a radio options of available precendents
7072 * @param int $selected, selected level
7173 * @returns string
72 - */
73 - public static function getPrecedenceMenu( $selected=null ) {
74 - $s = Xml::openElement( 'select', array('name' => 'precedence','id' => 'wpPrecedence') );
 74+ */
 75+ public static function getPrecedenceMenu( $selected = null ) {
 76+ $s = Xml::openElement( 'select',
 77+ array( 'name' => 'precedence', 'id' => 'wpPrecedence' ) );
7578 $s .= Xml::option( wfMsg( 'revreview-lev-sighted' ), FLAGGED_VIS_LATEST,
76 - $selected==FLAGGED_VIS_LATEST );
77 - if( FlaggedRevs::qualityVersions() )
 79+ $selected == FLAGGED_VIS_LATEST );
 80+ if ( FlaggedRevs::qualityVersions() )
7881 $s .= Xml::option( wfMsg( 'revreview-lev-quality' ), FLAGGED_VIS_QUALITY,
79 - $selected==FLAGGED_VIS_QUALITY );
80 - if( FlaggedRevs::pristineVersions() )
 82+ $selected == FLAGGED_VIS_QUALITY );
 83+ if ( FlaggedRevs::pristineVersions() )
8184 $s .= Xml::option( wfMsg( 'revreview-lev-pristine' ), FLAGGED_VIS_PRISTINE,
82 - $selected==FLAGGED_VIS_PRISTINE );
83 - $s .= Xml::closeElement('select')."\n";
 85+ $selected == FLAGGED_VIS_PRISTINE );
 86+ $s .= Xml::closeElement( 'select' ) . "\n";
8487 return $s;
8588 }
8689
@@ -88,14 +91,14 @@
8992 * @param int $selected, selected level
9093 * @returns string
9194 */
92 - public static function getStatusFilterMenu( $selected=null ) {
93 - $s = "<label for='wpStatus'>" . wfMsgHtml('revreview-statusfilter') . "</label>&nbsp;";
94 - $s .= Xml::openElement( 'select', array('name' => 'status','id' => 'wpStatus') );
95 - $s .= Xml::option( wfMsg( "revreview-filter-all" ), -1, $selected===-1 );
96 - $s .= Xml::option( wfMsg( "revreview-filter-approved" ), 1, $selected===1 );
97 - $s .= Xml::option( wfMsg( "revreview-filter-reapproved" ), 2, $selected===2 );
98 - $s .= Xml::option( wfMsg( "revreview-filter-unapproved" ), 3, $selected===3 );
99 - $s .= Xml::closeElement('select')."\n";
 95+ public static function getStatusFilterMenu( $selected = null ) {
 96+ $s = "<label for='wpStatus'>" . wfMsgHtml( 'revreview-statusfilter' ) . "</label>&nbsp;";
 97+ $s .= Xml::openElement( 'select', array( 'name' => 'status', 'id' => 'wpStatus' ) );
 98+ $s .= Xml::option( wfMsg( "revreview-filter-all" ), - 1, $selected === - 1 );
 99+ $s .= Xml::option( wfMsg( "revreview-filter-approved" ), 1, $selected === 1 );
 100+ $s .= Xml::option( wfMsg( "revreview-filter-reapproved" ), 2, $selected === 2 );
 101+ $s .= Xml::option( wfMsg( "revreview-filter-unapproved" ), 3, $selected === 3 );
 102+ $s .= Xml::closeElement( 'select' ) . "\n";
100103 return $s;
101104 }
102105
@@ -104,13 +107,13 @@
105108 * @param int $selected, selected level
106109 * @returns string
107110 */
108 - public static function getAutoFilterMenu( $selected=null ) {
109 - $s = "<label for='wpApproved'>" . wfMsgHtml('revreview-typefilter') . "</label>&nbsp;";
110 - $s .= Xml::openElement( 'select', array('name' => 'automatic','id' => 'wpApproved') );
111 - $s .= Xml::option( wfMsg( "revreview-filter-all" ), -1, $selected===-1 );
112 - $s .= Xml::option( wfMsg( "revreview-filter-manual" ), 0, $selected===0 );
113 - $s .= Xml::option( wfMsg( "revreview-filter-auto" ), 1, $selected===1 );
114 - $s .= Xml::closeElement('select')."\n";
 111+ public static function getAutoFilterMenu( $selected = null ) {
 112+ $s = "<label for='wpApproved'>" . wfMsgHtml( 'revreview-typefilter' ) . "</label>&nbsp;";
 113+ $s .= Xml::openElement( 'select', array( 'name' => 'automatic', 'id' => 'wpApproved' ) );
 114+ $s .= Xml::option( wfMsg( "revreview-filter-all" ), - 1, $selected === - 1 );
 115+ $s .= Xml::option( wfMsg( "revreview-filter-manual" ), 0, $selected === 0 );
 116+ $s .= Xml::option( wfMsg( "revreview-filter-auto" ), 1, $selected === 1 );
 117+ $s .= Xml::closeElement( 'select' ) . "\n";
115118 return $s;
116119 }
117120
@@ -119,7 +122,7 @@
120123 * @returns string, css color for this quality
121124 */
122125 public static function getQualityColor( $quality ) {
123 - if( $quality === false )
 126+ if ( $quality === false )
124127 return 'flaggedrevs-color-0';
125128 switch( $quality ) {
126129 case 2:
@@ -142,37 +145,37 @@
143146 * @returns string
144147 * Generates a review box/tag
145148 */
146 - public static function addTagRatings( $flags, $prettyBox = false, $css='' ) {
 149+ public static function addTagRatings( $flags, $prettyBox = false, $css = '' ) {
147150 $tag = '';
148 - if( $prettyBox ) {
 151+ if ( $prettyBox ) {
149152 $tag .= "<table id='mw-fr-revisionratings-box' align='center' class='$css' cellpadding='0'>";
150153 }
151 - foreach( FlaggedRevs::getDimensions() as $quality => $x ) {
 154+ foreach ( FlaggedRevs::getDimensions() as $quality => $x ) {
152155 $level = isset( $flags[$quality] ) ? $flags[$quality] : 0;
153 - $encValueText = wfMsgHtml("revreview-$quality-$level");
 156+ $encValueText = wfMsgHtml( "revreview-$quality-$level" );
154157 $level = $flags[$quality];
155158 $minlevel = FlaggedRevs::getMinQL( $quality );
156 - if( $level >= $minlevel ) {
 159+ if ( $level >= $minlevel ) {
157160 $classmarker = 2;
158 - } elseif( $level > 0 ) {
 161+ } elseif ( $level > 0 ) {
159162 $classmarker = 1;
160163 } else {
161164 $classmarker = 0;
162165 }
163166 $levelmarker = $level * 20 + 20;
164 - if( $prettyBox ) {
 167+ if ( $prettyBox ) {
165168 $tag .= "<tr><td class='fr-text' valign='middle'>" .
166 - wfMsgHtml("revreview-$quality") .
 169+ wfMsgHtml( "revreview-$quality" ) .
167170 "</td><td class='fr-value$levelmarker' valign='middle'>" .
168171 $encValueText . "</td></tr>\n";
169172 } else {
170173 $tag .= "&nbsp;<span class='fr-marker-$levelmarker'><strong>" .
171 - wfMsgHtml("revreview-$quality") .
 174+ wfMsgHtml( "revreview-$quality" ) .
172175 "</strong>: <span class='fr-text-value'>$encValueText&nbsp;</span>&nbsp;" .
173176 "</span>\n";
174177 }
175178 }
176 - if( $prettyBox ) {
 179+ if ( $prettyBox ) {
177180 $tag .= '</table>';
178181 }
179182 return $tag;
@@ -189,7 +192,7 @@
190193 * Generates a review box using a table using FlaggedRevsXML::addTagRatings()
191194 */
192195 public static function prettyRatingBox(
193 - $frev, $shtml, $revsSince, $type='oldstable', $synced=false
 196+ $frev, $shtml, $revsSince, $type = 'oldstable', $synced = false
194197 ) {
195198 global $wgLang;
196199 # Get quality level
@@ -198,24 +201,24 @@
199202 $pristine = FlaggedRevs::isPristine( $flags );
200203 $time = $wgLang->date( $frev->getTimestamp(), true );
201204 # Some checks for which tag CSS to use
202 - if( $pristine ) {
 205+ if ( $pristine ) {
203206 $color = 'flaggedrevs-color-3';
204 - } elseif( $quality ) {
 207+ } elseif ( $quality ) {
205208 $color = 'flaggedrevs-color-2';
206209 } else {
207210 $color = 'flaggedrevs-color-1';
208211 }
209212 # Construct some tagging
210 - if( $synced && ($type == 'stable' || $type == 'draft') ) {
 213+ if ( $synced && ( $type == 'stable' || $type == 'draft' ) ) {
211214 $msg = $quality ?
212215 'revreview-quality-same' : 'revreview-basic-same';
213 - $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
214 - } elseif( $type == 'oldstable' ) {
 216+ $html = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time, $revsSince );
 217+ } elseif ( $type == 'oldstable' ) {
215218 $msg = $quality ?
216219 'revreview-quality-old' : 'revreview-basic-old';
217 - $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time );
 220+ $html = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time );
218221 } else {
219 - if( $type == 'stable' ) {
 222+ if ( $type == 'stable' ) {
220223 $msg = $quality ?
221224 'revreview-quality' : 'revreview-basic';
222225 } else { // draft
@@ -224,8 +227,8 @@
225228 }
226229 # For searching: uses messages 'revreview-quality-i', 'revreview-basic-i',
227230 # 'revreview-newest-quality-i', 'revreview-newest-basic-i'
228 - $msg .= ($revsSince == 0) ? '-i' : '';
229 - $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
 231+ $msg .= ( $revsSince == 0 ) ? '-i' : '';
 232+ $html = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time, $revsSince );
230233 }
231234 # Make fancy box...
232235 $box = "<table style='background: none; border-spacing: 0px;'>";
@@ -233,7 +236,7 @@
234237 $box .= "<td style='text-align:right;'>" . self::ratingToggle() . "</td></tr>\n";
235238 $box .= "<tr><td id='mw-fr-revisionratings'>$html<br />";
236239 # Add any rating tags as needed...
237 - if( $flags && ($type == 'stable' || $type == 'oldstable') ) {
 240+ if ( $flags && ( $type == 'stable' || $type == 'oldstable' ) ) {
238241 $box .= self::addTagRatings( $flags, true, $color );
239242 }
240243 $box .= "</td><td></td></tr></table>";
@@ -247,7 +250,7 @@
248251 public static function ratingToggle() {
249252 return "<a id='mw-fr-revisiontoggle' class='flaggedrevs_toggle' style='display:none;'" .
250253 " onclick='FlaggedRevs.toggleRevRatings()' title='" .
251 - wfMsgHtml('revreview-toggle-title') . "' >" .
 254+ wfMsgHtml( 'revreview-toggle-title' ) . "' >" .
252255 wfMsg( 'revreview-toggle' ) . "</a>";
253256 }
254257
@@ -258,7 +261,7 @@
259262 public static function diffToggle() {
260263 return "<a id='mw-fr-difftoggle' class='flaggedrevs_toggle' style='display:none;'" .
261264 " onclick='FlaggedRevs.toggleDiff()' title='" .
262 - wfMsgHtml('revreview-diff-toggle-title') . "' >" .
 265+ wfMsgHtml( 'revreview-diff-toggle-title' ) . "' >" .
263266 wfMsg( 'revreview-diff-toggle-show' ) . "</a>";
264267 }
265268
@@ -273,76 +276,76 @@
274277 public static function ratingInputs( $flags, $config, $disabled, $reviewed ) {
275278 $form = '';
276279 # Get all available tags for this page/user
277 - list($labels,$minLevels) = self::ratingFormTags( $flags, $config );
278 - if( $labels === false ) {
 280+ list( $labels, $minLevels ) = self::ratingFormTags( $flags, $config );
 281+ if ( $labels === false ) {
279282 $disabled = true; // a tag is unsettable
280283 }
281284 $dimensions = FlaggedRevs::getDimensions();
282 - $tags = array_keys($dimensions);
 285+ $tags = array_keys( $dimensions );
283286 # If there are no tags, make one checkbox to approve/unapprove
284 - if( FlaggedRevs::binaryFlagging() ) {
 287+ if ( FlaggedRevs::binaryFlagging() ) {
285288 return '';
286289 }
287290 $items = array();
288291 # Build rating form...
289 - if( $disabled ) {
 292+ if ( $disabled ) {
290293 // Display the value for each tag as text
291 - foreach( $dimensions as $quality => $levels ) {
292 - $selected = isset($flags[$quality]) ? $flags[$quality] : 0;
 294+ foreach ( $dimensions as $quality => $levels ) {
 295+ $selected = isset( $flags[$quality] ) ? $flags[$quality] : 0;
293296 $items[] = "<b>" . FlaggedRevs::getTagMsg( $quality ) . ":</b> " .
294297 FlaggedRevs::getTagValueMsg( $quality, $selected );
295298 }
296299 } else {
297 - $size = count($labels,1) - count($labels);
298 - foreach( $labels as $quality => $levels ) {
 300+ $size = count( $labels, 1 ) - count( $labels );
 301+ foreach ( $labels as $quality => $levels ) {
299302 $item = '';
300303 $numLevels = count( $levels );
301304 $minLevel = $minLevels[$quality];
302305 # Determine the level selected by default
303 - if( !empty($flags[$quality]) && isset($levels[$flags[$quality]]) ) {
 306+ if ( !empty( $flags[$quality] ) && isset( $levels[$flags[$quality]] ) ) {
304307 $selected = $flags[$quality]; // valid non-zero value
305308 } else {
306309 $selected = $minLevel;
307310 }
308311 # Show label as needed
309 - if( !FlaggedRevs::binaryFlagging() ) {
 312+ if ( !FlaggedRevs::binaryFlagging() ) {
310313 $item .= "<b>" . Xml::tags( 'label', array( 'for' => "wp$quality" ),
311314 FlaggedRevs::getTagMsg( $quality ) ) . ":</b>\n";
312315 }
313316 # If the sum of qualities of all flags is above 6, use drop down boxes.
314317 # 6 is an arbitrary value choosen according to screen space and usability.
315 - if( $size > 6 ) {
 318+ if ( $size > 6 ) {
316319 $attribs = array( 'name' => "wp$quality", 'id' => "wp$quality",
317320 'onchange' => "FlaggedRevs.updateRatingForm()" );
318321 $item .= Xml::openElement( 'select', $attribs );
319 - foreach( $levels as $i => $name ) {
 322+ foreach ( $levels as $i => $name ) {
320323 $optionClass = array( 'class' => "fr-rating-option-$i" );
321 - $item .= Xml::option( FlaggedRevs::getTagMsg($name), $i,
322 - ($i == $selected), $optionClass )."\n";
 324+ $item .= Xml::option( FlaggedRevs::getTagMsg( $name ), $i,
 325+ ( $i == $selected ), $optionClass ) . "\n";
323326 }
324 - $item .= Xml::closeElement('select')."\n";
 327+ $item .= Xml::closeElement( 'select' ) . "\n";
325328 # If there are more than two levels, current user gets radio buttons
326 - } elseif( $numLevels > 2 ) {
327 - foreach( $levels as $i => $name ) {
 329+ } elseif ( $numLevels > 2 ) {
 330+ foreach ( $levels as $i => $name ) {
328331 $attribs = array( 'class' => "fr-rating-option-$i",
329332 'onchange' => "FlaggedRevs.updateRatingForm()" );
330 - $item .= Xml::radioLabel( FlaggedRevs::getTagMsg($name), "wp$quality",
331 - $i, "wp$quality".$i, ($i == $selected), $attribs ) . "\n";
 333+ $item .= Xml::radioLabel( FlaggedRevs::getTagMsg( $name ), "wp$quality",
 334+ $i, "wp$quality" . $i, ( $i == $selected ), $attribs ) . "\n";
332335 }
333336 # Otherwise make checkboxes (two levels available for current user)
334 - } else if( $numLevels == 2 ) {
 337+ } else if ( $numLevels == 2 ) {
335338 $i = $minLevel;
336339 $attribs = array( 'class' => "fr-rating-option-$i",
337340 'onchange' => "FlaggedRevs.updateRatingForm()" );
338 - $attribs = $attribs + array('value' => $i);
339 - $item .= Xml::checkLabel( wfMsg( 'revreview-'.$levels[$i] ),
340 - "wp$quality", "wp$quality", ($selected == $i), $attribs ) . "\n";
 341+ $attribs = $attribs + array( 'value' => $i );
 342+ $item .= Xml::checkLabel( wfMsg( 'revreview-' . $levels[$i] ),
 343+ "wp$quality", "wp$quality", ( $selected == $i ), $attribs ) . "\n";
341344 }
342345 $items[] = $item;
343346 }
344347 }
345348 # Wrap visible controls in a span
346 - $form = Xml::openElement( 'span', array('class' => 'fr-rating-options') ) . "\n";
 349+ $form = Xml::openElement( 'span', array( 'class' => 'fr-rating-options' ) ) . "\n";
347350 $form .= implode( '&nbsp;&nbsp;&nbsp;', $items );
348351 $form .= Xml::closeElement( 'span' ) . "\n";
349352 return $form;
@@ -352,58 +355,60 @@
353356 $labels = array();
354357 $minLevels = array();
355358 # Build up all levels available to user
356 - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) {
357 - if( isset($selected[$tag]) &&
358 - !RevisionReview::userCan($tag,$selected[$tag],$config) )
 359+ foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) {
 360+ if ( isset( $selected[$tag] ) &&
 361+ !RevisionReview::userCan( $tag, $selected[$tag], $config ) )
359362 {
360 - return array(false,false); // form will have to be disabled
 363+ return array( false, false ); // form will have to be disabled
361364 }
362365 $labels[$tag] = array(); // applicable tag levels
363366 $minLevels[$tag] = false; // first non-zero level number
364 - foreach( $levels as $i => $msg ) {
 367+ foreach ( $levels as $i => $msg ) {
365368 # Some levels may be restricted or not applicable...
366 - if( !RevisionReview::userCan($tag,$i,$config) ) {
 369+ if ( !RevisionReview::userCan( $tag, $i, $config ) ) {
367370 continue; // skip this level
368 - } else if( $i > 0 && !$minLevels[$tag] ) {
 371+ } else if ( $i > 0 && !$minLevels[$tag] ) {
369372 $minLevels[$tag] = $i; // first non-zero level number
370373 }
371374 $labels[$tag][$i] = $msg; // set label
372375 }
373 - if( !$minLevels[$tag] ) {
374 - return array(false,false); // form will have to be disabled
 376+ if ( !$minLevels[$tag] ) {
 377+ return array( false, false ); // form will have to be disabled
375378 }
376379 }
377 - return array($labels,$minLevels);
 380+ return array( $labels, $minLevels );
378381 }
379382
380383
381384 public static function ratingSubmitButtons( $frev, $disabled ) {
382 - $disAttrib = array('disabled' => 'disabled');
 385+ $disAttrib = array( 'disabled' => 'disabled' );
383386 # Add the submit button
384 - if( FlaggedRevs::binaryFlagging() ) {
 387+ if ( FlaggedRevs::binaryFlagging() ) {
385388 # We may want to re-review to change the notes ($wgFlaggedRevsComments)
386 - $s = Xml::submitButton( wfMsg('revreview-submit-review'),
 389+ $s = Xml::submitButton( wfMsg( 'revreview-submit-review' ),
387390 array(
388391 'id' => 'mw-fr-submitreview',
389 - 'accesskey' => wfMsg('revreview-ak-review'),
 392+ 'accesskey' => wfMsg( 'revreview-ak-review' ),
390393 'name' => 'wpApprove',
391 - 'title' => wfMsg('revreview-tt-flag').' ['.wfMsg('revreview-ak-review').']'
 394+ 'title' => wfMsg( 'revreview-tt-flag' ) . ' [' .
 395+ wfMsg( 'revreview-ak-review' ) . ']'
392396 ) + ( $disabled ? $disAttrib : array() )
393397 );
394398 $s .= ' ';
395 - $s .= Xml::submitButton( wfMsg('revreview-submit-unreview'),
 399+ $s .= Xml::submitButton( wfMsg( 'revreview-submit-unreview' ),
396400 array(
397401 'id' => 'mw-fr-submitunreview',
398402 'name' => 'wpUnapprove',
399 - 'title' => wfMsg('revreview-tt-unflag')
400 - ) + ( ($disabled || !$frev) ? $disAttrib : array() )
 403+ 'title' => wfMsg( 'revreview-tt-unflag' )
 404+ ) + ( ( $disabled || !$frev ) ? $disAttrib : array() )
401405 );
402406 } else {
403 - $s = Xml::submitButton( wfMsg('revreview-submit'),
 407+ $s = Xml::submitButton( wfMsg( 'revreview-submit' ),
404408 array(
405409 'id' => 'mw-fr-submitreview',
406 - 'accesskey' => wfMsg('revreview-ak-review'),
407 - 'title' => wfMsg('revreview-tt-review').' ['.wfMsg('revreview-ak-review').']'
 410+ 'accesskey' => wfMsg( 'revreview-ak-review' ),
 411+ 'title' => wfMsg( 'revreview-tt-review' ) . ' [' .
 412+ wfMsg( 'revreview-ak-review' ) . ']'
408413 ) + ( $disabled ? $disAttrib : array() )
409414 );
410415 }
@@ -414,14 +419,14 @@
415420 * @param FlaggedArticle $flaggedArticle
416421 * @returns string
417422 * Creates CSS lock icon if page is locked/unlocked
418 - */
 423+ */
419424 public static function lockStatusIcon( $flaggedArticle ) {
420 - if( $flaggedArticle->isPageLocked() ) {
421 - return "<span class='fr-icon-locked' title=\"".
422 - wfMsgHtml('revreview-locked-title')."\"></span>";
423 - } elseif( $flaggedArticle->isPageUnlocked() ) {
424 - return "<span class='fr-icon-unlocked' title=\"".
425 - wfMsgHtml('revreview-unlocked-title')."\"></span>";
 425+ if ( $flaggedArticle->isPageLocked() ) {
 426+ return "<span class='fr-icon-locked' title=\"" .
 427+ wfMsgHtml( 'revreview-locked-title' ) . "\"></span>";
 428+ } elseif ( $flaggedArticle->isPageUnlocked() ) {
 429+ return "<span class='fr-icon-unlocked' title=\"" .
 430+ wfMsgHtml( 'revreview-unlocked-title' ) . "\"></span>";
426431 }
427432 }
428433
@@ -441,8 +446,8 @@
442447 $msg = $quality
443448 ? 'revreview-newest-quality'
444449 : 'revreview-newest-basic';
445 - $msg .= ($revsSince == 0) ? '-i' : '';
446 - $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
 450+ $msg .= ( $revsSince == 0 ) ? '-i' : '';
 451+ $tag = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time, $revsSince );
447452 return $tag;
448453 }
449454 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -6,14 +6,14 @@
77 */
88 public 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() ) {
 12+ if ( !$wgOut->isArticleRelated() ) {
1313 return self::InjectStyleForSpecial(); // try special page CSS?
1414 }
1515 $fa = FlaggedArticleView::globalArticleInstance();
1616 # Try to only add to relevant pages
17 - if( !$fa || !$fa->isReviewable(true) ) {
 17+ if ( !$fa || !$fa->isReviewable( true ) ) {
1818 return true;
1919 }
2020 global $wgScriptPath, $wgJsMimeType, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion;
@@ -26,17 +26,17 @@
2727 # Add main JS file
2828 $head = "<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>";
2929 # Add review form JS for reviewers
30 - if( $wgUser->isAllowed('review') ) {
 30+ if ( $wgUser->isAllowed( 'review' ) ) {
3131 $encJsFile = htmlspecialchars( "$stylePath/review.js?$wgFlaggedRevStyleVersion" );
3232 $head .= "\n<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>";
3333 }
3434 # Set basic messages
3535 $msgs = (object) array(
36 - 'revreviewDiffToggleShow' => wfMsgHtml('revreview-diff-toggle-show'),
37 - 'revreviewDiffToggleHide' => wfMsgHtml('revreview-diff-toggle-hide')
 36+ 'revreviewDiffToggleShow' => wfMsgHtml( 'revreview-diff-toggle-show' ),
 37+ 'revreviewDiffToggleHide' => wfMsgHtml( 'revreview-diff-toggle-hide' )
3838 );
3939 $head .= "\n<script type=\"{$wgJsMimeType}\">" .
40 - "FlaggedRevs.messages = ".Xml::encodeJsVar($msgs).";</script>\n";
 40+ "FlaggedRevs.messages = " . Xml::encodeJsVar( $msgs ) . ";</script>\n";
4141 $wgOut->addHeadItem( 'FlaggedRevs', $head );
4242 return true;
4343 }
@@ -45,7 +45,7 @@
4646 global $wgUser;
4747 $fa = FlaggedArticleView::globalArticleInstance();
4848 # Try to only add to relevant pages
49 - if( !$fa || !$fa->isReviewable(true) ) {
 49+ if ( !$fa || !$fa->isReviewable( true ) ) {
5050 return true;
5151 }
5252 # Get the review tags on this wiki
@@ -55,19 +55,19 @@
5656 $stableId = $frev ? $frev->getRevId() : 0;
5757 $globalVars['wgFlaggedRevsParams'] = $rTags;
5858 $globalVars['wgStableRevisionId'] = $stableId;
59 - if( $wgUser->isAllowed('review') ) {
 59+ if ( $wgUser->isAllowed( 'review' ) ) {
6060 $ajaxReview = (object) array(
61 - 'sendMsg' => wfMsgHtml('revreview-submit'),
62 - 'flagMsg' => wfMsgHtml('revreview-submit-review'),
63 - 'unflagMsg' => wfMsgHtml('revreview-submit-unreview'),
64 - 'flagLegMsg' => wfMsgHtml('revreview-flag'),
65 - 'reflagLegMsg' => wfMsgHtml('revreview-reflag'),
66 - 'sendingMsg' => wfMsgHtml('revreview-submitting'),
67 - 'actioncomplete' => wfMsgHtml('actioncomplete'),
68 - 'actionfailed' => wfMsgHtml('actionfailed'),
69 - 'draftRev' => wfMsgHtml('hist-draft'),
70 - 'sightedRev' => wfMsgHtml('hist-stable'),
71 - 'qualityRev' => wfMsgHtml('hist-quality'),
 61+ 'sendMsg' => wfMsgHtml( 'revreview-submit' ),
 62+ 'flagMsg' => wfMsgHtml( 'revreview-submit-review' ),
 63+ 'unflagMsg' => wfMsgHtml( 'revreview-submit-unreview' ),
 64+ 'flagLegMsg' => wfMsgHtml( 'revreview-flag' ),
 65+ 'reflagLegMsg' => wfMsgHtml( 'revreview-reflag' ),
 66+ 'sendingMsg' => wfMsgHtml( 'revreview-submitting' ),
 67+ 'actioncomplete' => wfMsgHtml( 'actioncomplete' ),
 68+ 'actionfailed' => wfMsgHtml( 'actionfailed' ),
 69+ 'draftRev' => wfMsgHtml( 'hist-draft' ),
 70+ 'sightedRev' => wfMsgHtml( 'hist-stable' ),
 71+ 'qualityRev' => wfMsgHtml( 'hist-quality' ),
7272 );
7373 $globalVars['wgAjaxReview'] = $ajaxReview; // language for AJAX form
7474 }
@@ -79,13 +79,13 @@
8080 */
8181 public static function InjectStyleForSpecial() {
8282 global $wgTitle, $wgOut;
83 - if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
 83+ if ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
8484 return true;
8585 }
8686 $spPages = array( 'UnreviewedPages', 'OldReviewedPages', 'Watchlist',
8787 'Recentchanges', 'Contributions' );
88 - foreach( $spPages as $n => $key ) {
89 - if( $wgTitle->isSpecial( $key ) ) {
 88+ foreach ( $spPages as $n => $key ) {
 89+ if ( $wgTitle->isSpecial( $key ) ) {
9090 global $wgScriptPath, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion;
9191 $stylePath = str_replace( '$wgScriptPath',
9292 $wgScriptPath, $wgFlaggedRevsStylePath );
@@ -100,7 +100,7 @@
101101
102102 public static function onBeforePageDisplay() {
103103 global $wgOut;
104 - if( $wgOut->isArticleRelated() ) {
 104+ if ( $wgOut->isArticleRelated() ) {
105105 $view = FlaggedArticleView::singleton();
106106 $view->displayTag(); // show notice bar/icon in subtitle
107107 self::injectStyleAndJS(); // full CSS/JS
@@ -113,13 +113,16 @@
114114 public static function markUnderReview( $output, $article, $title, $user, $request ) {
115115 $action = $request->getVal( 'action', 'view' );
116116 $reviewing = ( $action == 'history' ); // default
117 - if( $action == 'view' && ($request->getInt('reviewform') || $request->getInt('rcid')) )
 117+ if ( $action == 'view'
 118+ && ( $request->getInt( 'reviewform' ) || $request->getInt( 'rcid' ) ) )
 119+ {
118120 $reviewing = true;
 121+ }
119122 # Set a key to note that someone is viewing this
120 - if( $reviewing && $user->isAllowed('review') ) {
 123+ if ( $reviewing && $user->isAllowed( 'review' ) ) {
121124 global $wgMemc;
122125 $key = wfMemcKey( 'unreviewedPages', 'underReview', $title->getArticleId() );
123 - $wgMemc->set( $key, '1', 20*60 ); // 20 min
 126+ $wgMemc->set( $key, '1', 20 * 60 ); // 20 min
124127 }
125128 return true;
126129 }
@@ -149,7 +152,7 @@
150153 $newPageID = $destTitle->getArticleID();
151154 # Get flagged revisions from old page id that point to destination page
152155 $dbw = wfGetDB( DB_MASTER );
153 - $result = $dbw->select( array('flaggedrevs','revision'),
 156+ $result = $dbw->select( array( 'flaggedrevs', 'revision' ),
154157 array( 'fr_rev_id' ),
155158 array( 'fr_page_id' => $oldPageID,
156159 'fr_rev_id = rev_id',
@@ -157,10 +160,10 @@
158161 __METHOD__ );
159162 # Update these rows
160163 $revIDs = array();
161 - while( $row = $dbw->fetchObject($result) ) {
 164+ while ( $row = $dbw->fetchObject( $result ) ) {
162165 $revIDs[] = $row->fr_rev_id;
163166 }
164 - if( !empty($revIDs) ) {
 167+ if ( !empty( $revIDs ) ) {
165168 $dbw->update( 'flaggedrevs',
166169 array( 'fr_page_id' => $newPageID ),
167170 array( 'fr_page_id' => $oldPageID,
@@ -197,16 +200,16 @@
198201 public static function onTitleMoveComplete( &$otitle, &$ntitle, $user, $pageId ) {
199202 $fa = FlaggedArticle::getTitleInstance( $ntitle );
200203 // Re-validate NS/config (new title may not be reviewable)
201 - if( $fa->isReviewable() ) {
 204+ if ( $fa->isReviewable() ) {
202205 // Moved from non-reviewable to reviewable NS?
203 - if( FlaggedRevs::autoReviewNewPages() && $user->isAllowed('autoreview')
204 - && !FlaggedRevs::isPageReviewable( $otitle ) )
 206+ if ( FlaggedRevs::autoReviewNewPages() && $user->isAllowed( 'autoreview' )
 207+ && !FlaggedRevs::isPageReviewable( $otitle ) )
205208 {
206209 $rev = Revision::newFromTitle( $ntitle );
207210 // Treat this kind of like a new page...
208211 FlaggedRevs::autoReviewEdit( $fa, $user, $rev->getText(), $rev );
209212 return true; // pending list handled
210 - } else if( $fa->getStableRev(FR_MASTER) ) {
 213+ } else if ( $fa->getStableRev( FR_MASTER ) ) {
211214 return true; // nothing to do
212215 }
213216 }
@@ -221,33 +224,33 @@
222225 $dbw = wfGetDB( DB_MASTER );
223226 $pageId = $linksUpdate->mTitle->getArticleId();
224227 # Check if this page has a stable version...
225 - if( isset($u->fr_stableRev) ) {
 228+ if ( isset( $u->fr_stableRev ) ) {
226229 $sv = $u->fr_stableRev; // Try the process cache...
227230 } else {
228231 $fa = FlaggedArticle::getTitleInstance( $linksUpdate->mTitle );
229 - if( $fa->isReviewable() ) { // re-validate NS/config
 232+ if ( $fa->isReviewable() ) { // re-validate NS/config
230233 $sv = $fa->getStableRev( FR_MASTER );
231234 } else {
232235 $sv = null;
233236 }
234237 }
235238 # Empty flagged revs data for this page if there is no stable version
236 - if( !$sv ) {
 239+ if ( !$sv ) {
237240 FlaggedRevs::clearTrackingRows( $pageId );
238241 return true;
239242 }
240243 # Try the process cache...
241244 $article = new Article( $linksUpdate->mTitle );
242 - if( isset($linksUpdate->fr_stableParserOut) ) {
 245+ if ( isset( $linksUpdate->fr_stableParserOut ) ) {
243246 $parserOut = $linksUpdate->fr_stableParserOut;
244247 } else {
245248 global $wgUser;
246249 # Try stable version cache. This should be updated before this is called.
247250 $anon = new User; // anon cache most likely to exist
248251 $parserOut = FlaggedRevs::getPageCache( $article, $anon );
249 - if( $parserOut == false && $wgUser->getId() )
 252+ if ( $parserOut == false && $wgUser->getId() )
250253 $parserOut = FlaggedRevs::getPageCache( $article, $wgUser );
251 - if( $parserOut == false ) {
 254+ if ( $parserOut == false ) {
252255 $text = $sv->getRevText();
253256 # Parse the text
254257 $parserOut = FlaggedRevs::parseStableText( $article, $text, $sv->getRevId() );
@@ -258,46 +261,46 @@
259262 # Get the list of categories that must be reviewed
260263 $reviewedCats = array();
261264 $msg = wfMsgForContent( 'flaggedrevs-stable-categories' );
262 - if( !wfEmptyMsg( 'flaggedrevs-stable-categories', $msg ) ) {
263 - $list = explode("\n*","\n$msg");
264 - foreach( $list as $category ) {
265 - $category = trim($category);
266 - if( $category != '' )
 265+ if ( !wfEmptyMsg( 'flaggedrevs-stable-categories', $msg ) ) {
 266+ $list = explode( "\n*", "\n$msg" );
 267+ foreach ( $list as $category ) {
 268+ $category = trim( $category );
 269+ if ( $category != '' )
267270 $reviewedCats[$category] = 1;
268271 }
269272 }
270273 $links = array();
271274 # Get any links that are only in the stable version...
272 - foreach( $parserOut->getLinks() as $ns => $titles ) {
273 - foreach( $titles as $title => $id ) {
274 - if( !isset($linksUpdate->mLinks[$ns])
275 - || !isset($linksUpdate->mLinks[$ns][$title]) )
 275+ foreach ( $parserOut->getLinks() as $ns => $titles ) {
 276+ foreach ( $titles as $title => $id ) {
 277+ if ( !isset( $linksUpdate->mLinks[$ns] )
 278+ || !isset( $linksUpdate->mLinks[$ns][$title] ) )
276279 {
277280 self::addLink( $links, $ns, $title );
278281 }
279282 }
280283 }
281284 # Get any images that are only in the stable version...
282 - foreach( $parserOut->getImages() as $image => $n ) {
283 - if( !isset($linksUpdate->mImages[$image]) ) {
 285+ foreach ( $parserOut->getImages() as $image => $n ) {
 286+ if ( !isset( $linksUpdate->mImages[$image] ) ) {
284287 self::addLink( $links, NS_FILE, $image );
285288 }
286289 }
287290 # Get any templates that are only in the stable version...
288 - foreach( $parserOut->getTemplates() as $ns => $titles ) {
289 - foreach( $titles as $title => $id ) {
290 - if( !isset($linksUpdate->mTemplates[$ns])
291 - || !isset($linksUpdate->mTemplates[$ns][$title]) )
 291+ foreach ( $parserOut->getTemplates() as $ns => $titles ) {
 292+ foreach ( $titles as $title => $id ) {
 293+ if ( !isset( $linksUpdate->mTemplates[$ns] )
 294+ || !isset( $linksUpdate->mTemplates[$ns][$title] ) )
292295 {
293296 self::addLink( $links, $ns, $title );
294297 }
295298 }
296299 }
297300 # Get any categories that are only in the stable version...
298 - foreach( $parserOut->getCategories() as $category => $sort ) {
299 - if( !isset($linksUpdate->mCategories[$category]) ) {
 301+ foreach ( $parserOut->getCategories() as $category => $sort ) {
 302+ if ( !isset( $linksUpdate->mCategories[$category] ) ) {
300303 // Stable categories must remain until removed from the stable version
301 - if( isset($reviewedCats[$category]) ) {
 304+ if ( isset( $reviewedCats[$category] ) ) {
302305 $linksUpdate->mCategories[$category] = $sort;
303306 } else {
304307 self::addLink( $links, NS_CATEGORY, $category );
@@ -305,9 +308,11 @@
306309 }
307310 }
308311 $stableCats = $parserOut->getCategories(); // from stable version
309 - foreach( $reviewedCats as $category ) {
 312+ foreach ( $reviewedCats as $category ) {
310313 // Stable categories cannot be added until added to the stable version
311 - if( isset($linksUpdate->mCategories[$category]) && !isset($stableCats[$category]) ) {
 314+ if ( isset( $linksUpdate->mCategories[$category] )
 315+ && !isset( $stableCats[$category] ) )
 316+ {
312317 unset( $linksUpdate->mCategories[$category] );
313318 }
314319 }
@@ -316,20 +321,20 @@
317322 $insertions = self::getLinkInsertions( $existing, $links, $pageId );
318323 $deletions = self::getLinkDeletions( $existing, $links );
319324 # Delete removed links
320 - if( $clause = self::makeWhereFrom2d( $deletions ) ) {
 325+ if ( $clause = self::makeWhereFrom2d( $deletions ) ) {
321326 $where = array( 'ftr_from' => $pageId );
322327 $where[] = $clause;
323328 $dbw->delete( 'flaggedrevs_tracking', $where, __METHOD__ );
324329 }
325330 # Add any new links
326 - if( count($insertions) ) {
 331+ if ( count( $insertions ) ) {
327332 $dbw->insert( 'flaggedrevs_tracking', $insertions, __METHOD__, 'IGNORE' );
328333 }
329334 return true;
330335 }
331336
332337 protected static function addLink( &$links, $ns, $dbKey ) {
333 - if( !isset($links[$ns]) ) {
 338+ if ( !isset( $links[$ns] ) ) {
334339 $links[$ns] = array();
335340 }
336341 $links[$ns][$dbKey] = 1;
@@ -337,13 +342,13 @@
338343
339344 protected static function getExistingLinks( $pageId ) {
340345 $dbr = wfGetDB( DB_SLAVE );
341 - $res = $dbr->select( 'flaggedrevs_tracking',
 346+ $res = $dbr->select( 'flaggedrevs_tracking',
342347 array( 'ftr_namespace', 'ftr_title' ),
343 - array( 'ftr_from' => $pageId ),
 348+ array( 'ftr_from' => $pageId ),
344349 __METHOD__ );
345350 $arr = array();
346 - while( $row = $dbr->fetchObject( $res ) ) {
347 - if( !isset( $arr[$row->ftr_namespace] ) ) {
 351+ while ( $row = $dbr->fetchObject( $res ) ) {
 352+ if ( !isset( $arr[$row->ftr_namespace] ) ) {
348353 $arr[$row->ftr_namespace] = array();
349354 }
350355 $arr[$row->ftr_namespace][$row->ftr_title] = 1;
@@ -359,10 +364,10 @@
360365
361366 protected static function getLinkInsertions( $existing, $new, $pageId ) {
362367 $arr = array();
363 - foreach( $new as $ns => $dbkeys ) {
 368+ foreach ( $new as $ns => $dbkeys ) {
364369 $diffs = isset( $existing[$ns] ) ?
365370 array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
366 - foreach( $diffs as $dbk => $id ) {
 371+ foreach ( $diffs as $dbk => $id ) {
367372 $arr[] = array(
368373 'ftr_from' => $pageId,
369374 'ftr_namespace' => $ns,
@@ -375,8 +380,8 @@
376381
377382 protected static function getLinkDeletions( $existing, $new ) {
378383 $del = array();
379 - foreach( $existing as $ns => $dbkeys ) {
380 - if( isset( $new[$ns] ) ) {
 384+ foreach ( $existing as $ns => $dbkeys ) {
 385+ if ( isset( $new[$ns] ) ) {
381386 $del[$ns] = array_diff_key( $existing[$ns], $new[$ns] );
382387 } else {
383388 $del[$ns] = $existing[$ns];
@@ -411,14 +416,14 @@
412417 */
413418 public static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) {
414419 # Trigger for stable version parsing only
415 - if( !$parser || empty($parser->fr_isStable) || $title->getNamespace() < 0 ) {
 420+ if ( !$parser || empty( $parser->fr_isStable ) || $title->getNamespace() < 0 ) {
416421 return true;
417422 }
418423 $dbr = wfGetDB( DB_SLAVE );
419424 # Check for stable version of template if this feature is enabled.
420425 # Should be in reviewable namespace, this saves unneeded DB checks as
421426 # well as enforce site settings if they are later changed.
422 - if( FlaggedRevs::isPageReviewable($title) && $title->getArticleId() ) {
 427+ if ( FlaggedRevs::isPageReviewable( $title ) && $title->getArticleId() ) {
423428 $id = $dbr->selectField( 'flaggedpages', 'fp_stable',
424429 array( 'fp_page_id' => $title->getArticleId() ),
425430 __METHOD__ );
@@ -427,13 +432,13 @@
428433 $idP = FlaggedRevs::getTemplateIdFromCache( $parser->getRevisionId(),
429434 $title->getNamespace(), $title->getDBkey() );
430435 # Use the process cache key if it's newer or we have none yet
431 - if( !is_null($idP) && (!$id || $idP > $id) ) {
 436+ if ( !is_null( $idP ) && ( !$id || $idP > $id ) ) {
432437 $id = $idP;
433438 }
434439 # If there is no stable version (or that feature is not enabled), use
435440 # the template revision during review time. If both, use the newest one.
436441 $revId = $parser->getRevisionId();
437 - if( $revId && !FlaggedRevs::useProcessCache( $revId ) ) {
 442+ if ( $revId && !FlaggedRevs::useProcessCache( $revId ) ) {
438443 $idP = $dbr->selectField( 'flaggedtemplates',
439444 'ft_tmp_rev_id',
440445 array( 'ft_rev_id' => $revId,
@@ -442,22 +447,22 @@
443448 __METHOD__
444449 );
445450 # Take the newest (or only available) of the two
446 - $id = ($id === false || $idP > $id) ? $idP : $id;
 451+ $id = ( $id === false || $idP > $id ) ? $idP : $id;
447452 }
448453 # If none specified, see if we are allowed to use the current revision
449 - if( !$id ) {
 454+ if ( !$id ) {
450455 global $wgUseCurrentTemplates;
451 - if( $id === false ) {
 456+ if ( $id === false ) {
452457 // May want to give an error
453458 $parser->mOutput->fr_includeErrors[] = $title->getPrefixedDBKey();
454 - if( !$wgUseCurrentTemplates ) {
 459+ if ( !$wgUseCurrentTemplates ) {
455460 $skip = true;
456461 }
457462 } else {
458463 $skip = true; // If ID is zero, don't load it
459464 }
460465 }
461 - if( $id > $parser->mOutput->fr_newestTemplateID ) {
 466+ if ( $id > $parser->mOutput->fr_newestTemplateID ) {
462467 $parser->mOutput->fr_newestTemplateID = $id;
463468 }
464469 return true;
@@ -467,16 +472,16 @@
468473 * Select the desired images based on the selected stable revision times/SHA-1s
469474 */
470475 public static function parserMakeStableFileLink(
471 - $parser, $nt, &$skip, &$time, &$query=false
 476+ $parser, $nt, &$skip, &$time, &$query = false
472477 ) {
473478 # Trigger for stable version parsing only
474 - if( empty($parser->fr_isStable) ) {
 479+ if ( empty( $parser->fr_isStable ) ) {
475480 return true;
476481 }
477482 $file = null;
478483 $isKnownLocal = $isLocalFile = false; // local file on this wiki?
479484 # Normalize NS_MEDIA to NS_FILE
480 - if( $nt->getNamespace() == NS_MEDIA ) {
 485+ if ( $nt->getNamespace() == NS_MEDIA ) {
481486 $title = Title::makeTitle( NS_FILE, $nt->getDBkey() );
482487 $title->resetArticleId( $nt->getArticleId() ); // avoid extra queries
483488 } else {
@@ -486,9 +491,9 @@
487492 # Should be in reviewable namespace, this saves unneeded DB checks as
488493 # well as enforce site settings if they are later changed.
489494 $sha1 = '';
490 - if( FlaggedRevs::isPageReviewable( $title ) ) {
 495+ if ( FlaggedRevs::isPageReviewable( $title ) ) {
491496 $srev = FlaggedRevision::newFromStable( $title );
492 - if( $srev && $srev->getFileTimestamp() ) {
 497+ if ( $srev && $srev->getFileTimestamp() ) {
493498 $time = $srev->getFileTimestamp(); // TS or null
494499 $sha1 = $srev->getFileSha1();
495500 $isKnownLocal = true; // must be local
@@ -497,10 +502,10 @@
498503 # Check cache before doing another DB hit...
499504 $params = FlaggedRevs::getFileVersionFromCache(
500505 $parser->getRevisionId(), $title->getDBkey() );
501 - if( is_array($params) ) {
502 - list($timeP,$sha1P) = $params;
 506+ if ( is_array( $params ) ) {
 507+ list( $timeP, $sha1P ) = $params;
503508 // Take the newest one...
504 - if( !$time || $timeP > $time ) {
 509+ if ( !$time || $timeP > $time ) {
505510 $time = $timeP;
506511 $sha1 = $sha1P;
507512 $isKnownLocal = false; // up in the air...possibly a commons image
@@ -509,29 +514,29 @@
510515 # If there is no stable version (or that feature is not enabled), use
511516 # the image revision during review time. If both, use the newest one.
512517 $revId = $parser->getRevisionId();
513 - if( $revId && !FlaggedRevs::useProcessCache( $revId ) ) {
 518+ if ( $revId && !FlaggedRevs::useProcessCache( $revId ) ) {
514519 $dbr = wfGetDB( DB_SLAVE );
515 - $row = $dbr->selectRow( 'flaggedimages',
 520+ $row = $dbr->selectRow( 'flaggedimages',
516521 array( 'fi_img_timestamp', 'fi_img_sha1' ),
517522 array( 'fi_rev_id' => $parser->getRevisionId(), 'fi_name' => $title->getDBkey() ),
518523 __METHOD__
519524 );
520525 # Only the one picked at review time exists OR it is the newest...use it!
521 - if( $row && ($time === false || $row->fi_img_timestamp > $time) ) {
 526+ if ( $row && ( $time === false || $row->fi_img_timestamp > $time ) ) {
522527 $time = $row->fi_img_timestamp;
523528 $sha1 = $row->fi_img_sha1;
524529 $isKnownLocal = false; // up in the air...possibly a commons image
525530 }
526531 }
527 - $query = $time ? "filetimestamp=" . urlencode( wfTimestamp(TS_MW,$time) ) : "";
 532+ $query = $time ? "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ) : "";
528533 # If none specified, see if we are allowed to use the current revision
529 - if( !$time ) {
 534+ if ( !$time ) {
530535 global $wgUseCurrentImages;
531536 # If the DB found nothing...
532 - if( $time === false ) {
 537+ if ( $time === false ) {
533538 # May want to give an error, so track these...
534539 $parser->mOutput->fr_includeErrors[] = $title->getPrefixedDBKey();
535 - if( !$wgUseCurrentImages ) {
 540+ if ( !$wgUseCurrentImages ) {
536541 $time = "0"; // no image
537542 } else {
538543 $file = wfFindFile( $title );
@@ -545,17 +550,17 @@
546551 $parser->mOutput->fr_ImageSHA1Keys[$title->getDBkey()] = array();
547552 $parser->mOutput->fr_ImageSHA1Keys[$title->getDBkey()][$time] = $sha1;
548553 # Check if this file is local or on a foreign repo...
549 - if( $isKnownLocal ) {
 554+ if ( $isKnownLocal ) {
550555 $isLocalFile = true; // no need to check
551556 # Load the image if needed (note that time === '0' means we have no image)
552 - } elseif( $time !== "0" ) {
 557+ } elseif ( $time !== "0" ) {
553558 # FIXME: would be nice not to double fetch!
554559 $file = $file ? $file : self::getLocalFile( $title, $time );
555560 $isLocalFile = $file && $file->exists() && $file->isLocal();
556561 }
557562 # Bug 15748, be lax about commons image sync status...
558563 # When getting the max timestamp, just ignore the commons image timestamps.
559 - if( $isLocalFile && $time > $parser->mOutput->fr_newestImageTime ) {
 564+ if ( $isLocalFile && $time > $parser->mOutput->fr_newestImageTime ) {
560565 $parser->mOutput->fr_newestImageTime = $time;
561566 }
562567 return true;
@@ -564,9 +569,9 @@
565570 /**
566571 * Select the desired images based on the selected stable revision times/SHA-1s
567572 */
568 - public static function galleryFindStableFileTime( $ig, $nt, &$time, &$query=false ) {
 573+ public static function galleryFindStableFileTime( $ig, $nt, &$time, &$query = false ) {
569574 # Trigger for stable version parsing only
570 - if( empty($ig->mParser->fr_isStable) || $nt->getNamespace() != NS_FILE ) {
 575+ if ( empty( $ig->mParser->fr_isStable ) || $nt->getNamespace() != NS_FILE ) {
571576 return true;
572577 }
573578 $file = null;
@@ -575,9 +580,9 @@
576581 # Should be in reviewable namespace, this saves unneeded DB checks as
577582 # well as enforce site settings if they are later changed.
578583 $sha1 = "";
579 - if( FlaggedRevs::isPageReviewable( $nt ) ) {
 584+ if ( FlaggedRevs::isPageReviewable( $nt ) ) {
580585 $srev = FlaggedRevision::newFromStable( $nt );
581 - if( $srev && $srev->getFileTimestamp() ) {
 586+ if ( $srev && $srev->getFileTimestamp() ) {
582587 $time = $srev->getFileTimestamp(); // TS or null
583588 $sha1 = $srev->getFileSha1();
584589 $isKnownLocal = true; // must be local
@@ -585,10 +590,10 @@
586591 }
587592 # Check cache before doing another DB hit...
588593 $params = FlaggedRevs::getFileVersionFromCache( $ig->mRevisionId, $nt->getDBkey() );
589 - if( is_array($params) ) {
590 - list($timeP,$sha1P) = $params;
 594+ if ( is_array( $params ) ) {
 595+ list( $timeP, $sha1P ) = $params;
591596 // Take the newest one...
592 - if( !$time || $timeP > $time ) {
 597+ if ( !$time || $timeP > $time ) {
593598 $time = $timeP;
594599 $sha1 = $sha1P;
595600 $isKnownLocal = false; // up in the air...possibly a commons image
@@ -596,29 +601,29 @@
597602 }
598603 # If there is no stable version (or that feature is not enabled), use
599604 # the image revision during review time. If both, use the newest one.
600 - if( $ig->mRevisionId && !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) {
 605+ if ( $ig->mRevisionId && !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) {
601606 $dbr = wfGetDB( DB_SLAVE );
602 - $row = $dbr->selectRow( 'flaggedimages',
 607+ $row = $dbr->selectRow( 'flaggedimages',
603608 array( 'fi_img_timestamp', 'fi_img_sha1' ),
604 - array('fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ),
 609+ array( 'fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ),
605610 __METHOD__
606611 );
607612 # Only the one picked at review time exists OR it is the newest...use it!
608 - if( $row && ($time === false || $row->fi_img_timestamp > $time) ) {
 613+ if ( $row && ( $time === false || $row->fi_img_timestamp > $time ) ) {
609614 $time = $row->fi_img_timestamp;
610615 $sha1 = $row->fi_img_sha1;
611616 $isKnownLocal = false; // up in the air...possibly a commons image
612617 }
613618 }
614 - $query = $time ? "filetimestamp=" . urlencode( wfTimestamp(TS_MW,$time) ) : "";
 619+ $query = $time ? "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ) : "";
615620 # If none specified, see if we are allowed to use the current revision
616 - if( !$time ) {
 621+ if ( !$time ) {
617622 global $wgUseCurrentImages;
618623 # If the DB found nothing...
619 - if( $time === false ) {
 624+ if ( $time === false ) {
620625 # May want to give an error, so track these...
621626 $ig->mParser->mOutput->fr_includeErrors[] = $nt->getPrefixedDBKey();
622 - if( !$wgUseCurrentImages ) {
 627+ if ( !$wgUseCurrentImages ) {
623628 $time = "0"; // no image
624629 } else {
625630 $file = wfFindFile( $nt );
@@ -632,16 +637,16 @@
633638 $ig->mParser->mOutput->fr_ImageSHA1Keys[$nt->getDBkey()] = array();
634639 $ig->mParser->mOutput->fr_ImageSHA1Keys[$nt->getDBkey()][$time] = $sha1;
635640 # Check if this file is local or on a foreign repo...
636 - if( $isKnownLocal ) {
 641+ if ( $isKnownLocal ) {
637642 $isLocalFile = true; // no need to check
638643 # Load the image if needed (note that time === '0' means we have no image)
639 - } elseif( $time !== "0" ) {
 644+ } elseif ( $time !== "0" ) {
640645 # FIXME: would be nice not to double fetch!
641646 $file = $file ? $file : self::getLocalFile( $nt, $time );
642647 $isLocalFile = $file && $file->exists() && $file->isLocal();
643648 }
644649 # Bug 15748, be lax about commons image sync status
645 - if( $isLocalFile && $time > $ig->mParser->mOutput->fr_newestImageTime ) {
 650+ if ( $isLocalFile && $time > $ig->mParser->mOutput->fr_newestImageTime ) {
646651 $ig->mParser->mOutput->fr_newestImageTime = $time;
647652 }
648653 return true;
@@ -652,15 +657,15 @@
653658 */
654659 public static function parserInjectTimestamps( $parser, &$text ) {
655660 # Don't trigger this for stable version parsing...it will do it separately.
656 - if( !empty($parser->fr_isStable) ) {
 661+ if ( !empty( $parser->fr_isStable ) ) {
657662 return true;
658663 }
659664 $maxRevision = 0;
660665 # Record the max template revision ID
661 - if( !empty($parser->mOutput->mTemplateIds) ) {
662 - foreach( $parser->mOutput->mTemplateIds as $namespace => $DBKeyRev ) {
663 - foreach( $DBKeyRev as $DBkey => $revID ) {
664 - if( $revID > $maxRevision ) {
 666+ if ( !empty( $parser->mOutput->mTemplateIds ) ) {
 667+ foreach ( $parser->mOutput->mTemplateIds as $namespace => $DBKeyRev ) {
 668+ foreach ( $DBKeyRev as $DBkey => $revID ) {
 669+ if ( $revID > $maxRevision ) {
665670 $maxRevision = $revID;
666671 }
667672 }
@@ -669,15 +674,15 @@
670675 $parser->mOutput->fr_newestTemplateID = $maxRevision;
671676 # Fetch the current timestamps of the images.
672677 $maxTimestamp = "0";
673 - if( !empty($parser->mOutput->mImages) ) {
674 - foreach( $parser->mOutput->mImages as $filename => $x ) {
 678+ if ( !empty( $parser->mOutput->mImages ) ) {
 679+ foreach ( $parser->mOutput->mImages as $filename => $x ) {
675680 # FIXME: it would be nice not to double fetch these!
676681 $file = wfFindFile( Title::makeTitleSafe( NS_FILE, $filename ) );
677682 $parser->mOutput->fr_ImageSHA1Keys[$filename] = array();
678 - if( $file ) {
 683+ if ( $file ) {
679684 $ts = $file->getTimestamp();
680685 # Bug 15748, be lax about commons image sync status
681 - if( $file->isLocal() && $ts > $maxTimestamp ) {
 686+ if ( $file->isLocal() && $ts > $maxTimestamp ) {
682687 $maxTimestamp = $ts;
683688 }
684689 $parser->mOutput->fr_ImageSHA1Keys[$filename][$ts] = $file->getSha1();
@@ -696,11 +701,11 @@
697702 */
698703 public static function outputInjectTimestamps( $out, $parserOut ) {
699704 # Set first time
700 - $out->fr_ImageSHA1Keys = isset($out->fr_ImageSHA1Keys) ?
 705+ $out->fr_ImageSHA1Keys = isset( $out->fr_ImageSHA1Keys ) ?
701706 $out->fr_ImageSHA1Keys : array();
702707 # Leave as defaults if missing. Relevant things will be updated only when needed.
703708 # We don't want to go around resetting caches all over the place if avoidable...
704 - $imageSHA1Keys = isset($parserOut->fr_ImageSHA1Keys) ?
 709+ $imageSHA1Keys = isset( $parserOut->fr_ImageSHA1Keys ) ?
705710 $parserOut->fr_ImageSHA1Keys : array();
706711 # Add on any new items
707712 $out->fr_ImageSHA1Keys = wfArrayMerge( $out->fr_ImageSHA1Keys, $imageSHA1Keys );
@@ -715,41 +720,41 @@
716721 * Check page move and patrol permissions for FlaggedRevs
717722 */
718723 public static function onUserCan( $title, $user, $action, &$result ) {
719 - if( $result === false )
 724+ if ( $result === false )
720725 return true; // nothing to do
721726 # Don't let users vandalize pages by moving them...
722 - if( $action === 'move' ) {
723 - if( !FlaggedRevs::isPageReviewable($title) || !$title->exists() )
 727+ if ( $action === 'move' ) {
 728+ if ( !FlaggedRevs::isPageReviewable( $title ) || !$title->exists() )
724729 return true;
725730 $flaggedArticle = FlaggedArticle::getTitleInstance( $title );
726731 # If the current shows be default anyway, nothing to do...
727 - if( !$flaggedArticle->isStableShownByDefault() ) {
 732+ if ( !$flaggedArticle->isStableShownByDefault() ) {
728733 return true;
729734 }
730735 $frev = $flaggedArticle->getStableRev();
731 - if( $frev && !$user->isAllowed('review') && !$user->isAllowed('movestable') ) {
 736+ if ( $frev && !$user->isAllowed( 'review' ) && !$user->isAllowed( 'movestable' ) ) {
732737 # Allow for only editors/reviewers to move this page
733738 $result = false;
734739 return false;
735740 }
736741 # Don't let users patrol pages not in $wgFlaggedRevsPatrolNamespaces
737 - } else if( $action === 'patrol' || $action === 'autopatrol' ) {
 742+ } else if ( $action === 'patrol' || $action === 'autopatrol' ) {
738743 # Pages in reviewable namespace can be patrolled IF reviewing
739744 # is disabled for pages that don't show the stable by default.
740745 # In such cases, we let people with 'review' rights patrol them.
741 - if( FlaggedRevs::isPageReviewable($title) && !$user->isAllowed('review') ) {
 746+ if ( FlaggedRevs::isPageReviewable( $title ) && !$user->isAllowed( 'review' ) ) {
742747 $result = false;
743748 return false;
744749 }
745750 $flaggedArticle = FlaggedArticle::getTitleInstance( $title );
746751 # The page must be in a patrollable namespace ($wgFlaggedRevsPatrolNamespaces)...
747 - if( !$flaggedArticle->isPatrollable() ) {
 752+ if ( !$flaggedArticle->isPatrollable() ) {
748753 global $wgUseNPPatrol;
749754 # ...unless the page is not in a reviewable namespace and
750755 # new page patrol is enabled. In this scenario, any edits
751756 # to pages outside of patrollable namespaces would already
752757 # be auto-patrolled, except for the new page edits.
753 - if( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) {
 758+ if ( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) {
754759 return true;
755760 } else {
756761 $result = false;
@@ -767,15 +772,15 @@
768773 global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle;
769774 # Assume $action may still not be set, in which case, treat it as 'view'...
770775 # Return out if $result set to false by some other hooked call.
771 - if( $action !== 'read' || $result===false || empty($wgFlaggedRevsVisible) )
 776+ if ( $action !== 'read' || $result === false || empty( $wgFlaggedRevsVisible ) )
772777 return true;
773778 # Admin may set this to false, rather than array()...
774779 $groups = $user->getGroups();
775780 $groups[] = '*';
776 - if( !array_intersect($groups,$wgFlaggedRevsVisible) )
 781+ if ( !array_intersect( $groups, $wgFlaggedRevsVisible ) )
777782 return true;
778783 # Is this a talk page?
779 - if( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) {
 784+ if ( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) {
780785 $result = true;
781786 return true;
782787 }
@@ -783,14 +788,14 @@
784789 # config and URL params, the page can be overriden. The later
785790 # only applies on page views of $title.
786791 $flaggedArticle = FlaggedArticle::getTitleInstance( $title );
787 - if( !empty($wgTitle) && $wgTitle->equals( $title ) ) {
 792+ if ( !empty( $wgTitle ) && $wgTitle->equals( $title ) ) {
788793 $view = FlaggedArticleView::singleton();
789794 // Cache stable version while we are at it.
790 - if( $view->pageOverride() && $flaggedArticle->getStableRev() ) {
 795+ if ( $view->pageOverride() && $flaggedArticle->getStableRev() ) {
791796 $result = true;
792797 }
793798 } else {
794 - if( FlaggedRevision::newFromStable( $title ) ) {
 799+ if ( FlaggedRevision::newFromStable( $title ) ) {
795800 $result = true;
796801 }
797802 }
@@ -809,7 +814,7 @@
810815 global $wgRequest;
811816 # Edit must be non-null, and to a reviewable page
812817 $fa = FlaggedArticle::getArticleInstance( $article );
813 - if( !$rev || !$fa->isReviewable() ) {
 818+ if ( !$rev || !$fa->isReviewable() ) {
814819 return true;
815820 }
816821 $title = $article->getTitle();
@@ -819,107 +824,107 @@
820825 $prevTimestamp = $flags = null;
821826 # Get edit timestamp. Existance already valided by EditPage.php. If
822827 # not present, then it the rev shouldn't be saved, like null edits.
823 - $editTimestamp = $wgRequest->getVal('wpEdittime');
 828+ $editTimestamp = $wgRequest->getVal( 'wpEdittime' );
824829 # Get the user who made the edit
825 - $user = is_null($user) ? User::newFromId( $rev->getUser() ) : $user;
 830+ $user = is_null( $user ) ? User::newFromId( $rev->getUser() ) : $user;
826831 # Is the page checked off to be reviewed?
827832 # Autoreview if this is such a valid case...
828 - if( $wgRequest->getCheck('wpReviewEdit') && $user->isAllowed('review') ) {
 833+ if ( $wgRequest->getCheck( 'wpReviewEdit' ) && $user->isAllowed( 'review' ) ) {
829834 # Check wpEdittime against the previous edit for verification
830 - if( $prevRevId ) {
 835+ if ( $prevRevId ) {
831836 $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK
832837 }
833838 # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit.
834839 # Don't do so if an edit was auto-merged in between though...
835 - if( !$editTimestamp || !$prevTimestamp || $prevTimestamp == $editTimestamp ) {
 840+ if ( !$editTimestamp || !$prevTimestamp || $prevTimestamp == $editTimestamp ) {
836841 $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev,
837842 $flags, false );
838 - if( $ok ) return true; // done!
 843+ if ( $ok ) return true; // done!
839844 }
840845 }
841846 # Get sync cache key
842847 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $rev->getPage() );
843848 # Auto-reviewing must be enabled and user must have the required permissions
844 - if( !FlaggedRevs::autoReviewEdits() || !$user->isAllowed('autoreview') ) {
 849+ if ( !FlaggedRevs::autoReviewEdits() || !$user->isAllowed( 'autoreview' ) ) {
845850 $isAllowed = false; // untrusted user
846851 } else {
847852 # Get autoreview restriction settings...
848853 $config = FlaggedRevs::getPageVisibilitySettings( $title, true );
849854 # Convert Sysop -> protect
850 - $right = ($config['autoreview'] === 'sysop') ?
 855+ $right = ( $config['autoreview'] === 'sysop' ) ?
851856 'protect' : $config['autoreview'];
852857 # Check if the user has the required right, if any
853 - $isAllowed = ($right == '' || $user->isAllowed($right));
 858+ $isAllowed = ( $right == '' || $user->isAllowed( $right ) );
854859 }
855860 # If $baseRevId passed in, this is a null edit
856861 $isNullEdit = $baseRevId ? true : false;
857862 $frev = null;
858863 $reviewableNewPage = false;
859864 # Get the revision ID the incoming one was based off...
860 - if( !$baseRevId && $prevRevId ) {
861 - if( is_null($prevTimestamp) ) { // may already be set
 865+ if ( !$baseRevId && $prevRevId ) {
 866+ if ( is_null( $prevTimestamp ) ) { // may already be set
862867 $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK
863868 }
864869 # The user just made an edit. The one before that should have
865870 # been the current version. If not reflected in wpEdittime, an
866871 # edit may have been auto-merged in between, in that case, discard
867872 # the baseRevId given from the client...
868 - if( !$editTimestamp || $prevTimestamp == $editTimestamp ) {
869 - $baseRevId = intval( trim( $wgRequest->getVal('baseRevId') ) );
 873+ if ( !$editTimestamp || $prevTimestamp == $editTimestamp ) {
 874+ $baseRevId = intval( trim( $wgRequest->getVal( 'baseRevId' ) ) );
870875 }
871876 # If baseRevId not given, assume the previous revision ID.
872877 # For auto-merges, this also occurs since the given ID is ignored.
873878 # Also for bots that don't submit everything...
874 - if( !$baseRevId ) {
 879+ if ( !$baseRevId ) {
875880 $baseRevId = $prevRevId;
876881 }
877882 }
878883 global $wgMemc, $wgParserCacheExpireTime;
879884 # User must have the required permissions for all autoreview cases
880885 # except for simple self-reversions.
881 - if( !$isAllowed ) {
 886+ if ( !$isAllowed ) {
882887 $srev = FlaggedRevision::newFromStable( $title, FR_MASTER );
883888 # Check if this reverted to the stable version. Reverts to other reviewed
884889 # revisions will not be allowed since we don't trust this user.
885 - if( $srev && $baseRevId == $srev->getRevId() ) {
 890+ if ( $srev && $baseRevId == $srev->getRevId() ) {
886891 # Check that this user is ONLY reverting his/herself.
887 - if( self::userWasLastAuthor($article,$baseRevId,$user) ) {
 892+ if ( self::userWasLastAuthor( $article, $baseRevId, $user ) ) {
888893 # Confirm the text; we can't trust this user.
889 - if( $rev->getText() == $srev->getRevText() ) {
 894+ if ( $rev->getText() == $srev->getRevText() ) {
890895 $flags = FlaggedRevs::quickTags( FR_SIGHTED );
891896 $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(),
892897 $rev, $flags );
893 - if( $ok ) return true; // done!
 898+ if ( $ok ) return true; // done!
894899 }
895900 }
896901 }
897902 # User does not have the permission for general autoreviewing...
898 - $wgMemc->set( $key, FlaggedRevs::makeMemcObj('false'), $wgParserCacheExpireTime );
 903+ $wgMemc->set( $key, FlaggedRevs::makeMemcObj( 'false' ), $wgParserCacheExpireTime );
899904 return true; // done! edit pending!
900905 }
901906 // New pages
902 - if( !$prevRevId ) {
 907+ if ( !$prevRevId ) {
903908 $reviewableNewPage = FlaggedRevs::autoReviewNewPages();
904909 // Edits to existing pages
905 - } elseif( $baseRevId ) {
 910+ } elseif ( $baseRevId ) {
906911 $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER );
907912 # If the base revision was not reviewed, check if the previous one was.
908913 # This should catch null edits as well as normal ones.
909 - if( !$frev ) {
 914+ if ( !$frev ) {
910915 $frev = FlaggedRevision::newFromTitle( $title, $prevRevId, FR_MASTER );
911916 }
912917 }
913918 // Is this an edit directly to the stable version? Is it a new page?
914 - if( $isAllowed && ($reviewableNewPage || !is_null($frev)) ) {
 919+ if ( $isAllowed && ( $reviewableNewPage || !is_null( $frev ) ) ) {
915920 # Assume basic flagging level unless this is a null edit
916 - if( $isNullEdit ) $flags = $frev->getTags();
 921+ if ( $isNullEdit ) $flags = $frev->getTags();
917922 # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit...
918923 $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags );
919924 } else {
920925 $ok = false;
921926 }
922 - if( !$ok ) { # Done! edit pending!
923 - $wgMemc->set( $key, FlaggedRevs::makeMemcObj('false'), $wgParserCacheExpireTime );
 927+ if ( !$ok ) { # Done! edit pending!
 928+ $wgMemc->set( $key, FlaggedRevs::makeMemcObj( 'false' ), $wgParserCacheExpireTime );
924929 }
925930 return true;
926931 }
@@ -932,8 +937,8 @@
933938 return !$dbw->selectField( 'revision', '1',
934939 array(
935940 'rev_page' => $article->getId(),
936 - 'rev_id > '.intval($baseRevId),
937 - 'rev_user_text != '.$dbw->addQuotes($user->getName())
 941+ 'rev_id > ' . intval( $baseRevId ),
 942+ 'rev_user_text != ' . $dbw->addQuotes( $user->getName() )
938943 ), __METHOD__
939944 );
940945 }
@@ -948,30 +953,30 @@
949954 # Must be in reviewable namespace
950955 $title = $article->getTitle();
951956 # Revision must *be* null (null edit). We also need the user who made the edit.
952 - if( !$user || $rev !== null || !FlaggedRevs::isPageReviewable( $title ) ) {
 957+ if ( !$user || $rev !== null || !FlaggedRevs::isPageReviewable( $title ) ) {
953958 return true;
954959 }
955960 # Get the current revision ID
956961 $rev = Revision::newFromTitle( $title );
957962 $flags = null;
958963 # Is this a rollback/undo that didn't change anything?
959 - if( $rev && $baseId ) {
 964+ if ( $rev && $baseId ) {
960965 $frev = FlaggedRevision::newFromTitle( $title, $baseId );
961966 # Was the edit that we tried to revert to reviewed?
962 - if( $frev ) {
 967+ if ( $frev ) {
963968 FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags );
964969 FlaggedRevs::markRevisionPatrolled( $rev ); // Make sure it is now marked patrolled...
965970 }
966971 }
967972 # Get edit timestamp, it must exist.
968 - $editTimestamp = $wgRequest->getVal('wpEdittime');
 973+ $editTimestamp = $wgRequest->getVal( 'wpEdittime' );
969974 # Is the page checked off to be reviewed?
970 - if( $rev && $editTimestamp && $wgRequest->getCheck('wpReviewEdit')
971 - && $user->isAllowed('review') )
 975+ if ( $rev && $editTimestamp && $wgRequest->getCheck( 'wpReviewEdit' )
 976+ && $user->isAllowed( 'review' ) )
972977 {
973978 # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit.
974979 # Don't do so if an edit was auto-merged in between though...
975 - if( $rev->getTimestamp() == $editTimestamp ) {
 980+ if ( $rev->getTimestamp() == $editTimestamp ) {
976981 FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(),
977982 $rev, $flags, false );
978983 FlaggedRevs::markRevisionPatrolled( $rev ); // Make sure it is now marked patrolled...
@@ -986,16 +991,16 @@
987992 */
988993 public static function autoMarkPatrolled( &$rc ) {
989994 global $wgUser;
990 - if( empty($rc->mAttribs['rc_this_oldid']) ) {
 995+ if ( empty( $rc->mAttribs['rc_this_oldid'] ) ) {
991996 return true;
992997 }
993998 // Is the page reviewable?
994 - if( FlaggedRevs::isPageReviewable( $rc->getTitle() ) ) {
 999+ if ( FlaggedRevs::isPageReviewable( $rc->getTitle() ) ) {
9951000 # Note: pages in reviewable namespace with FR disabled
9961001 # won't autopatrol. May or may not be useful...
9971002 $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'],
9981003 $rc->mAttribs['rc_this_oldid'], GAID_FOR_UPDATE );
999 - if( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) {
 1004+ if ( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) {
10001005 RevisionReview::updateRecentChanges( $rc->getTitle(),
10011006 $rc->mAttribs['rc_this_oldid'] );
10021007 $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status
@@ -1004,29 +1009,29 @@
10051010 }
10061011 // Is this page in patrollable namespace?
10071012 $patrol = $record = false;
1008 - if( FlaggedRevs::isPagePatrollable( $rc->getTitle() ) ) {
 1013+ if ( FlaggedRevs::isPagePatrollable( $rc->getTitle() ) ) {
10091014 # Bots and users with 'autopatrol' have edits to patrolleable pages
10101015 # marked automatically on edit.
1011 - $patrol = $wgUser->isAllowed('autopatrol') || $wgUser->isAllowed('bot');
 1016+ $patrol = $wgUser->isAllowed( 'autopatrol' ) || $wgUser->isAllowed( 'bot' );
10121017 $record = true;
10131018 } else {
10141019 global $wgUseNPPatrol;
10151020 # Mark patrolled by default unless this is a new page and new page patrol
10161021 # is enabled (except when the user has 'autopatrol', then patrol it).
10171022 # This is just to avoid RC clutter for non-patrollable pages.
1018 - if( $wgUser->isAllowed('autopatrol') ) {
 1023+ if ( $wgUser->isAllowed( 'autopatrol' ) ) {
10191024 $patrol = true;
10201025 # Record patrolled new pages if $wgUseNPPatrol is on
1021 - $record = ( $wgUseNPPatrol && !empty($rc->mAttribs['rc_new']) );
 1026+ $record = ( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) );
10221027 } else {
1023 - $patrol = !( $wgUseNPPatrol && !empty($rc->mAttribs['rc_new']) );
 1028+ $patrol = !( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) );
10241029 }
10251030 }
10261031 // Set rc_patrolled flag and add log entry as needed
1027 - if( $patrol ) {
 1032+ if ( $patrol ) {
10281033 $rc->reallyMarkPatrolled();
10291034 $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs now status
1030 - if( $record ) {
 1035+ if ( $record ) {
10311036 PatrolLog::record( $rc->mAttribs['rc_id'], true );
10321037 }
10331038 }
@@ -1035,9 +1040,9 @@
10361041
10371042 public static function incrementRollbacks( $this, $user, $target, $current ) {
10381043 # Mark when a user reverts another user, but not self-reverts
1039 - if( $current->getRawUser() && $user->getId() != $current->getRawUser() ) {
 1044+ if ( $current->getRawUser() && $user->getId() != $current->getRawUser() ) {
10401045 $p = FlaggedRevs::getUserParams( $current->getRawUser() );
1041 - $p['revertedEdits'] = isset($p['revertedEdits']) ? $p['revertedEdits'] : 0;
 1046+ $p['revertedEdits'] = isset( $p['revertedEdits'] ) ? $p['revertedEdits'] : 0;
10421047 $p['revertedEdits']++;
10431048 FlaggedRevs::saveUserParams( $current->getRawUser(), $p );
10441049 }
@@ -1048,12 +1053,12 @@
10491054 global $wgRequest;
10501055 # Was this an edit by an auto-sighter that undid another edit?
10511056 $undid = $wgRequest->getInt( 'undidRev' );
1052 - if( $rev && $undid && $user->isAllowed('autoreview') ) {
 1057+ if ( $rev && $undid && $user->isAllowed( 'autoreview' ) ) {
10531058 $badRev = Revision::newFromTitle( $article->getTitle(), $undid );
10541059 # Don't count self-reverts
1055 - if( $badRev && $badRev->getRawUser() && $badRev->getRawUser() != $rev->getRawUser() ) {
 1060+ if ( $badRev && $badRev->getRawUser() && $badRev->getRawUser() != $rev->getRawUser() ) {
10561061 $p = FlaggedRevs::getUserParams( $badRev->getRawUser() );
1057 - $p['revertedEdits'] = isset($p['revertedEdits']) ? $p['revertedEdits'] : 0;
 1062+ $p['revertedEdits'] = isset( $p['revertedEdits'] ) ? $p['revertedEdits'] : 0;
10581063 $p['revertedEdits']++;
10591064 FlaggedRevs::saveUserParams( $badRev->getRawUser(), $p );
10601065 }
@@ -1065,7 +1070,7 @@
10661071 # Convert days to seconds...
10671072 $spacing = $spacing * 24 * 3600;
10681073 # Check the oldest edit
1069 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
 1074+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
10701075 $lower = $dbr->selectField( 'revision', 'rev_timestamp',
10711076 array( 'rev_user' => $user->getId() ),
10721077 __METHOD__,
@@ -1075,17 +1080,17 @@
10761081 # The first edit counts, so we have one less scans to do...
10771082 $benchmarks = 0; // actual
10781083 $needed = $points - 1; // required
1079 - while( $lower && $benchmarks < $needed ) {
 1084+ while ( $lower && $benchmarks < $needed ) {
10801085 $next = wfTimestamp( TS_UNIX, $lower ) + $spacing;
10811086 $lower = $dbr->selectField( 'revision', 'rev_timestamp',
10821087 array( 'rev_user' => $user->getId(),
1083 - 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp($next) ) ),
 1088+ 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $next ) ) ),
10841089 __METHOD__,
10851090 array( 'ORDER BY' => 'rev_timestamp ASC', 'USE INDEX' => 'user_timestamp' )
10861091 );
1087 - if( $lower !== false ) $benchmarks++;
 1092+ if ( $lower !== false ) $benchmarks++;
10881093 }
1089 - return ($benchmarks >= $needed );
 1094+ return ( $benchmarks >= $needed );
10901095 }
10911096
10921097 /**
@@ -1095,7 +1100,7 @@
10961101 $dbr = wfGetDB( DB_SLAVE );
10971102 return (bool)$dbr->selectField( 'logging', '1',
10981103 array(
1099 - 'log_namespace' => NS_USER,
 1104+ 'log_namespace' => NS_USER,
11001105 'log_title' => $user->getUserPage()->getDBkey(),
11011106 'log_type' => 'block',
11021107 'log_action' => 'block' ),
@@ -1112,15 +1117,15 @@
11131118 public static function checkAutoPromote( $user, &$promote ) {
11141119 global $wgFlaggedRevsAutoconfirm, $wgMemc;
11151120 # Make sure bots always have autoreview
1116 - if( $user->isAllowed('bot') ) {
 1121+ if ( $user->isAllowed( 'bot' ) ) {
11171122 $promote[] = 'autoreview';
11181123 return true;
11191124 }
11201125 # Check if $wgFlaggedRevsAutoconfirm is actually enabled
11211126 # and that this is a logged-in user that doesn't already
11221127 # have the 'autoreview' permission
1123 - if( !$user->getId() || $user->isAllowed('autoreview')
1124 - || empty($wgFlaggedRevsAutoconfirm) )
 1128+ if ( !$user->getId() || $user->isAllowed( 'autoreview' )
 1129+ || empty( $wgFlaggedRevsAutoconfirm ) )
11251130 {
11261131 return true;
11271132 }
@@ -1128,74 +1133,74 @@
11291134 # Checked basic, already available, promotion heuristics first...
11301135 $APSkipKey = wfMemcKey( 'flaggedrevs', 'autoreview-skip', $user->getId() );
11311136 $value = $wgMemc->get( $APSkipKey );
1132 - if( $value === 'true' ) return true;
 1137+ if ( $value === 'true' ) return true;
11331138 # Check $wgFlaggedRevsAutoconfirm settings...
11341139 $now = time();
11351140 $userCreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
11361141 # User registration was not always tracked in DB...use null for such cases
1137 - $userage = $userCreation ? floor(($now - $userCreation) / 86400) : null;
 1142+ $userage = $userCreation ? floor( ( $now - $userCreation ) / 86400 ) : null;
11381143 $p = FlaggedRevs::getUserParams( $user->getId() );
11391144 # Check if user edited enough content pages
11401145 $totalCheckedEditsNeeded = false;
1141 - if( $wgFlaggedRevsAutoconfirm['totalContentEdits'] > $p['totalContentEdits'] ) {
1142 - if( !$wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
 1146+ if ( $wgFlaggedRevsAutoconfirm['totalContentEdits'] > $p['totalContentEdits'] ) {
 1147+ if ( !$wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
11431148 return true;
11441149 }
11451150 $totalCheckedEditsNeeded = true;
11461151 }
11471152 # Check if user edited enough unique pages
1148 - $pages = explode( ',', trim($p['uniqueContentPages']) ); // page IDs
1149 - if( $wgFlaggedRevsAutoconfirm['uniqueContentPages'] > count($pages) ) {
 1153+ $pages = explode( ',', trim( $p['uniqueContentPages'] ) ); // page IDs
 1154+ if ( $wgFlaggedRevsAutoconfirm['uniqueContentPages'] > count( $pages ) ) {
11501155 return true;
11511156 }
11521157 # Check edit comment use
1153 - if( $wgFlaggedRevsAutoconfirm['editComments'] > $p['editComments'] ) {
 1158+ if ( $wgFlaggedRevsAutoconfirm['editComments'] > $p['editComments'] ) {
11541159 return true;
11551160 }
11561161 # Check account age
1157 - if( !is_null($userage) && $userage < $wgFlaggedRevsAutoconfirm['days'] ) {
 1162+ if ( !is_null( $userage ) && $userage < $wgFlaggedRevsAutoconfirm['days'] ) {
11581163 return true;
11591164 }
11601165 # Check user edit count. Should be stored.
1161 - if( $user->getEditCount() < $wgFlaggedRevsAutoconfirm['edits'] ) {
 1166+ if ( $user->getEditCount() < $wgFlaggedRevsAutoconfirm['edits'] ) {
11621167 return true;
11631168 }
11641169 # Check user email
1165 - if( $wgFlaggedRevsAutoconfirm['email'] && !$user->isEmailConfirmed() ) {
 1170+ if ( $wgFlaggedRevsAutoconfirm['email'] && !$user->isEmailConfirmed() ) {
11661171 return true;
11671172 }
11681173 # Don't grant to currently blocked users...
1169 - if( $user->isBlocked() ) {
 1174+ if ( $user->isBlocked() ) {
11701175 return true;
11711176 }
11721177 # Check if user was ever blocked before
1173 - if( $wgFlaggedRevsAutoconfirm['neverBlocked'] ) {
 1178+ if ( $wgFlaggedRevsAutoconfirm['neverBlocked'] ) {
11741179 $blocked = self::previousBlockCheck( $user );
1175 - if( $blocked ) {
 1180+ if ( $blocked ) {
11761181 # Make a key to store the results
1177 - $wgMemc->set( $APSkipKey, 'true', 3600*24*7 );
 1182+ $wgMemc->set( $APSkipKey, 'true', 3600 * 24 * 7 );
11781183 return true;
11791184 }
11801185 }
11811186 # Check for edit spacing. This lets us know that the account has
11821187 # been used over N different days, rather than all in one lump.
1183 - if( $wgFlaggedRevsAutoconfirm['spacing'] > 0
 1188+ if ( $wgFlaggedRevsAutoconfirm['spacing'] > 0
11841189 && $wgFlaggedRevsAutoconfirm['benchmarks'] > 1 )
11851190 {
11861191 $sTestKey = wfMemcKey( 'flaggedrevs', 'autoreview-spacing-ok', $user->getId() );
11871192 $value = $wgMemc->get( $sTestKey );
11881193 # Check if the user already passed this test via cache.
11891194 # If no cache key is available, then check the DB...
1190 - if( $value !== 'true' ) {
 1195+ if ( $value !== 'true' ) {
11911196 $pass = self::editSpacingCheck(
11921197 $wgFlaggedRevsAutoconfirm['spacing'],
11931198 $wgFlaggedRevsAutoconfirm['benchmarks'],
11941199 $user
11951200 );
11961201 # Make a key to store the results
1197 - if( !$pass ) {
 1202+ if ( !$pass ) {
11981203 $wgMemc->set( $APSkipKey, 'true',
1199 - 3600*24*$spacing*($benchmarks - $needed - 1) );
 1204+ 3600 * 24 * $spacing * ( $benchmarks - $needed - 1 ) );
12001205 return true;
12011206 } else {
12021207 $wgMemc->set( $sTestKey, 'true', 7 * 24 * 3600 );
@@ -1203,16 +1208,16 @@
12041209 }
12051210 }
12061211 # Check implicitly sighted edits
1207 - if( $totalCheckedEditsNeeded && $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
 1212+ if ( $totalCheckedEditsNeeded && $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
12081213 $dbr = wfGetDB( DB_SLAVE );
1209 - $res = $dbr->select( array('revision','flaggedpages'), '1',
 1214+ $res = $dbr->select( array( 'revision', 'flaggedpages' ), '1',
12101215 array( 'rev_user' => $user->getId(),
12111216 'fp_page_id = rev_page', 'fp_stable >= rev_id' ),
12121217 __METHOD__,
1213 - array( 'USE INDEX' => array('revision' => 'user_timestamp'),
 1218+ array( 'USE INDEX' => array( 'revision' => 'user_timestamp' ),
12141219 'LIMIT' => $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] )
12151220 );
1216 - if( $dbr->numRows($res) < $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
 1221+ if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) {
12171222 return true;
12181223 }
12191224 }
@@ -1230,129 +1235,129 @@
12311236 ) {
12321237 global $wgFlaggedRevsAutopromote, $wgFlaggedRevsAutoconfirm, $wgMemc;
12331238 # Ignore NULL edits or edits by anon users
1234 - if( !$rev || !$user->getId() )
 1239+ if ( !$rev || !$user->getId() )
12351240 return true;
12361241 # No sense in running counters if nothing uses them
1237 - if( empty($wgFlaggedRevsAutopromote) && empty($wgFlaggedRevsAutoconfirm) ) {
 1242+ if ( empty( $wgFlaggedRevsAutopromote ) && empty( $wgFlaggedRevsAutoconfirm ) ) {
12381243 return true;
12391244 }
12401245 $p = FlaggedRevs::getUserParams( $user->getId() );
12411246 # Update any special counters for non-null revisions
12421247 $changed = false;
12431248 $pages = array();
1244 - if( $article->getTitle()->isContentPage() ) {
1245 - $pages = explode( ',', trim($p['uniqueContentPages']) ); // page IDs
 1249+ if ( $article->getTitle()->isContentPage() ) {
 1250+ $pages = explode( ',', trim( $p['uniqueContentPages'] ) ); // page IDs
12461251 # Don't let this get bloated for no reason
12471252 # (assumes $wgFlaggedRevsAutopromote is stricter than $wgFlaggedRevsAutoconfirm)
1248 - if( count($pages) < $wgFlaggedRevsAutopromote['uniqueContentPages']
1249 - && !in_array($article->getId(),$pages) )
 1253+ if ( count( $pages ) < $wgFlaggedRevsAutopromote['uniqueContentPages']
 1254+ && !in_array( $article->getId(), $pages ) )
12501255 {
12511256 $pages[] = $article->getId();
12521257 // Clear out any formatting garbage
1253 - $p['uniqueContentPages'] = preg_replace('/^,/','',implode(',',$pages));
 1258+ $p['uniqueContentPages'] = preg_replace( '/^,/', '', implode( ',', $pages ) );
12541259 }
12551260 $p['totalContentEdits'] += 1;
12561261 $changed = true;
12571262 }
1258 - if( $summary ) {
 1263+ if ( $summary ) {
12591264 $p['editComments'] += 1;
12601265 $changed = true;
12611266 }
12621267 # Save any updates to user params
1263 - if( $changed ) {
 1268+ if ( $changed ) {
12641269 FlaggedRevs::saveUserParams( $user->getId(), $p );
12651270 }
12661271 # Grab current groups
12671272 $groups = $user->getGroups();
12681273 # Do not give this to current holders or bots
1269 - if( $user->isAllowed('bot') || in_array('editor',$groups) ) {
 1274+ if ( $user->isAllowed( 'bot' ) || in_array( 'editor', $groups ) ) {
12701275 return true;
12711276 }
12721277 # Do not re-add status if it was previously removed!
1273 - if( isset($p['demoted']) && $p['demoted'] ) {
 1278+ if ( isset( $p['demoted'] ) && $p['demoted'] ) {
12741279 return true;
12751280 }
12761281 # Check if results are cached to avoid DB queries
12771282 $APSkipKey = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getId() );
12781283 $value = $wgMemc->get( $APSkipKey );
1279 - if( $value == 'true' ) return true;
 1284+ if ( $value == 'true' ) return true;
12801285 # Check if user edited enough content pages
12811286 $totalCheckedEditsNeeded = false;
1282 - if( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) {
1283 - if( !$wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
 1287+ if ( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) {
 1288+ if ( !$wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
12841289 return true;
12851290 }
12861291 $totalCheckedEditsNeeded = true;
12871292 }
12881293 # Check if user edited enough unique pages
1289 - if( $wgFlaggedRevsAutopromote['uniqueContentPages'] > count($pages) ) {
 1294+ if ( $wgFlaggedRevsAutopromote['uniqueContentPages'] > count( $pages ) ) {
12901295 return true;
12911296 }
12921297 # Check edit comment use
1293 - if( $wgFlaggedRevsAutopromote['editComments'] > $p['editComments'] ) {
 1298+ if ( $wgFlaggedRevsAutopromote['editComments'] > $p['editComments'] ) {
12941299 return true;
12951300 }
12961301 # Check reverted edits
1297 - if( $wgFlaggedRevsAutopromote['maxRevertedEdits'] < $p['revertedEdits'] ) {
 1302+ if ( $wgFlaggedRevsAutopromote['maxRevertedEdits'] < $p['revertedEdits'] ) {
12981303 return true;
12991304 }
13001305 # Check account age
13011306 $now = time();
13021307 $usercreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
1303 - $userage = $usercreation ? floor(($now - $usercreation) / 86400) : null;
1304 - if( !is_null($userage) && $userage < $wgFlaggedRevsAutopromote['days'] ) {
 1308+ $userage = $usercreation ? floor( ( $now - $usercreation ) / 86400 ) : null;
 1309+ if ( !is_null( $userage ) && $userage < $wgFlaggedRevsAutopromote['days'] ) {
13051310 return true;
13061311 }
13071312 # Check user edit count. Should be stored.
1308 - if( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] ) {
 1313+ if ( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] ) {
13091314 return true;
13101315 }
13111316 # Don't grant to currently blocked users...
1312 - if( $user->isBlocked() ) {
 1317+ if ( $user->isBlocked() ) {
13131318 return true;
13141319 }
13151320 # Check if user was ever blocked before
1316 - if( $wgFlaggedRevsAutopromote['neverBlocked'] ) {
 1321+ if ( $wgFlaggedRevsAutopromote['neverBlocked'] ) {
13171322 $blocked = self::previousBlockCheck( $user );
1318 - if( $blocked ) {
 1323+ if ( $blocked ) {
13191324 # Make a key to store the results
1320 - $wgMemc->set( $APSkipKey, 'true', 3600*24*7 );
 1325+ $wgMemc->set( $APSkipKey, 'true', 3600 * 24 * 7 );
13211326 return true;
13221327 }
13231328 }
13241329 # See if the page actually has sufficient content...
1325 - if( $wgFlaggedRevsAutopromote['userpageBytes'] > 0 ) {
1326 - if( !$user->getUserPage()->exists() ) {
 1330+ if ( $wgFlaggedRevsAutopromote['userpageBytes'] > 0 ) {
 1331+ if ( !$user->getUserPage()->exists() ) {
13271332 return true;
13281333 }
1329 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
 1334+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
13301335 $size = $dbr->selectField( 'page', 'page_len',
13311336 array( 'page_namespace' => $user->getUserPage()->getNamespace(),
13321337 'page_title' => $user->getUserPage()->getDBkey() ),
13331338 __METHOD__ );
1334 - if( $size < $wgFlaggedRevsAutopromote['userpageBytes'] ) {
 1339+ if ( $size < $wgFlaggedRevsAutopromote['userpageBytes'] ) {
13351340 return true;
13361341 }
13371342 }
13381343 # Check for edit spacing. This lets us know that the account has
13391344 # been used over N different days, rather than all in one lump.
1340 - if( $wgFlaggedRevsAutopromote['spacing'] > 0
 1345+ if ( $wgFlaggedRevsAutopromote['spacing'] > 0
13411346 && $wgFlaggedRevsAutopromote['benchmarks'] > 1 )
13421347 {
13431348 $sTestKey = wfMemcKey( 'flaggedrevs', 'autopromote-spacing-ok', $user->getId() );
13441349 $value = $wgMemc->get( $sTestKey );
13451350 # Check if the user already passed this test via cache.
13461351 # If no cache key is available, then check the DB...
1347 - if( $value !== 'true' ) {
 1352+ if ( $value !== 'true' ) {
13481353 $pass = self::editSpacingCheck(
13491354 $wgFlaggedRevsAutopromote['spacing'],
13501355 $wgFlaggedRevsAutopromote['benchmarks'],
13511356 $user
13521357 );
13531358 # Make a key to store the results
1354 - if( !$pass ) {
 1359+ if ( !$pass ) {
13551360 $wgMemc->set( $APSkipKey, 'true',
1356 - 3600*24*$spacing*($benchmarks - $needed - 1) );
 1361+ 3600 * 24 * $spacing * ( $benchmarks - $needed - 1 ) );
13571362 return true;
13581363 } else {
13591364 $wgMemc->set( $sTestKey, 'true', 7 * 24 * 3600 );
@@ -1360,71 +1365,71 @@
13611366 }
13621367 }
13631368 # Check if this user is sharing IPs with another users
1364 - if( $wgFlaggedRevsAutopromote['uniqueIPAddress'] ) {
 1369+ if ( $wgFlaggedRevsAutopromote['uniqueIPAddress'] ) {
13651370 $uid = $user->getId();
13661371
1367 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
 1372+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
13681373 $shared = $dbr->selectField( 'recentchanges', '1',
13691374 array( 'rc_ip' => wfGetIP(),
13701375 "rc_user != '$uid'" ),
13711376 __METHOD__,
13721377 array( 'USE INDEX' => 'rc_ip' ) );
1373 - if( $shared ) {
 1378+ if ( $shared ) {
13741379 # Make a key to store the results
1375 - $wgMemc->set( $key, 'true', 3600*24*7 );
 1380+ $wgMemc->set( $key, 'true', 3600 * 24 * 7 );
13761381 return true;
13771382 }
13781383 }
13791384 # Check if the user has any recent content edits
1380 - if( $wgFlaggedRevsAutopromote['recentContentEdits'] > 0 ) {
 1385+ if ( $wgFlaggedRevsAutopromote['recentContentEdits'] > 0 ) {
13811386 global $wgContentNamespaces;
13821387
1383 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
1384 - $res = $dbr->select( 'recentchanges', '1',
 1388+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
 1389+ $res = $dbr->select( 'recentchanges', '1',
13851390 array( 'rc_user_text' => $user->getName(),
1386 - 'rc_namespace' => $wgContentNamespaces ),
1387 - __METHOD__,
 1391+ 'rc_namespace' => $wgContentNamespaces ),
 1392+ __METHOD__,
13881393 array( 'USE INDEX' => 'rc_ns_usertext',
13891394 'LIMIT' => $wgFlaggedRevsAutopromote['recentContentEdits'] )
13901395 );
1391 - if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['recentContentEdits'] ) {
 1396+ if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutopromote['recentContentEdits'] ) {
13921397 return true;
13931398 }
13941399 }
13951400 # Check to see if the user has so many deleted edits that
13961401 # they don't actually enough live edits. This is because
13971402 # $user->getEditCount() is the count of edits made, not live.
1398 - if( $wgFlaggedRevsAutopromote['excludeDeleted'] ) {
1399 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
 1403+ if ( $wgFlaggedRevsAutopromote['excludeDeleted'] ) {
 1404+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
14001405 $minDiff = $user->getEditCount() - $wgFlaggedRevsAutopromote['days'] + 1;
14011406 # Use an estimate if the number starts to get large
1402 - if( $minDiff <= 100 ) {
1403 - $res = $dbr->select( 'archive', '1',
1404 - array( 'ar_user_text' => $user->getName() ),
1405 - __METHOD__,
 1407+ if ( $minDiff <= 100 ) {
 1408+ $res = $dbr->select( 'archive', '1',
 1409+ array( 'ar_user_text' => $user->getName() ),
 1410+ __METHOD__,
14061411 array( 'USE INDEX' => 'usertext_timestamp', 'LIMIT' => $minDiff ) );
1407 - $deletedEdits = $dbr->numRows($res);
 1412+ $deletedEdits = $dbr->numRows( $res );
14081413 } else {
14091414 $deletedEdits = $dbr->estimateRowCount( 'archive', '1',
14101415 array( 'ar_user_text' => $user->getName() ),
14111416 __METHOD__,
14121417 array( 'USE INDEX' => 'usertext_timestamp' ) );
14131418 }
1414 - if( $deletedEdits >= $minDiff ) {
 1419+ if ( $deletedEdits >= $minDiff ) {
14151420 return true;
14161421 }
14171422 }
14181423 # Check implicitly sighted edits
1419 - if( $totalCheckedEditsNeeded && $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
1420 - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
1421 - $res = $dbr->select( array('revision','flaggedpages'), '1',
 1424+ if ( $totalCheckedEditsNeeded && $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
 1425+ $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
 1426+ $res = $dbr->select( array( 'revision', 'flaggedpages' ), '1',
14221427 array( 'rev_user' => $user->getId(),
14231428 'fp_page_id = rev_page', 'fp_stable >= rev_id' ),
14241429 __METHOD__,
1425 - array( 'USE INDEX' => array('revision' => 'user_timestamp'),
 1430+ array( 'USE INDEX' => array( 'revision' => 'user_timestamp' ),
14261431 'LIMIT' => $wgFlaggedRevsAutopromote['totalCheckedEdits'] )
14271432 );
1428 - if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
 1433+ if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
14291434 return true;
14301435 }
14311436 }
@@ -1434,9 +1439,9 @@
14351440
14361441 global $wgFlaggedRevsAutopromoteInRC;
14371442 $log = new LogPage( 'rights', $wgFlaggedRevsAutopromoteInRC );
1438 - $log->addEntry( 'rights', $user->getUserPage(), wfMsg('rights-editor-autosum'),
1439 - array( implode(', ',$groups), implode(', ',$newGroups) ) );
1440 - $user->addGroup('editor');
 1443+ $log->addEntry( 'rights', $user->getUserPage(), wfMsg( 'rights-editor-autosum' ),
 1444+ array( implode( ', ', $groups ), implode( ', ', $newGroups ) ) );
 1445+ $user->addGroup( 'editor' );
14411446
14421447 return true;
14431448 }
@@ -1445,9 +1450,9 @@
14461451 * Record demotion so that auto-promote will be disabled
14471452 */
14481453 public static function recordDemote( $u, $addgroup, $removegroup ) {
1449 - if( $removegroup && in_array('editor',$removegroup) ) {
 1454+ if ( $removegroup && in_array( 'editor', $removegroup ) ) {
14501455 // Cross-wiki rights change
1451 - if( $u instanceof UserRightsProxy ) {
 1456+ if ( $u instanceof UserRightsProxy ) {
14521457 $params = FlaggedRevs::getUserParams( $u->getId(), $u->getDBName() );
14531458 $params['demoted'] = 1;
14541459 FlaggedRevs::saveUserParams( $u->getId(), $params, $u->getDBName() );
@@ -1482,7 +1487,7 @@
14831488 'label-message' => 'flaggedrevs-prefs-stable',
14841489 );
14851490 // Review-related rights...
1486 - if( $user->isAllowed( 'review' ) ) {
 1491+ if ( $user->isAllowed( 'review' ) ) {
14871492 // Watching reviewed pages
14881493 $preferences['flaggedrevswatch'] =
14891494 array(
@@ -1509,15 +1514,15 @@
15101515 }
15111516
15121517 public static function logLineLinks(
1513 - $type, $action, $title=null, $params, &$comment, &$rv, $ts
 1518+ $type, $action, $title = null, $params, &$comment, &$rv, $ts
15141519 ) {
1515 - if( !$title ) {
 1520+ if ( !$title ) {
15161521 return true; // nothing to do
15171522 // Stability log
1518 - } else if( $type == 'stable' ) {
 1523+ } else if ( $type == 'stable' ) {
15191524 $rv .= FlaggedRevsLogs::stabilityLogLinks( $title, $ts );
15201525 // Review log
1521 - } else if( $type == 'review' && FlaggedRevsLogs::isReviewAction($action) ) {
 1526+ } else if ( $type == 'review' && FlaggedRevsLogs::isReviewAction( $action ) ) {
15221527 $rv .= FlaggedRevsLogs::reviewLogLinks( $action, $title, $params );
15231528 }
15241529 return true;
@@ -1531,7 +1536,7 @@
15321537
15331538 public static function setActionTabs( $skin, &$contentActions ) {
15341539 // Note: $wgArticle sometimes not set here
1535 - if( FlaggedArticleView::globalArticleInstance() != null ) {
 1540+ if ( FlaggedArticleView::globalArticleInstance() != null ) {
15361541 $view = FlaggedArticleView::singleton();
15371542 $view->setActionTabs( $skin, $contentActions );
15381543 $view->setViewTabs( $skin, $contentActions );
@@ -1541,7 +1546,7 @@
15421547
15431548 public static function setNavigation( $skin, &$links ) {
15441549 // Note: $wgArticle sometimes not set here
1545 - if( FlaggedArticleView::globalArticleInstance() != null ) {
 1550+ if ( FlaggedArticleView::globalArticleInstance() != null ) {
15461551 $view = FlaggedArticleView::singleton();
15471552 $view->setActionTabs( $skin, $links['actions'] );
15481553 $view->setViewTabs( $skin, $links['views'] );
@@ -1561,34 +1566,34 @@
15621567 &$title, $request, &$ignoreRedirect, &$target, &$article
15631568 ) {
15641569 # Get an instance on the title ($wgTitle)
1565 - if( !FlaggedRevs::isPageReviewable($title) ) {
 1570+ if ( !FlaggedRevs::isPageReviewable( $title ) ) {
15661571 return true;
15671572 }
1568 - if( $request->getVal( 'stableid' ) ) {
 1573+ if ( $request->getVal( 'stableid' ) ) {
15691574 $ignoreRedirect = true;
15701575 } else {
15711576 global $wgMemc, $wgParserCacheExpireTime;
15721577 # Try the cache...
15731578 $key = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $title->getArticleId() );
1574 - $data = $wgMemc->get($key);
1575 - if( is_object($data) && $data->time >= $article->getTouched() ) {
1576 - list($ignoreRedirect,$target) = $data->value;
 1579+ $data = $wgMemc->get( $key );
 1580+ if ( is_object( $data ) && $data->time >= $article->getTouched() ) {
 1581+ list( $ignoreRedirect, $target ) = $data->value;
15771582 return true;
15781583 }
15791584 $fa = FlaggedArticle::getTitleInstance( $title );
1580 - if( $srev = $fa->getStableRev() ) {
 1585+ if ( $srev = $fa->getStableRev() ) {
15811586 $view = FlaggedArticleView::singleton();
15821587 # If synced, nothing special here...
1583 - if( $srev->getRevId() != $article->getLatest() && $view->pageOverride() ) {
 1588+ if ( $srev->getRevId() != $article->getLatest() && $view->pageOverride() ) {
15841589 $text = $srev->getRevText();
15851590 $redirect = $fa->followRedirectText( $text );
1586 - if( $redirect ) {
 1591+ if ( $redirect ) {
15871592 $target = $redirect;
15881593 } else {
15891594 $ignoreRedirect = true;
15901595 }
15911596 }
1592 - $data = FlaggedRevs::makeMemcObj( array($ignoreRedirect,$target) );
 1597+ $data = FlaggedRevs::makeMemcObj( array( $ignoreRedirect, $target ) );
15931598 $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
15941599 }
15951600 }
@@ -1615,7 +1620,7 @@
16161621
16171622 public static function onSkinAfterContent( &$data ) {
16181623 global $wgOut;
1619 - if( $wgOut->isArticleRelated() && FlaggedArticleView::globalArticleInstance() != null ) {
 1624+ if ( $wgOut->isArticleRelated() && FlaggedArticleView::globalArticleInstance() != null ) {
16201625 $view = FlaggedArticleView::singleton();
16211626 $view->addReviewNotes( $data );
16221627 $view->addReviewForm( $data );
@@ -1627,7 +1632,7 @@
16281633 public static function addToHistQuery( $pager, &$queryInfo ) {
16291634 $flaggedArticle = FlaggedArticle::getArticleInstance( $pager->getArticle() );
16301635 # Non-content pages cannot be validated. Stable version must exist.
1631 - if( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) {
 1636+ if ( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) {
16321637 $queryInfo['tables'][] = 'flaggedrevs';
16331638 $queryInfo['fields'][] = 'fr_quality';
16341639 $queryInfo['fields'][] = 'fr_user';
@@ -1641,11 +1646,11 @@
16421647 public static function addToFileHistQuery(
16431648 $file, &$tables, &$fields, &$conds, &$opts, &$join_conds
16441649 ) {
1645 - if( !$file->isLocal() )
 1650+ if ( !$file->isLocal() )
16461651 return true; // local files only
16471652 $flaggedArticle = FlaggedArticle::getTitleInstance( $file->getTitle() );
16481653 # Non-content pages cannot be validated. Stable version must exist.
1649 - if( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) {
 1654+ if ( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) {
16501655 $tables[] = 'flaggedrevs';
16511656 $fields[] = 'MAX(fr_quality) AS fr_quality';
16521657 # Avoid duplicate rows due to multiple revs with the same sha-1 key
@@ -1657,7 +1662,7 @@
16581663 }
16591664
16601665 public static function addToContribsQuery( $pager, &$queryInfo ) {
1661 - if( FlaggedRevs::stableOnlyIfConfigured() )
 1666+ if ( FlaggedRevs::stableOnlyIfConfigured() )
16621667 return true; // don't show colors if almost nothing will be highlighted
16631668 # Highlight flaggedrevs
16641669 $queryInfo['tables'][] = 'flaggedrevs';
@@ -1673,97 +1678,97 @@
16741679
16751680 public static function addToRCQuery( &$conds, &$tables, &$join_conds, $opts ) {
16761681 global $wgUser;
1677 - if( $wgUser->isAllowed('review') ) {
 1682+ if ( $wgUser->isAllowed( 'review' ) ) {
16781683 $tables[] = 'flaggedpage_pending';
16791684 $join_conds['flaggedpage_pending'] = array( 'LEFT JOIN',
1680 - 'fpp_page_id = rc_cur_id AND fpp_quality = '.FlaggedRevs::getPatrolLevel() );
 1685+ 'fpp_page_id = rc_cur_id AND fpp_quality = ' . FlaggedRevs::getPatrolLevel() );
16811686 }
16821687 return true;
16831688 }
16841689
16851690 public static function addToWatchlistQuery( &$conds, &$tables, &$join_conds, &$fields ) {
16861691 global $wgUser;
1687 - if( $wgUser->isAllowed('review') ) {
 1692+ if ( $wgUser->isAllowed( 'review' ) ) {
16881693 $fields[] = 'fpp_rev_id';
16891694 $tables[] = 'flaggedpage_pending';
16901695 $join_conds['flaggedpage_pending'] = array( 'LEFT JOIN',
1691 - 'fpp_page_id = rc_cur_id AND fpp_quality = '.FlaggedRevs::getPatrolLevel() );
 1696+ 'fpp_page_id = rc_cur_id AND fpp_quality = ' . FlaggedRevs::getPatrolLevel() );
16921697 }
16931698 return true;
16941699 }
16951700
16961701 public static function addToHistLine( $history, $row, &$s, &$liClasses ) {
16971702 $fa = FlaggedArticle::getArticleInstance( $history->getArticle() );
1698 - if( !$fa->isReviewable() ) {
 1703+ if ( !$fa->isReviewable() ) {
16991704 return true; // nothing to do here
17001705 }
17011706 $title = $history->getArticle()->getTitle();
17021707 # Fetch and process cache the stable revision
1703 - if( !isset($history->fr_stableRevId) ) {
 1708+ if ( !isset( $history->fr_stableRevId ) ) {
17041709 $frev = $fa->getStableRev();
17051710 $history->fr_stableRevId = $frev ? $frev->getRevId() : 0;
17061711 }
1707 - if( !$history->fr_stableRevId ) {
 1712+ if ( !$history->fr_stableRevId ) {
17081713 return true; // nothing to do here
17091714 }
17101715 // Unreviewed revision: highlight if pending
17111716 $link = $class = '';
1712 - if( !isset($row->fr_quality) ) {
1713 - if( $row->rev_id > $history->fr_stableRevId ) {
 1717+ if ( !isset( $row->fr_quality ) ) {
 1718+ if ( $row->rev_id > $history->fr_stableRevId ) {
17141719 $class = 'flaggedrevs-unreviewed';
1715 - $link = '<strong>'.wfMsgHtml('revreview-hist-pending').'</strong>';
 1720+ $link = '<strong>' . wfMsgHtml( 'revreview-hist-pending' ) . '</strong>';
17161721 }
17171722 // Reviewed revision: highlight and add link
1718 - } else if( !($row->rev_deleted & Revision::DELETED_TEXT) ) {
 1723+ } else if ( !( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
17191724 # Add link to stable version of *this* rev, if any
1720 - list($link,$class) = FlaggedRevs::markHistoryRow( $title, $row );
 1725+ list( $link, $class ) = FlaggedRevs::markHistoryRow( $title, $row );
17211726 # Space out and demark the stable revision
1722 - if( $row->rev_id == $history->fr_stableRevId ) {
 1727+ if ( $row->rev_id == $history->fr_stableRevId ) {
17231728 $liClasses[] = 'flaggedrevs_hist_stable';
17241729 }
17251730 }
17261731 # Style the row as needed
1727 - if( $class ) $s = "<span class='$class'>$s</span>";
 1732+ if ( $class ) $s = "<span class='$class'>$s</span>";
17281733 # Add stable old version link
1729 - if( $link ) $s .= " <small>$link</small>";
 1734+ if ( $link ) $s .= " <small>$link</small>";
17301735 return true;
17311736 }
17321737
17331738 public static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) {
1734 - if( !$file->isVisible() )
 1739+ if ( !$file->isVisible() )
17351740 return true; // Don't bother showing notice for deleted revs
17361741 # Quality level for old versions selected all at once.
17371742 # Commons queries cannot be done all at once...
1738 - if( !$file->isOld() || !$file->isLocal() ) {
1739 - $dbr = wfGetDB(DB_SLAVE);
 1743+ if ( !$file->isOld() || !$file->isLocal() ) {
 1744+ $dbr = wfGetDB( DB_SLAVE );
17401745 $quality = $dbr->selectField( 'flaggedrevs', 'fr_quality',
17411746 array( 'fr_img_sha1' => $file->getSha1(),
17421747 'fr_img_timestamp' => $dbr->timestamp( $file->getTimestamp() ) ),
17431748 __METHOD__
17441749 );
17451750 } else {
1746 - $quality = is_null($file->quality) ? false : $file->quality;
 1751+ $quality = is_null( $file->quality ) ? false : $file->quality;
17471752 }
17481753 # If reviewed, class the line
1749 - if( $quality !== false ) {
 1754+ if ( $quality !== false ) {
17501755 $rowClass = FlaggedRevsXML::getQualityColor( $quality );
17511756 }
17521757 return true;
17531758 }
17541759
17551760 public static function addToContribsLine( $contribs, &$ret, $row ) {
1756 - if( FlaggedRevs::stableOnlyIfConfigured() )
 1761+ if ( FlaggedRevs::stableOnlyIfConfigured() )
17571762 return true; // don't show colors if almost nothing will be highlighted
17581763 $namespaces = FlaggedRevs::getReviewNamespaces();
1759 - if( !in_array($row->page_namespace,$namespaces) ) {
 1764+ if ( !in_array( $row->page_namespace, $namespaces ) ) {
17601765 // do nothing
1761 - } elseif( isset($row->fr_quality) ) {
1762 - $ret = '<span class="'.FlaggedRevsXML::getQualityColor($row->fr_quality).
1763 - '">'.$ret.'</span>';
1764 - } elseif( isset($row->fp_stable) && $row->rev_id > $row->fp_stable ) {
1765 - $ret = '<span class="flaggedrevs-unreviewed">'.$ret.'</span>';
1766 - } elseif( !isset($row->fp_stable) ) {
1767 - $ret = '<span class="flaggedrevs-unreviewed2">'.$ret.'</span>';
 1766+ } elseif ( isset( $row->fr_quality ) ) {
 1767+ $ret = '<span class="' . FlaggedRevsXML::getQualityColor( $row->fr_quality ) .
 1768+ '">' . $ret . '</span>';
 1769+ } elseif ( isset( $row->fp_stable ) && $row->rev_id > $row->fp_stable ) {
 1770+ $ret = '<span class="flaggedrevs-unreviewed">' . $ret . '</span>';
 1771+ } elseif ( !isset( $row->fp_stable ) ) {
 1772+ $ret = '<span class="flaggedrevs-unreviewed2">' . $ret . '</span>';
17681773 }
17691774 return true;
17701775 }
@@ -1771,12 +1776,12 @@
17721777 public static function addToChangeListLine(
17731778 &$list, &$articlelink, &$s, &$rc, $unpatrolled, $watched
17741779 ) {
1775 - if( empty($rc->mAttribs['fpp_rev_id']) )
 1780+ if ( empty( $rc->mAttribs['fpp_rev_id'] ) )
17761781 return true; // page is not listed in pending edit table
1777 - if( !FlaggedRevs::isPageReviewable($rc->getTitle()) )
 1782+ if ( !FlaggedRevs::isPageReviewable( $rc->getTitle() ) )
17781783 return true; // confirm that page is in reviewable namespace
1779 - $rlink = $list->skin->makeKnownLinkObj( $rc->getTitle(), wfMsg('revreview-reviewlink'),
1780 - 'oldid='.intval($rc->mAttribs['fpp_rev_id']).'&diff=cur' );
 1784+ $rlink = $list->skin->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'revreview-reviewlink' ),
 1785+ 'oldid=' . intval( $rc->mAttribs['fpp_rev_id'] ) . '&diff=cur' );
17811786 $articlelink .= " <span class='mw-fr-reviewlink'>($rlink)</span>";
17821787 return true;
17831788 }
@@ -1789,9 +1794,9 @@
17901795
17911796 // diff=review param (bug 16923)
17921797 public static function checkDiffUrl( $titleObj, &$mOldid, &$mNewid, $old, $new ) {
1793 - if( $new === 'review' && isset($titleObj) ) {
 1798+ if ( $new === 'review' && isset( $titleObj ) ) {
17941799 $frev = FlaggedRevision::newFromStable( $titleObj );
1795 - if( $frev ) {
 1800+ if ( $frev ) {
17961801 $mOldid = $frev->getRevId(); // stable
17971802 $mNewid = 0; // cur
17981803 }
@@ -1816,23 +1821,23 @@
18171822
18181823 public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) {
18191824 global $wgUser, $wgRequest;
1820 - if( !$wgUser->isAllowed('review') ) {
 1825+ if ( !$wgUser->isAllowed( 'review' ) ) {
18211826 return true;
18221827 }
1823 - if( FlaggedRevs::autoReviewNewPages() && !$editPage->getArticle()->getId() ) {
 1828+ if ( FlaggedRevs::autoReviewNewPages() && !$editPage->getArticle()->getId() ) {
18241829 return true; // not needed
18251830 }
18261831 $fa = FlaggedArticleView::globalArticleInstance();
1827 - if( $fa->isReviewable() && !$fa->limitedUI() ) {
 1832+ if ( $fa->isReviewable() && !$fa->limitedUI() ) {
18281833 $srev = $fa->getStableRev();
18291834 # For pages with either no stable version, or an outdated one, let
18301835 # the user decide if he/she wants it reviewed on the spot. One might
18311836 # do this if he/she just saw the diff-to-stable and *then* decided to edit.
1832 - if( !$srev || $srev->getRevId() != $editPage->getArticle()->getLatest() ) {
1833 - $reviewLabel = wfMsgExt( 'revreview-check-flag', array('parseinline') );
 1837+ if ( !$srev || $srev->getRevId() != $editPage->getArticle()->getLatest() ) {
 1838+ $reviewLabel = wfMsgExt( 'revreview-check-flag', array( 'parseinline' ) );
18341839 $attribs = array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' );
1835 - $checkboxes['reviewed'] = Xml::check( 'wpReviewEdit',
1836 - $wgRequest->getCheck('wpReviewEdit'), $attribs ) .
 1840+ $checkboxes['reviewed'] = Xml::check( 'wpReviewEdit',
 1841+ $wgRequest->getCheck( 'wpReviewEdit' ), $attribs ) .
18371842 '&nbsp;' . Xml::label( $reviewLabel, 'wpReviewEdit' );
18381843 }
18391844 }
@@ -1842,21 +1847,21 @@
18431848 public static function addBacklogNotice( &$notice ) {
18441849 global $wgUser, $wgTitle;
18451850 $namespaces = FlaggedRevs::getReviewNamespaces();
1846 - if ( !count($namespaces) ) {
 1851+ if ( !count( $namespaces ) ) {
18471852 return true; // nothing to have a backlog on
18481853 }
1849 - if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
 1854+ if ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
18501855 return true; // nothing to do here
18511856 }
1852 - if( !$wgUser->isAllowed('review') )
 1857+ if ( !$wgUser->isAllowed( 'review' ) )
18531858 return true; // not relevant to user
1854 -
 1859+
18551860 $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
18561861 $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' );
1857 - if( $wgTitle->equals($watchlist) || $wgTitle->equals($recentchanges) ) {
 1862+ if ( $wgTitle->equals( $watchlist ) || $wgTitle->equals( $recentchanges ) ) {
18581863 $dbr = wfGetDB( DB_SLAVE );
18591864 $watchedOutdated = $dbr->selectField(
1860 - array('watchlist','page','flaggedpages'), '1',
 1865+ array( 'watchlist', 'page', 'flaggedpages' ), '1',
18611866 array( 'wl_user' => $wgUser->getId(), // this user
18621867 'wl_namespace' => $namespaces, // reviewable
18631868 'wl_namespace = page_namespace',
@@ -1866,26 +1871,26 @@
18671872 ), __METHOD__
18681873 );
18691874 # Give a notice if pages on the wachlist are outdated
1870 - if( $watchedOutdated ) {
1871 - $notice .= "<div id='mw-fr-oldreviewed-notice' class='plainlinks fr-watchlist-old-notice'>" .
1872 - wfMsgExt('flaggedrevs-watched-pending',array('parseinline')) . "</div>";
 1875+ if ( $watchedOutdated ) {
 1876+ $notice .= "<div id='mw-fr-oldreviewed-notice' class='plainlinks fr-watchlist-old-notice'>" .
 1877+ wfMsgExt( 'flaggedrevs-watched-pending', array( 'parseinline' ) ) . "</div>";
18731878 # Otherwise, give a notice if there is a large backlog in general
18741879 } else {
18751880 $pages = $dbr->estimateRowCount( 'page', '*',
1876 - array('page_namespace' => $namespaces), __METHOD__ );
 1881+ array( 'page_namespace' => $namespaces ), __METHOD__ );
18771882 # For small wikis, just get the real numbers to avoid some bogus messages
1878 - if( $pages < 50 ) {
 1883+ if ( $pages < 50 ) {
18791884 $pages = $dbr->selectField( 'page', 'COUNT(*)',
1880 - array('page_namespace' => $namespaces), __METHOD__ );
 1885+ array( 'page_namespace' => $namespaces ), __METHOD__ );
18811886 $unreviewed = $dbr->selectField( 'flaggedpages', 'COUNT(*)',
18821887 'fp_pending_since IS NOT NULL', __METHOD__ );
18831888 } else {
18841889 $unreviewed = $dbr->estimateRowCount( 'flaggedpages', '*',
18851890 'fp_pending_since IS NOT NULL', __METHOD__ );
18861891 }
1887 - if( $unreviewed > .02*$pages ) {
1888 - $notice .= "<div id='mw-fr-oldreviewed-notice' class='plainlinks fr-backlognotice'>" .
1889 - wfMsgExt('flaggedrevs-backlog',array('parseinline')) . "</div>";
 1892+ if ( $unreviewed > .02 * $pages ) {
 1893+ $notice .= "<div id='mw-fr-oldreviewed-notice' class='plainlinks fr-backlognotice'>" .
 1894+ wfMsgExt( 'flaggedrevs-backlog', array( 'parseinline' ) ) . "</div>";
18901895 }
18911896 }
18921897 }
@@ -1894,13 +1899,13 @@
18951900
18961901 public static function stableDumpQuery( &$tables, &$opts, &$join ) {
18971902 $namespaces = FlaggedRevs::getReviewNamespaces();
1898 - $tables = array('flaggedpages','page','revision');
 1903+ $tables = array( 'flaggedpages', 'page', 'revision' );
18991904 $opts['ORDER BY'] = 'fp_page_id ASC';
19001905 $opts['USE INDEX'] = array( 'flaggedpages' => 'PRIMARY' );
19011906 $join['page'] = array( 'INNER JOIN',
1902 - array('page_id = fp_page_id','page_namespace' => $namespaces)
 1907+ array( 'page_id = fp_page_id', 'page_namespace' => $namespaces )
19031908 );
1904 - $join['revision'] = array('INNER JOIN','rev_page = fp_page_id AND rev_id = fp_stable');
 1909+ $join['revision'] = array( 'INNER JOIN', 'rev_page = fp_page_id AND rev_id = fp_stable' );
19051910 return false; // final
19061911 }
19071912
@@ -1908,22 +1913,22 @@
19091914 // Code stolen from Stabilization (which was stolen from ProtectionForm)
19101915 public static function onProtectionForm( $article, &$output ) {
19111916 global $wgUser, $wgRequest, $wgOut, $wgLang;
1912 - if( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) {
 1917+ if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) {
19131918 return true; // nothing to do
1914 - } else if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
 1919+ } else if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
19151920 return true; // not a reviewable page
19161921 }
19171922 # Can the user actually do anything?
1918 - $isAllowed = $wgUser->isAllowed('stablesettings');
 1923+ $isAllowed = $wgUser->isAllowed( 'stablesettings' );
19191924 $disabledAttrib = !$isAllowed ? array( 'disabled' => 'disabled' ) : array();
19201925 # Get the current config/expiry
19211926 $config = FlaggedRevs::getPageVisibilitySettings( $article->getTitle(), true );
1922 - $oldExpiry = $config['expiry'] !== 'infinity' ?
 1927+ $oldExpiry = $config['expiry'] !== 'infinity' ?
19231928 wfTimestamp( TS_RFC2822, $config['expiry'] ) : 'infinite';
19241929 # Load request params...
19251930 $selected = $wgRequest->getVal( 'wpStabilityConfig',
1926 - FlaggedRevs::getProtectionLevel($config) );
1927 - if( $selected == 'invalid' ) {
 1931+ FlaggedRevs::getProtectionLevel( $config ) );
 1932+ if ( $selected == 'invalid' ) {
19281933 throw new MWException( 'This page has an undefined stability configuration!' );
19291934 }
19301935 $expiry = $wgRequest->getText( 'mwStabilize-expiry' );
@@ -1933,8 +1938,8 @@
19341939 function updateStabilizationDropdowns() {
19351940 val = document.getElementById('mwExpirySelection').value;
19361941 if( val == 'existing' )
1937 - document.getElementById('mwStabilize-expiry').value = ".
1938 - Xml::encodeJsVar($oldExpiry).";
 1942+ document.getElementById('mwStabilize-expiry').value = " .
 1943+ Xml::encodeJsVar( $oldExpiry ) . ";
19391944 else if( val != 'othertime' )
19401945 document.getElementById('mwStabilize-expiry').value = val;
19411946 }
@@ -1943,7 +1948,7 @@
19441949 # Add an extra row to the protection fieldset tables
19451950 $output .= "<tr><td>";
19461951 $output .= Xml::openElement( 'fieldset' );
1947 - $output .= Xml::element( 'legend', null, wfMsg('flaggedrevs-protect-legend') );
 1952+ $output .= Xml::element( 'legend', null, wfMsg( 'flaggedrevs-protect-legend' ) );
19481953 # Add a "no restrictions" level
19491954 $effectiveLevels = array( "none" => null );
19501955 $effectiveLevels += FlaggedRevs::getProtectionLevels();
@@ -1955,32 +1960,32 @@
19561961 ) + $disabledAttrib;
19571962 $output .= Xml::openElement( 'select', $attribs );
19581963 # Show all restriction levels in a select...
1959 - foreach( $effectiveLevels as $level => $x ) {
1960 - if( $level == 'none' ) {
 1964+ foreach ( $effectiveLevels as $level => $x ) {
 1965+ if ( $level == 'none' ) {
19611966 $label = FlaggedRevs::stableOnlyIfConfigured()
19621967 ? wfMsg( 'flaggedrevs-protect-none' )
19631968 : wfMsg( 'flaggedrevs-protect-basic' );
19641969 } else {
1965 - $label = wfMsg( 'flaggedrevs-protect-'.$level );
 1970+ $label = wfMsg( 'flaggedrevs-protect-' . $level );
19661971 }
19671972 // Default to the key itself if no UI message
1968 - if( wfEmptyMsg('flaggedrevs-protect-'.$level,$label) ) {
1969 - $label = 'flaggedrevs-protect-'.$level;
 1973+ if ( wfEmptyMsg( 'flaggedrevs-protect-' . $level, $label ) ) {
 1974+ $label = 'flaggedrevs-protect-' . $level;
19701975 }
19711976 $output .= Xml::option( $label, $level, $level == $selected );
19721977 }
19731978 $output .= Xml::closeElement( 'select' );
19741979 # Get expiry dropdown
19751980 $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' );
1976 - $showProtectOptions = ($scExpiryOptions !== '-' && $isAllowed);
 1981+ $showProtectOptions = ( $scExpiryOptions !== '-' && $isAllowed );
19771982 # Add the current expiry as an option
19781983 $expiryFormOptions = '';
1979 - if( $config['expiry'] && $config['expiry'] != 'infinity' ) {
 1984+ if ( $config['expiry'] && $config['expiry'] != 'infinity' ) {
19801985 $timestamp = $wgLang->timeanddate( $config['expiry'] );
19811986 $d = $wgLang->date( $config['expiry'] );
19821987 $t = $wgLang->time( $config['expiry'] );
1983 - $expiryFormOptions .=
1984 - Xml::option(
 1988+ $expiryFormOptions .=
 1989+ Xml::option(
19851990 wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ),
19861991 'existing',
19871992 $config['expiry'] == 'existing'
@@ -1988,25 +1993,25 @@
19891994 }
19901995 $expiryFormOptions .= Xml::option( wfMsg( 'protect-othertime-op' ), "othertime" ) . "\n";
19911996 # Add custom levels (from MediaWiki message)
1992 - foreach( explode(',',$scExpiryOptions) as $option ) {
1993 - if( strpos($option,":") === false ) {
 1997+ foreach ( explode( ',', $scExpiryOptions ) as $option ) {
 1998+ if ( strpos( $option, ":" ) === false ) {
19941999 $show = $value = $option;
19952000 } else {
1996 - list($show, $value) = explode(":",$option);
 2001+ list( $show, $value ) = explode( ":", $option );
19972002 }
1998 - $show = htmlspecialchars($show);
1999 - $value = htmlspecialchars($value);
 2003+ $show = htmlspecialchars( $show );
 2004+ $value = htmlspecialchars( $value );
20002005 $expiryFormOptions .= Xml::option( $show, $value, $config['expiry'] === $value )."\n";
20012006 }
20022007 # Add expiry dropdown to form
20032008 $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' );
2004 - $showProtectOptions = ($scExpiryOptions !== '-' && $isAllowed);
 2009+ $showProtectOptions = ( $scExpiryOptions !== '-' && $isAllowed );
20052010 $output .= "<table>"; // expiry table start
2006 - if( $showProtectOptions && $isAllowed ) {
 2011+ if ( $showProtectOptions && $isAllowed ) {
20072012 $output .= "
20082013 <tr>
20092014 <td class='mw-label'>" .
2010 - Xml::label( wfMsg('stabilization-expiry'), 'mwExpirySelection' ) .
 2015+ Xml::label( wfMsg( 'stabilization-expiry' ), 'mwExpirySelection' ) .
20112016 "</td>
20122017 <td class='mw-input'>" .
20132018 Xml::tags( 'select',
@@ -2025,7 +2030,7 @@
20262031 $output .= "
20272032 <tr>
20282033 <td class='mw-label'>" .
2029 - Xml::label( wfMsg('stabilization-othertime'), 'mwStabilize-expiry' ) .
 2034+ Xml::label( wfMsg( 'stabilization-othertime' ), 'mwStabilize-expiry' ) .
20302035 '</td>
20312036 <td class="mw-input">' .
20322037 Xml::input( "mwStabilize-expiry", 50,
@@ -2041,13 +2046,13 @@
20422047
20432048 // Add stability log extract to protection form
20442049 public static function insertStabilityLog( $article, $out ) {
2045 - if( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) {
 2050+ if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) {
20462051 return true; // nothing to do
2047 - } else if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
 2052+ } else if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
20482053 return true; // not a reviewable page
20492054 }
20502055 # Show relevant lines from the stability log:
2051 - $out->addHTML( Xml::element( 'h2', null, LogPage::logName('stable') ) );
 2056+ $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'stable' ) ) );
20522057 LogEventsList::showLogExtract( $out, 'stable', $article->getTitle()->getPrefixedText() );
20532058 return true;
20542059 }
@@ -2056,12 +2061,12 @@
20572062 public static function onProtectionSave( $article, &$errorMsg ) {
20582063 global $wgUser, $wgRequest;
20592064 $levels = FlaggedRevs::getProtectionLevels();
2060 - if( empty($levels) || !$article->exists() )
 2065+ if ( empty( $levels ) || !$article->exists() )
20612066 return true; // simple custom levels set for action=protect
2062 - if( wfReadOnly() || !$wgUser->isAllowed('stablesettings') ) {
 2067+ if ( wfReadOnly() || !$wgUser->isAllowed( 'stablesettings' ) ) {
20632068 return true; // user cannot change anything
20642069 }
2065 - if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
 2070+ if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
20662071 return true; // not a reviewable page
20672072 }
20682073 $form = new Stabilization();
@@ -2073,12 +2078,12 @@
20742079 $form->expirySelection = $wgRequest->getVal( 'wpExpirySelection' ); # Expiry dropdown
20752080 # Fill in config from the protection level...
20762081 $selected = $wgRequest->getVal( 'mwStabilityConfig' );
2077 - if( $selected == "none" ) {
 2082+ if ( $selected == "none" ) {
20782083 $form->select = FlaggedRevs::getPrecedence(); // default
20792084 $form->override = (int)FlaggedRevs::isStableShownByDefault(); // default
20802085 $form->autoreview = ''; // default
20812086 $form->reviewThis = false;
2082 - } else if( isset($levels[$selected]) ) {
 2087+ } else if ( isset( $levels[$selected] ) ) {
20832088 $form->select = $levels[$selected]['select'];
20842089 $form->override = $levels[$selected]['override'];
20852090 $form->autoreview = $levels[$selected]['autoreview'];
@@ -2087,10 +2092,10 @@
20882093 return false; // bad level
20892094 }
20902095 $form->wasPosted = $wgRequest->wasPosted();
2091 - if( $form->handleParams() ) {
 2096+ if ( $form->handleParams() ) {
20922097 $status = $form->submit();
2093 - if( $status !== true ) {
2094 - $errorMsg = wfMsg($status); // some error message
 2098+ if ( $status !== true ) {
 2099+ $errorMsg = wfMsg( $status ); // some error message
20952100 }
20962101 }
20972102 return true;
Index: trunk/extensions/FlaggedRevs/FlaggedRevsLogs.php
@@ -7,7 +7,7 @@
88 */
99 public static function isReviewAction( $action ) {
1010 return in_array( $action,
11 - array('approve','approve2','approve-a', 'approve2-a','unapprove','unapprove2')
 11+ array( 'approve', 'approve2', 'approve-a', 'approve2-a', 'unapprove', 'unapprove2' )
1212 );
1313 }
1414
@@ -16,7 +16,7 @@
1717 * $action is a valid review log deprecate action
1818 */
1919 public static function isReviewDeapproval( $action ) {
20 - return ($action == 'unapprove' || $action == 'unapprove2');
 20+ return ( $action == 'unapprove' || $action == 'unapprove2' );
2121 }
2222
2323 /**
@@ -30,7 +30,7 @@
3131 # Add history link showing edits right before the config change
3232 $links = ' (';
3333 $links .= $wgUser->getSkin()->link( $title,
34 - wfMsgHtml('hist'),
 34+ wfMsgHtml( 'hist' ),
3535 array(),
3636 array( 'action' => 'history', 'offset' => $timestamp ) );
3737 $links .= ')';
@@ -45,28 +45,28 @@
4646 $links = '';
4747 # Show link to page with oldid=x as well as the diff to the former stable rev.
4848 # Param format is <rev id, last stable id, rev timestamp>.
49 - if( isset($params[0]) ) {
 49+ if ( isset( $params[0] ) ) {
5050 $revId = (int)$params[0]; // the revision reviewed
51 - $oldStable = isset($params[1]) ? (int)$params[1] : 0;
 51+ $oldStable = isset( $params[1] ) ? (int)$params[1] : 0;
5252 # Show diff to changes since the prior stable version
53 - if( $oldStable && $revId > $oldStable ) {
 53+ if ( $oldStable && $revId > $oldStable ) {
5454 $msg = self::isReviewDeapproval( $action )
5555 ? 'review-logentry-diff2' // unreviewed
5656 : 'review-logentry-diff'; // reviewed
5757 $links .= '(';
5858 $links .= $wgUser->getSkin()->makeKnownLinkObj( $title,
59 - wfMsgHtml($msg),
 59+ wfMsgHtml( $msg ),
6060 "oldid={$oldStable}&diff={$revId}" );
6161 $links .= ')';
6262 }
6363 # Show a diff link to this revision
64 - $ts = empty($params[2])
65 - ? Revision::getTimestampFromId($title,$revId)
 64+ $ts = empty( $params[2] )
 65+ ? Revision::getTimestampFromId( $title, $revId )
6666 : $params[2];
6767 $time = $wgLang->timeanddate( $ts );
6868 $links .= ' (';
69 - $links .= $wgUser->getSkin()->makeKnownLinkObj( $title,
70 - wfMsgHtml('review-logentry-id',$revId,$time),
 69+ $links .= $wgUser->getSkin()->makeKnownLinkObj( $title,
 70+ wfMsgHtml( 'review-logentry-id', $revId, $time ),
7171 "oldid={$revId}&diff=prev&diffonly=0" );
7272 $links .= ')';
7373 }
@@ -84,8 +84,8 @@
8585 * @param bool $approve, approved? (otherwise unapproved)
8686 * @param bool $auto
8787 */
88 - public static function updateLog( $title, $dims, $oldDims, $comment,
89 - $revId, $stableId, $approve, $auto=false )
 88+ public static function updateLog( $title, $dims, $oldDims, $comment,
 89+ $revId, $stableId, $approve, $auto = false )
9090 {
9191 global $wgFlaggedRevsLogInRC;
9292 $log = new LogPage( 'review',
@@ -95,42 +95,42 @@
9696 # Tag rating list (e.g. accuracy=x, depth=y, style=z)
9797 $ratings = array();
9898 # Skip rating list if flagging is just an 0/1 feature...
99 - if( !FlaggedRevs::binaryFlagging() ) {
100 - foreach( $dims as $quality => $level ) {
 99+ if ( !FlaggedRevs::binaryFlagging() ) {
 100+ foreach ( $dims as $quality => $level ) {
101101 $ratings[] = wfMsgForContent( "revreview-$quality" ) .
102 - wfMsgForContent( 'colon-separator' ) .
103 - wfMsgForContent("revreview-$quality-$level" );
 102+ wfMsgForContent( 'colon-separator' ) .
 103+ wfMsgForContent( "revreview-$quality-$level" );
104104 }
105105 }
106 - $isAuto = ($auto && !FlaggedRevs::isQuality($dims)); // Paranoid check
 106+ $isAuto = ( $auto && !FlaggedRevs::isQuality( $dims ) ); // Paranoid check
107107 // Approved revisions
108 - if( $approve ) {
109 - if( $isAuto ) {
110 - $comment = wfMsgForContent('revreview-auto'); // override this
 108+ if ( $approve ) {
 109+ if ( $isAuto ) {
 110+ $comment = wfMsgForContent( 'revreview-auto' ); // override this
111111 }
112112 # Make comma-separated list of ratings
113 - $rating = !empty($ratings)
114 - ? '[' . implode(', ',$ratings). ']'
 113+ $rating = !empty( $ratings )
 114+ ? '[' . implode( ', ', $ratings ) . ']'
115115 : '';
116116 # Append comment with ratings
117 - if( $rating != '' ) {
 117+ if ( $rating != '' ) {
118118 $comment .= $comment ? " $rating" : $rating;
119119 }
120120 # Sort into the proper action (useful for filtering)
121 - $action = (FlaggedRevs::isQuality($dims) || FlaggedRevs::isQuality($oldDims)) ?
 121+ $action = ( FlaggedRevs::isQuality( $dims ) || FlaggedRevs::isQuality( $oldDims ) ) ?
122122 'approve2' : 'approve';
123 - if( !$stableId ) { // first time
 123+ if ( !$stableId ) { // first time
124124 $action .= $isAuto ? "-ia" : "-i";
125 - } elseif( $isAuto ) { // automatic
 125+ } elseif ( $isAuto ) { // automatic
126126 $action .= "-a";
127127 }
128128 // De-approved revisions
129129 } else {
130 - $action = FlaggedRevs::isQuality($oldDims) ?
 130+ $action = FlaggedRevs::isQuality( $oldDims ) ?
131131 'unapprove2' : 'unapprove';
132132 }
133133 $ts = Revision::getTimestampFromId( $title, $revId );
134134 # Param format is <rev id,old stable id, rev timestamp>
135 - $log->addEntry( $action, $title, $comment, array($revId,$stableId,$ts) );
 135+ $log->addEntry( $action, $title, $comment, array( $revId, $stableId, $ts ) );
136136 }
137137 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -16,21 +16,21 @@
1717 * Get the FlaggedArticleView for this request
1818 */
1919 public static function singleton() {
20 - if( self::$instance == null ) {
 20+ if ( self::$instance == null ) {
2121 self::$instance = new self();
2222 }
2323 return self::$instance;
2424 }
25 - protected function __construct() {}
26 - protected function __clone() {}
 25+ protected function __construct() { }
 26+ protected function __clone() { }
2727
2828 /*
2929 * Load the global FlaggedArticle instance
3030 */
3131 protected function load() {
32 - if( !$this->loaded ) {
 32+ if ( !$this->loaded ) {
3333 $this->article = self::globalArticleInstance();
34 - if( $this->article == null ) {
 34+ if ( $this->article == null ) {
3535 throw new MWException( 'FlaggedArticleViewer has no context article!' );
3636 }
3737 }
@@ -42,7 +42,7 @@
4343 */
4444 public static function globalArticleInstance() {
4545 global $wgTitle;
46 - if( !empty( $wgTitle ) ) {
 46+ if ( !empty( $wgTitle ) ) {
4747 return FlaggedArticle::getTitleInstance( $wgTitle );
4848 }
4949 return null;
@@ -57,28 +57,28 @@
5858 $this->load();
5959 # This only applies to viewing content pages
6060 $action = $wgRequest->getVal( 'action', 'view' );
61 - if( !self::isViewAction($action) || !$this->article->isReviewable() )
 61+ if ( !self::isViewAction( $action ) || !$this->article->isReviewable() )
6262 return false;
6363 # Does not apply to diffs/old revision...
64 - if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') )
 64+ if ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'diff' ) )
6565 return false;
6666 # Explicit requests for a certain stable version handled elsewhere...
67 - if( $wgRequest->getVal('stableid') )
 67+ if ( $wgRequest->getVal( 'stableid' ) )
6868 return false;
6969 # Check user preferences
70 - if( $wgUser->getOption('flaggedrevsstable') )
71 - return !( $wgRequest->getIntOrNull('stable') === 0 );
 70+ if ( $wgUser->getOption( 'flaggedrevsstable' ) )
 71+ return !( $wgRequest->getIntOrNull( 'stable' ) === 0 );
7272 # Get page configuration
7373 $config = $this->article->getVisibilitySettings();
7474 # Does the stable version override the current one?
75 - if( $config['override'] ) {
76 - if( FlaggedRevs::ignoreDefaultVersion() ) {
77 - return ( $wgRequest->getIntOrNull('stable') === 1 );
 75+ if ( $config['override'] ) {
 76+ if ( FlaggedRevs::ignoreDefaultVersion() ) {
 77+ return ( $wgRequest->getIntOrNull( 'stable' ) === 1 );
7878 }
7979 # Viewer sees stable by default
80 - return !( $wgRequest->getIntOrNull('stable') === 0 );
 80+ return !( $wgRequest->getIntOrNull( 'stable' ) === 0 );
8181 # We are explicity requesting the stable version?
82 - } elseif( $wgRequest->getIntOrNull('stable') === 1 ) {
 82+ } elseif ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) {
8383 return true;
8484 }
8585 return false;
@@ -101,7 +101,7 @@
102102 public function isDiffShownOnEdit() {
103103 global $wgUser;
104104 $this->load();
105 - return ( $wgUser->isAllowed('review') || $this->isStableShownByDefaultUser() );
 105+ return ( $wgUser->isAllowed( 'review' ) || $this->isStableShownByDefaultUser() );
106106 }
107107
108108 /**
@@ -121,7 +121,7 @@
122122 global $wgOut, $wgRequest;
123123 $this->load();
124124 // UI may be limited to unobtrusive patrolling system
125 - if( $wgRequest->getVal('stableid') || !$this->article->limitedUI() ) {
 125+ if ( $wgRequest->getVal( 'stableid' ) || !$this->article->limitedUI() ) {
126126 $wgOut->appendSubtitle( $this->reviewNotice );
127127 }
128128 return true;
@@ -136,23 +136,23 @@
137137 global $wgRequest, $wgOut, $wgLang;
138138 $this->load();
139139 # Only for viewing old versions. UI may be limited to unobtrusive patrolling system.
140 - if( !$wgRequest->getVal('oldid') || $this->article->limitedUI() )
 140+ if ( !$wgRequest->getVal( 'oldid' ) || $this->article->limitedUI() )
141141 return true;
142142 # We may have nav links like "direction=prev&oldid=x"
143143 $revID = $this->article->getOldIDFromRequest();
144144 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $revID );
145145 # Give a notice if this rev ID corresponds to a reviewed version...
146 - if( !is_null($frev) ) {
 146+ if ( !is_null( $frev ) ) {
147147 $time = $wgLang->date( $frev->getTimestamp(), true );
148148 $flags = $frev->getTags();
149149 $quality = FlaggedRevs::isQuality( $flags );
150150 $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source';
151 - $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
 151+ $tag = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time );
152152 # Hide clutter
153 - if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) {
154 - $tag .= " " . FlaggedRevsXML::ratingToggle() .
 153+ if ( !FlaggedRevs::useSimpleUI() && !empty( $flags ) ) {
 154+ $tag .= " " . FlaggedRevsXML::ratingToggle() .
155155 "<span id='mw-fr-revisionratings' style='display:block;'><br />" .
156 - wfMsgHtml('revreview-oldrating') .
 156+ wfMsgHtml( 'revreview-oldrating' ) .
157157 FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
158158 }
159159 $css = 'flaggedrevs_notice plainlinks noprint';
@@ -167,8 +167,8 @@
168168 */
169169 protected function getRequestedStableId() {
170170 global $wgRequest;
171 - $reqId = $wgRequest->getVal('stableid');
172 - if( $reqId === "best" ) {
 171+ $reqId = $wgRequest->getVal( 'stableid' );
 172+ if ( $reqId === "best" ) {
173173 $reqId = FlaggedRevs::getPrimeFlaggedRevId( $this->article );
174174 }
175175 return $reqId;
@@ -184,14 +184,14 @@
185185 $this->load();
186186 # Only trigger on article view for content pages, not for protect/delete/hist...
187187 $action = $wgRequest->getVal( 'action', 'view' );
188 - if( !self::isViewAction($action) || !$this->article->exists() )
 188+ if ( !self::isViewAction( $action ) || !$this->article->exists() )
189189 return true;
190190 # Do not clutter up diffs any further and leave archived versions alone...
191 - if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) {
 191+ if ( $wgRequest->getVal( 'diff' ) || $wgRequest->getVal( 'oldid' ) ) {
192192 return true;
193193 }
194194 # Only trigger for reviewable pages
195 - if( !$this->article->isReviewable() ) {
 195+ if ( !$this->article->isReviewable() ) {
196196 return true;
197197 }
198198 $simpleTag = $old = $stable = false;
@@ -202,15 +202,15 @@
203203 $frev = $srev; // $frev is the revision we are looking at
204204 # Check for any explicitly requested old stable version...
205205 $reqId = $this->getRequestedStableId();
206 - if( $reqId ) {
207 - if( !$stableId ) {
 206+ if ( $reqId ) {
 207+ if ( !$stableId ) {
208208 $reqId = false; // must be invalid
209209 # Treat requesting the stable version by ID as &stable=1
210 - } else if( $reqId != $stableId ) {
 210+ } else if ( $reqId != $stableId ) {
211211 $old = true; // old reviewed version requested by ID
212212 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(),
213213 $reqId, FR_TEXT );
214 - if( !$frev ) {
 214+ if ( !$frev ) {
215215 $reqId = false; // invalid ID given
216216 }
217217 } else {
@@ -218,8 +218,8 @@
219219 }
220220 }
221221 // $reqId is null if nothing requested, false if invalid
222 - if( $reqId === false ) {
223 - $wgOut->addWikiText( wfMsg('revreview-invalid') );
 222+ if ( $reqId === false ) {
 223+ $wgOut->addWikiText( wfMsg( 'revreview-invalid' ) );
224224 $wgOut->returnToMain( false, $this->article->getTitle() );
225225 # Tell MW that parser output is done
226226 $outputDone = true;
@@ -229,7 +229,7 @@
230230 // Is the page config altered?
231231 $prot = FlaggedRevsXML::lockStatusIcon( $this->article );
232232 // Is there no stable version?
233 - if( is_null($frev) ) {
 233+ if ( is_null( $frev ) ) {
234234 # Add "no reviewed version" tag, but not for printable output
235235 $this->showUnreviewedPage( $tag, $prot );
236236 return true;
@@ -244,13 +244,13 @@
245245 // set to override given the relevant conditions. If the user is
246246 // requesting the stable revision ("&stableid=x"), defer to override
247247 // behavior below, since it is the same as ("&stable=1").
248 - if( $old ) {
 248+ if ( $old ) {
249249 $this->showOldReviewedVersion( $srev, $frev, $tag, $prot );
250250 $outputDone = true; # Tell MW that parser output is done
251251 $pcache = false;
252252 // Stable version requested by ID or relevant conditions met to
253253 // to override page view.
254 - } else if( $stable || $this->pageOverride() ) {
 254+ } else if ( $stable || $this->pageOverride() ) {
255255 $this->showStableVersion( $srev, $tag, $prot );
256256 $outputDone = true; # Tell MW that parser output is done
257257 $pcache = false;
@@ -261,13 +261,13 @@
262262 $this->showDraftVersion( $srev, $tag, $prot );
263263 }
264264 # Some checks for which tag CSS to use
265 - if( FlaggedRevs::useSimpleUI() ) $tagClass = 'flaggedrevs_short';
266 - elseif( $simpleTag ) $tagClass = 'flaggedrevs_notice';
267 - elseif( $pristine ) $tagClass = 'flaggedrevs_pristine';
268 - elseif( $quality ) $tagClass = 'flaggedrevs_quality';
 265+ if ( FlaggedRevs::useSimpleUI() ) $tagClass = 'flaggedrevs_short';
 266+ elseif ( $simpleTag ) $tagClass = 'flaggedrevs_notice';
 267+ elseif ( $pristine ) $tagClass = 'flaggedrevs_pristine';
 268+ elseif ( $quality ) $tagClass = 'flaggedrevs_quality';
269269 else $tagClass = 'flaggedrevs_basic';
270270 # Wrap tag contents in a div
271 - if( $tag != '' ) {
 271+ if ( $tag != '' ) {
272272 $rtl = $wgContLang->isRTL() ? " rtl" : ""; // RTL langauges
273273 $tag = "<div id='mw-fr-revisiontag' class='{$tagClass}{$rtl} plainlinks noprint'>" .
274274 "$tag</div>";
@@ -281,19 +281,19 @@
282282 * @param $tag review box/bar info
283283 * @param $prot protection notice
284284 * Tag output function must be called by caller
285 - */
 285+ */
286286 protected function showUnreviewedPage( $tag, $prot ) {
287287 global $wgOut, $wgContLang;
288 - if( $wgOut->isPrintable() ) {
 288+ if ( $wgOut->isPrintable() ) {
289289 return;
290290 }
291291 // Simple icon-based UI
292 - if( FlaggedRevs::useSimpleUI() ) {
 292+ if ( FlaggedRevs::useSimpleUI() ) {
293293 // RTL langauges
294294 $rtl = $wgContLang->isRTL() ? " rtl" : "";
295295 $msg = 'revreview-quick-none';
296296 $tag .= "{$prot}<span class='fr-icon-current plainlinks'></span>" .
297 - wfMsgExt($msg,array('parseinline'));
 297+ wfMsgExt( $msg, array( 'parseinline' ) );
298298 $css = 'flaggedrevs_short{$rtl} plainlinks noprint';
299299 $tag = "<div id='mw-fr-revisiontag' class='$css'>" .
300300 "$tag</div>";
@@ -304,7 +304,7 @@
305305 $css = 'flaggedrevs_notice plainlinks noprint';
306306 $tag = "<div id='mw-fr-revisiontag' class='$css'>" .
307307 "{$prot}<span class='fr-icon-current plainlinks'></span>" .
308 - wfMsgExt($msg, array('parseinline')) . "</div>";
 308+ wfMsgExt( $msg, array( 'parseinline' ) ) . "</div>";
309309 $this->reviewNotice .= $tag;
310310 }
311311 }
@@ -326,7 +326,7 @@
327327 $pristine = FlaggedRevs::isPristine( $flags );
328328 # Get stable version sync status
329329 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article );
330 - if( $synced ) {
 330+ if ( $synced ) {
331331 $this->setReviewNotes( $srev ); // Still the same
332332 } else {
333333 $this->maybeShowTopDiff( $srev, $quality ); // user may want diff (via prefs)
@@ -334,11 +334,11 @@
335335 # If they are synced, do special styling
336336 $simpleTag = !$synced;
337337 # Give notice to newer users if an unreviewed edit was completed...
338 - if( !$synced && $wgRequest->getVal('shownotice') && !$wgUser->isAllowed('review') ) {
 338+ if ( !$synced && $wgRequest->getVal( 'shownotice' ) && !$wgUser->isAllowed( 'review' ) ) {
339339 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() );
340 - $tooltip = wfMsgHtml('revreview-draft-title');
 340+ $tooltip = wfMsgHtml( 'revreview-draft-title' );
341341 $pending = "{$prot}<span class='fr-icon-current' title=\"{$tooltip}\"></span>" .
342 - wfMsgExt('revreview-edited',array('parseinline'),$srev->getRevId(),$revsSince);
 342+ wfMsgExt( 'revreview-edited', array( 'parseinline' ), $srev->getRevId(), $revsSince );
343343 $pending = "<div id='mw-fr-reviewnotice' class='flaggedrevs_preview plainlinks'>" .
344344 "$pending</div>";
345345 # Notice should always use subtitle
@@ -346,15 +346,15 @@
347347 # Construct some tagging for non-printable outputs. Note that the pending
348348 # notice has all this info already, so don't do this if we added that already.
349349 # Also, if low profile UI is enabled and the page is synced, skip the tag.
350 - } else if( !$wgOut->isPrintable() && !($this->article->lowProfileUI() && $synced) ) {
 350+ } else if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) {
351351 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() );
352352 $class = 'fr-icon-current'; // default
353353 $tooltip = 'revreview-draft-title';
354354 // Simple icon-based UI
355 - if( FlaggedRevs::useSimpleUI() ) {
356 - if( !$wgUser->getId() ) {
 355+ if ( FlaggedRevs::useSimpleUI() ) {
 356+ if ( !$wgUser->getId() ) {
357357 $msgHTML = ''; // Anons just see simple icons
358 - } else if( $synced ) {
 358+ } else if ( $synced ) {
359359 $msg = $quality
360360 ? 'revreview-quick-quality-same'
361361 : 'revreview-quick-basic-same';
@@ -364,23 +364,23 @@
365365 $tooltip = $quality
366366 ? 'revreview-quality-title'
367367 : 'revreview-stable-title';
368 - $msgHTML = wfMsgExt( $msg, array('parseinline'),
 368+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ),
369369 $srev->getRevId(), $revsSince );
370370 } else {
371371 $msg = $quality
372372 ? 'revreview-quick-see-quality'
373373 : 'revreview-quick-see-basic';
374 - $msgHTML = wfMsgExt( $msg, array('parseinline'),
 374+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ),
375375 $srev->getRevId(), $revsSince );
376376 }
377 - $tooltip = wfMsgHtml($tooltip);
 377+ $tooltip = wfMsgHtml( $tooltip );
378378 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>$msgHTML";
379379 $tag .= FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML,
380380 $revsSince, 'draft', $synced, false );
381381 // Standard UI
382382 } else {
383 - if( $synced ) {
384 - if( $quality ) {
 383+ if ( $synced ) {
 384+ if ( $quality ) {
385385 $msg = 'revreview-quality-same';
386386 $class = 'fr-icon-quality';
387387 $tooltip = 'revreview-quality-title';
@@ -389,22 +389,22 @@
390390 $class = 'fr-icon-stable';
391391 $tooltip = 'revreview-stable-title';
392392 }
393 - $msgHTML = wfMsgExt( $msg, array('parseinline'),
 393+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ),
394394 $srev->getRevId(), $time, $revsSince );
395395 } else {
396396 $msg = $quality
397397 ? 'revreview-newest-quality'
398398 : 'revreview-newest-basic';
399 - $msg .= ($revsSince == 0) ? '-i' : '';
400 - $msgHTML = wfMsgExt( $msg, array('parseinline'),
 399+ $msg .= ( $revsSince == 0 ) ? '-i' : '';
 400+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ),
401401 $srev->getRevId(), $time, $revsSince );
402402 }
403 - $tooltip = wfMsgHtml($tooltip);
 403+ $tooltip = wfMsgHtml( $tooltip );
404404 $tag .= "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" . $msgHTML;
405405 }
406406 }
407407 # Index the stable version only if it is the default
408 - if( $this->article->isStableShownByDefault() ) {
 408+ if ( $this->article->isStableShownByDefault() ) {
409409 $wgOut->setRobotPolicy( 'noindex,nofollow' );
410410 }
411411 }
@@ -430,12 +430,12 @@
431431 $text = $frev->getRevText();
432432 # Check if this is a redirect...
433433 $redirHtml = $this->getRedirectHtml( $text );
434 - if( $redirHtml == '' ) {
 434+ if ( $redirHtml == '' ) {
435435 $parserOut = FlaggedRevs::parseStableText( $this->article, $text, $frev->getRevId() );
436436 }
437437 # Construct some tagging for non-printable outputs. Note that the pending
438438 # notice has all this info already, so don't do this if we added that already.
439 - if( !$wgOut->isPrintable() ) {
 439+ if ( !$wgOut->isPrintable() ) {
440440 $class = $quality ?
441441 'fr-icon-quality' : 'fr-icon-stable';
442442 $tooltip = $quality
@@ -443,15 +443,15 @@
444444 : 'revreview-stable-title';
445445 $tooltip = wfMsgHtml( $tooltip );
446446 // Simple icon-based UI
447 - if( FlaggedRevs::useSimpleUI() ) {
 447+ if ( FlaggedRevs::useSimpleUI() ) {
448448 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() );
449 - if( !$wgUser->getId() ) {
 449+ if ( !$wgUser->getId() ) {
450450 $msgHTML = ''; // Anons just see simple icons
451451 } else {
452452 $msg = $quality
453453 ? 'revreview-quick-quality-old'
454454 : 'revreview-quick-basic-old';
455 - $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
 455+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time );
456456 }
457457 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}";
458458 $tag = FlaggedRevsXML::prettyRatingBox( $frev, $msgHTML,
@@ -460,19 +460,19 @@
461461 } else {
462462 $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old';
463463 $tag = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" .
464 - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
 464+ wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time );
465465 # Hide clutter
466 - if( !empty($flags) ) {
 466+ if ( !empty( $flags ) ) {
467467 $tag .= " " . FlaggedRevsXML::ratingToggle();
468468 $tag .= "<span id='mw-fr-revisionratings' style='display:block;'><br />" .
469 - wfMsgHtml('revreview-oldrating') .
 469+ wfMsgHtml( 'revreview-oldrating' ) .
470470 FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
471471 }
472472 }
473473 }
474474 # Output HTML
475475 $this->setReviewNotes( $frev );
476 - if( $redirHtml != '' ) {
 476+ if ( $redirHtml != '' ) {
477477 $wgOut->addHtml( $redirHtml );
478478 } else {
479479 $wgOut->addParserOutput( $parserOut );
@@ -501,11 +501,11 @@
502502 # Get parsed stable version
503503 $redirHtml = '';
504504 $parserOut = FlaggedRevs::getPageCache( $this->article, $wgUser );
505 - if( $parserOut == false ) {
 505+ if ( $parserOut == false ) {
506506 $text = $srev->getRevText();
507507 # Check if this is a redirect...
508508 $redirHtml = $this->getRedirectHtml( $text );
509 - if( $redirHtml == '' ) {
 509+ if ( $redirHtml == '' ) {
510510 $parserOut = FlaggedRevs::parseStableText(
511511 $this->article, $text, $srev->getRevId() );
512512 # Update the stable version cache
@@ -514,14 +514,14 @@
515515 }
516516 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article, $parserOut, null );
517517 # Construct some tagging
518 - if( !$wgOut->isPrintable() && !($this->article->lowProfileUI() && $synced) ) {
 518+ if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) {
519519 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() );
520520 $class = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
521521 $tooltip = $quality ? 'revreview-quality-title' : 'revreview-stable-title';
522 - $tooltip = wfMsgHtml($tooltip);
 522+ $tooltip = wfMsgHtml( $tooltip );
523523 // Simple icon-based UI
524 - if( FlaggedRevs::useSimpleUI() ) {
525 - if( !$wgUser->getId() ) {
 524+ if ( FlaggedRevs::useSimpleUI() ) {
 525+ if ( !$wgUser->getId() ) {
526526 $msgHTML = ''; // Anons just see simple icons
527527 } else {
528528 $msg = $quality
@@ -529,7 +529,7 @@
530530 : 'revreview-quick-basic';
531531 # Uses messages 'revreview-quick-quality-same', 'revreview-quick-basic-same'
532532 $msg = $synced ? "{$msg}-same" : $msg;
533 - $msgHTML = wfMsgExt( $msg, array('parseinline'),
 533+ $msgHTML = wfMsgExt( $msg, array( 'parseinline' ),
534534 $srev->getRevId(), $revsSince );
535535 }
536536 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}";
@@ -538,16 +538,16 @@
539539 // Standard UI
540540 } else {
541541 $msg = $quality ? 'revreview-quality' : 'revreview-basic';
542 - if( $synced ) {
 542+ if ( $synced ) {
543543 # uses messages 'revreview-quality-same', 'revreview-basic-same'
544544 $msg .= '-same';
545 - } elseif( $revsSince == 0 ) {
 545+ } elseif ( $revsSince == 0 ) {
546546 # uses messages 'revreview-quality-i', 'revreview-basic-i'
547547 $msg .= '-i';
548548 }
549549 $tag = "{$prot}<span class='{$class} plainlinks' title=\"{$tooltip}\"></span>" .
550 - wfMsgExt( $msg, array('parseinline'), $srev->getRevId(), $time, $revsSince );
551 - if( !empty($flags) ) {
 550+ wfMsgExt( $msg, array( 'parseinline' ), $srev->getRevId(), $time, $revsSince );
 551+ if ( !empty( $flags ) ) {
552552 $tag .= " " . FlaggedRevsXML::ratingToggle();
553553 $tag .= "<span id='mw-fr-revisionratings' style='display:block;'><br />" .
554554 FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
@@ -556,7 +556,7 @@
557557 }
558558 # Output HTML
559559 $this->setReviewNotes( $srev );
560 - if( $redirHtml != '' ) {
 560+ if ( $redirHtml != '' ) {
561561 $wgOut->addHtml( $redirHtml );
562562 } else {
563563 $wgOut->addParserOutput( $parserOut );
@@ -565,7 +565,7 @@
566566
567567 protected function getRedirectHtml( $text ) {
568568 $rTarget = $this->article->followRedirectText( $text );
569 - if( $rTarget ) {
 569+ if ( $rTarget ) {
570570 return $this->article->viewRedirect( $rTarget );
571571 }
572572 return '';
@@ -575,18 +575,18 @@
576576 * @param FlaggedRevision $srev, stable version
577577 * @param bool $quality, revision is quality
578578 * @returns bool, diff added to output
579 - */
 579+ */
580580 protected function maybeShowTopDiff( $srev, $quality ) {
581581 global $wgUser, $wgOut, $wgMemc;
582582 $this->load();
583 - if( !$wgUser->getBoolOption('flaggedrevsviewdiffs') )
 583+ if ( !$wgUser->getBoolOption( 'flaggedrevsviewdiffs' ) )
584584 return false; // nothing to do here
585 - if( !$wgUser->isAllowed('review') )
 585+ if ( !$wgUser->isAllowed( 'review' ) )
586586 return false; // does not apply to this user
587587 # Diff should only show for the draft
588588 $oldid = $this->article->getOldIDFromRequest();
589589 $latest = $this->article->getLatest();
590 - if( $oldid && $oldid != $latest ) {
 590+ if ( $oldid && $oldid != $latest ) {
591591 return false; // not viewing the draft
592592 }
593593 # Conditions are met to show diff...
@@ -594,24 +594,24 @@
595595 $rClass = FlaggedRevsXML::getQualityColor( false );
596596 $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
597597 $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[" .
598 - wfMsgHtml('hist-draft') . "]</span>";
 598+ wfMsgHtml( 'hist-draft' ) . "]</span>";
599599 $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[" .
600 - wfMsgHtml($leftNote)."]</span>";
 600+ wfMsgHtml( $leftNote ) . "]</span>";
601601 # Fetch the stable and draft revision text
602602 $oText = $srev->getRevText();
603 - if( $oText === false )
 603+ if ( $oText === false )
604604 return false; // deleted revision or something?
605605 $nText = $this->article->getContent();
606 - if( $nText === false )
 606+ if ( $nText === false )
607607 return false; // deleted revision or something?
608608 # Build diff at the top of the page
609 - if( strcmp($oText,$nText) !== 0 ) {
 609+ if ( strcmp( $oText, $nText ) !== 0 ) {
610610 $diffEngine = new DifferenceEngine();
611611 $diffEngine->showDiffStyle();
612612 $n = $this->article->getTitle()->countRevisionsBetween( $srev->getRevId(), $latest );
613 - if( $n ) {
 613+ if ( $n ) {
614614 $multiNotice = "<tr><td colspan='4' align='center' class='diff-multi'>" .
615 - wfMsgExt( 'diff-multi', array( 'parse' ), $n )."</td></tr>";
 615+ wfMsgExt( 'diff-multi', array( 'parse' ), $n ) . "</td></tr>";
616616 } else {
617617 $multiNotice = '';
618618 }
@@ -654,15 +654,15 @@
655655 # Determine timestamp. A reviewed version may have explicitly been requested...
656656 $frev = null;
657657 $time = false;
658 - if( $reqId = $wgRequest->getVal('stableid') ) {
 658+ if ( $reqId = $wgRequest->getVal( 'stableid' ) ) {
659659 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId );
660 - } elseif( $this->pageOverride() ) {
 660+ } elseif ( $this->pageOverride() ) {
661661 $frev = $this->article->getStableRev();
662662 }
663 - if( !is_null($frev) ) {
 663+ if ( !is_null( $frev ) ) {
664664 $time = $frev->getFileTimestamp();
665665 // B/C, may be stored in associated image version metadata table
666 - if( !$time ) {
 666+ if ( !$time ) {
667667 $dbr = wfGetDB( DB_SLAVE );
668668 $time = $dbr->selectField( 'flaggedimages',
669669 'fi_img_timestamp',
@@ -674,29 +674,29 @@
675675 # NOTE: if not found, this will use the current
676676 $wgArticle = new ImagePage( $this->article->getTitle(), $time );
677677 }
678 - if( !$time ) {
 678+ if ( !$time ) {
679679 # Try request parameter
680680 $time = $wgRequest->getVal( 'filetimestamp', false );
681681 }
682682
683 - if( !$time ) {
 683+ if ( !$time ) {
684684 return; // Use the default behaviour
685685 }
686686
687687 $title = $this->article->getTitle();
688688 $displayFile = wfFindFile( $title, array( 'time' => $time ) );
689689 # If none found, try current
690 - if( !$displayFile ) {
691 - wfDebug( __METHOD__.": {$title->getPrefixedDBkey()}: $time not found, using current\n" );
 690+ if ( !$displayFile ) {
 691+ wfDebug( __METHOD__ . ": {$title->getPrefixedDBkey()}: $time not found, using current\n" );
692692 $displayFile = wfFindFile( $title );
693693 # If none found, use a valid local placeholder
694 - if( !$displayFile ) {
 694+ if ( !$displayFile ) {
695695 $displayFile = wfLocalFile( $title ); // fallback to current
696696 }
697697 $normalFile = $displayFile;
698698 # If found, set $normalFile
699699 } else {
700 - wfDebug( __METHOD__.": {$title->getPrefixedDBkey()}: using timestamp $time\n" );
 700+ wfDebug( __METHOD__ . ": {$title->getPrefixedDBkey()}: using timestamp $time\n" );
701701 $normalFile = wfFindFile( $title );
702702 }
703703 }
@@ -708,12 +708,12 @@
709709 global $wgOut;
710710 $this->load();
711711 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
712 - if( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 712+ if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
713713 return true;
714714 }
715715 # Add a notice if there are pending edits...
716716 $frev = $this->article->getStableRev();
717 - if( $frev && $frev->getRevId() < $this->article->getLatest() ) {
 717+ if ( $frev && $frev->getRevId() < $this->article->getLatest() ) {
718718 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() );
719719 $tag = "<div id='mw-fr-revisiontag-edit' class='flaggedrevs_notice plainlinks'>" .
720720 FlaggedRevsXML::lockStatusIcon( $this->article ) . # flag protection icon as needed
@@ -730,42 +730,42 @@
731731 global $wgRequest, $wgOut, $wgLang, $wgUser;
732732 $this->load();
733733 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
734 - if( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 734+ if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
735735 return true;
736736 }
737737 $items = array();
738738 $tag = $warning = $prot = '';
739739 # Show stabilization log
740740 $log = $this->stabilityLogExcerpt();
741 - if( $log ) $items[] = $log;
 741+ if ( $log ) $items[] = $log;
742742 # Check the newest stable version
743743 $quality = 0;
744744 $frev = $this->article->getStableRev();
745 - if( $frev ) {
 745+ if ( $frev ) {
746746 $quality = $frev->getQuality();
747747 # Find out revision id of base version
748748 $latestId = $this->article->getLatest();
749749 $revId = $editPage->oldid ? $editPage->oldid : $latestId;
750 - $isOld = ($revId != $latestId); // not the current rev?
 750+ $isOld = ( $revId != $latestId ); // not the current rev?
751751 # Let new users know about review procedure a tag.
752752 # If the log excerpt was shown this is redundant.
753 - if( !$log && !$wgUser->getId() && $this->article->isStableShownByDefault() ) {
754 - $items[] = wfMsgExt( 'revreview-editnotice', array('parseinline') );
 753+ if ( !$log && !$wgUser->getId() && $this->article->isStableShownByDefault() ) {
 754+ $items[] = wfMsgExt( 'revreview-editnotice', array( 'parseinline' ) );
755755 }
756756 # Add a notice if there are pending edits...
757 - if( $frev->getRevId() != $revId ) {
 757+ if ( $frev->getRevId() != $revId ) {
758758 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() );
759759 $items[] = FlaggedRevsXML::pendingEditNotice( $this->article, $frev, $revsSince );
760760 }
761761 # Show diff to stable, to make things less confusing...
762762 # This can be disabled via user preferences
763 - if( $frev->getRevId() < $revId // changes were made
 763+ if ( $frev->getRevId() < $revId // changes were made
764764 && $this->isDiffShownOnEdit() // stable default and user cannot review
765765 && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs
766766 ) {
767767 # Don't show for old revisions, diff, preview, or undo
768 - if( $isOld || $editPage->section === "new"
769 - || in_array($editPage->formtype,array('diff','preview')) )
 768+ if ( $isOld || $editPage->section === "new"
 769+ || in_array( $editPage->formtype, array( 'diff', 'preview' ) ) )
770770 {
771771 return true; // nothing to show here
772772 }
@@ -774,18 +774,18 @@
775775 $leftNote = $quality ? 'hist-quality' : 'hist-stable';
776776 $rClass = FlaggedRevsXML::getQualityColor( false );
777777 $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
778 - $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[".
779 - wfMsgHtml('hist-draft')."]</span>";
780 - $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[".
781 - wfMsgHtml($leftNote)."]</span>";
 778+ $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[" .
 779+ wfMsgHtml( 'hist-draft' ) . "]</span>";
 780+ $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[" .
 781+ wfMsgHtml( $leftNote ) . "]</span>";
782782 $text = $frev->getRevText();
783783 # Are we editing a section?
784 - $section = ($editPage->section == "") ?
785 - false : intval($editPage->section);
786 - if( $section !== false ) {
 784+ $section = ( $editPage->section == "" ) ?
 785+ false : intval( $editPage->section );
 786+ if ( $section !== false ) {
787787 $text = $this->article->getSection( $text, $section );
788788 }
789 - if( $text !== false && strcmp($text,$editPage->textbox1) !== 0 ) {
 789+ if ( $text !== false && strcmp( $text, $editPage->textbox1 ) !== 0 ) {
790790 $diffEngine = new DifferenceEngine();
791791 $diffEngine->showDiffStyle();
792792 $diffHtml =
@@ -810,10 +810,10 @@
811811 }
812812 }
813813 # Output items
814 - if( count($items) ) {
 814+ if ( count( $items ) ) {
815815 $html = "<table class='flaggedrevs_editnotice plainlinks'>";
816 - foreach( $items as $item ) {
817 - $html .= '<tr><td>'.$item.'</td></tr>';
 816+ foreach ( $items as $item ) {
 817+ $html .= '<tr><td>' . $item . '</td></tr>';
818818 }
819819 $html .= '</table>';
820820 $wgOut->addHTML( $html );
@@ -826,18 +826,18 @@
827827 $this->load();
828828 $s = '';
829829 # Only for pages manually made to be stable...
830 - if( $this->article->isPageLocked() ) {
 830+ if ( $this->article->isPageLocked() ) {
831831 $s = wfMsgExt( 'revreview-locked', 'parseinline' );
832832 $logHtml = '';
833833 LogEventsList::showLogExtract( $logHtml, 'stable',
834 - $this->article->getTitle()->getPrefixedText(), '', array('lim'=>1) );
 834+ $this->article->getTitle()->getPrefixedText(), '', array( 'lim' => 1 ) );
835835 $s .= $logHtml;
836836 # ...or unstable
837 - } elseif( $this->article->isPageUnlocked() ) {
 837+ } elseif ( $this->article->isPageUnlocked() ) {
838838 $s = wfMsgExt( 'revreview-unlocked', 'parseinline' );
839839 $logHtml = '';
840840 LogEventsList::showLogExtract( $logHtml, 'stable',
841 - $this->article->getTitle()->getPrefixedText(), '', array('lim' => 1) );
 841+ $this->article->getTitle()->getPrefixedText(), '', array( 'lim' => 1 ) );
842842 $s .= $logHtml;
843843 }
844844 return $s;
@@ -849,18 +849,18 @@
850850 public function addToCategoryView() {
851851 global $wgOut, $wgUser;
852852 $this->load();
853 - if( !$wgUser->isAllowed( 'review' ) ) {
 853+ if ( !$wgUser->isAllowed( 'review' ) ) {
854854 return true;
855855 }
856856 $category = $this->article->getTitle()->getText();
857857
858858 $unreviewed = SpecialPage::getTitleFor( 'UnreviewedPages' );
859859 $unreviewedLink = $wgUser->getSkin()->makeKnownLinkObj( $unreviewed,
860 - wfMsgHtml('unreviewedpages'), 'category=' . urlencode($category) );
 860+ wfMsgHtml( 'unreviewedpages' ), 'category=' . urlencode( $category ) );
861861
862862 $oldreviewed = SpecialPage::getTitleFor( 'OldReviewedPages' );
863863 $oldreviewedLink = $wgUser->getSkin()->makeKnownLinkObj( $oldreviewed,
864 - wfMsgHtml('oldreviewedpages'), 'category=' . urlencode($category) );
 864+ wfMsgHtml( 'oldreviewedpages' ), 'category=' . urlencode( $category ) );
865865
866866 $wgOut->appendSubtitle(
867867 "<span id='mw-fr-category-oldreviewed'>$unreviewedLink / $oldreviewedLink</span>"
@@ -875,27 +875,27 @@
876876 global $wgRequest, $wgUser, $wgOut;
877877 $this->load();
878878 # User must have review rights and page must be reviewable
879 - if( !$wgUser->isAllowed('review') || !$this->article->exists()
 879+ if ( !$wgUser->isAllowed( 'review' ) || !$this->article->exists()
880880 || !$this->article->isReviewable() )
881881 {
882882 return true;
883883 }
884884 # Unobtrusive patrolling UI only shows forms if requested
885 - if( !$wgRequest->getInt('reviewform') && $this->article->limitedUI() ) {
 885+ if ( !$wgRequest->getInt( 'reviewform' ) && $this->article->limitedUI() ) {
886886 return true;
887887 }
888888 # Avoid multi-page diffs that are useless and misbehave (bug 19327)
889 - if( $this->isMultiPageDiff ) {
 889+ if ( $this->isMultiPageDiff ) {
890890 return true;
891891 }
892892 # Check action and if page is protected
893893 $action = $wgRequest->getVal( 'action', 'view' );
894894 # Must be view/diff action...
895 - if( !self::isViewAction($action) ) {
 895+ if ( !self::isViewAction( $action ) ) {
896896 return true;
897897 }
898898 # Place the form at the top or bottom as most convenient
899 - $onTop = $wgRequest->getVal('diff') || $this->isDiffFromStable;
 899+ $onTop = $wgRequest->getVal( 'diff' ) || $this->isDiffFromStable;
900900 $this->addQuickReview( $data, $onTop, false );
901901 return true;
902902 }
@@ -906,28 +906,28 @@
907907 public function addVisibilityLink( &$data ) {
908908 global $wgUser, $wgRequest, $wgOut;
909909 $this->load();
910 - if( FlaggedRevs::getProtectionLevels() )
 910+ if ( FlaggedRevs::getProtectionLevels() )
911911 return true; // simple custom levels set for action=protect
912912 # Check only if the title is reviewable
913 - if( !$this->article->isReviewable(true) ) {
 913+ if ( !$this->article->isReviewable( true ) ) {
914914 return true;
915915 }
916916 $action = $wgRequest->getVal( 'action', 'view' );
917 - if( $action == 'protect' || $action == 'unprotect' ) {
 917+ if ( $action == 'protect' || $action == 'unprotect' ) {
918918 $title = SpecialPage::getTitleFor( 'Stabilization' );
919919 # Give a link to the page to configure the stable version
920920 $frev = $this->article->getStableRev();
921 - if( $frev && $frev->getRevId() == $this->article->getLatest() ) {
 921+ if ( $frev && $frev->getRevId() == $this->article->getLatest() ) {
922922 $wgOut->prependHTML( "<span class='plainlinks'>" .
923 - wfMsgExt( 'revreview-visibility',array('parseinline'),
 923+ wfMsgExt( 'revreview-visibility', array( 'parseinline' ),
924924 $title->getPrefixedText() ) . "</span>" );
925 - } elseif( $frev ) {
 925+ } elseif ( $frev ) {
926926 $wgOut->prependHTML( "<span class='plainlinks'>" .
927 - wfMsgExt( 'revreview-visibility2',array('parseinline'),
 927+ wfMsgExt( 'revreview-visibility2', array( 'parseinline' ),
928928 $title->getPrefixedText() ) . "</span>" );
929929 } else {
930930 $wgOut->prependHTML( "<span class='plainlinks'>" .
931 - wfMsgExt( 'revreview-visibility3',array('parseinline'),
 931+ wfMsgExt( 'revreview-visibility3', array( 'parseinline' ),
932932 $title->getPrefixedText() ) . "</span>" );
933933 }
934934 }
@@ -941,15 +941,15 @@
942942 public function setActionTabs( $skin, &$actions ) {
943943 global $wgRequest, $wgUser;
944944 $this->load();
945 - if( FlaggedRevs::getProtectionLevels() ) {
 945+ if ( FlaggedRevs::getProtectionLevels() ) {
946946 return true; // simple custom levels set for action=protect
947947 }
948948 $title = $this->article->getTitle()->getSubjectPage();
949 - if( !FlaggedRevs::isPageReviewable( $title ) ) {
 949+ if ( !FlaggedRevs::isPageReviewable( $title ) ) {
950950 return true; // Only reviewable pages need these tabs
951951 }
952952 // Check if we should show a stabilization tab
953 - if(
 953+ if (
954954 !$skin->mTitle->isTalkPage() &&
955955 is_array( $actions ) &&
956956 !isset( $actions['protect'] ) &&
@@ -982,35 +982,35 @@
983983 $fa = FlaggedArticle::getTitleInstance( $title );
984984
985985 $action = $wgRequest->getVal( 'action', 'view' );
986 - if( !$fa->isReviewable() || $fa->limitedUI() ) {
 986+ if ( !$fa->isReviewable() || $fa->limitedUI() ) {
987987 return true; // Not a reviewable page or the UI is hidden
988988 }
989 - $flags = ($action == 'rollback') ? FR_MASTER : 0;
 989+ $flags = ( $action == 'rollback' ) ? FR_MASTER : 0;
990990 $srev = $fa->getStableRev( $flags );
991 - if( !$srev ) {
 991+ if ( !$srev ) {
992992 return true; // No stable revision exists
993993 }
994994 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $fa );
995995 // Set draft tab as needed...
996 - if( !$skin->mTitle->isTalkPage() && !$synced ) {
997 - if( isset( $views['edit'] ) ) {
998 - if( $fa->isStableShownByDefault() ) {
999 - $views['edit']['text'] = wfMsg('revreview-edit');
 996+ if ( !$skin->mTitle->isTalkPage() && !$synced ) {
 997+ if ( isset( $views['edit'] ) ) {
 998+ if ( $fa->isStableShownByDefault() ) {
 999+ $views['edit']['text'] = wfMsg( 'revreview-edit' );
10001000 }
1001 - if( $this->pageOverride() ) {
 1001+ if ( $this->pageOverride() ) {
10021002 $views['edit']['href'] = $title->getLocalUrl( 'action=edit' );
10031003 }
10041004 }
1005 - if( isset( $views['viewsource'] ) ) {
1006 - if( $fa->isStableShownByDefault() ) {
1007 - $views['viewsource']['text'] = wfMsg('revreview-source');
 1005+ if ( isset( $views['viewsource'] ) ) {
 1006+ if ( $fa->isStableShownByDefault() ) {
 1007+ $views['viewsource']['text'] = wfMsg( 'revreview-source' );
10081008 }
1009 - if( $this->pageOverride() ) {
 1009+ if ( $this->pageOverride() ) {
10101010 $views['viewsource']['href'] = $title->getLocalUrl( 'action=edit' );
10111011 }
10121012 }
10131013 }
1014 - if( !FlaggedRevs::showVersionTabs() || $synced ) {
 1014+ if ( !FlaggedRevs::showVersionTabs() || $synced ) {
10151015 // Exit, since either the stable/draft tabs should not be shown
10161016 // or the page is already the most current revision
10171017 return true;
@@ -1027,10 +1027,10 @@
10281028 'class' => ''
10291029 ),
10301030 );
1031 - if( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) {
 1031+ if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) {
10321032 // We are looking a the stable version
10331033 $tabs['stable']['class'] = 'selected';
1034 - } elseif(
 1034+ } elseif (
10351035 ( self::isViewAction( $action ) || $action == 'edit' ) &&
10361036 !$skin->mTitle->isTalkPage()
10371037 ) {
@@ -1041,8 +1041,8 @@
10421042 $newViews = array();
10431043 foreach ( $views as $tabAction => $data ) {
10441044 // Very first tab (page link)
1045 - if( $first ) {
1046 - if( $synced ) {
 1045+ if ( $first ) {
 1046+ if ( $synced ) {
10471047 // Use existing first tabs when synced
10481048 $newViews[$tabAction] = $data;
10491049 } else {
@@ -1069,9 +1069,9 @@
10701070 public function setReviewNotes( $frev ) {
10711071 global $wgUser;
10721072 $this->load();
1073 - if( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) {
 1073+ if ( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) {
10741074 $this->reviewNotes = "<br /><div class='flaggedrevs_notes plainlinks'>";
1075 - $this->reviewNotes .= wfMsgExt('revreview-note', array('parseinline'),
 1075+ $this->reviewNotes .= wfMsgExt( 'revreview-note', array( 'parseinline' ),
10761076 User::whoIs( $frev->getUser() ) );
10771077 $this->reviewNotes .= '<br /><i>' .
10781078 $wgUser->getSkin()->formatComment( $frev->getComment() ) . '</i></div>';
@@ -1086,97 +1086,97 @@
10871087 global $wgRequest, $wgUser, $wgOut, $wgMemc;
10881088 $this->load();
10891089 # Exempt printer-friendly output
1090 - if( $wgOut->isPrintable() ) {
 1090+ if ( $wgOut->isPrintable() ) {
10911091 return true;
10921092 }
10931093 # Avoid multi-page diffs that are useless and misbehave (bug 19327)
1094 - if( $this->isMultiPageDiff ) {
 1094+ if ( $this->isMultiPageDiff ) {
10951095 return true;
10961096 }
10971097 # Page must be reviewable. UI may be limited to unobtrusive patrolling system.
1098 - if( !$this->article->isReviewable() || $this->article->limitedUI() ) {
 1098+ if ( !$this->article->isReviewable() || $this->article->limitedUI() ) {
10991099 return true;
11001100 }
11011101 # Check if this might be the diff to stable. If so, enhance it.
1102 - if( $newRev->isCurrent() && $oldRev ) {
 1102+ if ( $newRev->isCurrent() && $oldRev ) {
11031103 $article = new Article( $newRev->getTitle() );
11041104 $frev = $this->article->getStableRev();
1105 - if( $frev && $frev->getRevId() == $oldRev->getID() ) {
 1105+ if ( $frev && $frev->getRevId() == $oldRev->getID() ) {
11061106 global $wgParserCacheExpireTime;
11071107 # Check the page sync value cache...
11081108 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
1109 - $value = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article );
1110 - $synced = ($value === "true") ? true : false; // default as false to trigger query
 1109+ $value = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article );
 1110+ $synced = ( $value === "true" ) ? true : false; // default as false to trigger query
11111111
11121112 $changeList = array();
11131113
11141114 # Try the cache. Uses format <page ID>-<UNIX timestamp>.
11151115 $key = wfMemcKey( 'stableDiffs', 'templates', $article->getId() );
1116 - $tmpChanges = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article );
1117 - if( empty($tmpChanges) && !$synced ) {
 1116+ $tmpChanges = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article );
 1117+ if ( empty( $tmpChanges ) && !$synced ) {
11181118 $tmpChanges = false; // don't use cache, it's not consistent
11191119 }
11201120
11211121 # Make a list of each changed template...
1122 - if( $tmpChanges === false ) {
 1122+ if ( $tmpChanges === false ) {
11231123 $tmpChanges = $this->fetchTemplateChanges( $frev );
1124 - $wgMemc->set( $key, FlaggedRevs::makeMemcObj($tmpChanges),
 1124+ $wgMemc->set( $key, FlaggedRevs::makeMemcObj( $tmpChanges ),
11251125 $wgParserCacheExpireTime );
11261126 }
11271127 # Add set to list
1128 - if( $tmpChanges )
 1128+ if ( $tmpChanges )
11291129 $changeList += $tmpChanges;
11301130
11311131 # Try the cache. Uses format <page ID>-<UNIX timestamp>.
11321132 $key = wfMemcKey( 'stableDiffs', 'images', $article->getId() );
1133 - $imgChanges = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article );
1134 - if( empty($imgChanges) && !$synced ) {
 1133+ $imgChanges = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article );
 1134+ if ( empty( $imgChanges ) && !$synced ) {
11351135 $imgChanges = false; // don't use cache, it's not consistent
11361136 }
11371137
11381138 // Get list of each changed image...
1139 - if( $imgChanges === false ) {
 1139+ if ( $imgChanges === false ) {
11401140 $imgChanges = $this->fetchFileChanges( $frev );
1141 - $wgMemc->set( $key, FlaggedRevs::makeMemcObj($imgChanges),
 1141+ $wgMemc->set( $key, FlaggedRevs::makeMemcObj( $imgChanges ),
11421142 $wgParserCacheExpireTime );
11431143 }
1144 - if( $imgChanges )
 1144+ if ( $imgChanges )
11451145 $changeList += $imgChanges;
11461146
11471147 # Some important information...
11481148 $notice = '';
1149 - if( count($changeList) > 0 ) {
1150 - $notice = '<br />' . wfMsgExt('revreview-update-use', array('parseinline'));
1151 - } elseif( !$synced ) {
 1149+ if ( count( $changeList ) > 0 ) {
 1150+ $notice = '<br />' . wfMsgExt( 'revreview-update-use', array( 'parseinline' ) );
 1151+ } elseif ( !$synced ) {
11521152 $diff->mTitle->invalidateCache(); // bad cache, said they were not synced
11531153 }
11541154
11551155 # If the user is allowed to review, prompt them!
11561156 # Only those if there is something to actually review.
1157 - if( count($changeList) || $newRev->getId() > $oldRev->getId() ) {
 1157+ if ( count( $changeList ) || $newRev->getId() > $oldRev->getId() ) {
11581158 $css = 'flaggedrevs_diffnotice plainlinks';
1159 - if( empty($changeList) && $wgUser->isAllowed('review') ) {
 1159+ if ( empty( $changeList ) && $wgUser->isAllowed( 'review' ) ) {
11601160 $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" .
1161 - wfMsgExt('revreview-update-none', array('parseinline')) .
 1161+ wfMsgExt( 'revreview-update-none', array( 'parseinline' ) ) .
11621162 $notice . '</div>' );
1163 - } elseif( !empty($changeList) && $wgUser->isAllowed('review') ) {
1164 - $changeList = implode(', ',$changeList);
 1163+ } elseif ( !empty( $changeList ) && $wgUser->isAllowed( 'review' ) ) {
 1164+ $changeList = implode( ', ', $changeList );
11651165 $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" .
1166 - wfMsgExt('revreview-update', array('parseinline')) .
1167 - '&nbsp;' . $changeList.$notice.'</div>' );
1168 - } elseif( !empty($changeList) ) {
1169 - $changeList = implode(', ',$changeList);
 1166+ wfMsgExt( 'revreview-update', array( 'parseinline' ) ) .
 1167+ '&nbsp;' . $changeList . $notice . '</div>' );
 1168+ } elseif ( !empty( $changeList ) ) {
 1169+ $changeList = implode( ', ', $changeList );
11701170 $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" .
1171 - wfMsgExt('revreview-update-includes', array('parseinline')) .
1172 - '&nbsp;' . $changeList.$notice.'</div>' );
 1171+ wfMsgExt( 'revreview-update-includes', array( 'parseinline' ) ) .
 1172+ '&nbsp;' . $changeList . $notice . '</div>' );
11731173 }
11741174 }
11751175
11761176 # Set a key to note that someone is viewing this
1177 - if( $wgUser->isAllowed('review') ) {
 1177+ if ( $wgUser->isAllowed( 'review' ) ) {
11781178 $key = wfMemcKey( 'stableDiffs', 'underReview',
11791179 $oldRev->getID(), $newRev->getID() );
1180 - $wgMemc->set( $key, '1', 10*60 ); // 10 min
 1180+ $wgMemc->set( $key, '1', 10 * 60 ); // 10 min
11811181 }
11821182 }
11831183 }
@@ -1185,11 +1185,11 @@
11861186 ? FlaggedRevs::getRevQuality( $newRev->getPage(), $oldRev->getId() )
11871187 : false;
11881188 # Diff between two revisions
1189 - if( $oldRev ) {
 1189+ if ( $oldRev ) {
11901190 $wgOut->addHTML( "<table class='fr-diff-ratings'><tr>" );
11911191
11921192 $class = FlaggedRevsXML::getQualityColor( $oldRevQ );
1193 - if( $oldRevQ !== false ) {
 1193+ if ( $oldRevQ !== false ) {
11941194 $msg = $oldRevQ ? 'hist-quality' : 'hist-stable';
11951195 } else {
11961196 $msg = 'hist-draft';
@@ -1199,7 +1199,7 @@
12001200 wfMsgHtml( $msg ) . "]</span>" );
12011201
12021202 $class = FlaggedRevsXML::getQualityColor( $newRevQ );
1203 - if( $newRevQ !== false ) {
 1203+ if ( $newRevQ !== false ) {
12041204 $msg = $newRevQ ? 'hist-quality' : 'hist-stable';
12051205 } else {
12061206 $msg = 'hist-draft';
@@ -1211,7 +1211,7 @@
12121212 $wgOut->addHTML( '</td></tr></table>' );
12131213 # New page "diffs" - just one rev
12141214 } else {
1215 - if( $newRevQ !== false ) {
 1215+ if ( $newRevQ !== false ) {
12161216 $msg = $newRevQ ? 'hist-quality' : 'hist-stable';
12171217 } else {
12181218 $msg = 'hist-draft';
@@ -1233,28 +1233,28 @@
12341234 $skin = $wgUser->getSkin();
12351235 $dbr = wfGetDB( DB_SLAVE );
12361236 // Get templates where the current and stable are not the same revision
1237 - $ret = $dbr->select( array('flaggedtemplates','page','flaggedpages'),
 1237+ $ret = $dbr->select( array( 'flaggedtemplates', 'page', 'flaggedpages' ),
12381238 array( 'ft_namespace', 'ft_title', 'fp_stable',
1239 - 'ft_tmp_rev_id','page_latest' ),
 1239+ 'ft_tmp_rev_id', 'page_latest' ),
12401240 array( 'ft_rev_id' => $frev->getRevId(),
12411241 'page_namespace = ft_namespace',
12421242 'page_title = ft_title' ),
12431243 __METHOD__,
12441244 array(), /* OPTIONS */
1245 - array( 'flaggedpages' => array('LEFT JOIN','fp_page_id = page_id') )
 1245+ array( 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ) )
12461246 );
12471247 $tmpChanges = array();
1248 - while( $row = $dbr->fetchObject( $ret ) ) {
 1248+ while ( $row = $dbr->fetchObject( $ret ) ) {
12491249 $title = Title::makeTitleSafe( $row->ft_namespace, $row->ft_title );
12501250 $revIdDraft = $row->page_latest;
12511251 // stable time -> time when reviewed (unless the other is newer)
1252 - $revIdStable = isset($row->fp_stable) && $row->fp_stable >= $row->ft_tmp_rev_id ?
 1252+ $revIdStable = isset( $row->fp_stable ) && $row->fp_stable >= $row->ft_tmp_rev_id ?
12531253 $row->fp_stable : $row->ft_tmp_rev_id;
12541254 // compare to current
1255 - if( $revIdDraft > $revIdStable ) {
 1255+ if ( $revIdDraft > $revIdStable ) {
12561256 $tmpChanges[] = $skin->makeKnownLinkObj( $title,
12571257 $title->getPrefixedText(),
1258 - 'diff=cur&oldid='.intval($revIdStable) );
 1258+ 'diff=cur&oldid=' . intval( $revIdStable ) );
12591259 }
12601260 }
12611261 return $tmpChanges;
@@ -1267,28 +1267,28 @@
12681268 $dbr = wfGetDB( DB_SLAVE );
12691269 // Get images where the current and stable are not the same revision
12701270 $ret = $dbr->select(
1271 - array( 'flaggedimages','page','image','flaggedpages','flaggedrevs' ),
 1271+ array( 'flaggedimages', 'page', 'image', 'flaggedpages', 'flaggedrevs' ),
12721272 array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ),
12731273 array( 'fi_rev_id' => $frev->getRevId() ),
12741274 __METHOD__,
12751275 array(), /* OPTIONS */
12761276 array(
1277 - 'page' => array('LEFT JOIN',
1278 - 'page_namespace = '. NS_FILE .' AND page_title = fi_name'),
1279 - 'image' => array('LEFT JOIN','img_name = fi_name'),
1280 - 'flaggedpages' => array('LEFT JOIN','fp_page_id = page_id'),
1281 - 'flaggedrevs' => array('LEFT JOIN',
1282 - 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable') )
 1277+ 'page' => array( 'LEFT JOIN',
 1278+ 'page_namespace = ' . NS_FILE . ' AND page_title = fi_name' ),
 1279+ 'image' => array( 'LEFT JOIN', 'img_name = fi_name' ),
 1280+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
 1281+ 'flaggedrevs' => array( 'LEFT JOIN',
 1282+ 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ) )
12831283 );
12841284 $imgChanges = array();
1285 - while( $row = $dbr->fetchObject( $ret ) ) {
 1285+ while ( $row = $dbr->fetchObject( $ret ) ) {
12861286 $title = Title::makeTitleSafe( NS_FILE, $row->fi_name );
12871287 // stable time -> time when reviewed (unless the other is newer)
1288 - $timestamp = isset($row->fr_img_timestamp) && $row->fr_img_timestamp >= $row->fi_img_timestamp ?
 1288+ $timestamp = isset( $row->fr_img_timestamp ) && $row->fr_img_timestamp >= $row->fi_img_timestamp ?
12891289 $row->fr_img_timestamp : $row->fi_img_timestamp;
12901290 // compare to current
12911291 $file = wfFindFile( $title );
1292 - if( $file && $file->getTimestamp() > $timestamp ) {
 1292+ if ( $file && $file->getTimestamp() > $timestamp ) {
12931293 $imgChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
12941294 }
12951295 }
@@ -1300,15 +1300,15 @@
13011301 */
13021302 public function setViewFlags( $diff, $oldRev, $newRev ) {
13031303 $this->load();
1304 - if( $newRev && $oldRev ) {
 1304+ if ( $newRev && $oldRev ) {
13051305 // Is this a diff between two pages?
1306 - if( $newRev->getPage() != $oldRev->getPage() ) {
 1306+ if ( $newRev->getPage() != $oldRev->getPage() ) {
13071307 $this->isMultiPageDiff = true;
13081308 // Is there a stable version?
1309 - } else if( $this->article->isReviewable() ) {
 1309+ } else if ( $this->article->isReviewable() ) {
13101310 $frev = $this->article->getStableRev();
13111311 // Is this a diff of the draft rev against the stable rev?
1312 - if( $frev && $frev->getRevId() == $oldRev->getId() && $newRev->isCurrent() ) {
 1312+ if ( $frev && $frev->getRevId() == $oldRev->getId() && $newRev->isCurrent() ) {
13131313 $this->isDiffFromStable = true;
13141314 }
13151315 }
@@ -1323,16 +1323,16 @@
13241324 global $wgUser, $wgOut;
13251325 $this->load();
13261326 // Both revs must exists and the page must be reviewable
1327 - if( !$newRev || !$oldRev || !$this->article->isReviewable() ) {
 1327+ if ( !$newRev || !$oldRev || !$this->article->isReviewable() ) {
13281328 return true; // nothing to do
13291329 }
13301330 // Is there a stable version?
13311331 $frev = $this->article->getStableRev();
13321332 # Give a link to the diff-to-stable if needed
1333 - if( $frev && !$this->isDiffFromStable ) {
 1333+ if ( $frev && !$this->isDiffFromStable ) {
13341334 $article = new Article( $newRev->getTitle() );
13351335 # Is the stable revision using the same revision as the current?
1336 - if( $article->getLatest() != $frev->getRevId() ) {
 1336+ if ( $article->getLatest() != $frev->getRevId() ) {
13371337 $patrol = $wgUser->getSkin()->makeKnownLinkObj(
13381338 $newRev->getTitle(),
13391339 wfMsgHtml( 'review-diff2stable' ),
@@ -1352,27 +1352,27 @@
13531353 global $wgUser;
13541354 $this->load();
13551355 # Don't show this for pages that are not reviewable
1356 - if( !$this->article->isReviewable() || $this->article->getTitle()->isTalkPage() )
 1356+ if ( !$this->article->isReviewable() || $this->article->getTitle()->isTalkPage() )
13571357 return true;
13581358 # We may want to skip some UI elements
1359 - if( $this->article->limitedUI() )
 1359+ if ( $this->article->limitedUI() )
13601360 return true;
13611361 # Get the stable version, from master
13621362 $frev = $this->article->getStableRev( FR_MASTER );
1363 - if( !$frev )
 1363+ if ( !$frev )
13641364 return true;
13651365 # Get latest revision Id (lag safe)
1366 - $latest = $this->article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 1366+ $latest = $this->article->getTitle()->getLatestRevID( GAID_FOR_UPDATE );
13671367 // If the edit was not autoreviewed, and the user can actually make a
13681368 // new stable version, then go to the diff...
1369 - if( $latest > $frev->getRevId() && $frev->userCanSetFlags() ) {
 1369+ if ( $latest > $frev->getRevId() && $frev->userCanSetFlags() ) {
13701370 $extraQuery .= $extraQuery ? '&' : '';
13711371 $extraQuery .= "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; // override diff-only
13721372 // ...otherwise, go to the current revision after completing an edit.
13731373 } else {
1374 - if( $frev && $latest != $frev->getRevId() ) {
 1374+ if ( $frev && $latest != $frev->getRevId() ) {
13751375 $extraQuery .= "stable=0";
1376 - if( !$wgUser->isAllowed('review') && $this->article->isStableShownByDefault() ) {
 1376+ if ( !$wgUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) {
13771377 $extraQuery .= "&shownotice=1";
13781378 }
13791379 }
@@ -1388,25 +1388,25 @@
13891389 global $wgRequest;
13901390 $this->load();
13911391 # Find out revision id
1392 - if( $this->article->mRevision ) {
 1392+ if ( $this->article->mRevision ) {
13931393 $revId = $this->article->mRevision->mId;
13941394 } else {
1395 - $latest = $this->article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 1395+ $latest = $this->article->getTitle()->getLatestRevID( GAID_FOR_UPDATE );
13961396 $revId = $latest;
13971397 wfDebug( 'FlaggedArticle::addRevisionIDField - ID not specified, assumed current' );
13981398 }
13991399 # If undoing a few consecutive top edits, we know the base ID
1400 - if( $undo = $wgRequest->getIntOrNull('undo') ) {
1401 - $undoAfter = $wgRequest->getIntOrNull('undoafter');
1402 - $latest = isset($latest) ?
1403 - $latest : $this->article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
1404 - if( $undoAfter && $undo == $this->article->getLatest() ) {
 1400+ if ( $undo = $wgRequest->getIntOrNull( 'undo' ) ) {
 1401+ $undoAfter = $wgRequest->getIntOrNull( 'undoafter' );
 1402+ $latest = isset( $latest ) ?
 1403+ $latest : $this->article->getTitle()->getLatestRevID( GAID_FOR_UPDATE );
 1404+ if ( $undoAfter && $undo == $this->article->getLatest() ) {
14051405 $revId = $undoAfter;
14061406 }
14071407 }
14081408 $out->addHTML( "\n" . Xml::hidden( 'baseRevId', $revId ) );
1409 - $out->addHTML( "\n" . Xml::hidden( 'undidRev',
1410 - empty($editPage->undidRev) ? 0 : $editPage->undidRev )
 1409+ $out->addHTML( "\n" . Xml::hidden( 'undidRev',
 1410+ empty( $editPage->undidRev ) ? 0 : $editPage->undidRev )
14111411 );
14121412 return true;
14131413 }
@@ -1417,7 +1417,7 @@
14181418 */
14191419 public function addReviewNotes( &$data ) {
14201420 $this->load();
1421 - if( $this->reviewNotes ) {
 1421+ if ( $this->reviewNotes ) {
14221422 $data .= $this->reviewNotes;
14231423 }
14241424 return true;
@@ -1432,13 +1432,13 @@
14331433 public function addQuickReview( &$data, $top = false, $hide = false ) {
14341434 global $wgOut, $wgUser, $wgRequest;
14351435 $this->load();
1436 - if( $wgOut->isPrintable() ) {
 1436+ if ( $wgOut->isPrintable() ) {
14371437 return false; // Must be on non-printable output
14381438 }
14391439 # Get the revision being displayed
14401440 $id = $wgOut->getRevisionId();
1441 - if( !$id ) {
1442 - if( !$this->isDiffFromStable ) {
 1441+ if ( !$id ) {
 1442+ if ( !$this->isDiffFromStable ) {
14431443 return false; // only safe to assume current if diff-to-stable
14441444 } else {
14451445 $rev = Revision::newFromTitle( $this->article->getTitle() );
@@ -1448,31 +1448,31 @@
14491449 $rev = Revision::newFromTitle( $this->article->getTitle(), $id );
14501450 }
14511451 # The revision must be valid and public
1452 - if( !$rev || $rev->isDeleted(Revision::DELETED_TEXT) ) {
 1452+ if ( !$rev || $rev->isDeleted( Revision::DELETED_TEXT ) ) {
14531453 return false;
14541454 }
14551455 $useCurrent = false;
1456 - if( !isset($wgOut->mTemplateIds) || !isset($wgOut->fr_ImageSHA1Keys) ) {
 1456+ if ( !isset( $wgOut->mTemplateIds ) || !isset( $wgOut->fr_ImageSHA1Keys ) ) {
14571457 $useCurrent = true; // we need to get Ids from parser output
14581458 }
14591459 $skin = $wgUser->getSkin();
14601460
14611461 $config = $this->article->getVisibilitySettings();
14621462 # Variable for sites with no flags, otherwise discarded
1463 - $approve = $wgRequest->getBool('wpApprove');
 1463+ $approve = $wgRequest->getBool( 'wpApprove' );
14641464 # See if the version being displayed is flagged...
14651465 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $id );
14661466 $oldFlags = $frev
14671467 ? $frev->getTags() // existing tags
1468 - : FlaggedRevision::expandRevisionTags(''); // unset tags
 1468+ : FlaggedRevision::expandRevisionTags( '' ); // unset tags
14691469 # If we are reviewing updates to a page, start off with the stable revision's
14701470 # flags. Otherwise, we just fill them in with the selected revision's flags.
1471 - if( $this->isDiffFromStable ) {
 1471+ if ( $this->isDiffFromStable ) {
14721472 $srev = $this->article->getStableRev();
14731473 $flags = $srev->getTags();
14741474 # Check if user is allowed to renew the stable version.
14751475 # If not, then get the flags for the new revision itself.
1476 - if( !RevisionReview::userCanSetFlags( $oldFlags ) ) {
 1476+ if ( !RevisionReview::userCanSetFlags( $oldFlags ) ) {
14771477 $flags = $oldFlags;
14781478 }
14791479 $reviewNotes = $srev->getComment();
@@ -1486,68 +1486,68 @@
14871487 $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' );
14881488 $action = $reviewTitle->getLocalUrl( 'action=submit' );
14891489 $params = array( 'method' => 'post', 'action' => $action, 'id' => 'mw-fr-reviewform' );
1490 - if( $hide ) {
 1490+ if ( $hide ) {
14911491 $params['class'] = 'fr-hiddenform';
14921492 }
14931493 $form = Xml::openElement( 'form', $params );
14941494 $form .= Xml::openElement( 'fieldset',
1495 - array('class' => 'flaggedrevs_reviewform noprint') );
 1495+ array( 'class' => 'flaggedrevs_reviewform noprint' ) );
14961496 # Add appropriate legend text
14971497 $legendMsg = ( FlaggedRevs::binaryFlagging() && $frev )
14981498 ? 'revreview-reflag'
14991499 : 'revreview-flag';
1500 - $form .= Xml::openElement( 'legend', array('id' => 'mw-fr-reviewformlegend') );
 1500+ $form .= Xml::openElement( 'legend', array( 'id' => 'mw-fr-reviewformlegend' ) );
15011501 $form .= "<strong>" . wfMsgHtml( $legendMsg ) . "</strong>";
15021502 $form .= Xml::closeElement( 'legend' ) . "\n";
15031503 # Show explanatory text
1504 - if( !FlaggedRevs::lowProfileUI() ) {
 1504+ if ( !FlaggedRevs::lowProfileUI() ) {
15051505 $msg = FlaggedRevs::isStableShownByDefault() ? 'revreview-text' : 'revreview-text2';
1506 - $form .= wfMsgExt( $msg, array('parse') );
 1506+ $form .= wfMsgExt( $msg, array( 'parse' ) );
15071507 }
15081508
15091509 # Disable form for unprivileged users
1510 - $uneditable = !$this->article->getTitle()->quickUserCan('edit');
 1510+ $uneditable = !$this->article->getTitle()->quickUserCan( 'edit' );
15111511 $disabled = !RevisionReview::userCanSetFlags( $flags ) || $uneditable;
1512 - if( $disabled ) {
1513 - $form .= Xml::openElement( 'div', array('class' => 'fr-rating-controls-disabled',
1514 - 'id' => 'fr-rating-controls-disabled') );
 1512+ if ( $disabled ) {
 1513+ $form .= Xml::openElement( 'div', array( 'class' => 'fr-rating-controls-disabled',
 1514+ 'id' => 'fr-rating-controls-disabled' ) );
15151515 $toggle = array( 'disabled' => "disabled" );
15161516 } else {
1517 - $form .= Xml::openElement( 'div', array('class' => 'fr-rating-controls',
1518 - 'id' => 'fr-rating-controls') );
 1517+ $form .= Xml::openElement( 'div', array( 'class' => 'fr-rating-controls',
 1518+ 'id' => 'fr-rating-controls' ) );
15191519 $toggle = array();
15201520 }
15211521
15221522 # Add main checkboxes/selects
1523 - $form .= Xml::openElement( 'span', array('id' => 'mw-fr-ratingselects') );
 1523+ $form .= Xml::openElement( 'span', array( 'id' => 'mw-fr-ratingselects' ) );
15241524 $form .= FlaggedRevsXML::ratingInputs( $flags, $config, $disabled, (bool)$frev );
15251525 $form .= Xml::closeElement( 'span' );
15261526 # Add review notes input
1527 - if( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) {
 1527+ if ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) {
15281528 $form .= "<div id='mw-fr-notebox'>\n";
1529 - $form .= "<p>".wfMsgHtml( 'revreview-notes' ) . "</p>\n";
1530 - $form .= Xml::openElement( 'textarea', array('name' => 'wpNotes', 'id' => 'wpNotes',
1531 - 'class' => 'fr-notes-box', 'rows' => '2', 'cols' => '80') ) .
 1529+ $form .= "<p>" . wfMsgHtml( 'revreview-notes' ) . "</p>\n";
 1530+ $form .= Xml::openElement( 'textarea', array( 'name' => 'wpNotes', 'id' => 'wpNotes',
 1531+ 'class' => 'fr-notes-box', 'rows' => '2', 'cols' => '80' ) ) .
15321532 htmlspecialchars( $reviewNotes ) .
1533 - Xml::closeElement('textarea') . "\n";
 1533+ Xml::closeElement( 'textarea' ) . "\n";
15341534 $form .= "</div>\n";
15351535 }
15361536
15371537 # Get versions of templates/files used
15381538 $imageParams = $templateParams = $fileVersion = '';
1539 - if( $useCurrent ) {
 1539+ if ( $useCurrent ) {
15401540 # Get parsed current version
15411541 $parserCache = ParserCache::singleton();
15421542 $article = $this->article;
15431543 $currentOutput = $parserCache->get( $article, $wgUser );
1544 - if( $currentOutput == false ) {
 1544+ if ( $currentOutput == false ) {
15451545 global $wgParser, $wgEnableParserCache;
15461546 $text = $article->getContent();
15471547 $title = $article->getTitle();
15481548 $options = FlaggedRevs::makeParserOptions();
15491549 $currentOutput = $wgParser->parse( $text, $title, $options );
15501550 # Might as well save the cache while we're at it
1551 - if( $wgEnableParserCache )
 1551+ if ( $wgEnableParserCache )
15521552 $parserCache->save( $currentOutput, $article, $wgUser );
15531553 }
15541554 $templateIDs = $currentOutput->mTemplateIds;
@@ -1556,17 +1556,17 @@
15571557 $templateIDs = $wgOut->mTemplateIds;
15581558 $imageSHA1Keys = $wgOut->fr_ImageSHA1Keys;
15591559 }
1560 - list($templateParams,$imageParams,$fileVersion) =
 1560+ list( $templateParams, $imageParams, $fileVersion ) =
15611561 FlaggedRevs::getIncludeParams( $this->article, $templateIDs, $imageSHA1Keys );
15621562
1563 - $form .= Xml::openElement( 'span', array('style' => 'white-space: nowrap;') );
 1563+ $form .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap;' ) );
15641564 # Hide comment input if needed
1565 - if( !$disabled ) {
1566 - if( count(FlaggedRevs::getDimensions()) > 1 )
 1565+ if ( !$disabled ) {
 1566+ if ( count( FlaggedRevs::getDimensions() ) > 1 )
15671567 $form .= "<br />"; // Don't put too much on one line
1568 - $form .= "<span id='mw-fr-commentbox' style='clear:both'>" .
1569 - Xml::inputLabel( wfMsg('revreview-log'), 'wpReason', 'wpReason', 40, '',
1570 - array('class' => 'fr-comment-box') ) . "&nbsp;&nbsp;&nbsp;</span>";
 1568+ $form .= "<span id='mw-fr-commentbox' style='clear:both'>" .
 1569+ Xml::inputLabel( wfMsg( 'revreview-log' ), 'wpReason', 'wpReason', 40, '',
 1570+ array( 'class' => 'fr-comment-box' ) ) . "&nbsp;&nbsp;&nbsp;</span>";
15711571 }
15721572 # Add the submit buttons
15731573 $form .= FlaggedRevsXML::ratingSubmitButtons( $frev, (bool)$toggle );
@@ -1578,14 +1578,14 @@
15791579 $form .= Xml::hidden( 'title', $reviewTitle->getPrefixedText() ) . "\n";
15801580 $form .= Xml::hidden( 'target', $this->article->getTitle()->getPrefixedDBKey() ) . "\n";
15811581 $form .= Xml::hidden( 'oldid', $id ) . "\n";
1582 - $form .= Xml::hidden( 'action', 'submit') . "\n";
 1582+ $form .= Xml::hidden( 'action', 'submit' ) . "\n";
15831583 $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n";
15841584 # Add review parameters
15851585 $form .= Xml::hidden( 'templateParams', $templateParams ) . "\n";
15861586 $form .= Xml::hidden( 'imageParams', $imageParams ) . "\n";
15871587 $form .= Xml::hidden( 'fileVersion', $fileVersion ) . "\n";
15881588 # Pass this in if given; useful for new page patrol
1589 - $form .= Xml::hidden( 'rcid', $wgRequest->getVal('rcid') ) . "\n";
 1589+ $form .= Xml::hidden( 'rcid', $wgRequest->getVal( 'rcid' ) ) . "\n";
15901590 # Special token to discourage fiddling...
15911591 $checkCode = RevisionReview::validationKey(
15921592 $templateParams, $imageParams, $fileVersion, $id
@@ -1595,7 +1595,7 @@
15961596 $form .= Xml::closeElement( 'fieldset' );
15971597 $form .= Xml::closeElement( 'form' );
15981598 # Place form at the correct position specified by $top
1599 - if( $top ) {
 1599+ if ( $top ) {
16001600 $wgOut->prependHTML( $form );
16011601 } else {
16021602 $data .= $form;
@@ -1611,21 +1611,21 @@
16121612 $this->load();
16131613
16141614 $action = $wgRequest->getVal( 'action', 'view' );
1615 - if( $action == 'purge' )
 1615+ if ( $action == 'purge' )
16161616 return true; // already purging!
16171617 # Only trigger on article view for content pages, not for protect/delete/hist
1618 - if( !self::isViewAction($action) || !$wgUser->isAllowed( 'review' ) )
 1618+ if ( !self::isViewAction( $action ) || !$wgUser->isAllowed( 'review' ) )
16191619 return true;
1620 - if( !$this->article->exists() || !$this->article->isReviewable() )
 1620+ if ( !$this->article->exists() || !$this->article->isReviewable() )
16211621 return true;
16221622
16231623 $parserCache = ParserCache::singleton();
16241624 $parserOut = $parserCache->get( $this->article, $wgUser );
1625 - if( $parserOut ) {
 1625+ if ( $parserOut ) {
16261626 # Clear older, incomplete, cached versions
16271627 # We need the IDs of templates and timestamps of images used
1628 - if( !isset($parserOut->fr_newestTemplateID)
1629 - || !isset($parserOut->fr_newestImageTime) )
 1628+ if ( !isset( $parserOut->fr_newestTemplateID )
 1629+ || !isset( $parserOut->fr_newestImageTime ) )
16301630 {
16311631 $this->article->getTitle()->invalidateCache();
16321632 }

Status & tagging log