(bug 16046) Add show/hide for types that flood logs
This commit is contained in:
parent
b5bdbe5155
commit
fc69f9f54c
5 changed files with 64 additions and 8 deletions
|
|
@ -2704,6 +2704,14 @@ $wgLogRestrictions = array(
|
|||
'suppress' => 'suppressionlog'
|
||||
);
|
||||
|
||||
/**
|
||||
* Show/hide links on Special:Log will be shown for these log types
|
||||
* This is associative array of log => (hidden by default)
|
||||
*/
|
||||
$wgFilterLogTypes = array(
|
||||
'patrol' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Lists the message key string for each log type. The localized messages
|
||||
* will be listed in the user interface.
|
||||
|
|
|
|||
|
|
@ -62,10 +62,11 @@ class LogEventsList {
|
|||
* @param string $user,
|
||||
* @param string $page,
|
||||
* @param string $pattern
|
||||
* @param int $year
|
||||
* @parm int $month
|
||||
* @param int $y year
|
||||
* @param int $y month
|
||||
* @param bool $filter
|
||||
*/
|
||||
public function showOptions( $type='', $user='', $page='', $pattern='', $year='', $month='' ) {
|
||||
public function showOptions( $type='', $user='', $page='', $pattern='', $y='', $m='', $filter=null ) {
|
||||
global $wgScript, $wgMiserMode;
|
||||
$action = htmlspecialchars( $wgScript );
|
||||
$title = SpecialPage::getTitleFor( 'Log' );
|
||||
|
|
@ -78,9 +79,42 @@ class LogEventsList {
|
|||
$this->getUserInput( $user ) . "\n" .
|
||||
$this->getTitleInput( $page ) . "\n" .
|
||||
( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
|
||||
"<p>" . $this->getDateMenu( $year, $month ) . "\n" .
|
||||
"<p>" . $this->getDateMenu( $y, $m ) . "\n" .
|
||||
( empty($filter) ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) .
|
||||
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
|
||||
"</fieldset></form>" );
|
||||
"</fieldset></form>"
|
||||
);
|
||||
}
|
||||
|
||||
private function getFilterLinks( $logtype, $filter ) {
|
||||
global $wgTitle;
|
||||
// show/hide links
|
||||
$showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
|
||||
// Option value -> message mapping
|
||||
$links = array();
|
||||
foreach( $filter as $type => $val ) {
|
||||
$onoff = 1 - intval($val);
|
||||
$link = $this->skin->makeKnownLinkObj( $wgTitle, $showhide[$onoff],
|
||||
wfArrayToCGI( array( "hide{$type}log" => $onoff ), $this->getDefaultQuery() )
|
||||
);
|
||||
$links[$type] = wfMsgHtml( "logshowhide-{$type}", $link );
|
||||
}
|
||||
// Build links
|
||||
return implode( ' | ', $links );
|
||||
}
|
||||
|
||||
private function getDefaultQuery() {
|
||||
if ( !isset( $this->mDefaultQuery ) ) {
|
||||
$this->mDefaultQuery = $_GET;
|
||||
unset( $this->mDefaultQuery['title'] );
|
||||
unset( $this->mDefaultQuery['dir'] );
|
||||
unset( $this->mDefaultQuery['offset'] );
|
||||
unset( $this->mDefaultQuery['limit'] );
|
||||
unset( $this->mDefaultQuery['order'] );
|
||||
unset( $this->mDefaultQuery['month'] );
|
||||
unset( $this->mDefaultQuery['year'] );
|
||||
}
|
||||
return $this->mDefaultQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -460,6 +494,19 @@ class LogPager extends ReverseChronologicalPager {
|
|||
return $query;
|
||||
}
|
||||
|
||||
public function getFilterParams() {
|
||||
global $wgFilterLogTypes, $wgUser, $wgRequest;
|
||||
$filters = array();
|
||||
foreach( $wgFilterLogTypes as $type => $default ) {
|
||||
// Avoid silly filtering
|
||||
if( $type !== $this->type && ($type !== 'patrol' || $wgUser->useNPPatrol()) ) {
|
||||
$filters[$type] = $wgRequest->getInt( "hide{$type}log", $default );
|
||||
$this->mConds[] = 'log_type != '.$this->mDb->addQuotes( $this->mDb->strencode($type) );
|
||||
}
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the log reader to return only entries of the given type.
|
||||
* Type restrictions enforced here
|
||||
|
|
|
|||
|
|
@ -51,15 +51,14 @@ function wfSpecialLog( $par = '' ) {
|
|||
$y = '';
|
||||
$m = '';
|
||||
}
|
||||
# Create a LogPager item to get the results and a LogEventsList
|
||||
# item to format them...
|
||||
# Create a LogPager item to get the results and a LogEventsList item to format them...
|
||||
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
|
||||
$pager = new LogPager( $loglist, $type, $user, $title, $pattern, array(), $y, $m );
|
||||
# Set title and add header
|
||||
$loglist->showHeader( $pager->getType() );
|
||||
# Show form options
|
||||
$loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(),
|
||||
$pager->getYear(), $pager->getMonth() );
|
||||
$pager->getYear(), $pager->getMonth(), $pager->getFilterParams() );
|
||||
# Insert list
|
||||
$logBody = $pager->getBody();
|
||||
if( $logBody ) {
|
||||
|
|
|
|||
|
|
@ -2126,6 +2126,7 @@ Each row contains links to the first and second redirect, as well as the target
|
|||
You can narrow down the view by selecting a log type, the user name (case-sensitive), or the affected page (also case-sensitive).',
|
||||
'logempty' => 'No matching items in log.',
|
||||
'log-title-wildcard' => 'Search titles starting with this text',
|
||||
'logshowhide-patrol' => '$1 patrol log',
|
||||
|
||||
# Special:AllPages
|
||||
'allpages' => 'All pages',
|
||||
|
|
|
|||
|
|
@ -2149,6 +2149,7 @@ $wgMessageStructure = array(
|
|||
'patrol-log-line',
|
||||
'patrol-log-auto',
|
||||
'patrol-log-diff',
|
||||
'logshowhide-patrol'
|
||||
),
|
||||
'imagedeletion' => array(
|
||||
'deletedrevision',
|
||||
|
|
|
|||
Loading…
Reference in a new issue