Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -404,61 +404,9 @@ |
405 | 405 | $wgAutoloadClasses['ApiStabilize'] = $dir . 'api/ApiStabilize.php'; |
406 | 406 | $wgAPIModules['stabilize'] = 'ApiStabilize'; |
407 | 407 | |
408 | | -# ######## Hook triggered data operations ######### |
409 | | -# Autopromote Editors |
410 | | -$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeMakeEditor'; |
411 | | -# Adds table link references to include ones from the stable version |
412 | | -$wgHooks['LinksUpdate'][] = 'FlaggedRevsHooks::extraLinksUpdate'; |
413 | | -# Clear dead config rows |
414 | | -$wgHooks['ArticleDeleteComplete'][] = 'FlaggedRevsHooks::onArticleDelete'; |
415 | | -$wgHooks['ArticleRevisionVisiblitySet'][] = 'FlaggedRevsHooks::onRevisionDelete'; |
416 | | -$wgHooks['TitleMoveComplete'][] = 'FlaggedRevsHooks::onTitleMoveComplete'; |
417 | | -# Check on undelete/merge for changes to stable version |
418 | | -$wgHooks['ArticleMergeComplete'][] = 'FlaggedRevsHooks::updateFromMerge'; |
419 | | -$wgHooks['ArticleRevisionUndeleted'][] = 'FlaggedRevsHooks::onRevisionRestore'; |
420 | | -# Parser hooks, selects the desired images/templates |
421 | | -$wgHooks['ParserClearState'][] = 'FlaggedRevsHooks::parserAddFields'; |
422 | | -$wgHooks['BeforeGalleryFindFile'][] = 'FlaggedRevsHooks::galleryFindStableFileTime'; |
423 | | -$wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
424 | | -$wgHooks['BeforeParserMakeImageLinkObj'][] = 'FlaggedRevsHooks::parserMakeStableFileLink'; |
425 | | -# Additional parser versioning |
426 | | -$wgHooks['ParserAfterTidy'][] = 'FlaggedRevsHooks::parserInjectTimestamps'; |
427 | | -$wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputInjectTimestamps'; |
428 | | -# Auto-reviewing |
429 | | -$wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled'; |
430 | | -$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
431 | | -# Determine what pages can be moved and patrolled |
432 | | -$wgHooks['userCan'][] = 'FlaggedRevsHooks::onUserCan'; |
433 | | -# Log parameter |
434 | | -$wgHooks['LogLine'][] = 'FlaggedRevsHooks::logLineLinks'; |
435 | | -# Disable auto-promotion for demoted users |
436 | | -$wgHooks['UserRights'][] = 'FlaggedRevsHooks::recordDemote'; |
437 | | -# User stats |
438 | | -$wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks'; |
439 | | -$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::incrementReverts'; |
440 | | -# Null edit review via checkbox |
441 | | -$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview'; |
442 | | -# Special auto-promote |
443 | | -$wgHooks['GetAutoPromoteGroups'][] = 'FlaggedRevsHooks::checkAutoPromote'; |
444 | | -# Save stability settings |
445 | | -$wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave'; |
| 408 | +######## HOOK TRIGGERED FUNCTIONS ######### |
446 | 409 | |
447 | | -# Actually register special pages |
448 | | -$wgHooks['SpecialPage_initList'][] = 'efLoadFlaggedRevsSpecialPages'; |
449 | | - |
450 | | -# Stable dump hook |
451 | | -$wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
452 | | -# ######## |
453 | | - |
454 | | - |
455 | | -# ######## Hook triggered UI operations ######### |
456 | | -# Local user account preference |
457 | | -$wgHooks['GetPreferences'][] = 'FlaggedRevsHooks::onGetPreferences'; |
458 | | -# Show unreviewed pages links |
459 | | -$wgHooks['CategoryPageView'][] = 'FlaggedRevsHooks::onCategoryPageView'; |
460 | | -# Backlog notice |
461 | | -$wgHooks['SiteNoticeAfter'][] = 'FlaggedRevsHooks::addBacklogNotice'; |
462 | | - |
| 410 | +# ######## User interface ######### |
463 | 411 | # Override current revision, add patrol links, set cache... |
464 | 412 | $wgHooks['ArticleViewHeader'][] = 'FlaggedRevsHooks::onArticleViewHeader'; |
465 | 413 | $wgHooks['ImagePageFindFile'][] = 'FlaggedRevsHooks::imagePageFindFile'; |
— | — | @@ -495,29 +443,88 @@ |
496 | 444 | $wgHooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsHooks::injectPostEditURLParams'; |
497 | 445 | # Diff-to-stable |
498 | 446 | $wgHooks['DiffViewHeader'][] = 'FlaggedRevsHooks::onDiffViewHeader'; |
| 447 | +# Add diff=review url param alias |
| 448 | +$wgHooks['NewDifferenceEngine'][] = 'FlaggedRevsHooks::checkDiffUrl'; |
499 | 449 | # Autoreview stuff |
500 | 450 | $wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsHooks::addRevisionIDField'; |
501 | 451 | $wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsHooks::addReviewCheck'; |
502 | | -# Add diff url param alias |
503 | | -$wgHooks['NewDifferenceEngine'][] = 'FlaggedRevsHooks::checkDiffUrl'; |
504 | | -# Check if a page is currently being reviewed |
505 | | -$wgHooks['MediaWikiPerformAction'][] = 'FlaggedRevsHooks::markUnderReview'; |
| 452 | +# Local user account preference |
| 453 | +$wgHooks['GetPreferences'][] = 'FlaggedRevsHooks::onGetPreferences'; |
| 454 | +# Show unreviewed pages links |
| 455 | +$wgHooks['CategoryPageView'][] = 'FlaggedRevsHooks::onCategoryPageView'; |
| 456 | +# Backlog notice |
| 457 | +$wgHooks['SiteNoticeAfter'][] = 'FlaggedRevsHooks::addBacklogNotice'; |
| 458 | +# Review/stability log links |
| 459 | +$wgHooks['LogLine'][] = 'FlaggedRevsHooks::logLineLinks'; |
506 | 460 | |
507 | 461 | # Add CSS/JS as needed |
508 | 462 | $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::onBeforePageDisplay'; |
509 | 463 | $wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars'; |
510 | 464 | |
| 465 | +# Add flagging data to ApiQueryRevisions |
| 466 | +$wgHooks['APIGetAllowedParams'][] = 'FlaggedRevsApiHooks::addApiRevisionParams'; |
| 467 | +$wgHooks['APIQueryAfterExecute'][] = 'FlaggedRevsApiHooks::addApiRevisionData'; |
| 468 | +# ######## |
| 469 | + |
| 470 | +# ######## Parser ######### |
| 471 | +# Parser hooks, selects the desired images/templates |
| 472 | +$wgHooks['ParserClearState'][] = 'FlaggedRevsHooks::parserAddFields'; |
| 473 | +$wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
| 474 | +$wgHooks['BeforeParserMakeImageLinkObj'][] = 'FlaggedRevsHooks::parserMakeStableFileLink'; |
| 475 | +$wgHooks['BeforeGalleryFindFile'][] = 'FlaggedRevsHooks::galleryFindStableFileTime'; |
| 476 | +# Additional parser versioning |
| 477 | +$wgHooks['ParserAfterTidy'][] = 'FlaggedRevsHooks::parserInjectTimestamps'; |
| 478 | +$wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputInjectTimestamps'; |
| 479 | +# ######## |
| 480 | + |
| 481 | +# ######## DB write operations ######### |
| 482 | +# Autopromote Editors |
| 483 | +$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeMakeEditor'; |
| 484 | +# Auto-reviewing |
| 485 | +$wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled'; |
| 486 | +$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
| 487 | +# Disable auto-promotion for demoted users |
| 488 | +$wgHooks['UserRights'][] = 'FlaggedRevsHooks::recordDemote'; |
| 489 | +# User edit tallies |
| 490 | +$wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks'; |
| 491 | +$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::incrementReverts'; |
| 492 | +# Null edit review via checkbox |
| 493 | +$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview'; |
| 494 | +# Save stability settings |
| 495 | +$wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave'; |
511 | 496 | # Extra cache updates for stable versions |
512 | 497 | $wgHooks['HTMLCacheUpdate::doUpdate'][] = 'FlaggedRevsHooks::doCacheUpdate'; |
| 498 | +# Updates stable version tracking data |
| 499 | +$wgHooks['LinksUpdate'][] = 'FlaggedRevsHooks::extraLinksUpdate'; |
| 500 | +# Clear dead config rows |
| 501 | +$wgHooks['ArticleDeleteComplete'][] = 'FlaggedRevsHooks::onArticleDelete'; |
| 502 | +$wgHooks['ArticleRevisionVisiblitySet'][] = 'FlaggedRevsHooks::onRevisionDelete'; |
| 503 | +$wgHooks['TitleMoveComplete'][] = 'FlaggedRevsHooks::onTitleMoveComplete'; |
| 504 | +# Check on undelete/merge for changes to stable version |
| 505 | +$wgHooks['ArticleMergeComplete'][] = 'FlaggedRevsHooks::updateFromMerge'; |
| 506 | +$wgHooks['ArticleRevisionUndeleted'][] = 'FlaggedRevsHooks::onRevisionRestore'; |
| 507 | +# ######## |
513 | 508 | |
| 509 | +# ######## Other ######### |
| 510 | +# Determine what pages can be moved and patrolled |
| 511 | +$wgHooks['userCan'][] = 'FlaggedRevsHooks::onUserCan'; |
| 512 | +# Implicit autoreview rights group |
| 513 | +$wgHooks['GetAutoPromoteGroups'][] = 'FlaggedRevsHooks::checkAutoPromote'; |
| 514 | + |
| 515 | +# Check if a page is currently being reviewed |
| 516 | +$wgHooks['MediaWikiPerformAction'][] = 'FlaggedRevsHooks::markUnderReview'; |
| 517 | + |
| 518 | +# Actually register special pages |
| 519 | +$wgHooks['SpecialPage_initList'][] = 'efLoadFlaggedRevsSpecialPages'; |
| 520 | +# Stable dump hook |
| 521 | +$wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
| 522 | + |
514 | 523 | # Duplicate flagged* tables in parserTests.php |
515 | 524 | $wgHooks['ParserTestTables'][] = 'FlaggedRevsHooks::onParserTestTables'; |
516 | | - |
517 | | -# Add flagging data to ApiQueryRevisions |
518 | | -$wgHooks['APIGetAllowedParams'][] = 'FlaggedRevsApiHooks::addApiRevisionParams'; |
519 | | -$wgHooks['APIQueryAfterExecute'][] = 'FlaggedRevsApiHooks::addApiRevisionData'; |
520 | 525 | # ######## |
521 | 526 | |
| 527 | +######## END HOOK TRIGGERED FUNCTIONS ######### |
| 528 | + |
522 | 529 | function efLoadFlaggedRevs() { |
523 | 530 | global $wgUseRCPatrol, $wgFlaggedRevsNamespaces, $wgFlaggedRevsVisible; |
524 | 531 | # If patrolling is already on, then we know that it |
— | — | @@ -549,28 +556,29 @@ |
550 | 557 | global $wgSpecialPages, $wgUseTagFilter; |
551 | 558 | global $wgFlaggedRevsNamespaces, $wgFlaggedRevsOverride, $wgFlaggedRevsProtectLevels; |
552 | 559 | // Show special pages only if FlaggedRevs is enabled on some namespaces |
553 | | - if ( !empty( $wgFlaggedRevsNamespaces ) ) { |
554 | | - $list['RevisionReview'] = $wgSpecialPages['RevisionReview'] = 'RevisionReview'; |
555 | | - $list['ReviewedVersions'] = $wgSpecialPages['ReviewedVersions'] = 'ReviewedVersions'; |
556 | | - // Protect levels define allowed stability settings |
557 | | - if ( empty( $wgFlaggedRevsProtectLevels ) ) { |
558 | | - $list['Stabilization'] = $wgSpecialPages['Stabilization'] = 'Stabilization'; |
559 | | - } |
560 | | - $list['UnreviewedPages'] = $wgSpecialPages['UnreviewedPages'] = 'UnreviewedPages'; |
561 | | - $list['OldReviewedPages'] = $wgSpecialPages['OldReviewedPages'] = 'OldReviewedPages'; |
562 | | - // Show tag filtered pending edit page if there are tags |
563 | | - if ( $wgUseTagFilter && ChangeTags::listDefinedTags() ) { |
564 | | - $list['ProblemChanges'] = $wgSpecialPages['ProblemChanges'] = 'ProblemChanges'; |
565 | | - } |
566 | | - $list['ReviewedPages'] = $wgSpecialPages['ReviewedPages'] = 'ReviewedPages'; |
567 | | - $list['QualityOversight'] = $wgSpecialPages['QualityOversight'] = 'QualityOversight'; |
568 | | - $list['ValidationStatistics'] = $wgSpecialPages['ValidationStatistics'] = 'ValidationStatistics'; |
569 | | - if ( !$wgFlaggedRevsOverride ) { |
570 | | - $list['StablePages'] = $wgSpecialPages['StablePages'] = 'StablePages'; |
571 | | - } else { |
572 | | - $list['UnstablePages'] = $wgSpecialPages['UnstablePages'] = 'UnstablePages'; |
573 | | - } |
| 560 | + if ( empty( $wgFlaggedRevsNamespaces ) ) { |
| 561 | + return true; |
574 | 562 | } |
| 563 | + $list['RevisionReview'] = $wgSpecialPages['RevisionReview'] = 'RevisionReview'; |
| 564 | + $list['ReviewedVersions'] = $wgSpecialPages['ReviewedVersions'] = 'ReviewedVersions'; |
| 565 | + // Protect levels define allowed stability settings |
| 566 | + if ( empty( $wgFlaggedRevsProtectLevels ) ) { |
| 567 | + $list['Stabilization'] = $wgSpecialPages['Stabilization'] = 'Stabilization'; |
| 568 | + } |
| 569 | + $list['UnreviewedPages'] = $wgSpecialPages['UnreviewedPages'] = 'UnreviewedPages'; |
| 570 | + $list['OldReviewedPages'] = $wgSpecialPages['OldReviewedPages'] = 'OldReviewedPages'; |
| 571 | + // Show tag filtered pending edit page if there are tags |
| 572 | + if ( $wgUseTagFilter && ChangeTags::listDefinedTags() ) { |
| 573 | + $list['ProblemChanges'] = $wgSpecialPages['ProblemChanges'] = 'ProblemChanges'; |
| 574 | + } |
| 575 | + $list['ReviewedPages'] = $wgSpecialPages['ReviewedPages'] = 'ReviewedPages'; |
| 576 | + $list['QualityOversight'] = $wgSpecialPages['QualityOversight'] = 'QualityOversight'; |
| 577 | + $list['ValidationStatistics'] = $wgSpecialPages['ValidationStatistics'] = 'ValidationStatistics'; |
| 578 | + if ( !$wgFlaggedRevsOverride ) { |
| 579 | + $list['StablePages'] = $wgSpecialPages['StablePages'] = 'StablePages'; |
| 580 | + } else { |
| 581 | + $list['UnstablePages'] = $wgSpecialPages['UnstablePages'] = 'UnstablePages'; |
| 582 | + } |
575 | 583 | return true; |
576 | 584 | } |
577 | 585 | |