* @package MediaWiki
*/
class LogPage {
- /* private */ var $type, $action, $comment, $params;
+ /* private */ var $type, $action, $comment, $params, $target;
var $updateRecentChanges = true;
function LogPage( $type ) {
# And update recentchanges
if ( $this->updateRecentChanges ) {
+ $titleObj = Title::makeTitle( NS_SPECIAL, 'Log/' . $this->type );
$rcComment = $this->actionText;
if( '' != $this->comment ) {
$rcComment .= ': ' . $this->comment;
}
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Log/' . $this->type );
+
RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment );
}
return true;
/**
* @static
*/
- function actionText( $type, $action, $titleLink = NULL, $params = array(), $filterWikilinks=false ) {
+ function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false ) {
static $actions = array(
'block/block' => 'blocklogentry',
'block/unblock' => 'unblocklogentry',
);
$key = "$type/$action";
if( isset( $actions[$key] ) ) {
- if( is_null( $titleLink ) ) {
+ if( is_null( $title ) ) {
$rv=wfMsgForContent( $actions[$key] );
- } elseif ( count( $params ) == 0 ) {
- $rv=wfMsgForContent( $actions[$key], $titleLink );
- } else {
- array_unshift( $params, $titleLink );
- $rv=wfMsgReal( $actions[$key], $params, true, true );
+ }
+ else {
+ if ( $skin ) {
+ if ( $type == 'move' ) {
+ $titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' );
+ // Change $param[0] into a link to the title specified in $param[0]
+ $movedTo = Title::newFromText( $params[0] );
+ $params[0] = $skin->makeLinkObj( $movedTo, $params[0] );
+ } else {
+ $titleLink = $skin->makeLinkObj( $title );
+ }
+ } else {
+ $titleLink = $title->getPrefixedText();
+ }
+ if ( count( $params ) == 0 ) {
+ $rv=wfMsgForContent( $actions[$key], $titleLink );
+ } else {
+ array_unshift( $params, $titleLink );
+ $rv=wfMsgReal( $actions[$key], $params, true, true );
+ }
}
} else {
wfDebug( "LogPage::actionText - unknown action $key\n" );
/**
* Add a log entry
- * @param string $action one of 'block', 'protect', 'rights', 'delete', 'upload'
+ * @param string $action one of 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
* @param object &$target A title object.
* @param string $comment Description associated
* @param array $params Parameters passed later to wfMsg.* functions
$this->params = LogPage::makeParamBlob( $params );
$this->actionText = LogPage::actionText( $this->type, $action,
- $target->getPrefixedText(), $params );
+ $target, NULL, $params );
+
return $this->saveContent();
}
* @param OutputPage $out where to send output
*/
function showList( &$out ) {
- $html = "\n<ul>\n";
+ global $wgLinkCache;
$result = $this->reader->getRows();
+
+ // Fetch results and form a batch link existence query
+ $batch = new LinkBatch;
+ while ( $s = $result->fetchObject() ) {
+ // User link
+ $title = Title::makeTitleSafe( NS_USER, $s->user_name );
+ $batch->addObj( $title );
+
+ // Move destination link
+ if ( $s->log_type == 'move' ) {
+ $paramArray = LogPage::extractParams( $s->log_params );
+ $title = Title::newFromText( $paramArray[0] );
+ $batch->addObj( $title );
+ }
+ }
+ $batch->execute( $wgLinkCache );
+
+ // Rewind result pointer and go through it again, making the HTML
+ $result->seek( 0 );
+ $html = "\n<ul>\n";
while( $s = $result->fetchObject() ) {
$html .= $this->logLine( $s );
}
* @private
*/
function logLine( $s ) {
- global $wgLang;
+ global $wgLang, $wgLinkCache;
$title = Title::makeTitle( $s->log_namespace, $s->log_title );
$user = Title::makeTitleSafe( NS_USER, $s->user_name );
$time = $wgLang->timeanddate( $s->log_timestamp, true );
+
+ // Enter the existence or non-existence of this page into the link cache,
+ // for faster makeLinkObj() in LogPage::actionText()
if( $s->page_id ) {
- $titleLink = $this->skin->makeKnownLinkObj( $title );
+ $wgLinkCache->addGoodLink( $s->page_id, $title->getPrefixedText() );
} else {
- $titleLink = $this->skin->makeBrokenLinkObj( $title );
+ $wgLinkCache->addBadLink( $title->getPrefixedText() );
}
+
$userLink = $this->skin->makeLinkObj( $user, htmlspecialchars( $s->user_name ) );
$comment = $this->skin->commentBlock( $s->log_comment );
$paramArray = LogPage::extractParams( $s->log_params );
- $action = LogPage::actionText( $s->log_type, $s->log_action, $titleLink, $paramArray, true );
+ $action = LogPage::actionText( $s->log_type, $s->log_action, $title, $this->skin, $paramArray, true );
$out = "<li>$time $userLink $action $comment</li>\n";
return $out;
}