Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -18,41 +18,41 @@ |
19 | 19 | http://www.gnu.org/copyleft/gpl.html |
20 | 20 | */ |
21 | 21 | |
22 | | -if( !defined('MEDIAWIKI') ) { |
| 22 | +if ( !defined( 'MEDIAWIKI' ) ) { |
23 | 23 | echo "FlaggedRevs extension\n"; |
24 | 24 | exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | # This messes with dump HTML... |
28 | | -if( defined('MW_HTML_FOR_DUMP') ) { |
| 28 | +if ( defined( 'MW_HTML_FOR_DUMP' ) ) { |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | # 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 ); |
35 | 35 | # 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 ); |
38 | 38 | # 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 ); |
41 | 41 | |
42 | 42 | # 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 ); |
49 | 49 | |
50 | 50 | # 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 ); |
57 | 57 | |
58 | 58 | $wgExtensionCredits['specialpage'][] = array( |
59 | 59 | 'path' => __FILE__, |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | 'descriptionmsg' => 'flaggedrevs-desc', |
64 | 64 | ); |
65 | 65 | |
66 | | -######### |
| 66 | +# ######## |
67 | 67 | # IMPORTANT: DO NOT EDIT THIS FILE |
68 | 68 | # When configuring globals, set them at LocalSettings.php instead |
69 | 69 | |
— | — | @@ -227,11 +227,11 @@ |
228 | 228 | */ |
229 | 229 | |
230 | 230 | # Special:Userrights settings |
231 | | -## Basic rights for Sysops |
| 231 | +# # Basic rights for Sysops |
232 | 232 | $wgAddGroups['sysop'][] = 'editor'; |
233 | 233 | $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 |
236 | 236 | $wgAddGroups['bureaucrat'][] = 'reviewer'; |
237 | 237 | $wgRemoveGroups['bureaucrat'][] = 'reviewer'; |
238 | 238 | |
— | — | @@ -270,7 +270,7 @@ |
271 | 271 | $wgUseCurrentImages = true; |
272 | 272 | |
273 | 273 | # End of configuration variables. |
274 | | -######### |
| 274 | +# ######## |
275 | 275 | |
276 | 276 | # Bots are granted autoreview via hooks, mark in rights |
277 | 277 | # array so that it shows up in sp:ListGroupRights... |
— | — | @@ -290,17 +290,17 @@ |
291 | 291 | |
292 | 292 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
293 | 293 | |
294 | | -$dir = dirname(__FILE__) . '/'; |
| 294 | +$dir = dirname( __FILE__ ) . '/'; |
295 | 295 | $langDir = $dir . 'language/'; |
296 | 296 | |
297 | 297 | $wgSvgGraphDir = $dir . 'svggraph'; |
298 | 298 | $wgPHPlotDir = $dir . 'phplot-5.0.5'; |
299 | 299 | |
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'; |
305 | 305 | |
306 | 306 | # Special case cache invalidations |
307 | 307 | $wgJobClasses['flaggedrevs_CacheUpdate'] = 'FRCacheUpdateJob'; |
— | — | @@ -359,7 +359,7 @@ |
360 | 360 | $wgExtensionMessagesFiles['ValidationStatistics'] = $langDir . 'ValidationStatistics.i18n.php'; |
361 | 361 | $wgSpecialPageGroups['ValidationStatistics'] = 'quality'; |
362 | 362 | # API Modules |
363 | | -$wgAutoloadClasses['FlaggedRevsApiHooks'] = $dir.'api/FlaggedRevsApi.hooks.php'; |
| 363 | +$wgAutoloadClasses['FlaggedRevsApiHooks'] = $dir . 'api/FlaggedRevsApi.hooks.php'; |
364 | 364 | # OldReviewedPages for API |
365 | 365 | $wgAutoloadClasses['ApiQueryOldreviewedpages'] = $dir . 'api/ApiQueryOldreviewedpages.php'; |
366 | 366 | $wgAPIListModules['oldreviewedpages'] = 'ApiQueryOldreviewedpages'; |
— | — | @@ -377,13 +377,13 @@ |
378 | 378 | $wgAPIModules['flagconfig'] = 'ApiFlagConfig'; |
379 | 379 | |
380 | 380 | # Page review module for API |
381 | | -$wgAutoloadClasses['ApiReview'] = $dir.'api/ApiReview.php'; |
| 381 | +$wgAutoloadClasses['ApiReview'] = $dir . 'api/ApiReview.php'; |
382 | 382 | $wgAPIModules['review'] = 'ApiReview'; |
383 | 383 | # Stability config module for API |
384 | | -$wgAutoloadClasses['ApiStabilize'] = $dir.'api/ApiStabilize.php'; |
| 384 | +$wgAutoloadClasses['ApiStabilize'] = $dir . 'api/ApiStabilize.php'; |
385 | 385 | $wgAPIModules['stabilize'] = 'ApiStabilize'; |
386 | 386 | |
387 | | -######### Hook attachments ######### |
| 387 | +# ######## Hook attachments ######### |
388 | 388 | # Autopromote Editors |
389 | 389 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeMakeEditor'; |
390 | 390 | # Adds table link references to include ones from the stable version |
— | — | @@ -487,23 +487,23 @@ |
488 | 488 | |
489 | 489 | # Stable dump hook |
490 | 490 | $wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
491 | | -######### |
| 491 | +# ######## |
492 | 492 | |
493 | 493 | function efLoadFlaggedRevs() { |
494 | 494 | global $wgUseRCPatrol, $wgFlaggedRevsNamespaces, $wgFlaggedRevsVisible; |
495 | 495 | # If patrolling is already on, then we know that it |
496 | 496 | # was intended to have all namespaces patrollable. |
497 | | - if( $wgUseRCPatrol ) { |
| 497 | + if ( $wgUseRCPatrol ) { |
498 | 498 | global $wgFlaggedRevsPatrolNamespaces, $wgCanonicalNamespaceNames; |
499 | 499 | $wgFlaggedRevsPatrolNamespaces = array_keys( $wgCanonicalNamespaceNames ); |
500 | 500 | } |
501 | 501 | # Use RC Patrolling to check for vandalism |
502 | 502 | # When revisions are flagged, they count as patrolled |
503 | | - if( !empty($wgFlaggedRevsNamespaces) ) { |
| 503 | + if ( !empty( $wgFlaggedRevsNamespaces ) ) { |
504 | 504 | $wgUseRCPatrol = true; |
505 | 505 | } |
506 | 506 | # Visibility - experimental |
507 | | - if( !empty($wgFlaggedRevsVisible) ) { |
| 507 | + if ( !empty( $wgFlaggedRevsVisible ) ) { |
508 | 508 | global $wgHooks; |
509 | 509 | $wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanView'; |
510 | 510 | } |
— | — | @@ -520,23 +520,23 @@ |
521 | 521 | global $wgSpecialPages, $wgUseTagFilter; |
522 | 522 | global $wgFlaggedRevsNamespaces, $wgFlaggedRevsOverride, $wgFlaggedRevsProtectLevels; |
523 | 523 | // Show special pages only if FlaggedRevs is enabled on some namespaces |
524 | | - if( !empty($wgFlaggedRevsNamespaces) ) { |
| 524 | + if ( !empty( $wgFlaggedRevsNamespaces ) ) { |
525 | 525 | $list['RevisionReview'] = $wgSpecialPages['RevisionReview'] = 'RevisionReview'; |
526 | 526 | $list['ReviewedVersions'] = $wgSpecialPages['ReviewedVersions'] = 'ReviewedVersions'; |
527 | 527 | // Protect levels define allowed stability settings |
528 | | - if( empty($wgFlaggedRevsProtectLevels) ) { |
| 528 | + if ( empty( $wgFlaggedRevsProtectLevels ) ) { |
529 | 529 | $list['Stabilization'] = $wgSpecialPages['Stabilization'] = 'Stabilization'; |
530 | 530 | } |
531 | 531 | $list['UnreviewedPages'] = $wgSpecialPages['UnreviewedPages'] = 'UnreviewedPages'; |
532 | 532 | $list['OldReviewedPages'] = $wgSpecialPages['OldReviewedPages'] = 'OldReviewedPages'; |
533 | 533 | // Show tag filtered pending edit page if there are tags |
534 | | - if( $wgUseTagFilter && ChangeTags::listDefinedTags() ) { |
| 534 | + if ( $wgUseTagFilter && ChangeTags::listDefinedTags() ) { |
535 | 535 | $list['ProblemChanges'] = $wgSpecialPages['ProblemChanges'] = 'ProblemChanges'; |
536 | 536 | } |
537 | 537 | $list['ReviewedPages'] = $wgSpecialPages['ReviewedPages'] = 'ReviewedPages'; |
538 | 538 | $list['QualityOversight'] = $wgSpecialPages['QualityOversight'] = 'QualityOversight'; |
539 | 539 | $list['ValidationStatistics'] = $wgSpecialPages['ValidationStatistics'] = 'ValidationStatistics'; |
540 | | - if( !$wgFlaggedRevsOverride ) { |
| 540 | + if ( !$wgFlaggedRevsOverride ) { |
541 | 541 | $list['StablePages'] = $wgSpecialPages['StablePages'] = 'StablePages'; |
542 | 542 | } else { |
543 | 543 | $list['UnstablePages'] = $wgSpecialPages['UnstablePages'] = 'UnstablePages'; |
— | — | @@ -580,9 +580,9 @@ |
581 | 581 | $wgSpecialPageCacheUpdates[] = 'efFlaggedRevsUnreviewedPagesUpdate'; |
582 | 582 | |
583 | 583 | function efFlaggedRevsUnreviewedPagesUpdate() { |
584 | | - $base = dirname(__FILE__); |
| 584 | + $base = dirname( __FILE__ ); |
585 | 585 | require_once( "$base/maintenance/updateQueryCache.inc" ); |
586 | | - update_flaggedrevs_querycache(); |
| 586 | + update_flaggedrevs_querycache(); |
587 | 587 | require_once( "$base/maintenance/updateStats.inc" ); |
588 | 588 | update_flaggedrevs_stats(); |
589 | 589 | } |
— | — | @@ -595,11 +595,11 @@ |
596 | 596 | |
597 | 597 | function efFlaggedRevsSchemaUpdates() { |
598 | 598 | global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables; |
599 | | - $base = dirname(__FILE__); |
600 | | - if( $wgDBtype == 'mysql' ) { |
| 599 | + $base = dirname( __FILE__ ); |
| 600 | + if ( $wgDBtype == 'mysql' ) { |
601 | 601 | $wgExtNewTables[] = array( 'flaggedrevs', "$base/FlaggedRevs.sql" ); // Initial install tables |
602 | 602 | $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" ); |
604 | 604 | $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" ); |
605 | 605 | $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" ); |
606 | 606 | $wgExtNewFields[] = array( 'flaggedrevs', 'fr_img_name', "$base/archives/patch-fr_img_name.sql" ); |
— | — | @@ -607,16 +607,16 @@ |
608 | 608 | $wgExtNewFields[] = array( 'flaggedpages', 'fp_pending_since', "$base/archives/patch-fp_pending_since.sql" ); |
609 | 609 | $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_level', "$base/archives/patch-fpc_level.sql" ); |
610 | 610 | $wgExtNewTables[] = array( 'flaggedpage_pending', "$base/archives/patch-flaggedpage_pending.sql" ); |
611 | | - } elseif( $wgDBtype == 'postgres' ) { |
| 611 | + } elseif ( $wgDBtype == 'postgres' ) { |
612 | 612 | $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" ); |
615 | 615 | $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/postgres/patch-flaggedrevs_promote.sql" ); |
616 | 616 | $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" ); |
618 | 618 | $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" ); |
621 | 621 | $wgExtNewTables[] = array( 'flaggedpage_pending', "$base/postgres/patch-flaggedpage_pending.sql" ); |
622 | 622 | } |
623 | 623 | return true; |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | */ |
20 | 20 | public static function getTitleInstance( Title $title ) { |
21 | 21 | // Check if there is already an instance on this title |
22 | | - if( !isset( $title->flaggedRevsArticle ) ) { |
| 22 | + if ( !isset( $title->flaggedRevsArticle ) ) { |
23 | 23 | $title->flaggedRevsArticle = new self( $title ); |
24 | 24 | } |
25 | 25 | return $title->flaggedRevsArticle; |
— | — | @@ -79,9 +79,9 @@ |
80 | 80 | * @param bool $titleOnly, only check if title is in reviewable namespace |
81 | 81 | */ |
82 | 82 | public function isReviewable( $titleOnly = false ) { |
83 | | - if( !FlaggedRevs::isPageReviewable( $this->getTitle() ) ) { |
| 83 | + if ( !FlaggedRevs::isPageReviewable( $this->getTitle() ) ) { |
84 | 84 | return false; |
85 | | - } elseif( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
| 85 | + } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
86 | 86 | && !$this->isStableShownByDefault() ) |
87 | 87 | { |
88 | 88 | return false; |
— | — | @@ -95,9 +95,9 @@ |
96 | 96 | * @return bool |
97 | 97 | */ |
98 | 98 | public function isPatrollable( $titleOnly = false ) { |
99 | | - if( FlaggedRevs::isPagePatrollable( $this->getTitle() ) ) { |
| 99 | + if ( FlaggedRevs::isPagePatrollable( $this->getTitle() ) ) { |
100 | 100 | return true; |
101 | | - } elseif( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
| 101 | + } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
102 | 102 | && !$this->isStableShownByDefault() ) |
103 | 103 | { |
104 | 104 | return true; |
— | — | @@ -111,16 +111,16 @@ |
112 | 112 | * @return Row |
113 | 113 | */ |
114 | 114 | public function getStableRev( $flags = 0 ) { |
115 | | - if( $this->stableRev === false ) { |
| 115 | + if ( $this->stableRev === false ) { |
116 | 116 | return null; // We already looked and found nothing... |
117 | 117 | } |
118 | 118 | # Cached results available? |
119 | | - if( !is_null($this->stableRev) ) { |
| 119 | + if ( !is_null( $this->stableRev ) ) { |
120 | 120 | return $this->stableRev; |
121 | 121 | } |
122 | 122 | # Do we have one? |
123 | 123 | $srev = FlaggedRevision::newFromStable( $this->getTitle(), $flags ); |
124 | | - if( $srev ) { |
| 124 | + if ( $srev ) { |
125 | 125 | $this->stableRev = $srev; |
126 | 126 | $this->flags[$srev->getRevId()] = $srev->getTags(); |
127 | 127 | return $srev; |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | */ |
139 | 139 | public function getVisibilitySettings( $forUpdate = false ) { |
140 | 140 | # Cached results available? |
141 | | - if( !is_null($this->pageConfig) ) { |
| 141 | + if ( !is_null( $this->pageConfig ) ) { |
142 | 142 | return $this->pageConfig; |
143 | 143 | } |
144 | 144 | # Get the content page, skip talk |
— | — | @@ -153,13 +153,13 @@ |
154 | 154 | */ |
155 | 155 | public function getFlagsForRevision( $revId ) { |
156 | 156 | # Cached results? |
157 | | - if( isset($this->flags[$revId]) ) { |
| 157 | + if ( isset( $this->flags[$revId] ) ) { |
158 | 158 | return $this->flags[$revId]; |
159 | 159 | } |
160 | 160 | # Get the flags |
161 | 161 | $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $revId ); |
162 | 162 | # Don't let cache get too big |
163 | | - if( count($this->flags) >= self::CACHE_MAX ) { |
| 163 | + if ( count( $this->flags ) >= self::CACHE_MAX ) { |
164 | 164 | $this->flags = array(); |
165 | 165 | } |
166 | 166 | # Try to cache results |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -26,66 +26,66 @@ |
27 | 27 | |
28 | 28 | public static function load() { |
29 | 29 | global $wgFlaggedRevTags; |
30 | | - if( self::$loaded ) return true; |
| 30 | + if ( self::$loaded ) return true; |
31 | 31 | # Assume true, then set to false if needed |
32 | | - if( !empty($wgFlaggedRevTags) ) { |
| 32 | + if ( !empty( $wgFlaggedRevTags ) ) { |
33 | 33 | self::$qualityVersions = true; |
34 | 34 | self::$pristineVersions = true; |
35 | | - self::$binaryFlagging = (count($wgFlaggedRevTags) <= 1); |
| 35 | + self::$binaryFlagging = ( count( $wgFlaggedRevTags ) <= 1 ); |
36 | 36 | } |
37 | | - foreach( $wgFlaggedRevTags as $tag => $levels ) { |
| 37 | + foreach ( $wgFlaggedRevTags as $tag => $levels ) { |
38 | 38 | # 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 ) { |
41 | 41 | throw new MWException( 'FlaggedRevs given invalid tag name!' ); |
42 | 42 | } |
43 | 43 | # Define "quality" and "pristine" reqs |
44 | | - if( is_array($levels) ) { |
| 44 | + if ( is_array( $levels ) ) { |
45 | 45 | $minQL = $levels['quality']; |
46 | 46 | $minPL = $levels['pristine']; |
47 | 47 | $ratingLevels = $levels['levels']; |
48 | 48 | # B/C, $levels is just an integer (minQL) |
49 | 49 | } else { |
50 | 50 | global $wgFlaggedRevPristine, $wgFlaggedRevValues; |
51 | | - $ratingLevels = isset($wgFlaggedRevValues) ? |
| 51 | + $ratingLevels = isset( $wgFlaggedRevValues ) ? |
52 | 52 | $wgFlaggedRevValues : 1; |
53 | 53 | $minQL = $levels; // an integer |
54 | | - $minPL = isset($wgFlaggedRevPristine) ? |
55 | | - $wgFlaggedRevPristine : $ratingLevels+1; |
| 54 | + $minPL = isset( $wgFlaggedRevPristine ) ? |
| 55 | + $wgFlaggedRevPristine : $ratingLevels + 1; |
56 | 56 | } |
57 | 57 | # Set FlaggedRevs tags |
58 | 58 | self::$dimensions[$tag] = array(); |
59 | | - for( $i=0; $i <= $ratingLevels; $i++ ) { |
| 59 | + for ( $i = 0; $i <= $ratingLevels; $i++ ) { |
60 | 60 | self::$dimensions[$tag][$i] = "{$tag}-{$i}"; |
61 | 61 | } |
62 | | - if( $ratingLevels > 1 ) { |
| 62 | + if ( $ratingLevels > 1 ) { |
63 | 63 | self::$binaryFlagging = false; // more than one level |
64 | 64 | } |
65 | 65 | # Sanity checks |
66 | | - if( !is_integer($minQL) || !is_integer($minPL) ) { |
| 66 | + if ( !is_integer( $minQL ) || !is_integer( $minPL ) ) { |
67 | 67 | throw new MWException( 'FlaggedRevs given invalid tag value!' ); |
68 | 68 | } |
69 | | - if( $minQL > $ratingLevels ) { |
| 69 | + if ( $minQL > $ratingLevels ) { |
70 | 70 | self::$qualityVersions = false; |
71 | 71 | self::$pristineVersions = false; |
72 | 72 | } |
73 | | - if( $minPL > $ratingLevels ) { |
| 73 | + if ( $minPL > $ratingLevels ) { |
74 | 74 | self::$pristineVersions = false; |
75 | 75 | } |
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 ); |
78 | 78 | self::$minSL[$tag] = 1; |
79 | 79 | } |
80 | 80 | global $wgFlaggedRevsProtectLevels; |
81 | 81 | $wgFlaggedRevsProtectLevels = (array)$wgFlaggedRevsProtectLevels; |
82 | | - foreach( $wgFlaggedRevsProtectLevels as $level => $config ) { |
| 82 | + foreach ( $wgFlaggedRevsProtectLevels as $level => $config ) { |
83 | 83 | # 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'] ) |
86 | 86 | ) { |
87 | 87 | throw new MWException( 'FlaggedRevs given incomplete $wgFlaggedRevsProtectLevels value!' ); |
88 | 88 | # Disallow reserved level names |
89 | | - } else if( $level == 'invalid' || $level == 'none' ) { |
| 89 | + } else if ( $level == 'invalid' || $level == 'none' ) { |
90 | 90 | throw new MWException( 'FlaggedRevs given reserved $wgFlaggedRevsProtectLevels key!' ); |
91 | 91 | } |
92 | 92 | $config['override'] = intval( $config['override'] ); // Type cleanup |
— | — | @@ -93,16 +93,16 @@ |
94 | 94 | } |
95 | 95 | global $wgFlaggedRevsRestrictionLevels; |
96 | 96 | # 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; |
100 | 100 | } |
101 | 101 | # Make sure no talk namespaces are in review namespace |
102 | 102 | global $wgFlaggedRevsNamespaces; |
103 | | - foreach( $wgFlaggedRevsNamespaces as $ns ) { |
104 | | - if( MWNamespace::isTalk($ns) ) { |
| 103 | + foreach ( $wgFlaggedRevsNamespaces as $ns ) { |
| 104 | + if ( MWNamespace::isTalk( $ns ) ) { |
105 | 105 | throw new MWException( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' ); |
106 | | - } else if( $ns == NS_MEDIAWIKI ) { |
| 106 | + } else if ( $ns == NS_MEDIAWIKI ) { |
107 | 107 | throw new MWException( 'FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!' ); |
108 | 108 | } |
109 | 109 | } |
— | — | @@ -116,12 +116,12 @@ |
117 | 117 | self::$loaded = true; |
118 | 118 | } |
119 | 119 | |
120 | | - ################# Basic accessors ################# |
| 120 | + # ################ Basic accessors ################# |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Is there only one tag and it has only one level? |
124 | 124 | * @returns bool |
125 | | - */ |
| 125 | + */ |
126 | 126 | public static function binaryFlagging() { |
127 | 127 | self::load(); |
128 | 128 | return self::$binaryFlagging; |
— | — | @@ -130,13 +130,13 @@ |
131 | 131 | /** |
132 | 132 | * If there only one tag and it has only one level, return it |
133 | 133 | * @returns string |
134 | | - */ |
| 134 | + */ |
135 | 135 | public static function binaryTagName() { |
136 | | - if( !self::binaryFlagging() ) { |
| 136 | + if ( !self::binaryFlagging() ) { |
137 | 137 | return null; |
138 | 138 | } |
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]; |
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | */ |
166 | 166 | public static function useSimpleUI() { |
167 | 167 | global $wgUser, $wgSimpleFlaggedRevsUI; |
168 | | - return $wgUser->getOption( 'flaggedrevssimpleui', intval($wgSimpleFlaggedRevsUI) ); |
| 168 | + return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | /** |
218 | 218 | * Does FLaggedRevs only show for pages that have been set to do so? |
219 | 219 | * @returns bool |
220 | | - */ |
| 220 | + */ |
221 | 221 | public static function stableOnlyIfConfigured() { |
222 | 222 | return self::forDefaultVersionOnly() && !self::isStableShownByDefault(); |
223 | 223 | } |
— | — | @@ -228,10 +228,10 @@ |
229 | 229 | public static function ignoreDefaultVersion() { |
230 | 230 | global $wgFlaggedRevsExceptions, $wgUser; |
231 | 231 | # 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' ) { |
234 | 234 | return ( !$wgUser->isAnon() ); |
235 | | - } elseif( in_array( $group, $wgUser->getGroups() ) ) { |
| 235 | + } elseif ( in_array( $group, $wgUser->getGroups() ) ) { |
236 | 236 | return true; |
237 | 237 | } |
238 | 238 | } |
— | — | @@ -276,12 +276,12 @@ |
277 | 277 | unset( $defaultConfig['expiry'] ); |
278 | 278 | unset( $config['expiry'] ); |
279 | 279 | # Check if the page is not protected at all |
280 | | - if( $config == $defaultConfig ) { |
| 280 | + if ( $config == $defaultConfig ) { |
281 | 281 | return "none"; |
282 | 282 | } |
283 | 283 | # 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 ) { |
286 | 286 | return $level; |
287 | 287 | } |
288 | 288 | } |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | /** |
293 | 293 | * Get the autoreview restriction levels available |
294 | 294 | * @returns array |
295 | | - */ |
| 295 | + */ |
296 | 296 | public static function getRestrictionLevels() { |
297 | 297 | self::load(); |
298 | 298 | return self::$restrictionLevels; |
— | — | @@ -369,7 +369,7 @@ |
370 | 370 | */ |
371 | 371 | public static function getTagLevels( $tag ) { |
372 | 372 | self::load(); |
373 | | - return isset(self::$dimensions[$tag]) ? |
| 373 | + return isset( self::$dimensions[$tag] ) ? |
374 | 374 | self::$dimensions[$tag] : array(); |
375 | 375 | } |
376 | 376 | |
— | — | @@ -381,9 +381,9 @@ |
382 | 382 | */ |
383 | 383 | public static function getTagValueMsg( $tag, $value ) { |
384 | 384 | self::load(); |
385 | | - if( !isset(self::$dimensions[$tag]) ) |
| 385 | + if ( !isset( self::$dimensions[$tag] ) ) |
386 | 386 | return ''; |
387 | | - if( !isset(self::$dimensions[$tag][$value]) ) |
| 387 | + if ( !isset( self::$dimensions[$tag][$value] ) ) |
388 | 388 | return ''; |
389 | 389 | # Return empty string if not there |
390 | 390 | return wfMsgExt( 'revreview-' . self::$dimensions[$tag][$value], |
— | — | @@ -396,7 +396,7 @@ |
397 | 397 | */ |
398 | 398 | public static function dimensionsEmpty() { |
399 | 399 | self::load(); |
400 | | - return empty(self::$dimensions); |
| 400 | + return empty( self::$dimensions ); |
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | 1 => 'quality', |
413 | 413 | 2 => 'pristine' |
414 | 414 | ); |
415 | | - if( isset( $levelText[$level] ) ) { |
| 415 | + if ( isset( $levelText[$level] ) ) { |
416 | 416 | return $levelText[$level]; |
417 | 417 | } else { |
418 | 418 | return ''; |
— | — | @@ -428,7 +428,7 @@ |
429 | 429 | */ |
430 | 430 | public static function getPrecedence( $config = null ) { |
431 | 431 | global $wgFlaggedRevsPrecedence; |
432 | | - if( is_null($config) ) { |
| 432 | + if ( is_null( $config ) ) { |
433 | 433 | $config = (int)$wgFlaggedRevsPrecedence; |
434 | 434 | } |
435 | 435 | switch( $config ) |
— | — | @@ -471,7 +471,7 @@ |
472 | 472 | $minLevels = self::$minSL; |
473 | 473 | } |
474 | 474 | $flags = array(); |
475 | | - foreach( self::getDimensions() as $tag => $x ) { |
| 475 | + foreach ( self::getDimensions() as $tag => $x ) { |
476 | 476 | $flags[$tag] = $minLevels[$tag]; |
477 | 477 | } |
478 | 478 | return $flags; |
— | — | @@ -483,33 +483,33 @@ |
484 | 484 | * @return mixed array or null |
485 | 485 | */ |
486 | 486 | public static function getAutoReviewTags( $quality, $config = array() ) { |
487 | | - if( !FlaggedRevs::autoReviewEdits() ) |
| 487 | + if ( !FlaggedRevs::autoReviewEdits() ) |
488 | 488 | return null; // shouldn't happen |
489 | 489 | # Find the maximum auto-review quality level |
490 | | - $qal = min(FlaggedRevs::autoReviewEdits()-1,$quality); |
| 490 | + $qal = min( FlaggedRevs::autoReviewEdits() - 1, $quality ); |
491 | 491 | # Pristine auto-review? |
492 | | - if( $qal == FR_PRISTINE ) { |
| 492 | + if ( $qal == FR_PRISTINE ) { |
493 | 493 | $flags = self::quickTags( FR_PRISTINE ); |
494 | 494 | # 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 ) ) { |
496 | 496 | return $flags; |
497 | 497 | } |
498 | 498 | $qal = FR_QUALITY; // try lower level |
499 | 499 | } |
500 | 500 | # Quality auto-review? |
501 | | - if( $qal == FR_QUALITY ) { |
| 501 | + if ( $qal == FR_QUALITY ) { |
502 | 502 | $flags = self::quickTags( FR_QUALITY ); |
503 | 503 | # 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 ) ) { |
505 | 505 | return $flags; |
506 | 506 | } |
507 | 507 | $qal = FR_SIGHTED; // try lower level |
508 | 508 | } |
509 | 509 | # Sighted auto-review? |
510 | | - if( $qal == FR_SIGHTED ) { |
| 510 | + if ( $qal == FR_SIGHTED ) { |
511 | 511 | $flags = self::quickTags( FR_SIGHTED ); |
512 | 512 | # 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 ) ) { |
514 | 514 | return $flags; |
515 | 515 | } |
516 | 516 | } |
— | — | @@ -527,26 +527,26 @@ |
528 | 528 | */ |
529 | 529 | public static function userCanAutoSetFlags( $flags, $oldflags = array(), $config = array() ) { |
530 | 530 | global $wgUser; |
531 | | - if( !$wgUser->isAllowed('autoreview') ) { |
| 531 | + if ( !$wgUser->isAllowed( 'autoreview' ) ) { |
532 | 532 | return false; |
533 | 533 | } |
534 | 534 | # Check if all of the required site flags have a valid value |
535 | 535 | # 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 |
539 | 539 | # 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 ) ) { |
541 | 541 | return false; |
542 | 542 | # Sanity check numeric range |
543 | | - } elseif( $level < 0 || $level > $highest ) { |
| 543 | + } elseif ( $level < 0 || $level > $highest ) { |
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | } |
547 | 547 | return true; |
548 | 548 | } |
549 | 549 | |
550 | | - ################# Parsing functions ################# |
| 550 | + # ################ Parsing functions ################# |
551 | 551 | |
552 | 552 | /** |
553 | 553 | * @param string $text |
— | — | @@ -555,7 +555,7 @@ |
556 | 556 | * @return array( string, array, array, array, int ) |
557 | 557 | * All included pages/arguments are expanded out |
558 | 558 | */ |
559 | | - public static function expandText( $text='', $title, $id ) { |
| 559 | + public static function expandText( $text = '', $title, $id ) { |
560 | 560 | global $wgParser; |
561 | 561 | # Make our hooks trigger (force unstub so setting doesn't get lost) |
562 | 562 | $wgParser->firstCallInit(); |
— | — | @@ -564,7 +564,7 @@ |
565 | 565 | $options = self::makeParserOptions(); |
566 | 566 | $outputText = $wgParser->preprocess( $text, $title, $options, $id ); |
567 | 567 | $out =& $wgParser->mOutput; |
568 | | - $data = array( $outputText, $out->mTemplates, $out->mTemplateIds, |
| 568 | + $data = array( $outputText, $out->mTemplates, $out->mTemplateIds, |
569 | 569 | $out->fr_includeErrors, $out->fr_newestTemplateID ); |
570 | 570 | # Done! |
571 | 571 | $wgParser->fr_isStable = false; |
— | — | @@ -579,7 +579,7 @@ |
580 | 580 | * @param int $id |
581 | 581 | * @return ParserOutput |
582 | 582 | */ |
583 | | - public static function parseStableText( $article, $text='', $id ) { |
| 583 | + public static function parseStableText( $article, $text = '', $id ) { |
584 | 584 | global $wgParser; |
585 | 585 | $title = $article->getTitle(); // avoid pass-by-reference error |
586 | 586 | # Make our hooks trigger (force unstub so setting doesn't get lost) |
— | — | @@ -620,7 +620,7 @@ |
621 | 621 | global $parserMemc, $wgCacheEpoch; |
622 | 622 | wfProfileIn( __METHOD__ ); |
623 | 623 | # Make sure it is valid |
624 | | - if( !$article->getId() ) { |
| 624 | + if ( !$article->getId() ) { |
625 | 625 | wfProfileOut( __METHOD__ ); |
626 | 626 | return null; |
627 | 627 | } |
— | — | @@ -629,14 +629,14 @@ |
630 | 630 | # Get the cached HTML |
631 | 631 | wfDebug( "Trying parser cache $key\n" ); |
632 | 632 | $value = $parserMemc->get( $key ); |
633 | | - if( is_object( $value ) ) { |
| 633 | + if ( is_object( $value ) ) { |
634 | 634 | wfDebug( "Found.\n" ); |
635 | 635 | # Delete if article has changed since the cache was made |
636 | 636 | $canCache = $article->checkTouched(); |
637 | 637 | $cacheTime = $value->getCacheTime(); |
638 | 638 | $touched = $article->mTouched; |
639 | | - if( !$canCache || $value->expired( $touched ) ) { |
640 | | - if( !$canCache ) { |
| 639 | + if ( !$canCache || $value->expired( $touched ) ) { |
| 640 | + if ( !$canCache ) { |
641 | 641 | wfIncrStats( "pcache_miss_invalid" ); |
642 | 642 | wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); |
643 | 643 | } else { |
— | — | @@ -646,7 +646,7 @@ |
647 | 647 | $parserMemc->delete( $key ); |
648 | 648 | $value = false; |
649 | 649 | } else { |
650 | | - if( isset( $value->mTimestamp ) ) { |
| 650 | + if ( isset( $value->mTimestamp ) ) { |
651 | 651 | $article->mTimestamp = $value->mTimestamp; |
652 | 652 | } |
653 | 653 | wfIncrStats( "pcache_hit" ); |
— | — | @@ -676,10 +676,10 @@ |
677 | 677 | * @param parserOutput $parserOut |
678 | 678 | * Updates the stable cache of a page with the given $parserOut |
679 | 679 | */ |
680 | | - public static function updatePageCache( $article, $user, $parserOut=null ) { |
| 680 | + public static function updatePageCache( $article, $user, $parserOut = null ) { |
681 | 681 | global $parserMemc, $wgParserCacheExpireTime, $wgEnableParserCache; |
682 | 682 | # Make sure it is valid and $wgEnableParserCache is enabled |
683 | | - if( !$wgEnableParserCache || is_null($parserOut) ) |
| 683 | + if ( !$wgEnableParserCache || is_null( $parserOut ) ) |
684 | 684 | return false; |
685 | 685 | |
686 | 686 | $parserCache = ParserCache::singleton(); |
— | — | @@ -691,7 +691,7 @@ |
692 | 692 | $parserOut->mTimestamp = $article->getTimestamp(); |
693 | 693 | $parserOut->mText .= "\n<!-- Saved in stable version parser cache with key $key and timestamp $now -->"; |
694 | 694 | # Set expire time |
695 | | - if( $parserOut->containsOldMagic() ){ |
| 695 | + if ( $parserOut->containsOldMagic() ) { |
696 | 696 | $expire = 3600; // 1 hour |
697 | 697 | } else { |
698 | 698 | $expire = $wgParserCacheExpireTime; |
— | — | @@ -720,8 +720,8 @@ |
721 | 721 | */ |
722 | 722 | public static function clearIncludeVersionCache( $revId ) { |
723 | 723 | self::load(); |
724 | | - if( isset(self::$includeVersionCache[$revId]) ) { |
725 | | - unset(self::$includeVersionCache[$revId]); |
| 724 | + if ( isset( self::$includeVersionCache[$revId] ) ) { |
| 725 | + unset( self::$includeVersionCache[$revId] ); |
726 | 726 | } |
727 | 727 | } |
728 | 728 | |
— | — | @@ -730,7 +730,7 @@ |
731 | 731 | */ |
732 | 732 | public static function useProcessCache( $revId ) { |
733 | 733 | self::load(); |
734 | | - if( isset(self::$includeVersionCache[$revId]) ) { |
| 734 | + if ( isset( self::$includeVersionCache[$revId] ) ) { |
735 | 735 | return true; |
736 | 736 | } |
737 | 737 | return false; |
— | — | @@ -745,9 +745,9 @@ |
746 | 746 | */ |
747 | 747 | public static function getTemplateIdFromCache( $revId, $namespace, $dbKey ) { |
748 | 748 | 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] ) ) { |
752 | 752 | return self::$includeVersionCache[$revId]['templates'][$namespace][$dbKey]; |
753 | 753 | } |
754 | 754 | } |
— | — | @@ -764,22 +764,22 @@ |
765 | 765 | */ |
766 | 766 | public static function getFileVersionFromCache( $revId, $dbKey ) { |
767 | 767 | self::load(); |
768 | | - if( isset(self::$includeVersionCache[$revId]) ) { |
| 768 | + if ( isset( self::$includeVersionCache[$revId] ) ) { |
769 | 769 | # All NS_FILE, no need to check namespace |
770 | | - if( isset(self::$includeVersionCache[$revId]['files'][$dbKey]) ) { |
| 770 | + if ( isset( self::$includeVersionCache[$revId]['files'][$dbKey] ) ) { |
771 | 771 | $time_SHA1 = self::$includeVersionCache[$revId]['files'][$dbKey]; |
772 | | - foreach( $time_SHA1 as $time => $sha1 ) { |
| 772 | + foreach ( $time_SHA1 as $time => $sha1 ) { |
773 | 773 | // Should only be one, but this is an easy check |
774 | | - return array($time,$sha1); |
| 774 | + return array( $time, $sha1 ); |
775 | 775 | } |
776 | | - return array(false,""); // missing? |
| 776 | + return array( false, "" ); // missing? |
777 | 777 | } |
778 | 778 | } |
779 | 779 | return null; // cache not found |
780 | 780 | } |
781 | 781 | |
782 | | - ################# Synchronization and link update functions ################# |
783 | | - |
| 782 | + # ################ Synchronization and link update functions ################# |
| 783 | + |
784 | 784 | /** |
785 | 785 | * @param FlaggedRevision $srev, the stable revision |
786 | 786 | * @param Article $article |
— | — | @@ -788,77 +788,77 @@ |
789 | 789 | * @return bool |
790 | 790 | * See if a flagged revision is synced with the current. |
791 | 791 | * This function is pretty expensive... |
792 | | - */ |
| 792 | + */ |
793 | 793 | public static function stableVersionIsSynced( |
794 | | - $srev, $article, $stableOutput=null, $currentOutput=null |
| 794 | + $srev, $article, $stableOutput = null, $currentOutput = null |
795 | 795 | ) { |
796 | 796 | global $wgMemc, $wgEnableParserCache, $wgUser; |
797 | 797 | # Must be the same revision as the current |
798 | | - if( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) { |
| 798 | + if ( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) { |
799 | 799 | return false; |
800 | 800 | } |
801 | 801 | # 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() ) { |
804 | 804 | return false; |
805 | 805 | } |
806 | 806 | } |
807 | 807 | # Try the cache... |
808 | 808 | $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" ) { |
811 | 811 | return true; |
812 | | - } elseif( $value === "false" ) { |
| 812 | + } elseif ( $value === "false" ) { |
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | # If parseroutputs not given, fetch them... |
816 | | - if( is_null($stableOutput) || !isset($stableOutput->fr_newestTemplateID) ) { |
| 816 | + if ( is_null( $stableOutput ) || !isset( $stableOutput->fr_newestTemplateID ) ) { |
817 | 817 | # Get parsed stable version |
818 | 818 | $anon = new User(); // anon cache most likely to exist |
819 | 819 | $stableOutput = self::getPageCache( $article, $anon ); |
820 | | - if( $stableOutput == false && $wgUser->getId() ) |
| 820 | + if ( $stableOutput == false && $wgUser->getId() ) |
821 | 821 | $stableOutput = self::getPageCache( $article, $wgUser ); |
822 | 822 | # Regenerate the parser output as needed... |
823 | | - if( $stableOutput == false ) { |
| 823 | + if ( $stableOutput == false ) { |
824 | 824 | $text = $srev->getRevText(); |
825 | 825 | $stableOutput = self::parseStableText( $article, $text, $srev->getRevId() ); |
826 | 826 | # Update the stable version cache |
827 | 827 | self::updatePageCache( $article, $anon, $stableOutput ); |
828 | 828 | } |
829 | 829 | } |
830 | | - if( is_null($currentOutput) || !isset($currentOutput->fr_newestTemplateID) ) { |
| 830 | + if ( is_null( $currentOutput ) || !isset( $currentOutput->fr_newestTemplateID ) ) { |
831 | 831 | # Get parsed current version |
832 | 832 | $parserCache = ParserCache::singleton(); |
833 | 833 | $currentOutput = false; |
834 | 834 | $anon = new User(); // anon cache most likely to exist |
835 | 835 | # If $text is set, then the stableOutput is new. In that case, |
836 | 836 | # the current must also be new to avoid sync goofs. |
837 | | - if( !isset($text) ) { |
| 837 | + if ( !isset( $text ) ) { |
838 | 838 | $currentOutput = $parserCache->get( $article, $anon ); |
839 | | - if( $currentOutput == false && $wgUser->getId() ) |
| 839 | + if ( $currentOutput == false && $wgUser->getId() ) |
840 | 840 | $currentOutput = $parserCache->get( $article, $wgUser ); |
841 | 841 | } |
842 | 842 | # Regenerate the parser output as needed... |
843 | | - if( $currentOutput == false ) { |
| 843 | + if ( $currentOutput == false ) { |
844 | 844 | global $wgParser; |
845 | 845 | $rev = Revision::newFromTitle( $article->getTitle() ); |
846 | 846 | $text = $rev ? $rev->getText() : false; |
847 | 847 | $id = $rev ? $rev->getId() : null; |
848 | 848 | $title = $article->getTitle(); |
849 | | - $options = self::makeParserOptions($anon); |
| 849 | + $options = self::makeParserOptions( $anon ); |
850 | 850 | $currentOutput = $wgParser->parse( $text, $title, $options, |
851 | 851 | /*$lineStart*/true, /*$clearState*/true, $id ); |
852 | 852 | # Might as well save the cache while we're at it |
853 | | - if( $wgEnableParserCache ) |
| 853 | + if ( $wgEnableParserCache ) |
854 | 854 | $parserCache->save( $currentOutput, $article, $anon ); |
855 | 855 | } |
856 | 856 | } |
857 | 857 | # Only current of revisions of inclusions can be reviewed. Since the stable and current revisions |
858 | 858 | # have the same text, the only thing that can make them different is updating a template or image. |
859 | 859 | # 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 ) { |
861 | 861 | $synced = false; |
862 | | - } elseif( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
| 862 | + } elseif ( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
863 | 863 | $synced = false; |
864 | 864 | } else { |
865 | 865 | $synced = true; |
— | — | @@ -889,9 +889,9 @@ |
890 | 890 | * @param Article $article |
891 | 891 | * @return mixed |
892 | 892 | * Return memc value if not expired |
893 | | - */ |
| 893 | + */ |
894 | 894 | public static function getMemcValue( $data, $article ) { |
895 | | - if( is_object($data) && $data->time >= $article->getTouched() ) { |
| 895 | + if ( is_object( $data ) && $data->time >= $article->getTouched() ) { |
896 | 896 | return $data->value; |
897 | 897 | } |
898 | 898 | return false; |
— | — | @@ -904,19 +904,19 @@ |
905 | 905 | * @return int |
906 | 906 | * Get number of revs since the stable revision |
907 | 907 | */ |
908 | | - public static function getRevCountSince( $article, $revId, $forUpdate=false ) { |
| 908 | + public static function getRevCountSince( $article, $revId, $forUpdate = false ) { |
909 | 909 | global $wgMemc, $wgParserCacheExpireTime; |
910 | 910 | # Try the cache |
911 | 911 | $count = null; |
912 | 912 | $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; |
916 | 916 | } |
917 | | - if( is_null($count) ) { |
| 917 | + if ( is_null( $count ) ) { |
918 | 918 | $db = $forUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
919 | 919 | $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 ) ), |
921 | 921 | __METHOD__ ); |
922 | 922 | # Save to cache |
923 | 923 | $wgMemc->set( $key, $count, $wgParserCacheExpireTime ); |
— | — | @@ -931,32 +931,32 @@ |
932 | 932 | * Updates the tracking tables and pending edit count cache. Called on edit. |
933 | 933 | */ |
934 | 934 | public static function updateStableVersion( $article, $rev, $latest = null ) { |
935 | | - if( !$article->getId() ) |
| 935 | + if ( !$article->getId() ) |
936 | 936 | return true; // no bogus entries |
937 | 937 | # 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 ); |
940 | 940 | # Get the highest quality revision (not necessarily this one) |
941 | 941 | $dbw = wfGetDB( DB_MASTER ); |
942 | | - $maxQuality = $dbw->selectField( array('flaggedrevs','revision'), |
| 942 | + $maxQuality = $dbw->selectField( array( 'flaggedrevs', 'revision' ), |
943 | 943 | 'fr_quality', |
944 | 944 | array( 'fr_page_id' => $article->getId(), |
945 | 945 | 'rev_id = fr_rev_id', |
946 | 946 | 'rev_page = fr_page_id', |
947 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 947 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
948 | 948 | ), |
949 | 949 | __METHOD__, |
950 | | - array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 ) |
| 950 | + array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 ) |
951 | 951 | ); |
952 | 952 | # Get the timestamp of the edit after the stable version (if any) |
953 | 953 | $revId = $rev->getId(); |
954 | | - if( $latest != $revId ) { |
| 954 | + if ( $latest != $revId ) { |
955 | 955 | # Get the latest revision ID |
956 | 956 | $timestamp = $rev->getTimestamp(); |
957 | 957 | $nextTimestamp = $dbw->selectField( 'revision', |
958 | 958 | 'rev_timestamp', |
959 | 959 | array( 'rev_page' => $article->getId(), |
960 | | - "rev_timestamp > ".$dbw->addQuotes( $dbw->timestamp($timestamp) ) ), |
| 960 | + "rev_timestamp > " . $dbw->addQuotes( $dbw->timestamp( $timestamp ) ) ), |
961 | 961 | __METHOD__, |
962 | 962 | array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 ) |
963 | 963 | ); |
— | — | @@ -967,11 +967,11 @@ |
968 | 968 | $dbw->replace( 'flaggedpages', |
969 | 969 | array( 'fp_page_id' ), |
970 | 970 | 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, |
973 | 973 | '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__ |
976 | 976 | ); |
977 | 977 | # Reset cache of # of unreviewed revs |
978 | 978 | self::getRevCountSince( $article, $revId, true ); |
— | — | @@ -988,35 +988,35 @@ |
989 | 989 | public static function updatePendingList( $article, $latest = null ) { |
990 | 990 | $data = array(); |
991 | 991 | $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY; |
992 | | - if( !self::qualityVersions() ) |
| 992 | + if ( !self::qualityVersions() ) |
993 | 993 | $level = FR_SIGHTED; |
994 | 994 | # 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 ); |
997 | 997 | } |
998 | 998 | $pageId = $article->getId(); |
999 | 999 | # Update pending times for each level, going from highest to lowest |
1000 | 1000 | $dbw = wfGetDB( DB_MASTER ); |
1001 | 1001 | $higherLevelId = 0; |
1002 | 1002 | $higherLevelTS = ''; |
1003 | | - while( $level >= 0 ) { |
| 1003 | + while ( $level >= 0 ) { |
1004 | 1004 | # Get the latest revision of this level... |
1005 | | - $row = $dbw->selectRow( array('flaggedrevs','revision'), |
| 1005 | + $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ), |
1006 | 1006 | array( 'fr_rev_id', 'rev_timestamp' ), |
1007 | 1007 | array( 'fr_page_id' => $pageId, |
1008 | 1008 | 'fr_quality' => $level, |
1009 | 1009 | 'rev_id = fr_rev_id', |
1010 | 1010 | '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 ) |
1013 | 1013 | ), |
1014 | 1014 | __METHOD__, |
1015 | | - array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) |
| 1015 | + array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) |
1016 | 1016 | ); |
1017 | 1017 | # If there is a revision of this level, track it... |
1018 | 1018 | # Revisions reviewed to one level count as reviewed |
1019 | 1019 | # at the lower levels (i.e. quality -> sighted). |
1020 | | - if( $row ) { |
| 1020 | + if ( $row ) { |
1021 | 1021 | $id = $row->fr_rev_id; |
1022 | 1022 | $ts = $row->rev_timestamp; |
1023 | 1023 | } else { |
— | — | @@ -1024,11 +1024,11 @@ |
1025 | 1025 | $ts = $higherLevelTS; // use previous (quality -> sighted) |
1026 | 1026 | } |
1027 | 1027 | # Get edits that actually are pending... |
1028 | | - if( $id && $latest > $id ) { |
| 1028 | + if ( $id && $latest > $id ) { |
1029 | 1029 | # Get the timestamp of the edit after this version (if any) |
1030 | 1030 | $nextTimestamp = $dbw->selectField( 'revision', |
1031 | 1031 | 'rev_timestamp', |
1032 | | - array( 'rev_page' => $pageId, "rev_timestamp > ".$dbw->addQuotes($ts) ), |
| 1032 | + array( 'rev_page' => $pageId, "rev_timestamp > " . $dbw->addQuotes( $ts ) ), |
1033 | 1033 | __METHOD__, |
1034 | 1034 | array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 ) |
1035 | 1035 | ); |
— | — | @@ -1044,7 +1044,7 @@ |
1045 | 1045 | $level--; |
1046 | 1046 | } |
1047 | 1047 | # 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__ ); |
1049 | 1049 | $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ ); |
1050 | 1050 | return true; |
1051 | 1051 | } |
— | — | @@ -1058,12 +1058,12 @@ |
1059 | 1059 | $parserCache = ParserCache::singleton(); |
1060 | 1060 | $anon = new User(); // anon cache most likely to exist |
1061 | 1061 | $poutput = $parserCache->get( $article, $anon ); |
1062 | | - if( $poutput == false && $wgUser->getId() ) |
| 1062 | + if ( $poutput == false && $wgUser->getId() ) |
1063 | 1063 | $poutput = $parserCache->get( $article, $wgUser ); |
1064 | | - if( $poutput == false ) { |
| 1064 | + if ( $poutput == false ) { |
1065 | 1065 | $text = $article->getContent(); |
1066 | 1066 | $options = self::makeParserOptions(); |
1067 | | - $poutput = $wgParser->parse($text, $article->getTitle(), $options); |
| 1067 | + $poutput = $wgParser->parse( $text, $article->getTitle(), $options ); |
1068 | 1068 | } |
1069 | 1069 | $u = new LinksUpdate( $article->getTitle(), $poutput ); |
1070 | 1070 | $u->doUpdate(); // this will trigger our hook to add stable links too... |
— | — | @@ -1074,11 +1074,11 @@ |
1075 | 1075 | * Resets links for a page when changed (other than edits) |
1076 | 1076 | */ |
1077 | 1077 | public static function titleLinksUpdate( $title ) { |
1078 | | - return self::articleLinksUpdate( new Article($title) ); |
| 1078 | + return self::articleLinksUpdate( new Article( $title ) ); |
1079 | 1079 | } |
1080 | 1080 | |
1081 | | - ################# Revision functions ################# |
1082 | | - |
| 1081 | + # ################ Revision functions ################# |
| 1082 | + |
1083 | 1083 | /** |
1084 | 1084 | * Get flags for a revision |
1085 | 1085 | * @param Title $title |
— | — | @@ -1092,7 +1092,7 @@ |
1093 | 1093 | 'fr_page_id' => $title->getArticleId() ), |
1094 | 1094 | __METHOD__ ); |
1095 | 1095 | $tags = $tags ? $tags : ""; |
1096 | | - return FlaggedRevision::expandRevisionTags( strval($tags) ); |
| 1096 | + return FlaggedRevision::expandRevisionTags( strval( $tags ) ); |
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
— | — | @@ -1102,8 +1102,8 @@ |
1103 | 1103 | * @returns mixed (int or false) |
1104 | 1104 | * Get quality of a revision |
1105 | 1105 | */ |
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 ); |
1108 | 1108 | return $db->selectField( 'flaggedrevs', |
1109 | 1109 | 'fr_quality', |
1110 | 1110 | array( 'fr_page_id' => $page_id, 'fr_rev_id' => $rev_id ), |
— | — | @@ -1119,9 +1119,9 @@ |
1120 | 1120 | * @returns bool |
1121 | 1121 | * Useful for quickly pinging to see if a revision is flagged |
1122 | 1122 | */ |
1123 | | - public static function revIsFlagged( $title, $rev_id, $flags=0 ) { |
| 1123 | + public static function revIsFlagged( $title, $rev_id, $flags = 0 ) { |
1124 | 1124 | $quality = self::getRevQuality( $title->getArticleId(), $rev_id, $flags ); |
1125 | | - return ($quality !== false); |
| 1125 | + return ( $quality !== false ); |
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | /** |
— | — | @@ -1133,7 +1133,7 @@ |
1134 | 1134 | public static function getPrimeFlaggedRevId( $article ) { |
1135 | 1135 | $dbr = wfGetDB( DB_SLAVE ); |
1136 | 1136 | # Get the highest quality revision (not necessarily this one). |
1137 | | - $oldid = $dbr->selectField( array('flaggedrevs','revision'), |
| 1137 | + $oldid = $dbr->selectField( array( 'flaggedrevs', 'revision' ), |
1138 | 1138 | 'fr_rev_id', |
1139 | 1139 | array( |
1140 | 1140 | 'fr_page_id' => $article->getId(), |
— | — | @@ -1143,7 +1143,7 @@ |
1144 | 1144 | __METHOD__, |
1145 | 1145 | array( |
1146 | 1146 | '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' ) |
1148 | 1148 | ) |
1149 | 1149 | ); |
1150 | 1150 | return $oldid; |
— | — | @@ -1157,7 +1157,7 @@ |
1158 | 1158 | public static function markRevisionPatrolled( $rev ) { |
1159 | 1159 | $rcid = $rev->isUnpatrolled(); |
1160 | 1160 | # Make sure it is now marked patrolled... |
1161 | | - if( $rcid ) { |
| 1161 | + if ( $rcid ) { |
1162 | 1162 | $dbw = wfGetDB( DB_MASTER ); |
1163 | 1163 | $dbw->update( 'recentchanges', |
1164 | 1164 | array( 'rc_patrolled' => 1 ), |
— | — | @@ -1169,7 +1169,7 @@ |
1170 | 1170 | return false; |
1171 | 1171 | } |
1172 | 1172 | |
1173 | | - ################# Page configuration functions ################# |
| 1173 | + # ################ Page configuration functions ################# |
1174 | 1174 | |
1175 | 1175 | /** |
1176 | 1176 | * Get visibility restrictions on page |
— | — | @@ -1177,36 +1177,36 @@ |
1178 | 1178 | * @param bool $forUpdate, use master DB? |
1179 | 1179 | * @returns Array (select,override) |
1180 | 1180 | */ |
1181 | | - public static function getPageVisibilitySettings( $title, $forUpdate=false ) { |
| 1181 | + public static function getPageVisibilitySettings( $title, $forUpdate = false ) { |
1182 | 1182 | $db = wfGetDB( $forUpdate ? DB_MASTER : DB_SLAVE ); |
1183 | 1183 | $row = $db->selectRow( 'flaggedpage_config', |
1184 | 1184 | array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ), |
1185 | 1185 | array( 'fpc_page_id' => $title->getArticleID() ), |
1186 | 1186 | __METHOD__ |
1187 | 1187 | ); |
1188 | | - if( $row ) { |
| 1188 | + if ( $row ) { |
1189 | 1189 | $now = wfTimestampNow(); |
1190 | 1190 | # This code should be refactored, now that it's being used more generally. |
1191 | 1191 | $expiry = Block::decodeExpiry( $row->fpc_expiry ); |
1192 | 1192 | # Only apply the settings if they haven't expired |
1193 | | - if( !$expiry || $expiry < $now ) { |
| 1193 | + if ( !$expiry || $expiry < $now ) { |
1194 | 1194 | $row = null; |
1195 | 1195 | self::purgeExpiredConfigurations(); |
1196 | 1196 | self::titleLinksUpdate( $title ); // re-find stable version |
1197 | 1197 | $title->invalidateCache(); // purge squid/memcached |
1198 | 1198 | } |
1199 | 1199 | } |
1200 | | - if( !$row ) { |
| 1200 | + if ( !$row ) { |
1201 | 1201 | return self::getDefaultVisibilitySettings(); |
1202 | 1202 | } |
1203 | 1203 | $config = array( |
1204 | | - 'select' => intval($row->fpc_select), |
| 1204 | + 'select' => intval( $row->fpc_select ), |
1205 | 1205 | 'override' => $row->fpc_override, |
1206 | 1206 | 'autoreview' => $row->fpc_level, |
1207 | 1207 | 'expiry' => $row->fpc_expiry |
1208 | 1208 | ); |
1209 | 1209 | # 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' ) { |
1211 | 1211 | return self::getDefaultVisibilitySettings(); // revert to none |
1212 | 1212 | } |
1213 | 1213 | return $config; |
— | — | @@ -1214,16 +1214,16 @@ |
1215 | 1215 | |
1216 | 1216 | /** |
1217 | 1217 | * Get default page configuration settings |
1218 | | - */ |
| 1218 | + */ |
1219 | 1219 | public static function getDefaultVisibilitySettings() { |
1220 | 1220 | return array( |
1221 | 1221 | # 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 |
1225 | 1225 | 'select' => self::getPrecedence(), |
1226 | 1226 | # Keep this consistent across settings: |
1227 | | - ## 1 -> override, 0 -> don't |
| 1227 | + # # 1 -> override, 0 -> don't |
1228 | 1228 | 'override' => self::isStableShownByDefault() ? 1 : 0, |
1229 | 1229 | 'autoreview' => '', |
1230 | 1230 | 'expiry' => 'infinity' |
— | — | @@ -1244,19 +1244,19 @@ |
1245 | 1245 | ); |
1246 | 1246 | $pageIds = $pagesClearTracking = array(); |
1247 | 1247 | $config = self::getDefaultVisibilitySettings(); // config is to be reset |
1248 | | - while( $row = $dbw->fetchObject( $ret ) ) { |
| 1248 | + while ( $row = $dbw->fetchObject( $ret ) ) { |
1249 | 1249 | // If FlaggedRevs got "turned off" for this page (due to not |
1250 | 1250 | // having the stable version as the default), then clear it |
1251 | 1251 | // from the tracking tables... |
1252 | | - if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) { |
| 1252 | + if ( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) { |
1253 | 1253 | $pagesClearTracking[] = $row->fpc_page_id; // no stable version |
1254 | 1254 | // Check if the new (default) config has a different way |
1255 | 1255 | // 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 ) ) { |
1257 | 1257 | $title = Title::newFromId( $row->fpc_page_id, GAID_FOR_UPDATE ); |
1258 | 1258 | // Determine the new stable version and update the tracking tables... |
1259 | 1259 | $srev = FlaggedRevision::newFromStable( $title, FR_MASTER, $config ); |
1260 | | - if( $srev ) { |
| 1260 | + if ( $srev ) { |
1261 | 1261 | $article = new Article( $title ); |
1262 | 1262 | self::updateStableVersion( $article, $srev, $title->getArticleID() ); |
1263 | 1263 | } else { |
— | — | @@ -1266,16 +1266,16 @@ |
1267 | 1267 | $pageIds[] = $row->fpc_page_id; |
1268 | 1268 | } |
1269 | 1269 | // Clear the expired config for this pages |
1270 | | - if( count($pageIds) ) { |
| 1270 | + if ( count( $pageIds ) ) { |
1271 | 1271 | $dbw->delete( 'flaggedpage_config', array( 'fpc_page_id' => $pageIds ), __METHOD__ ); |
1272 | 1272 | } |
1273 | 1273 | // Clear the tracking rows where needed |
1274 | | - if( count($pagesClearTracking) ) { |
| 1274 | + if ( count( $pagesClearTracking ) ) { |
1275 | 1275 | self::clearTrackingRows( $pagesClearTracking ); |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | |
1279 | | - ################# Other utility functions ################# |
| 1279 | + # ################ Other utility functions ################# |
1280 | 1280 | |
1281 | 1281 | /** |
1282 | 1282 | * @param Array $flags |
— | — | @@ -1303,9 +1303,9 @@ |
1304 | 1304 | |
1305 | 1305 | // Checks if $flags meets $reqFlagLevels |
1306 | 1306 | 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] ) |
1310 | 1310 | return false; |
1311 | 1311 | } |
1312 | 1312 | return true; |
— | — | @@ -1317,20 +1317,20 @@ |
1318 | 1318 | * @return int, flagging tier (-1 for non-sighted) |
1319 | 1319 | */ |
1320 | 1320 | public static function getLevelTier( $flags ) { |
1321 | | - if( self::isPristine( $flags ) ) |
| 1321 | + if ( self::isPristine( $flags ) ) |
1322 | 1322 | return FR_PRISTINE; // 2 |
1323 | | - elseif( self::isQuality( $flags ) ) |
| 1323 | + elseif ( self::isQuality( $flags ) ) |
1324 | 1324 | return FR_QUALITY; // 1 |
1325 | | - elseif( self::isSighted( $flags ) ) |
| 1325 | + elseif ( self::isSighted( $flags ) ) |
1326 | 1326 | return FR_SIGHTED; // 0 |
1327 | 1327 | else |
1328 | | - return -1; |
| 1328 | + return - 1; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | /** |
1332 | 1332 | * Get the list of reviewable namespaces |
1333 | 1333 | * @return array |
1334 | | - */ |
| 1334 | + */ |
1335 | 1335 | public static function getReviewNamespaces() { |
1336 | 1336 | self::load(); // validates namespaces |
1337 | 1337 | return self::$reviewNamespaces; |
— | — | @@ -1339,7 +1339,7 @@ |
1340 | 1340 | /** |
1341 | 1341 | * Get the list of patrolable namespaces |
1342 | 1342 | * @return array |
1343 | | - */ |
| 1343 | + */ |
1344 | 1344 | public static function getPatrolNamespaces() { |
1345 | 1345 | self::load(); // validates namespaces |
1346 | 1346 | return self::$patrolNamespaces; |
— | — | @@ -1358,10 +1358,10 @@ |
1359 | 1359 | $ns = ( $title->getNamespace() == NS_MEDIA ) ? |
1360 | 1360 | NS_FILE : $title->getNamespace(); // Treat NS_MEDIA as NS_FILE |
1361 | 1361 | # Check for MW: pages and whitelist for exempt pages |
1362 | | - if( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) { |
| 1362 | + if ( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) { |
1363 | 1363 | return false; |
1364 | 1364 | } |
1365 | | - return ( in_array($ns,$namespaces) ); |
| 1365 | + return ( in_array( $ns, $namespaces ) ); |
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | /** |
— | — | @@ -1373,7 +1373,7 @@ |
1374 | 1374 | $namespaces = self::getPatrolNamespaces(); |
1375 | 1375 | $ns = ( $title->getNamespace() == NS_MEDIA ) ? |
1376 | 1376 | NS_FILE : $title->getNamespace(); // Treat NS_MEDIA as NS_FILE |
1377 | | - return ( in_array($ns,$namespaces) ); |
| 1377 | + return ( in_array( $ns, $namespaces ) ); |
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | /** |
— | — | @@ -1383,32 +1383,32 @@ |
1384 | 1384 | * @returns array (string,string) |
1385 | 1385 | */ |
1386 | 1386 | 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 |
1389 | 1389 | } |
1390 | 1390 | $css = FlaggedRevsXML::getQualityColor( $row->fr_quality ); |
1391 | 1391 | $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 ) ) { |
1394 | 1394 | $msg = 'hist-autoreviewed'; |
1395 | 1395 | } 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'; |
1397 | 1397 | } |
1398 | 1398 | $st = $title->getPrefixedDBkey(); |
1399 | 1399 | $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 ); |
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | /** |
1405 | 1405 | * Clear FlaggedRevs tracking tables for this page |
1406 | 1406 | * @param mixed $pageId (int or array) |
1407 | | - */ |
| 1407 | + */ |
1408 | 1408 | public static function clearTrackingRows( $pageId ) { |
1409 | 1409 | $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__ ); |
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | /** |
— | — | @@ -1426,23 +1426,23 @@ |
1427 | 1427 | ); |
1428 | 1428 | # Parse params |
1429 | 1429 | $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 ); |
1434 | 1434 | $key = $m[0]; |
1435 | | - $value = isset($m[1]) ? $m[1] : null; |
| 1435 | + $value = isset( $m[1] ) ? $m[1] : null; |
1436 | 1436 | $p[$key] = $value; |
1437 | 1437 | } |
1438 | 1438 | } |
1439 | 1439 | # Initialize fields as needed... |
1440 | | - if( !isset($p['uniqueContentPages']) ) |
| 1440 | + if ( !isset( $p['uniqueContentPages'] ) ) |
1441 | 1441 | $p['uniqueContentPages'] = ''; |
1442 | | - if( !isset($p['totalContentEdits']) ) |
| 1442 | + if ( !isset( $p['totalContentEdits'] ) ) |
1443 | 1443 | $p['totalContentEdits'] = 0; |
1444 | | - if( !isset($p['editComments']) ) |
| 1444 | + if ( !isset( $p['editComments'] ) ) |
1445 | 1445 | $p['editComments'] = 0; |
1446 | | - if( !isset($p['revertedEdits']) ) |
| 1446 | + if ( !isset( $p['revertedEdits'] ) ) |
1447 | 1447 | $p['revertedEdits'] = 0; |
1448 | 1448 | |
1449 | 1449 | return $p; |
— | — | @@ -1457,19 +1457,19 @@ |
1458 | 1458 | */ |
1459 | 1459 | public static function saveUserParams( $uid, $params, $DBName = false ) { |
1460 | 1460 | $flatParams = ''; |
1461 | | - foreach( $params as $key => $value ) { |
| 1461 | + foreach ( $params as $key => $value ) { |
1462 | 1462 | $flatParams .= "{$key}={$value}\n"; |
1463 | 1463 | } |
1464 | 1464 | $dbw = wfGetDB( DB_MASTER, array(), $DBName ); |
1465 | | - $row = $dbw->replace( 'flaggedrevs_promote', |
| 1465 | + $row = $dbw->replace( 'flaggedrevs_promote', |
1466 | 1466 | 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 ) ), |
1468 | 1468 | __METHOD__ |
1469 | 1469 | ); |
1470 | 1470 | return ( $dbw->affectedRows() > 0 ); |
1471 | 1471 | } |
1472 | 1472 | |
1473 | | - ################# Auto-review function ################# |
| 1473 | + # ################ Auto-review function ################# |
1474 | 1474 | |
1475 | 1475 | /** |
1476 | 1476 | * Automatically review an edit and add a log entry in the review log. |
— | — | @@ -1485,7 +1485,7 @@ |
1486 | 1486 | * If no appropriate tags can be found, then the review will abort. |
1487 | 1487 | */ |
1488 | 1488 | public static function autoReviewEdit( |
1489 | | - $article, $user, $text, $rev, $flags=null, $auto=true |
| 1489 | + $article, $user, $text, $rev, $flags = null, $auto = true |
1490 | 1490 | ) { |
1491 | 1491 | wfProfileIn( __METHOD__ ); |
1492 | 1492 | $title = $article->getTitle(); |
— | — | @@ -1494,20 +1494,20 @@ |
1495 | 1495 | $oldSvId = $oldSv ? $oldSv->getRevId() : 0; |
1496 | 1496 | # Set the auto-review tags from the prior stable version. |
1497 | 1497 | # 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 |
1500 | 1500 | $flags = self::getAutoReviewTags( $oldSv->getQuality() /* available */ ); |
1501 | 1501 | } else { // new page? use minimal level |
1502 | 1502 | $flags = self::getAutoReviewTags( FR_SIGHTED ); |
1503 | 1503 | } |
1504 | | - if( !is_array($flags) ) { |
| 1504 | + if ( !is_array( $flags ) ) { |
1505 | 1505 | wfProfileOut( __METHOD__ ); |
1506 | 1506 | return false; // can't auto-review this revision |
1507 | 1507 | } |
1508 | 1508 | } |
1509 | 1509 | $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; |
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | $tmpset = $imgset = array(); |
— | — | @@ -1519,8 +1519,8 @@ |
1520 | 1520 | $poutput = $editInfo->output; |
1521 | 1521 | |
1522 | 1522 | # 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 ) { |
1525 | 1525 | $tmpset[] = array( |
1526 | 1526 | 'ft_rev_id' => $rev->getId(), |
1527 | 1527 | 'ft_namespace' => $namespace, |
— | — | @@ -1530,8 +1530,8 @@ |
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | # 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 ) { |
1536 | 1536 | $imgset[] = array( |
1537 | 1537 | 'fi_rev_id' => $rev->getId(), |
1538 | 1538 | 'fi_name' => $dbkey, |
— | — | @@ -1543,10 +1543,10 @@ |
1544 | 1544 | |
1545 | 1545 | # If this is an image page, store corresponding file info |
1546 | 1546 | $fileData = array(); |
1547 | | - if( $title->getNamespace() == NS_FILE ) { |
| 1547 | + if ( $title->getNamespace() == NS_FILE ) { |
1548 | 1548 | $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() ) { |
1551 | 1551 | $fileData['name'] = $title->getDBkey(); |
1552 | 1552 | $fileData['timestamp'] = $file->getTimestamp(); |
1553 | 1553 | $fileData['sha1'] = $file->getSha1(); |
— | — | @@ -1574,11 +1574,11 @@ |
1575 | 1575 | # If we know that this is now the new stable version |
1576 | 1576 | # (which it probably is), save it to the cache... |
1577 | 1577 | $sv = FlaggedRevision::newFromStable( $article->getTitle(), FR_MASTER/*consistent*/ ); |
1578 | | - if( $sv && $sv->getRevId() == $rev->getId() ) { |
| 1578 | + if ( $sv && $sv->getRevId() == $rev->getId() ) { |
1579 | 1579 | global $wgMemc; |
1580 | 1580 | # Update stable page cache. Don't cache redirects; |
1581 | 1581 | # it would go unused and complicate things. |
1582 | | - if( !Title::newFromRedirect( $text ) ) { |
| 1582 | + if ( !Title::newFromRedirect( $text ) ) { |
1583 | 1583 | FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput ); |
1584 | 1584 | } |
1585 | 1585 | self::updatePageCache( $article, $user, $poutput ); |
— | — | @@ -1589,7 +1589,7 @@ |
1590 | 1590 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() ); |
1591 | 1591 | $data = FlaggedRevs::makeMemcObj( "true" ); |
1592 | 1592 | $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |
1593 | | - } else if( $sv ) { |
| 1593 | + } else if ( $sv ) { |
1594 | 1594 | # Update tracking table |
1595 | 1595 | self::updatePendingList( $article, $rev->getId() ); |
1596 | 1596 | } else { |
— | — | @@ -1607,9 +1607,9 @@ |
1608 | 1608 | self::load(); |
1609 | 1609 | # Param to pass to JS function to know if tags are at quality level |
1610 | 1610 | $tagsJS = array(); |
1611 | | - foreach( self::$dimensions as $tag => $x ) { |
| 1611 | + foreach ( self::$dimensions as $tag => $x ) { |
1612 | 1612 | $tagsJS[$tag] = array(); |
1613 | | - $tagsJS[$tag]['levels'] = count($x)-1; |
| 1613 | + $tagsJS[$tag]['levels'] = count( $x ) - 1; |
1614 | 1614 | $tagsJS[$tag]['quality'] = self::$minQL[$tag]; |
1615 | 1615 | $tagsJS[$tag]['pristine'] = self::$minPL[$tag]; |
1616 | 1616 | } |
— | — | @@ -1627,20 +1627,20 @@ |
1628 | 1628 | public static function getIncludeParams( $article, $templateIDs, $imageSHA1Keys ) { |
1629 | 1629 | $templateParams = $imageParams = $fileVersion = ''; |
1630 | 1630 | # 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 ) { |
1633 | 1633 | $temptitle = Title::makeTitle( $namespace, $dbKey ); |
1634 | 1634 | $templateParams .= $temptitle->getPrefixedDBKey() . "|" . $revId . "#"; |
1635 | 1635 | } |
1636 | 1636 | } |
1637 | 1637 | # 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 ) { |
1640 | 1640 | $imageParams .= $dbKey . "|" . $time . "|" . $sha1 . "#"; |
1641 | 1641 | } |
1642 | 1642 | } |
1643 | 1643 | # For image pages, note the displayed image version |
1644 | | - if( $article instanceof ImagePage ) { |
| 1644 | + if ( $article instanceof ImagePage ) { |
1645 | 1645 | $file = $article->getDisplayedFile(); |
1646 | 1646 | $fileVersion = $file->getTimestamp() . "#" . $file->getSha1(); |
1647 | 1647 | } |
Index: trunk/extensions/FlaggedRevs/FRCacheUpdate.php |
— | — | @@ -14,19 +14,19 @@ |
15 | 15 | |
16 | 16 | public function doUpdate() { |
17 | 17 | global $wgFlaggedRevsCacheUpdates; |
18 | | - if( !isset($wgFlaggedRevsCacheUpdates) ) { |
| 18 | + if ( !isset( $wgFlaggedRevsCacheUpdates ) ) { |
19 | 19 | $wgFlaggedRevsCacheUpdates = array(); // temp var |
20 | 20 | } |
21 | 21 | $key = $this->mTitle->getPrefixedDBKey(); |
22 | | - if( isset($wgFlaggedRevsCacheUpdates[$key]) ) |
| 22 | + if ( isset( $wgFlaggedRevsCacheUpdates[$key] ) ) |
23 | 23 | return; // No duplicates... |
24 | 24 | # Fetch the IDs |
25 | 25 | $dbr = wfGetDB( DB_SLAVE ); |
26 | 26 | $res = $dbr->select( $this->mTable, $this->getFromField(), |
27 | 27 | $this->getToCondition(), __METHOD__ ); |
28 | | - if( $dbr->numRows($res) > 0 ) { |
| 28 | + if ( $dbr->numRows( $res ) > 0 ) { |
29 | 29 | # Do it right now? |
30 | | - if( $dbr->numRows($res) <= $this->mRowsPerJob ) { |
| 30 | + if ( $dbr->numRows( $res ) <= $this->mRowsPerJob ) { |
31 | 31 | $this->invalidateIDs( $res ); |
32 | 32 | # Defer to job queue... |
33 | 33 | } else { |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | |
40 | 40 | protected function insertJobs( ResultWrapper $res ) { |
41 | 41 | $numRows = $res->numRows(); |
42 | | - if( !$numRows ) return; // sanity check |
| 42 | + if ( !$numRows ) return; // sanity check |
43 | 43 | $numBatches = ceil( $numRows / $this->mRowsPerJob ); |
44 | 44 | $realBatchSize = ceil( $numRows / $numBatches ); |
45 | 45 | $start = false; |
— | — | @@ -46,13 +46,13 @@ |
47 | 47 | do { |
48 | 48 | $first = $last = false; // first/last page_id of this batch |
49 | 49 | # Get $realBatchSize items (or less if not enough)... |
50 | | - for( $i = 0; $i < $realBatchSize; $i++ ) { |
| 50 | + for ( $i = 0; $i < $realBatchSize; $i++ ) { |
51 | 51 | $row = $res->fetchRow(); |
52 | 52 | # Is there another row? |
53 | | - if( $row ) { |
| 53 | + if ( $row ) { |
54 | 54 | $id = $row[0]; |
55 | 55 | $last = $id; // $id is the last page_id of this batch |
56 | | - if( $first === false ) |
| 56 | + if ( $first === false ) |
57 | 57 | $first = $id; // set first page_id of this batch |
58 | 58 | # Out of rows? |
59 | 59 | } else { |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | } |
63 | 63 | } |
64 | 64 | # Insert batch into the queue if there is anything there |
65 | | - if( $first ) { |
| 65 | + if ( $first ) { |
66 | 66 | $params = array( |
67 | 67 | 'table' => $this->mTable, |
68 | 68 | 'start' => $first, |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $jobs[] = new FRCacheUpdateJob( $this->mTitle, $params ); |
72 | 72 | } |
73 | 73 | $start = $id; // Where the last ID left off |
74 | | - } while( $start ); |
| 74 | + } while ( $start ); |
75 | 75 | Job::batchInsert( $jobs ); |
76 | 76 | } |
77 | 77 | |
— | — | @@ -88,39 +88,39 @@ |
89 | 89 | */ |
90 | 90 | public function invalidateIDs( ResultWrapper $res ) { |
91 | 91 | global $wgUseFileCache, $wgUseSquid; |
92 | | - if( $res->numRows() == 0 ) return; // sanity check |
| 92 | + if ( $res->numRows() == 0 ) return; // sanity check |
93 | 93 | |
94 | 94 | $dbw = wfGetDB( DB_MASTER ); |
95 | 95 | $timestamp = $dbw->timestamp(); |
96 | 96 | $done = false; |
97 | 97 | |
98 | | - while( !$done ) { |
| 98 | + while ( !$done ) { |
99 | 99 | # Get all IDs in this query into an array |
100 | 100 | $ids = array(); |
101 | | - for( $i = 0; $i < $this->mRowsPerQuery; $i++ ) { |
| 101 | + for ( $i = 0; $i < $this->mRowsPerQuery; $i++ ) { |
102 | 102 | $row = $res->fetchRow(); |
103 | | - if( $row ) { |
| 103 | + if ( $row ) { |
104 | 104 | $ids[] = $row[0]; |
105 | 105 | } else { |
106 | 106 | $done = true; |
107 | 107 | break; |
108 | 108 | } |
109 | 109 | } |
110 | | - if( count($ids) == 0 ) break; |
| 110 | + if ( count( $ids ) == 0 ) break; |
111 | 111 | # Update page_touched |
112 | 112 | $dbw->update( 'page', array( 'page_touched' => $timestamp ), |
113 | 113 | array( 'page_id' => $ids ), __METHOD__ ); |
114 | 114 | # Update static caches |
115 | | - if( $wgUseSquid || $wgUseFileCache ) { |
| 115 | + if ( $wgUseSquid || $wgUseFileCache ) { |
116 | 116 | $titles = Title::newFromIDs( $ids ); |
117 | 117 | # Update squid cache |
118 | | - if( $wgUseSquid ) { |
| 118 | + if ( $wgUseSquid ) { |
119 | 119 | $u = SquidUpdate::newFromTitles( $titles ); |
120 | 120 | $u->doUpdate(); |
121 | 121 | } |
122 | 122 | # Update file cache |
123 | | - if( $wgUseFileCache ) { |
124 | | - foreach( $titles as $title ) { |
| 123 | + if ( $wgUseFileCache ) { |
| 124 | + foreach ( $titles as $title ) { |
125 | 125 | HTMLFileCache::clearFileCache( $title ); |
126 | 126 | } |
127 | 127 | } |
— | — | @@ -154,10 +154,10 @@ |
155 | 155 | # Get query conditions |
156 | 156 | $fromField = $update->getFromField(); |
157 | 157 | $conds = $update->getToCondition(); |
158 | | - if( $this->start ) { |
| 158 | + if ( $this->start ) { |
159 | 159 | $conds[] = "$fromField >= {$this->start}"; |
160 | 160 | } |
161 | | - if( $this->end ) { |
| 161 | + if ( $this->end ) { |
162 | 162 | $conds[] = "$fromField <= {$this->end}"; |
163 | 163 | } |
164 | 164 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -28,13 +28,13 @@ |
29 | 29 | * @param Row $row (from database) |
30 | 30 | */ |
31 | 31 | public function __construct( $row ) { |
32 | | - if( is_object($row) ) { |
| 32 | + if ( is_object( $row ) ) { |
33 | 33 | $this->mRevId = intval( $row->fr_rev_id ); |
34 | 34 | $this->mPageId = intval( $row->fr_page_id ); |
35 | 35 | $this->mTimestamp = $row->fr_timestamp; |
36 | 36 | $this->mComment = $row->fr_comment; |
37 | 37 | $this->mQuality = intval( $row->fr_quality ); |
38 | | - $this->mTags = self::expandRevisionTags( strval($row->fr_tags) ); |
| 38 | + $this->mTags = self::expandRevisionTags( strval( $row->fr_tags ) ); |
39 | 39 | # Image page revision relevant params |
40 | 40 | $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null; |
41 | 41 | $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null; |
— | — | @@ -42,18 +42,18 @@ |
43 | 43 | $row->fr_img_timestamp : null; |
44 | 44 | $this->mUser = intval( $row->fr_user ); |
45 | 45 | # Optional fields |
46 | | - $this->mTitle = isset($row->page_namespace) && isset($row->page_title) |
| 46 | + $this->mTitle = isset( $row->page_namespace ) && isset( $row->page_title ) |
47 | 47 | ? Title::makeTitleSafe( $row->page_namespace, $row->page_title ) |
48 | 48 | : 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 ) ) { |
52 | 52 | $this->mRevId = intval( $row['fr_rev_id'] ); |
53 | 53 | $this->mPageId = intval( $row['fr_page_id'] ); |
54 | 54 | $this->mTimestamp = $row['fr_timestamp']; |
55 | 55 | $this->mComment = $row['fr_comment']; |
56 | 56 | $this->mQuality = intval( $row['fr_quality'] ); |
57 | | - $this->mTags = self::expandRevisionTags( strval($row['fr_tags']) ); |
| 57 | + $this->mTags = self::expandRevisionTags( strval( $row['fr_tags'] ) ); |
58 | 58 | # Image page revision relevant params |
59 | 59 | $this->mFileName = $row['fr_img_name'] ? $row['fr_img_name'] : null; |
60 | 60 | $this->mFileSha1 = $row['fr_img_sha1'] ? $row['fr_img_sha1'] : null; |
— | — | @@ -61,8 +61,8 @@ |
62 | 62 | $row['fr_img_timestamp'] : null; |
63 | 63 | $this->mUser = intval( $row['fr_user'] ); |
64 | 64 | # 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; |
67 | 67 | } else { |
68 | 68 | throw new MWException( 'FlaggedRevision constructor passed invalid row format.' ); |
69 | 69 | } |
— | — | @@ -78,36 +78,36 @@ |
79 | 79 | public static function newFromTitle( Title $title, $revId, $flags = 0 ) { |
80 | 80 | $columns = self::selectFields(); |
81 | 81 | # If we want the text, then get the text flags too |
82 | | - if( $flags & FR_TEXT ) { |
| 82 | + if ( $flags & FR_TEXT ) { |
83 | 83 | $columns += self::selectTextFields(); |
84 | 84 | } |
85 | 85 | $options = array(); |
86 | 86 | # User master/slave as appropriate |
87 | | - if( $flags & FR_FOR_UPDATE || $flags & FR_MASTER ) { |
| 87 | + if ( $flags & FR_FOR_UPDATE || $flags & FR_MASTER ) { |
88 | 88 | $db = wfGetDB( DB_MASTER ); |
89 | | - if( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE'; |
| 89 | + if ( $flags & FR_FOR_UPDATE ) $options[] = 'FOR UPDATE'; |
90 | 90 | } else { |
91 | 91 | $db = wfGetDB( DB_SLAVE ); |
92 | 92 | } |
93 | 93 | $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 ); |
94 | 94 | # Short-circuit query |
95 | | - if( !$pageId ) { |
| 95 | + if ( !$pageId ) { |
96 | 96 | return null; |
97 | 97 | } |
98 | 98 | # Skip deleted revisions |
99 | | - $row = $db->selectRow( array('flaggedrevs','revision'), |
| 99 | + $row = $db->selectRow( array( 'flaggedrevs', 'revision' ), |
100 | 100 | $columns, |
101 | 101 | array( 'fr_page_id' => $pageId, |
102 | 102 | 'fr_rev_id' => $revId, |
103 | 103 | 'rev_id = fr_rev_id', |
104 | 104 | 'rev_page = fr_page_id', |
105 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 105 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
106 | 106 | ), |
107 | 107 | __METHOD__, |
108 | 108 | $options |
109 | 109 | ); |
110 | 110 | # Sorted from highest to lowest, so just take the first one if any |
111 | | - if( $row ) { |
| 111 | + if ( $row ) { |
112 | 112 | $frev = new self( $row ); |
113 | 113 | $frev->mTitle = $title; |
114 | 114 | return $frev; |
— | — | @@ -125,20 +125,20 @@ |
126 | 126 | public static function newFromStable( Title $title, $flags = 0, $config = array() ) { |
127 | 127 | $columns = self::selectFields(); |
128 | 128 | # If we want the text, then get the text flags too |
129 | | - if( $flags & FR_TEXT ) { |
| 129 | + if ( $flags & FR_TEXT ) { |
130 | 130 | $columns += self::selectTextFields(); |
131 | 131 | } |
132 | 132 | $options = array(); |
133 | 133 | # Short-circuit query |
134 | 134 | $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 ); |
135 | 135 | # Short-circuit query |
136 | | - if( !$pageId ) { |
| 136 | + if ( !$pageId ) { |
137 | 137 | return null; |
138 | 138 | } |
139 | 139 | # Quick slave queries... |
140 | | - if( !($flags & FR_FOR_UPDATE) && !($flags & FR_MASTER) ) { |
| 140 | + if ( !( $flags & FR_FOR_UPDATE ) && !( $flags & FR_MASTER ) ) { |
141 | 141 | $dbr = wfGetDB( DB_SLAVE ); |
142 | | - $row = $dbr->selectRow( array('flaggedpages','flaggedrevs'), |
| 142 | + $row = $dbr->selectRow( array( 'flaggedpages', 'flaggedrevs' ), |
143 | 143 | $columns, |
144 | 144 | array( 'fp_page_id' => $pageId, |
145 | 145 | 'fr_page_id = fp_page_id', |
— | — | @@ -146,29 +146,29 @@ |
147 | 147 | ), |
148 | 148 | __METHOD__ |
149 | 149 | ); |
150 | | - if( !$row ) return null; |
| 150 | + if ( !$row ) return null; |
151 | 151 | # Master queries that skip the tracking table... |
152 | 152 | } else { |
153 | 153 | $row = null; |
154 | 154 | # Get visiblity settings... |
155 | | - if( empty($config) ) { |
| 155 | + if ( empty( $config ) ) { |
156 | 156 | $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
157 | 157 | } |
158 | | - if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) { |
| 158 | + if ( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) { |
159 | 159 | return $row; // page is not reviewable; no stable version |
160 | 160 | } |
161 | 161 | $dbw = wfGetDB( DB_MASTER ); |
162 | 162 | $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'; |
164 | 164 | # 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' ), |
167 | 167 | $columns, |
168 | 168 | array( 'fr_page_id' => $pageId, |
169 | | - 'fr_quality = '.FR_PRISTINE, |
| 169 | + 'fr_quality = ' . FR_PRISTINE, |
170 | 170 | 'rev_id = fr_rev_id', |
171 | 171 | 'rev_page = fr_page_id', |
172 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 172 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
173 | 173 | ), |
174 | 174 | __METHOD__, |
175 | 175 | $options |
— | — | @@ -176,20 +176,20 @@ |
177 | 177 | # Looks like a plausible revision |
178 | 178 | $row = $prow ? $prow : $row; |
179 | 179 | } |
180 | | - if( $row && $config['select'] == FLAGGED_VIS_PRISTINE ) { |
| 180 | + if ( $row && $config['select'] == FLAGGED_VIS_PRISTINE ) { |
181 | 181 | // we have what we want already |
182 | 182 | # Look for the latest quality revision... |
183 | | - } elseif( FlaggedRevs::qualityVersions() && $config['select'] != FLAGGED_VIS_LATEST ) { |
| 183 | + } elseif ( FlaggedRevs::qualityVersions() && $config['select'] != FLAGGED_VIS_LATEST ) { |
184 | 184 | // If we found a pristine rev above, this one must be newer... |
185 | 185 | $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' ), |
187 | 187 | $columns, |
188 | 188 | array( 'fr_page_id' => $pageId, |
189 | | - 'fr_quality = '.FR_QUALITY, |
| 189 | + 'fr_quality = ' . FR_QUALITY, |
190 | 190 | $newerClause, |
191 | 191 | 'rev_id = fr_rev_id', |
192 | 192 | 'rev_page = fr_page_id', |
193 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 193 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
194 | 194 | ), |
195 | 195 | __METHOD__, |
196 | 196 | $options |
— | — | @@ -197,18 +197,18 @@ |
198 | 198 | $row = $qrow ? $qrow : $row; |
199 | 199 | } |
200 | 200 | # 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' ), |
203 | 203 | $columns, |
204 | 204 | array( 'fr_page_id' => $pageId, |
205 | 205 | 'rev_id = fr_rev_id', |
206 | 206 | 'rev_page = fr_page_id', |
207 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 207 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
208 | 208 | ), |
209 | 209 | __METHOD__, |
210 | 210 | $options |
211 | 211 | ); |
212 | | - if( !$row ) return null; |
| 212 | + if ( !$row ) return null; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | $frev = new self( $row ); |
— | — | @@ -226,8 +226,8 @@ |
227 | 227 | */ |
228 | 228 | public function insertOn( $tmpRows, $fileRows, $auto = false ) { |
229 | 229 | $textFlags = 'dynamic'; |
230 | | - if( $auto ) $textFlags .= ',auto'; |
231 | | - $this->mFlags = explode(',',$textFlags); |
| 230 | + if ( $auto ) $textFlags .= ',auto'; |
| 231 | + $this->mFlags = explode( ',', $textFlags ); |
232 | 232 | $dbw = wfGetDB( DB_MASTER ); |
233 | 233 | # Our review entry |
234 | 234 | $revRow = array( |
— | — | @@ -245,7 +245,7 @@ |
246 | 246 | 'fr_img_sha1' => $this->getFileSha1() |
247 | 247 | ); |
248 | 248 | # 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' ) ), |
250 | 250 | $revRow, __METHOD__ ); |
251 | 251 | # Clear out any previous garbage. |
252 | 252 | # We want to be able to use this for tracking... |
— | — | @@ -254,10 +254,10 @@ |
255 | 255 | $dbw->delete( 'flaggedimages', |
256 | 256 | array( 'fi_rev_id' => $this->getRevId() ), __METHOD__ ); |
257 | 257 | # Update our versioning params |
258 | | - if( !empty($tmpRows) ) { |
| 258 | + if ( !empty( $tmpRows ) ) { |
259 | 259 | $dbw->insert( 'flaggedtemplates', $tmpRows, __METHOD__, 'IGNORE' ); |
260 | 260 | } |
261 | | - if( !empty($fileRows) ) { |
| 261 | + if ( !empty( $fileRows ) ) { |
262 | 262 | $dbw->insert( 'flaggedimages', $fileRows, __METHOD__, 'IGNORE' ); |
263 | 263 | } |
264 | 264 | return true; |
— | — | @@ -267,16 +267,16 @@ |
268 | 268 | * @returns Array basic select fields (not including text/text flags) |
269 | 269 | */ |
270 | 270 | 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' ); |
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
277 | 277 | * @returns Array text select fields (text/text flags) |
278 | 278 | */ |
279 | 279 | public static function selectTextFields() { |
280 | | - return array('fr_flags'); |
| 280 | + return array( 'fr_flags' ); |
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | * @returns Title title |
292 | 292 | */ |
293 | 293 | public function getTitle() { |
294 | | - if( is_null($this->mTitle) ) { |
| 294 | + if ( is_null( $this->mTitle ) ) { |
295 | 295 | $this->mTitle = Title::newFromId( $this->mPageId ); |
296 | 296 | } |
297 | 297 | return $this->mTitle; |
— | — | @@ -316,7 +316,7 @@ |
317 | 317 | * @returns Revision |
318 | 318 | */ |
319 | 319 | public function getRevision() { |
320 | | - if( is_null($this->mRevision) ) { |
| 320 | + if ( is_null( $this->mRevision ) ) { |
321 | 321 | # Get corresponding revision |
322 | 322 | $rev = Revision::newFromId( $this->mRevId ); |
323 | 323 | # Save to cache |
— | — | @@ -398,7 +398,7 @@ |
399 | 399 | /** |
400 | 400 | * Set template versions array |
401 | 401 | * @param Array template versions (ns -> dbKey -> rev id) |
402 | | - */ |
| 402 | + */ |
403 | 403 | public function setTemplateVersions( $templateVersions ) { |
404 | 404 | $this->mTemplates = $templateVersions; |
405 | 405 | } |
— | — | @@ -406,24 +406,24 @@ |
407 | 407 | /** |
408 | 408 | * Set file versions array |
409 | 409 | * @param Array file versions (dbKey -> sha1) |
410 | | - */ |
| 410 | + */ |
411 | 411 | public function setFileVersions( $fileVersions ) { |
412 | 412 | $this->mFiles = $fileVersions; |
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
416 | 416 | * @returns Array template versions (ns -> dbKey -> rev id) |
417 | | - */ |
| 417 | + */ |
418 | 418 | public function getTemplateVersions() { |
419 | | - if( $this->mTemplates == null ) { |
| 419 | + if ( $this->mTemplates == null ) { |
420 | 420 | $this->mTemplates = array(); |
421 | 421 | $dbr = wfGetDB( DB_SLAVE ); |
422 | 422 | $res = $dbr->select( 'flaggedtemplates', '*', |
423 | 423 | array( 'ft_rev_id' => $this->getRevId() ), |
424 | 424 | __METHOD__ |
425 | 425 | ); |
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] ) ) { |
428 | 428 | $this->mTemplates[$row->ft_namespace] = array(); |
429 | 429 | } |
430 | 430 | $this->mTemplates[$row->ft_namespace][$row->ft_title] = $row->ft_tmp_rev_id; |
— | — | @@ -434,16 +434,16 @@ |
435 | 435 | |
436 | 436 | /** |
437 | 437 | * @returns Array file versions (dbKey -> sha1) |
438 | | - */ |
| 438 | + */ |
439 | 439 | public function getFileVersions() { |
440 | | - if( $this->mFiles == null ) { |
| 440 | + if ( $this->mFiles == null ) { |
441 | 441 | $this->mFiles = array(); |
442 | 442 | $dbr = wfGetDB( DB_SLAVE ); |
443 | 443 | $res = $dbr->select( 'flaggedimages', '*', |
444 | 444 | array( 'fi_rev_id' => $this->getRevId() ), |
445 | 445 | __METHOD__ |
446 | 446 | ); |
447 | | - while( $row = $res->fetchObject() ) { |
| 447 | + while ( $row = $res->fetchObject() ) { |
448 | 448 | $this->mFiles[$row->fi_name] = $row->fi_img_sha1; |
449 | 449 | } |
450 | 450 | } |
— | — | @@ -469,21 +469,21 @@ |
470 | 470 | public static function expandRevisionTags( $tags ) { |
471 | 471 | # Set all flags to zero |
472 | 472 | $flags = array(); |
473 | | - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) { |
| 473 | + foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) { |
474 | 474 | $flags[$tag] = 0; |
475 | 475 | } |
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 ); |
483 | 483 | # Add only currently recognized ones |
484 | | - if( isset($flags[$tag]) ) { |
| 484 | + if ( isset( $flags[$tag] ) ) { |
485 | 485 | # 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; |
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
— | — | @@ -497,10 +497,10 @@ |
498 | 498 | */ |
499 | 499 | public static function flattenRevisionTags( $tags ) { |
500 | 500 | $flags = ''; |
501 | | - foreach( $tags as $tag => $value ) { |
| 501 | + foreach ( $tags as $tag => $value ) { |
502 | 502 | # 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"; |
505 | 505 | } |
506 | 506 | } |
507 | 507 | return $flags; |
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php |
— | — | @@ -18,12 +18,12 @@ |
19 | 19 | # Allow unprivileged users to at least view the settings |
20 | 20 | $this->isAllowed = $wgUser->isAllowed( 'stablesettings' ); |
21 | 21 | # Let anyone view, but not submit... |
22 | | - if( $wgRequest->wasPosted() ) { |
23 | | - if( $wgUser->isBlocked( !$confirm ) ) { |
| 22 | + if ( $wgRequest->wasPosted() ) { |
| 23 | + if ( $wgUser->isBlocked( !$confirm ) ) { |
24 | 24 | return $wgOut->blockedPage(); |
25 | | - } elseif( !$this->isAllowed ) { |
| 25 | + } elseif ( !$this->isAllowed ) { |
26 | 26 | return $wgOut->permissionRequired( 'stablesettings' ); |
27 | | - } elseif( wfReadOnly() ) { |
| 27 | + } elseif ( wfReadOnly() ) { |
28 | 28 | return $wgOut->readOnlyPage(); |
29 | 29 | } |
30 | 30 | } |
— | — | @@ -54,30 +54,32 @@ |
55 | 55 | $isValid = $this->handleParams(); |
56 | 56 | |
57 | 57 | # We need a page... |
58 | | - if( is_null($this->page) ) { |
| 58 | + if ( is_null( $this->page ) ) { |
59 | 59 | 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' ), |
62 | 62 | $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' ), |
65 | 65 | $this->page->getPrefixedText() ) ); |
66 | 66 | } |
67 | 67 | |
68 | 68 | # 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 | + { |
70 | 72 | $this->isAllowed = false; |
71 | 73 | } |
72 | 74 | # Disable some elements as needed |
73 | 75 | $this->disabledAttrib = !$this->isAllowed ? |
74 | 76 | array( 'disabled' => 'disabled' ) : array(); |
75 | 77 | # Show form or submit... |
76 | | - if( $this->isAllowed && $isValid && $confirm ) { |
| 78 | + if ( $this->isAllowed && $isValid && $confirm ) { |
77 | 79 | $status = $this->submit(); |
78 | | - if( $status === true ) { |
| 80 | + if ( $status === true ) { |
79 | 81 | $wgOut->redirect( $this->page->getFullUrl( $query ) ); |
80 | 82 | } else { |
81 | | - $this->showSettings( wfMsg($status) ); |
| 83 | + $this->showSettings( wfMsg( $status ) ); |
82 | 84 | } |
83 | 85 | } else { |
84 | 86 | $this->showSettings(); |
— | — | @@ -92,16 +94,16 @@ |
93 | 95 | # Our target page |
94 | 96 | $this->page = Title::newFromUrl( $this->target ); |
95 | 97 | # We need a page... |
96 | | - if( is_null($this->page) ) { |
| 98 | + if ( is_null( $this->page ) ) { |
97 | 99 | return false; // can't continue |
98 | 100 | } |
99 | 101 | # Get old config |
100 | 102 | $this->config = FlaggedRevs::getPageVisibilitySettings( $this->page, true ); |
101 | 103 | # Make user readable date for GET requests |
102 | | - $this->oldExpiry = $this->config['expiry'] !== 'infinity' ? |
| 104 | + $this->oldExpiry = $this->config['expiry'] !== 'infinity' ? |
103 | 105 | wfTimestamp( TS_RFC2822, $this->config['expiry'] ) : 'infinite'; |
104 | 106 | # If not posted, then fill in existing values/defaults |
105 | | - if( !$this->wasPosted ) { |
| 107 | + if ( !$this->wasPosted ) { |
106 | 108 | # Get visiblity settings... |
107 | 109 | $this->select = $this->config['select']; |
108 | 110 | $this->override = $this->config['override']; |
— | — | @@ -110,42 +112,43 @@ |
111 | 113 | # Handle submission data |
112 | 114 | } else { |
113 | 115 | // Custom expiry takes precedence |
114 | | - $this->expiry = strlen($this->expiry) ? |
| 116 | + $this->expiry = strlen( $this->expiry ) ? |
115 | 117 | $this->expiry : $this->expirySelection; |
116 | | - if( $this->expiry == 'existing' ) |
| 118 | + if ( $this->expiry == 'existing' ) |
117 | 119 | $this->expiry = $this->oldExpiry; |
118 | 120 | // Custom reason takes precedence |
119 | | - if( $this->reasonSelection != 'other' ) { |
| 121 | + if ( $this->reasonSelection != 'other' ) { |
120 | 122 | $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; |
123 | 126 | } |
124 | 127 | } else { |
125 | 128 | $comment = $this->reason; // just use custom reason |
126 | 129 | } |
127 | 130 | $this->reason = $comment; |
128 | 131 | // 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 ) { |
130 | 133 | return false; |
131 | 134 | } |
132 | 135 | // 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 ) ) { |
135 | 138 | return false; // invalid value |
136 | 139 | } |
137 | 140 | // Check autoreview setting |
138 | | - if( !self::userCanSetAutoreviewLevel($this->autoreview) ) { |
| 141 | + if ( !self::userCanSetAutoreviewLevel( $this->autoreview ) ) { |
139 | 142 | return false; // invalid value |
140 | 143 | } |
141 | 144 | } |
142 | 145 | # If we use protection levels, check that settings match one... |
143 | | - if( FlaggedRevs::useProtectionLevels() ) { |
| 146 | + if ( FlaggedRevs::useProtectionLevels() ) { |
144 | 147 | $config = array( |
145 | 148 | 'select' => $this->select, |
146 | 149 | 'override' => $this->override, |
147 | 150 | 'autoreview' => $this->autoreview |
148 | 151 | ); |
149 | | - if( FlaggedRevs::getProtectionLevel($config) == 'invalid' ) { |
| 152 | + if ( FlaggedRevs::getProtectionLevel( $config ) == 'invalid' ) { |
150 | 153 | return false; // this is not a valid configuration |
151 | 154 | } |
152 | 155 | } |
— | — | @@ -159,15 +162,15 @@ |
160 | 163 | */ |
161 | 164 | public static function userCanSetAutoreviewLevel( $right ) { |
162 | 165 | global $wgUser; |
163 | | - if( $right == '' ) |
| 166 | + if ( $right == '' ) |
164 | 167 | return true; // no restrictions |
165 | 168 | # Don't let them choose levels above their own rights |
166 | | - if( $right == 'sysop' ) { |
| 169 | + if ( $right == 'sysop' ) { |
167 | 170 | // special case, rewrite sysop to protect and editprotected |
168 | | - if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') ) { |
| 171 | + if ( !$wgUser->isAllowed( 'protect' ) && !$wgUser->isAllowed( 'editprotected' ) ) { |
169 | 172 | return false; |
170 | 173 | } |
171 | | - } else if( !$wgUser->isAllowed($right) ) { |
| 174 | + } else if ( !$wgUser->isAllowed( $right ) ) { |
172 | 175 | return false; |
173 | 176 | } |
174 | 177 | return true; |
— | — | @@ -176,24 +179,26 @@ |
177 | 180 | protected function showSettings( $err = null ) { |
178 | 181 | global $wgOut, $wgLang, $wgUser; |
179 | 182 | # Add any error messages |
180 | | - if( "" != $err ) { |
| 183 | + if ( "" != $err ) { |
181 | 184 | $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); |
182 | 185 | $wgOut->addHTML( "<p class='error'>{$err}</p>\n" ); |
183 | 186 | } |
184 | 187 | # 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() ); |
187 | 191 | } else { |
188 | | - $form = wfMsgExt( 'stabilization-text', array('parse'), $this->page->getPrefixedText() ); |
| 192 | + $form = wfMsgExt( 'stabilization-text', array( 'parse' ), |
| 193 | + $this->page->getPrefixedText() ); |
189 | 194 | } |
190 | 195 | # Add some script for expiry dropdowns |
191 | | - $wgOut->addScript( |
| 196 | + $wgOut->addScript( |
192 | 197 | "<script type=\"text/javascript\"> |
193 | 198 | function updateStabilizationDropdowns() { |
194 | 199 | val = document.getElementById('mwExpirySelection').value; |
195 | 200 | 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 ) . "; |
198 | 203 | else if( val != 'othertime' ) |
199 | 204 | document.getElementById('mwStabilize-expiry').value = val; |
200 | 205 | } |
— | — | @@ -202,20 +207,20 @@ |
203 | 208 | # Borrow some protection messages for dropdowns |
204 | 209 | $reasonDropDown = Xml::listDropDown( 'wpReasonSelection', |
205 | 210 | wfMsgForContent( 'protect-dropdown' ), |
206 | | - wfMsgForContent( 'protect-otherreason-op' ), |
| 211 | + wfMsgForContent( 'protect-otherreason-op' ), |
207 | 212 | $this->reasonSelection, |
208 | 213 | 'mwStabilize-reason', 4 |
209 | 214 | ); |
210 | 215 | $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' ); |
211 | | - $showProtectOptions = ($scExpiryOptions !== '-' && $this->isAllowed); |
| 216 | + $showProtectOptions = ( $scExpiryOptions !== '-' && $this->isAllowed ); |
212 | 217 | # Add the current expiry as an option |
213 | 218 | $expiryFormOptions = ''; |
214 | | - if( $this->config['expiry'] && $this->config['expiry'] != 'infinity' ) { |
| 219 | + if ( $this->config['expiry'] && $this->config['expiry'] != 'infinity' ) { |
215 | 220 | $timestamp = $wgLang->timeanddate( $this->config['expiry'] ); |
216 | 221 | $d = $wgLang->date( $this->config['expiry'] ); |
217 | 222 | $t = $wgLang->time( $this->config['expiry'] ); |
218 | | - $expiryFormOptions .= |
219 | | - Xml::option( |
| 223 | + $expiryFormOptions .= |
| 224 | + Xml::option( |
220 | 225 | wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ), |
221 | 226 | 'existing', |
222 | 227 | $this->config['expiry'] == 'existing' |
— | — | @@ -223,15 +228,16 @@ |
224 | 229 | } |
225 | 230 | $expiryFormOptions .= Xml::option( wfMsg( 'protect-othertime-op' ), "othertime" ) . "\n"; |
226 | 231 | # 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 ) { |
229 | 234 | $show = $value = $option; |
230 | 235 | } else { |
231 | | - list($show, $value) = explode(":",$option); |
| 236 | + list( $show, $value ) = explode( ":", $option ); |
232 | 237 | } |
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"; |
236 | 242 | } |
237 | 243 | # Add stable version override and selection options |
238 | 244 | $special = SpecialPage::getTitleFor( 'Stabilization' ); |
— | — | @@ -245,12 +251,15 @@ |
246 | 252 | Xml::closeElement( 'fieldset' ) . |
247 | 253 | |
248 | 254 | 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" . |
255 | 264 | Xml::closeElement( 'fieldset' ) . |
256 | 265 | |
257 | 266 | Xml::fieldset( wfMsg( 'stabilization-restrict' ), false ) . |
— | — | @@ -260,11 +269,11 @@ |
261 | 270 | Xml::fieldset( wfMsg( 'stabilization-leg' ), false ) . |
262 | 271 | Xml::openElement( 'table' ); |
263 | 272 | # Add expiry dropdown |
264 | | - if( $showProtectOptions && $this->isAllowed ) { |
| 273 | + if ( $showProtectOptions && $this->isAllowed ) { |
265 | 274 | $form .= " |
266 | 275 | <tr> |
267 | 276 | <td class='mw-label'>" . |
268 | | - Xml::label( wfMsg('stabilization-expiry'), 'mwExpirySelection' ) . |
| 277 | + Xml::label( wfMsg( 'stabilization-expiry' ), 'mwExpirySelection' ) . |
269 | 278 | "</td> |
270 | 279 | <td class='mw-input'>" . |
271 | 280 | Xml::tags( 'select', |
— | — | @@ -283,7 +292,7 @@ |
284 | 293 | $form .= " |
285 | 294 | <tr> |
286 | 295 | <td class='mw-label'>" . |
287 | | - Xml::label( wfMsg('stabilization-othertime'), 'mwStabilize-expiry' ) . |
| 296 | + Xml::label( wfMsg( 'stabilization-othertime' ), 'mwStabilize-expiry' ) . |
288 | 297 | '</td> |
289 | 298 | <td class="mw-input">' . |
290 | 299 | Xml::input( "mwStabilize-expiry", 50, |
— | — | @@ -291,15 +300,17 @@ |
292 | 301 | '</td> |
293 | 302 | </tr>'; |
294 | 303 | # 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' ) ); |
300 | 311 | |
301 | 312 | $form .= ' <tr> |
302 | 313 | <td class="mw-label">' . |
303 | | - xml::label( wfMsg('stabilization-comment'), 'wpReasonSelection' ) . |
| 314 | + xml::label( wfMsg( 'stabilization-comment' ), 'wpReasonSelection' ) . |
304 | 315 | '</td> |
305 | 316 | <td class="mw-input">' . |
306 | 317 | $reasonDropDown . |
— | — | @@ -316,7 +327,8 @@ |
317 | 328 | <tr> |
318 | 329 | <td></td> |
319 | 330 | <td class="mw-input">' . |
320 | | - Xml::check( 'wpReviewthis', $this->reviewThis, array('id'=>'wpReviewthis') ) . |
| 331 | + Xml::check( 'wpReviewthis', $this->reviewThis, |
| 332 | + array( 'id' => 'wpReviewthis' ) ) . |
321 | 333 | "<label for='wpReviewthis'>{$reviewLabel}</label>" . |
322 | 334 | ' ' . |
323 | 335 | Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ) . |
— | — | @@ -340,17 +352,18 @@ |
341 | 353 | |
342 | 354 | $wgOut->addHTML( $form ); |
343 | 355 | |
344 | | - $wgOut->addHTML( Xml::element( 'h2', null, htmlspecialchars( LogPage::logName( 'stable' ) ) ) ); |
| 356 | + $wgOut->addHTML( Xml::element( 'h2', null, |
| 357 | + htmlspecialchars( LogPage::logName( 'stable' ) ) ) ); |
345 | 358 | LogEventsList::showLogExtract( $wgOut, 'stable', $this->page->getPrefixedText() ); |
346 | 359 | } |
347 | 360 | |
348 | 361 | protected function buildSelector( $selected ) { |
349 | 362 | global $wgUser; |
350 | 363 | $levels = array(); |
351 | | - foreach( FlaggedRevs::getRestrictionLevels() as $key ) { |
| 364 | + foreach ( FlaggedRevs::getRestrictionLevels() as $key ) { |
352 | 365 | # Don't let them choose levels they can't set, |
353 | 366 | # but *show* them all when the form is disabled. |
354 | | - if( $this->isAllowed && !self::userCanSetAutoreviewLevel($key) ) { |
| 367 | + if ( $this->isAllowed && !self::userCanSetAutoreviewLevel( $key ) ) { |
355 | 368 | continue; |
356 | 369 | } |
357 | 370 | $levels[] = $key; |
— | — | @@ -363,7 +376,7 @@ |
364 | 377 | ) + $this->disabledAttrib; |
365 | 378 | |
366 | 379 | $out = Xml::openElement( 'select', $attribs ); |
367 | | - foreach( $levels as $key ) { |
| 380 | + foreach ( $levels as $key ) { |
368 | 381 | $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected ); |
369 | 382 | } |
370 | 383 | $out .= Xml::closeElement( 'select' ); |
— | — | @@ -377,12 +390,12 @@ |
378 | 391 | * @return string |
379 | 392 | */ |
380 | 393 | protected function getOptionLabel( $permission ) { |
381 | | - if( $permission == '' ) { |
| 394 | + if ( $permission == '' ) { |
382 | 395 | return wfMsg( 'stabilization-restrict-none' ); |
383 | 396 | } else { |
384 | 397 | $key = "protect-level-{$permission}"; |
385 | 398 | $msg = wfMsg( $key ); |
386 | | - if( wfEmptyMsg( $key, $msg ) ) |
| 399 | + if ( wfEmptyMsg( $key, $msg ) ) |
387 | 400 | $msg = wfMsg( 'protect-fallback', $permission ); |
388 | 401 | return $msg; |
389 | 402 | } |
— | — | @@ -393,23 +406,23 @@ |
394 | 407 | $changed = $reset = false; |
395 | 408 | $defaultPrecedence = FlaggedRevs::getPrecedence(); |
396 | 409 | $defaultOverride = FlaggedRevs::isStableShownByDefault(); |
397 | | - if( $this->select == $defaultPrecedence && $this->override == $defaultOverride ) |
| 410 | + if ( $this->select == $defaultPrecedence && $this->override == $defaultOverride ) |
398 | 411 | { |
399 | | - $reset = ($this->autoreview == ''); // we are going back to site defaults |
| 412 | + $reset = ( $this->autoreview == '' ); // we are going back to site defaults |
400 | 413 | } |
401 | 414 | # Take this opportunity to purge out expired configurations |
402 | 415 | FlaggedRevs::purgeExpiredConfigurations(); |
403 | 416 | # Parse expiry time given... |
404 | | - if( $reset || $this->expiry == 'infinite' || $this->expiry == 'indefinite' ) { |
| 417 | + if ( $reset || $this->expiry == 'infinite' || $this->expiry == 'indefinite' ) { |
405 | 418 | $expiry = Block::infinity(); |
406 | 419 | } else { |
407 | 420 | # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1 |
408 | 421 | $expiry = strtotime( $this->expiry ); |
409 | | - if( $expiry < 0 || $expiry === false ) { |
| 422 | + if ( $expiry < 0 || $expiry === false ) { |
410 | 423 | return 'stabilize_expiry_invalid'; |
411 | 424 | } |
412 | 425 | $expiry = wfTimestamp( TS_MW, $expiry ); |
413 | | - if( $expiry < wfTimestampNow() ) { |
| 426 | + if ( $expiry < wfTimestampNow() ) { |
414 | 427 | return 'stabilize_expiry_old'; |
415 | 428 | } |
416 | 429 | } |
— | — | @@ -423,16 +436,16 @@ |
424 | 437 | __METHOD__ |
425 | 438 | ); |
426 | 439 | # If setting to site default values and there is a row...erase it |
427 | | - if( $row && $reset ) { |
| 440 | + if ( $row && $reset ) { |
428 | 441 | $dbw->delete( 'flaggedpage_config', |
429 | 442 | array( 'fpc_page_id' => $this->page->getArticleID() ), |
430 | 443 | __METHOD__ |
431 | 444 | ); |
432 | | - $changed = ($dbw->affectedRows() != 0); // did this do anything? |
| 445 | + $changed = ( $dbw->affectedRows() != 0 ); // did this do anything? |
433 | 446 | # Otherwise, add a row unless we are just setting it as the site default, |
434 | 447 | # 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... |
437 | 450 | || $row->fpc_select != $this->select // ...precedence changed, or... |
438 | 451 | || $row->fpc_override != $this->override // ...override changed, or... |
439 | 452 | || $row->fpc_level != $this->autoreview // ...autoreview level changed, or... |
— | — | @@ -451,48 +464,48 @@ |
452 | 465 | } |
453 | 466 | } |
454 | 467 | // Check if this actually changed anything... |
455 | | - if( $changed ) { |
| 468 | + if ( $changed ) { |
456 | 469 | $id = $this->page->getArticleId(); |
457 | 470 | $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE ); |
458 | 471 | # Config may have changed to allow stable versions...refresh page |
459 | 472 | # tracking to account for any hidden reviewed versions. |
460 | 473 | $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
461 | | - if( $frev ) { |
| 474 | + if ( $frev ) { |
462 | 475 | FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $latest ); |
463 | 476 | } |
464 | 477 | # ID, accuracy, depth, style |
465 | 478 | $set = array(); |
466 | 479 | # @FIXME: do this better |
467 | 480 | // Precedence |
468 | | - if( FlaggedRevs::qualityVersions() ) { |
| 481 | + if ( FlaggedRevs::qualityVersions() ) { |
469 | 482 | $set[] = wfMsgForContent( 'stabilization-sel-short' ) . |
470 | 483 | wfMsgForContent( 'colon-separator' ) . |
471 | | - wfMsgForContent("stabilization-sel-short-{$this->select}"); |
| 484 | + wfMsgForContent( "stabilization-sel-short-{$this->select}" ); |
472 | 485 | } |
473 | 486 | // Default version |
474 | 487 | $set[] = wfMsgForContent( 'stabilization-def-short' ) . |
475 | 488 | 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 ) ) { |
478 | 491 | $set[] = "autoreview={$this->autoreview}"; |
479 | 492 | } |
480 | 493 | $settings = '[' . $wgContLang->commaList( $set ) . ']'; |
481 | 494 | # Append comment with settings (other than for resets) |
482 | 495 | $reason = $this->reason; |
483 | | - if( !$reset ) { |
| 496 | + if ( !$reset ) { |
484 | 497 | $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' ) { |
487 | 500 | $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 ) ) . ')'; |
491 | 504 | $reason .= "$expiry_description"; |
492 | 505 | } |
493 | 506 | } |
494 | 507 | # Add log entry... |
495 | 508 | $log = new LogPage( 'stable' ); |
496 | | - if( $reset ) { |
| 509 | + if ( $reset ) { |
497 | 510 | $log->addEntry( 'reset', $this->page, $reason ); |
498 | 511 | $type = "stable-logentry2"; |
499 | 512 | } else { |
— | — | @@ -500,8 +513,9 @@ |
501 | 514 | $type = "stable-logentry"; |
502 | 515 | } |
503 | 516 | # 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 ) { |
506 | 520 | $comment .= wfMsgForContent( 'colon-separator' ) . $reason; |
507 | 521 | } |
508 | 522 | # Insert a null revision |
— | — | @@ -509,7 +523,8 @@ |
510 | 524 | $nullRevId = $nullRevision->insertOn( $dbw ); |
511 | 525 | # Update page record and touch page |
512 | 526 | $article->updateRevisionOn( $dbw, $nullRevision, $latest ); |
513 | | - wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest) ); |
| 527 | + wfRunHooks( 'NewRevisionFromEditComplete', |
| 528 | + array( $article, $nullRevision, $latest ) ); |
514 | 529 | |
515 | 530 | $invalidate = true; |
516 | 531 | # Take the user to the diff if an outdated version is being |
— | — | @@ -518,10 +533,10 @@ |
519 | 534 | $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
520 | 535 | $cfLevel = FlaggedRevs::getPrecedence( $this->select ); // desired level |
521 | 536 | // 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 ) { |
523 | 538 | $flags = FlaggedRevs::quickTags( $cfLevel ); // desired flags |
524 | 539 | // Try to autoreview to this level... |
525 | | - if( $this->reviewThis && RevisionReview::userCanSetFlags($flags) ) { |
| 540 | + if ( $this->reviewThis && RevisionReview::userCanSetFlags( $flags ) ) { |
526 | 541 | $text = $nullRevision->getText(); |
527 | 542 | // Invalidate cache if not already done with auto-review |
528 | 543 | $invalidate = !FlaggedRevs::autoReviewEdit( $article, $wgUser, $text, |
— | — | @@ -529,14 +544,14 @@ |
530 | 545 | } |
531 | 546 | } |
532 | 547 | # Update the links tables as the stable version may now be the default page... |
533 | | - if( $invalidate ) { |
| 548 | + if ( $invalidate ) { |
534 | 549 | FlaggedRevs::titleLinksUpdate( $this->page ); |
535 | 550 | } |
536 | 551 | } |
537 | 552 | # Apply watchlist checkbox value (may be NULL) |
538 | | - if( $this->watchThis === true ) { |
| 553 | + if ( $this->watchThis === true ) { |
539 | 554 | $wgUser->addWatch( $this->page ); |
540 | | - } else if( $this->watchThis === false ) { |
| 555 | + } else if ( $this->watchThis === false ) { |
541 | 556 | $wgUser->removeWatch( $this->page ); |
542 | 557 | } |
543 | 558 | return true; |
Index: trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | public function execute( $par ) { |
15 | 15 | global $wgRequest, $wgUser, $wgOut; |
16 | 16 | $this->setHeaders(); |
17 | | - if( !$wgUser->isAllowed( 'unreviewedpages' ) ) { |
| 17 | + if ( !$wgUser->isAllowed( 'unreviewedpages' ) ) { |
18 | 18 | $wgOut->permissionRequired( 'unreviewedpages' ); |
19 | 19 | return; |
20 | 20 | } |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $namespace = $wgRequest->getIntOrNull( 'namespace', $defaultNS ); |
31 | 31 | $category = trim( $wgRequest->getVal( 'category' ) ); |
32 | 32 | $catTitle = Title::makeTitleSafe( NS_CATEGORY, $category ); |
33 | | - $category = is_null($catTitle) ? '' : $catTitle->getText(); |
| 33 | + $category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
34 | 34 | $level = $wgRequest->getInt( 'level' ); |
35 | 35 | $hideRedirs = $wgRequest->getBool( 'hideredirs', true ); |
36 | 36 | |
— | — | @@ -43,48 +43,49 @@ |
44 | 44 | |
45 | 45 | $action = htmlspecialchars( $wgScript ); |
46 | 46 | $wgOut->addHTML( "<form action=\"$action\" method=\"get\">\n" . |
47 | | - '<fieldset><legend>' . wfMsg('unreviewed-legend') . '</legend>' . |
| 47 | + '<fieldset><legend>' . wfMsg( 'unreviewed-legend' ) . '</legend>' . |
48 | 48 | Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . '<p>' ); |
49 | 49 | # Add dropdowns as needed |
50 | | - if( count($namespaces) > 1 ) { |
| 50 | + if ( count( $namespaces ) > 1 ) { |
51 | 51 | $wgOut->addHTML( FlaggedRevsXML::getNamespaceMenu( $namespace ) . ' ' ); |
52 | 52 | } |
53 | | - if( FlaggedRevs::qualityVersions() ) { |
| 53 | + if ( FlaggedRevs::qualityVersions() ) { |
54 | 54 | $wgOut->addHTML( FlaggedRevsXML::getLevelMenu( $level, false, 1 ) . ' ' ); |
55 | 55 | } |
56 | | - $wgOut->addHTML( |
| 56 | + $wgOut->addHTML( |
57 | 57 | "<span style='white-space: nowrap;'>" . |
58 | | - Xml::label( wfMsg("unreviewed-category"), 'category' ) . ' ' . |
59 | | - Xml::input( 'category', 30, $category, array('id' => 'category') ) . |
| 58 | + Xml::label( wfMsg( "unreviewed-category" ), 'category' ) . ' ' . |
| 59 | + Xml::input( 'category', 30, $category, array( 'id' => 'category' ) ) . |
60 | 60 | '</span><br />' . |
61 | | - $showhideredirs . ' ' . |
| 61 | + $showhideredirs . ' ' . |
62 | 62 | Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" . |
63 | 63 | "</fieldset></form>" |
64 | 64 | ); |
65 | 65 | # This will start to get slower if live... |
66 | | - if( !$live = self::generalQueryOK() ) { |
| 66 | + if ( !$live = self::generalQueryOK() ) { |
67 | 67 | $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 ) { |
71 | 71 | 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 ); |
76 | 76 | $wgOut->addHTML( wfMsg( 'perfcachedts', $td, $d, $t ) ); |
77 | 77 | } else { |
78 | 78 | $wgOut->addHTML( wfMsg( 'perfcached' ) ); |
79 | 79 | } |
80 | 80 | } |
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' ) ) ); |
84 | 85 | $wgOut->addHTML( $pager->getNavigationBar() ); |
85 | 86 | $wgOut->addHTML( $pager->getBody() ); |
86 | 87 | $wgOut->addHTML( $pager->getNavigationBar() ); |
87 | 88 | } else { |
88 | | - $wgOut->addHTML( wfMsgExt('unreviewed-none', array('parse') ) ); |
| 89 | + $wgOut->addHTML( wfMsgExt( 'unreviewed-none', array( 'parse' ) ) ); |
89 | 90 | } |
90 | 91 | } |
91 | 92 | |
— | — | @@ -93,50 +94,52 @@ |
94 | 95 | |
95 | 96 | $title = Title::newFromRow( $row ); |
96 | 97 | $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' ); |
98 | 99 | $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 ) ); |
103 | 104 | $stxt = " <small>$stxt</small>"; |
104 | 105 | } |
105 | 106 | # Get how long the first unreviewed edit has been waiting... |
106 | 107 | static $currentTime; |
107 | 108 | $currentTime = wfTimestamp( TS_UNIX ); // now |
108 | 109 | $firstPendingTime = wfTimestamp( TS_UNIX, $row->creation ); |
109 | | - $hours = ($currentTime - $firstPendingTime)/3600; |
| 110 | + $hours = ( $currentTime - $firstPendingTime ) / 3600; |
110 | 111 | // 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 ); |
114 | 115 | // 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 ); |
118 | 119 | } else { |
119 | | - $age = wfMsg('unreviewed-recent'); // hot off the press :) |
| 120 | + $age = wfMsg( 'unreviewed-recent' ); // hot off the press :) |
120 | 121 | } |
121 | | - if( $wgUser->isAllowed('unwatchedpages') ) { |
| 122 | + if ( $wgUser->isAllowed( 'unwatchedpages' ) ) { |
122 | 123 | $uw = self::usersWatching( $title ); |
123 | 124 | $watching = $uw |
124 | | - ? wfMsgExt( 'unreviewed-watched', array('parsemag'), $uw ) |
125 | | - : wfMsgHtml( 'unreviewed-unwatched'); |
| 125 | + ? wfMsgExt( 'unreviewed-watched', array( 'parsemag' ), $uw ) |
| 126 | + : wfMsgHtml( 'unreviewed-unwatched' ); |
126 | 127 | $watching = " $watching"; // Oh-noes! |
127 | 128 | } else { |
128 | | - $uw = -1; |
| 129 | + $uw = - 1; |
129 | 130 | } |
130 | 131 | $css = self::getLineClass( $hours, $uw ); |
131 | 132 | $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; |
133 | 134 | $key = wfMemcKey( 'unreviewedPages', 'underReview', $pageId ); |
134 | 135 | $val = $wgMemc->get( $key ); |
135 | 136 | # 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>'; |
138 | 140 | } |
139 | 141 | |
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>" ); |
141 | 144 | } |
142 | 145 | |
143 | 146 | /** |
— | — | @@ -146,38 +149,39 @@ |
147 | 150 | public static function usersWatching( $title ) { |
148 | 151 | global $wgMiserMode; |
149 | 152 | $dbr = wfGetDB( DB_SLAVE ); |
150 | | - $count = -1; |
151 | | - if( $wgMiserMode ) { |
| 153 | + $count = - 1; |
| 154 | + if ( $wgMiserMode ) { |
152 | 155 | # Get a rough idea of size |
153 | 156 | $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() ), |
155 | 159 | __METHOD__ ); |
156 | 160 | } |
157 | 161 | # If it is small, just COUNT() it, otherwise, stick with estimate... |
158 | | - if( $count == -1 || $count <= 100 ) { |
| 162 | + if ( $count == - 1 || $count <= 100 ) { |
159 | 163 | global $wgCookieExpiration; |
160 | 164 | # 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(), |
164 | 168 | 'wl_title' => $title->getDBkey(), |
165 | 169 | 'wl_user = user_id', |
166 | 170 | // logged in or out |
167 | | - 'user_touched > '.$dbr->addQuotes( $cutoff ) ), |
| 171 | + 'user_touched > ' . $dbr->addQuotes( $cutoff ) ), |
168 | 172 | __METHOD__, |
169 | | - array( 'USE INDEX' => array('watchlist' => 'namespace_title') ) |
| 173 | + array( 'USE INDEX' => array( 'watchlist' => 'namespace_title' ) ) |
170 | 174 | ); |
171 | | - $count = $dbr->numRows($res); |
| 175 | + $count = $dbr->numRows( $res ); |
172 | 176 | } |
173 | 177 | return $count; |
174 | 178 | } |
175 | 179 | |
176 | 180 | protected static function getLineClass( $hours, $uw ) { |
177 | | - if( $uw == 0 ) |
| 181 | + if ( $uw == 0 ) |
178 | 182 | return 'fr-unreviewed-unwatched'; |
179 | | - else if( $hours > 20*24 ) |
| 183 | + else if ( $hours > 20 * 24 ) |
180 | 184 | return 'fr-pending-long2'; |
181 | | - else if( $hours > 7*24 ) |
| 185 | + else if ( $hours > 7 * 24 ) |
182 | 186 | return 'fr-pending-long'; |
183 | 187 | else |
184 | 188 | return ""; |
— | — | @@ -188,19 +192,19 @@ |
189 | 193 | */ |
190 | 194 | public static function generalQueryOK() { |
191 | 195 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
192 | | - if( !$namespaces || !wfQueriesMustScale() ) { |
| 196 | + if ( !$namespaces || !wfQueriesMustScale() ) { |
193 | 197 | return true; |
194 | 198 | } |
195 | 199 | # Get est. of fraction of pages that are reviewed |
196 | 200 | $dbr = wfGetDB( DB_SLAVE ); |
197 | 201 | $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 ), |
200 | 204 | __METHOD__ |
201 | 205 | ); |
202 | | - $ratio = $pages/($pages - $reviewedpages); |
| 206 | + $ratio = $pages / ( $pages - $reviewedpages ); |
203 | 207 | # If dist. is equal, # of rows scanned = $ratio * LIMIT (or until list runs out) |
204 | | - return ($ratio <= 400); |
| 208 | + return ( $ratio <= 400 ); |
205 | 209 | } |
206 | 210 | } |
207 | 211 | |
— | — | @@ -211,21 +215,23 @@ |
212 | 216 | public $mForm, $mConds; |
213 | 217 | private $live, $namespace, $category, $showredirs; |
214 | 218 | |
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 | + ) { |
216 | 222 | $this->mForm = $form; |
217 | 223 | $this->live = (bool)$live; |
218 | 224 | # 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 ); |
222 | 228 | } |
223 | 229 | $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]; |
226 | 232 | } |
227 | 233 | $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 ); |
230 | 236 | $this->showredirs = (bool)$redirs; |
231 | 237 | parent::__construct(); |
232 | 238 | // Don't get to expensive |
— | — | @@ -238,14 +244,14 @@ |
239 | 245 | } |
240 | 246 | |
241 | 247 | function getQueryInfo() { |
242 | | - if( !$this->live ) { |
| 248 | + if ( !$this->live ) { |
243 | 249 | return $this->getQueryCacheInfo(); |
244 | 250 | } |
245 | 251 | $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' ); |
248 | 254 | # Filter by level |
249 | | - if( $this->level == 1 ) { |
| 255 | + if ( $this->level == 1 ) { |
250 | 256 | $conds[] = "fp_page_id IS NULL OR fp_quality = 0"; |
251 | 257 | } else { |
252 | 258 | $conds[] = 'fp_page_id IS NULL'; |
— | — | @@ -253,11 +259,11 @@ |
254 | 260 | # Reviewable pages only |
255 | 261 | $conds['page_namespace'] = $this->namespace; |
256 | 262 | # No redirects |
257 | | - if( !$this->showredirs ) { |
| 263 | + if ( !$this->showredirs ) { |
258 | 264 | $conds['page_is_redirect'] = 0; |
259 | 265 | } |
260 | 266 | # Filter by category |
261 | | - if( $this->category ) { |
| 267 | + if ( $this->category ) { |
262 | 268 | $tables = array( 'categorylinks', 'page', 'flaggedpages', 'revision' ); |
263 | 269 | $fields[] = 'cl_sortkey'; |
264 | 270 | $conds['cl_to'] = $this->category; |
— | — | @@ -278,20 +284,20 @@ |
279 | 285 | 'conds' => $conds, |
280 | 286 | 'options' => array( 'USE INDEX' => $useIndex, 'GROUP BY' => $groupBy ), |
281 | 287 | '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' ) |
284 | 290 | ) |
285 | 291 | ); |
286 | 292 | } |
287 | 293 | |
288 | 294 | function getQueryCacheInfo() { |
289 | 295 | $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' ); |
292 | 298 | # Re-join on flaggedpages to double-check since things |
293 | 299 | # could have changed since the cache date. Also, use |
294 | 300 | # the proper cache for this level. |
295 | | - if( $this->level == 1 ) { |
| 301 | + if ( $this->level == 1 ) { |
296 | 302 | $conds['qc_type'] = 'fr_unreviewedpages_q'; |
297 | 303 | $conds[] = "fp_page_id IS NULL OR fp_quality < {$this->level}"; |
298 | 304 | } else { |
— | — | @@ -301,31 +307,31 @@ |
302 | 308 | # Reviewable pages only |
303 | 309 | $conds['qc_namespace'] = $this->namespace; |
304 | 310 | # No redirects |
305 | | - if( !$this->showredirs ) { |
| 311 | + if ( !$this->showredirs ) { |
306 | 312 | $conds['page_is_redirect'] = 0; |
307 | 313 | } |
308 | 314 | $this->mIndexField = 'qc_value'; // page_id |
309 | 315 | # Filter by category |
310 | | - if( $this->category ) { |
| 316 | + if ( $this->category ) { |
311 | 317 | $tables = array( 'page', 'categorylinks', 'querycache', 'flaggedpages', 'revision' ); |
312 | 318 | $conds['cl_to'] = $this->category; |
313 | 319 | $conds[] = 'cl_from = qc_value'; // page_id |
314 | 320 | } else { |
315 | 321 | $tables = array( 'page', 'querycache', 'flaggedpages', 'revision' ); |
316 | 322 | } |
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... |
319 | 325 | return array( |
320 | 326 | 'tables' => $tables, |
321 | 327 | 'fields' => $fields, |
322 | 328 | 'conds' => $conds, |
323 | 329 | 'options' => array( 'USE INDEX' => $useIndex, 'GROUP BY' => 'qc_value' ), |
324 | 330 | '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 ) ) |
330 | 336 | ) |
331 | 337 | ); |
332 | 338 | } |
— | — | @@ -338,7 +344,7 @@ |
339 | 345 | wfProfileIn( __METHOD__ ); |
340 | 346 | # Do a link batch query |
341 | 347 | $lb = new LinkBatch(); |
342 | | - while( $row = $this->mResult->fetchObject() ) { |
| 348 | + while ( $row = $this->mResult->fetchObject() ) { |
343 | 349 | $lb->add( $row->page_namespace, $row->page_title ); |
344 | 350 | } |
345 | 351 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/specialpages/UnstablePages_body.php |
— | — | @@ -25,13 +25,13 @@ |
26 | 26 | protected function showForm() { |
27 | 27 | global $wgOut, $wgScript; |
28 | 28 | $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 ) { |
31 | 31 | $form = Xml::openElement( 'form', array( 'name' => 'unstablepages', |
32 | 32 | 'action' => $wgScript, 'method' => 'get' ) ); |
33 | | - $form .= "<fieldset><legend>".wfMsg('unstablepages')."</legend>\n"; |
| 33 | + $form .= "<fieldset><legend>" . wfMsg( 'unstablepages' ) . "</legend>\n"; |
34 | 34 | $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' '; |
35 | | - $form .= " ".Xml::submitButton( wfMsg( 'go' ) ); |
| 35 | + $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
36 | 36 | $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
37 | 37 | $form .= "</fieldset></form>\n"; |
38 | 38 | $wgOut->addHTML( $form ); |
— | — | @@ -43,12 +43,12 @@ |
44 | 44 | # Take this opportunity to purge out expired configurations |
45 | 45 | FlaggedRevs::purgeExpiredConfigurations(); |
46 | 46 | $pager = new unstablepagesPager( $this, array(), $this->namespace ); |
47 | | - if( $pager->getNumRows() ) { |
| 47 | + if ( $pager->getNumRows() ) { |
48 | 48 | $wgOut->addHTML( $pager->getNavigationBar() ); |
49 | 49 | $wgOut->addHTML( $pager->getBody() ); |
50 | 50 | $wgOut->addHTML( $pager->getNavigationBar() ); |
51 | 51 | } else { |
52 | | - $wgOut->addHTML( wfMsgExt('unstablepages-none', array('parse') ) ); |
| 52 | + $wgOut->addHTML( wfMsgExt( 'unstablepages-none', array( 'parse' ) ) ); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
— | — | @@ -59,11 +59,11 @@ |
60 | 60 | $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
61 | 61 | |
62 | 62 | $stitle = SpecialPage::getTitleFor( 'Stabilization' ); |
63 | | - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('unstablepages-config'), |
| 63 | + $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml( 'unstablepages-config' ), |
64 | 64 | 'page=' . $title->getPrefixedUrl() ); |
65 | | - $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('unstablepages-stable'), |
| 65 | + $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'unstablepages-stable' ), |
66 | 66 | 'stable=1' ); |
67 | | - if( $row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry) ) { |
| 67 | + if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) { |
68 | 68 | $expiry_description = " (" . wfMsgForContent( |
69 | 69 | 'protect-expiring', |
70 | 70 | $wgLang->timeanddate( $row->fpc_expiry ), |
— | — | @@ -84,16 +84,16 @@ |
85 | 85 | class UnstablePagesPager extends AlphabeticPager { |
86 | 86 | public $mForm, $mConds, $namespace; |
87 | 87 | |
88 | | - function __construct( $form, $conds = array(), $namespace=0 ) { |
| 88 | + function __construct( $form, $conds = array(), $namespace = 0 ) { |
89 | 89 | $this->mForm = $form; |
90 | 90 | $this->mConds = $conds; |
91 | 91 | # Must be a content page... |
92 | | - if( !is_null($namespace) ) { |
93 | | - $namespace = intval($namespace); |
| 92 | + if ( !is_null( $namespace ) ) { |
| 93 | + $namespace = intval( $namespace ); |
94 | 94 | } |
95 | 95 | $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]; |
98 | 98 | } |
99 | 99 | $this->namespace = $namespace; |
100 | 100 | parent::__construct(); |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $conds['fpc_override'] = 0; |
111 | 111 | $conds['page_namespace'] = $this->namespace; |
112 | 112 | return array( |
113 | | - 'tables' => array('flaggedpage_config','page'), |
| 113 | + 'tables' => array( 'flaggedpage_config', 'page' ), |
114 | 114 | 'fields' => 'page_namespace,page_title,fpc_expiry,fpc_page_id', |
115 | 115 | 'conds' => $conds, |
116 | 116 | 'options' => array() |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | wfProfileIn( __METHOD__ ); |
126 | 126 | # Do a link batch query |
127 | 127 | $lb = new LinkBatch(); |
128 | | - while( $row = $this->mResult->fetchObject() ) { |
| 128 | + while ( $row = $this->mResult->fetchObject() ) { |
129 | 129 | $lb->add( $row->page_namespace, $row->page_title ); |
130 | 130 | } |
131 | 131 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -#(c) Aaron Schulz, Joerg Baach, 2007 GPL |
| 3 | +# (c) Aaron Schulz, Joerg Baach, 2007 GPL |
4 | 4 | |
5 | 5 | if ( !defined( 'MEDIAWIKI' ) ) { |
6 | 6 | echo "FlaggedRevs extension\n"; |
— | — | @@ -34,8 +34,8 @@ |
35 | 35 | global $wgRequest, $wgUser, $wgOut; |
36 | 36 | $confirm = $wgRequest->wasPosted() |
37 | 37 | && $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 ) ) { |
40 | 40 | $wgOut->blockedPage(); |
41 | 41 | return; |
42 | 42 | } |
— | — | @@ -43,15 +43,15 @@ |
44 | 44 | $wgOut->permissionRequired( 'review' ); |
45 | 45 | return; |
46 | 46 | } |
47 | | - if( wfReadOnly() ) { |
| 47 | + if ( wfReadOnly() ) { |
48 | 48 | $wgOut->readOnlyPage(); |
49 | 49 | return; |
50 | 50 | } |
51 | 51 | $this->setHeaders(); |
52 | 52 | # Our target page |
53 | 53 | $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' ); |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | # Param for sites with binary flagging |
— | — | @@ -64,10 +64,10 @@ |
65 | 65 | // implicit dims for binary flag case |
66 | 66 | public function implicitDims() { |
67 | 67 | $tag = FlaggedRevs::binaryTagName(); |
68 | | - if( $tag ) { |
69 | | - if( $this->approve ) { |
| 68 | + if ( $tag ) { |
| 69 | + if ( $this->approve ) { |
70 | 70 | return array( $tag => 1 ); |
71 | | - } else if( $this->unapprove ) { |
| 71 | + } else if ( $this->unapprove ) { |
72 | 72 | return array( $tag => 0 ); |
73 | 73 | } |
74 | 74 | } |
— | — | @@ -78,18 +78,18 @@ |
79 | 79 | private function markReviewed() { |
80 | 80 | global $wgRequest, $wgOut, $wgUser; |
81 | 81 | # 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' ) ) ); |
84 | 84 | return; |
85 | 85 | } |
86 | 86 | # Get revision ID |
87 | 87 | $this->oldid = $wgRequest->getIntOrNull( 'oldid' ); |
88 | | - if( !$this->oldid ) { |
| 88 | + if ( !$this->oldid ) { |
89 | 89 | $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' ); |
90 | 90 | return; |
91 | 91 | } |
92 | 92 | # Check if page is protected |
93 | | - if( !$this->page->quickUserCan( 'edit' ) ) { |
| 93 | + if ( !$this->page->quickUserCan( 'edit' ) ) { |
94 | 94 | $wgOut->permissionRequired( 'badaccess-group0' ); |
95 | 95 | return; |
96 | 96 | } |
— | — | @@ -97,32 +97,32 @@ |
98 | 98 | $this->templateParams = $wgRequest->getVal( 'templateParams' ); |
99 | 99 | $this->imageParams = $wgRequest->getVal( 'imageParams' ); |
100 | 100 | $this->fileVersion = $wgRequest->getVal( 'fileVersion' ); |
101 | | - $this->validatedParams = $wgRequest->getVal( 'validatedParams' ); |
| 101 | + $this->validatedParams = $wgRequest->getVal( 'validatedParams' ); |
102 | 102 | # Special token to discourage fiddling... |
103 | 103 | $k = self::validationKey( $this->templateParams, $this->imageParams, |
104 | 104 | $this->fileVersion, $this->oldid ); |
105 | | - if( $this->validatedParams !== $k ) { |
| 105 | + if ( $this->validatedParams !== $k ) { |
106 | 106 | $wgOut->permissionRequired( 'badaccess-group0' ); |
107 | 107 | return; |
108 | 108 | } |
109 | 109 | # Log comment |
110 | 110 | $this->comment = $wgRequest->getText( 'wpReason' ); |
111 | 111 | # Additional notes (displayed at bottom of page) |
112 | | - $this->retrieveNotes( $wgRequest->getText('wpNotes') ); |
| 112 | + $this->retrieveNotes( $wgRequest->getText( 'wpNotes' ) ); |
113 | 113 | # Get the revision's current flags, if any |
114 | 114 | $this->oflags = FlaggedRevs::getRevisionTags( $this->page, $this->oldid ); |
115 | 115 | # Get our accuracy/quality dimensions |
116 | 116 | $this->dims = array(); |
117 | 117 | $this->unapprovedTags = 0; |
118 | 118 | # Fill in implicit tag data for binary flag case |
119 | | - if( $iDims = $this->implicitDims() ) { |
| 119 | + if ( $iDims = $this->implicitDims() ) { |
120 | 120 | $this->dims = $iDims; |
121 | 121 | } else { |
122 | | - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) { |
| 122 | + foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) { |
123 | 123 | $this->dims[$tag] = $wgRequest->getIntOrNull( "wp$tag" ); |
124 | | - if( $this->dims[$tag] === 0 ) { |
| 124 | + if ( $this->dims[$tag] === 0 ) { |
125 | 125 | $this->unapprovedTags++; |
126 | | - } elseif( is_null($this->dims[$tag]) ) { |
| 126 | + } elseif ( is_null( $this->dims[$tag] ) ) { |
127 | 127 | # This happens if we uncheck a checkbox |
128 | 128 | $this->unapprovedTags++; |
129 | 129 | $this->dims[$tag] = 0; |
— | — | @@ -132,38 +132,38 @@ |
133 | 133 | $fa = FlaggedArticle::getTitleInstance( $this->page ); |
134 | 134 | $this->config = $fa->getVisibilitySettings(); |
135 | 135 | # Check permissions and validate |
136 | | - if( !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) { |
| 136 | + if ( !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) { |
137 | 137 | $wgOut->permissionRequired( 'badaccess-group0' ); |
138 | 138 | return; |
139 | 139 | } |
140 | 140 | # We must at least rate each category as 1, the minimum |
141 | 141 | # 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() ) ) { |
143 | 143 | $wgOut->addWikiText( wfMsg( 'revreview-toolow' ) ); |
144 | 144 | $wgOut->returnToMain( false, $this->page ); |
145 | 145 | 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' ) ); |
148 | 148 | $wgOut->returnToMain( false, $this->page ); |
149 | 149 | return; |
150 | 150 | } |
151 | 151 | # 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(); |
154 | 154 | // Success for either flagging or unflagging |
155 | | - if( $status === true ) { |
156 | | - $wgOut->setPageTitle( wfMsgHtml('actioncomplete') ); |
| 155 | + if ( $status === true ) { |
| 156 | + $wgOut->setPageTitle( wfMsgHtml( 'actioncomplete' ) ); |
157 | 157 | $wgOut->addHTML( $this->showSuccess( $approved, true ) ); |
158 | 158 | // 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' ) ); |
161 | 161 | $wgOut->addHTML( $this->showSyncFailure( $status, true ) ); |
162 | 162 | // Failure for unflagging |
163 | | - } elseif( $status === false && !$approved ) { |
| 163 | + } elseif ( $status === false && !$approved ) { |
164 | 164 | $wgOut->redirect( $this->page->getFullUrl() ); |
165 | 165 | // Any other fail... |
166 | 166 | } else { |
167 | | - $wgOut->setPageTitle( wfMsgHtml('internalerror') ); |
| 167 | + $wgOut->setPageTitle( wfMsgHtml( 'internalerror' ) ); |
168 | 168 | $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' ); |
169 | 169 | $wgOut->returnToMain( false, $this->page ); |
170 | 170 | } |
— | — | @@ -172,14 +172,14 @@ |
173 | 173 | |
174 | 174 | private function retrieveNotes( $notes = '' ) { |
175 | 175 | global $wgUser; |
176 | | - $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ? |
| 176 | + $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) ? |
177 | 177 | $notes : ''; |
178 | 178 | } |
179 | 179 | |
180 | 180 | public static function AjaxReview( /*$args...*/ ) { |
181 | 181 | global $wgUser; |
182 | 182 | $args = func_get_args(); |
183 | | - if( wfReadOnly() ) { |
| 183 | + if ( wfReadOnly() ) { |
184 | 184 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
185 | 185 | } |
186 | 186 | $tags = FlaggedRevs::getDimensions(); |
— | — | @@ -187,23 +187,23 @@ |
188 | 188 | $form = new RevisionReview(); |
189 | 189 | // Each ajax url argument is of the form param|val. |
190 | 190 | // 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 ) { |
194 | 194 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
195 | 195 | } |
196 | | - list($par,$val) = $set; |
| 196 | + list( $par, $val ) = $set; |
197 | 197 | switch( $par ) |
198 | 198 | { |
199 | 199 | case "target": |
200 | 200 | $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 ) ) { |
202 | 202 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
203 | 203 | } |
204 | 204 | break; |
205 | 205 | case "oldid": |
206 | 206 | $form->oldid = intval( $val ); |
207 | | - if( !$form->oldid ) { |
| 207 | + if ( !$form->oldid ) { |
208 | 208 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
209 | 209 | } |
210 | 210 | break; |
— | — | @@ -235,15 +235,15 @@ |
236 | 236 | $form->retrieveNotes( $val ); |
237 | 237 | break; |
238 | 238 | case "wpEditToken": |
239 | | - if( !$wgUser->matchEditToken( $val ) ) { |
| 239 | + if ( !$wgUser->matchEditToken( $val ) ) { |
240 | 240 | return '<err#>' . wfMsgExt( 'sessionfailure', 'parseinline' ); |
241 | 241 | } |
242 | 242 | break; |
243 | 243 | default: |
244 | 244 | $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 ) { |
248 | 248 | $form->unapprovedTags++; |
249 | 249 | } |
250 | 250 | } |
— | — | @@ -251,40 +251,40 @@ |
252 | 252 | } |
253 | 253 | } |
254 | 254 | // No page? |
255 | | - if( !$form->page ) { |
| 255 | + if ( !$form->page ) { |
256 | 256 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
257 | 257 | } |
258 | 258 | // Basic permission check |
259 | 259 | $permErrors = $form->page->getUserPermissionsErrors( 'review', $wgUser ); |
260 | | - if( !$permErrors ) { |
| 260 | + if ( !$permErrors ) { |
261 | 261 | // User must be able to edit this page |
262 | 262 | $permErrors = $form->page->getUserPermissionsErrors( 'edit', $wgUser ); |
263 | 263 | } |
264 | | - if( $permErrors ) { |
| 264 | + if ( $permErrors ) { |
265 | 265 | global $wgOut; |
266 | 266 | return '<err#>' . $wgOut->parse( |
267 | 267 | $wgOut->formatPermissionsErrorMessage( $permErrors, 'review' ) |
268 | 268 | ); |
269 | 269 | } |
270 | 270 | # Fill in implicit tag data for binary flag case |
271 | | - if( $iDims = $form->implicitDims() ) { |
| 271 | + if ( $iDims = $form->implicitDims() ) { |
272 | 272 | $form->dims = $iDims; |
273 | 273 | } |
274 | 274 | // Missing params? |
275 | | - if( count($form->dims) != count($tags) ) { |
| 275 | + if ( count( $form->dims ) != count( $tags ) ) { |
276 | 276 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
277 | 277 | } |
278 | 278 | // Incomplete review? |
279 | | - if( !$form->oldid || is_null($form->page) ) { |
| 279 | + if ( !$form->oldid || is_null( $form->page ) ) { |
280 | 280 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
281 | 281 | } |
282 | | - if( $form->unapprovedTags && $form->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) { |
| 282 | + if ( $form->unapprovedTags && $form->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) { |
283 | 283 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
284 | | - } |
| 284 | + } |
285 | 285 | // Doesn't match up? |
286 | 286 | $k = self::validationKey( $form->templateParams, $form->imageParams, |
287 | 287 | $form->fileVersion, $form->oldid ); |
288 | | - if( $form->validatedParams !== $k ) { |
| 288 | + if ( $form->validatedParams !== $k ) { |
289 | 289 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
290 | 290 | } |
291 | 291 | $fa = FlaggedArticle::getTitleInstance( $form->page ); |
— | — | @@ -292,16 +292,16 @@ |
293 | 293 | # Get the revision's current flags, if any |
294 | 294 | $form->oflags = FlaggedRevs::getRevisionTags( $form->page, $form->oldid ); |
295 | 295 | # Check tag permissions |
296 | | - if( !self::userCanSetFlags($form->dims,$form->oflags,$form->config) ) { |
| 296 | + if ( !self::userCanSetFlags( $form->dims, $form->oflags, $form->config ) ) { |
297 | 297 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
298 | 298 | } |
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 |
302 | 302 | return "<suc#><t#$tier>" . $form->showSuccess( $approved ); |
303 | | - } elseif( $approved && is_array($status) ) { |
| 303 | + } elseif ( $approved && is_array( $status ) ) { |
304 | 304 | return '<err#>' . $form->showSyncFailure( $status ); |
305 | | - } elseif( $approved ) { |
| 305 | + } elseif ( $approved ) { |
306 | 306 | return '<err#>' . wfMsg( 'revreview-revnotfound' ); |
307 | 307 | } else { // hmmm? |
308 | 308 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
— | — | @@ -310,16 +310,16 @@ |
311 | 311 | |
312 | 312 | public function isApproval() { |
313 | 313 | # 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 ) |
316 | 316 | return true; // no tags & approve param given |
317 | | - if( $this->unapprove && !$this->approve ) |
| 317 | + if ( $this->unapprove && !$this->approve ) |
318 | 318 | return false; |
319 | 319 | else |
320 | 320 | return null; // nothing valid asserted |
321 | 321 | } |
322 | | - foreach( $this->dims as $quality => $value ) { |
323 | | - if( $value ) return true; |
| 322 | + foreach ( $this->dims as $quality => $value ) { |
| 323 | + if ( $value ) return true; |
324 | 324 | } |
325 | 325 | return false; |
326 | 326 | } |
— | — | @@ -328,71 +328,71 @@ |
329 | 329 | global $wgUser; |
330 | 330 | # If all values are set to zero, this has been unapproved |
331 | 331 | $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 |
334 | 334 | } |
335 | 335 | # 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 ) ) |
338 | 338 | { |
339 | | - return array($approved,false); |
| 339 | + return array( $approved, false ); |
340 | 340 | } |
341 | 341 | # We can only approve actual revisions... |
342 | | - if( $approved ) { |
| 342 | + if ( $approved ) { |
343 | 343 | $rev = Revision::newFromTitle( $this->page, $this->oldid ); |
344 | 344 | # 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 ); |
347 | 347 | } |
348 | 348 | $status = $this->approveRevision( $rev ); |
349 | 349 | # We can only unapprove approved revisions... |
350 | 350 | } else { |
351 | 351 | $frev = FlaggedRevision::newFromTitle( $this->page, $this->oldid ); |
352 | 352 | # 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 ); |
355 | 355 | } |
356 | 356 | $status = $this->unapproveRevision( $frev ); |
357 | 357 | } |
358 | 358 | # 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() ) { |
361 | 361 | $dbw = wfGetDB( DB_MASTER ); |
362 | 362 | $dbw->begin(); |
363 | 363 | $wgUser->addWatch( $this->page ); |
364 | 364 | $dbw->commit(); |
365 | 365 | } |
366 | 366 | } |
367 | | - return array($approved,$status); |
| 367 | + return array( $approved, $status ); |
368 | 368 | } |
369 | 369 | |
370 | | - private function showSuccess( $approved, $showlinks=false ) { |
| 370 | + private function showSuccess( $approved, $showlinks = false ) { |
371 | 371 | global $wgUser; |
372 | 372 | # Show success message |
373 | 373 | $msg = $approved ? 'revreview-successful' : 'revreview-successful2'; |
374 | | - $form = "<div class='plainlinks'>" .wfMsgExt( $msg, array('parseinline'), |
| 374 | + $form = "<div class='plainlinks'>" . wfMsgExt( $msg, array( 'parseinline' ), |
375 | 375 | $this->page->getPrefixedText(), $this->page->getPrefixedUrl() ); |
376 | 376 | $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 ); |
378 | 378 | $form .= "</div>"; |
379 | 379 | # Handy links to special pages |
380 | | - if( $showlinks && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
| 380 | + if ( $showlinks && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
381 | 381 | $form .= '<p>' . wfMsg( 'returnto', |
382 | | - $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'UnreviewedPages' ) ) ).'</p>'; |
| 382 | + $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'UnreviewedPages' ) ) ) . '</p>'; |
383 | 383 | $form .= '<p>' . wfMsg( 'returnto', |
384 | | - $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'OldReviewedPages' ) ) ).'</p>'; |
| 384 | + $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'OldReviewedPages' ) ) ) . '</p>'; |
385 | 385 | } |
386 | 386 | return $form; |
387 | 387 | } |
388 | 388 | |
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() ); |
391 | 391 | $form .= "<ul>"; |
392 | | - foreach( $status as $n => $text ) { |
| 392 | + foreach ( $status as $n => $text ) { |
393 | 393 | $form .= "<li><i>$text</i></li>\n"; |
394 | 394 | } |
395 | 395 | $form .= "</ul>"; |
396 | | - if( $showlinks ) { |
| 396 | + if ( $showlinks ) { |
397 | 397 | $form .= wfMsg( 'returnto', $this->skin->makeLinkObj( $this->page ) ); |
398 | 398 | } |
399 | 399 | return $form; |
— | — | @@ -410,8 +410,8 @@ |
411 | 411 | $article = new Article( $this->page ); |
412 | 412 | |
413 | 413 | $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; |
416 | 416 | } |
417 | 417 | # Our flags |
418 | 418 | $flags = $this->dims; |
— | — | @@ -420,22 +420,22 @@ |
421 | 421 | $lastImgTime = "0"; |
422 | 422 | # Our template version pointers |
423 | 423 | $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 ) |
427 | 427 | continue; |
428 | 428 | |
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] ) |
431 | 431 | continue; |
432 | 432 | |
433 | | - list($prefixed_text,$rev_id) = $m; |
| 433 | + list( $prefixed_text, $rev_id ) = $m; |
434 | 434 | |
435 | 435 | $tmp_title = Title::newFromText( $prefixed_text ); // Normalize this to be sure... |
436 | | - if( is_null($tmp_title) ) |
| 436 | + if ( is_null( $tmp_title ) ) |
437 | 437 | continue; // Page must be valid! |
438 | 438 | |
439 | | - if( $rev_id > $lastTempId ) |
| 439 | + if ( $rev_id > $lastTempId ) |
440 | 440 | $lastTempId = $rev_id; |
441 | 441 | |
442 | 442 | $tmpset[] = array( |
— | — | @@ -444,29 +444,29 @@ |
445 | 445 | 'ft_title' => $tmp_title->getDBkey(), |
446 | 446 | 'ft_tmp_rev_id' => $rev_id |
447 | 447 | ); |
448 | | - if( !isset($tmpParams[$tmp_title->getNamespace()]) ) { |
| 448 | + if ( !isset( $tmpParams[$tmp_title->getNamespace()] ) ) { |
449 | 449 | $tmpParams[$tmp_title->getNamespace()] = array(); |
450 | 450 | } |
451 | 451 | $tmpParams[$tmp_title->getNamespace()][$tmp_title->getDBkey()] = $rev_id; |
452 | 452 | } |
453 | 453 | # Our image version pointers |
454 | 454 | $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 ) |
458 | 458 | continue; |
459 | | - $m = explode('|',$image,3); |
| 459 | + $m = explode( '|', $image, 3 ); |
460 | 460 | # 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] ) |
462 | 462 | continue; |
463 | 463 | |
464 | | - list($dbkey,$timestamp,$key) = $m; |
| 464 | + list( $dbkey, $timestamp, $key ) = $m; |
465 | 465 | |
466 | 466 | $img_title = Title::makeTitle( NS_IMAGE, $dbkey ); // Normalize |
467 | | - if( is_null($img_title) ) |
| 467 | + if ( is_null( $img_title ) ) |
468 | 468 | continue; // Page must be valid! |
469 | 469 | |
470 | | - if( $timestamp > $lastImgTime ) |
| 470 | + if ( $timestamp > $lastImgTime ) |
471 | 471 | $lastImgTime = $timestamp; |
472 | 472 | |
473 | 473 | $imgset[] = array( |
— | — | @@ -475,16 +475,16 @@ |
476 | 476 | 'fi_img_timestamp' => $timestamp, |
477 | 477 | 'fi_img_sha1' => $key |
478 | 478 | ); |
479 | | - if( !isset($imgParams[$img_title->getDBkey()]) ) { |
| 479 | + if ( !isset( $imgParams[$img_title->getDBkey()] ) ) { |
480 | 480 | $imgParams[$img_title->getDBkey()] = array(); |
481 | 481 | } |
482 | 482 | $imgParams[$img_title->getDBkey()][$timestamp] = $key; |
483 | 483 | } |
484 | 484 | # If this is an image page, store corresponding file info |
485 | 485 | $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 ) { |
489 | 489 | $fileData['name'] = $this->page->getDBkey(); |
490 | 490 | $fileData['timestamp'] = $data[0]; |
491 | 491 | $fileData['sha1'] = $data[1]; |
— | — | @@ -499,7 +499,7 @@ |
500 | 500 | $flaggedOutput = false; |
501 | 501 | $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(), |
502 | 502 | FR_TEXT | FR_MASTER ); |
503 | | - if( $oldfrev ) { |
| 503 | + if ( $oldfrev ) { |
504 | 504 | $flaggedOutput = FlaggedRevs::parseStableText( $article, |
505 | 505 | $oldfrev->getRevText(), $oldfrev->getRevId() ); |
506 | 506 | } |
— | — | @@ -507,8 +507,8 @@ |
508 | 508 | # Be looser on includes for templates, since they don't matter much |
509 | 509 | # and strict checking breaks randomized images/metatemplates...(bug 14580) |
510 | 510 | global $wgUseCurrentTemplates, $wgUseCurrentImages; |
511 | | - $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE |
512 | | - && $wgUseCurrentTemplates && $wgUseCurrentImages); |
| 511 | + $noMatch = ( $rev->getTitle()->getNamespace() == NS_TEMPLATE |
| 512 | + && $wgUseCurrentTemplates && $wgUseCurrentImages ); |
513 | 513 | |
514 | 514 | # Set our versioning params cache |
515 | 515 | FlaggedRevs::setIncludeVersionCache( $rev->getId(), $tmpParams, $imgParams ); |
— | — | @@ -516,8 +516,8 @@ |
517 | 517 | $text = $rev->getText(); |
518 | 518 | $stableOutput = FlaggedRevs::parseStableText( $article, $text, $rev->getId() ); |
519 | 519 | $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 ) |
522 | 522 | || $stableOutput->fr_newestImageTime > $lastImgTime |
523 | 523 | || $stableOutput->fr_newestTemplateID > $lastTempId ) |
524 | 524 | { |
— | — | @@ -529,22 +529,22 @@ |
530 | 530 | FlaggedRevs::clearIncludeVersionCache( $rev->getId() ); |
531 | 531 | |
532 | 532 | # Is this a duplicate review? |
533 | | - if( $oldfrev && $flaggedOutput ) { |
| 533 | + if ( $oldfrev && $flaggedOutput ) { |
534 | 534 | $synced = true; |
535 | | - if( $stableOutput->fr_newestImageTime != $flaggedOutput->fr_newestImageTime ) |
| 535 | + if ( $stableOutput->fr_newestImageTime != $flaggedOutput->fr_newestImageTime ) |
536 | 536 | $synced = false; |
537 | | - elseif( $stableOutput->fr_newestTemplateID != $flaggedOutput->fr_newestTemplateID ) |
| 537 | + elseif ( $stableOutput->fr_newestTemplateID != $flaggedOutput->fr_newestTemplateID ) |
538 | 538 | $synced = false; |
539 | | - elseif( $oldfrev->getTags() != $flags ) |
| 539 | + elseif ( $oldfrev->getTags() != $flags ) |
540 | 540 | $synced = false; |
541 | | - elseif( $oldfrev->getFileSha1() != @$fileData['sha1'] ) |
| 541 | + elseif ( $oldfrev->getFileSha1() != @$fileData['sha1'] ) |
542 | 542 | $synced = false; |
543 | | - elseif( $oldfrev->getComment() != $this->notes ) |
| 543 | + elseif ( $oldfrev->getComment() != $this->notes ) |
544 | 544 | $synced = false; |
545 | | - elseif( $oldfrev->getQuality() != $quality ) |
| 545 | + elseif ( $oldfrev->getQuality() != $quality ) |
546 | 546 | $synced = false; |
547 | 547 | # Don't review if the same |
548 | | - if( $synced ) { |
| 548 | + if ( $synced ) { |
549 | 549 | wfProfileOut( __METHOD__ ); |
550 | 550 | return true; |
551 | 551 | } |
— | — | @@ -579,9 +579,9 @@ |
580 | 580 | # Try using the parser cache first since we didn't actually edit the current version. |
581 | 581 | $parserCache = ParserCache::singleton(); |
582 | 582 | $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 ) ) |
586 | 586 | { |
587 | 587 | $options = FlaggedRevs::makeParserOptions(); |
588 | 588 | $poutput = $wgParser->parse( $article->getContent(), $article->mTitle, $options ); |
— | — | @@ -591,19 +591,19 @@ |
592 | 592 | # If we know that this is now the new stable version |
593 | 593 | # (which it probably is), save it to the stable cache... |
594 | 594 | $sv = FlaggedRevision::newFromStable( $this->page, FR_MASTER/*consistent*/ ); |
595 | | - if( $sv && $sv->getRevId() == $rev->getId() ) { |
| 595 | + if ( $sv && $sv->getRevId() == $rev->getId() ) { |
596 | 596 | global $wgParserCacheExpireTime; |
597 | 597 | $this->page->invalidateCache(); |
598 | 598 | # Update stable cache with the revision we reviewed. |
599 | 599 | # Don't cache redirects; it would go unused and complicate things. |
600 | | - if( !Title::newFromRedirect( $text ) ) { |
| 600 | + if ( !Title::newFromRedirect( $text ) ) { |
601 | 601 | FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput ); |
602 | 602 | } |
603 | 603 | # We can set the sync cache key already |
604 | 604 | $includesSynced = true; |
605 | | - if( $poutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) { |
| 605 | + if ( $poutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) { |
606 | 606 | $includesSynced = false; |
607 | | - } elseif( $poutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
| 607 | + } elseif ( $poutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
608 | 608 | $includesSynced = false; |
609 | 609 | } |
610 | 610 | $u->fr_stableRev = $sv; // no need to re-fetch this! |
— | — | @@ -617,7 +617,7 @@ |
618 | 618 | $stableOutput = FlaggedRevs::getPageCache( $article, $wgUser ); |
619 | 619 | # Clear the cache...(for page histories) |
620 | 620 | $this->page->invalidateCache(); |
621 | | - if( $stableOutput !== false ) { |
| 621 | + if ( $stableOutput !== false ) { |
622 | 622 | # Reset stable cache if it existed, since we know it is the same. |
623 | 623 | FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput ); |
624 | 624 | } |
— | — | @@ -644,7 +644,7 @@ |
645 | 645 | $dbw = wfGetDB( DB_MASTER ); |
646 | 646 | $dbw->begin(); |
647 | 647 | # Delete from flaggedrevs table |
648 | | - $dbw->delete( 'flaggedrevs', |
| 648 | + $dbw->delete( 'flaggedrevs', |
649 | 649 | array( 'fr_page_id' => $frev->getPage(), 'fr_rev_id' => $frev->getRevId() ) ); |
650 | 650 | # Wipe versioning params |
651 | 651 | $dbw->delete( 'flaggedtemplates', array( 'ft_rev_id' => $frev->getRevId() ) ); |
— | — | @@ -665,7 +665,7 @@ |
666 | 666 | # may now be the default page. |
667 | 667 | $parserCache = ParserCache::singleton(); |
668 | 668 | $poutput = $parserCache->get( $article, $wgUser ); |
669 | | - if( $poutput == false ) { |
| 669 | + if ( $poutput == false ) { |
670 | 670 | $text = $article->getContent(); |
671 | 671 | $options = FlaggedRevs::makeParserOptions(); |
672 | 672 | $poutput = $wgParser->parse( $text, $article->mTitle, $options ); |
— | — | @@ -694,12 +694,12 @@ |
695 | 695 | public static function validationKey( $tmpP, $imgP, $imgV, $rid ) { |
696 | 696 | global $wgReviewCodes; |
697 | 697 | # Fall back to $wgSecretKey/$wgProxyKey |
698 | | - if( empty($wgReviewCodes) ) { |
| 698 | + if ( empty( $wgReviewCodes ) ) { |
699 | 699 | global $wgSecretKey, $wgProxyKey; |
700 | 700 | $key = $wgSecretKey ? $wgSecretKey : $wgProxyKey; |
701 | | - $p = md5($key.$imgP.$tmpP.$rid.$imgV); |
| 701 | + $p = md5( $key . $imgP . $tmpP . $rid . $imgV ); |
702 | 702 | } else { |
703 | | - $p = md5($wgReviewCodes[0].$imgP.$rid.$tmpP.$imgV.$wgReviewCodes[1]); |
| 703 | + $p = md5( $wgReviewCodes[0] . $imgP . $rid . $tmpP . $imgV . $wgReviewCodes[1] ); |
704 | 704 | } |
705 | 705 | return $p; |
706 | 706 | } |
— | — | @@ -716,19 +716,19 @@ |
717 | 717 | $restrictions = FlaggedRevs::getTagRestrictions(); |
718 | 718 | # Levels may not apply for some pages. |
719 | 719 | # 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 ) ) { |
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | # No restrictions -> full access |
724 | | - if( !isset($restrictions[$tag]) ) |
| 724 | + if ( !isset( $restrictions[$tag] ) ) |
725 | 725 | return true; |
726 | 726 | # Validators always have full access |
727 | | - if( $wgUser->isAllowed('validate') ) |
| 727 | + if ( $wgUser->isAllowed( 'validate' ) ) |
728 | 728 | return true; |
729 | 729 | # Check if this user has any right that lets him/her set |
730 | 730 | # 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 ) ) { |
733 | 733 | return true; |
734 | 734 | } |
735 | 735 | } |
— | — | @@ -746,18 +746,18 @@ |
747 | 747 | */ |
748 | 748 | public static function userCanSetFlags( $flags, $oldflags = array(), $config = null ) { |
749 | 749 | global $wgUser; |
750 | | - if( !$wgUser->isAllowed('review') ) |
| 750 | + if ( !$wgUser->isAllowed( 'review' ) ) |
751 | 751 | return false; // User is not able to review pages |
752 | 752 | # Check if all of the required site flags have a valid value |
753 | 753 | # 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 ) ) { |
758 | 758 | 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] ) ) { |
760 | 760 | return false; // user cannot change old flag ($config is ignored here) |
761 | | - } elseif( $level < 0 || $level > $highest ) { |
| 761 | + } elseif ( $level < 0 || $level > $highest ) { |
762 | 762 | return false; // flag range is invalid |
763 | 763 | } |
764 | 764 | } |
— | — | @@ -767,20 +767,20 @@ |
768 | 768 | // Check if a given level for a tag is available in $config |
769 | 769 | public static function levelAvailable( $tag, $val, $config ) { |
770 | 770 | global $wgFlagAvailability; |
771 | | - if( $val == 0 ) |
| 771 | + if ( $val == 0 ) |
772 | 772 | return true; // unreviewed is always applicable |
773 | | - if( !array_key_exists('select',$config) ) |
| 773 | + if ( !array_key_exists( 'select', $config ) ) |
774 | 774 | return true; // missing config |
775 | | - if( isset($wgFlagAvailability[$tag]) && isset($wgFlagAvailability[$tag][$val]) ) { |
| 775 | + if ( isset( $wgFlagAvailability[$tag] ) && isset( $wgFlagAvailability[$tag][$val] ) ) { |
776 | 776 | $precedence = $wgFlagAvailability[$tag][$val]; |
777 | 777 | return ( $config['select'] === $precedence ); |
778 | 778 | } |
779 | 779 | return true; |
780 | 780 | } |
781 | 781 | |
782 | | - public static function updateRecentChanges( $title, $revId, $rcId=false, $patrol=true ) { |
| 782 | + public static function updateRecentChanges( $title, $revId, $rcId = false, $patrol = true ) { |
783 | 783 | wfProfileIn( __METHOD__ ); |
784 | | - $revId = intval($revId); |
| 784 | + $revId = intval( $revId ); |
785 | 785 | $dbw = wfGetDB( DB_MASTER ); |
786 | 786 | # Olders edits be marked as patrolled now... |
787 | 787 | $dbw->update( 'recentchanges', |
— | — | @@ -793,7 +793,7 @@ |
794 | 794 | ); |
795 | 795 | # New page patrol may be enabled. If so, the rc_id may be the first |
796 | 796 | # edit and not this one. If it is different, mark it too. |
797 | | - if( $rcId && $rcId != $revId ) { |
| 797 | + if ( $rcId && $rcId != $revId ) { |
798 | 798 | $dbw->update( 'recentchanges', |
799 | 799 | array( 'rc_patrolled' => 1 ), |
800 | 800 | array( 'rc_id' => $rcId, |
Index: trunk/extensions/FlaggedRevs/specialpages/QualityOversight_body.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | global $wgOut, $wgUser, $wgRequest, $wgFlaggedRevsOversightAge; |
16 | 16 | |
17 | 17 | $this->setHeaders(); |
18 | | - $wgOut->addHTML( wfMsgExt('qualityoversight-list', array('parse') ) ); |
| 18 | + $wgOut->addHTML( wfMsgExt( 'qualityoversight-list', array( 'parse' ) ) ); |
19 | 19 | |
20 | 20 | $this->namespace = $wgRequest->getInt( 'namespace' ); |
21 | 21 | $this->level = $wgRequest->getIntOrNull( 'level' ); |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $this->showForm(); |
31 | 31 | |
32 | 32 | $actions = $this->getActions(); |
33 | | - if( empty($actions) ) { |
| 33 | + if ( empty( $actions ) ) { |
34 | 34 | $wgOut->addWikiMsg( 'logempty' ); |
35 | 35 | return; |
36 | 36 | } |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | # Get extra query conds |
40 | 40 | $conds = array( 'log_namespace' => $this->namespace, 'log_action' => $actions ); |
41 | 41 | # Get cutoff time (mainly for performance) |
42 | | - if( !$u ) { |
| 42 | + if ( !$u ) { |
43 | 43 | $cutoff_unixtime = time() - $wgFlaggedRevsOversightAge; |
44 | 44 | $cutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) ); |
45 | 45 | $conds[] = "log_timestamp >= $cutoff"; |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | $pager = new LogPager( $loglist, 'review', $this->user, '', '', $conds ); |
50 | 50 | # Insert list |
51 | 51 | $logBody = $pager->getBody(); |
52 | | - if( $logBody ) { |
| 52 | + if ( $logBody ) { |
53 | 53 | $wgOut->addHTML( |
54 | 54 | $pager->getNavigationBar() . |
55 | 55 | $loglist->beginLogEventsList() . |
— | — | @@ -63,16 +63,19 @@ |
64 | 64 | |
65 | 65 | private function showForm() { |
66 | 66 | 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>' . |
70 | 71 | Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . |
71 | 72 | FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' ' . |
72 | | - ( FlaggedRevs::qualityVersions() ? |
73 | | - FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-all', 1 ) . ' ' |
| 73 | + ( FlaggedRevs::qualityVersions() |
| 74 | + ? FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-all', 1 ) . |
| 75 | + ' ' |
74 | 76 | : "" |
75 | 77 | ) . |
76 | | - Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 20, $this->user ) . '<br />' . |
| 78 | + Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 20, $this->user ) . |
| 79 | + '<br />' . |
77 | 80 | FlaggedRevsXML::getStatusFilterMenu( $this->status ) . ' ' . |
78 | 81 | FlaggedRevsXML::getAutoFilterMenu( $this->automatic ) . ' ' . |
79 | 82 | Xml::submitButton( wfMsg( 'go' ) ) . |
— | — | @@ -85,32 +88,32 @@ |
86 | 89 | * @returns array |
87 | 90 | */ |
88 | 91 | 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 |
92 | 95 | $actions['approve2'] = 0; |
93 | 96 | $actions['approve2-i'] = 0; |
94 | 97 | $actions['unapprove2'] = 0; |
95 | | - } elseif( $this->level === 1 ) { // quality revisions |
| 98 | + } elseif ( $this->level === 1 ) { // quality revisions |
96 | 99 | $actions['approve'] = 0; |
97 | 100 | $actions['approve-a'] = 0; |
98 | 101 | $actions['approve-i'] = 0; |
99 | 102 | $actions['approve-ia'] = 0; |
100 | 103 | $actions['unapprove'] = 0; |
101 | 104 | } |
102 | | - if( $this->status === 1 ) { // approved first time |
| 105 | + if ( $this->status === 1 ) { // approved first time |
103 | 106 | $actions['approve'] = 0; |
104 | 107 | $actions['approve-a'] = 0; |
105 | 108 | $actions['approve2'] = 0; |
106 | 109 | $actions['unapprove'] = 0; |
107 | 110 | $actions['unapprove2'] = 0; |
108 | | - } elseif( $this->status === 2 ) { // re-approved |
| 111 | + } elseif ( $this->status === 2 ) { // re-approved |
109 | 112 | $actions['approve-i'] = 0; |
110 | 113 | $actions['approve-ia'] = 0; |
111 | 114 | $actions['approve2-i'] = 0; |
112 | 115 | $actions['unapprove'] = 0; |
113 | 116 | $actions['unapprove2'] = 0; |
114 | | - } elseif( $this->status === 3 ) { // depreciated |
| 117 | + } elseif ( $this->status === 3 ) { // depreciated |
115 | 118 | $actions['approve'] = 0; |
116 | 119 | $actions['approve-a'] = 0; |
117 | 120 | $actions['approve-i'] = 0; |
— | — | @@ -118,10 +121,10 @@ |
119 | 122 | $actions['approve2'] = 0; |
120 | 123 | $actions['approve2-i'] = 0; |
121 | 124 | } |
122 | | - if( $this->automatic === 0 ) { // manual review |
| 125 | + if ( $this->automatic === 0 ) { // manual review |
123 | 126 | $actions['approve-a'] = 0; |
124 | 127 | $actions['approve-ia'] = 0; |
125 | | - } elseif( $this->automatic === 1 ) { // auto-reviewed |
| 128 | + } elseif ( $this->automatic === 1 ) { // auto-reviewed |
126 | 129 | $actions['approve'] = 0; |
127 | 130 | $actions['approve-i'] = 0; |
128 | 131 | $actions['approve2'] = 0; |
— | — | @@ -130,8 +133,8 @@ |
131 | 134 | $actions['unapprove2'] = 0; |
132 | 135 | } |
133 | 136 | $showActions = array(); |
134 | | - foreach( $actions as $action => $show ) { |
135 | | - if( $show ) |
| 137 | + foreach ( $actions as $action => $show ) { |
| 138 | + if ( $show ) |
136 | 139 | $showActions[] = $action; |
137 | 140 | } |
138 | 141 | return $showActions; |
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php |
— | — | @@ -20,9 +20,9 @@ |
21 | 21 | $this->page = Title::newFromUrl( $this->target ); |
22 | 22 | # Revision ID |
23 | 23 | $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 ); |
25 | 25 | # We need a page... |
26 | | - if( is_null($this->page) ) { |
| 26 | + if ( is_null( $this->page ) ) { |
27 | 27 | $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
28 | 28 | return; |
29 | 29 | } |
— | — | @@ -33,21 +33,21 @@ |
34 | 34 | protected function showStableList() { |
35 | 35 | global $wgOut, $wgUser; |
36 | 36 | # 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' ), |
39 | 39 | $this->page->getPrefixedText() ) ); |
40 | 40 | return; |
41 | 41 | } |
42 | 42 | $pager = new ReviewedVersionsPager( $this, array(), $this->page ); |
43 | 43 | $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' ), |
46 | 46 | $this->page->getPrefixedText(), $num ) ); |
47 | 47 | $wgOut->addHTML( $pager->getNavigationBar() ); |
48 | 48 | $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" ); |
49 | 49 | $wgOut->addHTML( $pager->getNavigationBar() ); |
50 | 50 | } else { |
51 | | - $wgOut->addHTML( wfMsgExt('reviewedversions-none', array('parse'), |
| 51 | + $wgOut->addHTML( wfMsgExt( 'reviewedversions-none', array( 'parse' ), |
52 | 52 | $this->page->getPrefixedText() ) ); |
53 | 53 | } |
54 | 54 | } |
— | — | @@ -64,9 +64,12 @@ |
65 | 65 | ' ' . $this->skin->userToolLinks( $row->fr_user, $row->user_name ), |
66 | 66 | $fdate, $ftime, $row->user_name |
67 | 67 | ); |
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>'; |
71 | 74 | } |
72 | 75 | } |
73 | 76 | |
— | — | @@ -93,18 +96,18 @@ |
94 | 97 | $conds = $this->mConds; |
95 | 98 | # Must be in a reviewable namespace |
96 | 99 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
97 | | - if( !in_array($this->namespace, $namespaces) ) { |
| 100 | + if ( !in_array( $this->namespace, $namespaces ) ) { |
98 | 101 | $conds[] = "1 = 0"; |
99 | 102 | } |
100 | 103 | $conds["fr_page_id"] = $this->pageID; |
101 | 104 | $conds[] = "fr_rev_id = rev_id"; |
102 | 105 | $conds[] = "fr_user = user_id"; |
103 | | - $conds[] = 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'; |
| 106 | + $conds[] = 'rev_deleted & ' . Revision::DELETED_TEXT . ' = 0'; |
104 | 107 | return array( |
105 | | - 'tables' => array('flaggedrevs','revision','user'), |
| 108 | + 'tables' => array( 'flaggedrevs', 'revision', 'user' ), |
106 | 109 | 'fields' => 'fr_rev_id,fr_timestamp,rev_timestamp,fr_quality,fr_user,user_name', |
107 | 110 | 'conds' => $conds, |
108 | | - 'options' => array( 'USE INDEX' => array('flaggedrevs' => 'PRIMARY') ) |
| 111 | + 'options' => array( 'USE INDEX' => array( 'flaggedrevs' => 'PRIMARY' ) ) |
109 | 112 | ); |
110 | 113 | } |
111 | 114 | |
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php |
— | — | @@ -24,16 +24,16 @@ |
25 | 25 | $mdt = $this->getMedianReviewWait(); |
26 | 26 | $pt = $this->getMeanPendingWait(); |
27 | 27 | $timestamp = $this->getLastUpdate(); |
28 | | - if( $timestamp != '-' ) { |
| 28 | + if ( $timestamp != '-' ) { |
29 | 29 | $date = $wgLang->date( $timestamp, true ); |
30 | 30 | $time = $wgLang->time( $timestamp, true ); |
31 | 31 | } |
32 | 32 | |
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 ) ) |
35 | 35 | ); |
36 | 36 | # Most of the output depends on background queries |
37 | | - if( !$this->readyForQuery() ) { |
| 37 | + if ( !$this->readyForQuery() ) { |
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
— | — | @@ -41,13 +41,14 @@ |
42 | 42 | $dbCache = wfGetCache( CACHE_DB ); |
43 | 43 | $data = $dbCache->get( $key ); |
44 | 44 | # Is there a review time table available? |
45 | | - if( is_array($data) && count($data) ) { |
| 45 | + if ( is_array( $data ) && count( $data ) ) { |
46 | 46 | $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>'; |
50 | 50 | } |
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"; |
52 | 53 | $reviewChart .= "<tr align='center'>$headerRows</tr>\n"; |
53 | 54 | $reviewChart .= "<tr align='center'>$dataRows</tr>\n"; |
54 | 55 | $reviewChart .= "</table>\n"; |
— | — | @@ -56,45 +57,51 @@ |
57 | 58 | } |
58 | 59 | |
59 | 60 | # 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 ) |
63 | 64 | ); |
64 | 65 | |
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' ) ) ); |
67 | 69 | $wgOut->addHTML( "<tr>\n" ); |
68 | 70 | // Headings (for a positive grep result): |
69 | 71 | // validationstatistics-ns, validationstatistics-total, validationstatistics-stable, |
70 | 72 | // validationstatistics-latest, validationstatistics-synced, validationstatistics-old |
71 | 73 | $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>' ); |
74 | 77 | } |
75 | 78 | $wgOut->addHTML( "</tr>\n" ); |
76 | 79 | |
77 | 80 | $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 ) ); |
80 | 84 | $NsText = $wgContLang->getFormattedNsText( $row->namespace ); |
81 | | - $NsText = $NsText ? $NsText : wfMsgHTML('blanknamespace'); |
| 85 | + $NsText = $NsText ? $NsText : wfMsgHTML( 'blanknamespace' ); |
82 | 86 | |
83 | 87 | $percRev = intval( $row->total ) == 0 |
84 | 88 | ? '-' // devision by zero |
85 | 89 | : $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 | + ); |
87 | 92 | $percLatest = intval( $row->total ) == 0 |
88 | 93 | ? '-' // devision by zero |
89 | 94 | : $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 | + ); |
91 | 97 | $percSynced = intval( $row->reviewed ) == 0 |
92 | 98 | ? '-' // devision by zero |
93 | 99 | : $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 | + ); |
95 | 102 | $outdated = intval( $row->reviewed ) - intval( $row->synced ); |
96 | 103 | $outdated = $wgLang->formatnum( max( 0, $outdated ) ); // lag between queries |
97 | 104 | |
98 | | - $wgOut->addHTML( |
| 105 | + $wgOut->addHTML( |
99 | 106 | "<tr align='center'> |
100 | 107 | <td>" . |
101 | 108 | htmlspecialchars( $NsText ) . |
— | — | @@ -103,11 +110,11 @@ |
104 | 111 | htmlspecialchars( $wgLang->formatnum( $row->total ) ) . |
105 | 112 | "</td> |
106 | 113 | <td>" . |
107 | | - htmlspecialchars( $wgLang->formatnum( $row->reviewed ) . |
| 114 | + htmlspecialchars( $wgLang->formatnum( $row->reviewed ) . |
108 | 115 | $wgContLang->getDirMark() ) . " <i>($percRev)</i> |
109 | 116 | </td> |
110 | 117 | <td>" . |
111 | | - htmlspecialchars( $wgLang->formatnum( $row->synced ) . |
| 118 | + htmlspecialchars( $wgLang->formatnum( $row->synced ) . |
112 | 119 | $wgContLang->getDirMark() ) . " <i>($percLatest)</i> |
113 | 120 | </td> |
114 | 121 | <td>" . |
— | — | @@ -124,15 +131,15 @@ |
125 | 132 | |
126 | 133 | $data = $this->getTopFiveReviewers(); |
127 | 134 | # Is there a top 5 user list? |
128 | | - if( is_array($data) && count($data) ) { |
| 135 | + if ( is_array( $data ) && count( $data ) ) { |
129 | 136 | $wgOut->addWikiMsg( 'validationstatistics-utable' ); |
130 | 137 | |
131 | 138 | $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>'; |
137 | 144 | } |
138 | 145 | $reviewChart .= "</table>\n"; |
139 | 146 | $wgOut->addHTML( $reviewChart ); |
— | — | @@ -141,7 +148,7 @@ |
142 | 149 | |
143 | 150 | protected function maybeUpdate() { |
144 | 151 | global $wgFlaggedRevsStatsAge; |
145 | | - if( !$wgFlaggedRevsStatsAge ) { |
| 152 | + if ( !$wgFlaggedRevsStatsAge ) { |
146 | 153 | return false; |
147 | 154 | } |
148 | 155 | $dbCache = wfGetCache( CACHE_DB ); |
— | — | @@ -149,14 +156,14 @@ |
150 | 157 | $keySQL = wfMemcKey( 'flaggedrevs', 'statsUpdating' ); |
151 | 158 | // If a cache update is needed, do so asynchronously. |
152 | 159 | // Don't trigger query while another is running. |
153 | | - if( $dbCache->get( $key ) ) { |
| 160 | + if ( $dbCache->get( $key ) ) { |
154 | 161 | wfDebugLog( 'ValidationStatistics', __METHOD__ . " skipping, got data" ); |
155 | | - } elseif( $dbCache->get( $keySQL ) ) { |
| 162 | + } elseif ( $dbCache->get( $keySQL ) ) { |
156 | 163 | wfDebugLog( 'ValidationStatistics', __METHOD__ . " skipping, in progress" ); |
157 | 164 | } else { |
158 | 165 | 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' ); |
161 | 168 | $wiki = wfEscapeShellArg( wfWikiId() ); |
162 | 169 | $devNull = wfIsWindows() ? "NUL:" : "/dev/null"; |
163 | 170 | $commandLine = "$ext $path --wiki=$wiki > $devNull &"; |
— | — | @@ -168,7 +175,7 @@ |
169 | 176 | } |
170 | 177 | |
171 | 178 | protected function readyForQuery() { |
172 | | - if( !$this->db->tableExists( 'flaggedrevs_stats' ) ) { |
| 179 | + if ( !$this->db->tableExists( 'flaggedrevs_stats' ) ) { |
173 | 180 | return false; |
174 | 181 | } else { |
175 | 182 | return ( 0 != $this->db->selectField( 'flaggedrevs_stats', 'COUNT(*)' ) ); |
— | — | @@ -188,51 +195,51 @@ |
189 | 196 | } |
190 | 197 | |
191 | 198 | protected function getMeanReviewWait() { |
192 | | - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
| 199 | + if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
193 | 200 | $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_review_time' ); |
194 | | - return ($val == false ? '-' : $val ); |
| 201 | + return ( $val == false ? '-' : $val ); |
195 | 202 | } |
196 | 203 | |
197 | 204 | protected function getMedianReviewWait() { |
198 | | - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
| 205 | + if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
199 | 206 | $val = $this->db->selectField( 'flaggedrevs_stats2', 'med_review_time' ); |
200 | | - return ($val == false ? '-' : $val ); |
| 207 | + return ( $val == false ? '-' : $val ); |
201 | 208 | } |
202 | 209 | |
203 | 210 | protected function getMeanPendingWait() { |
204 | | - if( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
| 211 | + if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
205 | 212 | $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_pending_time' ); |
206 | | - return ($val == false ? '-' : $val ); |
| 213 | + return ( $val == false ? '-' : $val ); |
207 | 214 | } |
208 | 215 | |
209 | 216 | protected function getLastUpdate() { |
210 | | - if( !$this->db->tableExists( 'querycache_info' ) ) return '-'; |
| 217 | + if ( !$this->db->tableExists( 'querycache_info' ) ) return '-'; |
211 | 218 | $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 ); |
214 | 221 | } |
215 | 222 | |
216 | 223 | protected function getTopFiveReviewers() { |
217 | 224 | $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' ); |
218 | 225 | $dbCache = wfGetCache( CACHE_DB ); |
219 | 226 | $data = $dbCache->get( $key ); |
220 | | - if( is_array($data) ) |
| 227 | + if ( is_array( $data ) ) |
221 | 228 | return $data; // cache hit |
222 | | - |
| 229 | + |
223 | 230 | $dbr = wfGetDB( DB_SLAVE ); |
224 | 231 | $cutoff = $dbr->timestamp( time() - 3600 ); |
225 | 232 | $res = $dbr->select( 'logging', |
226 | | - array('log_user','COUNT(*) AS reviews'), |
| 233 | + array( 'log_user', 'COUNT(*) AS reviews' ), |
227 | 234 | array( |
228 | 235 | '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 |
231 | 238 | ), |
232 | 239 | __METHOD__, |
233 | 240 | array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => 5 ) |
234 | 241 | ); |
235 | 242 | $data = array(); |
236 | | - foreach( $res as $row ) { |
| 243 | + foreach ( $res as $row ) { |
237 | 244 | $data[$row->log_user] = $row->reviews; |
238 | 245 | } |
239 | 246 | // Save/cache users |
Index: trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php |
— | — | @@ -16,15 +16,15 @@ |
17 | 17 | $this->setHeaders(); |
18 | 18 | $this->skin = $wgUser->getSkin(); |
19 | 19 | $this->namespace = $wgRequest->getIntOrNull( 'namespace' ); |
20 | | - $this->level = $wgRequest->getInt( 'level', -1 ); |
| 20 | + $this->level = $wgRequest->getInt( 'level', - 1 ); |
21 | 21 | $this->category = trim( $wgRequest->getVal( 'category' ) ); |
22 | 22 | $catTitle = Title::makeTitleSafe( NS_CATEGORY, $this->category ); |
23 | | - $this->category = is_null($catTitle) ? '' : $catTitle->getText(); |
| 23 | + $this->category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
24 | 24 | $this->size = $wgRequest->getIntOrNull( 'size' ); |
25 | 25 | $this->watched = $wgRequest->getCheck( 'watched' ); |
26 | 26 | $this->stable = $wgRequest->getCheck( 'stable' ); |
27 | 27 | $feedType = $wgRequest->getVal( 'feed' ); |
28 | | - if( $feedType ) { |
| 28 | + if ( $feedType ) { |
29 | 29 | return $this->feed( $feedType ); |
30 | 30 | } |
31 | 31 | $this->setSyndicated(); |
— | — | @@ -52,41 +52,44 @@ |
53 | 53 | // Apply limit if transcluded |
54 | 54 | $pager->mLimit = $limit ? $limit : $pager->mLimit; |
55 | 55 | // Viewing the page normally... |
56 | | - if( !$this->including() ) { |
| 56 | + if ( !$this->including() ) { |
57 | 57 | $action = htmlspecialchars( $wgScript ); |
58 | 58 | $wgOut->addHTML( |
59 | 59 | "<form action=\"$action\" method=\"get\">\n" . |
60 | | - '<fieldset><legend>' . wfMsg('oldreviewedpages-legend') . '</legend>' . |
| 60 | + '<fieldset><legend>' . wfMsg( 'oldreviewedpages-legend' ) . '</legend>' . |
61 | 61 | Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) |
62 | 62 | ); |
63 | 63 | $form = |
64 | | - ( count($namespaces) > 1 ? |
| 64 | + ( count( $namespaces ) > 1 ? |
65 | 65 | "<span style='white-space: nowrap;'>" . |
66 | 66 | FlaggedRevsXML::getNamespaceMenu( $this->namespace, '' ) . '</span> ' |
67 | 67 | : "" |
68 | 68 | ) . |
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> ' |
72 | 73 | : "" |
73 | 74 | ) . |
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> ' |
78 | 80 | : "" |
79 | 81 | ); |
80 | | - if( $form ) $form .= '<br />'; |
| 82 | + if ( $form ) $form .= '<br />'; |
81 | 83 | $form .= |
82 | | - Xml::label( wfMsg("oldreviewed-category"), 'wpCategory' ) . ' ' . |
83 | | - Xml::input( 'category', 30, $this->category, array('id' => 'wpCategory') ) . ' ' . |
| 84 | + Xml::label( wfMsg( "oldreviewed-category" ), 'wpCategory' ) . ' ' . |
| 85 | + Xml::input( 'category', 30, $this->category, |
| 86 | + array( 'id' => 'wpCategory' ) ) . ' ' . |
84 | 87 | ( $wgUser->getId() ? |
85 | 88 | Xml::check( 'watched', $this->watched, array( 'id' => 'wpWatched' ) ) . |
86 | | - Xml::label( wfMsg('oldreviewed-watched'), 'wpWatched' ) . ' ' |
| 89 | + Xml::label( wfMsg( 'oldreviewed-watched' ), 'wpWatched' ) . ' ' |
87 | 90 | : "" |
88 | 91 | ); |
89 | 92 | $form .= '<br />' . |
90 | | - Xml::label( wfMsg('oldreviewed-size'), 'wpSize' ) . |
| 93 | + Xml::label( wfMsg( 'oldreviewed-size' ), 'wpSize' ) . |
91 | 94 | Xml::input( 'size', 4, $this->size, array( 'id' => 'wpSize' ) ) . ' ' . |
92 | 95 | Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
93 | 96 | "</fieldset></form>"; |
— | — | @@ -94,20 +97,20 @@ |
95 | 98 | $wgOut->addHTML( $form ); |
96 | 99 | # Add list output |
97 | 100 | $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 ) { |
100 | 103 | $wgOut->addHTML( $pager->getNavigationBar() ); |
101 | 104 | $wgOut->addHTML( $pager->getBody() ); |
102 | 105 | $wgOut->addHTML( $pager->getNavigationBar() ); |
103 | 106 | } else { |
104 | | - $wgOut->addHTML( wfMsgExt('oldreviewedpages-none', array('parse') ) ); |
| 107 | + $wgOut->addHTML( wfMsgExt( 'oldreviewedpages-none', array( 'parse' ) ) ); |
105 | 108 | } |
106 | 109 | // If this page is transcluded... |
107 | 110 | } else { |
108 | | - if( $pager->getNumRows() ) { |
| 111 | + if ( $pager->getNumRows() ) { |
109 | 112 | $wgOut->addHTML( $pager->getBody() ); |
110 | 113 | } else { |
111 | | - $wgOut->addHTML( wfMsgExt('oldreviewedpages-none', array('parse') ) ); |
| 114 | + $wgOut->addHTML( wfMsgExt( 'oldreviewedpages-none', array( 'parse' ) ) ); |
112 | 115 | } |
113 | 116 | } |
114 | 117 | } |
— | — | @@ -116,19 +119,19 @@ |
117 | 120 | global $wgLang; |
118 | 121 | $bits = preg_split( '/\s*,\s*/', trim( $par ) ); |
119 | 122 | $limit = false; |
120 | | - foreach( $bits as $bit ) { |
121 | | - if( is_numeric( $bit ) ) |
| 123 | + foreach ( $bits as $bit ) { |
| 124 | + if ( is_numeric( $bit ) ) |
122 | 125 | $limit = intval( $bit ); |
123 | 126 | $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 ) ) { |
127 | 130 | $ns = $wgLang->getNsIndex( $m[1] ); |
128 | | - if( $ns !== false ) { |
| 131 | + if ( $ns !== false ) { |
129 | 132 | $this->namespace = $ns; |
130 | 133 | } |
131 | 134 | } |
132 | | - if( preg_match( '/^category=(.+)$/', $bit, $m ) ) { |
| 135 | + if ( preg_match( '/^category=(.+)$/', $bit, $m ) ) { |
133 | 136 | $this->category = $m[1]; |
134 | 137 | } |
135 | 138 | } |
— | — | @@ -141,12 +144,12 @@ |
142 | 145 | */ |
143 | 146 | protected function feed( $type ) { |
144 | 147 | global $wgFeed, $wgFeedClasses, $wgRequest; |
145 | | - if( !$wgFeed ) { |
| 148 | + if ( !$wgFeed ) { |
146 | 149 | global $wgOut; |
147 | 150 | $wgOut->addWikiMsg( 'feed-unavailable' ); |
148 | 151 | return; |
149 | 152 | } |
150 | | - if( !isset( $wgFeedClasses[$type] ) ) { |
| 153 | + if ( !isset( $wgFeedClasses[$type] ) ) { |
151 | 154 | global $wgOut; |
152 | 155 | $wgOut->addWikiMsg( 'feed-invalid' ); |
153 | 156 | return; |
— | — | @@ -162,8 +165,8 @@ |
163 | 166 | $pager->mLimit = min( $wgFeedLimit, $limit ); |
164 | 167 | |
165 | 168 | $feed->outHeader(); |
166 | | - if( $pager->getNumRows() > 0 ) { |
167 | | - while( $row = $pager->mResult->fetchObject() ) { |
| 169 | + if ( $pager->getNumRows() > 0 ) { |
| 170 | + while ( $row = $pager->mResult->fetchObject() ) { |
168 | 171 | $feed->outItem( $this->feedItem( $row ) ); |
169 | 172 | } |
170 | 173 | } |
— | — | @@ -179,7 +182,7 @@ |
180 | 183 | |
181 | 184 | protected function feedItem( $row ) { |
182 | 185 | $title = Title::MakeTitle( $row->page_namespace, $row->page_title ); |
183 | | - if( $title ) { |
| 186 | + if ( $title ) { |
184 | 187 | $date = $row->pending_since; |
185 | 188 | $comments = $title->getTalkPage()->getFullURL(); |
186 | 189 | $curRev = Revision::newFromTitle( $title ); |
— | — | @@ -190,7 +193,7 @@ |
191 | 194 | $title->getFullURL(), |
192 | 195 | $date, |
193 | 196 | $curRev->getUserText(), |
194 | | - $comments); |
| 197 | + $comments ); |
195 | 198 | } else { |
196 | 199 | return null; |
197 | 200 | } |
— | — | @@ -203,40 +206,41 @@ |
204 | 207 | $link = $this->skin->makeKnownLinkObj( $title ); |
205 | 208 | $css = $stxt = $review = $quality = $underReview = ''; |
206 | 209 | $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' ), |
208 | 211 | "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" ); |
209 | 212 | # Show quality level if there are several |
210 | | - if( FlaggedRevs::qualityVersions() ) { |
| 213 | + if ( FlaggedRevs::qualityVersions() ) { |
211 | 214 | $quality = $row->quality ? |
212 | | - wfMsgHtml('revreview-lev-quality') : wfMsgHtml('revreview-lev-sighted'); |
| 215 | + wfMsgHtml( 'revreview-lev-quality' ) : wfMsgHtml( 'revreview-lev-sighted' ); |
213 | 216 | $quality = " <b>[{$quality}]</b>"; |
214 | 217 | } |
215 | 218 | # Is anybody watching? |
216 | | - if( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
| 219 | + if ( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
217 | 220 | $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' ); |
220 | 224 | $watching = " {$watching}"; |
221 | 225 | } else { |
222 | | - $uw = -1; |
| 226 | + $uw = - 1; |
223 | 227 | $watching = ''; // leave out data |
224 | 228 | } |
225 | 229 | # Get how long the first unreviewed edit has been waiting... |
226 | | - if( $row->pending_since ) { |
| 230 | + if ( $row->pending_since ) { |
227 | 231 | static $currentTime; |
228 | 232 | $currentTime = wfTimestamp( TS_UNIX ); // now |
229 | 233 | $firstPendingTime = wfTimestamp( TS_UNIX, $row->pending_since ); |
230 | | - $hours = ($currentTime - $firstPendingTime)/3600; |
| 234 | + $hours = ( $currentTime - $firstPendingTime ) / 3600; |
231 | 235 | // 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 ); |
235 | 239 | // 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 ); |
239 | 243 | } else { |
240 | | - $age = wfMsg('oldreviewedpages-recent'); // hot off the press :) |
| 244 | + $age = wfMsg( 'oldreviewedpages-recent' ); // hot off the press :) |
241 | 245 | } |
242 | 246 | // Oh-noes! |
243 | 247 | $css = self::getLineClass( $hours, $uw ); |
— | — | @@ -246,11 +250,13 @@ |
247 | 251 | } |
248 | 252 | $key = wfMemcKey( 'stableDiffs', 'underReview', $row->stable, $row->page_latest ); |
249 | 253 | # 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>'; |
252 | 257 | } |
253 | 258 | |
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>" ); |
255 | 261 | } |
256 | 262 | |
257 | 263 | /** |
— | — | @@ -272,7 +278,7 @@ |
273 | 279 | } |
274 | 280 | |
275 | 281 | protected static function getLineClass( $hours, $uw ) { |
276 | | - if( $uw == 0 ) |
| 282 | + if ( $uw == 0 ) |
277 | 283 | return 'fr-unreviewed-unwatched'; |
278 | 284 | else |
279 | 285 | return ""; |
— | — | @@ -286,26 +292,26 @@ |
287 | 293 | public $mForm, $mConds; |
288 | 294 | private $category, $namespace; |
289 | 295 | |
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 | + { |
293 | 299 | $this->mForm = $form; |
294 | 300 | # Must be a content page... |
295 | 301 | $vnamespaces = FlaggedRevs::getReviewNamespaces(); |
296 | | - if( is_null($namespace) ) { |
| 302 | + if ( is_null( $namespace ) ) { |
297 | 303 | $namespace = $vnamespaces; |
298 | 304 | } else { |
299 | | - $namespace = intval($namespace); |
| 305 | + $namespace = intval( $namespace ); |
300 | 306 | } |
301 | 307 | # Sanity check |
302 | | - if( !in_array($namespace,$vnamespaces) ) { |
| 308 | + if ( !in_array( $namespace, $vnamespaces ) ) { |
303 | 309 | $namespace = $vnamespaces; |
304 | 310 | } |
305 | 311 | $this->namespace = $namespace; |
306 | 312 | # 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; |
310 | 316 | $this->watched = (bool)$watched; |
311 | 317 | $this->stable = $stable && !FlaggedRevs::isStableShownByDefault() |
312 | 318 | && !FlaggedRevs::forDefaultVersionOnly(); |
— | — | @@ -333,9 +339,9 @@ |
334 | 340 | global $wgUser; |
335 | 341 | $conds = $this->mConds; |
336 | 342 | $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' ); |
338 | 344 | # Show outdated "stable" versions |
339 | | - if( $this->level < 0 ) { |
| 345 | + if ( $this->level < 0 ) { |
340 | 346 | $tables[] = 'flaggedpages'; |
341 | 347 | $fields[] = 'fp_stable AS stable'; |
342 | 348 | $fields[] = 'fp_quality AS quality'; |
— | — | @@ -344,15 +350,15 @@ |
345 | 351 | # Overconstrain rev_page to force PK use |
346 | 352 | $conds[] = 'rev_page = page_id AND rev_id = fp_stable'; |
347 | 353 | $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' ); |
349 | 355 | # Filter by pages configured to be stable |
350 | | - if( $this->stable ) { |
| 356 | + if ( $this->stable ) { |
351 | 357 | $tables[] = 'flaggedpage_config'; |
352 | 358 | $conds[] = 'fp_page_id = fpc_page_id'; |
353 | 359 | $conds['fpc_override'] = 1; |
354 | 360 | } |
355 | 361 | # Filter by category |
356 | | - if( $this->category ) { |
| 362 | + if ( $this->category ) { |
357 | 363 | $tables[] = 'categorylinks'; |
358 | 364 | $conds[] = 'cl_from = fp_page_id'; |
359 | 365 | $conds['cl_to'] = $this->category; |
— | — | @@ -369,17 +375,18 @@ |
370 | 376 | # Overconstrain rev_page to force PK use |
371 | 377 | $conds[] = 'rev_page = page_id AND rev_id = fpp_rev_id'; |
372 | 378 | $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' ); |
374 | 381 | # Filter by review level |
375 | 382 | $conds['fpp_quality'] = $this->level; |
376 | 383 | # Filter by pages configured to be stable |
377 | | - if( $this->stable ) { |
| 384 | + if ( $this->stable ) { |
378 | 385 | $tables[] = 'flaggedpage_config'; |
379 | 386 | $conds[] = 'fpp_page_id = fpc_page_id'; |
380 | 387 | $conds['fpc_override'] = 1; |
381 | 388 | } |
382 | 389 | # Filter by category |
383 | | - if( $this->category != '' ) { |
| 390 | + if ( $this->category != '' ) { |
384 | 391 | $tables[] = 'categorylinks'; |
385 | 392 | $conds[] = 'cl_from = fpp_page_id'; |
386 | 393 | $conds['cl_to'] = $this->category; |
— | — | @@ -389,22 +396,22 @@ |
390 | 397 | } |
391 | 398 | $fields[] = $this->mIndexField; // Pager needs this |
392 | 399 | # Filter namespace |
393 | | - if( $this->namespace !== null ) { |
| 400 | + if ( $this->namespace !== null ) { |
394 | 401 | $conds['page_namespace'] = $this->namespace; |
395 | 402 | } |
396 | 403 | # Filter by watchlist |
397 | | - if( $this->watched && ($uid = $wgUser->getId()) ) { |
| 404 | + if ( $this->watched && ( $uid = $wgUser->getId() ) ) { |
398 | 405 | $tables[] = 'watchlist'; |
399 | 406 | $conds[] = "wl_user = '$uid'"; |
400 | 407 | $conds[] = 'page_namespace = wl_namespace'; |
401 | 408 | $conds[] = 'page_title = wl_title'; |
402 | 409 | } |
403 | 410 | # Filter by bytes changed |
404 | | - if( $this->size !== null && $this->size >= 0 ) { |
| 411 | + if ( $this->size !== null && $this->size >= 0 ) { |
405 | 412 | # Get absolute difference for comparison. ABS(x-y) |
406 | 413 | # 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 ); |
409 | 416 | } |
410 | 417 | return array( |
411 | 418 | 'tables' => $tables, |
— | — | @@ -422,7 +429,7 @@ |
423 | 430 | wfProfileIn( __METHOD__ ); |
424 | 431 | # Do a link batch query |
425 | 432 | $lb = new LinkBatch(); |
426 | | - while( $row = $this->mResult->fetchObject() ) { |
| 433 | + while ( $row = $this->mResult->fetchObject() ) { |
427 | 434 | $lb->add( $row->page_namespace, $row->page_title ); |
428 | 435 | } |
429 | 436 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php |
— | — | @@ -15,13 +15,13 @@ |
16 | 16 | global $wgRequest, $wgUser, $wgOut; |
17 | 17 | $this->setHeaders(); |
18 | 18 | $this->skin = $wgUser->getSkin(); |
19 | | - $this->level = $wgRequest->getInt( 'level', -1 ); |
| 19 | + $this->level = $wgRequest->getInt( 'level', - 1 ); |
20 | 20 | $this->tag = trim( $wgRequest->getVal( 'tagfilter' ) ); |
21 | 21 | $this->category = trim( $wgRequest->getVal( 'category' ) ); |
22 | 22 | $catTitle = Title::newFromText( $this->category ); |
23 | | - $this->category = is_null($catTitle) ? '' : $catTitle->getText(); |
| 23 | + $this->category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
24 | 24 | $feedType = $wgRequest->getVal( 'feed' ); |
25 | | - if( $feedType ) { |
| 25 | + if ( $feedType ) { |
26 | 26 | return $this->feed( $feedType ); |
27 | 27 | } |
28 | 28 | $this->setSyndicated(); |
— | — | @@ -46,45 +46,47 @@ |
47 | 47 | // Apply limit if transcluded |
48 | 48 | $pager->mLimit = $limit ? $limit : $pager->mLimit; |
49 | 49 | // Viewing the page normally... |
50 | | - if( !$this->including() ) { |
| 50 | + if ( !$this->including() ) { |
51 | 51 | $action = htmlspecialchars( $wgScript ); |
52 | 52 | $tagForm = ChangeTags::buildTagFilterSelector( $this->tag ); |
53 | 53 | $wgOut->addHTML( |
54 | 54 | "<form action=\"$action\" method=\"get\">\n" . |
55 | | - '<fieldset><legend>' . wfMsg('problemchanges-legend') . '</legend>' . |
| 55 | + '<fieldset><legend>' . wfMsg( 'problemchanges-legend' ) . '</legend>' . |
56 | 56 | Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) |
57 | 57 | ); |
58 | 58 | $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> ' |
62 | 63 | : "" |
63 | 64 | ); |
64 | | - if( count($tagForm) ) { |
| 65 | + if ( count( $tagForm ) ) { |
65 | 66 | $form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $tagForm[0] ); |
66 | 67 | $form .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $tagForm[1] ); |
67 | 68 | } |
68 | 69 | $form .= '<br />' . |
69 | | - Xml::label( wfMsg("problemchanges-category"), 'wpCategory' ) . ' ' . |
70 | | - Xml::input( 'category', 30, $this->category, array('id' => 'wpCategory') ) . ' '; |
| 70 | + Xml::label( wfMsg( "problemchanges-category" ), 'wpCategory' ) . ' ' . |
| 71 | + Xml::input( 'category', 30, $this->category, |
| 72 | + array( 'id' => 'wpCategory' ) ) . ' '; |
71 | 73 | $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
72 | 74 | "</fieldset></form>"; |
73 | 75 | # Add filter options |
74 | 76 | $wgOut->addHTML( $form ); |
75 | 77 | # Add list output |
76 | | - if( $pager->getNumRows() ) { |
| 78 | + if ( $pager->getNumRows() ) { |
77 | 79 | $wgOut->addHTML( $pager->getNavigationBar() ); |
78 | 80 | $wgOut->addHTML( $pager->getBody() ); |
79 | 81 | $wgOut->addHTML( $pager->getNavigationBar() ); |
80 | 82 | } else { |
81 | | - $wgOut->addHTML( wfMsgExt('problemchanges-none', array('parse') ) ); |
| 83 | + $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) ); |
82 | 84 | } |
83 | 85 | // If this page is transcluded... |
84 | 86 | } else { |
85 | | - if( $pager->getNumRows() ) { |
| 87 | + if ( $pager->getNumRows() ) { |
86 | 88 | $wgOut->addHTML( $pager->getBody() ); |
87 | 89 | } else { |
88 | | - $wgOut->addHTML( wfMsgExt('problemchanges-none', array('parse') ) ); |
| 90 | + $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) ); |
89 | 91 | } |
90 | 92 | } |
91 | 93 | } |
— | — | @@ -93,15 +95,15 @@ |
94 | 96 | global $wgLang; |
95 | 97 | $bits = preg_split( '/\s*,\s*/', trim( $par ) ); |
96 | 98 | $limit = false; |
97 | | - foreach( $bits as $bit ) { |
98 | | - if( is_numeric( $bit ) ) |
| 99 | + foreach ( $bits as $bit ) { |
| 100 | + if ( is_numeric( $bit ) ) |
99 | 101 | $limit = intval( $bit ); |
100 | 102 | $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 ) ) |
104 | 106 | $this->category = $m[1]; |
105 | | - if( preg_match( '/^tagfilter=(.+)$/', $bit, $m ) ) |
| 107 | + if ( preg_match( '/^tagfilter=(.+)$/', $bit, $m ) ) |
106 | 108 | $this->tag = $m[1]; |
107 | 109 | } |
108 | 110 | return $limit; |
— | — | @@ -113,12 +115,12 @@ |
114 | 116 | */ |
115 | 117 | protected function feed( $type ) { |
116 | 118 | global $wgFeed, $wgFeedClasses, $wgRequest; |
117 | | - if( !$wgFeed ) { |
| 119 | + if ( !$wgFeed ) { |
118 | 120 | global $wgOut; |
119 | 121 | $wgOut->addWikiMsg( 'feed-unavailable' ); |
120 | 122 | return; |
121 | 123 | } |
122 | | - if( !isset( $wgFeedClasses[$type] ) ) { |
| 124 | + if ( !isset( $wgFeedClasses[$type] ) ) { |
123 | 125 | global $wgOut; |
124 | 126 | $wgOut->addWikiMsg( 'feed-invalid' ); |
125 | 127 | return; |
— | — | @@ -134,8 +136,8 @@ |
135 | 137 | $pager->mLimit = min( $wgFeedLimit, $limit ); |
136 | 138 | |
137 | 139 | $feed->outHeader(); |
138 | | - if( $pager->getNumRows() > 0 ) { |
139 | | - while( $row = $pager->mResult->fetchObject() ) { |
| 140 | + if ( $pager->getNumRows() > 0 ) { |
| 141 | + while ( $row = $pager->mResult->fetchObject() ) { |
140 | 142 | $feed->outItem( $this->feedItem( $row ) ); |
141 | 143 | } |
142 | 144 | } |
— | — | @@ -151,7 +153,7 @@ |
152 | 154 | |
153 | 155 | protected function feedItem( $row ) { |
154 | 156 | $title = Title::MakeTitle( $row->page_namespace, $row->page_title ); |
155 | | - if( $title ) { |
| 157 | + if ( $title ) { |
156 | 158 | $date = $row->pending_since; |
157 | 159 | $comments = $title->getTalkPage()->getFullURL(); |
158 | 160 | $curRev = Revision::newFromTitle( $title ); |
— | — | @@ -175,41 +177,41 @@ |
176 | 178 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
177 | 179 | $link = $this->skin->makeKnownLinkObj( $title ); |
178 | 180 | $css = $stxt = $review = $quality = $underReview = ''; |
179 | | - $review = $this->skin->makeKnownLinkObj( $title, wfMsg('oldreviewed-diff'), |
| 181 | + $review = $this->skin->makeKnownLinkObj( $title, wfMsg( 'oldreviewed-diff' ), |
180 | 182 | "diff=cur&oldid={$row->stable}&reviewform=1&diffonly=0" ); |
181 | 183 | # Show quality level if there are several |
182 | | - if( FlaggedRevs::qualityVersions() ) { |
| 184 | + if ( FlaggedRevs::qualityVersions() ) { |
183 | 185 | $quality = $row->quality ? |
184 | | - wfMsgHtml('revreview-lev-quality') : wfMsgHtml('revreview-lev-sighted'); |
| 186 | + wfMsgHtml( 'revreview-lev-quality' ) : wfMsgHtml( 'revreview-lev-sighted' ); |
185 | 187 | $quality = " <b>[{$quality}]</b>"; |
186 | 188 | } |
187 | 189 | # Is anybody watching? |
188 | | - if( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
| 190 | + if ( !$this->including() && $wgUser->isAllowed( 'unreviewedpages' ) ) { |
189 | 191 | $uw = UnreviewedPages::usersWatching( $title ); |
190 | 192 | $watching = $uw |
191 | 193 | ? wfMsgExt( 'oldreviewedpages-watched', 'parsemag', $uw ) |
192 | | - : wfMsgHtml('oldreviewedpages-unwatched'); |
| 194 | + : wfMsgHtml( 'oldreviewedpages-unwatched' ); |
193 | 195 | $watching = " {$watching}"; |
194 | 196 | } else { |
195 | | - $uw = -1; |
| 197 | + $uw = - 1; |
196 | 198 | $watching = ''; // leave out data |
197 | 199 | } |
198 | 200 | # Get how long the first unreviewed edit has been waiting... |
199 | | - if( $row->pending_since ) { |
| 201 | + if ( $row->pending_since ) { |
200 | 202 | static $currentTime; |
201 | 203 | $currentTime = wfTimestamp( TS_UNIX ); // now |
202 | 204 | $firstPendingTime = wfTimestamp( TS_UNIX, $row->pending_since ); |
203 | | - $hours = ($currentTime - $firstPendingTime)/3600; |
| 205 | + $hours = ( $currentTime - $firstPendingTime ) / 3600; |
204 | 206 | // 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 ); |
208 | 210 | // 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 ); |
212 | 214 | } else { |
213 | | - $age = wfMsg('oldreviewedpages-recent'); // hot off the press :) |
| 215 | + $age = wfMsg( 'oldreviewedpages-recent' ); // hot off the press :) |
214 | 216 | } |
215 | 217 | // Oh-noes! |
216 | 218 | $css = self::getLineClass( $hours, $uw ); |
— | — | @@ -219,11 +221,13 @@ |
220 | 222 | } |
221 | 223 | $key = wfMemcKey( 'stableDiffs', 'underReview', $row->stable, $row->page_latest ); |
222 | 224 | # 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>'; |
225 | 228 | } |
226 | 229 | |
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>" ); |
228 | 232 | } |
229 | 233 | |
230 | 234 | /** |
— | — | @@ -234,6 +238,7 @@ |
235 | 239 | */ |
236 | 240 | protected function getNextRevisionTimestamp( $revision, $page ) { |
237 | 241 | $dbr = wfGetDB( DB_SLAVE ); |
| 242 | + |
238 | 243 | return $dbr->selectField( 'revision', 'rev_timestamp', |
239 | 244 | array( |
240 | 245 | 'rev_page' => $page, |
— | — | @@ -245,7 +250,7 @@ |
246 | 251 | } |
247 | 252 | |
248 | 253 | protected static function getLineClass( $hours, $uw ) { |
249 | | - if( $uw == 0 ) |
| 254 | + if ( $uw == 0 ) |
250 | 255 | return 'fr-unreviewed-unwatched'; |
251 | 256 | else |
252 | 257 | return ""; |
— | — | @@ -259,15 +264,15 @@ |
260 | 265 | public $mForm, $mConds; |
261 | 266 | private $category, $namespace, $tag; |
262 | 267 | |
263 | | - function __construct( $form, $level=-1, $category='', $tag='' ) |
| 268 | + function __construct( $form, $level = - 1, $category = '', $tag = '' ) |
264 | 269 | { |
265 | 270 | $this->mForm = $form; |
266 | 271 | # Must be a content page... |
267 | 272 | $this->namespace = FlaggedRevs::getReviewNamespaces(); |
268 | 273 | # 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; |
270 | 275 | $this->tag = $tag; |
271 | | - $this->category = $category ? str_replace(' ','_',$category) : null; |
| 276 | + $this->category = $category ? str_replace( ' ', '_', $category ) : null; |
272 | 277 | parent::__construct(); |
273 | 278 | // Don't get to expensive |
274 | 279 | $this->mLimitsShown = array( 20, 50, 100 ); |
— | — | @@ -289,7 +294,7 @@ |
290 | 295 | $fields = array( 'page_namespace' , 'page_title', 'page_latest' ); |
291 | 296 | $ctIndex = $wgOldChangeTagsIndex ? 'ct_rev_id' : 'change_tag_rev_tag'; |
292 | 297 | # Show outdated "stable" pages |
293 | | - if( $this->level < 0 ) { |
| 298 | + if ( $this->level < 0 ) { |
294 | 299 | $fields[] = 'fp_stable AS stable'; |
295 | 300 | $fields[] = 'fp_quality AS quality'; |
296 | 301 | $fields[] = 'fp_pending_since AS pending_since'; |
— | — | @@ -298,19 +303,19 @@ |
299 | 304 | $conds[] = 'rev_page = fp_page_id'; |
300 | 305 | $conds[] = 'rev_id > fp_stable'; |
301 | 306 | $conds[] = 'ct_rev_id = rev_id'; |
302 | | - if( $this->tag != '' ) { |
| 307 | + if ( $this->tag != '' ) { |
303 | 308 | $conds['ct_tag'] = $this->tag; |
304 | 309 | } |
305 | 310 | $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 ); |
307 | 312 | # 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 |
310 | 315 | $conds[] = 'cl_from = fp_page_id'; |
311 | 316 | $conds['cl_to'] = $this->category; |
312 | 317 | $useIndex['categorylinks'] = 'cl_from'; |
313 | 318 | } |
314 | | - array_unshift($tables,'flaggedpages'); // order matters |
| 319 | + array_unshift( $tables, 'flaggedpages' ); // order matters |
315 | 320 | $this->mIndexField = 'fp_pending_since'; |
316 | 321 | $groupBy = 'fp_pending_since,fp_page_id'; |
317 | 322 | # Show outdated pages for a specific review level |
— | — | @@ -325,18 +330,18 @@ |
326 | 331 | $conds[] = 'rev_id > fpp_rev_id'; |
327 | 332 | $conds[] = 'rev_id = ct_rev_id'; |
328 | 333 | $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 ); |
331 | 336 | # Filter by review level |
332 | 337 | $conds['fpp_quality'] = $this->level; |
333 | 338 | # 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 |
336 | 341 | $conds[] = 'cl_from = fpp_page_id'; |
337 | 342 | $conds['cl_to'] = $this->category; |
338 | 343 | $useIndex['categorylinks'] = 'cl_from'; |
339 | 344 | } |
340 | | - array_unshift($tables,'flaggedpage_pending'); // order matters |
| 345 | + array_unshift( $tables, 'flaggedpage_pending' ); // order matters |
341 | 346 | $this->mIndexField = 'fpp_pending_since'; |
342 | 347 | $groupBy = 'fpp_pending_since,fpp_page_id'; |
343 | 348 | } |
— | — | @@ -346,7 +351,8 @@ |
347 | 352 | 'tables' => $tables, |
348 | 353 | 'fields' => $fields, |
349 | 354 | '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' ) |
351 | 357 | ); |
352 | 358 | } |
353 | 359 | |
— | — | @@ -358,7 +364,7 @@ |
359 | 365 | wfProfileIn( __METHOD__ ); |
360 | 366 | # Do a link batch query |
361 | 367 | $lb = new LinkBatch(); |
362 | | - while( $row = $this->mResult->fetchObject() ) { |
| 368 | + while ( $row = $this->mResult->fetchObject() ) { |
363 | 369 | $lb->add( $row->page_namespace, $row->page_title ); |
364 | 370 | } |
365 | 371 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function execute( $par ) { |
15 | | - global $wgRequest, $wgUser, $wgFlaggedRevPristine; |
| 15 | + global $wgRequest, $wgUser; |
16 | 16 | |
17 | 17 | $this->setHeaders(); |
18 | 18 | $this->skin = $wgUser->getSkin(); |
— | — | @@ -19,8 +19,8 @@ |
20 | 20 | # Check if there is a featured level |
21 | 21 | $maxType = FlaggedRevs::pristineVersions() ? 2 : 1; |
22 | 22 | $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 ); |
25 | 25 | $this->hideRedirs = $wgRequest->getBool( 'hideredirs', true ); |
26 | 26 | |
27 | 27 | $this->showForm(); |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | |
34 | 34 | $form = Xml::openElement( 'form', |
35 | 35 | 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"; |
37 | 37 | |
38 | 38 | // show/hide links |
39 | 39 | $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); |
— | — | @@ -44,17 +44,17 @@ |
45 | 45 | |
46 | 46 | $fields = array(); |
47 | 47 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
48 | | - if( count($namespaces) > 1 ) { |
| 48 | + if ( count( $namespaces ) > 1 ) { |
49 | 49 | $fields[] = FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' '; |
50 | 50 | } |
51 | | - if( FlaggedRevs::qualityVersions() ) { |
| 51 | + if ( FlaggedRevs::qualityVersions() ) { |
52 | 52 | $fields[] = FlaggedRevsXML::getLevelMenu( $this->type ) . ' '; |
53 | 53 | } |
54 | | - $form .= implode(' ',$fields) . ' '; |
| 54 | + $form .= implode( ' ', $fields ) . ' '; |
55 | 55 | $form .= $showhideredirs; |
56 | 56 | |
57 | | - if( count($fields) ) { |
58 | | - $form .= " ".Xml::submitButton( wfMsg( 'go' ) ); |
| 57 | + if ( count( $fields ) ) { |
| 58 | + $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
59 | 59 | } |
60 | 60 | $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
61 | 61 | $form .= "</fieldset></form>\n"; |
— | — | @@ -65,15 +65,16 @@ |
66 | 66 | protected function showPageList() { |
67 | 67 | global $wgOut, $wgUser, $wgLang; |
68 | 68 | |
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 ); |
70 | 71 | $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 ) ); |
73 | 74 | $wgOut->addHTML( $pager->getNavigationBar() ); |
74 | 75 | $wgOut->addHTML( $pager->getBody() ); |
75 | 76 | $wgOut->addHTML( $pager->getNavigationBar() ); |
76 | 77 | } else { |
77 | | - $wgOut->addHTML( wfMsgExt('reviewedpages-none', array('parse') ) ); |
| 78 | + $wgOut->addHTML( wfMsgExt( 'reviewedpages-none', array( 'parse' ) ) ); |
78 | 79 | } |
79 | 80 | } |
80 | 81 | |
— | — | @@ -84,18 +85,18 @@ |
85 | 86 | $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
86 | 87 | |
87 | 88 | $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>'; |
91 | 92 | else |
92 | | - $stxt = ' <small>' . wfMsgExt('historysize', array('parsemag'), |
| 93 | + $stxt = ' <small>' . wfMsgExt( 'historysize', array( 'parsemag' ), |
93 | 94 | $wgLang->formatNum( $size ) ) . '</small>'; |
94 | 95 | } |
95 | 96 | |
96 | 97 | $SVtitle = SpecialPage::getTitleFor( 'ReviewedVersions' ); |
97 | | - $list = $this->skin->makeKnownLinkObj( $SVtitle, wfMsgHtml('reviewedpages-all'), |
| 98 | + $list = $this->skin->makeKnownLinkObj( $SVtitle, wfMsgHtml( 'reviewedpages-all' ), |
98 | 99 | 'page=' . $title->getPrefixedUrl() ); |
99 | | - $best = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('reviewedpages-best'), |
| 100 | + $best = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'reviewedpages-best' ), |
100 | 101 | 'stableid=best' ); |
101 | 102 | |
102 | 103 | return "<li>$link $stxt ($list) [$best]</li>"; |
— | — | @@ -108,17 +109,17 @@ |
109 | 110 | class ReviewedPagesPager extends AlphabeticPager { |
110 | 111 | public $mForm, $mConds, $namespace, $type; |
111 | 112 | |
112 | | - function __construct( $form, $conds = array(), $type=0, $namespace=0, $hideRedirs=1 ) { |
| 113 | + function __construct( $form, $conds = array(), $type = 0, $namespace = 0, $hideRedirs = 1 ) { |
113 | 114 | $this->mForm = $form; |
114 | 115 | $this->mConds = $conds; |
115 | 116 | $this->type = $type; |
116 | 117 | # Must be a content page... |
117 | | - if( !is_null($namespace) ) { |
118 | | - $namespace = intval($namespace); |
| 118 | + if ( !is_null( $namespace ) ) { |
| 119 | + $namespace = intval( $namespace ); |
119 | 120 | } |
120 | 121 | $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]; |
123 | 124 | } |
124 | 125 | $this->namespace = $namespace; |
125 | 126 | $this->hideRedirs = $hideRedirs; |
— | — | @@ -134,19 +135,20 @@ |
135 | 136 | $conds = $this->mConds; |
136 | 137 | $conds[] = 'page_id = fp_page_id'; |
137 | 138 | $index = 'PRIMARY'; |
138 | | - if( $this->type >= 0 ) { |
| 139 | + if ( $this->type >= 0 ) { |
139 | 140 | $conds['fp_quality'] = $this->type; |
140 | 141 | $index = 'fp_quality_page'; |
141 | 142 | } |
142 | | - if( $this->hideRedirs ) { |
| 143 | + if ( $this->hideRedirs ) { |
143 | 144 | $conds['page_is_redirect'] = 0; |
144 | 145 | } |
145 | 146 | $conds['page_namespace'] = $this->namespace; // Sanity check NS |
146 | 147 | return array( |
147 | | - 'tables' => array('flaggedpages','page'), |
| 148 | + 'tables' => array( 'flaggedpages', 'page' ), |
148 | 149 | 'fields' => 'page_namespace,page_title,page_len,fp_page_id', |
149 | 150 | 'conds' => $conds, |
150 | | - 'options' => array( 'USE INDEX' => array('flaggedpages' => $index,'page' => 'PRIMARY') ) |
| 151 | + 'options' => array( 'USE INDEX' => array( 'flaggedpages' => $index, |
| 152 | + 'page' => 'PRIMARY' ) ) |
151 | 153 | ); |
152 | 154 | } |
153 | 155 | |
— | — | @@ -158,7 +160,7 @@ |
159 | 161 | wfProfileIn( __METHOD__ ); |
160 | 162 | # Do a link batch query |
161 | 163 | $lb = new LinkBatch(); |
162 | | - while( $row = $this->mResult->fetchObject() ) { |
| 164 | + while ( $row = $this->mResult->fetchObject() ) { |
163 | 165 | $lb->add( $row->page_namespace, $row->page_title ); |
164 | 166 | } |
165 | 167 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/specialpages/StablePages_body.php |
— | — | @@ -25,21 +25,22 @@ |
26 | 26 | |
27 | 27 | protected function showForm() { |
28 | 28 | global $wgOut, $wgScript; |
29 | | - $wgOut->addHTML( wfMsgExt('stablepages-text', array('parseinline') ) ); |
| 29 | + $wgOut->addHTML( wfMsgExt( 'stablepages-text', array( 'parseinline' ) ) ); |
30 | 30 | $fields = array(); |
31 | 31 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
32 | | - if( count($namespaces) > 1 ) { |
| 32 | + if ( count( $namespaces ) > 1 ) { |
33 | 33 | $fields[] = FlaggedRevsXML::getNamespaceMenu( $this->namespace ); |
34 | 34 | } |
35 | | - if( FlaggedRevs::qualityVersions() ) { |
36 | | - $fields[] = Xml::label( wfMsg('stablepages-precedence'), 'wpPrecedence' ) . |
| 35 | + if ( FlaggedRevs::qualityVersions() ) { |
| 36 | + $fields[] = Xml::label( wfMsg( 'stablepages-precedence' ), 'wpPrecedence' ) . |
37 | 37 | ' ' . FlaggedRevsXML::getPrecedenceMenu( $this->precedence ); |
38 | 38 | } |
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(' ',$fields) . ' '; |
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( ' ', $fields ) . ' '; |
| 44 | + $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
44 | 45 | $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
45 | 46 | $form .= "</fieldset>\n"; |
46 | 47 | $form .= Xml::closeElement( 'form' ); |
— | — | @@ -52,12 +53,12 @@ |
53 | 54 | # Take this opportunity to purge out expired configurations |
54 | 55 | FlaggedRevs::purgeExpiredConfigurations(); |
55 | 56 | $pager = new StablePagesPager( $this, array(), $this->namespace, $this->precedence ); |
56 | | - if( $pager->getNumRows() ) { |
| 57 | + if ( $pager->getNumRows() ) { |
57 | 58 | $wgOut->addHTML( $pager->getNavigationBar() ); |
58 | 59 | $wgOut->addHTML( $pager->getBody() ); |
59 | 60 | $wgOut->addHTML( $pager->getNavigationBar() ); |
60 | 61 | } else { |
61 | | - $wgOut->addHTML( wfMsgExt('stablepages-none', array('parse') ) ); |
| 62 | + $wgOut->addHTML( wfMsgExt( 'stablepages-none', array( 'parse' ) ) ); |
62 | 63 | } |
63 | 64 | } |
64 | 65 | |
— | — | @@ -68,29 +69,30 @@ |
69 | 70 | $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
70 | 71 | |
71 | 72 | $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' ), |
74 | 75 | 'action=protect' ); |
75 | 76 | } else { |
76 | | - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('stablepages-config'), |
| 77 | + $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml( 'stablepages-config' ), |
77 | 78 | 'page=' . $title->getPrefixedUrl() ); |
78 | 79 | } |
79 | | - $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('stablepages-stable'), 'stable=1' ); |
| 80 | + $stable = $this->skin->makeKnownLinkObj( $title, |
| 81 | + wfMsgHtml( 'stablepages-stable' ), 'stable=1' ); |
80 | 82 | |
81 | 83 | $type = ''; |
82 | 84 | // 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' ); |
88 | 90 | } else { |
89 | | - $type = wfMsgHtml('stablepages-prec-none'); |
| 91 | + $type = wfMsgHtml( 'stablepages-prec-none' ); |
90 | 92 | } |
91 | 93 | $type = " (<b>{$type}</b>) "; |
92 | 94 | } |
93 | 95 | |
94 | | - if( $row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry) ) { |
| 96 | + if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) { |
95 | 97 | $expiry_description = " (" . wfMsgForContent( |
96 | 98 | 'protect-expiring', |
97 | 99 | $wgLang->timeanddate( $row->fpc_expiry ), |
— | — | @@ -111,16 +113,16 @@ |
112 | 114 | class StablePagesPager extends AlphabeticPager { |
113 | 115 | public $mForm, $mConds, $namespace; |
114 | 116 | |
115 | | - function __construct( $form, $conds = array(), $namespace=0, $precedence=null ) { |
| 117 | + function __construct( $form, $conds = array(), $namespace = 0, $precedence = null ) { |
116 | 118 | $this->mForm = $form; |
117 | 119 | $this->mConds = $conds; |
118 | 120 | # Must be a content page... |
119 | | - if( !is_null($namespace) ) { |
120 | | - $namespace = intval($namespace); |
| 121 | + if ( !is_null( $namespace ) ) { |
| 122 | + $namespace = intval( $namespace ); |
121 | 123 | } |
122 | 124 | $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]; |
125 | 127 | } |
126 | 128 | $this->namespace = $namespace; |
127 | 129 | $this->precedence = $precedence; |
— | — | @@ -135,12 +137,12 @@ |
136 | 138 | $conds = $this->mConds; |
137 | 139 | $conds[] = 'page_id = fpc_page_id'; |
138 | 140 | $conds['fpc_override'] = 1; |
139 | | - if( $this->precedence !== null && $this->precedence >= 0 ) { |
| 141 | + if ( $this->precedence !== null && $this->precedence >= 0 ) { |
140 | 142 | $conds['fpc_select'] = $this->precedence; |
141 | 143 | } |
142 | 144 | $conds['page_namespace'] = $this->namespace; |
143 | 145 | return array( |
144 | | - 'tables' => array('flaggedpage_config','page'), |
| 146 | + 'tables' => array( 'flaggedpage_config', 'page' ), |
145 | 147 | 'fields' => 'page_namespace,page_title,fpc_expiry,fpc_page_id,fpc_select', |
146 | 148 | 'conds' => $conds, |
147 | 149 | 'options' => array() |
— | — | @@ -155,7 +157,7 @@ |
156 | 158 | wfProfileIn( __METHOD__ ); |
157 | 159 | # Do a link batch query |
158 | 160 | $lb = new LinkBatch(); |
159 | | - while( $row = $this->mResult->fetchObject() ) { |
| 161 | + while ( $row = $this->mResult->fetchObject() ) { |
160 | 162 | $lb->add( $row->page_namespace, $row->page_title ); |
161 | 163 | } |
162 | 164 | $lb->execute(); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php |
— | — | @@ -7,35 +7,35 @@ |
8 | 8 | * @param $all Mixed: Value of an item denoting all namespaces, or null to omit |
9 | 9 | * @returns string |
10 | 10 | */ |
11 | | - public static function getNamespaceMenu( $selected=null, $all=null ) { |
| 11 | + public static function getNamespaceMenu( $selected = null, $all = null ) { |
12 | 12 | global $wgContLang; |
13 | 13 | $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 ) ) { |
17 | 17 | # No namespace selected; let exact match work without hitting Main |
18 | 18 | $selected = ''; |
19 | 19 | } else { |
20 | 20 | # Let input be numeric strings without breaking the empty match. |
21 | | - $selected = intval($selected); |
| 21 | + $selected = intval( $selected ); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | $s .= "\n<select id='namespace' name='namespace' class='namespaceselector'>\n"; |
25 | 25 | $arr = $wgContLang->getFormattedNamespaces(); |
26 | | - if( !is_null($all) ) { |
| 26 | + if ( !is_null( $all ) ) { |
27 | 27 | $arr = array( $all => wfMsg( 'namespacesall' ) ) + $arr; // should be first |
28 | 28 | } |
29 | | - foreach( $arr as $index => $name ) { |
| 29 | + foreach ( $arr as $index => $name ) { |
30 | 30 | # Content pages only (except 'all') |
31 | | - if( $index !== $all && !in_array($index, $namespaces) ) { |
| 31 | + if ( $index !== $all && !in_array( $index, $namespaces ) ) { |
32 | 32 | continue; |
33 | 33 | } |
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"; |
38 | 38 | } else { |
39 | | - $s .= "\t" . Xml::element("option", array("value" => $index), $name) . "\n"; |
| 39 | + $s .= "\t" . Xml::element( "option", array( "value" => $index ), $name ) . "\n"; |
40 | 40 | } |
41 | 41 | } |
42 | 42 | $s .= "</select>\n"; |
— | — | @@ -49,18 +49,20 @@ |
50 | 50 | * @param int $max max level? |
51 | 51 | * @returns string |
52 | 52 | */ |
53 | | - public static function getLevelMenu( $selected=null, $all='revreview-filter-all', $max=2 ) { |
54 | | - $s = "<label for='wpLevel'>" . wfMsgHtml('revreview-levelfilter') . "</label> "; |
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> "; |
| 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 ); |
63 | 65 | # Note: Pristine not tracked at sp:QualityOversight (counts as quality) |
64 | | - $s .= Xml::closeElement('select')."\n"; |
| 66 | + $s .= Xml::closeElement( 'select' ) . "\n"; |
65 | 67 | return $s; |
66 | 68 | } |
67 | 69 | |
— | — | @@ -68,18 +70,19 @@ |
69 | 71 | * Get a radio options of available precendents |
70 | 72 | * @param int $selected, selected level |
71 | 73 | * @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' ) ); |
75 | 78 | $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() ) |
78 | 81 | $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() ) |
81 | 84 | $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"; |
84 | 87 | return $s; |
85 | 88 | } |
86 | 89 | |
— | — | @@ -88,14 +91,14 @@ |
89 | 92 | * @param int $selected, selected level |
90 | 93 | * @returns string |
91 | 94 | */ |
92 | | - public static function getStatusFilterMenu( $selected=null ) { |
93 | | - $s = "<label for='wpStatus'>" . wfMsgHtml('revreview-statusfilter') . "</label> "; |
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> "; |
| 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"; |
100 | 103 | return $s; |
101 | 104 | } |
102 | 105 | |
— | — | @@ -104,13 +107,13 @@ |
105 | 108 | * @param int $selected, selected level |
106 | 109 | * @returns string |
107 | 110 | */ |
108 | | - public static function getAutoFilterMenu( $selected=null ) { |
109 | | - $s = "<label for='wpApproved'>" . wfMsgHtml('revreview-typefilter') . "</label> "; |
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> "; |
| 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"; |
115 | 118 | return $s; |
116 | 119 | } |
117 | 120 | |
— | — | @@ -119,7 +122,7 @@ |
120 | 123 | * @returns string, css color for this quality |
121 | 124 | */ |
122 | 125 | public static function getQualityColor( $quality ) { |
123 | | - if( $quality === false ) |
| 126 | + if ( $quality === false ) |
124 | 127 | return 'flaggedrevs-color-0'; |
125 | 128 | switch( $quality ) { |
126 | 129 | case 2: |
— | — | @@ -142,37 +145,37 @@ |
143 | 146 | * @returns string |
144 | 147 | * Generates a review box/tag |
145 | 148 | */ |
146 | | - public static function addTagRatings( $flags, $prettyBox = false, $css='' ) { |
| 149 | + public static function addTagRatings( $flags, $prettyBox = false, $css = '' ) { |
147 | 150 | $tag = ''; |
148 | | - if( $prettyBox ) { |
| 151 | + if ( $prettyBox ) { |
149 | 152 | $tag .= "<table id='mw-fr-revisionratings-box' align='center' class='$css' cellpadding='0'>"; |
150 | 153 | } |
151 | | - foreach( FlaggedRevs::getDimensions() as $quality => $x ) { |
| 154 | + foreach ( FlaggedRevs::getDimensions() as $quality => $x ) { |
152 | 155 | $level = isset( $flags[$quality] ) ? $flags[$quality] : 0; |
153 | | - $encValueText = wfMsgHtml("revreview-$quality-$level"); |
| 156 | + $encValueText = wfMsgHtml( "revreview-$quality-$level" ); |
154 | 157 | $level = $flags[$quality]; |
155 | 158 | $minlevel = FlaggedRevs::getMinQL( $quality ); |
156 | | - if( $level >= $minlevel ) { |
| 159 | + if ( $level >= $minlevel ) { |
157 | 160 | $classmarker = 2; |
158 | | - } elseif( $level > 0 ) { |
| 161 | + } elseif ( $level > 0 ) { |
159 | 162 | $classmarker = 1; |
160 | 163 | } else { |
161 | 164 | $classmarker = 0; |
162 | 165 | } |
163 | 166 | $levelmarker = $level * 20 + 20; |
164 | | - if( $prettyBox ) { |
| 167 | + if ( $prettyBox ) { |
165 | 168 | $tag .= "<tr><td class='fr-text' valign='middle'>" . |
166 | | - wfMsgHtml("revreview-$quality") . |
| 169 | + wfMsgHtml( "revreview-$quality" ) . |
167 | 170 | "</td><td class='fr-value$levelmarker' valign='middle'>" . |
168 | 171 | $encValueText . "</td></tr>\n"; |
169 | 172 | } else { |
170 | 173 | $tag .= " <span class='fr-marker-$levelmarker'><strong>" . |
171 | | - wfMsgHtml("revreview-$quality") . |
| 174 | + wfMsgHtml( "revreview-$quality" ) . |
172 | 175 | "</strong>: <span class='fr-text-value'>$encValueText </span> " . |
173 | 176 | "</span>\n"; |
174 | 177 | } |
175 | 178 | } |
176 | | - if( $prettyBox ) { |
| 179 | + if ( $prettyBox ) { |
177 | 180 | $tag .= '</table>'; |
178 | 181 | } |
179 | 182 | return $tag; |
— | — | @@ -189,7 +192,7 @@ |
190 | 193 | * Generates a review box using a table using FlaggedRevsXML::addTagRatings() |
191 | 194 | */ |
192 | 195 | public static function prettyRatingBox( |
193 | | - $frev, $shtml, $revsSince, $type='oldstable', $synced=false |
| 196 | + $frev, $shtml, $revsSince, $type = 'oldstable', $synced = false |
194 | 197 | ) { |
195 | 198 | global $wgLang; |
196 | 199 | # Get quality level |
— | — | @@ -198,24 +201,24 @@ |
199 | 202 | $pristine = FlaggedRevs::isPristine( $flags ); |
200 | 203 | $time = $wgLang->date( $frev->getTimestamp(), true ); |
201 | 204 | # Some checks for which tag CSS to use |
202 | | - if( $pristine ) { |
| 205 | + if ( $pristine ) { |
203 | 206 | $color = 'flaggedrevs-color-3'; |
204 | | - } elseif( $quality ) { |
| 207 | + } elseif ( $quality ) { |
205 | 208 | $color = 'flaggedrevs-color-2'; |
206 | 209 | } else { |
207 | 210 | $color = 'flaggedrevs-color-1'; |
208 | 211 | } |
209 | 212 | # Construct some tagging |
210 | | - if( $synced && ($type == 'stable' || $type == 'draft') ) { |
| 213 | + if ( $synced && ( $type == 'stable' || $type == 'draft' ) ) { |
211 | 214 | $msg = $quality ? |
212 | 215 | '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' ) { |
215 | 218 | $msg = $quality ? |
216 | 219 | 'revreview-quality-old' : 'revreview-basic-old'; |
217 | | - $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time ); |
| 220 | + $html = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time ); |
218 | 221 | } else { |
219 | | - if( $type == 'stable' ) { |
| 222 | + if ( $type == 'stable' ) { |
220 | 223 | $msg = $quality ? |
221 | 224 | 'revreview-quality' : 'revreview-basic'; |
222 | 225 | } else { // draft |
— | — | @@ -224,8 +227,8 @@ |
225 | 228 | } |
226 | 229 | # For searching: uses messages 'revreview-quality-i', 'revreview-basic-i', |
227 | 230 | # '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 ); |
230 | 233 | } |
231 | 234 | # Make fancy box... |
232 | 235 | $box = "<table style='background: none; border-spacing: 0px;'>"; |
— | — | @@ -233,7 +236,7 @@ |
234 | 237 | $box .= "<td style='text-align:right;'>" . self::ratingToggle() . "</td></tr>\n"; |
235 | 238 | $box .= "<tr><td id='mw-fr-revisionratings'>$html<br />"; |
236 | 239 | # Add any rating tags as needed... |
237 | | - if( $flags && ($type == 'stable' || $type == 'oldstable') ) { |
| 240 | + if ( $flags && ( $type == 'stable' || $type == 'oldstable' ) ) { |
238 | 241 | $box .= self::addTagRatings( $flags, true, $color ); |
239 | 242 | } |
240 | 243 | $box .= "</td><td></td></tr></table>"; |
— | — | @@ -247,7 +250,7 @@ |
248 | 251 | public static function ratingToggle() { |
249 | 252 | return "<a id='mw-fr-revisiontoggle' class='flaggedrevs_toggle' style='display:none;'" . |
250 | 253 | " onclick='FlaggedRevs.toggleRevRatings()' title='" . |
251 | | - wfMsgHtml('revreview-toggle-title') . "' >" . |
| 254 | + wfMsgHtml( 'revreview-toggle-title' ) . "' >" . |
252 | 255 | wfMsg( 'revreview-toggle' ) . "</a>"; |
253 | 256 | } |
254 | 257 | |
— | — | @@ -258,7 +261,7 @@ |
259 | 262 | public static function diffToggle() { |
260 | 263 | return "<a id='mw-fr-difftoggle' class='flaggedrevs_toggle' style='display:none;'" . |
261 | 264 | " onclick='FlaggedRevs.toggleDiff()' title='" . |
262 | | - wfMsgHtml('revreview-diff-toggle-title') . "' >" . |
| 265 | + wfMsgHtml( 'revreview-diff-toggle-title' ) . "' >" . |
263 | 266 | wfMsg( 'revreview-diff-toggle-show' ) . "</a>"; |
264 | 267 | } |
265 | 268 | |
— | — | @@ -273,76 +276,76 @@ |
274 | 277 | public static function ratingInputs( $flags, $config, $disabled, $reviewed ) { |
275 | 278 | $form = ''; |
276 | 279 | # 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 ) { |
279 | 282 | $disabled = true; // a tag is unsettable |
280 | 283 | } |
281 | 284 | $dimensions = FlaggedRevs::getDimensions(); |
282 | | - $tags = array_keys($dimensions); |
| 285 | + $tags = array_keys( $dimensions ); |
283 | 286 | # If there are no tags, make one checkbox to approve/unapprove |
284 | | - if( FlaggedRevs::binaryFlagging() ) { |
| 287 | + if ( FlaggedRevs::binaryFlagging() ) { |
285 | 288 | return ''; |
286 | 289 | } |
287 | 290 | $items = array(); |
288 | 291 | # Build rating form... |
289 | | - if( $disabled ) { |
| 292 | + if ( $disabled ) { |
290 | 293 | // 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; |
293 | 296 | $items[] = "<b>" . FlaggedRevs::getTagMsg( $quality ) . ":</b> " . |
294 | 297 | FlaggedRevs::getTagValueMsg( $quality, $selected ); |
295 | 298 | } |
296 | 299 | } 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 ) { |
299 | 302 | $item = ''; |
300 | 303 | $numLevels = count( $levels ); |
301 | 304 | $minLevel = $minLevels[$quality]; |
302 | 305 | # Determine the level selected by default |
303 | | - if( !empty($flags[$quality]) && isset($levels[$flags[$quality]]) ) { |
| 306 | + if ( !empty( $flags[$quality] ) && isset( $levels[$flags[$quality]] ) ) { |
304 | 307 | $selected = $flags[$quality]; // valid non-zero value |
305 | 308 | } else { |
306 | 309 | $selected = $minLevel; |
307 | 310 | } |
308 | 311 | # Show label as needed |
309 | | - if( !FlaggedRevs::binaryFlagging() ) { |
| 312 | + if ( !FlaggedRevs::binaryFlagging() ) { |
310 | 313 | $item .= "<b>" . Xml::tags( 'label', array( 'for' => "wp$quality" ), |
311 | 314 | FlaggedRevs::getTagMsg( $quality ) ) . ":</b>\n"; |
312 | 315 | } |
313 | 316 | # If the sum of qualities of all flags is above 6, use drop down boxes. |
314 | 317 | # 6 is an arbitrary value choosen according to screen space and usability. |
315 | | - if( $size > 6 ) { |
| 318 | + if ( $size > 6 ) { |
316 | 319 | $attribs = array( 'name' => "wp$quality", 'id' => "wp$quality", |
317 | 320 | 'onchange' => "FlaggedRevs.updateRatingForm()" ); |
318 | 321 | $item .= Xml::openElement( 'select', $attribs ); |
319 | | - foreach( $levels as $i => $name ) { |
| 322 | + foreach ( $levels as $i => $name ) { |
320 | 323 | $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"; |
323 | 326 | } |
324 | | - $item .= Xml::closeElement('select')."\n"; |
| 327 | + $item .= Xml::closeElement( 'select' ) . "\n"; |
325 | 328 | # 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 ) { |
328 | 331 | $attribs = array( 'class' => "fr-rating-option-$i", |
329 | 332 | '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"; |
332 | 335 | } |
333 | 336 | # Otherwise make checkboxes (two levels available for current user) |
334 | | - } else if( $numLevels == 2 ) { |
| 337 | + } else if ( $numLevels == 2 ) { |
335 | 338 | $i = $minLevel; |
336 | 339 | $attribs = array( 'class' => "fr-rating-option-$i", |
337 | 340 | '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"; |
341 | 344 | } |
342 | 345 | $items[] = $item; |
343 | 346 | } |
344 | 347 | } |
345 | 348 | # 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"; |
347 | 350 | $form .= implode( ' ', $items ); |
348 | 351 | $form .= Xml::closeElement( 'span' ) . "\n"; |
349 | 352 | return $form; |
— | — | @@ -352,58 +355,60 @@ |
353 | 356 | $labels = array(); |
354 | 357 | $minLevels = array(); |
355 | 358 | # 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 ) ) |
359 | 362 | { |
360 | | - return array(false,false); // form will have to be disabled |
| 363 | + return array( false, false ); // form will have to be disabled |
361 | 364 | } |
362 | 365 | $labels[$tag] = array(); // applicable tag levels |
363 | 366 | $minLevels[$tag] = false; // first non-zero level number |
364 | | - foreach( $levels as $i => $msg ) { |
| 367 | + foreach ( $levels as $i => $msg ) { |
365 | 368 | # Some levels may be restricted or not applicable... |
366 | | - if( !RevisionReview::userCan($tag,$i,$config) ) { |
| 369 | + if ( !RevisionReview::userCan( $tag, $i, $config ) ) { |
367 | 370 | continue; // skip this level |
368 | | - } else if( $i > 0 && !$minLevels[$tag] ) { |
| 371 | + } else if ( $i > 0 && !$minLevels[$tag] ) { |
369 | 372 | $minLevels[$tag] = $i; // first non-zero level number |
370 | 373 | } |
371 | 374 | $labels[$tag][$i] = $msg; // set label |
372 | 375 | } |
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 |
375 | 378 | } |
376 | 379 | } |
377 | | - return array($labels,$minLevels); |
| 380 | + return array( $labels, $minLevels ); |
378 | 381 | } |
379 | 382 | |
380 | 383 | |
381 | 384 | public static function ratingSubmitButtons( $frev, $disabled ) { |
382 | | - $disAttrib = array('disabled' => 'disabled'); |
| 385 | + $disAttrib = array( 'disabled' => 'disabled' ); |
383 | 386 | # Add the submit button |
384 | | - if( FlaggedRevs::binaryFlagging() ) { |
| 387 | + if ( FlaggedRevs::binaryFlagging() ) { |
385 | 388 | # 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' ), |
387 | 390 | array( |
388 | 391 | 'id' => 'mw-fr-submitreview', |
389 | | - 'accesskey' => wfMsg('revreview-ak-review'), |
| 392 | + 'accesskey' => wfMsg( 'revreview-ak-review' ), |
390 | 393 | 'name' => 'wpApprove', |
391 | | - 'title' => wfMsg('revreview-tt-flag').' ['.wfMsg('revreview-ak-review').']' |
| 394 | + 'title' => wfMsg( 'revreview-tt-flag' ) . ' [' . |
| 395 | + wfMsg( 'revreview-ak-review' ) . ']' |
392 | 396 | ) + ( $disabled ? $disAttrib : array() ) |
393 | 397 | ); |
394 | 398 | $s .= ' '; |
395 | | - $s .= Xml::submitButton( wfMsg('revreview-submit-unreview'), |
| 399 | + $s .= Xml::submitButton( wfMsg( 'revreview-submit-unreview' ), |
396 | 400 | array( |
397 | 401 | 'id' => 'mw-fr-submitunreview', |
398 | 402 | 'name' => 'wpUnapprove', |
399 | | - 'title' => wfMsg('revreview-tt-unflag') |
400 | | - ) + ( ($disabled || !$frev) ? $disAttrib : array() ) |
| 403 | + 'title' => wfMsg( 'revreview-tt-unflag' ) |
| 404 | + ) + ( ( $disabled || !$frev ) ? $disAttrib : array() ) |
401 | 405 | ); |
402 | 406 | } else { |
403 | | - $s = Xml::submitButton( wfMsg('revreview-submit'), |
| 407 | + $s = Xml::submitButton( wfMsg( 'revreview-submit' ), |
404 | 408 | array( |
405 | 409 | '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' ) . ']' |
408 | 413 | ) + ( $disabled ? $disAttrib : array() ) |
409 | 414 | ); |
410 | 415 | } |
— | — | @@ -414,14 +419,14 @@ |
415 | 420 | * @param FlaggedArticle $flaggedArticle |
416 | 421 | * @returns string |
417 | 422 | * Creates CSS lock icon if page is locked/unlocked |
418 | | - */ |
| 423 | + */ |
419 | 424 | 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>"; |
426 | 431 | } |
427 | 432 | } |
428 | 433 | |
— | — | @@ -441,8 +446,8 @@ |
442 | 447 | $msg = $quality |
443 | 448 | ? 'revreview-newest-quality' |
444 | 449 | : '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 ); |
447 | 452 | return $tag; |
448 | 453 | } |
449 | 454 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -6,14 +6,14 @@ |
7 | 7 | */ |
8 | 8 | public static function injectStyleAndJS() { |
9 | 9 | global $wgOut, $wgUser; |
10 | | - if( $wgOut->hasHeadItem( 'FlaggedRevs' ) ) |
| 10 | + if ( $wgOut->hasHeadItem( 'FlaggedRevs' ) ) |
11 | 11 | return true; # Don't double-load |
12 | | - if( !$wgOut->isArticleRelated() ) { |
| 12 | + if ( !$wgOut->isArticleRelated() ) { |
13 | 13 | return self::InjectStyleForSpecial(); // try special page CSS? |
14 | 14 | } |
15 | 15 | $fa = FlaggedArticleView::globalArticleInstance(); |
16 | 16 | # Try to only add to relevant pages |
17 | | - if( !$fa || !$fa->isReviewable(true) ) { |
| 17 | + if ( !$fa || !$fa->isReviewable( true ) ) { |
18 | 18 | return true; |
19 | 19 | } |
20 | 20 | global $wgScriptPath, $wgJsMimeType, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion; |
— | — | @@ -26,17 +26,17 @@ |
27 | 27 | # Add main JS file |
28 | 28 | $head = "<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
29 | 29 | # Add review form JS for reviewers |
30 | | - if( $wgUser->isAllowed('review') ) { |
| 30 | + if ( $wgUser->isAllowed( 'review' ) ) { |
31 | 31 | $encJsFile = htmlspecialchars( "$stylePath/review.js?$wgFlaggedRevStyleVersion" ); |
32 | 32 | $head .= "\n<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
33 | 33 | } |
34 | 34 | # Set basic messages |
35 | 35 | $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' ) |
38 | 38 | ); |
39 | 39 | $head .= "\n<script type=\"{$wgJsMimeType}\">" . |
40 | | - "FlaggedRevs.messages = ".Xml::encodeJsVar($msgs).";</script>\n"; |
| 40 | + "FlaggedRevs.messages = " . Xml::encodeJsVar( $msgs ) . ";</script>\n"; |
41 | 41 | $wgOut->addHeadItem( 'FlaggedRevs', $head ); |
42 | 42 | return true; |
43 | 43 | } |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | global $wgUser; |
47 | 47 | $fa = FlaggedArticleView::globalArticleInstance(); |
48 | 48 | # Try to only add to relevant pages |
49 | | - if( !$fa || !$fa->isReviewable(true) ) { |
| 49 | + if ( !$fa || !$fa->isReviewable( true ) ) { |
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | # Get the review tags on this wiki |
— | — | @@ -55,19 +55,19 @@ |
56 | 56 | $stableId = $frev ? $frev->getRevId() : 0; |
57 | 57 | $globalVars['wgFlaggedRevsParams'] = $rTags; |
58 | 58 | $globalVars['wgStableRevisionId'] = $stableId; |
59 | | - if( $wgUser->isAllowed('review') ) { |
| 59 | + if ( $wgUser->isAllowed( 'review' ) ) { |
60 | 60 | $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' ), |
72 | 72 | ); |
73 | 73 | $globalVars['wgAjaxReview'] = $ajaxReview; // language for AJAX form |
74 | 74 | } |
— | — | @@ -79,13 +79,13 @@ |
80 | 80 | */ |
81 | 81 | public static function InjectStyleForSpecial() { |
82 | 82 | global $wgTitle, $wgOut; |
83 | | - if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) { |
| 83 | + if ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) { |
84 | 84 | return true; |
85 | 85 | } |
86 | 86 | $spPages = array( 'UnreviewedPages', 'OldReviewedPages', 'Watchlist', |
87 | 87 | 'Recentchanges', 'Contributions' ); |
88 | | - foreach( $spPages as $n => $key ) { |
89 | | - if( $wgTitle->isSpecial( $key ) ) { |
| 88 | + foreach ( $spPages as $n => $key ) { |
| 89 | + if ( $wgTitle->isSpecial( $key ) ) { |
90 | 90 | global $wgScriptPath, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion; |
91 | 91 | $stylePath = str_replace( '$wgScriptPath', |
92 | 92 | $wgScriptPath, $wgFlaggedRevsStylePath ); |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | |
102 | 102 | public static function onBeforePageDisplay() { |
103 | 103 | global $wgOut; |
104 | | - if( $wgOut->isArticleRelated() ) { |
| 104 | + if ( $wgOut->isArticleRelated() ) { |
105 | 105 | $view = FlaggedArticleView::singleton(); |
106 | 106 | $view->displayTag(); // show notice bar/icon in subtitle |
107 | 107 | self::injectStyleAndJS(); // full CSS/JS |
— | — | @@ -113,13 +113,16 @@ |
114 | 114 | public static function markUnderReview( $output, $article, $title, $user, $request ) { |
115 | 115 | $action = $request->getVal( 'action', 'view' ); |
116 | 116 | $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 | + { |
118 | 120 | $reviewing = true; |
| 121 | + } |
119 | 122 | # Set a key to note that someone is viewing this |
120 | | - if( $reviewing && $user->isAllowed('review') ) { |
| 123 | + if ( $reviewing && $user->isAllowed( 'review' ) ) { |
121 | 124 | global $wgMemc; |
122 | 125 | $key = wfMemcKey( 'unreviewedPages', 'underReview', $title->getArticleId() ); |
123 | | - $wgMemc->set( $key, '1', 20*60 ); // 20 min |
| 126 | + $wgMemc->set( $key, '1', 20 * 60 ); // 20 min |
124 | 127 | } |
125 | 128 | return true; |
126 | 129 | } |
— | — | @@ -149,7 +152,7 @@ |
150 | 153 | $newPageID = $destTitle->getArticleID(); |
151 | 154 | # Get flagged revisions from old page id that point to destination page |
152 | 155 | $dbw = wfGetDB( DB_MASTER ); |
153 | | - $result = $dbw->select( array('flaggedrevs','revision'), |
| 156 | + $result = $dbw->select( array( 'flaggedrevs', 'revision' ), |
154 | 157 | array( 'fr_rev_id' ), |
155 | 158 | array( 'fr_page_id' => $oldPageID, |
156 | 159 | 'fr_rev_id = rev_id', |
— | — | @@ -157,10 +160,10 @@ |
158 | 161 | __METHOD__ ); |
159 | 162 | # Update these rows |
160 | 163 | $revIDs = array(); |
161 | | - while( $row = $dbw->fetchObject($result) ) { |
| 164 | + while ( $row = $dbw->fetchObject( $result ) ) { |
162 | 165 | $revIDs[] = $row->fr_rev_id; |
163 | 166 | } |
164 | | - if( !empty($revIDs) ) { |
| 167 | + if ( !empty( $revIDs ) ) { |
165 | 168 | $dbw->update( 'flaggedrevs', |
166 | 169 | array( 'fr_page_id' => $newPageID ), |
167 | 170 | array( 'fr_page_id' => $oldPageID, |
— | — | @@ -197,16 +200,16 @@ |
198 | 201 | public static function onTitleMoveComplete( &$otitle, &$ntitle, $user, $pageId ) { |
199 | 202 | $fa = FlaggedArticle::getTitleInstance( $ntitle ); |
200 | 203 | // Re-validate NS/config (new title may not be reviewable) |
201 | | - if( $fa->isReviewable() ) { |
| 204 | + if ( $fa->isReviewable() ) { |
202 | 205 | // 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 ) ) |
205 | 208 | { |
206 | 209 | $rev = Revision::newFromTitle( $ntitle ); |
207 | 210 | // Treat this kind of like a new page... |
208 | 211 | FlaggedRevs::autoReviewEdit( $fa, $user, $rev->getText(), $rev ); |
209 | 212 | return true; // pending list handled |
210 | | - } else if( $fa->getStableRev(FR_MASTER) ) { |
| 213 | + } else if ( $fa->getStableRev( FR_MASTER ) ) { |
211 | 214 | return true; // nothing to do |
212 | 215 | } |
213 | 216 | } |
— | — | @@ -221,33 +224,33 @@ |
222 | 225 | $dbw = wfGetDB( DB_MASTER ); |
223 | 226 | $pageId = $linksUpdate->mTitle->getArticleId(); |
224 | 227 | # Check if this page has a stable version... |
225 | | - if( isset($u->fr_stableRev) ) { |
| 228 | + if ( isset( $u->fr_stableRev ) ) { |
226 | 229 | $sv = $u->fr_stableRev; // Try the process cache... |
227 | 230 | } else { |
228 | 231 | $fa = FlaggedArticle::getTitleInstance( $linksUpdate->mTitle ); |
229 | | - if( $fa->isReviewable() ) { // re-validate NS/config |
| 232 | + if ( $fa->isReviewable() ) { // re-validate NS/config |
230 | 233 | $sv = $fa->getStableRev( FR_MASTER ); |
231 | 234 | } else { |
232 | 235 | $sv = null; |
233 | 236 | } |
234 | 237 | } |
235 | 238 | # Empty flagged revs data for this page if there is no stable version |
236 | | - if( !$sv ) { |
| 239 | + if ( !$sv ) { |
237 | 240 | FlaggedRevs::clearTrackingRows( $pageId ); |
238 | 241 | return true; |
239 | 242 | } |
240 | 243 | # Try the process cache... |
241 | 244 | $article = new Article( $linksUpdate->mTitle ); |
242 | | - if( isset($linksUpdate->fr_stableParserOut) ) { |
| 245 | + if ( isset( $linksUpdate->fr_stableParserOut ) ) { |
243 | 246 | $parserOut = $linksUpdate->fr_stableParserOut; |
244 | 247 | } else { |
245 | 248 | global $wgUser; |
246 | 249 | # Try stable version cache. This should be updated before this is called. |
247 | 250 | $anon = new User; // anon cache most likely to exist |
248 | 251 | $parserOut = FlaggedRevs::getPageCache( $article, $anon ); |
249 | | - if( $parserOut == false && $wgUser->getId() ) |
| 252 | + if ( $parserOut == false && $wgUser->getId() ) |
250 | 253 | $parserOut = FlaggedRevs::getPageCache( $article, $wgUser ); |
251 | | - if( $parserOut == false ) { |
| 254 | + if ( $parserOut == false ) { |
252 | 255 | $text = $sv->getRevText(); |
253 | 256 | # Parse the text |
254 | 257 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $sv->getRevId() ); |
— | — | @@ -258,46 +261,46 @@ |
259 | 262 | # Get the list of categories that must be reviewed |
260 | 263 | $reviewedCats = array(); |
261 | 264 | $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 != '' ) |
267 | 270 | $reviewedCats[$category] = 1; |
268 | 271 | } |
269 | 272 | } |
270 | 273 | $links = array(); |
271 | 274 | # 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] ) ) |
276 | 279 | { |
277 | 280 | self::addLink( $links, $ns, $title ); |
278 | 281 | } |
279 | 282 | } |
280 | 283 | } |
281 | 284 | # 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] ) ) { |
284 | 287 | self::addLink( $links, NS_FILE, $image ); |
285 | 288 | } |
286 | 289 | } |
287 | 290 | # 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] ) ) |
292 | 295 | { |
293 | 296 | self::addLink( $links, $ns, $title ); |
294 | 297 | } |
295 | 298 | } |
296 | 299 | } |
297 | 300 | # 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] ) ) { |
300 | 303 | // Stable categories must remain until removed from the stable version |
301 | | - if( isset($reviewedCats[$category]) ) { |
| 304 | + if ( isset( $reviewedCats[$category] ) ) { |
302 | 305 | $linksUpdate->mCategories[$category] = $sort; |
303 | 306 | } else { |
304 | 307 | self::addLink( $links, NS_CATEGORY, $category ); |
— | — | @@ -305,9 +308,11 @@ |
306 | 309 | } |
307 | 310 | } |
308 | 311 | $stableCats = $parserOut->getCategories(); // from stable version |
309 | | - foreach( $reviewedCats as $category ) { |
| 312 | + foreach ( $reviewedCats as $category ) { |
310 | 313 | // 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 | + { |
312 | 317 | unset( $linksUpdate->mCategories[$category] ); |
313 | 318 | } |
314 | 319 | } |
— | — | @@ -316,20 +321,20 @@ |
317 | 322 | $insertions = self::getLinkInsertions( $existing, $links, $pageId ); |
318 | 323 | $deletions = self::getLinkDeletions( $existing, $links ); |
319 | 324 | # Delete removed links |
320 | | - if( $clause = self::makeWhereFrom2d( $deletions ) ) { |
| 325 | + if ( $clause = self::makeWhereFrom2d( $deletions ) ) { |
321 | 326 | $where = array( 'ftr_from' => $pageId ); |
322 | 327 | $where[] = $clause; |
323 | 328 | $dbw->delete( 'flaggedrevs_tracking', $where, __METHOD__ ); |
324 | 329 | } |
325 | 330 | # Add any new links |
326 | | - if( count($insertions) ) { |
| 331 | + if ( count( $insertions ) ) { |
327 | 332 | $dbw->insert( 'flaggedrevs_tracking', $insertions, __METHOD__, 'IGNORE' ); |
328 | 333 | } |
329 | 334 | return true; |
330 | 335 | } |
331 | 336 | |
332 | 337 | protected static function addLink( &$links, $ns, $dbKey ) { |
333 | | - if( !isset($links[$ns]) ) { |
| 338 | + if ( !isset( $links[$ns] ) ) { |
334 | 339 | $links[$ns] = array(); |
335 | 340 | } |
336 | 341 | $links[$ns][$dbKey] = 1; |
— | — | @@ -337,13 +342,13 @@ |
338 | 343 | |
339 | 344 | protected static function getExistingLinks( $pageId ) { |
340 | 345 | $dbr = wfGetDB( DB_SLAVE ); |
341 | | - $res = $dbr->select( 'flaggedrevs_tracking', |
| 346 | + $res = $dbr->select( 'flaggedrevs_tracking', |
342 | 347 | array( 'ftr_namespace', 'ftr_title' ), |
343 | | - array( 'ftr_from' => $pageId ), |
| 348 | + array( 'ftr_from' => $pageId ), |
344 | 349 | __METHOD__ ); |
345 | 350 | $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] ) ) { |
348 | 353 | $arr[$row->ftr_namespace] = array(); |
349 | 354 | } |
350 | 355 | $arr[$row->ftr_namespace][$row->ftr_title] = 1; |
— | — | @@ -359,10 +364,10 @@ |
360 | 365 | |
361 | 366 | protected static function getLinkInsertions( $existing, $new, $pageId ) { |
362 | 367 | $arr = array(); |
363 | | - foreach( $new as $ns => $dbkeys ) { |
| 368 | + foreach ( $new as $ns => $dbkeys ) { |
364 | 369 | $diffs = isset( $existing[$ns] ) ? |
365 | 370 | array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys; |
366 | | - foreach( $diffs as $dbk => $id ) { |
| 371 | + foreach ( $diffs as $dbk => $id ) { |
367 | 372 | $arr[] = array( |
368 | 373 | 'ftr_from' => $pageId, |
369 | 374 | 'ftr_namespace' => $ns, |
— | — | @@ -375,8 +380,8 @@ |
376 | 381 | |
377 | 382 | protected static function getLinkDeletions( $existing, $new ) { |
378 | 383 | $del = array(); |
379 | | - foreach( $existing as $ns => $dbkeys ) { |
380 | | - if( isset( $new[$ns] ) ) { |
| 384 | + foreach ( $existing as $ns => $dbkeys ) { |
| 385 | + if ( isset( $new[$ns] ) ) { |
381 | 386 | $del[$ns] = array_diff_key( $existing[$ns], $new[$ns] ); |
382 | 387 | } else { |
383 | 388 | $del[$ns] = $existing[$ns]; |
— | — | @@ -411,14 +416,14 @@ |
412 | 417 | */ |
413 | 418 | public static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) { |
414 | 419 | # 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 ) { |
416 | 421 | return true; |
417 | 422 | } |
418 | 423 | $dbr = wfGetDB( DB_SLAVE ); |
419 | 424 | # Check for stable version of template if this feature is enabled. |
420 | 425 | # Should be in reviewable namespace, this saves unneeded DB checks as |
421 | 426 | # well as enforce site settings if they are later changed. |
422 | | - if( FlaggedRevs::isPageReviewable($title) && $title->getArticleId() ) { |
| 427 | + if ( FlaggedRevs::isPageReviewable( $title ) && $title->getArticleId() ) { |
423 | 428 | $id = $dbr->selectField( 'flaggedpages', 'fp_stable', |
424 | 429 | array( 'fp_page_id' => $title->getArticleId() ), |
425 | 430 | __METHOD__ ); |
— | — | @@ -427,13 +432,13 @@ |
428 | 433 | $idP = FlaggedRevs::getTemplateIdFromCache( $parser->getRevisionId(), |
429 | 434 | $title->getNamespace(), $title->getDBkey() ); |
430 | 435 | # 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 ) ) { |
432 | 437 | $id = $idP; |
433 | 438 | } |
434 | 439 | # If there is no stable version (or that feature is not enabled), use |
435 | 440 | # the template revision during review time. If both, use the newest one. |
436 | 441 | $revId = $parser->getRevisionId(); |
437 | | - if( $revId && !FlaggedRevs::useProcessCache( $revId ) ) { |
| 442 | + if ( $revId && !FlaggedRevs::useProcessCache( $revId ) ) { |
438 | 443 | $idP = $dbr->selectField( 'flaggedtemplates', |
439 | 444 | 'ft_tmp_rev_id', |
440 | 445 | array( 'ft_rev_id' => $revId, |
— | — | @@ -442,22 +447,22 @@ |
443 | 448 | __METHOD__ |
444 | 449 | ); |
445 | 450 | # 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; |
447 | 452 | } |
448 | 453 | # If none specified, see if we are allowed to use the current revision |
449 | | - if( !$id ) { |
| 454 | + if ( !$id ) { |
450 | 455 | global $wgUseCurrentTemplates; |
451 | | - if( $id === false ) { |
| 456 | + if ( $id === false ) { |
452 | 457 | // May want to give an error |
453 | 458 | $parser->mOutput->fr_includeErrors[] = $title->getPrefixedDBKey(); |
454 | | - if( !$wgUseCurrentTemplates ) { |
| 459 | + if ( !$wgUseCurrentTemplates ) { |
455 | 460 | $skip = true; |
456 | 461 | } |
457 | 462 | } else { |
458 | 463 | $skip = true; // If ID is zero, don't load it |
459 | 464 | } |
460 | 465 | } |
461 | | - if( $id > $parser->mOutput->fr_newestTemplateID ) { |
| 466 | + if ( $id > $parser->mOutput->fr_newestTemplateID ) { |
462 | 467 | $parser->mOutput->fr_newestTemplateID = $id; |
463 | 468 | } |
464 | 469 | return true; |
— | — | @@ -467,16 +472,16 @@ |
468 | 473 | * Select the desired images based on the selected stable revision times/SHA-1s |
469 | 474 | */ |
470 | 475 | public static function parserMakeStableFileLink( |
471 | | - $parser, $nt, &$skip, &$time, &$query=false |
| 476 | + $parser, $nt, &$skip, &$time, &$query = false |
472 | 477 | ) { |
473 | 478 | # Trigger for stable version parsing only |
474 | | - if( empty($parser->fr_isStable) ) { |
| 479 | + if ( empty( $parser->fr_isStable ) ) { |
475 | 480 | return true; |
476 | 481 | } |
477 | 482 | $file = null; |
478 | 483 | $isKnownLocal = $isLocalFile = false; // local file on this wiki? |
479 | 484 | # Normalize NS_MEDIA to NS_FILE |
480 | | - if( $nt->getNamespace() == NS_MEDIA ) { |
| 485 | + if ( $nt->getNamespace() == NS_MEDIA ) { |
481 | 486 | $title = Title::makeTitle( NS_FILE, $nt->getDBkey() ); |
482 | 487 | $title->resetArticleId( $nt->getArticleId() ); // avoid extra queries |
483 | 488 | } else { |
— | — | @@ -486,9 +491,9 @@ |
487 | 492 | # Should be in reviewable namespace, this saves unneeded DB checks as |
488 | 493 | # well as enforce site settings if they are later changed. |
489 | 494 | $sha1 = ''; |
490 | | - if( FlaggedRevs::isPageReviewable( $title ) ) { |
| 495 | + if ( FlaggedRevs::isPageReviewable( $title ) ) { |
491 | 496 | $srev = FlaggedRevision::newFromStable( $title ); |
492 | | - if( $srev && $srev->getFileTimestamp() ) { |
| 497 | + if ( $srev && $srev->getFileTimestamp() ) { |
493 | 498 | $time = $srev->getFileTimestamp(); // TS or null |
494 | 499 | $sha1 = $srev->getFileSha1(); |
495 | 500 | $isKnownLocal = true; // must be local |
— | — | @@ -497,10 +502,10 @@ |
498 | 503 | # Check cache before doing another DB hit... |
499 | 504 | $params = FlaggedRevs::getFileVersionFromCache( |
500 | 505 | $parser->getRevisionId(), $title->getDBkey() ); |
501 | | - if( is_array($params) ) { |
502 | | - list($timeP,$sha1P) = $params; |
| 506 | + if ( is_array( $params ) ) { |
| 507 | + list( $timeP, $sha1P ) = $params; |
503 | 508 | // Take the newest one... |
504 | | - if( !$time || $timeP > $time ) { |
| 509 | + if ( !$time || $timeP > $time ) { |
505 | 510 | $time = $timeP; |
506 | 511 | $sha1 = $sha1P; |
507 | 512 | $isKnownLocal = false; // up in the air...possibly a commons image |
— | — | @@ -509,29 +514,29 @@ |
510 | 515 | # If there is no stable version (or that feature is not enabled), use |
511 | 516 | # the image revision during review time. If both, use the newest one. |
512 | 517 | $revId = $parser->getRevisionId(); |
513 | | - if( $revId && !FlaggedRevs::useProcessCache( $revId ) ) { |
| 518 | + if ( $revId && !FlaggedRevs::useProcessCache( $revId ) ) { |
514 | 519 | $dbr = wfGetDB( DB_SLAVE ); |
515 | | - $row = $dbr->selectRow( 'flaggedimages', |
| 520 | + $row = $dbr->selectRow( 'flaggedimages', |
516 | 521 | array( 'fi_img_timestamp', 'fi_img_sha1' ), |
517 | 522 | array( 'fi_rev_id' => $parser->getRevisionId(), 'fi_name' => $title->getDBkey() ), |
518 | 523 | __METHOD__ |
519 | 524 | ); |
520 | 525 | # 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 ) ) { |
522 | 527 | $time = $row->fi_img_timestamp; |
523 | 528 | $sha1 = $row->fi_img_sha1; |
524 | 529 | $isKnownLocal = false; // up in the air...possibly a commons image |
525 | 530 | } |
526 | 531 | } |
527 | | - $query = $time ? "filetimestamp=" . urlencode( wfTimestamp(TS_MW,$time) ) : ""; |
| 532 | + $query = $time ? "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ) : ""; |
528 | 533 | # If none specified, see if we are allowed to use the current revision |
529 | | - if( !$time ) { |
| 534 | + if ( !$time ) { |
530 | 535 | global $wgUseCurrentImages; |
531 | 536 | # If the DB found nothing... |
532 | | - if( $time === false ) { |
| 537 | + if ( $time === false ) { |
533 | 538 | # May want to give an error, so track these... |
534 | 539 | $parser->mOutput->fr_includeErrors[] = $title->getPrefixedDBKey(); |
535 | | - if( !$wgUseCurrentImages ) { |
| 540 | + if ( !$wgUseCurrentImages ) { |
536 | 541 | $time = "0"; // no image |
537 | 542 | } else { |
538 | 543 | $file = wfFindFile( $title ); |
— | — | @@ -545,17 +550,17 @@ |
546 | 551 | $parser->mOutput->fr_ImageSHA1Keys[$title->getDBkey()] = array(); |
547 | 552 | $parser->mOutput->fr_ImageSHA1Keys[$title->getDBkey()][$time] = $sha1; |
548 | 553 | # Check if this file is local or on a foreign repo... |
549 | | - if( $isKnownLocal ) { |
| 554 | + if ( $isKnownLocal ) { |
550 | 555 | $isLocalFile = true; // no need to check |
551 | 556 | # Load the image if needed (note that time === '0' means we have no image) |
552 | | - } elseif( $time !== "0" ) { |
| 557 | + } elseif ( $time !== "0" ) { |
553 | 558 | # FIXME: would be nice not to double fetch! |
554 | 559 | $file = $file ? $file : self::getLocalFile( $title, $time ); |
555 | 560 | $isLocalFile = $file && $file->exists() && $file->isLocal(); |
556 | 561 | } |
557 | 562 | # Bug 15748, be lax about commons image sync status... |
558 | 563 | # 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 ) { |
560 | 565 | $parser->mOutput->fr_newestImageTime = $time; |
561 | 566 | } |
562 | 567 | return true; |
— | — | @@ -564,9 +569,9 @@ |
565 | 570 | /** |
566 | 571 | * Select the desired images based on the selected stable revision times/SHA-1s |
567 | 572 | */ |
568 | | - public static function galleryFindStableFileTime( $ig, $nt, &$time, &$query=false ) { |
| 573 | + public static function galleryFindStableFileTime( $ig, $nt, &$time, &$query = false ) { |
569 | 574 | # 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 ) { |
571 | 576 | return true; |
572 | 577 | } |
573 | 578 | $file = null; |
— | — | @@ -575,9 +580,9 @@ |
576 | 581 | # Should be in reviewable namespace, this saves unneeded DB checks as |
577 | 582 | # well as enforce site settings if they are later changed. |
578 | 583 | $sha1 = ""; |
579 | | - if( FlaggedRevs::isPageReviewable( $nt ) ) { |
| 584 | + if ( FlaggedRevs::isPageReviewable( $nt ) ) { |
580 | 585 | $srev = FlaggedRevision::newFromStable( $nt ); |
581 | | - if( $srev && $srev->getFileTimestamp() ) { |
| 586 | + if ( $srev && $srev->getFileTimestamp() ) { |
582 | 587 | $time = $srev->getFileTimestamp(); // TS or null |
583 | 588 | $sha1 = $srev->getFileSha1(); |
584 | 589 | $isKnownLocal = true; // must be local |
— | — | @@ -585,10 +590,10 @@ |
586 | 591 | } |
587 | 592 | # Check cache before doing another DB hit... |
588 | 593 | $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; |
591 | 596 | // Take the newest one... |
592 | | - if( !$time || $timeP > $time ) { |
| 597 | + if ( !$time || $timeP > $time ) { |
593 | 598 | $time = $timeP; |
594 | 599 | $sha1 = $sha1P; |
595 | 600 | $isKnownLocal = false; // up in the air...possibly a commons image |
— | — | @@ -596,29 +601,29 @@ |
597 | 602 | } |
598 | 603 | # If there is no stable version (or that feature is not enabled), use |
599 | 604 | # 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 ) ) { |
601 | 606 | $dbr = wfGetDB( DB_SLAVE ); |
602 | | - $row = $dbr->selectRow( 'flaggedimages', |
| 607 | + $row = $dbr->selectRow( 'flaggedimages', |
603 | 608 | 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() ), |
605 | 610 | __METHOD__ |
606 | 611 | ); |
607 | 612 | # 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 ) ) { |
609 | 614 | $time = $row->fi_img_timestamp; |
610 | 615 | $sha1 = $row->fi_img_sha1; |
611 | 616 | $isKnownLocal = false; // up in the air...possibly a commons image |
612 | 617 | } |
613 | 618 | } |
614 | | - $query = $time ? "filetimestamp=" . urlencode( wfTimestamp(TS_MW,$time) ) : ""; |
| 619 | + $query = $time ? "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ) : ""; |
615 | 620 | # If none specified, see if we are allowed to use the current revision |
616 | | - if( !$time ) { |
| 621 | + if ( !$time ) { |
617 | 622 | global $wgUseCurrentImages; |
618 | 623 | # If the DB found nothing... |
619 | | - if( $time === false ) { |
| 624 | + if ( $time === false ) { |
620 | 625 | # May want to give an error, so track these... |
621 | 626 | $ig->mParser->mOutput->fr_includeErrors[] = $nt->getPrefixedDBKey(); |
622 | | - if( !$wgUseCurrentImages ) { |
| 627 | + if ( !$wgUseCurrentImages ) { |
623 | 628 | $time = "0"; // no image |
624 | 629 | } else { |
625 | 630 | $file = wfFindFile( $nt ); |
— | — | @@ -632,16 +637,16 @@ |
633 | 638 | $ig->mParser->mOutput->fr_ImageSHA1Keys[$nt->getDBkey()] = array(); |
634 | 639 | $ig->mParser->mOutput->fr_ImageSHA1Keys[$nt->getDBkey()][$time] = $sha1; |
635 | 640 | # Check if this file is local or on a foreign repo... |
636 | | - if( $isKnownLocal ) { |
| 641 | + if ( $isKnownLocal ) { |
637 | 642 | $isLocalFile = true; // no need to check |
638 | 643 | # Load the image if needed (note that time === '0' means we have no image) |
639 | | - } elseif( $time !== "0" ) { |
| 644 | + } elseif ( $time !== "0" ) { |
640 | 645 | # FIXME: would be nice not to double fetch! |
641 | 646 | $file = $file ? $file : self::getLocalFile( $nt, $time ); |
642 | 647 | $isLocalFile = $file && $file->exists() && $file->isLocal(); |
643 | 648 | } |
644 | 649 | # 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 ) { |
646 | 651 | $ig->mParser->mOutput->fr_newestImageTime = $time; |
647 | 652 | } |
648 | 653 | return true; |
— | — | @@ -652,15 +657,15 @@ |
653 | 658 | */ |
654 | 659 | public static function parserInjectTimestamps( $parser, &$text ) { |
655 | 660 | # 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 ) ) { |
657 | 662 | return true; |
658 | 663 | } |
659 | 664 | $maxRevision = 0; |
660 | 665 | # 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 ) { |
665 | 670 | $maxRevision = $revID; |
666 | 671 | } |
667 | 672 | } |
— | — | @@ -669,15 +674,15 @@ |
670 | 675 | $parser->mOutput->fr_newestTemplateID = $maxRevision; |
671 | 676 | # Fetch the current timestamps of the images. |
672 | 677 | $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 ) { |
675 | 680 | # FIXME: it would be nice not to double fetch these! |
676 | 681 | $file = wfFindFile( Title::makeTitleSafe( NS_FILE, $filename ) ); |
677 | 682 | $parser->mOutput->fr_ImageSHA1Keys[$filename] = array(); |
678 | | - if( $file ) { |
| 683 | + if ( $file ) { |
679 | 684 | $ts = $file->getTimestamp(); |
680 | 685 | # Bug 15748, be lax about commons image sync status |
681 | | - if( $file->isLocal() && $ts > $maxTimestamp ) { |
| 686 | + if ( $file->isLocal() && $ts > $maxTimestamp ) { |
682 | 687 | $maxTimestamp = $ts; |
683 | 688 | } |
684 | 689 | $parser->mOutput->fr_ImageSHA1Keys[$filename][$ts] = $file->getSha1(); |
— | — | @@ -696,11 +701,11 @@ |
697 | 702 | */ |
698 | 703 | public static function outputInjectTimestamps( $out, $parserOut ) { |
699 | 704 | # Set first time |
700 | | - $out->fr_ImageSHA1Keys = isset($out->fr_ImageSHA1Keys) ? |
| 705 | + $out->fr_ImageSHA1Keys = isset( $out->fr_ImageSHA1Keys ) ? |
701 | 706 | $out->fr_ImageSHA1Keys : array(); |
702 | 707 | # Leave as defaults if missing. Relevant things will be updated only when needed. |
703 | 708 | # 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 ) ? |
705 | 710 | $parserOut->fr_ImageSHA1Keys : array(); |
706 | 711 | # Add on any new items |
707 | 712 | $out->fr_ImageSHA1Keys = wfArrayMerge( $out->fr_ImageSHA1Keys, $imageSHA1Keys ); |
— | — | @@ -715,41 +720,41 @@ |
716 | 721 | * Check page move and patrol permissions for FlaggedRevs |
717 | 722 | */ |
718 | 723 | public static function onUserCan( $title, $user, $action, &$result ) { |
719 | | - if( $result === false ) |
| 724 | + if ( $result === false ) |
720 | 725 | return true; // nothing to do |
721 | 726 | # 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() ) |
724 | 729 | return true; |
725 | 730 | $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
726 | 731 | # If the current shows be default anyway, nothing to do... |
727 | | - if( !$flaggedArticle->isStableShownByDefault() ) { |
| 732 | + if ( !$flaggedArticle->isStableShownByDefault() ) { |
728 | 733 | return true; |
729 | 734 | } |
730 | 735 | $frev = $flaggedArticle->getStableRev(); |
731 | | - if( $frev && !$user->isAllowed('review') && !$user->isAllowed('movestable') ) { |
| 736 | + if ( $frev && !$user->isAllowed( 'review' ) && !$user->isAllowed( 'movestable' ) ) { |
732 | 737 | # Allow for only editors/reviewers to move this page |
733 | 738 | $result = false; |
734 | 739 | return false; |
735 | 740 | } |
736 | 741 | # Don't let users patrol pages not in $wgFlaggedRevsPatrolNamespaces |
737 | | - } else if( $action === 'patrol' || $action === 'autopatrol' ) { |
| 742 | + } else if ( $action === 'patrol' || $action === 'autopatrol' ) { |
738 | 743 | # Pages in reviewable namespace can be patrolled IF reviewing |
739 | 744 | # is disabled for pages that don't show the stable by default. |
740 | 745 | # 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' ) ) { |
742 | 747 | $result = false; |
743 | 748 | return false; |
744 | 749 | } |
745 | 750 | $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
746 | 751 | # The page must be in a patrollable namespace ($wgFlaggedRevsPatrolNamespaces)... |
747 | | - if( !$flaggedArticle->isPatrollable() ) { |
| 752 | + if ( !$flaggedArticle->isPatrollable() ) { |
748 | 753 | global $wgUseNPPatrol; |
749 | 754 | # ...unless the page is not in a reviewable namespace and |
750 | 755 | # new page patrol is enabled. In this scenario, any edits |
751 | 756 | # to pages outside of patrollable namespaces would already |
752 | 757 | # be auto-patrolled, except for the new page edits. |
753 | | - if( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) { |
| 758 | + if ( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) { |
754 | 759 | return true; |
755 | 760 | } else { |
756 | 761 | $result = false; |
— | — | @@ -767,15 +772,15 @@ |
768 | 773 | global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
769 | 774 | # Assume $action may still not be set, in which case, treat it as 'view'... |
770 | 775 | # 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 ) ) |
772 | 777 | return true; |
773 | 778 | # Admin may set this to false, rather than array()... |
774 | 779 | $groups = $user->getGroups(); |
775 | 780 | $groups[] = '*'; |
776 | | - if( !array_intersect($groups,$wgFlaggedRevsVisible) ) |
| 781 | + if ( !array_intersect( $groups, $wgFlaggedRevsVisible ) ) |
777 | 782 | return true; |
778 | 783 | # Is this a talk page? |
779 | | - if( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) { |
| 784 | + if ( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) { |
780 | 785 | $result = true; |
781 | 786 | return true; |
782 | 787 | } |
— | — | @@ -783,14 +788,14 @@ |
784 | 789 | # config and URL params, the page can be overriden. The later |
785 | 790 | # only applies on page views of $title. |
786 | 791 | $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
787 | | - if( !empty($wgTitle) && $wgTitle->equals( $title ) ) { |
| 792 | + if ( !empty( $wgTitle ) && $wgTitle->equals( $title ) ) { |
788 | 793 | $view = FlaggedArticleView::singleton(); |
789 | 794 | // Cache stable version while we are at it. |
790 | | - if( $view->pageOverride() && $flaggedArticle->getStableRev() ) { |
| 795 | + if ( $view->pageOverride() && $flaggedArticle->getStableRev() ) { |
791 | 796 | $result = true; |
792 | 797 | } |
793 | 798 | } else { |
794 | | - if( FlaggedRevision::newFromStable( $title ) ) { |
| 799 | + if ( FlaggedRevision::newFromStable( $title ) ) { |
795 | 800 | $result = true; |
796 | 801 | } |
797 | 802 | } |
— | — | @@ -809,7 +814,7 @@ |
810 | 815 | global $wgRequest; |
811 | 816 | # Edit must be non-null, and to a reviewable page |
812 | 817 | $fa = FlaggedArticle::getArticleInstance( $article ); |
813 | | - if( !$rev || !$fa->isReviewable() ) { |
| 818 | + if ( !$rev || !$fa->isReviewable() ) { |
814 | 819 | return true; |
815 | 820 | } |
816 | 821 | $title = $article->getTitle(); |
— | — | @@ -819,107 +824,107 @@ |
820 | 825 | $prevTimestamp = $flags = null; |
821 | 826 | # Get edit timestamp. Existance already valided by EditPage.php. If |
822 | 827 | # not present, then it the rev shouldn't be saved, like null edits. |
823 | | - $editTimestamp = $wgRequest->getVal('wpEdittime'); |
| 828 | + $editTimestamp = $wgRequest->getVal( 'wpEdittime' ); |
824 | 829 | # 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; |
826 | 831 | # Is the page checked off to be reviewed? |
827 | 832 | # Autoreview if this is such a valid case... |
828 | | - if( $wgRequest->getCheck('wpReviewEdit') && $user->isAllowed('review') ) { |
| 833 | + if ( $wgRequest->getCheck( 'wpReviewEdit' ) && $user->isAllowed( 'review' ) ) { |
829 | 834 | # Check wpEdittime against the previous edit for verification |
830 | | - if( $prevRevId ) { |
| 835 | + if ( $prevRevId ) { |
831 | 836 | $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK |
832 | 837 | } |
833 | 838 | # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit. |
834 | 839 | # 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 ) { |
836 | 841 | $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, |
837 | 842 | $flags, false ); |
838 | | - if( $ok ) return true; // done! |
| 843 | + if ( $ok ) return true; // done! |
839 | 844 | } |
840 | 845 | } |
841 | 846 | # Get sync cache key |
842 | 847 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $rev->getPage() ); |
843 | 848 | # 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' ) ) { |
845 | 850 | $isAllowed = false; // untrusted user |
846 | 851 | } else { |
847 | 852 | # Get autoreview restriction settings... |
848 | 853 | $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
849 | 854 | # Convert Sysop -> protect |
850 | | - $right = ($config['autoreview'] === 'sysop') ? |
| 855 | + $right = ( $config['autoreview'] === 'sysop' ) ? |
851 | 856 | 'protect' : $config['autoreview']; |
852 | 857 | # Check if the user has the required right, if any |
853 | | - $isAllowed = ($right == '' || $user->isAllowed($right)); |
| 858 | + $isAllowed = ( $right == '' || $user->isAllowed( $right ) ); |
854 | 859 | } |
855 | 860 | # If $baseRevId passed in, this is a null edit |
856 | 861 | $isNullEdit = $baseRevId ? true : false; |
857 | 862 | $frev = null; |
858 | 863 | $reviewableNewPage = false; |
859 | 864 | # 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 |
862 | 867 | $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK |
863 | 868 | } |
864 | 869 | # The user just made an edit. The one before that should have |
865 | 870 | # been the current version. If not reflected in wpEdittime, an |
866 | 871 | # edit may have been auto-merged in between, in that case, discard |
867 | 872 | # 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' ) ) ); |
870 | 875 | } |
871 | 876 | # If baseRevId not given, assume the previous revision ID. |
872 | 877 | # For auto-merges, this also occurs since the given ID is ignored. |
873 | 878 | # Also for bots that don't submit everything... |
874 | | - if( !$baseRevId ) { |
| 879 | + if ( !$baseRevId ) { |
875 | 880 | $baseRevId = $prevRevId; |
876 | 881 | } |
877 | 882 | } |
878 | 883 | global $wgMemc, $wgParserCacheExpireTime; |
879 | 884 | # User must have the required permissions for all autoreview cases |
880 | 885 | # except for simple self-reversions. |
881 | | - if( !$isAllowed ) { |
| 886 | + if ( !$isAllowed ) { |
882 | 887 | $srev = FlaggedRevision::newFromStable( $title, FR_MASTER ); |
883 | 888 | # Check if this reverted to the stable version. Reverts to other reviewed |
884 | 889 | # revisions will not be allowed since we don't trust this user. |
885 | | - if( $srev && $baseRevId == $srev->getRevId() ) { |
| 890 | + if ( $srev && $baseRevId == $srev->getRevId() ) { |
886 | 891 | # Check that this user is ONLY reverting his/herself. |
887 | | - if( self::userWasLastAuthor($article,$baseRevId,$user) ) { |
| 892 | + if ( self::userWasLastAuthor( $article, $baseRevId, $user ) ) { |
888 | 893 | # Confirm the text; we can't trust this user. |
889 | | - if( $rev->getText() == $srev->getRevText() ) { |
| 894 | + if ( $rev->getText() == $srev->getRevText() ) { |
890 | 895 | $flags = FlaggedRevs::quickTags( FR_SIGHTED ); |
891 | 896 | $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), |
892 | 897 | $rev, $flags ); |
893 | | - if( $ok ) return true; // done! |
| 898 | + if ( $ok ) return true; // done! |
894 | 899 | } |
895 | 900 | } |
896 | 901 | } |
897 | 902 | # 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 ); |
899 | 904 | return true; // done! edit pending! |
900 | 905 | } |
901 | 906 | // New pages |
902 | | - if( !$prevRevId ) { |
| 907 | + if ( !$prevRevId ) { |
903 | 908 | $reviewableNewPage = FlaggedRevs::autoReviewNewPages(); |
904 | 909 | // Edits to existing pages |
905 | | - } elseif( $baseRevId ) { |
| 910 | + } elseif ( $baseRevId ) { |
906 | 911 | $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
907 | 912 | # If the base revision was not reviewed, check if the previous one was. |
908 | 913 | # This should catch null edits as well as normal ones. |
909 | | - if( !$frev ) { |
| 914 | + if ( !$frev ) { |
910 | 915 | $frev = FlaggedRevision::newFromTitle( $title, $prevRevId, FR_MASTER ); |
911 | 916 | } |
912 | 917 | } |
913 | 918 | // 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 ) ) ) { |
915 | 920 | # Assume basic flagging level unless this is a null edit |
916 | | - if( $isNullEdit ) $flags = $frev->getTags(); |
| 921 | + if ( $isNullEdit ) $flags = $frev->getTags(); |
917 | 922 | # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit... |
918 | 923 | $ok = FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags ); |
919 | 924 | } else { |
920 | 925 | $ok = false; |
921 | 926 | } |
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 ); |
924 | 929 | } |
925 | 930 | return true; |
926 | 931 | } |
— | — | @@ -932,8 +937,8 @@ |
933 | 938 | return !$dbw->selectField( 'revision', '1', |
934 | 939 | array( |
935 | 940 | '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() ) |
938 | 943 | ), __METHOD__ |
939 | 944 | ); |
940 | 945 | } |
— | — | @@ -948,30 +953,30 @@ |
949 | 954 | # Must be in reviewable namespace |
950 | 955 | $title = $article->getTitle(); |
951 | 956 | # 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 ) ) { |
953 | 958 | return true; |
954 | 959 | } |
955 | 960 | # Get the current revision ID |
956 | 961 | $rev = Revision::newFromTitle( $title ); |
957 | 962 | $flags = null; |
958 | 963 | # Is this a rollback/undo that didn't change anything? |
959 | | - if( $rev && $baseId ) { |
| 964 | + if ( $rev && $baseId ) { |
960 | 965 | $frev = FlaggedRevision::newFromTitle( $title, $baseId ); |
961 | 966 | # Was the edit that we tried to revert to reviewed? |
962 | | - if( $frev ) { |
| 967 | + if ( $frev ) { |
963 | 968 | FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags ); |
964 | 969 | FlaggedRevs::markRevisionPatrolled( $rev ); // Make sure it is now marked patrolled... |
965 | 970 | } |
966 | 971 | } |
967 | 972 | # Get edit timestamp, it must exist. |
968 | | - $editTimestamp = $wgRequest->getVal('wpEdittime'); |
| 973 | + $editTimestamp = $wgRequest->getVal( 'wpEdittime' ); |
969 | 974 | # 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' ) ) |
972 | 977 | { |
973 | 978 | # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit. |
974 | 979 | # Don't do so if an edit was auto-merged in between though... |
975 | | - if( $rev->getTimestamp() == $editTimestamp ) { |
| 980 | + if ( $rev->getTimestamp() == $editTimestamp ) { |
976 | 981 | FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), |
977 | 982 | $rev, $flags, false ); |
978 | 983 | FlaggedRevs::markRevisionPatrolled( $rev ); // Make sure it is now marked patrolled... |
— | — | @@ -986,16 +991,16 @@ |
987 | 992 | */ |
988 | 993 | public static function autoMarkPatrolled( &$rc ) { |
989 | 994 | global $wgUser; |
990 | | - if( empty($rc->mAttribs['rc_this_oldid']) ) { |
| 995 | + if ( empty( $rc->mAttribs['rc_this_oldid'] ) ) { |
991 | 996 | return true; |
992 | 997 | } |
993 | 998 | // Is the page reviewable? |
994 | | - if( FlaggedRevs::isPageReviewable( $rc->getTitle() ) ) { |
| 999 | + if ( FlaggedRevs::isPageReviewable( $rc->getTitle() ) ) { |
995 | 1000 | # Note: pages in reviewable namespace with FR disabled |
996 | 1001 | # won't autopatrol. May or may not be useful... |
997 | 1002 | $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'], |
998 | 1003 | $rc->mAttribs['rc_this_oldid'], GAID_FOR_UPDATE ); |
999 | | - if( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) { |
| 1004 | + if ( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) { |
1000 | 1005 | RevisionReview::updateRecentChanges( $rc->getTitle(), |
1001 | 1006 | $rc->mAttribs['rc_this_oldid'] ); |
1002 | 1007 | $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status |
— | — | @@ -1004,29 +1009,29 @@ |
1005 | 1010 | } |
1006 | 1011 | // Is this page in patrollable namespace? |
1007 | 1012 | $patrol = $record = false; |
1008 | | - if( FlaggedRevs::isPagePatrollable( $rc->getTitle() ) ) { |
| 1013 | + if ( FlaggedRevs::isPagePatrollable( $rc->getTitle() ) ) { |
1009 | 1014 | # Bots and users with 'autopatrol' have edits to patrolleable pages |
1010 | 1015 | # marked automatically on edit. |
1011 | | - $patrol = $wgUser->isAllowed('autopatrol') || $wgUser->isAllowed('bot'); |
| 1016 | + $patrol = $wgUser->isAllowed( 'autopatrol' ) || $wgUser->isAllowed( 'bot' ); |
1012 | 1017 | $record = true; |
1013 | 1018 | } else { |
1014 | 1019 | global $wgUseNPPatrol; |
1015 | 1020 | # Mark patrolled by default unless this is a new page and new page patrol |
1016 | 1021 | # is enabled (except when the user has 'autopatrol', then patrol it). |
1017 | 1022 | # This is just to avoid RC clutter for non-patrollable pages. |
1018 | | - if( $wgUser->isAllowed('autopatrol') ) { |
| 1023 | + if ( $wgUser->isAllowed( 'autopatrol' ) ) { |
1019 | 1024 | $patrol = true; |
1020 | 1025 | # Record patrolled new pages if $wgUseNPPatrol is on |
1021 | | - $record = ( $wgUseNPPatrol && !empty($rc->mAttribs['rc_new']) ); |
| 1026 | + $record = ( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) ); |
1022 | 1027 | } else { |
1023 | | - $patrol = !( $wgUseNPPatrol && !empty($rc->mAttribs['rc_new']) ); |
| 1028 | + $patrol = !( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) ); |
1024 | 1029 | } |
1025 | 1030 | } |
1026 | 1031 | // Set rc_patrolled flag and add log entry as needed |
1027 | | - if( $patrol ) { |
| 1032 | + if ( $patrol ) { |
1028 | 1033 | $rc->reallyMarkPatrolled(); |
1029 | 1034 | $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs now status |
1030 | | - if( $record ) { |
| 1035 | + if ( $record ) { |
1031 | 1036 | PatrolLog::record( $rc->mAttribs['rc_id'], true ); |
1032 | 1037 | } |
1033 | 1038 | } |
— | — | @@ -1035,9 +1040,9 @@ |
1036 | 1041 | |
1037 | 1042 | public static function incrementRollbacks( $this, $user, $target, $current ) { |
1038 | 1043 | # 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() ) { |
1040 | 1045 | $p = FlaggedRevs::getUserParams( $current->getRawUser() ); |
1041 | | - $p['revertedEdits'] = isset($p['revertedEdits']) ? $p['revertedEdits'] : 0; |
| 1046 | + $p['revertedEdits'] = isset( $p['revertedEdits'] ) ? $p['revertedEdits'] : 0; |
1042 | 1047 | $p['revertedEdits']++; |
1043 | 1048 | FlaggedRevs::saveUserParams( $current->getRawUser(), $p ); |
1044 | 1049 | } |
— | — | @@ -1048,12 +1053,12 @@ |
1049 | 1054 | global $wgRequest; |
1050 | 1055 | # Was this an edit by an auto-sighter that undid another edit? |
1051 | 1056 | $undid = $wgRequest->getInt( 'undidRev' ); |
1052 | | - if( $rev && $undid && $user->isAllowed('autoreview') ) { |
| 1057 | + if ( $rev && $undid && $user->isAllowed( 'autoreview' ) ) { |
1053 | 1058 | $badRev = Revision::newFromTitle( $article->getTitle(), $undid ); |
1054 | 1059 | # Don't count self-reverts |
1055 | | - if( $badRev && $badRev->getRawUser() && $badRev->getRawUser() != $rev->getRawUser() ) { |
| 1060 | + if ( $badRev && $badRev->getRawUser() && $badRev->getRawUser() != $rev->getRawUser() ) { |
1056 | 1061 | $p = FlaggedRevs::getUserParams( $badRev->getRawUser() ); |
1057 | | - $p['revertedEdits'] = isset($p['revertedEdits']) ? $p['revertedEdits'] : 0; |
| 1062 | + $p['revertedEdits'] = isset( $p['revertedEdits'] ) ? $p['revertedEdits'] : 0; |
1058 | 1063 | $p['revertedEdits']++; |
1059 | 1064 | FlaggedRevs::saveUserParams( $badRev->getRawUser(), $p ); |
1060 | 1065 | } |
— | — | @@ -1065,7 +1070,7 @@ |
1066 | 1071 | # Convert days to seconds... |
1067 | 1072 | $spacing = $spacing * 24 * 3600; |
1068 | 1073 | # Check the oldest edit |
1069 | | - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE ); |
| 1074 | + $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1070 | 1075 | $lower = $dbr->selectField( 'revision', 'rev_timestamp', |
1071 | 1076 | array( 'rev_user' => $user->getId() ), |
1072 | 1077 | __METHOD__, |
— | — | @@ -1075,17 +1080,17 @@ |
1076 | 1081 | # The first edit counts, so we have one less scans to do... |
1077 | 1082 | $benchmarks = 0; // actual |
1078 | 1083 | $needed = $points - 1; // required |
1079 | | - while( $lower && $benchmarks < $needed ) { |
| 1084 | + while ( $lower && $benchmarks < $needed ) { |
1080 | 1085 | $next = wfTimestamp( TS_UNIX, $lower ) + $spacing; |
1081 | 1086 | $lower = $dbr->selectField( 'revision', 'rev_timestamp', |
1082 | 1087 | array( 'rev_user' => $user->getId(), |
1083 | | - 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp($next) ) ), |
| 1088 | + 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $next ) ) ), |
1084 | 1089 | __METHOD__, |
1085 | 1090 | array( 'ORDER BY' => 'rev_timestamp ASC', 'USE INDEX' => 'user_timestamp' ) |
1086 | 1091 | ); |
1087 | | - if( $lower !== false ) $benchmarks++; |
| 1092 | + if ( $lower !== false ) $benchmarks++; |
1088 | 1093 | } |
1089 | | - return ($benchmarks >= $needed ); |
| 1094 | + return ( $benchmarks >= $needed ); |
1090 | 1095 | } |
1091 | 1096 | |
1092 | 1097 | /** |
— | — | @@ -1095,7 +1100,7 @@ |
1096 | 1101 | $dbr = wfGetDB( DB_SLAVE ); |
1097 | 1102 | return (bool)$dbr->selectField( 'logging', '1', |
1098 | 1103 | array( |
1099 | | - 'log_namespace' => NS_USER, |
| 1104 | + 'log_namespace' => NS_USER, |
1100 | 1105 | 'log_title' => $user->getUserPage()->getDBkey(), |
1101 | 1106 | 'log_type' => 'block', |
1102 | 1107 | 'log_action' => 'block' ), |
— | — | @@ -1112,15 +1117,15 @@ |
1113 | 1118 | public static function checkAutoPromote( $user, &$promote ) { |
1114 | 1119 | global $wgFlaggedRevsAutoconfirm, $wgMemc; |
1115 | 1120 | # Make sure bots always have autoreview |
1116 | | - if( $user->isAllowed('bot') ) { |
| 1121 | + if ( $user->isAllowed( 'bot' ) ) { |
1117 | 1122 | $promote[] = 'autoreview'; |
1118 | 1123 | return true; |
1119 | 1124 | } |
1120 | 1125 | # Check if $wgFlaggedRevsAutoconfirm is actually enabled |
1121 | 1126 | # and that this is a logged-in user that doesn't already |
1122 | 1127 | # have the 'autoreview' permission |
1123 | | - if( !$user->getId() || $user->isAllowed('autoreview') |
1124 | | - || empty($wgFlaggedRevsAutoconfirm) ) |
| 1128 | + if ( !$user->getId() || $user->isAllowed( 'autoreview' ) |
| 1129 | + || empty( $wgFlaggedRevsAutoconfirm ) ) |
1125 | 1130 | { |
1126 | 1131 | return true; |
1127 | 1132 | } |
— | — | @@ -1128,74 +1133,74 @@ |
1129 | 1134 | # Checked basic, already available, promotion heuristics first... |
1130 | 1135 | $APSkipKey = wfMemcKey( 'flaggedrevs', 'autoreview-skip', $user->getId() ); |
1131 | 1136 | $value = $wgMemc->get( $APSkipKey ); |
1132 | | - if( $value === 'true' ) return true; |
| 1137 | + if ( $value === 'true' ) return true; |
1133 | 1138 | # Check $wgFlaggedRevsAutoconfirm settings... |
1134 | 1139 | $now = time(); |
1135 | 1140 | $userCreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); |
1136 | 1141 | # 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; |
1138 | 1143 | $p = FlaggedRevs::getUserParams( $user->getId() ); |
1139 | 1144 | # Check if user edited enough content pages |
1140 | 1145 | $totalCheckedEditsNeeded = false; |
1141 | | - if( $wgFlaggedRevsAutoconfirm['totalContentEdits'] > $p['totalContentEdits'] ) { |
1142 | | - if( !$wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
| 1146 | + if ( $wgFlaggedRevsAutoconfirm['totalContentEdits'] > $p['totalContentEdits'] ) { |
| 1147 | + if ( !$wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
1143 | 1148 | return true; |
1144 | 1149 | } |
1145 | 1150 | $totalCheckedEditsNeeded = true; |
1146 | 1151 | } |
1147 | 1152 | # 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 ) ) { |
1150 | 1155 | return true; |
1151 | 1156 | } |
1152 | 1157 | # Check edit comment use |
1153 | | - if( $wgFlaggedRevsAutoconfirm['editComments'] > $p['editComments'] ) { |
| 1158 | + if ( $wgFlaggedRevsAutoconfirm['editComments'] > $p['editComments'] ) { |
1154 | 1159 | return true; |
1155 | 1160 | } |
1156 | 1161 | # Check account age |
1157 | | - if( !is_null($userage) && $userage < $wgFlaggedRevsAutoconfirm['days'] ) { |
| 1162 | + if ( !is_null( $userage ) && $userage < $wgFlaggedRevsAutoconfirm['days'] ) { |
1158 | 1163 | return true; |
1159 | 1164 | } |
1160 | 1165 | # Check user edit count. Should be stored. |
1161 | | - if( $user->getEditCount() < $wgFlaggedRevsAutoconfirm['edits'] ) { |
| 1166 | + if ( $user->getEditCount() < $wgFlaggedRevsAutoconfirm['edits'] ) { |
1162 | 1167 | return true; |
1163 | 1168 | } |
1164 | 1169 | # Check user email |
1165 | | - if( $wgFlaggedRevsAutoconfirm['email'] && !$user->isEmailConfirmed() ) { |
| 1170 | + if ( $wgFlaggedRevsAutoconfirm['email'] && !$user->isEmailConfirmed() ) { |
1166 | 1171 | return true; |
1167 | 1172 | } |
1168 | 1173 | # Don't grant to currently blocked users... |
1169 | | - if( $user->isBlocked() ) { |
| 1174 | + if ( $user->isBlocked() ) { |
1170 | 1175 | return true; |
1171 | 1176 | } |
1172 | 1177 | # Check if user was ever blocked before |
1173 | | - if( $wgFlaggedRevsAutoconfirm['neverBlocked'] ) { |
| 1178 | + if ( $wgFlaggedRevsAutoconfirm['neverBlocked'] ) { |
1174 | 1179 | $blocked = self::previousBlockCheck( $user ); |
1175 | | - if( $blocked ) { |
| 1180 | + if ( $blocked ) { |
1176 | 1181 | # Make a key to store the results |
1177 | | - $wgMemc->set( $APSkipKey, 'true', 3600*24*7 ); |
| 1182 | + $wgMemc->set( $APSkipKey, 'true', 3600 * 24 * 7 ); |
1178 | 1183 | return true; |
1179 | 1184 | } |
1180 | 1185 | } |
1181 | 1186 | # Check for edit spacing. This lets us know that the account has |
1182 | 1187 | # been used over N different days, rather than all in one lump. |
1183 | | - if( $wgFlaggedRevsAutoconfirm['spacing'] > 0 |
| 1188 | + if ( $wgFlaggedRevsAutoconfirm['spacing'] > 0 |
1184 | 1189 | && $wgFlaggedRevsAutoconfirm['benchmarks'] > 1 ) |
1185 | 1190 | { |
1186 | 1191 | $sTestKey = wfMemcKey( 'flaggedrevs', 'autoreview-spacing-ok', $user->getId() ); |
1187 | 1192 | $value = $wgMemc->get( $sTestKey ); |
1188 | 1193 | # Check if the user already passed this test via cache. |
1189 | 1194 | # If no cache key is available, then check the DB... |
1190 | | - if( $value !== 'true' ) { |
| 1195 | + if ( $value !== 'true' ) { |
1191 | 1196 | $pass = self::editSpacingCheck( |
1192 | 1197 | $wgFlaggedRevsAutoconfirm['spacing'], |
1193 | 1198 | $wgFlaggedRevsAutoconfirm['benchmarks'], |
1194 | 1199 | $user |
1195 | 1200 | ); |
1196 | 1201 | # Make a key to store the results |
1197 | | - if( !$pass ) { |
| 1202 | + if ( !$pass ) { |
1198 | 1203 | $wgMemc->set( $APSkipKey, 'true', |
1199 | | - 3600*24*$spacing*($benchmarks - $needed - 1) ); |
| 1204 | + 3600 * 24 * $spacing * ( $benchmarks - $needed - 1 ) ); |
1200 | 1205 | return true; |
1201 | 1206 | } else { |
1202 | 1207 | $wgMemc->set( $sTestKey, 'true', 7 * 24 * 3600 ); |
— | — | @@ -1203,16 +1208,16 @@ |
1204 | 1209 | } |
1205 | 1210 | } |
1206 | 1211 | # Check implicitly sighted edits |
1207 | | - if( $totalCheckedEditsNeeded && $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
| 1212 | + if ( $totalCheckedEditsNeeded && $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
1208 | 1213 | $dbr = wfGetDB( DB_SLAVE ); |
1209 | | - $res = $dbr->select( array('revision','flaggedpages'), '1', |
| 1214 | + $res = $dbr->select( array( 'revision', 'flaggedpages' ), '1', |
1210 | 1215 | array( 'rev_user' => $user->getId(), |
1211 | 1216 | 'fp_page_id = rev_page', 'fp_stable >= rev_id' ), |
1212 | 1217 | __METHOD__, |
1213 | | - array( 'USE INDEX' => array('revision' => 'user_timestamp'), |
| 1218 | + array( 'USE INDEX' => array( 'revision' => 'user_timestamp' ), |
1214 | 1219 | 'LIMIT' => $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) |
1215 | 1220 | ); |
1216 | | - if( $dbr->numRows($res) < $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
| 1221 | + if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutoconfirm['totalCheckedEdits'] ) { |
1217 | 1222 | return true; |
1218 | 1223 | } |
1219 | 1224 | } |
— | — | @@ -1230,129 +1235,129 @@ |
1231 | 1236 | ) { |
1232 | 1237 | global $wgFlaggedRevsAutopromote, $wgFlaggedRevsAutoconfirm, $wgMemc; |
1233 | 1238 | # Ignore NULL edits or edits by anon users |
1234 | | - if( !$rev || !$user->getId() ) |
| 1239 | + if ( !$rev || !$user->getId() ) |
1235 | 1240 | return true; |
1236 | 1241 | # No sense in running counters if nothing uses them |
1237 | | - if( empty($wgFlaggedRevsAutopromote) && empty($wgFlaggedRevsAutoconfirm) ) { |
| 1242 | + if ( empty( $wgFlaggedRevsAutopromote ) && empty( $wgFlaggedRevsAutoconfirm ) ) { |
1238 | 1243 | return true; |
1239 | 1244 | } |
1240 | 1245 | $p = FlaggedRevs::getUserParams( $user->getId() ); |
1241 | 1246 | # Update any special counters for non-null revisions |
1242 | 1247 | $changed = false; |
1243 | 1248 | $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 |
1246 | 1251 | # Don't let this get bloated for no reason |
1247 | 1252 | # (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 ) ) |
1250 | 1255 | { |
1251 | 1256 | $pages[] = $article->getId(); |
1252 | 1257 | // Clear out any formatting garbage |
1253 | | - $p['uniqueContentPages'] = preg_replace('/^,/','',implode(',',$pages)); |
| 1258 | + $p['uniqueContentPages'] = preg_replace( '/^,/', '', implode( ',', $pages ) ); |
1254 | 1259 | } |
1255 | 1260 | $p['totalContentEdits'] += 1; |
1256 | 1261 | $changed = true; |
1257 | 1262 | } |
1258 | | - if( $summary ) { |
| 1263 | + if ( $summary ) { |
1259 | 1264 | $p['editComments'] += 1; |
1260 | 1265 | $changed = true; |
1261 | 1266 | } |
1262 | 1267 | # Save any updates to user params |
1263 | | - if( $changed ) { |
| 1268 | + if ( $changed ) { |
1264 | 1269 | FlaggedRevs::saveUserParams( $user->getId(), $p ); |
1265 | 1270 | } |
1266 | 1271 | # Grab current groups |
1267 | 1272 | $groups = $user->getGroups(); |
1268 | 1273 | # 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 ) ) { |
1270 | 1275 | return true; |
1271 | 1276 | } |
1272 | 1277 | # Do not re-add status if it was previously removed! |
1273 | | - if( isset($p['demoted']) && $p['demoted'] ) { |
| 1278 | + if ( isset( $p['demoted'] ) && $p['demoted'] ) { |
1274 | 1279 | return true; |
1275 | 1280 | } |
1276 | 1281 | # Check if results are cached to avoid DB queries |
1277 | 1282 | $APSkipKey = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getId() ); |
1278 | 1283 | $value = $wgMemc->get( $APSkipKey ); |
1279 | | - if( $value == 'true' ) return true; |
| 1284 | + if ( $value == 'true' ) return true; |
1280 | 1285 | # Check if user edited enough content pages |
1281 | 1286 | $totalCheckedEditsNeeded = false; |
1282 | | - if( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) { |
1283 | | - if( !$wgFlaggedRevsAutopromote['totalCheckedEdits'] ) { |
| 1287 | + if ( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) { |
| 1288 | + if ( !$wgFlaggedRevsAutopromote['totalCheckedEdits'] ) { |
1284 | 1289 | return true; |
1285 | 1290 | } |
1286 | 1291 | $totalCheckedEditsNeeded = true; |
1287 | 1292 | } |
1288 | 1293 | # Check if user edited enough unique pages |
1289 | | - if( $wgFlaggedRevsAutopromote['uniqueContentPages'] > count($pages) ) { |
| 1294 | + if ( $wgFlaggedRevsAutopromote['uniqueContentPages'] > count( $pages ) ) { |
1290 | 1295 | return true; |
1291 | 1296 | } |
1292 | 1297 | # Check edit comment use |
1293 | | - if( $wgFlaggedRevsAutopromote['editComments'] > $p['editComments'] ) { |
| 1298 | + if ( $wgFlaggedRevsAutopromote['editComments'] > $p['editComments'] ) { |
1294 | 1299 | return true; |
1295 | 1300 | } |
1296 | 1301 | # Check reverted edits |
1297 | | - if( $wgFlaggedRevsAutopromote['maxRevertedEdits'] < $p['revertedEdits'] ) { |
| 1302 | + if ( $wgFlaggedRevsAutopromote['maxRevertedEdits'] < $p['revertedEdits'] ) { |
1298 | 1303 | return true; |
1299 | 1304 | } |
1300 | 1305 | # Check account age |
1301 | 1306 | $now = time(); |
1302 | 1307 | $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'] ) { |
1305 | 1310 | return true; |
1306 | 1311 | } |
1307 | 1312 | # Check user edit count. Should be stored. |
1308 | | - if( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] ) { |
| 1313 | + if ( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] ) { |
1309 | 1314 | return true; |
1310 | 1315 | } |
1311 | 1316 | # Don't grant to currently blocked users... |
1312 | | - if( $user->isBlocked() ) { |
| 1317 | + if ( $user->isBlocked() ) { |
1313 | 1318 | return true; |
1314 | 1319 | } |
1315 | 1320 | # Check if user was ever blocked before |
1316 | | - if( $wgFlaggedRevsAutopromote['neverBlocked'] ) { |
| 1321 | + if ( $wgFlaggedRevsAutopromote['neverBlocked'] ) { |
1317 | 1322 | $blocked = self::previousBlockCheck( $user ); |
1318 | | - if( $blocked ) { |
| 1323 | + if ( $blocked ) { |
1319 | 1324 | # Make a key to store the results |
1320 | | - $wgMemc->set( $APSkipKey, 'true', 3600*24*7 ); |
| 1325 | + $wgMemc->set( $APSkipKey, 'true', 3600 * 24 * 7 ); |
1321 | 1326 | return true; |
1322 | 1327 | } |
1323 | 1328 | } |
1324 | 1329 | # 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() ) { |
1327 | 1332 | return true; |
1328 | 1333 | } |
1329 | | - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE ); |
| 1334 | + $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1330 | 1335 | $size = $dbr->selectField( 'page', 'page_len', |
1331 | 1336 | array( 'page_namespace' => $user->getUserPage()->getNamespace(), |
1332 | 1337 | 'page_title' => $user->getUserPage()->getDBkey() ), |
1333 | 1338 | __METHOD__ ); |
1334 | | - if( $size < $wgFlaggedRevsAutopromote['userpageBytes'] ) { |
| 1339 | + if ( $size < $wgFlaggedRevsAutopromote['userpageBytes'] ) { |
1335 | 1340 | return true; |
1336 | 1341 | } |
1337 | 1342 | } |
1338 | 1343 | # Check for edit spacing. This lets us know that the account has |
1339 | 1344 | # been used over N different days, rather than all in one lump. |
1340 | | - if( $wgFlaggedRevsAutopromote['spacing'] > 0 |
| 1345 | + if ( $wgFlaggedRevsAutopromote['spacing'] > 0 |
1341 | 1346 | && $wgFlaggedRevsAutopromote['benchmarks'] > 1 ) |
1342 | 1347 | { |
1343 | 1348 | $sTestKey = wfMemcKey( 'flaggedrevs', 'autopromote-spacing-ok', $user->getId() ); |
1344 | 1349 | $value = $wgMemc->get( $sTestKey ); |
1345 | 1350 | # Check if the user already passed this test via cache. |
1346 | 1351 | # If no cache key is available, then check the DB... |
1347 | | - if( $value !== 'true' ) { |
| 1352 | + if ( $value !== 'true' ) { |
1348 | 1353 | $pass = self::editSpacingCheck( |
1349 | 1354 | $wgFlaggedRevsAutopromote['spacing'], |
1350 | 1355 | $wgFlaggedRevsAutopromote['benchmarks'], |
1351 | 1356 | $user |
1352 | 1357 | ); |
1353 | 1358 | # Make a key to store the results |
1354 | | - if( !$pass ) { |
| 1359 | + if ( !$pass ) { |
1355 | 1360 | $wgMemc->set( $APSkipKey, 'true', |
1356 | | - 3600*24*$spacing*($benchmarks - $needed - 1) ); |
| 1361 | + 3600 * 24 * $spacing * ( $benchmarks - $needed - 1 ) ); |
1357 | 1362 | return true; |
1358 | 1363 | } else { |
1359 | 1364 | $wgMemc->set( $sTestKey, 'true', 7 * 24 * 3600 ); |
— | — | @@ -1360,71 +1365,71 @@ |
1361 | 1366 | } |
1362 | 1367 | } |
1363 | 1368 | # Check if this user is sharing IPs with another users |
1364 | | - if( $wgFlaggedRevsAutopromote['uniqueIPAddress'] ) { |
| 1369 | + if ( $wgFlaggedRevsAutopromote['uniqueIPAddress'] ) { |
1365 | 1370 | $uid = $user->getId(); |
1366 | 1371 | |
1367 | | - $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE ); |
| 1372 | + $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1368 | 1373 | $shared = $dbr->selectField( 'recentchanges', '1', |
1369 | 1374 | array( 'rc_ip' => wfGetIP(), |
1370 | 1375 | "rc_user != '$uid'" ), |
1371 | 1376 | __METHOD__, |
1372 | 1377 | array( 'USE INDEX' => 'rc_ip' ) ); |
1373 | | - if( $shared ) { |
| 1378 | + if ( $shared ) { |
1374 | 1379 | # Make a key to store the results |
1375 | | - $wgMemc->set( $key, 'true', 3600*24*7 ); |
| 1380 | + $wgMemc->set( $key, 'true', 3600 * 24 * 7 ); |
1376 | 1381 | return true; |
1377 | 1382 | } |
1378 | 1383 | } |
1379 | 1384 | # Check if the user has any recent content edits |
1380 | | - if( $wgFlaggedRevsAutopromote['recentContentEdits'] > 0 ) { |
| 1385 | + if ( $wgFlaggedRevsAutopromote['recentContentEdits'] > 0 ) { |
1381 | 1386 | global $wgContentNamespaces; |
1382 | 1387 | |
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', |
1385 | 1390 | array( 'rc_user_text' => $user->getName(), |
1386 | | - 'rc_namespace' => $wgContentNamespaces ), |
1387 | | - __METHOD__, |
| 1391 | + 'rc_namespace' => $wgContentNamespaces ), |
| 1392 | + __METHOD__, |
1388 | 1393 | array( 'USE INDEX' => 'rc_ns_usertext', |
1389 | 1394 | 'LIMIT' => $wgFlaggedRevsAutopromote['recentContentEdits'] ) |
1390 | 1395 | ); |
1391 | | - if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['recentContentEdits'] ) { |
| 1396 | + if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutopromote['recentContentEdits'] ) { |
1392 | 1397 | return true; |
1393 | 1398 | } |
1394 | 1399 | } |
1395 | 1400 | # Check to see if the user has so many deleted edits that |
1396 | 1401 | # they don't actually enough live edits. This is because |
1397 | 1402 | # $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 ); |
1400 | 1405 | $minDiff = $user->getEditCount() - $wgFlaggedRevsAutopromote['days'] + 1; |
1401 | 1406 | # 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__, |
1406 | 1411 | array( 'USE INDEX' => 'usertext_timestamp', 'LIMIT' => $minDiff ) ); |
1407 | | - $deletedEdits = $dbr->numRows($res); |
| 1412 | + $deletedEdits = $dbr->numRows( $res ); |
1408 | 1413 | } else { |
1409 | 1414 | $deletedEdits = $dbr->estimateRowCount( 'archive', '1', |
1410 | 1415 | array( 'ar_user_text' => $user->getName() ), |
1411 | 1416 | __METHOD__, |
1412 | 1417 | array( 'USE INDEX' => 'usertext_timestamp' ) ); |
1413 | 1418 | } |
1414 | | - if( $deletedEdits >= $minDiff ) { |
| 1419 | + if ( $deletedEdits >= $minDiff ) { |
1415 | 1420 | return true; |
1416 | 1421 | } |
1417 | 1422 | } |
1418 | 1423 | # 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', |
1422 | 1427 | array( 'rev_user' => $user->getId(), |
1423 | 1428 | 'fp_page_id = rev_page', 'fp_stable >= rev_id' ), |
1424 | 1429 | __METHOD__, |
1425 | | - array( 'USE INDEX' => array('revision' => 'user_timestamp'), |
| 1430 | + array( 'USE INDEX' => array( 'revision' => 'user_timestamp' ), |
1426 | 1431 | 'LIMIT' => $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) |
1427 | 1432 | ); |
1428 | | - if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) { |
| 1433 | + if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) { |
1429 | 1434 | return true; |
1430 | 1435 | } |
1431 | 1436 | } |
— | — | @@ -1434,9 +1439,9 @@ |
1435 | 1440 | |
1436 | 1441 | global $wgFlaggedRevsAutopromoteInRC; |
1437 | 1442 | $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' ); |
1441 | 1446 | |
1442 | 1447 | return true; |
1443 | 1448 | } |
— | — | @@ -1445,9 +1450,9 @@ |
1446 | 1451 | * Record demotion so that auto-promote will be disabled |
1447 | 1452 | */ |
1448 | 1453 | public static function recordDemote( $u, $addgroup, $removegroup ) { |
1449 | | - if( $removegroup && in_array('editor',$removegroup) ) { |
| 1454 | + if ( $removegroup && in_array( 'editor', $removegroup ) ) { |
1450 | 1455 | // Cross-wiki rights change |
1451 | | - if( $u instanceof UserRightsProxy ) { |
| 1456 | + if ( $u instanceof UserRightsProxy ) { |
1452 | 1457 | $params = FlaggedRevs::getUserParams( $u->getId(), $u->getDBName() ); |
1453 | 1458 | $params['demoted'] = 1; |
1454 | 1459 | FlaggedRevs::saveUserParams( $u->getId(), $params, $u->getDBName() ); |
— | — | @@ -1482,7 +1487,7 @@ |
1483 | 1488 | 'label-message' => 'flaggedrevs-prefs-stable', |
1484 | 1489 | ); |
1485 | 1490 | // Review-related rights... |
1486 | | - if( $user->isAllowed( 'review' ) ) { |
| 1491 | + if ( $user->isAllowed( 'review' ) ) { |
1487 | 1492 | // Watching reviewed pages |
1488 | 1493 | $preferences['flaggedrevswatch'] = |
1489 | 1494 | array( |
— | — | @@ -1509,15 +1514,15 @@ |
1510 | 1515 | } |
1511 | 1516 | |
1512 | 1517 | public static function logLineLinks( |
1513 | | - $type, $action, $title=null, $params, &$comment, &$rv, $ts |
| 1518 | + $type, $action, $title = null, $params, &$comment, &$rv, $ts |
1514 | 1519 | ) { |
1515 | | - if( !$title ) { |
| 1520 | + if ( !$title ) { |
1516 | 1521 | return true; // nothing to do |
1517 | 1522 | // Stability log |
1518 | | - } else if( $type == 'stable' ) { |
| 1523 | + } else if ( $type == 'stable' ) { |
1519 | 1524 | $rv .= FlaggedRevsLogs::stabilityLogLinks( $title, $ts ); |
1520 | 1525 | // Review log |
1521 | | - } else if( $type == 'review' && FlaggedRevsLogs::isReviewAction($action) ) { |
| 1526 | + } else if ( $type == 'review' && FlaggedRevsLogs::isReviewAction( $action ) ) { |
1522 | 1527 | $rv .= FlaggedRevsLogs::reviewLogLinks( $action, $title, $params ); |
1523 | 1528 | } |
1524 | 1529 | return true; |
— | — | @@ -1531,7 +1536,7 @@ |
1532 | 1537 | |
1533 | 1538 | public static function setActionTabs( $skin, &$contentActions ) { |
1534 | 1539 | // Note: $wgArticle sometimes not set here |
1535 | | - if( FlaggedArticleView::globalArticleInstance() != null ) { |
| 1540 | + if ( FlaggedArticleView::globalArticleInstance() != null ) { |
1536 | 1541 | $view = FlaggedArticleView::singleton(); |
1537 | 1542 | $view->setActionTabs( $skin, $contentActions ); |
1538 | 1543 | $view->setViewTabs( $skin, $contentActions ); |
— | — | @@ -1541,7 +1546,7 @@ |
1542 | 1547 | |
1543 | 1548 | public static function setNavigation( $skin, &$links ) { |
1544 | 1549 | // Note: $wgArticle sometimes not set here |
1545 | | - if( FlaggedArticleView::globalArticleInstance() != null ) { |
| 1550 | + if ( FlaggedArticleView::globalArticleInstance() != null ) { |
1546 | 1551 | $view = FlaggedArticleView::singleton(); |
1547 | 1552 | $view->setActionTabs( $skin, $links['actions'] ); |
1548 | 1553 | $view->setViewTabs( $skin, $links['views'] ); |
— | — | @@ -1561,34 +1566,34 @@ |
1562 | 1567 | &$title, $request, &$ignoreRedirect, &$target, &$article |
1563 | 1568 | ) { |
1564 | 1569 | # Get an instance on the title ($wgTitle) |
1565 | | - if( !FlaggedRevs::isPageReviewable($title) ) { |
| 1570 | + if ( !FlaggedRevs::isPageReviewable( $title ) ) { |
1566 | 1571 | return true; |
1567 | 1572 | } |
1568 | | - if( $request->getVal( 'stableid' ) ) { |
| 1573 | + if ( $request->getVal( 'stableid' ) ) { |
1569 | 1574 | $ignoreRedirect = true; |
1570 | 1575 | } else { |
1571 | 1576 | global $wgMemc, $wgParserCacheExpireTime; |
1572 | 1577 | # Try the cache... |
1573 | 1578 | $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; |
1577 | 1582 | return true; |
1578 | 1583 | } |
1579 | 1584 | $fa = FlaggedArticle::getTitleInstance( $title ); |
1580 | | - if( $srev = $fa->getStableRev() ) { |
| 1585 | + if ( $srev = $fa->getStableRev() ) { |
1581 | 1586 | $view = FlaggedArticleView::singleton(); |
1582 | 1587 | # If synced, nothing special here... |
1583 | | - if( $srev->getRevId() != $article->getLatest() && $view->pageOverride() ) { |
| 1588 | + if ( $srev->getRevId() != $article->getLatest() && $view->pageOverride() ) { |
1584 | 1589 | $text = $srev->getRevText(); |
1585 | 1590 | $redirect = $fa->followRedirectText( $text ); |
1586 | | - if( $redirect ) { |
| 1591 | + if ( $redirect ) { |
1587 | 1592 | $target = $redirect; |
1588 | 1593 | } else { |
1589 | 1594 | $ignoreRedirect = true; |
1590 | 1595 | } |
1591 | 1596 | } |
1592 | | - $data = FlaggedRevs::makeMemcObj( array($ignoreRedirect,$target) ); |
| 1597 | + $data = FlaggedRevs::makeMemcObj( array( $ignoreRedirect, $target ) ); |
1593 | 1598 | $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |
1594 | 1599 | } |
1595 | 1600 | } |
— | — | @@ -1615,7 +1620,7 @@ |
1616 | 1621 | |
1617 | 1622 | public static function onSkinAfterContent( &$data ) { |
1618 | 1623 | global $wgOut; |
1619 | | - if( $wgOut->isArticleRelated() && FlaggedArticleView::globalArticleInstance() != null ) { |
| 1624 | + if ( $wgOut->isArticleRelated() && FlaggedArticleView::globalArticleInstance() != null ) { |
1620 | 1625 | $view = FlaggedArticleView::singleton(); |
1621 | 1626 | $view->addReviewNotes( $data ); |
1622 | 1627 | $view->addReviewForm( $data ); |
— | — | @@ -1627,7 +1632,7 @@ |
1628 | 1633 | public static function addToHistQuery( $pager, &$queryInfo ) { |
1629 | 1634 | $flaggedArticle = FlaggedArticle::getArticleInstance( $pager->getArticle() ); |
1630 | 1635 | # Non-content pages cannot be validated. Stable version must exist. |
1631 | | - if( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) { |
| 1636 | + if ( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) { |
1632 | 1637 | $queryInfo['tables'][] = 'flaggedrevs'; |
1633 | 1638 | $queryInfo['fields'][] = 'fr_quality'; |
1634 | 1639 | $queryInfo['fields'][] = 'fr_user'; |
— | — | @@ -1641,11 +1646,11 @@ |
1642 | 1647 | public static function addToFileHistQuery( |
1643 | 1648 | $file, &$tables, &$fields, &$conds, &$opts, &$join_conds |
1644 | 1649 | ) { |
1645 | | - if( !$file->isLocal() ) |
| 1650 | + if ( !$file->isLocal() ) |
1646 | 1651 | return true; // local files only |
1647 | 1652 | $flaggedArticle = FlaggedArticle::getTitleInstance( $file->getTitle() ); |
1648 | 1653 | # Non-content pages cannot be validated. Stable version must exist. |
1649 | | - if( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) { |
| 1654 | + if ( $flaggedArticle->isReviewable() && $flaggedArticle->getStableRev() ) { |
1650 | 1655 | $tables[] = 'flaggedrevs'; |
1651 | 1656 | $fields[] = 'MAX(fr_quality) AS fr_quality'; |
1652 | 1657 | # Avoid duplicate rows due to multiple revs with the same sha-1 key |
— | — | @@ -1657,7 +1662,7 @@ |
1658 | 1663 | } |
1659 | 1664 | |
1660 | 1665 | public static function addToContribsQuery( $pager, &$queryInfo ) { |
1661 | | - if( FlaggedRevs::stableOnlyIfConfigured() ) |
| 1666 | + if ( FlaggedRevs::stableOnlyIfConfigured() ) |
1662 | 1667 | return true; // don't show colors if almost nothing will be highlighted |
1663 | 1668 | # Highlight flaggedrevs |
1664 | 1669 | $queryInfo['tables'][] = 'flaggedrevs'; |
— | — | @@ -1673,97 +1678,97 @@ |
1674 | 1679 | |
1675 | 1680 | public static function addToRCQuery( &$conds, &$tables, &$join_conds, $opts ) { |
1676 | 1681 | global $wgUser; |
1677 | | - if( $wgUser->isAllowed('review') ) { |
| 1682 | + if ( $wgUser->isAllowed( 'review' ) ) { |
1678 | 1683 | $tables[] = 'flaggedpage_pending'; |
1679 | 1684 | $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() ); |
1681 | 1686 | } |
1682 | 1687 | return true; |
1683 | 1688 | } |
1684 | 1689 | |
1685 | 1690 | public static function addToWatchlistQuery( &$conds, &$tables, &$join_conds, &$fields ) { |
1686 | 1691 | global $wgUser; |
1687 | | - if( $wgUser->isAllowed('review') ) { |
| 1692 | + if ( $wgUser->isAllowed( 'review' ) ) { |
1688 | 1693 | $fields[] = 'fpp_rev_id'; |
1689 | 1694 | $tables[] = 'flaggedpage_pending'; |
1690 | 1695 | $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() ); |
1692 | 1697 | } |
1693 | 1698 | return true; |
1694 | 1699 | } |
1695 | 1700 | |
1696 | 1701 | public static function addToHistLine( $history, $row, &$s, &$liClasses ) { |
1697 | 1702 | $fa = FlaggedArticle::getArticleInstance( $history->getArticle() ); |
1698 | | - if( !$fa->isReviewable() ) { |
| 1703 | + if ( !$fa->isReviewable() ) { |
1699 | 1704 | return true; // nothing to do here |
1700 | 1705 | } |
1701 | 1706 | $title = $history->getArticle()->getTitle(); |
1702 | 1707 | # Fetch and process cache the stable revision |
1703 | | - if( !isset($history->fr_stableRevId) ) { |
| 1708 | + if ( !isset( $history->fr_stableRevId ) ) { |
1704 | 1709 | $frev = $fa->getStableRev(); |
1705 | 1710 | $history->fr_stableRevId = $frev ? $frev->getRevId() : 0; |
1706 | 1711 | } |
1707 | | - if( !$history->fr_stableRevId ) { |
| 1712 | + if ( !$history->fr_stableRevId ) { |
1708 | 1713 | return true; // nothing to do here |
1709 | 1714 | } |
1710 | 1715 | // Unreviewed revision: highlight if pending |
1711 | 1716 | $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 ) { |
1714 | 1719 | $class = 'flaggedrevs-unreviewed'; |
1715 | | - $link = '<strong>'.wfMsgHtml('revreview-hist-pending').'</strong>'; |
| 1720 | + $link = '<strong>' . wfMsgHtml( 'revreview-hist-pending' ) . '</strong>'; |
1716 | 1721 | } |
1717 | 1722 | // Reviewed revision: highlight and add link |
1718 | | - } else if( !($row->rev_deleted & Revision::DELETED_TEXT) ) { |
| 1723 | + } else if ( !( $row->rev_deleted & Revision::DELETED_TEXT ) ) { |
1719 | 1724 | # 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 ); |
1721 | 1726 | # Space out and demark the stable revision |
1722 | | - if( $row->rev_id == $history->fr_stableRevId ) { |
| 1727 | + if ( $row->rev_id == $history->fr_stableRevId ) { |
1723 | 1728 | $liClasses[] = 'flaggedrevs_hist_stable'; |
1724 | 1729 | } |
1725 | 1730 | } |
1726 | 1731 | # Style the row as needed |
1727 | | - if( $class ) $s = "<span class='$class'>$s</span>"; |
| 1732 | + if ( $class ) $s = "<span class='$class'>$s</span>"; |
1728 | 1733 | # Add stable old version link |
1729 | | - if( $link ) $s .= " <small>$link</small>"; |
| 1734 | + if ( $link ) $s .= " <small>$link</small>"; |
1730 | 1735 | return true; |
1731 | 1736 | } |
1732 | 1737 | |
1733 | 1738 | public static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) { |
1734 | | - if( !$file->isVisible() ) |
| 1739 | + if ( !$file->isVisible() ) |
1735 | 1740 | return true; // Don't bother showing notice for deleted revs |
1736 | 1741 | # Quality level for old versions selected all at once. |
1737 | 1742 | # 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 ); |
1740 | 1745 | $quality = $dbr->selectField( 'flaggedrevs', 'fr_quality', |
1741 | 1746 | array( 'fr_img_sha1' => $file->getSha1(), |
1742 | 1747 | 'fr_img_timestamp' => $dbr->timestamp( $file->getTimestamp() ) ), |
1743 | 1748 | __METHOD__ |
1744 | 1749 | ); |
1745 | 1750 | } else { |
1746 | | - $quality = is_null($file->quality) ? false : $file->quality; |
| 1751 | + $quality = is_null( $file->quality ) ? false : $file->quality; |
1747 | 1752 | } |
1748 | 1753 | # If reviewed, class the line |
1749 | | - if( $quality !== false ) { |
| 1754 | + if ( $quality !== false ) { |
1750 | 1755 | $rowClass = FlaggedRevsXML::getQualityColor( $quality ); |
1751 | 1756 | } |
1752 | 1757 | return true; |
1753 | 1758 | } |
1754 | 1759 | |
1755 | 1760 | public static function addToContribsLine( $contribs, &$ret, $row ) { |
1756 | | - if( FlaggedRevs::stableOnlyIfConfigured() ) |
| 1761 | + if ( FlaggedRevs::stableOnlyIfConfigured() ) |
1757 | 1762 | return true; // don't show colors if almost nothing will be highlighted |
1758 | 1763 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
1759 | | - if( !in_array($row->page_namespace,$namespaces) ) { |
| 1764 | + if ( !in_array( $row->page_namespace, $namespaces ) ) { |
1760 | 1765 | // 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>'; |
1768 | 1773 | } |
1769 | 1774 | return true; |
1770 | 1775 | } |
— | — | @@ -1771,12 +1776,12 @@ |
1772 | 1777 | public static function addToChangeListLine( |
1773 | 1778 | &$list, &$articlelink, &$s, &$rc, $unpatrolled, $watched |
1774 | 1779 | ) { |
1775 | | - if( empty($rc->mAttribs['fpp_rev_id']) ) |
| 1780 | + if ( empty( $rc->mAttribs['fpp_rev_id'] ) ) |
1776 | 1781 | return true; // page is not listed in pending edit table |
1777 | | - if( !FlaggedRevs::isPageReviewable($rc->getTitle()) ) |
| 1782 | + if ( !FlaggedRevs::isPageReviewable( $rc->getTitle() ) ) |
1778 | 1783 | 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' ); |
1781 | 1786 | $articlelink .= " <span class='mw-fr-reviewlink'>($rlink)</span>"; |
1782 | 1787 | return true; |
1783 | 1788 | } |
— | — | @@ -1789,9 +1794,9 @@ |
1790 | 1795 | |
1791 | 1796 | // diff=review param (bug 16923) |
1792 | 1797 | public static function checkDiffUrl( $titleObj, &$mOldid, &$mNewid, $old, $new ) { |
1793 | | - if( $new === 'review' && isset($titleObj) ) { |
| 1798 | + if ( $new === 'review' && isset( $titleObj ) ) { |
1794 | 1799 | $frev = FlaggedRevision::newFromStable( $titleObj ); |
1795 | | - if( $frev ) { |
| 1800 | + if ( $frev ) { |
1796 | 1801 | $mOldid = $frev->getRevId(); // stable |
1797 | 1802 | $mNewid = 0; // cur |
1798 | 1803 | } |
— | — | @@ -1816,23 +1821,23 @@ |
1817 | 1822 | |
1818 | 1823 | public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) { |
1819 | 1824 | global $wgUser, $wgRequest; |
1820 | | - if( !$wgUser->isAllowed('review') ) { |
| 1825 | + if ( !$wgUser->isAllowed( 'review' ) ) { |
1821 | 1826 | return true; |
1822 | 1827 | } |
1823 | | - if( FlaggedRevs::autoReviewNewPages() && !$editPage->getArticle()->getId() ) { |
| 1828 | + if ( FlaggedRevs::autoReviewNewPages() && !$editPage->getArticle()->getId() ) { |
1824 | 1829 | return true; // not needed |
1825 | 1830 | } |
1826 | 1831 | $fa = FlaggedArticleView::globalArticleInstance(); |
1827 | | - if( $fa->isReviewable() && !$fa->limitedUI() ) { |
| 1832 | + if ( $fa->isReviewable() && !$fa->limitedUI() ) { |
1828 | 1833 | $srev = $fa->getStableRev(); |
1829 | 1834 | # For pages with either no stable version, or an outdated one, let |
1830 | 1835 | # the user decide if he/she wants it reviewed on the spot. One might |
1831 | 1836 | # 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' ) ); |
1834 | 1839 | $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 ) . |
1837 | 1842 | ' ' . Xml::label( $reviewLabel, 'wpReviewEdit' ); |
1838 | 1843 | } |
1839 | 1844 | } |
— | — | @@ -1842,21 +1847,21 @@ |
1843 | 1848 | public static function addBacklogNotice( &$notice ) { |
1844 | 1849 | global $wgUser, $wgTitle; |
1845 | 1850 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
1846 | | - if ( !count($namespaces) ) { |
| 1851 | + if ( !count( $namespaces ) ) { |
1847 | 1852 | return true; // nothing to have a backlog on |
1848 | 1853 | } |
1849 | | - if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) { |
| 1854 | + if ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) { |
1850 | 1855 | return true; // nothing to do here |
1851 | 1856 | } |
1852 | | - if( !$wgUser->isAllowed('review') ) |
| 1857 | + if ( !$wgUser->isAllowed( 'review' ) ) |
1853 | 1858 | return true; // not relevant to user |
1854 | | - |
| 1859 | + |
1855 | 1860 | $watchlist = SpecialPage::getTitleFor( 'Watchlist' ); |
1856 | 1861 | $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' ); |
1857 | | - if( $wgTitle->equals($watchlist) || $wgTitle->equals($recentchanges) ) { |
| 1862 | + if ( $wgTitle->equals( $watchlist ) || $wgTitle->equals( $recentchanges ) ) { |
1858 | 1863 | $dbr = wfGetDB( DB_SLAVE ); |
1859 | 1864 | $watchedOutdated = $dbr->selectField( |
1860 | | - array('watchlist','page','flaggedpages'), '1', |
| 1865 | + array( 'watchlist', 'page', 'flaggedpages' ), '1', |
1861 | 1866 | array( 'wl_user' => $wgUser->getId(), // this user |
1862 | 1867 | 'wl_namespace' => $namespaces, // reviewable |
1863 | 1868 | 'wl_namespace = page_namespace', |
— | — | @@ -1866,26 +1871,26 @@ |
1867 | 1872 | ), __METHOD__ |
1868 | 1873 | ); |
1869 | 1874 | # 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>"; |
1873 | 1878 | # Otherwise, give a notice if there is a large backlog in general |
1874 | 1879 | } else { |
1875 | 1880 | $pages = $dbr->estimateRowCount( 'page', '*', |
1876 | | - array('page_namespace' => $namespaces), __METHOD__ ); |
| 1881 | + array( 'page_namespace' => $namespaces ), __METHOD__ ); |
1877 | 1882 | # For small wikis, just get the real numbers to avoid some bogus messages |
1878 | | - if( $pages < 50 ) { |
| 1883 | + if ( $pages < 50 ) { |
1879 | 1884 | $pages = $dbr->selectField( 'page', 'COUNT(*)', |
1880 | | - array('page_namespace' => $namespaces), __METHOD__ ); |
| 1885 | + array( 'page_namespace' => $namespaces ), __METHOD__ ); |
1881 | 1886 | $unreviewed = $dbr->selectField( 'flaggedpages', 'COUNT(*)', |
1882 | 1887 | 'fp_pending_since IS NOT NULL', __METHOD__ ); |
1883 | 1888 | } else { |
1884 | 1889 | $unreviewed = $dbr->estimateRowCount( 'flaggedpages', '*', |
1885 | 1890 | 'fp_pending_since IS NOT NULL', __METHOD__ ); |
1886 | 1891 | } |
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>"; |
1890 | 1895 | } |
1891 | 1896 | } |
1892 | 1897 | } |
— | — | @@ -1894,13 +1899,13 @@ |
1895 | 1900 | |
1896 | 1901 | public static function stableDumpQuery( &$tables, &$opts, &$join ) { |
1897 | 1902 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
1898 | | - $tables = array('flaggedpages','page','revision'); |
| 1903 | + $tables = array( 'flaggedpages', 'page', 'revision' ); |
1899 | 1904 | $opts['ORDER BY'] = 'fp_page_id ASC'; |
1900 | 1905 | $opts['USE INDEX'] = array( 'flaggedpages' => 'PRIMARY' ); |
1901 | 1906 | $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 ) |
1903 | 1908 | ); |
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' ); |
1905 | 1910 | return false; // final |
1906 | 1911 | } |
1907 | 1912 | |
— | — | @@ -1908,22 +1913,22 @@ |
1909 | 1914 | // Code stolen from Stabilization (which was stolen from ProtectionForm) |
1910 | 1915 | public static function onProtectionForm( $article, &$output ) { |
1911 | 1916 | global $wgUser, $wgRequest, $wgOut, $wgLang; |
1912 | | - if( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { |
| 1917 | + if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { |
1913 | 1918 | return true; // nothing to do |
1914 | | - } else if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
| 1919 | + } else if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
1915 | 1920 | return true; // not a reviewable page |
1916 | 1921 | } |
1917 | 1922 | # Can the user actually do anything? |
1918 | | - $isAllowed = $wgUser->isAllowed('stablesettings'); |
| 1923 | + $isAllowed = $wgUser->isAllowed( 'stablesettings' ); |
1919 | 1924 | $disabledAttrib = !$isAllowed ? array( 'disabled' => 'disabled' ) : array(); |
1920 | 1925 | # Get the current config/expiry |
1921 | 1926 | $config = FlaggedRevs::getPageVisibilitySettings( $article->getTitle(), true ); |
1922 | | - $oldExpiry = $config['expiry'] !== 'infinity' ? |
| 1927 | + $oldExpiry = $config['expiry'] !== 'infinity' ? |
1923 | 1928 | wfTimestamp( TS_RFC2822, $config['expiry'] ) : 'infinite'; |
1924 | 1929 | # Load request params... |
1925 | 1930 | $selected = $wgRequest->getVal( 'wpStabilityConfig', |
1926 | | - FlaggedRevs::getProtectionLevel($config) ); |
1927 | | - if( $selected == 'invalid' ) { |
| 1931 | + FlaggedRevs::getProtectionLevel( $config ) ); |
| 1932 | + if ( $selected == 'invalid' ) { |
1928 | 1933 | throw new MWException( 'This page has an undefined stability configuration!' ); |
1929 | 1934 | } |
1930 | 1935 | $expiry = $wgRequest->getText( 'mwStabilize-expiry' ); |
— | — | @@ -1933,8 +1938,8 @@ |
1934 | 1939 | function updateStabilizationDropdowns() { |
1935 | 1940 | val = document.getElementById('mwExpirySelection').value; |
1936 | 1941 | if( val == 'existing' ) |
1937 | | - document.getElementById('mwStabilize-expiry').value = ". |
1938 | | - Xml::encodeJsVar($oldExpiry)."; |
| 1942 | + document.getElementById('mwStabilize-expiry').value = " . |
| 1943 | + Xml::encodeJsVar( $oldExpiry ) . "; |
1939 | 1944 | else if( val != 'othertime' ) |
1940 | 1945 | document.getElementById('mwStabilize-expiry').value = val; |
1941 | 1946 | } |
— | — | @@ -1943,7 +1948,7 @@ |
1944 | 1949 | # Add an extra row to the protection fieldset tables |
1945 | 1950 | $output .= "<tr><td>"; |
1946 | 1951 | $output .= Xml::openElement( 'fieldset' ); |
1947 | | - $output .= Xml::element( 'legend', null, wfMsg('flaggedrevs-protect-legend') ); |
| 1952 | + $output .= Xml::element( 'legend', null, wfMsg( 'flaggedrevs-protect-legend' ) ); |
1948 | 1953 | # Add a "no restrictions" level |
1949 | 1954 | $effectiveLevels = array( "none" => null ); |
1950 | 1955 | $effectiveLevels += FlaggedRevs::getProtectionLevels(); |
— | — | @@ -1955,32 +1960,32 @@ |
1956 | 1961 | ) + $disabledAttrib; |
1957 | 1962 | $output .= Xml::openElement( 'select', $attribs ); |
1958 | 1963 | # 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' ) { |
1961 | 1966 | $label = FlaggedRevs::stableOnlyIfConfigured() |
1962 | 1967 | ? wfMsg( 'flaggedrevs-protect-none' ) |
1963 | 1968 | : wfMsg( 'flaggedrevs-protect-basic' ); |
1964 | 1969 | } else { |
1965 | | - $label = wfMsg( 'flaggedrevs-protect-'.$level ); |
| 1970 | + $label = wfMsg( 'flaggedrevs-protect-' . $level ); |
1966 | 1971 | } |
1967 | 1972 | // 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; |
1970 | 1975 | } |
1971 | 1976 | $output .= Xml::option( $label, $level, $level == $selected ); |
1972 | 1977 | } |
1973 | 1978 | $output .= Xml::closeElement( 'select' ); |
1974 | 1979 | # Get expiry dropdown |
1975 | 1980 | $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' ); |
1976 | | - $showProtectOptions = ($scExpiryOptions !== '-' && $isAllowed); |
| 1981 | + $showProtectOptions = ( $scExpiryOptions !== '-' && $isAllowed ); |
1977 | 1982 | # Add the current expiry as an option |
1978 | 1983 | $expiryFormOptions = ''; |
1979 | | - if( $config['expiry'] && $config['expiry'] != 'infinity' ) { |
| 1984 | + if ( $config['expiry'] && $config['expiry'] != 'infinity' ) { |
1980 | 1985 | $timestamp = $wgLang->timeanddate( $config['expiry'] ); |
1981 | 1986 | $d = $wgLang->date( $config['expiry'] ); |
1982 | 1987 | $t = $wgLang->time( $config['expiry'] ); |
1983 | | - $expiryFormOptions .= |
1984 | | - Xml::option( |
| 1988 | + $expiryFormOptions .= |
| 1989 | + Xml::option( |
1985 | 1990 | wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ), |
1986 | 1991 | 'existing', |
1987 | 1992 | $config['expiry'] == 'existing' |
— | — | @@ -1988,25 +1993,25 @@ |
1989 | 1994 | } |
1990 | 1995 | $expiryFormOptions .= Xml::option( wfMsg( 'protect-othertime-op' ), "othertime" ) . "\n"; |
1991 | 1996 | # 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 ) { |
1994 | 1999 | $show = $value = $option; |
1995 | 2000 | } else { |
1996 | | - list($show, $value) = explode(":",$option); |
| 2001 | + list( $show, $value ) = explode( ":", $option ); |
1997 | 2002 | } |
1998 | | - $show = htmlspecialchars($show); |
1999 | | - $value = htmlspecialchars($value); |
| 2003 | + $show = htmlspecialchars( $show ); |
| 2004 | + $value = htmlspecialchars( $value ); |
2000 | 2005 | $expiryFormOptions .= Xml::option( $show, $value, $config['expiry'] === $value )."\n"; |
2001 | 2006 | } |
2002 | 2007 | # Add expiry dropdown to form |
2003 | 2008 | $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' ); |
2004 | | - $showProtectOptions = ($scExpiryOptions !== '-' && $isAllowed); |
| 2009 | + $showProtectOptions = ( $scExpiryOptions !== '-' && $isAllowed ); |
2005 | 2010 | $output .= "<table>"; // expiry table start |
2006 | | - if( $showProtectOptions && $isAllowed ) { |
| 2011 | + if ( $showProtectOptions && $isAllowed ) { |
2007 | 2012 | $output .= " |
2008 | 2013 | <tr> |
2009 | 2014 | <td class='mw-label'>" . |
2010 | | - Xml::label( wfMsg('stabilization-expiry'), 'mwExpirySelection' ) . |
| 2015 | + Xml::label( wfMsg( 'stabilization-expiry' ), 'mwExpirySelection' ) . |
2011 | 2016 | "</td> |
2012 | 2017 | <td class='mw-input'>" . |
2013 | 2018 | Xml::tags( 'select', |
— | — | @@ -2025,7 +2030,7 @@ |
2026 | 2031 | $output .= " |
2027 | 2032 | <tr> |
2028 | 2033 | <td class='mw-label'>" . |
2029 | | - Xml::label( wfMsg('stabilization-othertime'), 'mwStabilize-expiry' ) . |
| 2034 | + Xml::label( wfMsg( 'stabilization-othertime' ), 'mwStabilize-expiry' ) . |
2030 | 2035 | '</td> |
2031 | 2036 | <td class="mw-input">' . |
2032 | 2037 | Xml::input( "mwStabilize-expiry", 50, |
— | — | @@ -2041,13 +2046,13 @@ |
2042 | 2047 | |
2043 | 2048 | // Add stability log extract to protection form |
2044 | 2049 | public static function insertStabilityLog( $article, $out ) { |
2045 | | - if( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { |
| 2050 | + if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { |
2046 | 2051 | return true; // nothing to do |
2047 | | - } else if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
| 2052 | + } else if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
2048 | 2053 | return true; // not a reviewable page |
2049 | 2054 | } |
2050 | 2055 | # 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' ) ) ); |
2052 | 2057 | LogEventsList::showLogExtract( $out, 'stable', $article->getTitle()->getPrefixedText() ); |
2053 | 2058 | return true; |
2054 | 2059 | } |
— | — | @@ -2056,12 +2061,12 @@ |
2057 | 2062 | public static function onProtectionSave( $article, &$errorMsg ) { |
2058 | 2063 | global $wgUser, $wgRequest; |
2059 | 2064 | $levels = FlaggedRevs::getProtectionLevels(); |
2060 | | - if( empty($levels) || !$article->exists() ) |
| 2065 | + if ( empty( $levels ) || !$article->exists() ) |
2061 | 2066 | return true; // simple custom levels set for action=protect |
2062 | | - if( wfReadOnly() || !$wgUser->isAllowed('stablesettings') ) { |
| 2067 | + if ( wfReadOnly() || !$wgUser->isAllowed( 'stablesettings' ) ) { |
2063 | 2068 | return true; // user cannot change anything |
2064 | 2069 | } |
2065 | | - if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
| 2070 | + if ( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) { |
2066 | 2071 | return true; // not a reviewable page |
2067 | 2072 | } |
2068 | 2073 | $form = new Stabilization(); |
— | — | @@ -2073,12 +2078,12 @@ |
2074 | 2079 | $form->expirySelection = $wgRequest->getVal( 'wpExpirySelection' ); # Expiry dropdown |
2075 | 2080 | # Fill in config from the protection level... |
2076 | 2081 | $selected = $wgRequest->getVal( 'mwStabilityConfig' ); |
2077 | | - if( $selected == "none" ) { |
| 2082 | + if ( $selected == "none" ) { |
2078 | 2083 | $form->select = FlaggedRevs::getPrecedence(); // default |
2079 | 2084 | $form->override = (int)FlaggedRevs::isStableShownByDefault(); // default |
2080 | 2085 | $form->autoreview = ''; // default |
2081 | 2086 | $form->reviewThis = false; |
2082 | | - } else if( isset($levels[$selected]) ) { |
| 2087 | + } else if ( isset( $levels[$selected] ) ) { |
2083 | 2088 | $form->select = $levels[$selected]['select']; |
2084 | 2089 | $form->override = $levels[$selected]['override']; |
2085 | 2090 | $form->autoreview = $levels[$selected]['autoreview']; |
— | — | @@ -2087,10 +2092,10 @@ |
2088 | 2093 | return false; // bad level |
2089 | 2094 | } |
2090 | 2095 | $form->wasPosted = $wgRequest->wasPosted(); |
2091 | | - if( $form->handleParams() ) { |
| 2096 | + if ( $form->handleParams() ) { |
2092 | 2097 | $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 |
2095 | 2100 | } |
2096 | 2101 | } |
2097 | 2102 | return true; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsLogs.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | */ |
9 | 9 | public static function isReviewAction( $action ) { |
10 | 10 | return in_array( $action, |
11 | | - array('approve','approve2','approve-a', 'approve2-a','unapprove','unapprove2') |
| 11 | + array( 'approve', 'approve2', 'approve-a', 'approve2-a', 'unapprove', 'unapprove2' ) |
12 | 12 | ); |
13 | 13 | } |
14 | 14 | |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | * $action is a valid review log deprecate action |
18 | 18 | */ |
19 | 19 | public static function isReviewDeapproval( $action ) { |
20 | | - return ($action == 'unapprove' || $action == 'unapprove2'); |
| 20 | + return ( $action == 'unapprove' || $action == 'unapprove2' ); |
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | # Add history link showing edits right before the config change |
32 | 32 | $links = ' ('; |
33 | 33 | $links .= $wgUser->getSkin()->link( $title, |
34 | | - wfMsgHtml('hist'), |
| 34 | + wfMsgHtml( 'hist' ), |
35 | 35 | array(), |
36 | 36 | array( 'action' => 'history', 'offset' => $timestamp ) ); |
37 | 37 | $links .= ')'; |
— | — | @@ -45,28 +45,28 @@ |
46 | 46 | $links = ''; |
47 | 47 | # Show link to page with oldid=x as well as the diff to the former stable rev. |
48 | 48 | # Param format is <rev id, last stable id, rev timestamp>. |
49 | | - if( isset($params[0]) ) { |
| 49 | + if ( isset( $params[0] ) ) { |
50 | 50 | $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; |
52 | 52 | # Show diff to changes since the prior stable version |
53 | | - if( $oldStable && $revId > $oldStable ) { |
| 53 | + if ( $oldStable && $revId > $oldStable ) { |
54 | 54 | $msg = self::isReviewDeapproval( $action ) |
55 | 55 | ? 'review-logentry-diff2' // unreviewed |
56 | 56 | : 'review-logentry-diff'; // reviewed |
57 | 57 | $links .= '('; |
58 | 58 | $links .= $wgUser->getSkin()->makeKnownLinkObj( $title, |
59 | | - wfMsgHtml($msg), |
| 59 | + wfMsgHtml( $msg ), |
60 | 60 | "oldid={$oldStable}&diff={$revId}" ); |
61 | 61 | $links .= ')'; |
62 | 62 | } |
63 | 63 | # 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 ) |
66 | 66 | : $params[2]; |
67 | 67 | $time = $wgLang->timeanddate( $ts ); |
68 | 68 | $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 ), |
71 | 71 | "oldid={$revId}&diff=prev&diffonly=0" ); |
72 | 72 | $links .= ')'; |
73 | 73 | } |
— | — | @@ -84,8 +84,8 @@ |
85 | 85 | * @param bool $approve, approved? (otherwise unapproved) |
86 | 86 | * @param bool $auto |
87 | 87 | */ |
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 ) |
90 | 90 | { |
91 | 91 | global $wgFlaggedRevsLogInRC; |
92 | 92 | $log = new LogPage( 'review', |
— | — | @@ -95,42 +95,42 @@ |
96 | 96 | # Tag rating list (e.g. accuracy=x, depth=y, style=z) |
97 | 97 | $ratings = array(); |
98 | 98 | # 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 ) { |
101 | 101 | $ratings[] = wfMsgForContent( "revreview-$quality" ) . |
102 | | - wfMsgForContent( 'colon-separator' ) . |
103 | | - wfMsgForContent("revreview-$quality-$level" ); |
| 102 | + wfMsgForContent( 'colon-separator' ) . |
| 103 | + wfMsgForContent( "revreview-$quality-$level" ); |
104 | 104 | } |
105 | 105 | } |
106 | | - $isAuto = ($auto && !FlaggedRevs::isQuality($dims)); // Paranoid check |
| 106 | + $isAuto = ( $auto && !FlaggedRevs::isQuality( $dims ) ); // Paranoid check |
107 | 107 | // 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 |
111 | 111 | } |
112 | 112 | # Make comma-separated list of ratings |
113 | | - $rating = !empty($ratings) |
114 | | - ? '[' . implode(', ',$ratings). ']' |
| 113 | + $rating = !empty( $ratings ) |
| 114 | + ? '[' . implode( ', ', $ratings ) . ']' |
115 | 115 | : ''; |
116 | 116 | # Append comment with ratings |
117 | | - if( $rating != '' ) { |
| 117 | + if ( $rating != '' ) { |
118 | 118 | $comment .= $comment ? " $rating" : $rating; |
119 | 119 | } |
120 | 120 | # Sort into the proper action (useful for filtering) |
121 | | - $action = (FlaggedRevs::isQuality($dims) || FlaggedRevs::isQuality($oldDims)) ? |
| 121 | + $action = ( FlaggedRevs::isQuality( $dims ) || FlaggedRevs::isQuality( $oldDims ) ) ? |
122 | 122 | 'approve2' : 'approve'; |
123 | | - if( !$stableId ) { // first time |
| 123 | + if ( !$stableId ) { // first time |
124 | 124 | $action .= $isAuto ? "-ia" : "-i"; |
125 | | - } elseif( $isAuto ) { // automatic |
| 125 | + } elseif ( $isAuto ) { // automatic |
126 | 126 | $action .= "-a"; |
127 | 127 | } |
128 | 128 | // De-approved revisions |
129 | 129 | } else { |
130 | | - $action = FlaggedRevs::isQuality($oldDims) ? |
| 130 | + $action = FlaggedRevs::isQuality( $oldDims ) ? |
131 | 131 | 'unapprove2' : 'unapprove'; |
132 | 132 | } |
133 | 133 | $ts = Revision::getTimestampFromId( $title, $revId ); |
134 | 134 | # 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 ) ); |
136 | 136 | } |
137 | 137 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -16,21 +16,21 @@ |
17 | 17 | * Get the FlaggedArticleView for this request |
18 | 18 | */ |
19 | 19 | public static function singleton() { |
20 | | - if( self::$instance == null ) { |
| 20 | + if ( self::$instance == null ) { |
21 | 21 | self::$instance = new self(); |
22 | 22 | } |
23 | 23 | return self::$instance; |
24 | 24 | } |
25 | | - protected function __construct() {} |
26 | | - protected function __clone() {} |
| 25 | + protected function __construct() { } |
| 26 | + protected function __clone() { } |
27 | 27 | |
28 | 28 | /* |
29 | 29 | * Load the global FlaggedArticle instance |
30 | 30 | */ |
31 | 31 | protected function load() { |
32 | | - if( !$this->loaded ) { |
| 32 | + if ( !$this->loaded ) { |
33 | 33 | $this->article = self::globalArticleInstance(); |
34 | | - if( $this->article == null ) { |
| 34 | + if ( $this->article == null ) { |
35 | 35 | throw new MWException( 'FlaggedArticleViewer has no context article!' ); |
36 | 36 | } |
37 | 37 | } |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | */ |
44 | 44 | public static function globalArticleInstance() { |
45 | 45 | global $wgTitle; |
46 | | - if( !empty( $wgTitle ) ) { |
| 46 | + if ( !empty( $wgTitle ) ) { |
47 | 47 | return FlaggedArticle::getTitleInstance( $wgTitle ); |
48 | 48 | } |
49 | 49 | return null; |
— | — | @@ -57,28 +57,28 @@ |
58 | 58 | $this->load(); |
59 | 59 | # This only applies to viewing content pages |
60 | 60 | $action = $wgRequest->getVal( 'action', 'view' ); |
61 | | - if( !self::isViewAction($action) || !$this->article->isReviewable() ) |
| 61 | + if ( !self::isViewAction( $action ) || !$this->article->isReviewable() ) |
62 | 62 | return false; |
63 | 63 | # Does not apply to diffs/old revision... |
64 | | - if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) |
| 64 | + if ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'diff' ) ) |
65 | 65 | return false; |
66 | 66 | # Explicit requests for a certain stable version handled elsewhere... |
67 | | - if( $wgRequest->getVal('stableid') ) |
| 67 | + if ( $wgRequest->getVal( 'stableid' ) ) |
68 | 68 | return false; |
69 | 69 | # 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 ); |
72 | 72 | # Get page configuration |
73 | 73 | $config = $this->article->getVisibilitySettings(); |
74 | 74 | # 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 ); |
78 | 78 | } |
79 | 79 | # Viewer sees stable by default |
80 | | - return !( $wgRequest->getIntOrNull('stable') === 0 ); |
| 80 | + return !( $wgRequest->getIntOrNull( 'stable' ) === 0 ); |
81 | 81 | # We are explicity requesting the stable version? |
82 | | - } elseif( $wgRequest->getIntOrNull('stable') === 1 ) { |
| 82 | + } elseif ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) { |
83 | 83 | return true; |
84 | 84 | } |
85 | 85 | return false; |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | public function isDiffShownOnEdit() { |
103 | 103 | global $wgUser; |
104 | 104 | $this->load(); |
105 | | - return ( $wgUser->isAllowed('review') || $this->isStableShownByDefaultUser() ); |
| 105 | + return ( $wgUser->isAllowed( 'review' ) || $this->isStableShownByDefaultUser() ); |
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | global $wgOut, $wgRequest; |
123 | 123 | $this->load(); |
124 | 124 | // UI may be limited to unobtrusive patrolling system |
125 | | - if( $wgRequest->getVal('stableid') || !$this->article->limitedUI() ) { |
| 125 | + if ( $wgRequest->getVal( 'stableid' ) || !$this->article->limitedUI() ) { |
126 | 126 | $wgOut->appendSubtitle( $this->reviewNotice ); |
127 | 127 | } |
128 | 128 | return true; |
— | — | @@ -136,23 +136,23 @@ |
137 | 137 | global $wgRequest, $wgOut, $wgLang; |
138 | 138 | $this->load(); |
139 | 139 | # 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() ) |
141 | 141 | return true; |
142 | 142 | # We may have nav links like "direction=prev&oldid=x" |
143 | 143 | $revID = $this->article->getOldIDFromRequest(); |
144 | 144 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $revID ); |
145 | 145 | # Give a notice if this rev ID corresponds to a reviewed version... |
146 | | - if( !is_null($frev) ) { |
| 146 | + if ( !is_null( $frev ) ) { |
147 | 147 | $time = $wgLang->date( $frev->getTimestamp(), true ); |
148 | 148 | $flags = $frev->getTags(); |
149 | 149 | $quality = FlaggedRevs::isQuality( $flags ); |
150 | 150 | $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 ); |
152 | 152 | # Hide clutter |
153 | | - if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) { |
154 | | - $tag .= " " . FlaggedRevsXML::ratingToggle() . |
| 153 | + if ( !FlaggedRevs::useSimpleUI() && !empty( $flags ) ) { |
| 154 | + $tag .= " " . FlaggedRevsXML::ratingToggle() . |
155 | 155 | "<span id='mw-fr-revisionratings' style='display:block;'><br />" . |
156 | | - wfMsgHtml('revreview-oldrating') . |
| 156 | + wfMsgHtml( 'revreview-oldrating' ) . |
157 | 157 | FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
158 | 158 | } |
159 | 159 | $css = 'flaggedrevs_notice plainlinks noprint'; |
— | — | @@ -167,8 +167,8 @@ |
168 | 168 | */ |
169 | 169 | protected function getRequestedStableId() { |
170 | 170 | global $wgRequest; |
171 | | - $reqId = $wgRequest->getVal('stableid'); |
172 | | - if( $reqId === "best" ) { |
| 171 | + $reqId = $wgRequest->getVal( 'stableid' ); |
| 172 | + if ( $reqId === "best" ) { |
173 | 173 | $reqId = FlaggedRevs::getPrimeFlaggedRevId( $this->article ); |
174 | 174 | } |
175 | 175 | return $reqId; |
— | — | @@ -184,14 +184,14 @@ |
185 | 185 | $this->load(); |
186 | 186 | # Only trigger on article view for content pages, not for protect/delete/hist... |
187 | 187 | $action = $wgRequest->getVal( 'action', 'view' ); |
188 | | - if( !self::isViewAction($action) || !$this->article->exists() ) |
| 188 | + if ( !self::isViewAction( $action ) || !$this->article->exists() ) |
189 | 189 | return true; |
190 | 190 | # 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' ) ) { |
192 | 192 | return true; |
193 | 193 | } |
194 | 194 | # Only trigger for reviewable pages |
195 | | - if( !$this->article->isReviewable() ) { |
| 195 | + if ( !$this->article->isReviewable() ) { |
196 | 196 | return true; |
197 | 197 | } |
198 | 198 | $simpleTag = $old = $stable = false; |
— | — | @@ -202,15 +202,15 @@ |
203 | 203 | $frev = $srev; // $frev is the revision we are looking at |
204 | 204 | # Check for any explicitly requested old stable version... |
205 | 205 | $reqId = $this->getRequestedStableId(); |
206 | | - if( $reqId ) { |
207 | | - if( !$stableId ) { |
| 206 | + if ( $reqId ) { |
| 207 | + if ( !$stableId ) { |
208 | 208 | $reqId = false; // must be invalid |
209 | 209 | # Treat requesting the stable version by ID as &stable=1 |
210 | | - } else if( $reqId != $stableId ) { |
| 210 | + } else if ( $reqId != $stableId ) { |
211 | 211 | $old = true; // old reviewed version requested by ID |
212 | 212 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), |
213 | 213 | $reqId, FR_TEXT ); |
214 | | - if( !$frev ) { |
| 214 | + if ( !$frev ) { |
215 | 215 | $reqId = false; // invalid ID given |
216 | 216 | } |
217 | 217 | } else { |
— | — | @@ -218,8 +218,8 @@ |
219 | 219 | } |
220 | 220 | } |
221 | 221 | // $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' ) ); |
224 | 224 | $wgOut->returnToMain( false, $this->article->getTitle() ); |
225 | 225 | # Tell MW that parser output is done |
226 | 226 | $outputDone = true; |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | // Is the page config altered? |
231 | 231 | $prot = FlaggedRevsXML::lockStatusIcon( $this->article ); |
232 | 232 | // Is there no stable version? |
233 | | - if( is_null($frev) ) { |
| 233 | + if ( is_null( $frev ) ) { |
234 | 234 | # Add "no reviewed version" tag, but not for printable output |
235 | 235 | $this->showUnreviewedPage( $tag, $prot ); |
236 | 236 | return true; |
— | — | @@ -244,13 +244,13 @@ |
245 | 245 | // set to override given the relevant conditions. If the user is |
246 | 246 | // requesting the stable revision ("&stableid=x"), defer to override |
247 | 247 | // behavior below, since it is the same as ("&stable=1"). |
248 | | - if( $old ) { |
| 248 | + if ( $old ) { |
249 | 249 | $this->showOldReviewedVersion( $srev, $frev, $tag, $prot ); |
250 | 250 | $outputDone = true; # Tell MW that parser output is done |
251 | 251 | $pcache = false; |
252 | 252 | // Stable version requested by ID or relevant conditions met to |
253 | 253 | // to override page view. |
254 | | - } else if( $stable || $this->pageOverride() ) { |
| 254 | + } else if ( $stable || $this->pageOverride() ) { |
255 | 255 | $this->showStableVersion( $srev, $tag, $prot ); |
256 | 256 | $outputDone = true; # Tell MW that parser output is done |
257 | 257 | $pcache = false; |
— | — | @@ -261,13 +261,13 @@ |
262 | 262 | $this->showDraftVersion( $srev, $tag, $prot ); |
263 | 263 | } |
264 | 264 | # 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'; |
269 | 269 | else $tagClass = 'flaggedrevs_basic'; |
270 | 270 | # Wrap tag contents in a div |
271 | | - if( $tag != '' ) { |
| 271 | + if ( $tag != '' ) { |
272 | 272 | $rtl = $wgContLang->isRTL() ? " rtl" : ""; // RTL langauges |
273 | 273 | $tag = "<div id='mw-fr-revisiontag' class='{$tagClass}{$rtl} plainlinks noprint'>" . |
274 | 274 | "$tag</div>"; |
— | — | @@ -281,19 +281,19 @@ |
282 | 282 | * @param $tag review box/bar info |
283 | 283 | * @param $prot protection notice |
284 | 284 | * Tag output function must be called by caller |
285 | | - */ |
| 285 | + */ |
286 | 286 | protected function showUnreviewedPage( $tag, $prot ) { |
287 | 287 | global $wgOut, $wgContLang; |
288 | | - if( $wgOut->isPrintable() ) { |
| 288 | + if ( $wgOut->isPrintable() ) { |
289 | 289 | return; |
290 | 290 | } |
291 | 291 | // Simple icon-based UI |
292 | | - if( FlaggedRevs::useSimpleUI() ) { |
| 292 | + if ( FlaggedRevs::useSimpleUI() ) { |
293 | 293 | // RTL langauges |
294 | 294 | $rtl = $wgContLang->isRTL() ? " rtl" : ""; |
295 | 295 | $msg = 'revreview-quick-none'; |
296 | 296 | $tag .= "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
297 | | - wfMsgExt($msg,array('parseinline')); |
| 297 | + wfMsgExt( $msg, array( 'parseinline' ) ); |
298 | 298 | $css = 'flaggedrevs_short{$rtl} plainlinks noprint'; |
299 | 299 | $tag = "<div id='mw-fr-revisiontag' class='$css'>" . |
300 | 300 | "$tag</div>"; |
— | — | @@ -304,7 +304,7 @@ |
305 | 305 | $css = 'flaggedrevs_notice plainlinks noprint'; |
306 | 306 | $tag = "<div id='mw-fr-revisiontag' class='$css'>" . |
307 | 307 | "{$prot}<span class='fr-icon-current plainlinks'></span>" . |
308 | | - wfMsgExt($msg, array('parseinline')) . "</div>"; |
| 308 | + wfMsgExt( $msg, array( 'parseinline' ) ) . "</div>"; |
309 | 309 | $this->reviewNotice .= $tag; |
310 | 310 | } |
311 | 311 | } |
— | — | @@ -326,7 +326,7 @@ |
327 | 327 | $pristine = FlaggedRevs::isPristine( $flags ); |
328 | 328 | # Get stable version sync status |
329 | 329 | $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article ); |
330 | | - if( $synced ) { |
| 330 | + if ( $synced ) { |
331 | 331 | $this->setReviewNotes( $srev ); // Still the same |
332 | 332 | } else { |
333 | 333 | $this->maybeShowTopDiff( $srev, $quality ); // user may want diff (via prefs) |
— | — | @@ -334,11 +334,11 @@ |
335 | 335 | # If they are synced, do special styling |
336 | 336 | $simpleTag = !$synced; |
337 | 337 | # 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' ) ) { |
339 | 339 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() ); |
340 | | - $tooltip = wfMsgHtml('revreview-draft-title'); |
| 340 | + $tooltip = wfMsgHtml( 'revreview-draft-title' ); |
341 | 341 | $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 ); |
343 | 343 | $pending = "<div id='mw-fr-reviewnotice' class='flaggedrevs_preview plainlinks'>" . |
344 | 344 | "$pending</div>"; |
345 | 345 | # Notice should always use subtitle |
— | — | @@ -346,15 +346,15 @@ |
347 | 347 | # Construct some tagging for non-printable outputs. Note that the pending |
348 | 348 | # notice has all this info already, so don't do this if we added that already. |
349 | 349 | # 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 ) ) { |
351 | 351 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() ); |
352 | 352 | $class = 'fr-icon-current'; // default |
353 | 353 | $tooltip = 'revreview-draft-title'; |
354 | 354 | // Simple icon-based UI |
355 | | - if( FlaggedRevs::useSimpleUI() ) { |
356 | | - if( !$wgUser->getId() ) { |
| 355 | + if ( FlaggedRevs::useSimpleUI() ) { |
| 356 | + if ( !$wgUser->getId() ) { |
357 | 357 | $msgHTML = ''; // Anons just see simple icons |
358 | | - } else if( $synced ) { |
| 358 | + } else if ( $synced ) { |
359 | 359 | $msg = $quality |
360 | 360 | ? 'revreview-quick-quality-same' |
361 | 361 | : 'revreview-quick-basic-same'; |
— | — | @@ -364,23 +364,23 @@ |
365 | 365 | $tooltip = $quality |
366 | 366 | ? 'revreview-quality-title' |
367 | 367 | : 'revreview-stable-title'; |
368 | | - $msgHTML = wfMsgExt( $msg, array('parseinline'), |
| 368 | + $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), |
369 | 369 | $srev->getRevId(), $revsSince ); |
370 | 370 | } else { |
371 | 371 | $msg = $quality |
372 | 372 | ? 'revreview-quick-see-quality' |
373 | 373 | : 'revreview-quick-see-basic'; |
374 | | - $msgHTML = wfMsgExt( $msg, array('parseinline'), |
| 374 | + $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), |
375 | 375 | $srev->getRevId(), $revsSince ); |
376 | 376 | } |
377 | | - $tooltip = wfMsgHtml($tooltip); |
| 377 | + $tooltip = wfMsgHtml( $tooltip ); |
378 | 378 | $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>$msgHTML"; |
379 | 379 | $tag .= FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML, |
380 | 380 | $revsSince, 'draft', $synced, false ); |
381 | 381 | // Standard UI |
382 | 382 | } else { |
383 | | - if( $synced ) { |
384 | | - if( $quality ) { |
| 383 | + if ( $synced ) { |
| 384 | + if ( $quality ) { |
385 | 385 | $msg = 'revreview-quality-same'; |
386 | 386 | $class = 'fr-icon-quality'; |
387 | 387 | $tooltip = 'revreview-quality-title'; |
— | — | @@ -389,22 +389,22 @@ |
390 | 390 | $class = 'fr-icon-stable'; |
391 | 391 | $tooltip = 'revreview-stable-title'; |
392 | 392 | } |
393 | | - $msgHTML = wfMsgExt( $msg, array('parseinline'), |
| 393 | + $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), |
394 | 394 | $srev->getRevId(), $time, $revsSince ); |
395 | 395 | } else { |
396 | 396 | $msg = $quality |
397 | 397 | ? 'revreview-newest-quality' |
398 | 398 | : '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' ), |
401 | 401 | $srev->getRevId(), $time, $revsSince ); |
402 | 402 | } |
403 | | - $tooltip = wfMsgHtml($tooltip); |
| 403 | + $tooltip = wfMsgHtml( $tooltip ); |
404 | 404 | $tag .= "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" . $msgHTML; |
405 | 405 | } |
406 | 406 | } |
407 | 407 | # Index the stable version only if it is the default |
408 | | - if( $this->article->isStableShownByDefault() ) { |
| 408 | + if ( $this->article->isStableShownByDefault() ) { |
409 | 409 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
410 | 410 | } |
411 | 411 | } |
— | — | @@ -430,12 +430,12 @@ |
431 | 431 | $text = $frev->getRevText(); |
432 | 432 | # Check if this is a redirect... |
433 | 433 | $redirHtml = $this->getRedirectHtml( $text ); |
434 | | - if( $redirHtml == '' ) { |
| 434 | + if ( $redirHtml == '' ) { |
435 | 435 | $parserOut = FlaggedRevs::parseStableText( $this->article, $text, $frev->getRevId() ); |
436 | 436 | } |
437 | 437 | # Construct some tagging for non-printable outputs. Note that the pending |
438 | 438 | # notice has all this info already, so don't do this if we added that already. |
439 | | - if( !$wgOut->isPrintable() ) { |
| 439 | + if ( !$wgOut->isPrintable() ) { |
440 | 440 | $class = $quality ? |
441 | 441 | 'fr-icon-quality' : 'fr-icon-stable'; |
442 | 442 | $tooltip = $quality |
— | — | @@ -443,15 +443,15 @@ |
444 | 444 | : 'revreview-stable-title'; |
445 | 445 | $tooltip = wfMsgHtml( $tooltip ); |
446 | 446 | // Simple icon-based UI |
447 | | - if( FlaggedRevs::useSimpleUI() ) { |
| 447 | + if ( FlaggedRevs::useSimpleUI() ) { |
448 | 448 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() ); |
449 | | - if( !$wgUser->getId() ) { |
| 449 | + if ( !$wgUser->getId() ) { |
450 | 450 | $msgHTML = ''; // Anons just see simple icons |
451 | 451 | } else { |
452 | 452 | $msg = $quality |
453 | 453 | ? 'revreview-quick-quality-old' |
454 | 454 | : 'revreview-quick-basic-old'; |
455 | | - $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time ); |
| 455 | + $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time ); |
456 | 456 | } |
457 | 457 | $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}"; |
458 | 458 | $tag = FlaggedRevsXML::prettyRatingBox( $frev, $msgHTML, |
— | — | @@ -460,19 +460,19 @@ |
461 | 461 | } else { |
462 | 462 | $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old'; |
463 | 463 | $tag = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" . |
464 | | - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time ); |
| 464 | + wfMsgExt( $msg, array( 'parseinline' ), $frev->getRevId(), $time ); |
465 | 465 | # Hide clutter |
466 | | - if( !empty($flags) ) { |
| 466 | + if ( !empty( $flags ) ) { |
467 | 467 | $tag .= " " . FlaggedRevsXML::ratingToggle(); |
468 | 468 | $tag .= "<span id='mw-fr-revisionratings' style='display:block;'><br />" . |
469 | | - wfMsgHtml('revreview-oldrating') . |
| 469 | + wfMsgHtml( 'revreview-oldrating' ) . |
470 | 470 | FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | 474 | # Output HTML |
475 | 475 | $this->setReviewNotes( $frev ); |
476 | | - if( $redirHtml != '' ) { |
| 476 | + if ( $redirHtml != '' ) { |
477 | 477 | $wgOut->addHtml( $redirHtml ); |
478 | 478 | } else { |
479 | 479 | $wgOut->addParserOutput( $parserOut ); |
— | — | @@ -501,11 +501,11 @@ |
502 | 502 | # Get parsed stable version |
503 | 503 | $redirHtml = ''; |
504 | 504 | $parserOut = FlaggedRevs::getPageCache( $this->article, $wgUser ); |
505 | | - if( $parserOut == false ) { |
| 505 | + if ( $parserOut == false ) { |
506 | 506 | $text = $srev->getRevText(); |
507 | 507 | # Check if this is a redirect... |
508 | 508 | $redirHtml = $this->getRedirectHtml( $text ); |
509 | | - if( $redirHtml == '' ) { |
| 509 | + if ( $redirHtml == '' ) { |
510 | 510 | $parserOut = FlaggedRevs::parseStableText( |
511 | 511 | $this->article, $text, $srev->getRevId() ); |
512 | 512 | # Update the stable version cache |
— | — | @@ -514,14 +514,14 @@ |
515 | 515 | } |
516 | 516 | $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article, $parserOut, null ); |
517 | 517 | # Construct some tagging |
518 | | - if( !$wgOut->isPrintable() && !($this->article->lowProfileUI() && $synced) ) { |
| 518 | + if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) { |
519 | 519 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() ); |
520 | 520 | $class = $quality ? 'fr-icon-quality' : 'fr-icon-stable'; |
521 | 521 | $tooltip = $quality ? 'revreview-quality-title' : 'revreview-stable-title'; |
522 | | - $tooltip = wfMsgHtml($tooltip); |
| 522 | + $tooltip = wfMsgHtml( $tooltip ); |
523 | 523 | // Simple icon-based UI |
524 | | - if( FlaggedRevs::useSimpleUI() ) { |
525 | | - if( !$wgUser->getId() ) { |
| 524 | + if ( FlaggedRevs::useSimpleUI() ) { |
| 525 | + if ( !$wgUser->getId() ) { |
526 | 526 | $msgHTML = ''; // Anons just see simple icons |
527 | 527 | } else { |
528 | 528 | $msg = $quality |
— | — | @@ -529,7 +529,7 @@ |
530 | 530 | : 'revreview-quick-basic'; |
531 | 531 | # Uses messages 'revreview-quick-quality-same', 'revreview-quick-basic-same' |
532 | 532 | $msg = $synced ? "{$msg}-same" : $msg; |
533 | | - $msgHTML = wfMsgExt( $msg, array('parseinline'), |
| 533 | + $msgHTML = wfMsgExt( $msg, array( 'parseinline' ), |
534 | 534 | $srev->getRevId(), $revsSince ); |
535 | 535 | } |
536 | 536 | $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}"; |
— | — | @@ -538,16 +538,16 @@ |
539 | 539 | // Standard UI |
540 | 540 | } else { |
541 | 541 | $msg = $quality ? 'revreview-quality' : 'revreview-basic'; |
542 | | - if( $synced ) { |
| 542 | + if ( $synced ) { |
543 | 543 | # uses messages 'revreview-quality-same', 'revreview-basic-same' |
544 | 544 | $msg .= '-same'; |
545 | | - } elseif( $revsSince == 0 ) { |
| 545 | + } elseif ( $revsSince == 0 ) { |
546 | 546 | # uses messages 'revreview-quality-i', 'revreview-basic-i' |
547 | 547 | $msg .= '-i'; |
548 | 548 | } |
549 | 549 | $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 ) ) { |
552 | 552 | $tag .= " " . FlaggedRevsXML::ratingToggle(); |
553 | 553 | $tag .= "<span id='mw-fr-revisionratings' style='display:block;'><br />" . |
554 | 554 | FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
— | — | @@ -556,7 +556,7 @@ |
557 | 557 | } |
558 | 558 | # Output HTML |
559 | 559 | $this->setReviewNotes( $srev ); |
560 | | - if( $redirHtml != '' ) { |
| 560 | + if ( $redirHtml != '' ) { |
561 | 561 | $wgOut->addHtml( $redirHtml ); |
562 | 562 | } else { |
563 | 563 | $wgOut->addParserOutput( $parserOut ); |
— | — | @@ -565,7 +565,7 @@ |
566 | 566 | |
567 | 567 | protected function getRedirectHtml( $text ) { |
568 | 568 | $rTarget = $this->article->followRedirectText( $text ); |
569 | | - if( $rTarget ) { |
| 569 | + if ( $rTarget ) { |
570 | 570 | return $this->article->viewRedirect( $rTarget ); |
571 | 571 | } |
572 | 572 | return ''; |
— | — | @@ -575,18 +575,18 @@ |
576 | 576 | * @param FlaggedRevision $srev, stable version |
577 | 577 | * @param bool $quality, revision is quality |
578 | 578 | * @returns bool, diff added to output |
579 | | - */ |
| 579 | + */ |
580 | 580 | protected function maybeShowTopDiff( $srev, $quality ) { |
581 | 581 | global $wgUser, $wgOut, $wgMemc; |
582 | 582 | $this->load(); |
583 | | - if( !$wgUser->getBoolOption('flaggedrevsviewdiffs') ) |
| 583 | + if ( !$wgUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) |
584 | 584 | return false; // nothing to do here |
585 | | - if( !$wgUser->isAllowed('review') ) |
| 585 | + if ( !$wgUser->isAllowed( 'review' ) ) |
586 | 586 | return false; // does not apply to this user |
587 | 587 | # Diff should only show for the draft |
588 | 588 | $oldid = $this->article->getOldIDFromRequest(); |
589 | 589 | $latest = $this->article->getLatest(); |
590 | | - if( $oldid && $oldid != $latest ) { |
| 590 | + if ( $oldid && $oldid != $latest ) { |
591 | 591 | return false; // not viewing the draft |
592 | 592 | } |
593 | 593 | # Conditions are met to show diff... |
— | — | @@ -594,24 +594,24 @@ |
595 | 595 | $rClass = FlaggedRevsXML::getQualityColor( false ); |
596 | 596 | $lClass = FlaggedRevsXML::getQualityColor( (int)$quality ); |
597 | 597 | $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[" . |
598 | | - wfMsgHtml('hist-draft') . "]</span>"; |
| 598 | + wfMsgHtml( 'hist-draft' ) . "]</span>"; |
599 | 599 | $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[" . |
600 | | - wfMsgHtml($leftNote)."]</span>"; |
| 600 | + wfMsgHtml( $leftNote ) . "]</span>"; |
601 | 601 | # Fetch the stable and draft revision text |
602 | 602 | $oText = $srev->getRevText(); |
603 | | - if( $oText === false ) |
| 603 | + if ( $oText === false ) |
604 | 604 | return false; // deleted revision or something? |
605 | 605 | $nText = $this->article->getContent(); |
606 | | - if( $nText === false ) |
| 606 | + if ( $nText === false ) |
607 | 607 | return false; // deleted revision or something? |
608 | 608 | # Build diff at the top of the page |
609 | | - if( strcmp($oText,$nText) !== 0 ) { |
| 609 | + if ( strcmp( $oText, $nText ) !== 0 ) { |
610 | 610 | $diffEngine = new DifferenceEngine(); |
611 | 611 | $diffEngine->showDiffStyle(); |
612 | 612 | $n = $this->article->getTitle()->countRevisionsBetween( $srev->getRevId(), $latest ); |
613 | | - if( $n ) { |
| 613 | + if ( $n ) { |
614 | 614 | $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>"; |
616 | 616 | } else { |
617 | 617 | $multiNotice = ''; |
618 | 618 | } |
— | — | @@ -654,15 +654,15 @@ |
655 | 655 | # Determine timestamp. A reviewed version may have explicitly been requested... |
656 | 656 | $frev = null; |
657 | 657 | $time = false; |
658 | | - if( $reqId = $wgRequest->getVal('stableid') ) { |
| 658 | + if ( $reqId = $wgRequest->getVal( 'stableid' ) ) { |
659 | 659 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId ); |
660 | | - } elseif( $this->pageOverride() ) { |
| 660 | + } elseif ( $this->pageOverride() ) { |
661 | 661 | $frev = $this->article->getStableRev(); |
662 | 662 | } |
663 | | - if( !is_null($frev) ) { |
| 663 | + if ( !is_null( $frev ) ) { |
664 | 664 | $time = $frev->getFileTimestamp(); |
665 | 665 | // B/C, may be stored in associated image version metadata table |
666 | | - if( !$time ) { |
| 666 | + if ( !$time ) { |
667 | 667 | $dbr = wfGetDB( DB_SLAVE ); |
668 | 668 | $time = $dbr->selectField( 'flaggedimages', |
669 | 669 | 'fi_img_timestamp', |
— | — | @@ -674,29 +674,29 @@ |
675 | 675 | # NOTE: if not found, this will use the current |
676 | 676 | $wgArticle = new ImagePage( $this->article->getTitle(), $time ); |
677 | 677 | } |
678 | | - if( !$time ) { |
| 678 | + if ( !$time ) { |
679 | 679 | # Try request parameter |
680 | 680 | $time = $wgRequest->getVal( 'filetimestamp', false ); |
681 | 681 | } |
682 | 682 | |
683 | | - if( !$time ) { |
| 683 | + if ( !$time ) { |
684 | 684 | return; // Use the default behaviour |
685 | 685 | } |
686 | 686 | |
687 | 687 | $title = $this->article->getTitle(); |
688 | 688 | $displayFile = wfFindFile( $title, array( 'time' => $time ) ); |
689 | 689 | # 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" ); |
692 | 692 | $displayFile = wfFindFile( $title ); |
693 | 693 | # If none found, use a valid local placeholder |
694 | | - if( !$displayFile ) { |
| 694 | + if ( !$displayFile ) { |
695 | 695 | $displayFile = wfLocalFile( $title ); // fallback to current |
696 | 696 | } |
697 | 697 | $normalFile = $displayFile; |
698 | 698 | # If found, set $normalFile |
699 | 699 | } else { |
700 | | - wfDebug( __METHOD__.": {$title->getPrefixedDBkey()}: using timestamp $time\n" ); |
| 700 | + wfDebug( __METHOD__ . ": {$title->getPrefixedDBkey()}: using timestamp $time\n" ); |
701 | 701 | $normalFile = wfFindFile( $title ); |
702 | 702 | } |
703 | 703 | } |
— | — | @@ -708,12 +708,12 @@ |
709 | 709 | global $wgOut; |
710 | 710 | $this->load(); |
711 | 711 | # 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() ) { |
713 | 713 | return true; |
714 | 714 | } |
715 | 715 | # Add a notice if there are pending edits... |
716 | 716 | $frev = $this->article->getStableRev(); |
717 | | - if( $frev && $frev->getRevId() < $this->article->getLatest() ) { |
| 717 | + if ( $frev && $frev->getRevId() < $this->article->getLatest() ) { |
718 | 718 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() ); |
719 | 719 | $tag = "<div id='mw-fr-revisiontag-edit' class='flaggedrevs_notice plainlinks'>" . |
720 | 720 | FlaggedRevsXML::lockStatusIcon( $this->article ) . # flag protection icon as needed |
— | — | @@ -730,42 +730,42 @@ |
731 | 731 | global $wgRequest, $wgOut, $wgLang, $wgUser; |
732 | 732 | $this->load(); |
733 | 733 | # 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() ) { |
735 | 735 | return true; |
736 | 736 | } |
737 | 737 | $items = array(); |
738 | 738 | $tag = $warning = $prot = ''; |
739 | 739 | # Show stabilization log |
740 | 740 | $log = $this->stabilityLogExcerpt(); |
741 | | - if( $log ) $items[] = $log; |
| 741 | + if ( $log ) $items[] = $log; |
742 | 742 | # Check the newest stable version |
743 | 743 | $quality = 0; |
744 | 744 | $frev = $this->article->getStableRev(); |
745 | | - if( $frev ) { |
| 745 | + if ( $frev ) { |
746 | 746 | $quality = $frev->getQuality(); |
747 | 747 | # Find out revision id of base version |
748 | 748 | $latestId = $this->article->getLatest(); |
749 | 749 | $revId = $editPage->oldid ? $editPage->oldid : $latestId; |
750 | | - $isOld = ($revId != $latestId); // not the current rev? |
| 750 | + $isOld = ( $revId != $latestId ); // not the current rev? |
751 | 751 | # Let new users know about review procedure a tag. |
752 | 752 | # 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' ) ); |
755 | 755 | } |
756 | 756 | # Add a notice if there are pending edits... |
757 | | - if( $frev->getRevId() != $revId ) { |
| 757 | + if ( $frev->getRevId() != $revId ) { |
758 | 758 | $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() ); |
759 | 759 | $items[] = FlaggedRevsXML::pendingEditNotice( $this->article, $frev, $revsSince ); |
760 | 760 | } |
761 | 761 | # Show diff to stable, to make things less confusing... |
762 | 762 | # This can be disabled via user preferences |
763 | | - if( $frev->getRevId() < $revId // changes were made |
| 763 | + if ( $frev->getRevId() < $revId // changes were made |
764 | 764 | && $this->isDiffShownOnEdit() // stable default and user cannot review |
765 | 765 | && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs |
766 | 766 | ) { |
767 | 767 | # 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' ) ) ) |
770 | 770 | { |
771 | 771 | return true; // nothing to show here |
772 | 772 | } |
— | — | @@ -774,18 +774,18 @@ |
775 | 775 | $leftNote = $quality ? 'hist-quality' : 'hist-stable'; |
776 | 776 | $rClass = FlaggedRevsXML::getQualityColor( false ); |
777 | 777 | $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>"; |
782 | 782 | $text = $frev->getRevText(); |
783 | 783 | # 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 ) { |
787 | 787 | $text = $this->article->getSection( $text, $section ); |
788 | 788 | } |
789 | | - if( $text !== false && strcmp($text,$editPage->textbox1) !== 0 ) { |
| 789 | + if ( $text !== false && strcmp( $text, $editPage->textbox1 ) !== 0 ) { |
790 | 790 | $diffEngine = new DifferenceEngine(); |
791 | 791 | $diffEngine->showDiffStyle(); |
792 | 792 | $diffHtml = |
— | — | @@ -810,10 +810,10 @@ |
811 | 811 | } |
812 | 812 | } |
813 | 813 | # Output items |
814 | | - if( count($items) ) { |
| 814 | + if ( count( $items ) ) { |
815 | 815 | $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>'; |
818 | 818 | } |
819 | 819 | $html .= '</table>'; |
820 | 820 | $wgOut->addHTML( $html ); |
— | — | @@ -826,18 +826,18 @@ |
827 | 827 | $this->load(); |
828 | 828 | $s = ''; |
829 | 829 | # Only for pages manually made to be stable... |
830 | | - if( $this->article->isPageLocked() ) { |
| 830 | + if ( $this->article->isPageLocked() ) { |
831 | 831 | $s = wfMsgExt( 'revreview-locked', 'parseinline' ); |
832 | 832 | $logHtml = ''; |
833 | 833 | LogEventsList::showLogExtract( $logHtml, 'stable', |
834 | | - $this->article->getTitle()->getPrefixedText(), '', array('lim'=>1) ); |
| 834 | + $this->article->getTitle()->getPrefixedText(), '', array( 'lim' => 1 ) ); |
835 | 835 | $s .= $logHtml; |
836 | 836 | # ...or unstable |
837 | | - } elseif( $this->article->isPageUnlocked() ) { |
| 837 | + } elseif ( $this->article->isPageUnlocked() ) { |
838 | 838 | $s = wfMsgExt( 'revreview-unlocked', 'parseinline' ); |
839 | 839 | $logHtml = ''; |
840 | 840 | LogEventsList::showLogExtract( $logHtml, 'stable', |
841 | | - $this->article->getTitle()->getPrefixedText(), '', array('lim' => 1) ); |
| 841 | + $this->article->getTitle()->getPrefixedText(), '', array( 'lim' => 1 ) ); |
842 | 842 | $s .= $logHtml; |
843 | 843 | } |
844 | 844 | return $s; |
— | — | @@ -849,18 +849,18 @@ |
850 | 850 | public function addToCategoryView() { |
851 | 851 | global $wgOut, $wgUser; |
852 | 852 | $this->load(); |
853 | | - if( !$wgUser->isAllowed( 'review' ) ) { |
| 853 | + if ( !$wgUser->isAllowed( 'review' ) ) { |
854 | 854 | return true; |
855 | 855 | } |
856 | 856 | $category = $this->article->getTitle()->getText(); |
857 | 857 | |
858 | 858 | $unreviewed = SpecialPage::getTitleFor( 'UnreviewedPages' ); |
859 | 859 | $unreviewedLink = $wgUser->getSkin()->makeKnownLinkObj( $unreviewed, |
860 | | - wfMsgHtml('unreviewedpages'), 'category=' . urlencode($category) ); |
| 860 | + wfMsgHtml( 'unreviewedpages' ), 'category=' . urlencode( $category ) ); |
861 | 861 | |
862 | 862 | $oldreviewed = SpecialPage::getTitleFor( 'OldReviewedPages' ); |
863 | 863 | $oldreviewedLink = $wgUser->getSkin()->makeKnownLinkObj( $oldreviewed, |
864 | | - wfMsgHtml('oldreviewedpages'), 'category=' . urlencode($category) ); |
| 864 | + wfMsgHtml( 'oldreviewedpages' ), 'category=' . urlencode( $category ) ); |
865 | 865 | |
866 | 866 | $wgOut->appendSubtitle( |
867 | 867 | "<span id='mw-fr-category-oldreviewed'>$unreviewedLink / $oldreviewedLink</span>" |
— | — | @@ -875,27 +875,27 @@ |
876 | 876 | global $wgRequest, $wgUser, $wgOut; |
877 | 877 | $this->load(); |
878 | 878 | # 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() |
880 | 880 | || !$this->article->isReviewable() ) |
881 | 881 | { |
882 | 882 | return true; |
883 | 883 | } |
884 | 884 | # Unobtrusive patrolling UI only shows forms if requested |
885 | | - if( !$wgRequest->getInt('reviewform') && $this->article->limitedUI() ) { |
| 885 | + if ( !$wgRequest->getInt( 'reviewform' ) && $this->article->limitedUI() ) { |
886 | 886 | return true; |
887 | 887 | } |
888 | 888 | # Avoid multi-page diffs that are useless and misbehave (bug 19327) |
889 | | - if( $this->isMultiPageDiff ) { |
| 889 | + if ( $this->isMultiPageDiff ) { |
890 | 890 | return true; |
891 | 891 | } |
892 | 892 | # Check action and if page is protected |
893 | 893 | $action = $wgRequest->getVal( 'action', 'view' ); |
894 | 894 | # Must be view/diff action... |
895 | | - if( !self::isViewAction($action) ) { |
| 895 | + if ( !self::isViewAction( $action ) ) { |
896 | 896 | return true; |
897 | 897 | } |
898 | 898 | # 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; |
900 | 900 | $this->addQuickReview( $data, $onTop, false ); |
901 | 901 | return true; |
902 | 902 | } |
— | — | @@ -906,28 +906,28 @@ |
907 | 907 | public function addVisibilityLink( &$data ) { |
908 | 908 | global $wgUser, $wgRequest, $wgOut; |
909 | 909 | $this->load(); |
910 | | - if( FlaggedRevs::getProtectionLevels() ) |
| 910 | + if ( FlaggedRevs::getProtectionLevels() ) |
911 | 911 | return true; // simple custom levels set for action=protect |
912 | 912 | # Check only if the title is reviewable |
913 | | - if( !$this->article->isReviewable(true) ) { |
| 913 | + if ( !$this->article->isReviewable( true ) ) { |
914 | 914 | return true; |
915 | 915 | } |
916 | 916 | $action = $wgRequest->getVal( 'action', 'view' ); |
917 | | - if( $action == 'protect' || $action == 'unprotect' ) { |
| 917 | + if ( $action == 'protect' || $action == 'unprotect' ) { |
918 | 918 | $title = SpecialPage::getTitleFor( 'Stabilization' ); |
919 | 919 | # Give a link to the page to configure the stable version |
920 | 920 | $frev = $this->article->getStableRev(); |
921 | | - if( $frev && $frev->getRevId() == $this->article->getLatest() ) { |
| 921 | + if ( $frev && $frev->getRevId() == $this->article->getLatest() ) { |
922 | 922 | $wgOut->prependHTML( "<span class='plainlinks'>" . |
923 | | - wfMsgExt( 'revreview-visibility',array('parseinline'), |
| 923 | + wfMsgExt( 'revreview-visibility', array( 'parseinline' ), |
924 | 924 | $title->getPrefixedText() ) . "</span>" ); |
925 | | - } elseif( $frev ) { |
| 925 | + } elseif ( $frev ) { |
926 | 926 | $wgOut->prependHTML( "<span class='plainlinks'>" . |
927 | | - wfMsgExt( 'revreview-visibility2',array('parseinline'), |
| 927 | + wfMsgExt( 'revreview-visibility2', array( 'parseinline' ), |
928 | 928 | $title->getPrefixedText() ) . "</span>" ); |
929 | 929 | } else { |
930 | 930 | $wgOut->prependHTML( "<span class='plainlinks'>" . |
931 | | - wfMsgExt( 'revreview-visibility3',array('parseinline'), |
| 931 | + wfMsgExt( 'revreview-visibility3', array( 'parseinline' ), |
932 | 932 | $title->getPrefixedText() ) . "</span>" ); |
933 | 933 | } |
934 | 934 | } |
— | — | @@ -941,15 +941,15 @@ |
942 | 942 | public function setActionTabs( $skin, &$actions ) { |
943 | 943 | global $wgRequest, $wgUser; |
944 | 944 | $this->load(); |
945 | | - if( FlaggedRevs::getProtectionLevels() ) { |
| 945 | + if ( FlaggedRevs::getProtectionLevels() ) { |
946 | 946 | return true; // simple custom levels set for action=protect |
947 | 947 | } |
948 | 948 | $title = $this->article->getTitle()->getSubjectPage(); |
949 | | - if( !FlaggedRevs::isPageReviewable( $title ) ) { |
| 949 | + if ( !FlaggedRevs::isPageReviewable( $title ) ) { |
950 | 950 | return true; // Only reviewable pages need these tabs |
951 | 951 | } |
952 | 952 | // Check if we should show a stabilization tab |
953 | | - if( |
| 953 | + if ( |
954 | 954 | !$skin->mTitle->isTalkPage() && |
955 | 955 | is_array( $actions ) && |
956 | 956 | !isset( $actions['protect'] ) && |
— | — | @@ -982,35 +982,35 @@ |
983 | 983 | $fa = FlaggedArticle::getTitleInstance( $title ); |
984 | 984 | |
985 | 985 | $action = $wgRequest->getVal( 'action', 'view' ); |
986 | | - if( !$fa->isReviewable() || $fa->limitedUI() ) { |
| 986 | + if ( !$fa->isReviewable() || $fa->limitedUI() ) { |
987 | 987 | return true; // Not a reviewable page or the UI is hidden |
988 | 988 | } |
989 | | - $flags = ($action == 'rollback') ? FR_MASTER : 0; |
| 989 | + $flags = ( $action == 'rollback' ) ? FR_MASTER : 0; |
990 | 990 | $srev = $fa->getStableRev( $flags ); |
991 | | - if( !$srev ) { |
| 991 | + if ( !$srev ) { |
992 | 992 | return true; // No stable revision exists |
993 | 993 | } |
994 | 994 | $synced = FlaggedRevs::stableVersionIsSynced( $srev, $fa ); |
995 | 995 | // 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' ); |
1000 | 1000 | } |
1001 | | - if( $this->pageOverride() ) { |
| 1001 | + if ( $this->pageOverride() ) { |
1002 | 1002 | $views['edit']['href'] = $title->getLocalUrl( 'action=edit' ); |
1003 | 1003 | } |
1004 | 1004 | } |
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' ); |
1008 | 1008 | } |
1009 | | - if( $this->pageOverride() ) { |
| 1009 | + if ( $this->pageOverride() ) { |
1010 | 1010 | $views['viewsource']['href'] = $title->getLocalUrl( 'action=edit' ); |
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | } |
1014 | | - if( !FlaggedRevs::showVersionTabs() || $synced ) { |
| 1014 | + if ( !FlaggedRevs::showVersionTabs() || $synced ) { |
1015 | 1015 | // Exit, since either the stable/draft tabs should not be shown |
1016 | 1016 | // or the page is already the most current revision |
1017 | 1017 | return true; |
— | — | @@ -1027,10 +1027,10 @@ |
1028 | 1028 | 'class' => '' |
1029 | 1029 | ), |
1030 | 1030 | ); |
1031 | | - if( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) { |
| 1031 | + if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) { |
1032 | 1032 | // We are looking a the stable version |
1033 | 1033 | $tabs['stable']['class'] = 'selected'; |
1034 | | - } elseif( |
| 1034 | + } elseif ( |
1035 | 1035 | ( self::isViewAction( $action ) || $action == 'edit' ) && |
1036 | 1036 | !$skin->mTitle->isTalkPage() |
1037 | 1037 | ) { |
— | — | @@ -1041,8 +1041,8 @@ |
1042 | 1042 | $newViews = array(); |
1043 | 1043 | foreach ( $views as $tabAction => $data ) { |
1044 | 1044 | // Very first tab (page link) |
1045 | | - if( $first ) { |
1046 | | - if( $synced ) { |
| 1045 | + if ( $first ) { |
| 1046 | + if ( $synced ) { |
1047 | 1047 | // Use existing first tabs when synced |
1048 | 1048 | $newViews[$tabAction] = $data; |
1049 | 1049 | } else { |
— | — | @@ -1069,9 +1069,9 @@ |
1070 | 1070 | public function setReviewNotes( $frev ) { |
1071 | 1071 | global $wgUser; |
1072 | 1072 | $this->load(); |
1073 | | - if( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) { |
| 1073 | + if ( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) { |
1074 | 1074 | $this->reviewNotes = "<br /><div class='flaggedrevs_notes plainlinks'>"; |
1075 | | - $this->reviewNotes .= wfMsgExt('revreview-note', array('parseinline'), |
| 1075 | + $this->reviewNotes .= wfMsgExt( 'revreview-note', array( 'parseinline' ), |
1076 | 1076 | User::whoIs( $frev->getUser() ) ); |
1077 | 1077 | $this->reviewNotes .= '<br /><i>' . |
1078 | 1078 | $wgUser->getSkin()->formatComment( $frev->getComment() ) . '</i></div>'; |
— | — | @@ -1086,97 +1086,97 @@ |
1087 | 1087 | global $wgRequest, $wgUser, $wgOut, $wgMemc; |
1088 | 1088 | $this->load(); |
1089 | 1089 | # Exempt printer-friendly output |
1090 | | - if( $wgOut->isPrintable() ) { |
| 1090 | + if ( $wgOut->isPrintable() ) { |
1091 | 1091 | return true; |
1092 | 1092 | } |
1093 | 1093 | # Avoid multi-page diffs that are useless and misbehave (bug 19327) |
1094 | | - if( $this->isMultiPageDiff ) { |
| 1094 | + if ( $this->isMultiPageDiff ) { |
1095 | 1095 | return true; |
1096 | 1096 | } |
1097 | 1097 | # 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() ) { |
1099 | 1099 | return true; |
1100 | 1100 | } |
1101 | 1101 | # Check if this might be the diff to stable. If so, enhance it. |
1102 | | - if( $newRev->isCurrent() && $oldRev ) { |
| 1102 | + if ( $newRev->isCurrent() && $oldRev ) { |
1103 | 1103 | $article = new Article( $newRev->getTitle() ); |
1104 | 1104 | $frev = $this->article->getStableRev(); |
1105 | | - if( $frev && $frev->getRevId() == $oldRev->getID() ) { |
| 1105 | + if ( $frev && $frev->getRevId() == $oldRev->getID() ) { |
1106 | 1106 | global $wgParserCacheExpireTime; |
1107 | 1107 | # Check the page sync value cache... |
1108 | 1108 | $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 |
1111 | 1111 | |
1112 | 1112 | $changeList = array(); |
1113 | 1113 | |
1114 | 1114 | # Try the cache. Uses format <page ID>-<UNIX timestamp>. |
1115 | 1115 | $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 ) { |
1118 | 1118 | $tmpChanges = false; // don't use cache, it's not consistent |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | # Make a list of each changed template... |
1122 | | - if( $tmpChanges === false ) { |
| 1122 | + if ( $tmpChanges === false ) { |
1123 | 1123 | $tmpChanges = $this->fetchTemplateChanges( $frev ); |
1124 | | - $wgMemc->set( $key, FlaggedRevs::makeMemcObj($tmpChanges), |
| 1124 | + $wgMemc->set( $key, FlaggedRevs::makeMemcObj( $tmpChanges ), |
1125 | 1125 | $wgParserCacheExpireTime ); |
1126 | 1126 | } |
1127 | 1127 | # Add set to list |
1128 | | - if( $tmpChanges ) |
| 1128 | + if ( $tmpChanges ) |
1129 | 1129 | $changeList += $tmpChanges; |
1130 | 1130 | |
1131 | 1131 | # Try the cache. Uses format <page ID>-<UNIX timestamp>. |
1132 | 1132 | $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 ) { |
1135 | 1135 | $imgChanges = false; // don't use cache, it's not consistent |
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // Get list of each changed image... |
1139 | | - if( $imgChanges === false ) { |
| 1139 | + if ( $imgChanges === false ) { |
1140 | 1140 | $imgChanges = $this->fetchFileChanges( $frev ); |
1141 | | - $wgMemc->set( $key, FlaggedRevs::makeMemcObj($imgChanges), |
| 1141 | + $wgMemc->set( $key, FlaggedRevs::makeMemcObj( $imgChanges ), |
1142 | 1142 | $wgParserCacheExpireTime ); |
1143 | 1143 | } |
1144 | | - if( $imgChanges ) |
| 1144 | + if ( $imgChanges ) |
1145 | 1145 | $changeList += $imgChanges; |
1146 | 1146 | |
1147 | 1147 | # Some important information... |
1148 | 1148 | $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 ) { |
1152 | 1152 | $diff->mTitle->invalidateCache(); // bad cache, said they were not synced |
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | # If the user is allowed to review, prompt them! |
1156 | 1156 | # 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() ) { |
1158 | 1158 | $css = 'flaggedrevs_diffnotice plainlinks'; |
1159 | | - if( empty($changeList) && $wgUser->isAllowed('review') ) { |
| 1159 | + if ( empty( $changeList ) && $wgUser->isAllowed( 'review' ) ) { |
1160 | 1160 | $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" . |
1161 | | - wfMsgExt('revreview-update-none', array('parseinline')) . |
| 1161 | + wfMsgExt( 'revreview-update-none', array( 'parseinline' ) ) . |
1162 | 1162 | $notice . '</div>' ); |
1163 | | - } elseif( !empty($changeList) && $wgUser->isAllowed('review') ) { |
1164 | | - $changeList = implode(', ',$changeList); |
| 1163 | + } elseif ( !empty( $changeList ) && $wgUser->isAllowed( 'review' ) ) { |
| 1164 | + $changeList = implode( ', ', $changeList ); |
1165 | 1165 | $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" . |
1166 | | - wfMsgExt('revreview-update', array('parseinline')) . |
1167 | | - ' ' . $changeList.$notice.'</div>' ); |
1168 | | - } elseif( !empty($changeList) ) { |
1169 | | - $changeList = implode(', ',$changeList); |
| 1166 | + wfMsgExt( 'revreview-update', array( 'parseinline' ) ) . |
| 1167 | + ' ' . $changeList . $notice . '</div>' ); |
| 1168 | + } elseif ( !empty( $changeList ) ) { |
| 1169 | + $changeList = implode( ', ', $changeList ); |
1170 | 1170 | $wgOut->addHTML( "<div id='mw-fr-difftostable' class='$css'>" . |
1171 | | - wfMsgExt('revreview-update-includes', array('parseinline')) . |
1172 | | - ' ' . $changeList.$notice.'</div>' ); |
| 1171 | + wfMsgExt( 'revreview-update-includes', array( 'parseinline' ) ) . |
| 1172 | + ' ' . $changeList . $notice . '</div>' ); |
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | # Set a key to note that someone is viewing this |
1177 | | - if( $wgUser->isAllowed('review') ) { |
| 1177 | + if ( $wgUser->isAllowed( 'review' ) ) { |
1178 | 1178 | $key = wfMemcKey( 'stableDiffs', 'underReview', |
1179 | 1179 | $oldRev->getID(), $newRev->getID() ); |
1180 | | - $wgMemc->set( $key, '1', 10*60 ); // 10 min |
| 1180 | + $wgMemc->set( $key, '1', 10 * 60 ); // 10 min |
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | } |
— | — | @@ -1185,11 +1185,11 @@ |
1186 | 1186 | ? FlaggedRevs::getRevQuality( $newRev->getPage(), $oldRev->getId() ) |
1187 | 1187 | : false; |
1188 | 1188 | # Diff between two revisions |
1189 | | - if( $oldRev ) { |
| 1189 | + if ( $oldRev ) { |
1190 | 1190 | $wgOut->addHTML( "<table class='fr-diff-ratings'><tr>" ); |
1191 | 1191 | |
1192 | 1192 | $class = FlaggedRevsXML::getQualityColor( $oldRevQ ); |
1193 | | - if( $oldRevQ !== false ) { |
| 1193 | + if ( $oldRevQ !== false ) { |
1194 | 1194 | $msg = $oldRevQ ? 'hist-quality' : 'hist-stable'; |
1195 | 1195 | } else { |
1196 | 1196 | $msg = 'hist-draft'; |
— | — | @@ -1199,7 +1199,7 @@ |
1200 | 1200 | wfMsgHtml( $msg ) . "]</span>" ); |
1201 | 1201 | |
1202 | 1202 | $class = FlaggedRevsXML::getQualityColor( $newRevQ ); |
1203 | | - if( $newRevQ !== false ) { |
| 1203 | + if ( $newRevQ !== false ) { |
1204 | 1204 | $msg = $newRevQ ? 'hist-quality' : 'hist-stable'; |
1205 | 1205 | } else { |
1206 | 1206 | $msg = 'hist-draft'; |
— | — | @@ -1211,7 +1211,7 @@ |
1212 | 1212 | $wgOut->addHTML( '</td></tr></table>' ); |
1213 | 1213 | # New page "diffs" - just one rev |
1214 | 1214 | } else { |
1215 | | - if( $newRevQ !== false ) { |
| 1215 | + if ( $newRevQ !== false ) { |
1216 | 1216 | $msg = $newRevQ ? 'hist-quality' : 'hist-stable'; |
1217 | 1217 | } else { |
1218 | 1218 | $msg = 'hist-draft'; |
— | — | @@ -1233,28 +1233,28 @@ |
1234 | 1234 | $skin = $wgUser->getSkin(); |
1235 | 1235 | $dbr = wfGetDB( DB_SLAVE ); |
1236 | 1236 | // 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' ), |
1238 | 1238 | array( 'ft_namespace', 'ft_title', 'fp_stable', |
1239 | | - 'ft_tmp_rev_id','page_latest' ), |
| 1239 | + 'ft_tmp_rev_id', 'page_latest' ), |
1240 | 1240 | array( 'ft_rev_id' => $frev->getRevId(), |
1241 | 1241 | 'page_namespace = ft_namespace', |
1242 | 1242 | 'page_title = ft_title' ), |
1243 | 1243 | __METHOD__, |
1244 | 1244 | array(), /* OPTIONS */ |
1245 | | - array( 'flaggedpages' => array('LEFT JOIN','fp_page_id = page_id') ) |
| 1245 | + array( 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ) ) |
1246 | 1246 | ); |
1247 | 1247 | $tmpChanges = array(); |
1248 | | - while( $row = $dbr->fetchObject( $ret ) ) { |
| 1248 | + while ( $row = $dbr->fetchObject( $ret ) ) { |
1249 | 1249 | $title = Title::makeTitleSafe( $row->ft_namespace, $row->ft_title ); |
1250 | 1250 | $revIdDraft = $row->page_latest; |
1251 | 1251 | // 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 ? |
1253 | 1253 | $row->fp_stable : $row->ft_tmp_rev_id; |
1254 | 1254 | // compare to current |
1255 | | - if( $revIdDraft > $revIdStable ) { |
| 1255 | + if ( $revIdDraft > $revIdStable ) { |
1256 | 1256 | $tmpChanges[] = $skin->makeKnownLinkObj( $title, |
1257 | 1257 | $title->getPrefixedText(), |
1258 | | - 'diff=cur&oldid='.intval($revIdStable) ); |
| 1258 | + 'diff=cur&oldid=' . intval( $revIdStable ) ); |
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | return $tmpChanges; |
— | — | @@ -1267,28 +1267,28 @@ |
1268 | 1268 | $dbr = wfGetDB( DB_SLAVE ); |
1269 | 1269 | // Get images where the current and stable are not the same revision |
1270 | 1270 | $ret = $dbr->select( |
1271 | | - array( 'flaggedimages','page','image','flaggedpages','flaggedrevs' ), |
| 1271 | + array( 'flaggedimages', 'page', 'image', 'flaggedpages', 'flaggedrevs' ), |
1272 | 1272 | array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ), |
1273 | 1273 | array( 'fi_rev_id' => $frev->getRevId() ), |
1274 | 1274 | __METHOD__, |
1275 | 1275 | array(), /* OPTIONS */ |
1276 | 1276 | 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' ) ) |
1283 | 1283 | ); |
1284 | 1284 | $imgChanges = array(); |
1285 | | - while( $row = $dbr->fetchObject( $ret ) ) { |
| 1285 | + while ( $row = $dbr->fetchObject( $ret ) ) { |
1286 | 1286 | $title = Title::makeTitleSafe( NS_FILE, $row->fi_name ); |
1287 | 1287 | // 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 ? |
1289 | 1289 | $row->fr_img_timestamp : $row->fi_img_timestamp; |
1290 | 1290 | // compare to current |
1291 | 1291 | $file = wfFindFile( $title ); |
1292 | | - if( $file && $file->getTimestamp() > $timestamp ) { |
| 1292 | + if ( $file && $file->getTimestamp() > $timestamp ) { |
1293 | 1293 | $imgChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
1294 | 1294 | } |
1295 | 1295 | } |
— | — | @@ -1300,15 +1300,15 @@ |
1301 | 1301 | */ |
1302 | 1302 | public function setViewFlags( $diff, $oldRev, $newRev ) { |
1303 | 1303 | $this->load(); |
1304 | | - if( $newRev && $oldRev ) { |
| 1304 | + if ( $newRev && $oldRev ) { |
1305 | 1305 | // Is this a diff between two pages? |
1306 | | - if( $newRev->getPage() != $oldRev->getPage() ) { |
| 1306 | + if ( $newRev->getPage() != $oldRev->getPage() ) { |
1307 | 1307 | $this->isMultiPageDiff = true; |
1308 | 1308 | // Is there a stable version? |
1309 | | - } else if( $this->article->isReviewable() ) { |
| 1309 | + } else if ( $this->article->isReviewable() ) { |
1310 | 1310 | $frev = $this->article->getStableRev(); |
1311 | 1311 | // 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() ) { |
1313 | 1313 | $this->isDiffFromStable = true; |
1314 | 1314 | } |
1315 | 1315 | } |
— | — | @@ -1323,16 +1323,16 @@ |
1324 | 1324 | global $wgUser, $wgOut; |
1325 | 1325 | $this->load(); |
1326 | 1326 | // Both revs must exists and the page must be reviewable |
1327 | | - if( !$newRev || !$oldRev || !$this->article->isReviewable() ) { |
| 1327 | + if ( !$newRev || !$oldRev || !$this->article->isReviewable() ) { |
1328 | 1328 | return true; // nothing to do |
1329 | 1329 | } |
1330 | 1330 | // Is there a stable version? |
1331 | 1331 | $frev = $this->article->getStableRev(); |
1332 | 1332 | # Give a link to the diff-to-stable if needed |
1333 | | - if( $frev && !$this->isDiffFromStable ) { |
| 1333 | + if ( $frev && !$this->isDiffFromStable ) { |
1334 | 1334 | $article = new Article( $newRev->getTitle() ); |
1335 | 1335 | # Is the stable revision using the same revision as the current? |
1336 | | - if( $article->getLatest() != $frev->getRevId() ) { |
| 1336 | + if ( $article->getLatest() != $frev->getRevId() ) { |
1337 | 1337 | $patrol = $wgUser->getSkin()->makeKnownLinkObj( |
1338 | 1338 | $newRev->getTitle(), |
1339 | 1339 | wfMsgHtml( 'review-diff2stable' ), |
— | — | @@ -1352,27 +1352,27 @@ |
1353 | 1353 | global $wgUser; |
1354 | 1354 | $this->load(); |
1355 | 1355 | # 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() ) |
1357 | 1357 | return true; |
1358 | 1358 | # We may want to skip some UI elements |
1359 | | - if( $this->article->limitedUI() ) |
| 1359 | + if ( $this->article->limitedUI() ) |
1360 | 1360 | return true; |
1361 | 1361 | # Get the stable version, from master |
1362 | 1362 | $frev = $this->article->getStableRev( FR_MASTER ); |
1363 | | - if( !$frev ) |
| 1363 | + if ( !$frev ) |
1364 | 1364 | return true; |
1365 | 1365 | # Get latest revision Id (lag safe) |
1366 | | - $latest = $this->article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
| 1366 | + $latest = $this->article->getTitle()->getLatestRevID( GAID_FOR_UPDATE ); |
1367 | 1367 | // If the edit was not autoreviewed, and the user can actually make a |
1368 | 1368 | // new stable version, then go to the diff... |
1369 | | - if( $latest > $frev->getRevId() && $frev->userCanSetFlags() ) { |
| 1369 | + if ( $latest > $frev->getRevId() && $frev->userCanSetFlags() ) { |
1370 | 1370 | $extraQuery .= $extraQuery ? '&' : ''; |
1371 | 1371 | $extraQuery .= "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; // override diff-only |
1372 | 1372 | // ...otherwise, go to the current revision after completing an edit. |
1373 | 1373 | } else { |
1374 | | - if( $frev && $latest != $frev->getRevId() ) { |
| 1374 | + if ( $frev && $latest != $frev->getRevId() ) { |
1375 | 1375 | $extraQuery .= "stable=0"; |
1376 | | - if( !$wgUser->isAllowed('review') && $this->article->isStableShownByDefault() ) { |
| 1376 | + if ( !$wgUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) { |
1377 | 1377 | $extraQuery .= "&shownotice=1"; |
1378 | 1378 | } |
1379 | 1379 | } |
— | — | @@ -1388,25 +1388,25 @@ |
1389 | 1389 | global $wgRequest; |
1390 | 1390 | $this->load(); |
1391 | 1391 | # Find out revision id |
1392 | | - if( $this->article->mRevision ) { |
| 1392 | + if ( $this->article->mRevision ) { |
1393 | 1393 | $revId = $this->article->mRevision->mId; |
1394 | 1394 | } else { |
1395 | | - $latest = $this->article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
| 1395 | + $latest = $this->article->getTitle()->getLatestRevID( GAID_FOR_UPDATE ); |
1396 | 1396 | $revId = $latest; |
1397 | 1397 | wfDebug( 'FlaggedArticle::addRevisionIDField - ID not specified, assumed current' ); |
1398 | 1398 | } |
1399 | 1399 | # 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() ) { |
1405 | 1405 | $revId = $undoAfter; |
1406 | 1406 | } |
1407 | 1407 | } |
1408 | 1408 | $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 ) |
1411 | 1411 | ); |
1412 | 1412 | return true; |
1413 | 1413 | } |
— | — | @@ -1417,7 +1417,7 @@ |
1418 | 1418 | */ |
1419 | 1419 | public function addReviewNotes( &$data ) { |
1420 | 1420 | $this->load(); |
1421 | | - if( $this->reviewNotes ) { |
| 1421 | + if ( $this->reviewNotes ) { |
1422 | 1422 | $data .= $this->reviewNotes; |
1423 | 1423 | } |
1424 | 1424 | return true; |
— | — | @@ -1432,13 +1432,13 @@ |
1433 | 1433 | public function addQuickReview( &$data, $top = false, $hide = false ) { |
1434 | 1434 | global $wgOut, $wgUser, $wgRequest; |
1435 | 1435 | $this->load(); |
1436 | | - if( $wgOut->isPrintable() ) { |
| 1436 | + if ( $wgOut->isPrintable() ) { |
1437 | 1437 | return false; // Must be on non-printable output |
1438 | 1438 | } |
1439 | 1439 | # Get the revision being displayed |
1440 | 1440 | $id = $wgOut->getRevisionId(); |
1441 | | - if( !$id ) { |
1442 | | - if( !$this->isDiffFromStable ) { |
| 1441 | + if ( !$id ) { |
| 1442 | + if ( !$this->isDiffFromStable ) { |
1443 | 1443 | return false; // only safe to assume current if diff-to-stable |
1444 | 1444 | } else { |
1445 | 1445 | $rev = Revision::newFromTitle( $this->article->getTitle() ); |
— | — | @@ -1448,31 +1448,31 @@ |
1449 | 1449 | $rev = Revision::newFromTitle( $this->article->getTitle(), $id ); |
1450 | 1450 | } |
1451 | 1451 | # The revision must be valid and public |
1452 | | - if( !$rev || $rev->isDeleted(Revision::DELETED_TEXT) ) { |
| 1452 | + if ( !$rev || $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
1453 | 1453 | return false; |
1454 | 1454 | } |
1455 | 1455 | $useCurrent = false; |
1456 | | - if( !isset($wgOut->mTemplateIds) || !isset($wgOut->fr_ImageSHA1Keys) ) { |
| 1456 | + if ( !isset( $wgOut->mTemplateIds ) || !isset( $wgOut->fr_ImageSHA1Keys ) ) { |
1457 | 1457 | $useCurrent = true; // we need to get Ids from parser output |
1458 | 1458 | } |
1459 | 1459 | $skin = $wgUser->getSkin(); |
1460 | 1460 | |
1461 | 1461 | $config = $this->article->getVisibilitySettings(); |
1462 | 1462 | # Variable for sites with no flags, otherwise discarded |
1463 | | - $approve = $wgRequest->getBool('wpApprove'); |
| 1463 | + $approve = $wgRequest->getBool( 'wpApprove' ); |
1464 | 1464 | # See if the version being displayed is flagged... |
1465 | 1465 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $id ); |
1466 | 1466 | $oldFlags = $frev |
1467 | 1467 | ? $frev->getTags() // existing tags |
1468 | | - : FlaggedRevision::expandRevisionTags(''); // unset tags |
| 1468 | + : FlaggedRevision::expandRevisionTags( '' ); // unset tags |
1469 | 1469 | # If we are reviewing updates to a page, start off with the stable revision's |
1470 | 1470 | # flags. Otherwise, we just fill them in with the selected revision's flags. |
1471 | | - if( $this->isDiffFromStable ) { |
| 1471 | + if ( $this->isDiffFromStable ) { |
1472 | 1472 | $srev = $this->article->getStableRev(); |
1473 | 1473 | $flags = $srev->getTags(); |
1474 | 1474 | # Check if user is allowed to renew the stable version. |
1475 | 1475 | # If not, then get the flags for the new revision itself. |
1476 | | - if( !RevisionReview::userCanSetFlags( $oldFlags ) ) { |
| 1476 | + if ( !RevisionReview::userCanSetFlags( $oldFlags ) ) { |
1477 | 1477 | $flags = $oldFlags; |
1478 | 1478 | } |
1479 | 1479 | $reviewNotes = $srev->getComment(); |
— | — | @@ -1486,68 +1486,68 @@ |
1487 | 1487 | $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' ); |
1488 | 1488 | $action = $reviewTitle->getLocalUrl( 'action=submit' ); |
1489 | 1489 | $params = array( 'method' => 'post', 'action' => $action, 'id' => 'mw-fr-reviewform' ); |
1490 | | - if( $hide ) { |
| 1490 | + if ( $hide ) { |
1491 | 1491 | $params['class'] = 'fr-hiddenform'; |
1492 | 1492 | } |
1493 | 1493 | $form = Xml::openElement( 'form', $params ); |
1494 | 1494 | $form .= Xml::openElement( 'fieldset', |
1495 | | - array('class' => 'flaggedrevs_reviewform noprint') ); |
| 1495 | + array( 'class' => 'flaggedrevs_reviewform noprint' ) ); |
1496 | 1496 | # Add appropriate legend text |
1497 | 1497 | $legendMsg = ( FlaggedRevs::binaryFlagging() && $frev ) |
1498 | 1498 | ? 'revreview-reflag' |
1499 | 1499 | : 'revreview-flag'; |
1500 | | - $form .= Xml::openElement( 'legend', array('id' => 'mw-fr-reviewformlegend') ); |
| 1500 | + $form .= Xml::openElement( 'legend', array( 'id' => 'mw-fr-reviewformlegend' ) ); |
1501 | 1501 | $form .= "<strong>" . wfMsgHtml( $legendMsg ) . "</strong>"; |
1502 | 1502 | $form .= Xml::closeElement( 'legend' ) . "\n"; |
1503 | 1503 | # Show explanatory text |
1504 | | - if( !FlaggedRevs::lowProfileUI() ) { |
| 1504 | + if ( !FlaggedRevs::lowProfileUI() ) { |
1505 | 1505 | $msg = FlaggedRevs::isStableShownByDefault() ? 'revreview-text' : 'revreview-text2'; |
1506 | | - $form .= wfMsgExt( $msg, array('parse') ); |
| 1506 | + $form .= wfMsgExt( $msg, array( 'parse' ) ); |
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | # Disable form for unprivileged users |
1510 | | - $uneditable = !$this->article->getTitle()->quickUserCan('edit'); |
| 1510 | + $uneditable = !$this->article->getTitle()->quickUserCan( 'edit' ); |
1511 | 1511 | $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' ) ); |
1515 | 1515 | $toggle = array( 'disabled' => "disabled" ); |
1516 | 1516 | } 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' ) ); |
1519 | 1519 | $toggle = array(); |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | # Add main checkboxes/selects |
1523 | | - $form .= Xml::openElement( 'span', array('id' => 'mw-fr-ratingselects') ); |
| 1523 | + $form .= Xml::openElement( 'span', array( 'id' => 'mw-fr-ratingselects' ) ); |
1524 | 1524 | $form .= FlaggedRevsXML::ratingInputs( $flags, $config, $disabled, (bool)$frev ); |
1525 | 1525 | $form .= Xml::closeElement( 'span' ); |
1526 | 1526 | # Add review notes input |
1527 | | - if( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) { |
| 1527 | + if ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) { |
1528 | 1528 | $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' ) ) . |
1532 | 1532 | htmlspecialchars( $reviewNotes ) . |
1533 | | - Xml::closeElement('textarea') . "\n"; |
| 1533 | + Xml::closeElement( 'textarea' ) . "\n"; |
1534 | 1534 | $form .= "</div>\n"; |
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | # Get versions of templates/files used |
1538 | 1538 | $imageParams = $templateParams = $fileVersion = ''; |
1539 | | - if( $useCurrent ) { |
| 1539 | + if ( $useCurrent ) { |
1540 | 1540 | # Get parsed current version |
1541 | 1541 | $parserCache = ParserCache::singleton(); |
1542 | 1542 | $article = $this->article; |
1543 | 1543 | $currentOutput = $parserCache->get( $article, $wgUser ); |
1544 | | - if( $currentOutput == false ) { |
| 1544 | + if ( $currentOutput == false ) { |
1545 | 1545 | global $wgParser, $wgEnableParserCache; |
1546 | 1546 | $text = $article->getContent(); |
1547 | 1547 | $title = $article->getTitle(); |
1548 | 1548 | $options = FlaggedRevs::makeParserOptions(); |
1549 | 1549 | $currentOutput = $wgParser->parse( $text, $title, $options ); |
1550 | 1550 | # Might as well save the cache while we're at it |
1551 | | - if( $wgEnableParserCache ) |
| 1551 | + if ( $wgEnableParserCache ) |
1552 | 1552 | $parserCache->save( $currentOutput, $article, $wgUser ); |
1553 | 1553 | } |
1554 | 1554 | $templateIDs = $currentOutput->mTemplateIds; |
— | — | @@ -1556,17 +1556,17 @@ |
1557 | 1557 | $templateIDs = $wgOut->mTemplateIds; |
1558 | 1558 | $imageSHA1Keys = $wgOut->fr_ImageSHA1Keys; |
1559 | 1559 | } |
1560 | | - list($templateParams,$imageParams,$fileVersion) = |
| 1560 | + list( $templateParams, $imageParams, $fileVersion ) = |
1561 | 1561 | FlaggedRevs::getIncludeParams( $this->article, $templateIDs, $imageSHA1Keys ); |
1562 | 1562 | |
1563 | | - $form .= Xml::openElement( 'span', array('style' => 'white-space: nowrap;') ); |
| 1563 | + $form .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap;' ) ); |
1564 | 1564 | # Hide comment input if needed |
1565 | | - if( !$disabled ) { |
1566 | | - if( count(FlaggedRevs::getDimensions()) > 1 ) |
| 1565 | + if ( !$disabled ) { |
| 1566 | + if ( count( FlaggedRevs::getDimensions() ) > 1 ) |
1567 | 1567 | $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') ) . " </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' ) ) . " </span>"; |
1571 | 1571 | } |
1572 | 1572 | # Add the submit buttons |
1573 | 1573 | $form .= FlaggedRevsXML::ratingSubmitButtons( $frev, (bool)$toggle ); |
— | — | @@ -1578,14 +1578,14 @@ |
1579 | 1579 | $form .= Xml::hidden( 'title', $reviewTitle->getPrefixedText() ) . "\n"; |
1580 | 1580 | $form .= Xml::hidden( 'target', $this->article->getTitle()->getPrefixedDBKey() ) . "\n"; |
1581 | 1581 | $form .= Xml::hidden( 'oldid', $id ) . "\n"; |
1582 | | - $form .= Xml::hidden( 'action', 'submit') . "\n"; |
| 1582 | + $form .= Xml::hidden( 'action', 'submit' ) . "\n"; |
1583 | 1583 | $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n"; |
1584 | 1584 | # Add review parameters |
1585 | 1585 | $form .= Xml::hidden( 'templateParams', $templateParams ) . "\n"; |
1586 | 1586 | $form .= Xml::hidden( 'imageParams', $imageParams ) . "\n"; |
1587 | 1587 | $form .= Xml::hidden( 'fileVersion', $fileVersion ) . "\n"; |
1588 | 1588 | # 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"; |
1590 | 1590 | # Special token to discourage fiddling... |
1591 | 1591 | $checkCode = RevisionReview::validationKey( |
1592 | 1592 | $templateParams, $imageParams, $fileVersion, $id |
— | — | @@ -1595,7 +1595,7 @@ |
1596 | 1596 | $form .= Xml::closeElement( 'fieldset' ); |
1597 | 1597 | $form .= Xml::closeElement( 'form' ); |
1598 | 1598 | # Place form at the correct position specified by $top |
1599 | | - if( $top ) { |
| 1599 | + if ( $top ) { |
1600 | 1600 | $wgOut->prependHTML( $form ); |
1601 | 1601 | } else { |
1602 | 1602 | $data .= $form; |
— | — | @@ -1611,21 +1611,21 @@ |
1612 | 1612 | $this->load(); |
1613 | 1613 | |
1614 | 1614 | $action = $wgRequest->getVal( 'action', 'view' ); |
1615 | | - if( $action == 'purge' ) |
| 1615 | + if ( $action == 'purge' ) |
1616 | 1616 | return true; // already purging! |
1617 | 1617 | # 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' ) ) |
1619 | 1619 | return true; |
1620 | | - if( !$this->article->exists() || !$this->article->isReviewable() ) |
| 1620 | + if ( !$this->article->exists() || !$this->article->isReviewable() ) |
1621 | 1621 | return true; |
1622 | 1622 | |
1623 | 1623 | $parserCache = ParserCache::singleton(); |
1624 | 1624 | $parserOut = $parserCache->get( $this->article, $wgUser ); |
1625 | | - if( $parserOut ) { |
| 1625 | + if ( $parserOut ) { |
1626 | 1626 | # Clear older, incomplete, cached versions |
1627 | 1627 | # 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 ) ) |
1630 | 1630 | { |
1631 | 1631 | $this->article->getTitle()->invalidateCache(); |
1632 | 1632 | } |