http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88633
Revision: 88633
Author: aaron
Date: 2011-05-23 04:28:58 +0000 (Mon, 23 May 2011)
Log Message:
-----------
* In core:
** Added hooks for custom RC/newpages filters
** Added tables,fields,and join_conds to SpecialNewPagesConditions hook
** Removed superflous $nameSpace logic in watchlist code
** Removed some copy-paste code for RC/watchlist filters
** Updates hooks.txt
* In FlaggedRevs:
* Added "hide reviewed edits" filter to RC/newpages
* Combined two handlers into modifyChangesListQuery. Removed is_array() check -
always true now.
* Fixed onBeforePageDisplay() so that CSS worked on sp:Watchlist
* @TODO: remove $wgUseRCPatrol stuff...this gets us closer.
Modified Paths:
--------------
trunk/extensions/FlaggedRevs/FlaggedRevs.php
trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php
trunk/phase3/docs/hooks.txt
trunk/phase3/includes/specials/SpecialNewpages.php
trunk/phase3/includes/specials/SpecialRecentchanges.php
trunk/phase3/includes/specials/SpecialWatchlist.php
Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.php
===================================================================
--- trunk/extensions/FlaggedRevs/FlaggedRevs.php 2011-05-23 03:07:58 UTC
(rev 88632)
+++ trunk/extensions/FlaggedRevs/FlaggedRevs.php 2011-05-23 04:28:58 UTC
(rev 88633)
@@ -421,10 +421,16 @@
$wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine';
$wgHooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery';
$wgHooks['ImagePageFileHistoryLine'][] =
'FlaggedRevsUIHooks::addToFileHistLine';
+# Select extra info & filter items in RC
+$wgHooks['SpecialRecentChangesQuery'][] =
'FlaggedRevsUIHooks::modifyRecentChangesQuery';
+$wgHooks['SpecialNewpagesConditions'][] =
'FlaggedRevsUIHooks::modifyNewPagesQuery';
+$wgHooks['SpecialWatchlistQuery'][] =
'FlaggedRevsUIHooks::modifyChangesListQuery';
# Mark items in RC
-$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::addToRCQuery';
-$wgHooks['SpecialWatchlistQuery'][] =
'FlaggedRevsUIHooks::addToWatchlistQuery';
$wgHooks['ChangesListInsertArticleLink'][] =
'FlaggedRevsUIHooks::addToChangeListLine';
+# RC filter UIs
+$wgHooks['SpecialNewPagesFilters'][] =
'FlaggedRevsUIHooks::addHideReviewedFilter';
+$wgHooks['SpecialRecentChangesFilters'][] =
'FlaggedRevsUIHooks::addHideReviewedFilter';
+$wgHooks['SpecialWatchlistFilters'][] =
'FlaggedRevsUIHooks::addHideReviewedFilter';
# Page review on edit
$wgHooks['ArticleUpdateBeforeRedirect'][] =
'FlaggedRevsUIHooks::injectPostEditURLParams';
# Diff-to-stable
Modified: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
===================================================================
--- trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
2011-05-23 03:07:58 UTC (rev 88632)
+++ trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
2011-05-23 04:28:58 UTC (rev 88633)
@@ -89,9 +89,6 @@
*/
protected static function injectStyleForSpecial( &$out ) {
$title = $out->getTitle();
- if ( $title->getNamespace() !== NS_SPECIAL ) {
- return true;
- }
$spPages = array( 'UnreviewedPages', 'PendingChanges',
'ProblemChanges',
'Watchlist', 'Recentchanges', 'Contributions',
'Recentchangeslinked' );
foreach ( $spPages as $key ) {
@@ -107,7 +104,7 @@
* Add tag notice, CSS/JS, and set robots policy
*/
public static function onBeforePageDisplay( &$out, &$skin ) {
- if ( $out->isArticleRelated() ) {
+ if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) {
$view = FlaggedPageView::singleton();
$view->displayTag(); // show notice bar/icon in subtitle
$view->setRobotPolicy(); // set indexing policy
@@ -332,6 +329,11 @@
return true;
}
+ public static function addHideReviewedFilter( $specialPage, &$filters )
{
+ $filters['hideReviewed'] = array( 'msg' =>
'flaggedrevs-hidereviewed', 'default' => false );
+ return true;
+ }
+
public static function addToHistQuery( HistoryPager $pager, array
&$queryInfo ) {
$flaggedArticle = FlaggedPage::getArticleInstance(
$pager->getArticle() );
# Non-content pages cannot be validated. Stable version must
exist.
@@ -397,27 +399,28 @@
return true;
}
- public static function addToRCQuery(
- &$conds, array &$tables, array &$join_conds, $opts,
&$query_opts, &$select
+ public static function modifyRecentChangesQuery(
+ &$conds, &$tables, &$join_conds, $opts, &$query_opts, &$fields
) {
- $tables[] = 'flaggedpages';
- $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id =
rc_cur_id' );
- if ( is_array( $select ) ) { // RCL
- $select[] = 'fp_stable';
- $select[] = 'fp_pending_since';
- }
- return true;
+ return self::modifyChangesListQuery( $conds, $tables,
$join_conds, $fields );
}
- public static function addToWatchlistQuery(
- &$conds, array &$tables, array &$join_conds, array &$fields
+ public static function modifyNewPagesQuery(
+ $specialPage, $opts, &$conds, &$tables, &$fields, &$join_conds
) {
- global $wgUser;
- if ( $wgUser->isAllowed( 'review' ) ) {
- $fields[] = 'fp_stable';
- $fields[] = 'fp_pending_since';
- $tables[] = 'flaggedpages';
- $join_conds['flaggedpages'] = array( 'LEFT JOIN',
'fp_page_id = rc_cur_id' );
+ return self::modifyChangesListQuery( $conds, $tables,
$join_conds, $fields );
+ }
+
+ public static function modifyChangesListQuery(
+ array &$conds, array &$tables, array &$join_conds, array
&$fields
+ ) {
+ global $wgRequest;
+ $tables[] = 'flaggedpages';
+ $fields[] = 'fp_stable';
+ $fields[] = 'fp_pending_since';
+ $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id =
rc_cur_id' );
+ if ( $wgRequest->getBool( 'hidereviewed' ) ) {
+ $conds[] = 'rc_timestamp >= fp_pending_since OR
fp_stable IS NULL';
}
return true;
}
Modified:
trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php
===================================================================
--- trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php
2011-05-23 03:07:58 UTC (rev 88632)
+++ trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php
2011-05-23 04:28:58 UTC (rev 88633)
@@ -32,6 +32,7 @@
'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist',
'flaggedrevs-prefs-editdiffs' => 'Show the pending changes diff when
editing pages',
'flaggedrevs-prefs-viewdiffs' => 'Show the pending changes diff when
viewing the latest pending revision',
+ 'flaggedrevs-hidereviewed' => '$1 reviewed edits',
'group-editor' => 'Editors',
'group-editor-member' => 'editor',
'group-reviewer' => 'Reviewers',
Modified: trunk/phase3/docs/hooks.txt
===================================================================
--- trunk/phase3/docs/hooks.txt 2011-05-23 03:07:58 UTC (rev 88632)
+++ trunk/phase3/docs/hooks.txt 2011-05-23 04:28:58 UTC (rev 88633)
@@ -1610,7 +1610,15 @@
&$special: NewPagesPager object (subclass of ReverseChronologicalPager)
$opts: FormOptions object containing special page options
&$conds: array of WHERE conditionals for query
+&tables: array of tables to be queried
+&$fields: array of columns to select
+&$join_conds: join conditions for the tables
+'SpecialNewPagesFilters': called after building form options at NewPages
+$special: the special page object
+&$filters: associative array of filter definitions. The keys are the HTML
name/URL parameters.
+Each key maps to an associative array with a 'msg' (message key) and a
'default' value.
+
'SpecialPage_initList': called when setting up SpecialPage::$mList, use this
hook to remove a core special page
$list: list (array) of core special pages
@@ -1624,6 +1632,11 @@
&$title: If the hook returns false, a Title object to use instead of the
result from the normal query
+'SpecialRecentChangesFilters': called after building form options at
RecentChanges
+$special: the special page object
+&$filters: associative array of filter definitions. The keys are the HTML
name/URL parameters.
+Each key maps to an associative array with a 'msg' (message key) and a
'default' value.
+
'SpecialRecentChangesPanel': called when building form options in
SpecialRecentChanges
&$extraOpts: array of added items, to which can be added
@@ -1636,7 +1649,7 @@
&$join_conds: join conditions for the tables
$opts: FormOptions for this request
&$query_options: array of options for the database request
-&$select: String '*' or array of columns to select
+&$select: Array of columns to select
'SpecialSearchGo': called when user clicked the "Go"
&$title: title object generated from the text entered by the user
@@ -1683,6 +1696,11 @@
use this to change the tables headers
$extTypes: associative array of extensions types
+'SpecialWatchlistFilters': called after building form options at Watchlist
+$special: the special page object
+&$filters: associative array of filter definitions. The keys are the HTML
name/URL parameters.
+Each key maps to an associative array with a 'msg' (message key) and a
'default' value.
+
'SpecialWatchlistQuery': called when building sql query for SpecialWatchlist
&$conds: array of WHERE conditionals for query
&$tables: array of tables to be queried
Modified: trunk/phase3/includes/specials/SpecialNewpages.php
===================================================================
--- trunk/phase3/includes/specials/SpecialNewpages.php 2011-05-23 03:07:58 UTC
(rev 88632)
+++ trunk/phase3/includes/specials/SpecialNewpages.php 2011-05-23 04:28:58 UTC
(rev 88633)
@@ -34,6 +34,7 @@
* @var FormOptions
*/
protected $opts;
+ protected $customFilters;
// Some internal settings
protected $showNavigation = false;
@@ -59,6 +60,12 @@
$opts->add( 'feed', '' );
$opts->add( 'tagfilter', '' );
+ $this->customFilters = array();
+ wfRunHooks( 'SpecialNewPagesFilters', array( $this,
&$this->customFilters ) );
+ foreach( $this->customFilters as $key => $params ) {
+ $opts->add( $key, $params['default'] );
+ }
+
// Set values
$opts->fetchValuesFromRequest( $this->getRequest() );
if ( $par ) $this->parseParams( $par );
@@ -167,13 +174,15 @@
'hidebots' => 'rcshowhidebots',
'hideredirs' => 'whatlinkshere-hideredirs'
);
+ foreach ( $this->customFilters as $key => $params ) {
+ $filters[$key] = $params['msg'];
+ }
// Disable some if needed
# @todo FIXME: Throws E_NOTICEs if not set; and doesn't obey
hooks etc.
if ( $wgGroupPermissions['*']['createpage'] !== true ) {
unset( $filters['hideliu'] );
}
-
if ( !$this->getUser()->useNPPatrol() ) {
unset( $filters['hidepatrolled'] );
}
@@ -507,21 +516,23 @@
}
// Allow changes to the New Pages query
- wfRunHooks( 'SpecialNewpagesConditions', array( &$this,
$this->opts, &$conds ) );
+ $tables = array( 'recentchanges', 'page' );
+ $fields = array(
+ 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user',
'rc_user_text',
+ 'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id',
'rc_deleted',
+ 'page_len AS length', 'page_latest AS rev_id', 'ts_tags'
+ );
+ $join_conds = array( 'page' => array( 'INNER JOIN',
'page_id=rc_cur_id' ) );
+ wfRunHooks( 'SpecialNewpagesConditions',
+ array( &$this, $this->opts, &$conds, &$tables,
&$fields, &$join_conds ) );
+
$info = array(
- 'tables' => array( 'recentchanges', 'page' ),
- 'fields' => array(
- 'rc_namespace', 'rc_title', 'rc_cur_id',
'rc_user',
- 'rc_user_text', 'rc_comment', 'rc_timestamp',
'rc_patrolled',
- 'rc_id', 'rc_deleted', 'page_len AS length',
'page_latest AS rev_id',
- 'ts_tags'
- ),
- 'conds' => $conds,
- 'options' => array( 'USE INDEX' => array(
'recentchanges' => $rcIndexes ) ),
- 'join_conds' => array(
- 'page' => array( 'INNER JOIN',
'page_id=rc_cur_id' ),
- ),
+ 'tables' => $tables,
+ 'fields' => $fields,
+ 'conds' => $conds,
+ 'options' => array( 'USE INDEX' => array(
'recentchanges' => $rcIndexes ) ),
+ 'join_conds' => $join_conds
);
// Empty array for fields, it'll be set by us anyway.
Modified: trunk/phase3/includes/specials/SpecialRecentchanges.php
===================================================================
--- trunk/phase3/includes/specials/SpecialRecentchanges.php 2011-05-23
03:07:58 UTC (rev 88632)
+++ trunk/phase3/includes/specials/SpecialRecentchanges.php 2011-05-23
04:28:58 UTC (rev 88633)
@@ -28,6 +28,7 @@
*/
class SpecialRecentChanges extends IncludableSpecialPage {
var $rcOptions, $rcSubpage;
+ protected $customFilters;
public function __construct( $name = 'Recentchanges' ) {
parent::__construct( $name );
@@ -71,6 +72,13 @@
global $wgRequest, $wgRCMaxAge;
$opts = $this->getDefaultOptions();
+
+ $this->customFilters = array();
+ wfRunHooks( 'SpecialRecentChangesFilters', array( $this,
&$this->customFilters ) );
+ foreach( $this->customFilters as $key => $params ) {
+ $opts->add( $key, $params['default'] );
+ }
+
$opts->fetchValuesFromRequest( $wgRequest );
$opts->validateIntBounds( 'days', 1, $wgRCMaxAge / ( 3600 * 24
) );
@@ -789,28 +797,28 @@
// show/hide links
$showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
- $minorLink = $this->makeOptionsLink( $showhide[1 -
$options['hideminor']],
- array( 'hideminor' => 1-$options['hideminor'] ),
$nondefaults );
- $botLink = $this->makeOptionsLink( $showhide[1 -
$options['hidebots']],
- array( 'hidebots' => 1-$options['hidebots'] ),
$nondefaults );
- $anonsLink = $this->makeOptionsLink( $showhide[ 1 -
$options['hideanons'] ],
- array( 'hideanons' => 1 - $options['hideanons'] ),
$nondefaults );
- $liuLink = $this->makeOptionsLink( $showhide[1 -
$options['hideliu']],
- array( 'hideliu' => 1-$options['hideliu'] ),
$nondefaults );
- $patrLink = $this->makeOptionsLink( $showhide[1 -
$options['hidepatrolled']],
- array( 'hidepatrolled' => 1-$options['hidepatrolled']
), $nondefaults );
- $myselfLink = $this->makeOptionsLink( $showhide[1 -
$options['hidemyself']],
- array( 'hidemyself' => 1-$options['hidemyself'] ),
$nondefaults );
+ $filters = array(
+ 'hideminor' => 'rcshowhideminor',
+ 'hidebots' => 'rcshowhidebots',
+ 'hideanons' => 'rcshowhideanons',
+ 'hideliu' => 'rcshowhideliu',
+ 'hidepatrolled' => 'rcshowhidepatr',
+ 'hidemyself' => 'rcshowhidemine'
+ );
+ foreach ( $this->customFilters as $key => $params ) {
+ $filters[$key] = $params['msg'];
+ }
+ // Disable some if needed
+ if ( !$this->getUser()->useRCPatrol() ) {
+ unset( $filters['hidepatrolled'] );
+ }
- $links[] = wfMsgHtml( 'rcshowhideminor', $minorLink );
- $links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
- $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
- $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
- if( $this->getUser()->useRCPatrol() ) {
- $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
+ $links = array();
+ foreach ( $filters as $key => $msg ) {
+ $link = $this->makeOptionsLink( $showhide[1 -
$options[$key]],
+ array( $key => 1-$options[$key] ), $nondefaults
);
+ $links[] = wfMsgHtml( $msg, $link );
}
- $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
- $hl = $wgLang->pipeList( $links );
// show from this onward link
$now = $wgLang->timeanddate( wfTimestampNow(), true );
@@ -819,7 +827,7 @@
);
$rclinks = wfMsgExt( 'rclinks', array( 'parseinline',
'replaceafter' ),
- $cl, $dl, $hl );
+ $cl, $dl, $wgLang->pipeList( $links ) );
$rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline',
'replaceafter' ), $tl );
return "{$note}$rclinks<br />$rclistfrom";
}
Modified: trunk/phase3/includes/specials/SpecialWatchlist.php
===================================================================
--- trunk/phase3/includes/specials/SpecialWatchlist.php 2011-05-23 03:07:58 UTC
(rev 88632)
+++ trunk/phase3/includes/specials/SpecialWatchlist.php 2011-05-23 04:28:58 UTC
(rev 88633)
@@ -21,6 +21,7 @@
* @ingroup SpecialPage Watchlist
*/
class SpecialWatchlist extends SpecialPage {
+ protected $customFilters;
/**
* Constructor
@@ -109,6 +110,7 @@
return;
}
+ // @TODO: use FormOptions!
$defaults = array(
/* float */ 'days' => floatval( $wgUser->getOption(
'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
/* bool */ 'hideMinor' => (int)$wgUser->getBoolOption(
'watchlisthideminor' ),
@@ -120,6 +122,11 @@
/* ? */ 'namespace' => 'all',
/* ? */ 'invert' => false,
);
+ $this->customFilters = array();
+ wfRunHooks( 'SpecialWatchlistFilters', array( $this,
&$this->customFilters ) );
+ foreach( $this->customFilters as $key => $params ) {
+ $defaults[$key] = $params['msg'];
+ }
# Extract variables from the request, falling back to user
preferences or
# other default values if these don't exist
@@ -132,20 +139,24 @@
$prefs['hidepatrolled' ] = $wgUser->getBoolOption(
'watchlisthidepatrolled' );
# Get query variables
- $days = $wgRequest->getVal( 'days' , $prefs['days'] );
- $hideMinor = $wgRequest->getBool( 'hideMinor',
$prefs['hideminor'] );
- $hideBots = $wgRequest->getBool( 'hideBots' ,
$prefs['hidebots'] );
- $hideAnons = $wgRequest->getBool( 'hideAnons',
$prefs['hideanons'] );
- $hideLiu = $wgRequest->getBool( 'hideLiu' ,
$prefs['hideliu'] );
- $hideOwn = $wgRequest->getBool( 'hideOwn' ,
$prefs['hideown'] );
- $hidePatrolled = $wgRequest->getBool( 'hidePatrolled' ,
$prefs['hidepatrolled'] );
+ $values = array();
+ $values['days'] = $wgRequest->getVal( 'days',
$prefs['days'] );
+ $values['hideMinor'] = (int)$wgRequest->getBool(
'hideMinor', $prefs['hideminor'] );
+ $values['hideBots'] = (int)$wgRequest->getBool( 'hideBots'
, $prefs['hidebots'] );
+ $values['hideAnons'] = (int)$wgRequest->getBool(
'hideAnons', $prefs['hideanons'] );
+ $values['hideLiu'] = (int)$wgRequest->getBool( 'hideLiu'
, $prefs['hideliu'] );
+ $values['hideOwn'] = (int)$wgRequest->getBool( 'hideOwn'
, $prefs['hideown'] );
+ $values['hidePatrolled'] = (int)$wgRequest->getBool(
'hidePatrolled', $prefs['hidepatrolled'] );
+ foreach( $this->customFilters as $key => $params ) {
+ $values[$key] = (int)$wgRequest->getBool( $key );
+ }
# Get namespace value, if supplied, and prepare a WHERE fragment
$nameSpace = $wgRequest->getIntOrNull( 'namespace' );
$invert = $wgRequest->getIntOrNull( 'invert' );
- if( !is_null( $nameSpace ) ) {
- $nameSpace = intval( $nameSpace );
- if( $invert && $nameSpace !== 'all' ) {
+ if ( !is_null( $nameSpace ) ) {
+ $nameSpace = intval( $nameSpace ); // paranioa
+ if ( $invert ) {
$nameSpaceClause = "rc_namespace != $nameSpace";
} else {
$nameSpaceClause = "rc_namespace = $nameSpace";
@@ -154,6 +165,8 @@
$nameSpace = '';
$nameSpaceClause = '';
}
+ $values['namespace'] = $nameSpace;
+ $values['invert'] = $invert;
$dbr = wfGetDB( DB_SLAVE, 'watchlist' );
$recentchanges = $dbr->tableName( 'recentchanges' );
@@ -164,30 +177,24 @@
// but treated together
$nitems = floor( $watchlistCount / 2 );
- if( is_null( $days ) || !is_numeric( $days ) ) {
+ if( is_null( $values['days'] ) || !is_numeric( $values['days']
) ) {
$big = 1000; /* The magical big */
if( $nitems > $big ) {
# Set default cutoff shorter
- $days = $defaults['days'] = (12.0 / 24.0); # 12
hours...
+ $values['days'] = $defaults['days'] = (12.0 /
24.0); # 12 hours...
} else {
- $days = $defaults['days']; # default cutoff for
shortlisters
+ $values['days'] = $defaults['days']; # default
cutoff for shortlisters
}
} else {
- $days = floatval( $days );
+ $values['days'] = floatval( $values['days'] );
}
// Dump everything here
$nondefaults = array();
+ foreach ( $defaults as $name => $defValue ) {
+ wfAppendToArrayIfNotDefault( $name, $values[$name],
$defaults, $nondefaults );
+ }
- wfAppendToArrayIfNotDefault( 'days' , $days ,
$defaults, $nondefaults);
- wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor,
$defaults, $nondefaults );
- wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots ,
$defaults, $nondefaults);
- wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons,
$defaults, $nondefaults );
- wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu ,
$defaults, $nondefaults );
- wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn ,
$defaults, $nondefaults);
- wfAppendToArrayIfNotDefault( 'namespace', $nameSpace ,
$defaults, $nondefaults);
- wfAppendToArrayIfNotDefault( 'hidePatrolled',
(int)$hidePatrolled, $defaults, $nondefaults );
-
if( $nitems == 0 ) {
$wgOut->addWikiMsg( 'nowatchlist' );
return;
@@ -196,8 +203,8 @@
# Possible where conditions
$conds = array();
- if( $days > 0 ) {
- $conds[] = "rc_timestamp > '".$dbr->timestamp( time() -
intval( $days * 86400 ) )."'";
+ if( $values['days'] > 0 ) {
+ $conds[] = "rc_timestamp > '".$dbr->timestamp( time() -
intval( $values['days'] * 86400 ) )."'";
}
# If the watchlist is relatively short, it's simplest to zip
@@ -209,25 +216,25 @@
# Up estimate of watched items by 15% to compensate for talk
pages...
# Toggles
- if( $hideOwn ) {
+ if( $values['hideOwn'] ) {
$conds[] = "rc_user != $uid";
}
- if( $hideBots ) {
+ if( $values['hideBots'] ) {
$conds[] = 'rc_bot = 0';
}
- if( $hideMinor ) {
+ if( $values['hideMinor'] ) {
$conds[] = 'rc_minor = 0';
}
- if( $hideLiu ) {
+ if( $values['hideLiu'] ) {
$conds[] = 'rc_user = 0';
}
- if( $hideAnons ) {
+ if( $values['hideAnons'] ) {
$conds[] = 'rc_user != 0';
}
- if ( $wgUser->useRCPatrol() && $hidePatrolled ) {
+ if ( $wgUser->useRCPatrol() && $values['hidePatrolled'] ) {
$conds[] = 'rc_patrolled != 1';
}
- if( $nameSpaceClause ) {
+ if ( $nameSpaceClause ) {
$conds[] = $nameSpaceClause;
}
@@ -299,34 +306,45 @@
/* Start bottom header */
$wlInfo = '';
- if( $days >= 1 ) {
+ if( $values['days'] >= 1 ) {
$wlInfo = wfMsgExt( 'rcnote', 'parseinline',
$wgLang->formatNum( $numRows ),
- $wgLang->formatNum( $days ),
+ $wgLang->formatNum( $values['days'] ),
$wgLang->timeAndDate( wfTimestampNow(),
true ),
$wgLang->date( wfTimestampNow(), true ),
$wgLang->time( wfTimestampNow(), true )
) . '<br />';
- } elseif( $days > 0 ) {
+ } elseif( $values['days'] > 0 ) {
$wlInfo = wfMsgExt( 'wlnote', 'parseinline',
$wgLang->formatNum( $numRows ),
- $wgLang->formatNum( round( $days * 24 )
)
+ $wgLang->formatNum( round(
$values['days'] * 24 ) )
) . '<br />';
}
- $cutofflinks = "\n" . self::cutoffLinks( $days, 'Watchlist',
$nondefaults ) . "<br />\n";
+ $cutofflinks = "\n" . self::cutoffLinks( $values['days'],
'Watchlist', $nondefaults ) . "<br />\n";
$thisTitle = SpecialPage::getTitleFor( 'Watchlist' );
# Spit out some control panel links
- $links[] = self::showHideLink( $nondefaults, 'rcshowhideminor',
'hideMinor', $hideMinor );
- $links[] = self::showHideLink( $nondefaults, 'rcshowhidebots',
'hideBots', $hideBots );
- $links[] = self::showHideLink( $nondefaults, 'rcshowhideanons',
'hideAnons', $hideAnons );
- $links[] = self::showHideLink( $nondefaults, 'rcshowhideliu',
'hideLiu', $hideLiu );
- $links[] = self::showHideLink( $nondefaults, 'rcshowhidemine',
'hideOwn', $hideOwn );
+ $filters = array(
+ 'hideMinor' => 'rcshowhideminor',
+ 'hideBots' => 'rcshowhidebots',
+ 'hideAnons' => 'rcshowhideanons',
+ 'hideLiu' => 'rcshowhideliu',
+ 'hideOwn' => 'rcshowhidemine',
+ 'hidePatrolled' => 'rcshowhidepatr'
+ );
+ foreach ( $this->customFilters as $key => $params ) {
+ $filters[$key] = $params['msg'];
+ }
+ // Disable some if needed
+ if ( !$wgUser->useNPPatrol() ) {
+ unset( $filters['hidePatrolled'] );
+ }
- if( $wgUser->useRCPatrol() ) {
- $links[] = self::showHideLink( $nondefaults,
'rcshowhidepatr', 'hidePatrolled', $hidePatrolled );
+ $links = array();
+ foreach( $filters as $name => $msg ) {
+ $links[] = self::showHideLink( $nondefaults, $msg,
$name, $values[$name] );
}
# Namespace filter and put the whole form together.
@@ -339,22 +357,12 @@
$form .= Xml::namespaceSelector( $nameSpace, '' ) . ' ';
$form .= Xml::checkLabel( wfMsg('invert'), 'invert',
'nsinvert', $invert ) . ' ';
$form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
'</p>';
- $form .= Html::hidden( 'days', $days );
- if( $hideMinor ) {
- $form .= Html::hidden( 'hideMinor', 1 );
+ $form .= Html::hidden( 'days', $values['days'] );
+ foreach ( $filters as $key => $msg ) {
+ if ( $values[$key] ) {
+ $form .= Html::hidden( $key, 1 );
+ }
}
- if( $hideBots ) {
- $form .= Html::hidden( 'hideBots', 1 );
- }
- if( $hideAnons ) {
- $form .= Html::hidden( 'hideAnons', 1 );
- }
- if( $hideLiu ) {
- $form .= Html::hidden( 'hideLiu', 1 );
- }
- if( $hideOwn ) {
- $form .= Html::hidden( 'hideOwn', 1 );
- }
$form .= Xml::closeElement( 'form' );
$form .= Xml::closeElement( 'fieldset' );
$wgOut->addHTML( $form );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs