private $out;
public $flags;
- function __construct( $skin, $out, $flags = 0 ) {
+ public function __construct( $skin, $out, $flags = 0 ) {
$this->skin = $skin;
$this->out = $out;
$this->flags = $flags;
private function preCacheMessages() {
// Precache various messages
if( !isset( $this->message ) ) {
- $messages = 'revertmerge protect_change unblocklink change-blocklink revertmove undeletelink revdel-restore rev-delundel hist';
- foreach( explode( ' ', $messages ) as $msg ) {
- $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
+ $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
+ 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'pipe-separator' );
+ foreach( $messages as $msg ) {
+ $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
}
}
}
* @param $pattern String
* @param $year Integer: year
* @param $month Integer: month
- * @param $filter Boolean
+ * @param $filter: array
+ * @param $tagFilter: array?
*/
public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
- $month = '', $filter = null )
+ $month = '', $filter = null, $tagFilter='' )
{
global $wgScript, $wgMiserMode;
$action = htmlspecialchars( $wgScript );
$title = SpecialPage::getTitleFor( 'Log' );
$special = htmlspecialchars( $title->getPrefixedDBkey() );
+ $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
+
$this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
Xml::hidden( 'title', $special ) . "\n" .
$this->getUserInput( $user ) . "\n" .
$this->getTitleInput( $page ) . "\n" .
( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
- "<p>" . $this->getDateMenu( $year, $month ) . "\n" .
- ( $filter ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) .
+ "<p>" . Xml::dateMenu( $year, $month ) . "\n" .
+ ( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
+ ( $filter ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" .
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
"</fieldset></form>"
);
}
private function getFilterLinks( $logType, $filter ) {
- global $wgTitle;
+ global $wgTitle, $wgLang;
// show/hide links
$messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
// Option value -> message mapping
$links = array();
+ $hiddens = ''; // keep track for "go" button
foreach( $filter as $type => $val ) {
$hideVal = 1 - intval($val);
$link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
);
$links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
+ $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
}
// Build links
- return implode( ' | ', $links );
+ return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
}
private function getDefaultQuery() {
return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
}
- /**
- * @param $year Integer
- * @param $month Integer
- * @return string Formatted HTML
- */
- private function getDateMenu( $year, $month ) {
- # Offset overrides year/month selection
- if( $month && $month !== -1 ) {
- $encMonth = intval( $month );
- } else {
- $encMonth = '';
- }
- if ( $year ) {
- $encYear = intval( $year );
- } else if( $encMonth ) {
- $thisMonth = intval( gmdate( 'n' ) );
- $thisYear = intval( gmdate( 'Y' ) );
- if( intval($encMonth) > $thisMonth ) {
- $thisYear--;
- }
- $encYear = $thisYear;
- } else {
- $encYear = '';
- }
- return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
- Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
- ' '.
- Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
- Xml::monthSelector( $encMonth, -1 );
- }
-
/**
* @return boolean Checkbox
*/
global $wgLang, $wgUser, $wgContLang;
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
+ $classes = array( "mw-logline-{$row->log_type}" );
$time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->log_timestamp), true );
// User links
if( self::isDeleted($row,LogPage::DELETED_USER) ) {
$this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
$this->message['unblocklink'],
array(),
- array( 'action' => 'unblock', 'ip' => urlencode( $row->log_title ) ),
+ array( 'action' => 'unblock', 'ip' => $row->log_title ),
'known' )
- . ' ' . wfMsg( 'pipe-separator' ) . ' ' .
- $this->skin->link( SpecialPage::getTitleFor( 'Blockip', htmlspecialchars( $row->log_title ) ),
+ . $this->message['pipe-separator'] .
+ $this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
$this->message['change-blocklink'],
array(), array(), 'known' ) .
')';
// Show change protection link
- } else if( self::typeAction($row,'protect',array('modify','protect','unprotect')) ) {
- $revert .= ' (' . $this->skin->makeKnownLinkObj( $title, $this->message['hist'],
- 'action=history&offset=' . urlencode($row->log_timestamp) ) . ')';
- if( $wgUser->isAllowed('protect') && $row->log_action != 'unprotect' ) {
- $revert .= ' (' . $this->skin->makeKnownLinkObj( $title, $this->message['protect_change'],
- 'action=unprotect' ) . ')';
+ } else if( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
+ $revert .= ' (' .
+ $this->skin->link( $title,
+ $this->message['hist'],
+ array(),
+ array( 'action' => 'history', 'offset' => $row->log_timestamp ) );
+ if( $wgUser->isAllowed( 'protect' ) ) {
+ $revert .= $this->message['pipe-separator'] .
+ $this->skin->link( $title,
+ $this->message['protect_change'],
+ array(),
+ array( 'action' => 'protect' ),
+ 'known' );
}
+ $revert .= ')';
// Show unmerge link
} else if( self::typeAction($row,'merge','merge','mergehistory') ) {
$merge = SpecialPage::getTitleFor( 'Mergehistory' );
$revert = $this->skin->userToolLinks( 1, $title->getDBkey() );
}
if( $time < '20080129000000' ) {
- # Suppress $comment from old entries (before 2008-01-29), not needed and can contain incorrect links
+ # Suppress $comment from old entries (before 2008-01-29),
+ # not needed and can contain incorrect links
$comment = '';
}
// Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
if( self::isDeleted($row,LogPage::DELETED_ACTION) ) {
$action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
} else {
- $action = LogPage::actionText( $row->log_type, $row->log_action, $title, $this->skin, $paramArray, true );
+ $action = LogPage::actionText( $row->log_type, $row->log_action, $title,
+ $this->skin, $paramArray, true );
+ }
+
+ // Any tags...
+ list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
+ $classes = array_merge( $classes, $newClasses );
+
+ if( $revert != '' ) {
+ $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
}
- return "<li>$del$time $userLink $action $comment $revert</li>\n";
+ return Xml::tags( 'li', array( "class" => implode( ' ', $classes ) ),
+ $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
}
/**
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// If event was hidden from sysops
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
- $del = $this->message['rev-delundel'];
+ $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
} else if( $row->log_type == 'suppress' ) {
// No one should be hiding from the oversight log
- $del = $this->message['rev-delundel'];
+ $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
} else {
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
- $del = $this->skin->makeKnownLinkObj( $revdel, $this->message['rev-delundel'],
- 'target=' . $target->getPrefixedUrl() . '&logid='.$row->log_id );
- // Bolden oversighted content
- if( self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) )
- $del = "<strong>$del</strong>";
+ $query = array( 'target' => $target->getPrefixedDBkey(),
+ 'logid' => $row->log_id
+ );
+ $del = $this->skin->revDeleteLink( $query, self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
}
- return "<tt>(<small>$del</small>)</tt>";
+ return $del;
}
/**
* @param $year Integer
* @param $month Integer
*/
- function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
- $conds = array(), $year = false, $month = false )
+ public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
+ $conds = array(), $year = false, $month = false, $tagFilter = '' )
{
parent::__construct();
$this->mConds = $conds;
$this->mLogEventsList = $list;
- $this->limitType( $type );
+ $this->limitType( $type ); // also excludes hidden types
$this->limitUser( $user );
$this->limitTitle( $title, $pattern );
$this->getDateCond( $year, $month );
+ $this->mTagFilter = $tagFilter;
}
public function getDefaultQuery() {
$query = parent::getDefaultQuery();
$query['type'] = $this->type;
+ $query['user'] = $this->user;
$query['month'] = $this->mMonth;
$query['year'] = $this->mYear;
return $query;
$this->mConds[] = "NULL";
} else {
$this->mConds['log_user'] = $userid;
+ // Paranoia: avoid brute force searches (bug 17342)
+ $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
$this->user = $usertitle->getText();
}
}
$this->mConds['log_namespace'] = $ns;
$this->mConds['log_title'] = $title->getDBkey();
}
+ // Paranoia: avoid brute force searches (bug 17342)
+ $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
}
public function getQueryInfo() {
} else {
$index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
}
- return array(
+ $info = array(
'tables' => array( 'logging', 'user' ),
'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
'conds' => $this->mConds,
- 'options' => $index
+ 'options' => $index,
+ 'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ) ),
);
+
+ ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $this->mTagFilter );
+
+ return $info;
}
function getIndexField() {
public function getMonth() {
return $this->mMonth;
}
+
+ public function getTagFilter() {
+ return $this->mTagFilter;
+ }
}
/**
*/
function __construct( $request ) {
global $wgUser, $wgOut;
+ wfDeprecated(__METHOD__);
# Get parameters
$type = $request->getVal( 'type' );
$user = $request->getText( 'user' );
$pattern = $request->getBool( 'pattern' );
$year = $request->getIntOrNull( 'year' );
$month = $request->getIntOrNull( 'month' );
+ $tagFilter = $request->getVal( 'tagfilter' );
# Don't let the user get stuck with a certain date
$skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
if( $skip ) {
}
# Use new list class to output results
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
- $this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month );
+ $this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
}
/**
*/
function __construct( &$reader, $flags = 0 ) {
global $wgUser;
+ wfDeprecated(__METHOD__);
$this->reader =& $reader;
$this->reader->pager->mLogEventsList->flags = $flags;
# Aliases for shorter code...