| Index: trunk/phase3/docs/hooks.txt |
| — | — | @@ -1610,7 +1610,15 @@ |
| 1611 | 1611 | &$special: NewPagesPager object (subclass of ReverseChronologicalPager) |
| 1612 | 1612 | $opts: FormOptions object containing special page options |
| 1613 | 1613 | &$conds: array of WHERE conditionals for query |
| | 1614 | +&tables: array of tables to be queried |
| | 1615 | +&$fields: array of columns to select |
| | 1616 | +&$join_conds: join conditions for the tables |
| 1614 | 1617 | |
| | 1618 | +'SpecialNewPagesFilters': called after building form options at NewPages |
| | 1619 | +$special: the special page object |
| | 1620 | +&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters. |
| | 1621 | +Each key maps to an associative array with a 'msg' (message key) and a 'default' value. |
| | 1622 | + |
| 1615 | 1623 | 'SpecialPage_initList': called when setting up SpecialPage::$mList, use this |
| 1616 | 1624 | hook to remove a core special page |
| 1617 | 1625 | $list: list (array) of core special pages |
| — | — | @@ -1624,6 +1632,11 @@ |
| 1625 | 1633 | &$title: If the hook returns false, a Title object to use instead of the |
| 1626 | 1634 | result from the normal query |
| 1627 | 1635 | |
| | 1636 | +'SpecialRecentChangesFilters': called after building form options at RecentChanges |
| | 1637 | +$special: the special page object |
| | 1638 | +&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters. |
| | 1639 | +Each key maps to an associative array with a 'msg' (message key) and a 'default' value. |
| | 1640 | + |
| 1628 | 1641 | 'SpecialRecentChangesPanel': called when building form options in |
| 1629 | 1642 | SpecialRecentChanges |
| 1630 | 1643 | &$extraOpts: array of added items, to which can be added |
| — | — | @@ -1636,7 +1649,7 @@ |
| 1637 | 1650 | &$join_conds: join conditions for the tables |
| 1638 | 1651 | $opts: FormOptions for this request |
| 1639 | 1652 | &$query_options: array of options for the database request |
| 1640 | | -&$select: String '*' or array of columns to select |
| | 1653 | +&$select: Array of columns to select |
| 1641 | 1654 | |
| 1642 | 1655 | 'SpecialSearchGo': called when user clicked the "Go" |
| 1643 | 1656 | &$title: title object generated from the text entered by the user |
| — | — | @@ -1683,6 +1696,11 @@ |
| 1684 | 1697 | use this to change the tables headers |
| 1685 | 1698 | $extTypes: associative array of extensions types |
| 1686 | 1699 | |
| | 1700 | +'SpecialWatchlistFilters': called after building form options at Watchlist |
| | 1701 | +$special: the special page object |
| | 1702 | +&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters. |
| | 1703 | +Each key maps to an associative array with a 'msg' (message key) and a 'default' value. |
| | 1704 | + |
| 1687 | 1705 | 'SpecialWatchlistQuery': called when building sql query for SpecialWatchlist |
| 1688 | 1706 | &$conds: array of WHERE conditionals for query |
| 1689 | 1707 | &$tables: array of tables to be queried |
| Index: trunk/phase3/includes/specials/SpecialNewpages.php |
| — | — | @@ -34,6 +34,7 @@ |
| 35 | 35 | * @var FormOptions |
| 36 | 36 | */ |
| 37 | 37 | protected $opts; |
| | 38 | + protected $customFilters; |
| 38 | 39 | |
| 39 | 40 | // Some internal settings |
| 40 | 41 | protected $showNavigation = false; |
| — | — | @@ -59,6 +60,12 @@ |
| 60 | 61 | $opts->add( 'feed', '' ); |
| 61 | 62 | $opts->add( 'tagfilter', '' ); |
| 62 | 63 | |
| | 64 | + $this->customFilters = array(); |
| | 65 | + wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) ); |
| | 66 | + foreach( $this->customFilters as $key => $params ) { |
| | 67 | + $opts->add( $key, $params['default'] ); |
| | 68 | + } |
| | 69 | + |
| 63 | 70 | // Set values |
| 64 | 71 | $opts->fetchValuesFromRequest( $this->getRequest() ); |
| 65 | 72 | if ( $par ) $this->parseParams( $par ); |
| — | — | @@ -167,13 +174,15 @@ |
| 168 | 175 | 'hidebots' => 'rcshowhidebots', |
| 169 | 176 | 'hideredirs' => 'whatlinkshere-hideredirs' |
| 170 | 177 | ); |
| | 178 | + foreach ( $this->customFilters as $key => $params ) { |
| | 179 | + $filters[$key] = $params['msg']; |
| | 180 | + } |
| 171 | 181 | |
| 172 | 182 | // Disable some if needed |
| 173 | 183 | # @todo FIXME: Throws E_NOTICEs if not set; and doesn't obey hooks etc. |
| 174 | 184 | if ( $wgGroupPermissions['*']['createpage'] !== true ) { |
| 175 | 185 | unset( $filters['hideliu'] ); |
| 176 | 186 | } |
| 177 | | - |
| 178 | 187 | if ( !$this->getUser()->useNPPatrol() ) { |
| 179 | 188 | unset( $filters['hidepatrolled'] ); |
| 180 | 189 | } |
| — | — | @@ -507,21 +516,23 @@ |
| 508 | 517 | } |
| 509 | 518 | |
| 510 | 519 | // Allow changes to the New Pages query |
| 511 | | - wfRunHooks( 'SpecialNewpagesConditions', array( &$this, $this->opts, &$conds ) ); |
| | 520 | + $tables = array( 'recentchanges', 'page' ); |
| | 521 | + $fields = array( |
| | 522 | + 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', |
| | 523 | + 'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted', |
| | 524 | + 'page_len AS length', 'page_latest AS rev_id', 'ts_tags' |
| | 525 | + ); |
| | 526 | + $join_conds = array( 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ) ); |
| 512 | 527 | |
| | 528 | + wfRunHooks( 'SpecialNewpagesConditions', |
| | 529 | + array( &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ) ); |
| | 530 | + |
| 513 | 531 | $info = array( |
| 514 | | - 'tables' => array( 'recentchanges', 'page' ), |
| 515 | | - 'fields' => array( |
| 516 | | - 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', |
| 517 | | - 'rc_user_text', 'rc_comment', 'rc_timestamp', 'rc_patrolled', |
| 518 | | - 'rc_id', 'rc_deleted', 'page_len AS length', 'page_latest AS rev_id', |
| 519 | | - 'ts_tags' |
| 520 | | - ), |
| 521 | | - 'conds' => $conds, |
| 522 | | - 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ), |
| 523 | | - 'join_conds' => array( |
| 524 | | - 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ), |
| 525 | | - ), |
| | 532 | + 'tables' => $tables, |
| | 533 | + 'fields' => $fields, |
| | 534 | + 'conds' => $conds, |
| | 535 | + 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ), |
| | 536 | + 'join_conds' => $join_conds |
| 526 | 537 | ); |
| 527 | 538 | |
| 528 | 539 | // Empty array for fields, it'll be set by us anyway. |
| Index: trunk/phase3/includes/specials/SpecialRecentchanges.php |
| — | — | @@ -28,6 +28,7 @@ |
| 29 | 29 | */ |
| 30 | 30 | class SpecialRecentChanges extends IncludableSpecialPage { |
| 31 | 31 | var $rcOptions, $rcSubpage; |
| | 32 | + protected $customFilters; |
| 32 | 33 | |
| 33 | 34 | public function __construct( $name = 'Recentchanges' ) { |
| 34 | 35 | parent::__construct( $name ); |
| — | — | @@ -71,6 +72,13 @@ |
| 72 | 73 | global $wgRequest, $wgRCMaxAge; |
| 73 | 74 | |
| 74 | 75 | $opts = $this->getDefaultOptions(); |
| | 76 | + |
| | 77 | + $this->customFilters = array(); |
| | 78 | + wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) ); |
| | 79 | + foreach( $this->customFilters as $key => $params ) { |
| | 80 | + $opts->add( $key, $params['default'] ); |
| | 81 | + } |
| | 82 | + |
| 75 | 83 | $opts->fetchValuesFromRequest( $wgRequest ); |
| 76 | 84 | $opts->validateIntBounds( 'days', 1, $wgRCMaxAge / ( 3600 * 24 ) ); |
| 77 | 85 | |
| — | — | @@ -789,28 +797,28 @@ |
| 790 | 798 | |
| 791 | 799 | // show/hide links |
| 792 | 800 | $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) ); |
| 793 | | - $minorLink = $this->makeOptionsLink( $showhide[1 - $options['hideminor']], |
| 794 | | - array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults ); |
| 795 | | - $botLink = $this->makeOptionsLink( $showhide[1 - $options['hidebots']], |
| 796 | | - array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults ); |
| 797 | | - $anonsLink = $this->makeOptionsLink( $showhide[ 1 - $options['hideanons'] ], |
| 798 | | - array( 'hideanons' => 1 - $options['hideanons'] ), $nondefaults ); |
| 799 | | - $liuLink = $this->makeOptionsLink( $showhide[1 - $options['hideliu']], |
| 800 | | - array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults ); |
| 801 | | - $patrLink = $this->makeOptionsLink( $showhide[1 - $options['hidepatrolled']], |
| 802 | | - array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults ); |
| 803 | | - $myselfLink = $this->makeOptionsLink( $showhide[1 - $options['hidemyself']], |
| 804 | | - array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults ); |
| | 801 | + $filters = array( |
| | 802 | + 'hideminor' => 'rcshowhideminor', |
| | 803 | + 'hidebots' => 'rcshowhidebots', |
| | 804 | + 'hideanons' => 'rcshowhideanons', |
| | 805 | + 'hideliu' => 'rcshowhideliu', |
| | 806 | + 'hidepatrolled' => 'rcshowhidepatr', |
| | 807 | + 'hidemyself' => 'rcshowhidemine' |
| | 808 | + ); |
| | 809 | + foreach ( $this->customFilters as $key => $params ) { |
| | 810 | + $filters[$key] = $params['msg']; |
| | 811 | + } |
| | 812 | + // Disable some if needed |
| | 813 | + if ( !$this->getUser()->useRCPatrol() ) { |
| | 814 | + unset( $filters['hidepatrolled'] ); |
| | 815 | + } |
| 805 | 816 | |
| 806 | | - $links[] = wfMsgHtml( 'rcshowhideminor', $minorLink ); |
| 807 | | - $links[] = wfMsgHtml( 'rcshowhidebots', $botLink ); |
| 808 | | - $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink ); |
| 809 | | - $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink ); |
| 810 | | - if( $this->getUser()->useRCPatrol() ) { |
| 811 | | - $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink ); |
| | 817 | + $links = array(); |
| | 818 | + foreach ( $filters as $key => $msg ) { |
| | 819 | + $link = $this->makeOptionsLink( $showhide[1 - $options[$key]], |
| | 820 | + array( $key => 1-$options[$key] ), $nondefaults ); |
| | 821 | + $links[] = wfMsgHtml( $msg, $link ); |
| 812 | 822 | } |
| 813 | | - $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink ); |
| 814 | | - $hl = $wgLang->pipeList( $links ); |
| 815 | 823 | |
| 816 | 824 | // show from this onward link |
| 817 | 825 | $now = $wgLang->timeanddate( wfTimestampNow(), true ); |
| — | — | @@ -819,7 +827,7 @@ |
| 820 | 828 | ); |
| 821 | 829 | |
| 822 | 830 | $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ), |
| 823 | | - $cl, $dl, $hl ); |
| | 831 | + $cl, $dl, $wgLang->pipeList( $links ) ); |
| 824 | 832 | $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); |
| 825 | 833 | return "{$note}$rclinks<br />$rclistfrom"; |
| 826 | 834 | } |
| Index: trunk/phase3/includes/specials/SpecialWatchlist.php |
| — | — | @@ -21,6 +21,7 @@ |
| 22 | 22 | * @ingroup SpecialPage Watchlist |
| 23 | 23 | */ |
| 24 | 24 | class SpecialWatchlist extends SpecialPage { |
| | 25 | + protected $customFilters; |
| 25 | 26 | |
| 26 | 27 | /** |
| 27 | 28 | * Constructor |
| — | — | @@ -109,6 +110,7 @@ |
| 110 | 111 | return; |
| 111 | 112 | } |
| 112 | 113 | |
| | 114 | + // @TODO: use FormOptions! |
| 113 | 115 | $defaults = array( |
| 114 | 116 | /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */ |
| 115 | 117 | /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ), |
| — | — | @@ -120,6 +122,11 @@ |
| 121 | 123 | /* ? */ 'namespace' => 'all', |
| 122 | 124 | /* ? */ 'invert' => false, |
| 123 | 125 | ); |
| | 126 | + $this->customFilters = array(); |
| | 127 | + wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) ); |
| | 128 | + foreach( $this->customFilters as $key => $params ) { |
| | 129 | + $defaults[$key] = $params['msg']; |
| | 130 | + } |
| 124 | 131 | |
| 125 | 132 | # Extract variables from the request, falling back to user preferences or |
| 126 | 133 | # other default values if these don't exist |
| — | — | @@ -132,20 +139,24 @@ |
| 133 | 140 | $prefs['hidepatrolled' ] = $wgUser->getBoolOption( 'watchlisthidepatrolled' ); |
| 134 | 141 | |
| 135 | 142 | # Get query variables |
| 136 | | - $days = $wgRequest->getVal( 'days' , $prefs['days'] ); |
| 137 | | - $hideMinor = $wgRequest->getBool( 'hideMinor', $prefs['hideminor'] ); |
| 138 | | - $hideBots = $wgRequest->getBool( 'hideBots' , $prefs['hidebots'] ); |
| 139 | | - $hideAnons = $wgRequest->getBool( 'hideAnons', $prefs['hideanons'] ); |
| 140 | | - $hideLiu = $wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] ); |
| 141 | | - $hideOwn = $wgRequest->getBool( 'hideOwn' , $prefs['hideown'] ); |
| 142 | | - $hidePatrolled = $wgRequest->getBool( 'hidePatrolled' , $prefs['hidepatrolled'] ); |
| | 143 | + $values = array(); |
| | 144 | + $values['days'] = $wgRequest->getVal( 'days', $prefs['days'] ); |
| | 145 | + $values['hideMinor'] = (int)$wgRequest->getBool( 'hideMinor', $prefs['hideminor'] ); |
| | 146 | + $values['hideBots'] = (int)$wgRequest->getBool( 'hideBots' , $prefs['hidebots'] ); |
| | 147 | + $values['hideAnons'] = (int)$wgRequest->getBool( 'hideAnons', $prefs['hideanons'] ); |
| | 148 | + $values['hideLiu'] = (int)$wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] ); |
| | 149 | + $values['hideOwn'] = (int)$wgRequest->getBool( 'hideOwn' , $prefs['hideown'] ); |
| | 150 | + $values['hidePatrolled'] = (int)$wgRequest->getBool( 'hidePatrolled', $prefs['hidepatrolled'] ); |
| | 151 | + foreach( $this->customFilters as $key => $params ) { |
| | 152 | + $values[$key] = (int)$wgRequest->getBool( $key ); |
| | 153 | + } |
| 143 | 154 | |
| 144 | 155 | # Get namespace value, if supplied, and prepare a WHERE fragment |
| 145 | 156 | $nameSpace = $wgRequest->getIntOrNull( 'namespace' ); |
| 146 | 157 | $invert = $wgRequest->getIntOrNull( 'invert' ); |
| 147 | | - if( !is_null( $nameSpace ) ) { |
| 148 | | - $nameSpace = intval( $nameSpace ); |
| 149 | | - if( $invert && $nameSpace !== 'all' ) { |
| | 158 | + if ( !is_null( $nameSpace ) ) { |
| | 159 | + $nameSpace = intval( $nameSpace ); // paranioa |
| | 160 | + if ( $invert ) { |
| 150 | 161 | $nameSpaceClause = "rc_namespace != $nameSpace"; |
| 151 | 162 | } else { |
| 152 | 163 | $nameSpaceClause = "rc_namespace = $nameSpace"; |
| — | — | @@ -154,6 +165,8 @@ |
| 155 | 166 | $nameSpace = ''; |
| 156 | 167 | $nameSpaceClause = ''; |
| 157 | 168 | } |
| | 169 | + $values['namespace'] = $nameSpace; |
| | 170 | + $values['invert'] = $invert; |
| 158 | 171 | |
| 159 | 172 | $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); |
| 160 | 173 | $recentchanges = $dbr->tableName( 'recentchanges' ); |
| — | — | @@ -164,30 +177,24 @@ |
| 165 | 178 | // but treated together |
| 166 | 179 | $nitems = floor( $watchlistCount / 2 ); |
| 167 | 180 | |
| 168 | | - if( is_null( $days ) || !is_numeric( $days ) ) { |
| | 181 | + if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) { |
| 169 | 182 | $big = 1000; /* The magical big */ |
| 170 | 183 | if( $nitems > $big ) { |
| 171 | 184 | # Set default cutoff shorter |
| 172 | | - $days = $defaults['days'] = (12.0 / 24.0); # 12 hours... |
| | 185 | + $values['days'] = $defaults['days'] = (12.0 / 24.0); # 12 hours... |
| 173 | 186 | } else { |
| 174 | | - $days = $defaults['days']; # default cutoff for shortlisters |
| | 187 | + $values['days'] = $defaults['days']; # default cutoff for shortlisters |
| 175 | 188 | } |
| 176 | 189 | } else { |
| 177 | | - $days = floatval( $days ); |
| | 190 | + $values['days'] = floatval( $values['days'] ); |
| 178 | 191 | } |
| 179 | 192 | |
| 180 | 193 | // Dump everything here |
| 181 | 194 | $nondefaults = array(); |
| | 195 | + foreach ( $defaults as $name => $defValue ) { |
| | 196 | + wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults ); |
| | 197 | + } |
| 182 | 198 | |
| 183 | | - wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults); |
| 184 | | - wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); |
| 185 | | - wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults); |
| 186 | | - wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons, $defaults, $nondefaults ); |
| 187 | | - wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu , $defaults, $nondefaults ); |
| 188 | | - wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults); |
| 189 | | - wfAppendToArrayIfNotDefault( 'namespace', $nameSpace , $defaults, $nondefaults); |
| 190 | | - wfAppendToArrayIfNotDefault( 'hidePatrolled', (int)$hidePatrolled, $defaults, $nondefaults ); |
| 191 | | - |
| 192 | 199 | if( $nitems == 0 ) { |
| 193 | 200 | $wgOut->addWikiMsg( 'nowatchlist' ); |
| 194 | 201 | return; |
| — | — | @@ -196,8 +203,8 @@ |
| 197 | 204 | # Possible where conditions |
| 198 | 205 | $conds = array(); |
| 199 | 206 | |
| 200 | | - if( $days > 0 ) { |
| 201 | | - $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'"; |
| | 207 | + if( $values['days'] > 0 ) { |
| | 208 | + $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $values['days'] * 86400 ) )."'"; |
| 202 | 209 | } |
| 203 | 210 | |
| 204 | 211 | # If the watchlist is relatively short, it's simplest to zip |
| — | — | @@ -209,25 +216,25 @@ |
| 210 | 217 | # Up estimate of watched items by 15% to compensate for talk pages... |
| 211 | 218 | |
| 212 | 219 | # Toggles |
| 213 | | - if( $hideOwn ) { |
| | 220 | + if( $values['hideOwn'] ) { |
| 214 | 221 | $conds[] = "rc_user != $uid"; |
| 215 | 222 | } |
| 216 | | - if( $hideBots ) { |
| | 223 | + if( $values['hideBots'] ) { |
| 217 | 224 | $conds[] = 'rc_bot = 0'; |
| 218 | 225 | } |
| 219 | | - if( $hideMinor ) { |
| | 226 | + if( $values['hideMinor'] ) { |
| 220 | 227 | $conds[] = 'rc_minor = 0'; |
| 221 | 228 | } |
| 222 | | - if( $hideLiu ) { |
| | 229 | + if( $values['hideLiu'] ) { |
| 223 | 230 | $conds[] = 'rc_user = 0'; |
| 224 | 231 | } |
| 225 | | - if( $hideAnons ) { |
| | 232 | + if( $values['hideAnons'] ) { |
| 226 | 233 | $conds[] = 'rc_user != 0'; |
| 227 | 234 | } |
| 228 | | - if ( $wgUser->useRCPatrol() && $hidePatrolled ) { |
| | 235 | + if ( $wgUser->useRCPatrol() && $values['hidePatrolled'] ) { |
| 229 | 236 | $conds[] = 'rc_patrolled != 1'; |
| 230 | 237 | } |
| 231 | | - if( $nameSpaceClause ) { |
| | 238 | + if ( $nameSpaceClause ) { |
| 232 | 239 | $conds[] = $nameSpaceClause; |
| 233 | 240 | } |
| 234 | 241 | |
| — | — | @@ -299,34 +306,45 @@ |
| 300 | 307 | /* Start bottom header */ |
| 301 | 308 | |
| 302 | 309 | $wlInfo = ''; |
| 303 | | - if( $days >= 1 ) { |
| | 310 | + if( $values['days'] >= 1 ) { |
| 304 | 311 | $wlInfo = wfMsgExt( 'rcnote', 'parseinline', |
| 305 | 312 | $wgLang->formatNum( $numRows ), |
| 306 | | - $wgLang->formatNum( $days ), |
| | 313 | + $wgLang->formatNum( $values['days'] ), |
| 307 | 314 | $wgLang->timeAndDate( wfTimestampNow(), true ), |
| 308 | 315 | $wgLang->date( wfTimestampNow(), true ), |
| 309 | 316 | $wgLang->time( wfTimestampNow(), true ) |
| 310 | 317 | ) . '<br />'; |
| 311 | | - } elseif( $days > 0 ) { |
| | 318 | + } elseif( $values['days'] > 0 ) { |
| 312 | 319 | $wlInfo = wfMsgExt( 'wlnote', 'parseinline', |
| 313 | 320 | $wgLang->formatNum( $numRows ), |
| 314 | | - $wgLang->formatNum( round( $days * 24 ) ) |
| | 321 | + $wgLang->formatNum( round( $values['days'] * 24 ) ) |
| 315 | 322 | ) . '<br />'; |
| 316 | 323 | } |
| 317 | 324 | |
| 318 | | - $cutofflinks = "\n" . self::cutoffLinks( $days, 'Watchlist', $nondefaults ) . "<br />\n"; |
| | 325 | + $cutofflinks = "\n" . self::cutoffLinks( $values['days'], 'Watchlist', $nondefaults ) . "<br />\n"; |
| 319 | 326 | |
| 320 | 327 | $thisTitle = SpecialPage::getTitleFor( 'Watchlist' ); |
| 321 | 328 | |
| 322 | 329 | # Spit out some control panel links |
| 323 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhideminor', 'hideMinor', $hideMinor ); |
| 324 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhidebots', 'hideBots', $hideBots ); |
| 325 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhideanons', 'hideAnons', $hideAnons ); |
| 326 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhideliu', 'hideLiu', $hideLiu ); |
| 327 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn ); |
| | 330 | + $filters = array( |
| | 331 | + 'hideMinor' => 'rcshowhideminor', |
| | 332 | + 'hideBots' => 'rcshowhidebots', |
| | 333 | + 'hideAnons' => 'rcshowhideanons', |
| | 334 | + 'hideLiu' => 'rcshowhideliu', |
| | 335 | + 'hideOwn' => 'rcshowhidemine', |
| | 336 | + 'hidePatrolled' => 'rcshowhidepatr' |
| | 337 | + ); |
| | 338 | + foreach ( $this->customFilters as $key => $params ) { |
| | 339 | + $filters[$key] = $params['msg']; |
| | 340 | + } |
| | 341 | + // Disable some if needed |
| | 342 | + if ( !$wgUser->useNPPatrol() ) { |
| | 343 | + unset( $filters['hidePatrolled'] ); |
| | 344 | + } |
| 328 | 345 | |
| 329 | | - if( $wgUser->useRCPatrol() ) { |
| 330 | | - $links[] = self::showHideLink( $nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled ); |
| | 346 | + $links = array(); |
| | 347 | + foreach( $filters as $name => $msg ) { |
| | 348 | + $links[] = self::showHideLink( $nondefaults, $msg, $name, $values[$name] ); |
| 331 | 349 | } |
| 332 | 350 | |
| 333 | 351 | # Namespace filter and put the whole form together. |
| — | — | @@ -339,22 +357,12 @@ |
| 340 | 358 | $form .= Xml::namespaceSelector( $nameSpace, '' ) . ' '; |
| 341 | 359 | $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . ' '; |
| 342 | 360 | $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . '</p>'; |
| 343 | | - $form .= Html::hidden( 'days', $days ); |
| 344 | | - if( $hideMinor ) { |
| 345 | | - $form .= Html::hidden( 'hideMinor', 1 ); |
| | 361 | + $form .= Html::hidden( 'days', $values['days'] ); |
| | 362 | + foreach ( $filters as $key => $msg ) { |
| | 363 | + if ( $values[$key] ) { |
| | 364 | + $form .= Html::hidden( $key, 1 ); |
| | 365 | + } |
| 346 | 366 | } |
| 347 | | - if( $hideBots ) { |
| 348 | | - $form .= Html::hidden( 'hideBots', 1 ); |
| 349 | | - } |
| 350 | | - if( $hideAnons ) { |
| 351 | | - $form .= Html::hidden( 'hideAnons', 1 ); |
| 352 | | - } |
| 353 | | - if( $hideLiu ) { |
| 354 | | - $form .= Html::hidden( 'hideLiu', 1 ); |
| 355 | | - } |
| 356 | | - if( $hideOwn ) { |
| 357 | | - $form .= Html::hidden( 'hideOwn', 1 ); |
| 358 | | - } |
| 359 | 367 | $form .= Xml::closeElement( 'form' ); |
| 360 | 368 | $form .= Xml::closeElement( 'fieldset' ); |
| 361 | 369 | $wgOut->addHTML( $form ); |
| Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
| — | — | @@ -421,10 +421,16 @@ |
| 422 | 422 | $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine'; |
| 423 | 423 | $wgHooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery'; |
| 424 | 424 | $wgHooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine'; |
| | 425 | +# Select extra info & filter items in RC |
| | 426 | +$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::modifyRecentChangesQuery'; |
| | 427 | +$wgHooks['SpecialNewpagesConditions'][] = 'FlaggedRevsUIHooks::modifyNewPagesQuery'; |
| | 428 | +$wgHooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::modifyChangesListQuery'; |
| 425 | 429 | # Mark items in RC |
| 426 | | -$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::addToRCQuery'; |
| 427 | | -$wgHooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::addToWatchlistQuery'; |
| 428 | 430 | $wgHooks['ChangesListInsertArticleLink'][] = 'FlaggedRevsUIHooks::addToChangeListLine'; |
| | 431 | +# RC filter UIs |
| | 432 | +$wgHooks['SpecialNewPagesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
| | 433 | +$wgHooks['SpecialRecentChangesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
| | 434 | +$wgHooks['SpecialWatchlistFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
| 429 | 435 | # Page review on edit |
| 430 | 436 | $wgHooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams'; |
| 431 | 437 | # Diff-to-stable |
| Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php |
| — | — | @@ -89,9 +89,6 @@ |
| 90 | 90 | */ |
| 91 | 91 | protected static function injectStyleForSpecial( &$out ) { |
| 92 | 92 | $title = $out->getTitle(); |
| 93 | | - if ( $title->getNamespace() !== NS_SPECIAL ) { |
| 94 | | - return true; |
| 95 | | - } |
| 96 | 93 | $spPages = array( 'UnreviewedPages', 'PendingChanges', 'ProblemChanges', |
| 97 | 94 | 'Watchlist', 'Recentchanges', 'Contributions', 'Recentchangeslinked' ); |
| 98 | 95 | foreach ( $spPages as $key ) { |
| — | — | @@ -107,7 +104,7 @@ |
| 108 | 105 | * Add tag notice, CSS/JS, and set robots policy |
| 109 | 106 | */ |
| 110 | 107 | public static function onBeforePageDisplay( &$out, &$skin ) { |
| 111 | | - if ( $out->isArticleRelated() ) { |
| | 108 | + if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) { |
| 112 | 109 | $view = FlaggedPageView::singleton(); |
| 113 | 110 | $view->displayTag(); // show notice bar/icon in subtitle |
| 114 | 111 | $view->setRobotPolicy(); // set indexing policy |
| — | — | @@ -332,6 +329,11 @@ |
| 333 | 330 | return true; |
| 334 | 331 | } |
| 335 | 332 | |
| | 333 | + public static function addHideReviewedFilter( $specialPage, &$filters ) { |
| | 334 | + $filters['hideReviewed'] = array( 'msg' => 'flaggedrevs-hidereviewed', 'default' => false ); |
| | 335 | + return true; |
| | 336 | + } |
| | 337 | + |
| 336 | 338 | public static function addToHistQuery( HistoryPager $pager, array &$queryInfo ) { |
| 337 | 339 | $flaggedArticle = FlaggedPage::getArticleInstance( $pager->getArticle() ); |
| 338 | 340 | # Non-content pages cannot be validated. Stable version must exist. |
| — | — | @@ -397,27 +399,28 @@ |
| 398 | 400 | return true; |
| 399 | 401 | } |
| 400 | 402 | |
| 401 | | - public static function addToRCQuery( |
| 402 | | - &$conds, array &$tables, array &$join_conds, $opts, &$query_opts, &$select |
| | 403 | + public static function modifyRecentChangesQuery( |
| | 404 | + &$conds, &$tables, &$join_conds, $opts, &$query_opts, &$fields |
| 403 | 405 | ) { |
| 404 | | - $tables[] = 'flaggedpages'; |
| 405 | | - $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' ); |
| 406 | | - if ( is_array( $select ) ) { // RCL |
| 407 | | - $select[] = 'fp_stable'; |
| 408 | | - $select[] = 'fp_pending_since'; |
| 409 | | - } |
| 410 | | - return true; |
| | 406 | + return self::modifyChangesListQuery( $conds, $tables, $join_conds, $fields ); |
| 411 | 407 | } |
| 412 | 408 | |
| 413 | | - public static function addToWatchlistQuery( |
| 414 | | - &$conds, array &$tables, array &$join_conds, array &$fields |
| | 409 | + public static function modifyNewPagesQuery( |
| | 410 | + $specialPage, $opts, &$conds, &$tables, &$fields, &$join_conds |
| 415 | 411 | ) { |
| 416 | | - global $wgUser; |
| 417 | | - if ( $wgUser->isAllowed( 'review' ) ) { |
| 418 | | - $fields[] = 'fp_stable'; |
| 419 | | - $fields[] = 'fp_pending_since'; |
| 420 | | - $tables[] = 'flaggedpages'; |
| 421 | | - $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' ); |
| | 412 | + return self::modifyChangesListQuery( $conds, $tables, $join_conds, $fields ); |
| | 413 | + } |
| | 414 | + |
| | 415 | + public static function modifyChangesListQuery( |
| | 416 | + array &$conds, array &$tables, array &$join_conds, array &$fields |
| | 417 | + ) { |
| | 418 | + global $wgRequest; |
| | 419 | + $tables[] = 'flaggedpages'; |
| | 420 | + $fields[] = 'fp_stable'; |
| | 421 | + $fields[] = 'fp_pending_since'; |
| | 422 | + $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' ); |
| | 423 | + if ( $wgRequest->getBool( 'hidereviewed' ) ) { |
| | 424 | + $conds[] = 'rc_timestamp >= fp_pending_since OR fp_stable IS NULL'; |
| 422 | 425 | } |
| 423 | 426 | return true; |
| 424 | 427 | } |
| Index: trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php |
| — | — | @@ -32,6 +32,7 @@ |
| 33 | 33 | 'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist', |
| 34 | 34 | 'flaggedrevs-prefs-editdiffs' => 'Show the pending changes diff when editing pages', |
| 35 | 35 | 'flaggedrevs-prefs-viewdiffs' => 'Show the pending changes diff when viewing the latest pending revision', |
| | 36 | + 'flaggedrevs-hidereviewed' => '$1 reviewed edits', |
| 36 | 37 | 'group-editor' => 'Editors', |
| 37 | 38 | 'group-editor-member' => 'editor', |
| 38 | 39 | 'group-reviewer' => 'Reviewers', |