// Precache various messages
if( !isset( $this->message ) ) {
$messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
- 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
+ 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
'pipe-separator' );
foreach( $messages as $msg ) {
$this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
/**
* Set page title and show header for this log type
- * @param $type String
+ * @param $type Array
*/
public function showHeader( $type ) {
- if( LogPage::isLogType( $type ) ) {
- $this->out->setPageTitle( LogPage::logName( $type ) );
- $this->out->addHTML( LogPage::logHeader( $type ) );
+ // If only one log type is used, then show a special message...
+ $headerType = (count($type) == 1) ? $type[0] : '';
+ if( LogPage::isLogType( $headerType ) ) {
+ $this->out->setPageTitle( LogPage::logName( $headerType ) );
+ $this->out->addHTML( LogPage::logHeader( $headerType ) );
+ } else {
+ $this->out->addHTML( wfMsgExt('alllogstext',array('parseinline')) );
}
}
$month = '', $filter = null, $tagFilter='' )
{
global $wgScript, $wgMiserMode;
- $action = htmlspecialchars( $wgScript );
+
+ $action = $wgScript;
$title = SpecialPage::getTitleFor( 'Log' );
- $special = htmlspecialchars( $title->getPrefixedDBkey() );
+ $special = $title->getPrefixedDBkey();
+
// For B/C, we take strings, but make sure they are converted...
$types = ($types === '') ? array() : (array)$types;
$tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
+
+ $html = '';
+ $html .= Xml::hidden( 'title', $special );
+
+ // Basic selectors
+ $html .= $this->getTypeMenu( $types ) . "\n";
+ $html .= $this->getUserInput( $user ) . "\n";
+ $html .= $this->getTitleInput( $page ) . "\n";
+ $html .= $this->getExtraInputs( $types ) . "\n";
- $this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
- Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
- Xml::hidden( 'title', $special ) . "\n" .
- $this->getTypeMenu( $types ) . "\n" .
- $this->getUserInput( $user ) . "\n" .
- $this->getTitleInput( $page ) . "\n" .
- ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
- "<p>" . Xml::dateMenu( $year, $month ) . "\n" .
- ( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
- ( $filter ? "</p><p>".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" .
- Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
- "</fieldset></form>"
- );
+ // Title pattern, if allowed
+ if (!$wgMiserMode) {
+ $html .= $this->getTitlePattern( $pattern ) . "\n";
+ }
+
+ // date menu
+ $html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) );
+
+ // Tag filter
+ if ($tagSelector) {
+ $html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) );
+ }
+
+ // Filter links
+ if ($filter) {
+ $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
+ }
+
+ // Submit button
+ $html .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
+
+ // Fieldset
+ $html = Xml::fieldset( wfMsg( 'log' ), $html );
+
+ // Form wrapping
+ $html = Xml::tags( 'form', array( 'action' => $action, 'method' => 'get' ), $html );
+
+ $this->out->addHTML( $html );
}
/**
$links = array();
$hiddens = ''; // keep track for "go" button
foreach( $filter as $type => $val ) {
+ // Should the below assignment be outside the foreach?
+ // Then it would have to be copied. Not certain what is more expensive.
+ $query = $this->getDefaultQuery();
+ $queryKey = "hide_{$type}_log";
+
$hideVal = 1 - intval($val);
- $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
- wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
+ $query[$queryKey] = $hideVal;
+
+ $link = $this->skin->link(
+ $wgTitle,
+ $messages[$hideVal],
+ array(),
+ $query,
+ array( 'known', 'noclasses' )
);
+
$links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
$hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
}
Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
'</span>';
}
+
+ private function getExtraInputs( $types ) {
+ global $wgRequest;
+ if( count($types) == 1 && $types[0] == 'suppress' ) {
+ return Xml::inputLabel( wfMsg('revdelete-offender'), 'offender',
+ 'mw-log-offender', 20, $wgRequest->getVal('offender') );
+ }
+ return '';
+ }
public function beginLogEventsList() {
return "<ul>\n";
} else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
$destTitle = Title::newFromText( $paramArray[0] );
if( $destTitle ) {
- $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
+ $revert = '(' . $this->skin->link(
+ SpecialPage::getTitleFor( 'Movepage' ),
$this->message['revertmove'],
- 'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
- '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
- '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
- '&wpMovetalk=0' ) . ')';
+ array(),
+ array(
+ 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
+ 'wpNewTitle' => $title->getPrefixedDBkey(),
+ 'wpReason' => wfMsgForContent( 'revertmove' ),
+ 'wpMovetalk' => 0
+ ),
+ array( 'known', 'noclasses' )
+ ) . ')';
}
// Show undelete link
- } else if( self::typeAction($row,array('delete','suppress'),'delete','delete') ) {
- $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
- $this->message['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
+ } else if( self::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) {
+ if( !$wgUser->isAllowed( 'undelete' ) ) {
+ $viewdeleted = $this->message['undeleteviewlink'];
+ } else {
+ $viewdeleted = $this->message['undeletelink'];
+ }
+
+ $revert = '(' . $this->skin->link(
+ SpecialPage::getTitleFor( 'Undelete' ),
+ $viewdeleted,
+ array(),
+ array( 'target' => $title->getPrefixedDBkey() ),
+ array( 'known', 'noclasses' )
+ ) . ')';
// Show unblock/change block link
} else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
$revert = '(' .
- $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
+ $this->skin->link(
+ SpecialPage::getTitleFor( 'Ipblocklist' ),
$this->message['unblocklink'],
array(),
- array( 'action' => 'unblock', 'ip' => $row->log_title ),
- 'known' )
- . $this->message['pipe-separator'] .
- $this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
+ array(
+ 'action' => 'unblock',
+ 'ip' => $row->log_title
+ ),
+ 'known'
+ ) .
+ $this->message['pipe-separator'] .
+ $this->skin->link(
+ SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
$this->message['change-blocklink'],
- array(), array(), 'known' ) .
+ array(),
+ array(),
+ 'known'
+ ) .
')';
// Show change protection link
} else if( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
$this->skin->link( $title,
$this->message['hist'],
array(),
- array( 'action' => 'history', 'offset' => $row->log_timestamp ) );
+ array(
+ 'action' => 'history',
+ 'offset' => $row->log_timestamp
+ )
+ );
if( $wgUser->isAllowed( 'protect' ) ) {
$revert .= $this->message['pipe-separator'] .
$this->skin->link( $title,
// Show unmerge link
} else if( self::typeAction($row,'merge','merge','mergehistory') ) {
$merge = SpecialPage::getTitleFor( 'Mergehistory' );
- $revert = '(' . $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'],
- wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
- 'mergepoint' => $paramArray[1] ) ) ) . ')';
+ $revert = '(' . $this->skin->link(
+ $merge,
+ $this->message['revertmerge'],
+ array(),
+ array(
+ 'target' => $paramArray[0],
+ 'dest' => $title->getPrefixedDBkey(),
+ 'mergepoint' => $paramArray[1]
+ ),
+ array( 'known', 'noclasses' )
+ ) . ')';
// If an edit was hidden from a page give a review link to the history
} else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
if( count($paramArray) >= 2 ) {
- $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// Different revision types use different URL params...
$key = $paramArray[0];
- // $paramArray[1] is a CVS of the IDs
+ // $paramArray[1] is a CSV of the IDs
$Ids = explode( ',', $paramArray[1] );
- $query = urlencode($paramArray[1]);
+ $query = $paramArray[1];
$revert = array();
// Diff link for single rev deletions
- if( $key === 'oldid' && count($Ids) == 1 ) {
- $token = urlencode( $wgUser->editToken( intval($Ids[0]) ) );
- $revert[] = $this->skin->makeKnownLinkObj( $title, $this->message['diff'],
- 'diff='.intval($Ids[0])."&unhide=1&token=$token" );
+ if( count($Ids) == 1 ) {
+ // Live revision diffs...
+ if( in_array($key, array('oldid','revision')) ) {
+ $revert[] = $this->skin->link(
+ $title,
+ $this->message['diff'],
+ array(),
+ array(
+ 'diff' => intval( $Ids[0] ),
+ 'unhide' => 1
+ ),
+ array( 'known', 'noclasses' )
+ );
+ // Deleted revision diffs...
+ } else if( in_array($key, array('artimestamp','archive')) ) {
+ $revert[] = $this->skin->link(
+ SpecialPage::getTitleFor( 'Undelete' ),
+ $this->message['diff'],
+ array(),
+ array(
+ 'target' => $title->getPrefixedDBKey(),
+ 'diff' => 'prev',
+ 'timestamp' => $Ids[0]
+ ),
+ array( 'known', 'noclasses' )
+ );
+ }
}
// View/modify link...
- $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
- 'target='.$title->getPrefixedUrl()."&$key=$query" );
+ $revert[] = $this->skin->link(
+ SpecialPage::getTitleFor( 'Revisiondelete' ),
+ $this->message['revdel-restore'],
+ array(),
+ array(
+ 'target' => $title->getPrefixedText(),
+ 'type' => $key,
+ 'ids' => $query
+ ),
+ array( 'known', 'noclasses' )
+ );
// Pipe links
- $revert = '(' . implode(' | ',$revert) . ')';
+ $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
}
// Hidden log items, give review link
} else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
if( count($paramArray) >= 1 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
- // $paramArray[1] is a CVS of the IDs
+ // $paramArray[1] is a CSV of the IDs
$Ids = explode( ',', $paramArray[0] );
- $query = urlencode($paramArray[0]);
+ $query = $paramArray[0];
// Link to each hidden object ID, $paramArray[1] is the url param
- $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
- 'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')';
+ $revert = '(' . $this->skin->link(
+ $revdel,
+ $this->message['revdel-restore'],
+ array(),
+ array(
+ 'target' => $title->getPrefixedText(),
+ 'type' => 'logging',
+ 'ids' => $query
+ ),
+ array( 'known', 'noclasses' )
+ ) . ')';
}
// Self-created users
} else if( self::typeAction($row,'newusers','create2') ) {
$revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
}
+ $time = htmlspecialchars( $time );
+
return Xml::tags( 'li', array( "class" => implode( ' ', $classes ) ),
$del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
}
* @return string
*/
private function getShowHideLinks( $row ) {
- $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// If event was hidden from sysops
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
$del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
} else {
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
$page = Title::makeTitle( $row->log_namespace, $row->log_title );
- $query = array( 'target' => $target->getPrefixedDBkey(),
- 'logid' => $row->log_id, 'page' => $page->getPrefixedDBkey() );
+ $query = array(
+ 'target' => $target->getPrefixedDBkey(),
+ 'type' => 'logging',
+ 'ids' => $row->log_id,
+ );
$del = $this->skin->revDeleteLink( $query,
self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
}
}
/**
- * Quick function to show a short log extract
- * @param $out OutputPage
+ * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
+ * @param $out OutputPage or String-by-reference
* @param $types String or Array
- * @param $page String
- * @param $user String
- * @param $lim Integer
- * @param $conds Array
+ * @param $page String The page title to show log entries for
+ * @param $user String The user who made the log entries
+ * @param $param Associative Array with the following additional options:
+ * lim Integer Limit of items to show, default is 50
+ * conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
+ * showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty
+ * if set to true (default), "No matching items in log" is displayed if loglist is empty
+ * msgKey Array If you want a nice box with a message, set this
+ * to the key of the message. First element is the message
+ * key, additional optional elements are parameters for the
+ * key that are processed with wgMsgExt and option 'parse'
+ * @return Integer Number of total log items (not limited by $lim)
*/
- public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) {
- global $wgUser;
- # Insert list of top 50 or so items
- $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
+ public static function showLogExtract( &$out, $types=array(), $page='', $user='',
+ $param = array() ) {
+
+ $defaultParameters = array(
+ 'lim' => 0,
+ 'conds' => array(),
+ 'showIfEmpty' => true,
+ 'msgKey' => array('')
+ );
+
+ # The + operator appends elements of remaining keys from the right
+ # handed array to the left handed, whereas duplicated keys are NOT overwritten.
+ $param += $defaultParameters;
+
+ global $wgUser, $wgOut;
+ # Convert $param array to individual variables
+ $lim = $param['lim'];
+ $conds = $param['conds'];
+ $showIfEmpty = $param['showIfEmpty'];
+ $msgKey = $param['msgKey'];
+ if ( !is_array($msgKey) )
+ $msgKey = array( $msgKey );
+ # Insert list of top 50 (or top $lim) items
+ $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
if( $lim > 0 ) $pager->mLimit = $lim;
$logBody = $pager->getBody();
+ $s = '';
if( $logBody ) {
- $out->addHTML(
- $loglist->beginLogEventsList() .
- $logBody .
- $loglist->endLogEventsList()
+ if ( $msgKey[0] ) {
+ $s = '<div class="mw-warning-with-logexcerpt">';
+
+ if ( count( $msgKey ) == 1 ) {
+ $s .= wfMsgExt( $msgKey[0], array('parse') );
+ } else { // Process additional arguments
+ $args = $msgKey;
+ array_shift( $args );
+ $s .= wfMsgExt( $msgKey[0], array('parse'), $args );
+ }
+ }
+ $s .= $loglist->beginLogEventsList() .
+ $logBody .
+ $loglist->endLogEventsList();
+ } else {
+ if ( $showIfEmpty )
+ $s = wfMsgExt( 'logempty', array('parse') );
+ }
+ if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
+ $urlParam = array();
+ if ( $page != '')
+ $urlParam['page'] = $page;
+ if ( $user != '')
+ $urlParam['user'] = $user;
+ if ( !is_array( $types ) ) # Make it an array, if it isn't
+ $types = array( $types );
+ # If there is exactly one log type, we can link to Special:Log?type=foo
+ if ( count( $types ) == 1 )
+ $urlParam['type'] = $types[0];
+ $s .= $wgUser->getSkin()->link(
+ SpecialPage::getTitleFor( 'Log' ),
+ wfMsgHtml( 'log-fulllog' ),
+ array(),
+ $urlParam
);
+
+ }
+ if ( $logBody && $msgKey[0] )
+ $s .= '</div>';
+
+ if( $out instanceof OutputPage ){
+ $out->addHTML( $s );
} else {
- $out->addWikiMsg( 'logempty' );
+ $out = $s;
}
return $pager->getNumRows();
}
/**
* constructor
* @param $list LogEventsList
- * @param $types String or Array
- * @param $user String
- * @param $title String
- * @param $pattern String
- * @param $conds Array
- * @param $year Integer
- * @param $month Integer
+ * @param $types String or Array log types to show
+ * @param $user String The user who made the log entries
+ * @param $title String The page title the log entries are for
+ * @param $pattern String Do a prefix search rather than an exact title match
+ * @param $conds Array Extra conditions for the query
+ * @param $year Integer The year to start from
+ * @param $month Integer The month to start from
*/
public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
$conds = array(), $year = false, $month = false, $tagFilter = '' )
global $wgUser;
$this->mConds['log_user'] = $userid;
// Paranoia: avoid brute force searches (bug 17342)
- if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
- $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
+ if( !$wgUser->isAllowed( 'deleterevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
+ } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) .
+ ' != ' . LogPage::SUPPRESSED_USER;
}
$this->user = $usertitle->getText();
}
$this->mConds['log_title'] = $title->getDBkey();
}
// Paranoia: avoid brute force searches (bug 17342)
- if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
- $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
+ if( !$wgUser->isAllowed( 'deleterevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
+ } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
+ ' != ' . LogPage::SUPPRESSED_ACTION;
}
}
$tables = array( 'logging', 'user' );
$this->mConds[] = 'user_id = log_user';
$groupBy = false;
- $index = array();
# Add log_search table if there are conditions on it
if( array_key_exists('ls_field',$this->mConds) ) {
$tables[] = 'log_search';
- $index = array( 'log_search' => 'PRIMARY', 'logging' => 'PRIMARY' );
+ $index = array( 'log_search' => 'ls_field_val', 'logging' => 'PRIMARY' );
$groupBy = 'ls_log_id';
# Don't use the wrong logging index
} else if( $this->title || $this->pattern || $this->user ) {
}
public function doQuery() {
- // Work around MySQL optimizer bug
- if ( in_array( get_class( $this->mDb ), array( 'Database', 'DatabaseMysql' ) ) ) {
- $this->mDb->query( 'SET SQL_BIG_SELECTS=1' );
- parent::doQuery();
- $this->mDb->query( 'SET SQL_BIG_SELECTS=0' );
- } else {
- parent::doQuery();
- }
+ // Workaround MySQL optimizer bug
+ $this->mDb->setBigSelects();
+ parent::doQuery();
+ $this->mDb->setBigSelects( 'default' );
}
}