r66532 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66531‎ | r66532 | r66533 >
Date:14:16, 16 May 2010
Author:aaron
Status:ok
Tags:
Comment:
* Added class description
* Whitespace consistency :)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1,5 +1,7 @@
22 <?php
3 -
 3+/**
 4+ * Class containing hooked functions for a FlaggedRevs environment
 5+ */
46 class FlaggedRevsHooks {
57 /*
68 * Register FlaggedRevs special pages as needed.
@@ -78,7 +80,7 @@
7981
8082 return true;
8183 }
82 -
 84+
8385 public static function injectGlobalJSVars( &$globalVars ) {
8486 global $wgUser;
8587 $fa = FlaggedArticleView::globalArticleInstance();
@@ -112,7 +114,7 @@
113115 }
114116 return true;
115117 }
116 -
 118+
117119 /**
118120 * Add FlaggedRevs css for relevant special pages.
119121 */
@@ -136,7 +138,7 @@
137139 }
138140 return true;
139141 }
140 -
 142+
141143 /*
142144 * Add tag notice, CSS/JS, and set robots policy
143145 */
@@ -225,7 +227,7 @@
226228
227229 return true;
228230 }
229 -
 231+
230232 /**
231233 * Update flaggedrevs tracking tables
232234 */
@@ -233,7 +235,7 @@
234236 FlaggedRevs::clearTrackingRows( $id );
235237 return true;
236238 }
237 -
 239+
238240 /**
239241 * Update stable version selection
240242 */
@@ -241,7 +243,7 @@
242244 FlaggedRevs::titleLinksUpdate( $title );
243245 return true;
244246 }
245 -
 247+
246248 /**
247249 * Update pending revision table
248250 * Autoreview pages moved into content NS
@@ -388,7 +390,7 @@
389391 }
390392 $links[$ns][$dbKey] = 1;
391393 }
392 -
 394+
393395 protected static function getExistingLinks( $pageId ) {
394396 $dbr = wfGetDB( DB_SLAVE );
395397 $res = $dbr->select( 'flaggedrevs_tracking',
@@ -404,13 +406,13 @@
405407 }
406408 return $arr;
407409 }
408 -
 410+
409411 protected static function makeWhereFrom2d( &$arr ) {
410412 $lb = new LinkBatch();
411413 $lb->setArray( $arr );
412414 return $lb->constructSet( 'ftr', wfGetDB( DB_SLAVE ) );
413415 }
414 -
 416+
415417 protected static function getLinkInsertions( $existing, $new, $pageId ) {
416418 $arr = array();
417419 foreach ( $new as $ns => $dbkeys ) {
@@ -426,7 +428,7 @@
427429 }
428430 return $arr;
429431 }
430 -
 432+
431433 protected static function getLinkDeletions( $existing, $new ) {
432434 $del = array();
433435 foreach ( $existing as $ns => $dbkeys ) {
@@ -438,7 +440,7 @@
439441 }
440442 return $del;
441443 }
442 -
 444+
443445 /*
444446 * Update pages where only the stable version links to a page
445447 * that was just changed in some way.
@@ -448,7 +450,7 @@
449451 $update->doUpdate();
450452 return true;
451453 }
452 -
 454+
453455 /**
454456 * Add special fields to parser.
455457 */
@@ -706,7 +708,7 @@
707709 }
708710 return true;
709711 }
710 -
 712+
711713 /**
712714 * Insert image timestamps/SHA-1 keys into parser output
713715 */
@@ -820,7 +822,7 @@
821823 }
822824 return true;
823825 }
824 -
 826+
825827 /**
826828 * Allow users to view reviewed pages
827829 */
@@ -857,7 +859,7 @@
858860 }
859861 return true;
860862 }
861 -
 863+
862864 /**
863865 * When an edit is made by a reviewer, if the base revision the
864866 * edit was made from is the stable version, or the edit is a reversion
@@ -1013,7 +1015,7 @@
10141016 # Confirm the text because we can't trust this user.
10151017 return ( $rev->getText() == $srev->getRevText() );
10161018 }
1017 -
 1019+
10181020 /**
10191021 * When an user makes a null-edit we sometimes want to review it...
10201022 * (a) Null undo or rollback
@@ -1128,7 +1130,7 @@
11291131 }
11301132 return true;
11311133 }
1132 -
 1134+
11331135 public static function incrementRollbacks( $this, $user, $target, $current ) {
11341136 # Mark when a user reverts another user, but not self-reverts
11351137 if ( $current->getRawUser() && $user->getId() != $current->getRawUser() ) {
@@ -1139,7 +1141,7 @@
11401142 }
11411143 return true;
11421144 }
1143 -
 1145+
11441146 public static function incrementReverts( $article, $rev, $baseRevId = false, $user = null ) {
11451147 global $wgRequest;
11461148 # Was this an edit by an auto-sighter that undid another edit?
@@ -1156,7 +1158,7 @@
11571159 }
11581160 return true;
11591161 }
1160 -
 1162+
11611163 protected static function editSpacingCheck( $spacing, $points, $user ) {
11621164 # Convert days to seconds...
11631165 $spacing = $spacing * 24 * 3600;
@@ -1183,7 +1185,7 @@
11841186 }
11851187 return ( $benchmarks >= $needed );
11861188 }
1187 -
 1189+
11881190 /**
11891191 * Checks if $user was previously blocked
11901192 */
@@ -1199,7 +1201,7 @@
12001202 array( 'USE INDEX' => 'page_time' )
12011203 );
12021204 }
1203 -
 1205+
12041206 /**
12051207 * Check for 'autoreview' permission. This lets people who opt-out as
12061208 * Editors still have their own edits automatically reviewed. Bot
@@ -1535,7 +1537,7 @@
15361538
15371539 return true;
15381540 }
1539 -
 1541+
15401542 /**
15411543 * Record demotion so that auto-promote will be disabled
15421544 */
@@ -1555,7 +1557,7 @@
15561558 }
15571559 return true;
15581560 }
1559 -
 1561+
15601562 /** Add user preferences */
15611563 public static function onGetPreferences( $user, &$preferences ) {
15621564 // Box or bar UI
@@ -1602,7 +1604,7 @@
16031605 }
16041606 return true;
16051607 }
1606 -
 1608+
16071609 public static function logLineLinks(
16081610 $type, $action, $title = null, $params, &$comment, &$rv, $ts
16091611 ) {
@@ -1651,7 +1653,7 @@
16521654 $view->setPageContent( $outputDone, $pcache );
16531655 return true;
16541656 }
1655 -
 1657+
16561658 public static function overrideRedirect(
16571659 &$title, $request, &$ignoreRedirect, &$target, &$article
16581660 ) {
@@ -1690,31 +1692,31 @@
16911693 }
16921694 return true;
16931695 }
1694 -
 1696+
16951697 public static function addToEditView( &$editPage ) {
16961698 $view = FlaggedArticleView::singleton();
16971699 $view->addToEditView( $editPage );
16981700 return true;
16991701 }
1700 -
 1702+
17011703 public static function onNoSuchSection( &$editPage, &$s ) {
17021704 $view = FlaggedArticleView::singleton();
17031705 $view->addToNoSuchSection( $editPage, $s );
17041706 return true;
17051707 }
1706 -
 1708+
17071709 public static function addToHistView( &$article ) {
17081710 $view = FlaggedArticleView::singleton();
17091711 $view->addToHistView();
17101712 return true;
17111713 }
1712 -
 1714+
17131715 public static function onCategoryPageView( &$category ) {
17141716 $view = FlaggedArticleView::singleton();
17151717 $view->addToCategoryView();
17161718 return true;
17171719 }
1718 -
 1720+
17191721 public static function onSkinAfterContent( &$data ) {
17201722 global $wgOut;
17211723 if ( $wgOut->isArticleRelated()
@@ -1727,7 +1729,7 @@
17281730 }
17291731 return true;
17301732 }
1731 -
 1733+
17321734 public static function addToHistQuery( $pager, &$queryInfo ) {
17331735 $flaggedArticle = FlaggedArticle::getArticleInstance( $pager->getArticle() );
17341736 # Non-content pages cannot be validated. Stable version must exist.
@@ -1748,7 +1750,7 @@
17491751 }
17501752 return true;
17511753 }
1752 -
 1754+
17531755 public static function addToFileHistQuery(
17541756 $file, &$tables, &$fields, &$conds, &$opts, &$join_conds
17551757 ) {
@@ -1767,7 +1769,7 @@
17681770 }
17691771 return true;
17701772 }
1771 -
 1773+
17721774 public static function addToContribsQuery( $pager, &$queryInfo ) {
17731775 # Highlight flaggedrevs
17741776 $queryInfo['tables'][] = 'flaggedrevs';
@@ -1780,13 +1782,13 @@
17811783 $queryInfo['join_conds']['flaggedpages'] = array( 'LEFT JOIN', "fp_page_id = rev_page" );
17821784 return true;
17831785 }
1784 -
 1786+
17851787 public static function addToRCQuery( &$conds, &$tables, &$join_conds, $opts ) {
17861788 $tables[] = 'flaggedpages';
17871789 $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' );
17881790 return true;
17891791 }
1790 -
 1792+
17911793 public static function addToWatchlistQuery( &$conds, &$tables, &$join_conds, &$fields ) {
17921794 global $wgUser;
17931795 if ( $wgUser->isAllowed( 'review' ) ) {
@@ -1796,7 +1798,7 @@
17971799 }
17981800 return true;
17991801 }
1800 -
 1802+
18011803 public static function addToHistLine( $history, $row, &$s, &$liClasses ) {
18021804 $fa = FlaggedArticle::getArticleInstance( $history->getArticle() );
18031805 if ( !$fa->isReviewable() ) {
@@ -1838,8 +1840,7 @@
18391841 if ( $link ) $s .= " <small>$link</small>";
18401842 return true;
18411843 }
1842 -
1843 -
 1844+
18441845 /**
18451846 * Make stable version link and return the css
18461847 * @param Title $title
@@ -1873,7 +1874,7 @@
18741875 $link = "<span class='$css plainlinks'>[$link]</span>";
18751876 return array( $link, $liCss );
18761877 }
1877 -
 1878+
18781879 public static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) {
18791880 if ( !$file->isVisible() ) {
18801881 return true; // Don't bother showing notice for deleted revs
@@ -1896,7 +1897,7 @@
18971898 }
18981899 return true;
18991900 }
1900 -
 1901+
19011902 public static function addToContribsLine( $contribs, &$ret, $row ) {
19021903 $namespaces = FlaggedRevs::getReviewNamespaces();
19031904 if ( !in_array( $row->page_namespace, $namespaces ) ) {
@@ -1911,7 +1912,7 @@
19121913 }
19131914 return true;
19141915 }
1915 -
 1916+
19161917 public static function addToChangeListLine(
19171918 &$list, &$articlelink, &$s, &$rc, $unpatrolled, $watched
19181919 ) {
@@ -1944,13 +1945,13 @@
19451946 }
19461947 return true;
19471948 }
1948 -
 1949+
19491950 public static function injectPostEditURLParams( $article, &$sectionAnchor, &$extraQuery ) {
19501951 $view = FlaggedArticleView::singleton();
19511952 $view->injectPostEditURLParams( $sectionAnchor, $extraQuery );
19521953 return true;
19531954 }
1954 -
 1955+
19551956 // diff=review param (bug 16923)
19561957 public static function checkDiffUrl( $titleObj, &$mOldid, &$mNewid, $old, $new ) {
19571958 if ( $new === 'review' && isset( $titleObj ) ) {
@@ -1976,7 +1977,7 @@
19771978 $view->addRevisionIDField( $editPage, $out );
19781979 return true;
19791980 }
1980 -
 1981+
19811982 public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) {
19821983 global $wgUser, $wgRequest;
19831984 if ( !$wgUser->isAllowed( 'review' ) ) {
@@ -2001,7 +2002,7 @@
20022003 }
20032004 return true;
20042005 }
2005 -
 2006+
20062007 public static function addBacklogNotice( &$notice ) {
20072008 global $wgUser, $wgTitle;
20082009 $namespaces = FlaggedRevs::getReviewNamespaces();
@@ -2054,7 +2055,7 @@
20552056 }
20562057 return true;
20572058 }
2058 -
 2059+
20592060 public static function stableDumpQuery( &$tables, &$opts, &$join ) {
20602061 $namespaces = FlaggedRevs::getReviewNamespaces();
20612062 $tables = array( 'flaggedpages', 'page', 'revision' );
@@ -2066,7 +2067,7 @@
20672068 $join['revision'] = array( 'INNER JOIN', 'rev_page = fp_page_id AND rev_id = fp_stable' );
20682069 return false; // final
20692070 }
2070 -
 2071+
20712072 // Add selector of review "protection" options
20722073 // Code stolen from Stabilization (which was stolen from ProtectionForm)
20732074 public static function onProtectionForm( $article, &$output ) {
@@ -2261,7 +2262,7 @@
22622263 $tables[] = 'flaggedrevs_tracking';
22632264 return true;
22642265 }
2265 -
 2266+
22662267 public static function addSchemaUpdates() {
22672268 global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables;
22682269 $base = dirname( __FILE__ );

Status & tagging log