2008-04-02 05:48:16 +00:00
|
|
|
<?php
|
|
|
|
|
# Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2008 Aaron Schulz
|
|
|
|
|
# http://www.mediawiki.org/
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
class LogEventsList {
|
2008-04-02 05:48:16 +00:00
|
|
|
const NO_ACTION_LINK = 1;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
private $skin;
|
2008-04-12 06:11:09 +00:00
|
|
|
private $out;
|
2008-04-02 16:24:30 +00:00
|
|
|
public $flags;
|
2008-04-02 05:48:16 +00:00
|
|
|
|
Prevent E_STRICT warning on editing a non-existent page / starting a new page:
-------------------------------
Strict Standards: Only variables should be passed by reference in includes/EditPage.php on line 2233
EditPage.showDeletionLog(Object:OutputPage) # line 685, file: includes/EditPage.php
EditPage.showIntro() # line 450, file: includes/EditPage.php
EditPage.edit() # line 348, file: includes/EditPage.php
EditPage.submit() # line 490, file: includes/Wiki.php
MediaWiki.performAction(Object:OutputPage, Object:Article, Object:Title, Object:User, Object:WebRequest) # line 59, file: includes/Wiki.php
MediaWiki.initialize(Object:Title, Object:Article, Object:OutputPage, Object:User, Object:WebRequest) # line 92, file: index.php
-------------------------------
2008-06-02 06:44:05 +00:00
|
|
|
function __construct( $skin, $out, $flags = 0 ) {
|
|
|
|
|
$this->skin = $skin;
|
|
|
|
|
$this->out = $out;
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->flags = $flags;
|
|
|
|
|
$this->preCacheMessages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* As we use the same small set of messages in various methods and that
|
|
|
|
|
* they are called often, we call them once and save them in $this->message
|
|
|
|
|
*/
|
|
|
|
|
private function preCacheMessages() {
|
|
|
|
|
// Precache various messages
|
|
|
|
|
if( !isset( $this->message ) ) {
|
2008-04-02 18:46:32 +00:00
|
|
|
$messages = 'revertmerge protect_change unblocklink revertmove undeletelink revdel-restore rev-delundel';
|
|
|
|
|
foreach( explode(' ', $messages ) as $msg ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set page title and show header for this log type
|
2008-04-15 10:26:53 +00:00
|
|
|
* @param string $type
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-12 06:11:09 +00:00
|
|
|
public function showHeader( $type ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
if( LogPage::isLogType( $type ) ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->out->setPageTitle( LogPage::logName( $type ) );
|
|
|
|
|
$this->out->addHtml( LogPage::logHeader( $type ) );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show options for the log list
|
|
|
|
|
* @param string $type,
|
|
|
|
|
* @param string $user,
|
|
|
|
|
* @param string $page,
|
|
|
|
|
* @param string $pattern
|
2008-04-12 06:11:09 +00:00
|
|
|
* @param int $year
|
|
|
|
|
* @parm int $month
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-12 06:11:09 +00:00
|
|
|
public function showOptions( $type='', $user='', $page='', $pattern='', $year='', $month='' ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgScript, $wgMiserMode;
|
|
|
|
|
$action = htmlspecialchars( $wgScript );
|
|
|
|
|
$title = SpecialPage::getTitleFor( 'Log' );
|
|
|
|
|
$special = htmlspecialchars( $title->getPrefixedDBkey() );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
|
2008-04-02 05:48:16 +00:00
|
|
|
Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
|
|
|
|
|
Xml::hidden( 'title', $special ) . "\n" .
|
|
|
|
|
$this->getTypeMenu( $type ) . "\n" .
|
|
|
|
|
$this->getUserInput( $user ) . "\n" .
|
|
|
|
|
$this->getTitleInput( $page ) . "\n" .
|
|
|
|
|
( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
|
2008-04-12 06:11:09 +00:00
|
|
|
"<p>" . $this->getDateMenu( $year, $month ) . "\n" .
|
|
|
|
|
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
|
2008-04-02 05:48:16 +00:00
|
|
|
"</fieldset></form>" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
2008-04-12 06:11:09 +00:00
|
|
|
* @param string $queryType
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function getTypeMenu( $queryType ) {
|
|
|
|
|
global $wgLogRestrictions, $wgUser;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$html = "<select name='type'>\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
|
|
|
|
|
$validTypes = LogPage::validTypes();
|
|
|
|
|
$m = array(); // Temporary array
|
|
|
|
|
|
|
|
|
|
// First pass to load the log names
|
|
|
|
|
foreach( $validTypes as $type ) {
|
|
|
|
|
$text = LogPage::logName( $type );
|
|
|
|
|
$m[$text] = $type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Second pass to sort by name
|
|
|
|
|
ksort($m);
|
|
|
|
|
|
|
|
|
|
// Third pass generates sorted XHTML content
|
|
|
|
|
foreach( $m as $text => $type ) {
|
|
|
|
|
$selected = ($type == $queryType);
|
|
|
|
|
// Restricted types
|
|
|
|
|
if ( isset($wgLogRestrictions[$type]) ) {
|
|
|
|
|
if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= Xml::option( $text, $type, $selected ) . "\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= Xml::option( $text, $type, $selected ) . "\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= '</select>';
|
|
|
|
|
return $html;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
2008-04-12 06:11:09 +00:00
|
|
|
* @param string $user
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function getUserInput( $user ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
2008-04-12 06:11:09 +00:00
|
|
|
* @param string $title
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function getTitleInput( $title ) {
|
|
|
|
|
return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
|
|
|
|
* @param int $year
|
|
|
|
|
* @param int $month
|
|
|
|
|
*/
|
|
|
|
|
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 );
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return boolean Checkbox
|
|
|
|
|
*/
|
|
|
|
|
private function getTitlePattern( $pattern ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
return '<span style="white-space: nowrap">' .
|
|
|
|
|
Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
|
|
|
|
|
'</span>';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
public function beginLogEventsList() {
|
2008-04-08 18:20:28 +00:00
|
|
|
return "<ul>\n";
|
2008-04-02 07:10:41 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
public function endLogEventsList() {
|
2008-04-08 18:20:28 +00:00
|
|
|
return "</ul>\n";
|
2008-04-02 07:10:41 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* @param Row $row a single row from the result set
|
|
|
|
|
* @return string Formatted HTML list item
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
public function logLine( $row ) {
|
|
|
|
|
global $wgLang, $wgUser, $wgContLang;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
|
|
|
|
|
$time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->log_timestamp), true );
|
|
|
|
|
// User links
|
2008-04-02 17:11:58 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_USER) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
|
|
|
|
|
} else {
|
2008-04-08 21:22:44 +00:00
|
|
|
$userLink = $this->skin->userLink( $row->log_user, $row->user_name ) .
|
2008-04-08 23:30:36 +00:00
|
|
|
$this->skin->userToolLinks( $row->log_user, $row->user_name, true, 0, $row->user_editcount );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
// Comment
|
2008-04-02 18:46:32 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_COMMENT) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
$comment = $wgContLang->getDirMark() . $this->skin->commentBlock( $row->log_comment );
|
|
|
|
|
}
|
|
|
|
|
// Extract extra parameters
|
|
|
|
|
$paramArray = LogPage::extractParams( $row->log_params );
|
|
|
|
|
$revert = $del = '';
|
|
|
|
|
// Some user can hide log items and have review links
|
|
|
|
|
if( $wgUser->isAllowed( 'deleterevision' ) ) {
|
|
|
|
|
$del = $this->showhideLinks( $row ) . ' ';
|
|
|
|
|
}
|
|
|
|
|
// Add review links and such...
|
|
|
|
|
if( !($this->flags & self::NO_ACTION_LINK) && !($row->log_deleted & LogPage::DELETED_ACTION) ) {
|
2008-04-13 15:18:59 +00:00
|
|
|
if( self::typeAction($row,'move','move') && isset( $paramArray[0] ) && $wgUser->isAllowed( 'move' ) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$destTitle = Title::newFromText( $paramArray[0] );
|
|
|
|
|
if( $destTitle ) {
|
|
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
|
2008-04-02 18:46:32 +00:00
|
|
|
$this->message['revertmove'],
|
2008-04-02 05:48:16 +00:00
|
|
|
'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
|
|
|
|
|
'&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
|
|
|
|
|
'&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
|
|
|
|
|
'&wpMovetalk=0' ) . ')';
|
|
|
|
|
}
|
|
|
|
|
// Show undelete link
|
2008-04-16 18:44:15 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'delete') && $wgUser->isAllowed( 'delete' ) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
|
2008-04-02 18:46:32 +00:00
|
|
|
$this->message['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
// Show unblock link
|
2008-04-26 19:54:47 +00:00
|
|
|
} else if( self::typeAction($row,array('block','suppress'),'block') && $wgUser->isAllowed( 'block' ) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ),
|
2008-04-02 18:46:32 +00:00
|
|
|
$this->message['unblocklink'],
|
2008-04-02 05:48:16 +00:00
|
|
|
'action=unblock&ip=' . urlencode( $row->log_title ) ) . ')';
|
|
|
|
|
// Show change protection link
|
2008-04-13 15:18:59 +00:00
|
|
|
} else if( self::typeAction($row,'protect','modify') && $wgUser->isAllowed( 'protect' ) ) {
|
2008-04-02 18:46:32 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( $title, $this->message['protect_change'], 'action=unprotect' ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
// Show unmerge link
|
2008-04-13 15:18:59 +00:00
|
|
|
} else if ( self::typeAction($row,'merge','merge') ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$merge = SpecialPage::getTitleFor( 'Mergehistory' );
|
2008-04-02 18:46:32 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'],
|
2008-04-16 18:49:43 +00:00
|
|
|
wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
|
2008-04-16 18:44:15 +00:00
|
|
|
'mergepoint' => $paramArray[1] ) ) ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
// If an edit was hidden from a page give a review link to the history
|
2008-04-16 18:05:54 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'revision') && $wgUser->isAllowed( 'deleterevision' ) ) {
|
2008-04-16 18:44:15 +00:00
|
|
|
if( count($paramArray) == 2 ) {
|
2008-04-16 18:05:54 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
// Different revision types use different URL params...
|
2008-04-17 21:06:31 +00:00
|
|
|
$key = $paramArray[0];
|
2008-04-20 21:47:12 +00:00
|
|
|
// Link to each hidden object ID, $paramArray[1] is the url param
|
2008-04-17 21:06:31 +00:00
|
|
|
$Ids = explode( ',', $paramArray[1] );
|
2008-04-20 21:47:12 +00:00
|
|
|
$revParams = '';
|
|
|
|
|
foreach( $Ids as $n => $id ) {
|
|
|
|
|
$revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-20 21:47:12 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
|
|
|
|
|
'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
// Hidden log items, give review link
|
2008-04-16 18:05:54 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'event') && $wgUser->isAllowed( 'deleterevision' ) ) {
|
2008-04-16 18:44:15 +00:00
|
|
|
if( count($paramArray) == 1 ) {
|
2008-04-16 18:05:54 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
$Ids = explode( ',', $paramArray[0] );
|
2008-04-20 21:47:12 +00:00
|
|
|
// Link to each hidden object ID, $paramArray[1] is the url param
|
|
|
|
|
$logParams = '';
|
|
|
|
|
foreach( $Ids as $n => $id ) {
|
|
|
|
|
$logParams .= '&logid[]=' . intval($id);
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-20 21:47:12 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
|
|
|
|
|
'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2008-04-14 07:45:50 +00:00
|
|
|
wfRunHooks( 'LogLine', array( $row->log_type, $row->log_action, $title, $paramArray,
|
2008-04-02 05:48:16 +00:00
|
|
|
&$comment, &$revert, $row->log_timestamp ) );
|
|
|
|
|
// wfDebug( "Invoked LogLine hook for " $row->log_type . ", " . $row->log_action . "\n" );
|
|
|
|
|
// Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Event description
|
2008-04-02 19:01:41 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_ACTION) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$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 );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-08 18:20:28 +00:00
|
|
|
return "<li>$del$time $userLink $action $comment $revert</li>\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* @param Row $row
|
2008-04-13 15:18:59 +00:00
|
|
|
* @return string
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function showhideLinks( $row ) {
|
|
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
// If event was hidden from sysops
|
2008-04-02 17:11:58 +00:00
|
|
|
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$del = $this->message['rev-delundel'];
|
|
|
|
|
} else if( $row->log_type == 'suppress' ) {
|
2008-04-02 13:17:50 +00:00
|
|
|
// No one should be hiding from the oversight log
|
|
|
|
|
$del = $this->message['rev-delundel'];
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-16 18:44:15 +00:00
|
|
|
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
|
|
|
|
|
$del = $this->skin->makeKnownLinkObj( $revdel, $this->message['rev-delundel'],
|
2008-04-16 18:49:43 +00:00
|
|
|
'target=' . $target->getPrefixedUrl() . '&logid='.$row->log_id );
|
2008-04-02 05:48:16 +00:00
|
|
|
// Bolden oversighted content
|
2008-04-02 17:11:58 +00:00
|
|
|
if( self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) )
|
2008-04-02 05:48:16 +00:00
|
|
|
$del = "<strong>$del</strong>";
|
|
|
|
|
}
|
|
|
|
|
return "<tt>(<small>$del</small>)</tt>";
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 15:18:59 +00:00
|
|
|
/**
|
|
|
|
|
* @param Row $row
|
2008-04-16 18:05:54 +00:00
|
|
|
* @param mixed $type (string/array)
|
2008-04-13 15:18:59 +00:00
|
|
|
* @param string $action
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function typeAction( $row, $type, $action ) {
|
2008-04-16 18:05:54 +00:00
|
|
|
if( is_array($type) ) {
|
|
|
|
|
return ( in_array($row->log_type,$type) && $row->log_action == $action );
|
|
|
|
|
} else {
|
|
|
|
|
return ( $row->log_type == $type && $row->log_action == $action );
|
|
|
|
|
}
|
2008-04-13 15:18:59 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:11:58 +00:00
|
|
|
/**
|
|
|
|
|
* Determine if the current user is allowed to view a particular
|
|
|
|
|
* field of this log row, if it's marked as deleted.
|
|
|
|
|
* @param Row $row
|
|
|
|
|
* @param int $field
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function userCan( $row, $field ) {
|
|
|
|
|
if( ( $row->log_deleted & $field ) == $field ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$permission = ( $row->log_deleted & LogPage::DELETED_RESTRICTED ) == LogPage::DELETED_RESTRICTED
|
2008-05-25 00:31:28 +00:00
|
|
|
? 'suppressrevision'
|
2008-04-02 17:11:58 +00:00
|
|
|
: 'deleterevision';
|
|
|
|
|
wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
|
|
|
|
|
return $wgUser->isAllowed( $permission );
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Row $row
|
2008-04-02 17:12:45 +00:00
|
|
|
* @param int $field one of DELETED_* bitfield constants
|
2008-04-02 17:11:58 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function isDeleted( $row, $field ) {
|
|
|
|
|
return ($row->log_deleted & $field) == $field;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 19:01:41 +00:00
|
|
|
/**
|
2008-04-02 20:20:47 +00:00
|
|
|
* Quick function to show a short log extract
|
|
|
|
|
* @param OutputPage $out
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @param string $page
|
2008-04-04 04:15:21 +00:00
|
|
|
* @param string $user
|
2008-04-02 20:20:47 +00:00
|
|
|
*/
|
|
|
|
|
public static function showLogExtract( $out, $type='', $page='', $user='' ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
# Insert list of top 50 or so items
|
2008-04-12 06:11:09 +00:00
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
|
2008-04-02 20:20:47 +00:00
|
|
|
$pager = new LogPager( $loglist, $type, $user, $page, '' );
|
|
|
|
|
$logBody = $pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$out->addHTML(
|
|
|
|
|
$loglist->beginLogEventsList() .
|
|
|
|
|
$logBody .
|
|
|
|
|
$loglist->endLogEventsList()
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$out->addWikiMsg( 'logempty' );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 20:20:47 +00:00
|
|
|
/**
|
2008-04-02 19:01:41 +00:00
|
|
|
* SQL clause to skip forbidden log types for this user
|
|
|
|
|
* @param Database $db
|
|
|
|
|
* @returns mixed (string or false)
|
|
|
|
|
*/
|
|
|
|
|
public static function getExcludeClause( $db ) {
|
|
|
|
|
global $wgLogRestrictions, $wgUser;
|
|
|
|
|
// Reset the array, clears extra "where" clauses when $par is used
|
|
|
|
|
$hiddenLogs = array();
|
2008-04-08 13:58:33 +00:00
|
|
|
// Don't show private logs to unprivileged users
|
2008-04-02 19:01:41 +00:00
|
|
|
foreach( $wgLogRestrictions as $logtype => $right ) {
|
|
|
|
|
if( !$wgUser->isAllowed($right) ) {
|
|
|
|
|
$safetype = $db->strencode( $logtype );
|
2008-04-08 13:58:33 +00:00
|
|
|
$hiddenLogs[] = $safetype;
|
2008-04-02 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-08 13:58:33 +00:00
|
|
|
if( count($hiddenLogs) == 1 ) {
|
|
|
|
|
return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
|
|
|
|
|
} elseif( !empty( $hiddenLogs ) ) {
|
|
|
|
|
return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
|
2008-04-02 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Pager
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 16:24:30 +00:00
|
|
|
class LogPager extends ReverseChronologicalPager {
|
2008-08-01 22:39:45 +00:00
|
|
|
private $type = '', $user = '', $title = '', $pattern = '';
|
2008-04-02 17:43:57 +00:00
|
|
|
public $mLogEventsList;
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-04-02 16:24:30 +00:00
|
|
|
* constructor
|
2008-04-02 17:43:57 +00:00
|
|
|
* @param LogEventsList $loglist,
|
2008-04-02 16:24:30 +00:00
|
|
|
* @param string $type,
|
|
|
|
|
* @param string $user,
|
|
|
|
|
* @param string $page,
|
|
|
|
|
* @param string $pattern
|
|
|
|
|
* @param array $conds
|
|
|
|
|
*/
|
2008-04-12 06:11:09 +00:00
|
|
|
function __construct( $list, $type='', $user='', $title='', $pattern='', $conds=array(), $y=false, $m=false ) {
|
2008-04-02 16:24:30 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
$this->mConds = $conds;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->mLogEventsList = $list;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->limitType( $type );
|
|
|
|
|
$this->limitUser( $user );
|
|
|
|
|
$this->limitTitle( $title, $pattern );
|
2008-08-01 22:38:45 +00:00
|
|
|
$this->getDateCond( $y, $m );
|
2008-04-08 20:51:19 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-08 20:51:19 +00:00
|
|
|
function getDefaultQuery() {
|
|
|
|
|
$query = parent::getDefaultQuery();
|
|
|
|
|
$query['type'] = $this->type;
|
2008-08-01 22:38:45 +00:00
|
|
|
$query['month'] = $this->mMonth;
|
|
|
|
|
$query['year'] = $this->mYear;
|
2008-04-08 20:51:19 +00:00
|
|
|
return $query;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries of the given type.
|
|
|
|
|
* Type restrictions enforced here
|
|
|
|
|
* @param string $type A log type ('upload', 'delete', etc)
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2008-04-02 16:24:30 +00:00
|
|
|
private function limitType( $type ) {
|
2008-04-02 18:09:02 +00:00
|
|
|
global $wgLogRestrictions, $wgUser;
|
|
|
|
|
// Don't even show header for private logs; don't recognize it...
|
|
|
|
|
if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
|
|
|
|
|
$type = '';
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
// Don't show private logs to unpriviledged users
|
2008-04-02 17:43:57 +00:00
|
|
|
$hideLogs = LogEventsList::getExcludeClause( $this->mDb );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $hideLogs !== false ) {
|
|
|
|
|
$this->mConds[] = $hideLogs;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
if( empty($type) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->type = $type;
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds['log_type'] = $type;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries by the given user.
|
|
|
|
|
* @param string $name (In)valid user name
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function limitUser( $name ) {
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $name == '' ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
$usertitle = Title::makeTitleSafe( NS_USER, $name );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( is_null($usertitle) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
/* Fetch userid at first, if known, provides awesome query plan afterwards */
|
2008-04-08 23:30:36 +00:00
|
|
|
$userid = User::idFromName( $name );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( !$userid ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
/* It should be nicer to abort query at all,
|
2008-04-02 05:48:16 +00:00
|
|
|
but for now it won't pass anywhere behind the optimizer */
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds[] = "NULL";
|
|
|
|
|
} else {
|
|
|
|
|
$this->mConds['log_user'] = $userid;
|
2008-04-08 22:54:15 +00:00
|
|
|
$this->user = $usertitle->getText();
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries affecting the given page.
|
|
|
|
|
* (For the block and rights logs, this is a user page.)
|
|
|
|
|
* @param string $page Title name as text
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2008-04-02 16:24:30 +00:00
|
|
|
function limitTitle( $page, $pattern ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgMiserMode;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = Title::newFromText( $page );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( strlen($page) == 0 || !$title instanceof Title )
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->title = $title->getPrefixedText();
|
2008-04-02 05:48:16 +00:00
|
|
|
$ns = $title->getNamespace();
|
2008-07-10 18:05:52 +00:00
|
|
|
# Using the (log_namespace, log_title, log_timestamp) index with a
|
|
|
|
|
# range scan (LIKE) on the first two parts, instead of simple equality,
|
|
|
|
|
# makes it unusable for sorting. Sorted retrieval using another index
|
|
|
|
|
# would be possible, but then we might have to scan arbitrarily many
|
|
|
|
|
# nodes of that index. Therefore, we need to avoid this if $wgMiserMode
|
|
|
|
|
# is on.
|
|
|
|
|
#
|
|
|
|
|
# This is not a problem with simple title matches, because then we can
|
|
|
|
|
# use the page_time index. That should have no more than a few hundred
|
|
|
|
|
# log entries for even the busiest pages, so it can be safely scanned
|
|
|
|
|
# in full to satisfy an impossible condition on user or similar.
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $pattern && !$wgMiserMode ) {
|
|
|
|
|
# use escapeLike to avoid expensive search patterns like 't%st%'
|
|
|
|
|
$safetitle = $this->mDb->escapeLike( $title->getDBkey() );
|
|
|
|
|
$this->mConds['log_namespace'] = $ns;
|
|
|
|
|
$this->mConds[] = "log_title LIKE '$safetitle%'";
|
2008-04-08 22:40:36 +00:00
|
|
|
$this->pattern = $pattern;
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds['log_namespace'] = $ns;
|
|
|
|
|
$this->mConds['log_title'] = $title->getDBkey();
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
function getQueryInfo() {
|
|
|
|
|
$this->mConds[] = 'user_id = log_user';
|
2008-04-08 08:46:15 +00:00
|
|
|
# Don't use the wrong logging index
|
2008-04-08 15:50:16 +00:00
|
|
|
if( $this->title || $this->pattern || $this->user ) {
|
|
|
|
|
$index = array( 'USE INDEX' => array( 'logging' => array('page_time','user_time') ) );
|
2008-04-08 08:51:52 +00:00
|
|
|
} else if( $this->type ) {
|
|
|
|
|
$index = array( 'USE INDEX' => array( 'logging' => 'type_time' ) );
|
2008-04-08 08:46:15 +00:00
|
|
|
} else {
|
|
|
|
|
$index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
|
|
|
|
|
}
|
2008-04-02 16:24:30 +00:00
|
|
|
return array(
|
|
|
|
|
'tables' => array( 'logging', 'user' ),
|
2008-04-14 07:45:50 +00:00
|
|
|
'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
|
2008-04-17 14:48:28 +00:00
|
|
|
'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
|
2008-04-02 16:24:30 +00:00
|
|
|
'conds' => $this->mConds,
|
2008-04-08 08:46:15 +00:00
|
|
|
'options' => $index
|
2008-04-02 16:24:30 +00:00
|
|
|
);
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
function getIndexField() {
|
|
|
|
|
return 'log_timestamp';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-08 15:50:16 +00:00
|
|
|
function getStartBody() {
|
|
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
# Do a link batch query
|
2008-04-08 23:30:36 +00:00
|
|
|
if( $this->getNumRows() > 0 ) {
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
while( $row = $this->mResult->fetchObject() ) {
|
|
|
|
|
$lb->add( $row->log_namespace, $row->log_title );
|
|
|
|
|
$lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
|
|
|
|
|
$lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
|
|
|
|
|
}
|
|
|
|
|
$lb->execute();
|
|
|
|
|
$this->mResult->seek( 0 );
|
2008-04-08 15:50:16 +00:00
|
|
|
}
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
function formatRow( $row ) {
|
2008-04-02 17:43:57 +00:00
|
|
|
return $this->mLogEventsList->logLine( $row );
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getType() {
|
2008-04-02 05:48:16 +00:00
|
|
|
return $this->type;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getUser() {
|
2008-04-02 05:48:16 +00:00
|
|
|
return $this->user;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getPage() {
|
|
|
|
|
return $this->title;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getPattern() {
|
2008-04-02 05:48:16 +00:00
|
|
|
return $this->pattern;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
public function getYear() {
|
2008-08-01 22:56:17 +00:00
|
|
|
return $this->mYear;
|
2008-04-12 06:11:09 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
public function getMonth() {
|
2008-08-01 22:56:17 +00:00
|
|
|
return $this->mMonth;
|
2008-04-12 06:11:09 +00:00
|
|
|
}
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
/**
|
2008-05-21 18:18:58 +00:00
|
|
|
* @deprecated
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2008-04-02 16:24:30 +00:00
|
|
|
*/
|
|
|
|
|
class LogReader {
|
2008-04-04 02:12:27 +00:00
|
|
|
var $pager;
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-04-02 16:24:30 +00:00
|
|
|
* @param WebRequest $request For internal use use a FauxRequest object to pass arbitrary parameters.
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
function __construct( $request ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
global $wgUser, $wgOut;
|
2008-04-02 16:24:30 +00:00
|
|
|
# Get parameters
|
|
|
|
|
$type = $request->getVal( 'type' );
|
|
|
|
|
$user = $request->getText( 'user' );
|
|
|
|
|
$title = $request->getText( 'page' );
|
|
|
|
|
$pattern = $request->getBool( 'pattern' );
|
2008-04-12 06:11:09 +00:00
|
|
|
$y = $request->getIntOrNull( 'year' );
|
|
|
|
|
$m = $request->getIntOrNull( 'month' );
|
|
|
|
|
# Don't let the user get stuck with a certain date
|
|
|
|
|
$skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
|
|
|
|
|
if( $skip ) {
|
|
|
|
|
$y = '';
|
|
|
|
|
$m = '';
|
|
|
|
|
}
|
|
|
|
|
# Use new list class to output results
|
|
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
|
|
|
|
|
$this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $y, $m );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:28:26 +00:00
|
|
|
/**
|
|
|
|
|
* Is there at least one row?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function hasRows() {
|
|
|
|
|
return isset($this->pager) ? ($this->pager->getNumRows() > 0) : false;
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-05-21 18:18:58 +00:00
|
|
|
* @deprecated
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
class LogViewer {
|
2008-04-02 06:03:00 +00:00
|
|
|
const NO_ACTION_LINK = 1;
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* @var LogReader $reader
|
|
|
|
|
*/
|
|
|
|
|
var $reader;
|
|
|
|
|
/**
|
|
|
|
|
* @param LogReader &$reader where to get our data from
|
|
|
|
|
* @param integer $flags Bitwise combination of flags:
|
2008-04-02 17:43:57 +00:00
|
|
|
* LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
function __construct( &$reader, $flags = 0 ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
$this->reader =& $reader;
|
2008-04-02 17:43:57 +00:00
|
|
|
$this->reader->pager->mLogEventsList->flags = $flags;
|
2008-04-02 16:24:30 +00:00
|
|
|
# Aliases for shorter code...
|
|
|
|
|
$this->pager =& $this->reader->pager;
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list =& $this->reader->pager->mLogEventsList;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Take over the whole output page in $wgOut with the log display.
|
|
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
public function show() {
|
2008-04-02 16:24:30 +00:00
|
|
|
# Set title and add header
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->showHeader( $pager->getType() );
|
2008-04-02 16:24:30 +00:00
|
|
|
# Show form options
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->list->showOptions( $this->pager->getType(), $this->pager->getUser(), $this->pager->getPage(),
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->pager->getPattern(), $this->pager->getYear(), $this->pager->getMonth() );
|
2008-04-02 16:24:30 +00:00
|
|
|
# Insert list
|
|
|
|
|
$logBody = $this->pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$wgOut->addHTML(
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->pager->getNavigationBar() .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->beginLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->endLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->pager->getNavigationBar()
|
|
|
|
|
);
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:24:30 +00:00
|
|
|
$wgOut->addWikiMsg( 'logempty' );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Output just the list of entries given by the linked LogReader,
|
|
|
|
|
* with extraneous UI elements. Use for displaying log fragments in
|
|
|
|
|
* another page (eg at Special:Undelete)
|
|
|
|
|
* @param OutputPage $out where to send output
|
|
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
public function showList( &$out ) {
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody = $this->pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$out->addHTML(
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->beginLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->endLogEventsList()
|
2008-04-02 16:24:30 +00:00
|
|
|
);
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:59:16 +00:00
|
|
|
$out->addWikiMsg( 'logempty' );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|