/**
* Changeslist contructor
*
- * @param $obj Skin or RequestContext
+ * @param $obj Skin or IContextSource
*/
public function __construct( $obj ) {
- if ( $obj instanceof RequestContext ) {
+ if ( $obj instanceof IContextSource ) {
$this->setContext( $obj );
$this->skin = $obj->getSkin();
} else {
* Fetch an appropriate changes list class for the specified context
* Some users might want to use an enhanced list format, for instance
*
- * @param $context RequestContext to use
+ * @param $context IContextSource to use
* @return ChangesList|EnhancedChangesList|OldChangesList derivative
*/
- public static function newFromContext( RequestContext $context ) {
+ public static function newFromContext( IContextSource $context ) {
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
}
}
- /**
- * @param $s
- * @param $rc RecentChange
- * @return void
- */
- public function insertMove( &$s, $rc ) {
- # Diff
- $s .= '(' . $this->message['diff'] . ') (';
- # Hist
- $s .= Linker::linkKnown(
- $rc->getMovedToTitle(),
- $this->message['hist'],
- array(),
- array( 'action' => 'history' )
- ) . ') . . ';
- # "[[x]] moved to [[y]]"
- $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
- $s .= wfMsgHtml(
- $msg,
- Linker::linkKnown(
- $rc->getTitle(),
- null,
- array(),
- array( 'redirect' => 'no' )
- ),
- Linker::linkKnown( $rc->getMovedToTitle() )
- );
- }
-
public function insertDateHeader( &$s, $rc_timestamp ) {
# Make date header if necessary
$date = $this->getLang()->date( $rc_timestamp, true, true );
}
public function insertLog( &$s, $title, $logtype ) {
- $logname = LogPage::logName( $logtype );
- $s .= '(' . Linker::linkKnown( $title, htmlspecialchars( $logname ) ) . ')';
+ $page = new LogPage( $logtype );
+ $logname = $page->getName()->escaped();
+ $s .= '(' . Linker::linkKnown( $title, $logname ) . ')';
}
/**
$params['rcid'] = $rc->mAttribs['rc_id'];
}
+ $articlelink = Linker::linkKnown(
+ $rc->getTitle(),
+ null,
+ array(),
+ $params
+ );
if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
- $articlelink = Linker::linkKnown(
- $rc->getTitle(),
- null,
- array(),
- $params
- );
$articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
- } else {
- $articlelink = ' '. Linker::linkKnown(
- $rc->getTitle(),
- null,
- array(),
- $params
- );
}
# Bolden pages watched by this user
if( $watched ) {
*
* @param $rc RecentChange
*/
- public function insertAction( &$s, &$rc ) {
- if( $rc->mAttribs['rc_type'] == RC_LOG ) {
- if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) {
- $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
- } else {
- $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
- $rc->getTitle(), $this->getSkin(), LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
- }
- }
+ public function insertLogEntry( $rc ) {
+ $formatter = LogFormatter::newFromRow( $rc->mAttribs );
+ $formatter->setShowUserToolLinks( true );
+ $mark = $this->getLang()->getDirMark();
+ return $formatter->getActionText() . " $mark" . $formatter->getComment();
}
- /** insert a formatted comment
- *
+ /**
+ * Insert a formatted comment
* @param $rc RecentChange
*/
- public function insertComment( &$s, &$rc ) {
+ public function insertComment( $rc ) {
if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
- $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
+ return ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
} else {
- $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
+ return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
}
}
}
}
}
- // Moved pages
+ // Moved pages (very very old, not supported anymore)
if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
- $this->insertMove( $s, $rc );
// Log entries
} elseif( $rc->mAttribs['rc_log_type'] ) {
- $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL );
+ $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
$this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
// Log entries (old format) or log targets, and special pages
} elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
$s .= "$cd . . ";
}
}
- # User tool links
- $this->insertUserRelatedLinks( $s, $rc );
- # LTR/RTL direction mark
- $s .= $this->getLang()->getDirMark();
- # Log action text (if any)
- $this->insertAction( $s, $rc );
- # LTR/RTL direction mark
- $s .= $this->getLang()->getDirMark();
- # Edit or log comment
- $this->insertComment( $s, $rc );
+
+ if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
+ $s .= $this->insertLogEntry( $rc );
+ } else {
+ # User tool links
+ $this->insertUserRelatedLinks( $s, $rc );
+ # LTR/RTL direction mark
+ $s .= $this->getLang()->getDirMark();
+ $s .= $this->insertComment( $rc );
+ }
+
# Tags
$this->insertTags( $s, $rc, $classes );
# Rollback
# Make article link
$type = $rc->mAttribs['rc_type'];
$logType = $rc->mAttribs['rc_log_type'];
- // Page moves
+ // Page moves, very old style, not supported anymore
if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
- $msg = ( $type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
- $clink = wfMsg( $msg, Linker::linkKnown( $rc->getTitle(), null,
- array(), array( 'redirect' => 'no' ) ),
- Linker::linkKnown( $rc->getMovedToTitle() ) );
// New unpatrolled pages
} elseif( $rc->unpatrolled && $type == RC_NEW ) {
$clink = Linker::linkKnown( $rc->getTitle(), null, array(),
$r .= $rcObj->getCharacterDifference() . ' . . ' ;
}
- # User links
- $r .= $rcObj->userlink;
- $r .= $rcObj->usertalklink;
- // log action
- $this->insertAction( $r, $rcObj );
- // log comment
- $this->insertComment( $r, $rcObj );
+ if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
+ $r .= $this->insertLogEntry( $rcObj );
+ } else {
+ # User links
+ $r .= $rcObj->userlink;
+ $r .= $rcObj->usertalklink;
+ $r .= $this->insertComment( $rcObj );
+ }
+
# Rollback
$this->insertRollback( $r, $rcObj );
# Tags
if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
$r .= "$cd . . ";
}
- # User/talk
- $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
- # Log action (if any)
- if( $logType ) {
- if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
- $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
- } else {
- $r .= ' ' . LogPage::actionText( $logType, $rcObj->mAttribs['rc_log_action'], $rcObj->getTitle(),
- $this->getSkin(), LogPage::extractParams( $rcObj->mAttribs['rc_params'] ), true, true );
- }
+
+ if ( $type == RC_LOG ) {
+ $r .= $this->insertLogEntry( $rcObj );
+ } else {
+ $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
+ $r .= $this->insertComment( $rcObj );
+ $r .= $this->insertRollback( $r, $rcObj );
}
- $this->insertComment( $r, $rcObj );
- $this->insertRollback( $r, $rcObj );
+
# Tags
$classes = explode( ' ', $classes );
$this->insertTags( $r, $rcObj, $classes );