Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | <?php |
3 | | - |
| 3 | +/** |
| 4 | + * Class containing hooked functions for a FlaggedRevs environment |
| 5 | + */ |
4 | 6 | class FlaggedRevsHooks { |
5 | 7 | /* |
6 | 8 | * Register FlaggedRevs special pages as needed. |
— | — | @@ -78,7 +80,7 @@ |
79 | 81 | |
80 | 82 | return true; |
81 | 83 | } |
82 | | - |
| 84 | + |
83 | 85 | public static function injectGlobalJSVars( &$globalVars ) { |
84 | 86 | global $wgUser; |
85 | 87 | $fa = FlaggedArticleView::globalArticleInstance(); |
— | — | @@ -112,7 +114,7 @@ |
113 | 115 | } |
114 | 116 | return true; |
115 | 117 | } |
116 | | - |
| 118 | + |
117 | 119 | /** |
118 | 120 | * Add FlaggedRevs css for relevant special pages. |
119 | 121 | */ |
— | — | @@ -136,7 +138,7 @@ |
137 | 139 | } |
138 | 140 | return true; |
139 | 141 | } |
140 | | - |
| 142 | + |
141 | 143 | /* |
142 | 144 | * Add tag notice, CSS/JS, and set robots policy |
143 | 145 | */ |
— | — | @@ -225,7 +227,7 @@ |
226 | 228 | |
227 | 229 | return true; |
228 | 230 | } |
229 | | - |
| 231 | + |
230 | 232 | /** |
231 | 233 | * Update flaggedrevs tracking tables |
232 | 234 | */ |
— | — | @@ -233,7 +235,7 @@ |
234 | 236 | FlaggedRevs::clearTrackingRows( $id ); |
235 | 237 | return true; |
236 | 238 | } |
237 | | - |
| 239 | + |
238 | 240 | /** |
239 | 241 | * Update stable version selection |
240 | 242 | */ |
— | — | @@ -241,7 +243,7 @@ |
242 | 244 | FlaggedRevs::titleLinksUpdate( $title ); |
243 | 245 | return true; |
244 | 246 | } |
245 | | - |
| 247 | + |
246 | 248 | /** |
247 | 249 | * Update pending revision table |
248 | 250 | * Autoreview pages moved into content NS |
— | — | @@ -388,7 +390,7 @@ |
389 | 391 | } |
390 | 392 | $links[$ns][$dbKey] = 1; |
391 | 393 | } |
392 | | - |
| 394 | + |
393 | 395 | protected static function getExistingLinks( $pageId ) { |
394 | 396 | $dbr = wfGetDB( DB_SLAVE ); |
395 | 397 | $res = $dbr->select( 'flaggedrevs_tracking', |
— | — | @@ -404,13 +406,13 @@ |
405 | 407 | } |
406 | 408 | return $arr; |
407 | 409 | } |
408 | | - |
| 410 | + |
409 | 411 | protected static function makeWhereFrom2d( &$arr ) { |
410 | 412 | $lb = new LinkBatch(); |
411 | 413 | $lb->setArray( $arr ); |
412 | 414 | return $lb->constructSet( 'ftr', wfGetDB( DB_SLAVE ) ); |
413 | 415 | } |
414 | | - |
| 416 | + |
415 | 417 | protected static function getLinkInsertions( $existing, $new, $pageId ) { |
416 | 418 | $arr = array(); |
417 | 419 | foreach ( $new as $ns => $dbkeys ) { |
— | — | @@ -426,7 +428,7 @@ |
427 | 429 | } |
428 | 430 | return $arr; |
429 | 431 | } |
430 | | - |
| 432 | + |
431 | 433 | protected static function getLinkDeletions( $existing, $new ) { |
432 | 434 | $del = array(); |
433 | 435 | foreach ( $existing as $ns => $dbkeys ) { |
— | — | @@ -438,7 +440,7 @@ |
439 | 441 | } |
440 | 442 | return $del; |
441 | 443 | } |
442 | | - |
| 444 | + |
443 | 445 | /* |
444 | 446 | * Update pages where only the stable version links to a page |
445 | 447 | * that was just changed in some way. |
— | — | @@ -448,7 +450,7 @@ |
449 | 451 | $update->doUpdate(); |
450 | 452 | return true; |
451 | 453 | } |
452 | | - |
| 454 | + |
453 | 455 | /** |
454 | 456 | * Add special fields to parser. |
455 | 457 | */ |
— | — | @@ -706,7 +708,7 @@ |
707 | 709 | } |
708 | 710 | return true; |
709 | 711 | } |
710 | | - |
| 712 | + |
711 | 713 | /** |
712 | 714 | * Insert image timestamps/SHA-1 keys into parser output |
713 | 715 | */ |
— | — | @@ -820,7 +822,7 @@ |
821 | 823 | } |
822 | 824 | return true; |
823 | 825 | } |
824 | | - |
| 826 | + |
825 | 827 | /** |
826 | 828 | * Allow users to view reviewed pages |
827 | 829 | */ |
— | — | @@ -857,7 +859,7 @@ |
858 | 860 | } |
859 | 861 | return true; |
860 | 862 | } |
861 | | - |
| 863 | + |
862 | 864 | /** |
863 | 865 | * When an edit is made by a reviewer, if the base revision the |
864 | 866 | * edit was made from is the stable version, or the edit is a reversion |
— | — | @@ -1013,7 +1015,7 @@ |
1014 | 1016 | # Confirm the text because we can't trust this user. |
1015 | 1017 | return ( $rev->getText() == $srev->getRevText() ); |
1016 | 1018 | } |
1017 | | - |
| 1019 | + |
1018 | 1020 | /** |
1019 | 1021 | * When an user makes a null-edit we sometimes want to review it... |
1020 | 1022 | * (a) Null undo or rollback |
— | — | @@ -1128,7 +1130,7 @@ |
1129 | 1131 | } |
1130 | 1132 | return true; |
1131 | 1133 | } |
1132 | | - |
| 1134 | + |
1133 | 1135 | public static function incrementRollbacks( $this, $user, $target, $current ) { |
1134 | 1136 | # Mark when a user reverts another user, but not self-reverts |
1135 | 1137 | if ( $current->getRawUser() && $user->getId() != $current->getRawUser() ) { |
— | — | @@ -1139,7 +1141,7 @@ |
1140 | 1142 | } |
1141 | 1143 | return true; |
1142 | 1144 | } |
1143 | | - |
| 1145 | + |
1144 | 1146 | public static function incrementReverts( $article, $rev, $baseRevId = false, $user = null ) { |
1145 | 1147 | global $wgRequest; |
1146 | 1148 | # Was this an edit by an auto-sighter that undid another edit? |
— | — | @@ -1156,7 +1158,7 @@ |
1157 | 1159 | } |
1158 | 1160 | return true; |
1159 | 1161 | } |
1160 | | - |
| 1162 | + |
1161 | 1163 | protected static function editSpacingCheck( $spacing, $points, $user ) { |
1162 | 1164 | # Convert days to seconds... |
1163 | 1165 | $spacing = $spacing * 24 * 3600; |
— | — | @@ -1183,7 +1185,7 @@ |
1184 | 1186 | } |
1185 | 1187 | return ( $benchmarks >= $needed ); |
1186 | 1188 | } |
1187 | | - |
| 1189 | + |
1188 | 1190 | /** |
1189 | 1191 | * Checks if $user was previously blocked |
1190 | 1192 | */ |
— | — | @@ -1199,7 +1201,7 @@ |
1200 | 1202 | array( 'USE INDEX' => 'page_time' ) |
1201 | 1203 | ); |
1202 | 1204 | } |
1203 | | - |
| 1205 | + |
1204 | 1206 | /** |
1205 | 1207 | * Check for 'autoreview' permission. This lets people who opt-out as |
1206 | 1208 | * Editors still have their own edits automatically reviewed. Bot |
— | — | @@ -1535,7 +1537,7 @@ |
1536 | 1538 | |
1537 | 1539 | return true; |
1538 | 1540 | } |
1539 | | - |
| 1541 | + |
1540 | 1542 | /** |
1541 | 1543 | * Record demotion so that auto-promote will be disabled |
1542 | 1544 | */ |
— | — | @@ -1555,7 +1557,7 @@ |
1556 | 1558 | } |
1557 | 1559 | return true; |
1558 | 1560 | } |
1559 | | - |
| 1561 | + |
1560 | 1562 | /** Add user preferences */ |
1561 | 1563 | public static function onGetPreferences( $user, &$preferences ) { |
1562 | 1564 | // Box or bar UI |
— | — | @@ -1602,7 +1604,7 @@ |
1603 | 1605 | } |
1604 | 1606 | return true; |
1605 | 1607 | } |
1606 | | - |
| 1608 | + |
1607 | 1609 | public static function logLineLinks( |
1608 | 1610 | $type, $action, $title = null, $params, &$comment, &$rv, $ts |
1609 | 1611 | ) { |
— | — | @@ -1651,7 +1653,7 @@ |
1652 | 1654 | $view->setPageContent( $outputDone, $pcache ); |
1653 | 1655 | return true; |
1654 | 1656 | } |
1655 | | - |
| 1657 | + |
1656 | 1658 | public static function overrideRedirect( |
1657 | 1659 | &$title, $request, &$ignoreRedirect, &$target, &$article |
1658 | 1660 | ) { |
— | — | @@ -1690,31 +1692,31 @@ |
1691 | 1693 | } |
1692 | 1694 | return true; |
1693 | 1695 | } |
1694 | | - |
| 1696 | + |
1695 | 1697 | public static function addToEditView( &$editPage ) { |
1696 | 1698 | $view = FlaggedArticleView::singleton(); |
1697 | 1699 | $view->addToEditView( $editPage ); |
1698 | 1700 | return true; |
1699 | 1701 | } |
1700 | | - |
| 1702 | + |
1701 | 1703 | public static function onNoSuchSection( &$editPage, &$s ) { |
1702 | 1704 | $view = FlaggedArticleView::singleton(); |
1703 | 1705 | $view->addToNoSuchSection( $editPage, $s ); |
1704 | 1706 | return true; |
1705 | 1707 | } |
1706 | | - |
| 1708 | + |
1707 | 1709 | public static function addToHistView( &$article ) { |
1708 | 1710 | $view = FlaggedArticleView::singleton(); |
1709 | 1711 | $view->addToHistView(); |
1710 | 1712 | return true; |
1711 | 1713 | } |
1712 | | - |
| 1714 | + |
1713 | 1715 | public static function onCategoryPageView( &$category ) { |
1714 | 1716 | $view = FlaggedArticleView::singleton(); |
1715 | 1717 | $view->addToCategoryView(); |
1716 | 1718 | return true; |
1717 | 1719 | } |
1718 | | - |
| 1720 | + |
1719 | 1721 | public static function onSkinAfterContent( &$data ) { |
1720 | 1722 | global $wgOut; |
1721 | 1723 | if ( $wgOut->isArticleRelated() |
— | — | @@ -1727,7 +1729,7 @@ |
1728 | 1730 | } |
1729 | 1731 | return true; |
1730 | 1732 | } |
1731 | | - |
| 1733 | + |
1732 | 1734 | public static function addToHistQuery( $pager, &$queryInfo ) { |
1733 | 1735 | $flaggedArticle = FlaggedArticle::getArticleInstance( $pager->getArticle() ); |
1734 | 1736 | # Non-content pages cannot be validated. Stable version must exist. |
— | — | @@ -1748,7 +1750,7 @@ |
1749 | 1751 | } |
1750 | 1752 | return true; |
1751 | 1753 | } |
1752 | | - |
| 1754 | + |
1753 | 1755 | public static function addToFileHistQuery( |
1754 | 1756 | $file, &$tables, &$fields, &$conds, &$opts, &$join_conds |
1755 | 1757 | ) { |
— | — | @@ -1767,7 +1769,7 @@ |
1768 | 1770 | } |
1769 | 1771 | return true; |
1770 | 1772 | } |
1771 | | - |
| 1773 | + |
1772 | 1774 | public static function addToContribsQuery( $pager, &$queryInfo ) { |
1773 | 1775 | # Highlight flaggedrevs |
1774 | 1776 | $queryInfo['tables'][] = 'flaggedrevs'; |
— | — | @@ -1780,13 +1782,13 @@ |
1781 | 1783 | $queryInfo['join_conds']['flaggedpages'] = array( 'LEFT JOIN', "fp_page_id = rev_page" ); |
1782 | 1784 | return true; |
1783 | 1785 | } |
1784 | | - |
| 1786 | + |
1785 | 1787 | public static function addToRCQuery( &$conds, &$tables, &$join_conds, $opts ) { |
1786 | 1788 | $tables[] = 'flaggedpages'; |
1787 | 1789 | $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' ); |
1788 | 1790 | return true; |
1789 | 1791 | } |
1790 | | - |
| 1792 | + |
1791 | 1793 | public static function addToWatchlistQuery( &$conds, &$tables, &$join_conds, &$fields ) { |
1792 | 1794 | global $wgUser; |
1793 | 1795 | if ( $wgUser->isAllowed( 'review' ) ) { |
— | — | @@ -1796,7 +1798,7 @@ |
1797 | 1799 | } |
1798 | 1800 | return true; |
1799 | 1801 | } |
1800 | | - |
| 1802 | + |
1801 | 1803 | public static function addToHistLine( $history, $row, &$s, &$liClasses ) { |
1802 | 1804 | $fa = FlaggedArticle::getArticleInstance( $history->getArticle() ); |
1803 | 1805 | if ( !$fa->isReviewable() ) { |
— | — | @@ -1838,8 +1840,7 @@ |
1839 | 1841 | if ( $link ) $s .= " <small>$link</small>"; |
1840 | 1842 | return true; |
1841 | 1843 | } |
1842 | | - |
1843 | | - |
| 1844 | + |
1844 | 1845 | /** |
1845 | 1846 | * Make stable version link and return the css |
1846 | 1847 | * @param Title $title |
— | — | @@ -1873,7 +1874,7 @@ |
1874 | 1875 | $link = "<span class='$css plainlinks'>[$link]</span>"; |
1875 | 1876 | return array( $link, $liCss ); |
1876 | 1877 | } |
1877 | | - |
| 1878 | + |
1878 | 1879 | public static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) { |
1879 | 1880 | if ( !$file->isVisible() ) { |
1880 | 1881 | return true; // Don't bother showing notice for deleted revs |
— | — | @@ -1896,7 +1897,7 @@ |
1897 | 1898 | } |
1898 | 1899 | return true; |
1899 | 1900 | } |
1900 | | - |
| 1901 | + |
1901 | 1902 | public static function addToContribsLine( $contribs, &$ret, $row ) { |
1902 | 1903 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
1903 | 1904 | if ( !in_array( $row->page_namespace, $namespaces ) ) { |
— | — | @@ -1911,7 +1912,7 @@ |
1912 | 1913 | } |
1913 | 1914 | return true; |
1914 | 1915 | } |
1915 | | - |
| 1916 | + |
1916 | 1917 | public static function addToChangeListLine( |
1917 | 1918 | &$list, &$articlelink, &$s, &$rc, $unpatrolled, $watched |
1918 | 1919 | ) { |
— | — | @@ -1944,13 +1945,13 @@ |
1945 | 1946 | } |
1946 | 1947 | return true; |
1947 | 1948 | } |
1948 | | - |
| 1949 | + |
1949 | 1950 | public static function injectPostEditURLParams( $article, &$sectionAnchor, &$extraQuery ) { |
1950 | 1951 | $view = FlaggedArticleView::singleton(); |
1951 | 1952 | $view->injectPostEditURLParams( $sectionAnchor, $extraQuery ); |
1952 | 1953 | return true; |
1953 | 1954 | } |
1954 | | - |
| 1955 | + |
1955 | 1956 | // diff=review param (bug 16923) |
1956 | 1957 | public static function checkDiffUrl( $titleObj, &$mOldid, &$mNewid, $old, $new ) { |
1957 | 1958 | if ( $new === 'review' && isset( $titleObj ) ) { |
— | — | @@ -1976,7 +1977,7 @@ |
1977 | 1978 | $view->addRevisionIDField( $editPage, $out ); |
1978 | 1979 | return true; |
1979 | 1980 | } |
1980 | | - |
| 1981 | + |
1981 | 1982 | public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) { |
1982 | 1983 | global $wgUser, $wgRequest; |
1983 | 1984 | if ( !$wgUser->isAllowed( 'review' ) ) { |
— | — | @@ -2001,7 +2002,7 @@ |
2002 | 2003 | } |
2003 | 2004 | return true; |
2004 | 2005 | } |
2005 | | - |
| 2006 | + |
2006 | 2007 | public static function addBacklogNotice( &$notice ) { |
2007 | 2008 | global $wgUser, $wgTitle; |
2008 | 2009 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
— | — | @@ -2054,7 +2055,7 @@ |
2055 | 2056 | } |
2056 | 2057 | return true; |
2057 | 2058 | } |
2058 | | - |
| 2059 | + |
2059 | 2060 | public static function stableDumpQuery( &$tables, &$opts, &$join ) { |
2060 | 2061 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
2061 | 2062 | $tables = array( 'flaggedpages', 'page', 'revision' ); |
— | — | @@ -2066,7 +2067,7 @@ |
2067 | 2068 | $join['revision'] = array( 'INNER JOIN', 'rev_page = fp_page_id AND rev_id = fp_stable' ); |
2068 | 2069 | return false; // final |
2069 | 2070 | } |
2070 | | - |
| 2071 | + |
2071 | 2072 | // Add selector of review "protection" options |
2072 | 2073 | // Code stolen from Stabilization (which was stolen from ProtectionForm) |
2073 | 2074 | public static function onProtectionForm( $article, &$output ) { |
— | — | @@ -2261,7 +2262,7 @@ |
2262 | 2263 | $tables[] = 'flaggedrevs_tracking'; |
2263 | 2264 | return true; |
2264 | 2265 | } |
2265 | | - |
| 2266 | + |
2266 | 2267 | public static function addSchemaUpdates() { |
2267 | 2268 | global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables; |
2268 | 2269 | $base = dirname( __FILE__ ); |