X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FChangesList.php;h=f75c5d5bc1a091f2154ef2a3a498ca7733d2436e;hb=b8880963ce764fa363072dc76cc698e809a93238;hp=c438b58a78c611b30b6e7f6447242867904163b7;hpb=56f811163b24c57b21071616214fc756de76bd4c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index c438b58a78..f75c5d5bc1 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1,95 +1,172 @@ mAttribs = $rc->mAttribs; $rc2->mExtra = $rc->mExtra; return $rc2; } -} ; +} /** - * Class to show various lists of changes: - * - what links here - * - related changes - * - recent changes + * Base class for all changes lists */ -class ChangesList { - # Called by history lists and recent changes - # +class ChangesList extends ContextSource { + + /** + * @var Skin + */ + public $skin; + + protected $watchlist = false; + + protected $message; /** - * Changeslist contructor - * @param Skin $skin - */ - function __construct( &$skin ) { - $this->skin =& $skin; + * Changeslist contructor + * + * @param $obj Skin or RequestContext + */ + public function __construct( $obj ) { + if ( $obj instanceof RequestContext ) { + $this->setContext( $obj ); + $this->skin = $obj->getSkin(); + } else { + $this->setContext( $obj->getContext() ); + $this->skin = $obj; + } $this->preCacheMessages(); } /** - * Fetch an appropriate changes list class for the specified user + * Fetch an appropriate changes list class for the main context + * This first argument used to be an User object. + * + * @deprecated in 1.18; use newFromContext() instead + * @param $unused Unused + * @return ChangesList|EnhancedChangesList|OldChangesList derivative + */ + public static function newFromUser( $unused ) { + return self::newFromContext( RequestContext::getMain() ); + } + + /** + * Fetch an appropriate changes list class for the specified context * Some users might want to use an enhanced list format, for instance * - * @param $user User to fetch the list class for - * @return ChangesList derivative - */ - public static function newFromUser( &$user ) { - $sk = $user->getSkin(); - $list = NULL; - if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { - return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); + * @param $context RequestContext to use + * @return ChangesList|EnhancedChangesList|OldChangesList derivative + */ + public static function newFromContext( RequestContext $context ) { + $user = $context->getUser(); + $sk = $context->getSkin(); + $list = null; + if( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) { + $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); + return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context ); } else { return $list; } } + /** + * Sets the list to use a
'.$tl.' ';
+ $tl = ""
+ . ""
+ . "{$this->sideArrow()}"
+ . ""
+ . "{$this->downArrow()}"
+ . "";
+ $r .= "$tl | ";
# Main line
- $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
+ $r .= '' . $this->recentChangesFlags( array(
+ 'newpage' => $isnew,
+ 'minor' => false,
+ 'unpatrolled' => $unpatrolled,
+ 'bot' => $bot ,
+ ) );
# Timestamp
- $r .= ' '.$block[0]->timestamp.' | ';
+ $r .= ' '.$block[0]->timestamp.' | ';
# Article link
if( $namehidden ) {
- $r .= ' ' . wfMsgHtml('rev-deleted-event') . '';
- } else {
+ $r .= ' ' . wfMsgHtml( 'rev-deleted-event' ) . '';
+ } elseif( $allLogs ) {
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
+ } else {
+ $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
}
- $r .= $wgContLang->getDirMark();
+ $r .= $this->getLang()->getDirMark();
- $curIdEq = 'curid=' . $curId;
+ $queryParams['curid'] = $curId;
# Changes message
$n = count($block);
static $nchanges = array();
if ( !isset( $nchanges[$n] ) ) {
- $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
+ $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) );
}
# Total change link
$r .= ' ';
- if( !$alllogs ) {
+ if( !$allLogs ) {
$r .= '(';
- if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+ if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
$r .= $nchanges[$n];
- } else if( $isnew ) {
+ } elseif( $isnew ) {
$r .= $nchanges[$n];
} else {
- $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
- $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
+ $params = $queryParams;
+ $params['diff'] = $currentRevision;
+ $params['oldid'] = $oldid;
+
+ $r .= Linker::link(
+ $block[0]->getTitle(),
+ $nchanges[$n],
+ array(),
+ $params,
+ array( 'known', 'noclasses' )
+ );
}
- $r .= ') . . ';
}
+ # History
+ if( $allLogs ) {
+ // don't show history link for logs
+ } elseif( $namehidden || !$block[0]->getTitle()->exists() ) {
+ $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')';
+ } else {
+ $params = $queryParams;
+ $params['action'] = 'history';
+
+ $r .= $this->message['pipe-separator'] .
+ Linker::linkKnown(
+ $block[0]->getTitle(),
+ $this->message['hist'],
+ array(),
+ $params
+ ) . ')';
+ }
+ $r .= ' . . ';
+
# Character difference (does not apply if only log items)
- if( $wgRCShowChangedSize && !$alllogs ) {
+ if( $wgRCShowChangedSize && !$allLogs ) {
$last = 0;
$first = count($block) - 1;
# Some events (like logs) have an "empty" size, so we need to skip those...
- while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === NULL ) {
+ while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
$last++;
}
- while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === NULL ) {
+ while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
$first--;
}
# Get net change
@@ -690,101 +978,96 @@ class EnhancedChangesList extends ChangesList {
}
}
- # History
- if( $alllogs ) {
- // don't show history link for logs
- } else if( $namehidden || !$block[0]->getTitle()->exists() ) {
- $r .= '(' . $this->message['history'] . ')';
- } else {
- $r .= '(' . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
- $this->message['history'], $curIdEq.'&action=history' ) . ')';
- }
-
$r .= $users;
$r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
- $r .= " | |
'.$this->spacerArrow(); - $r .= ' | ||
'; - $r .= ''.$this->spacerIndent() . $this->spacerIndent(); - $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); - $r .= ' | '; - - $o = ''; - if( $rc_this_oldid != 0 ) { - $o = 'oldid='.$rc_this_oldid; + $r .= ' | |
'; + $r .= $this->recentChangesFlags( array( + 'newpage' => $rcObj->mAttribs['rc_new'], + 'minor' => $rcObj->mAttribs['rc_minor'], + 'unpatrolled' => $rcObj->unpatrolled, + 'bot' => $rcObj->mAttribs['rc_bot'], + ) ); + $r .= ' | '; + + $params = $queryParams; + + if( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { + $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; } + # Log timestamp - if( $rc_type == RC_LOG ) { - $link = ''.$rcObj->timestamp.' '; + if( $type == RC_LOG ) { + $link = $rcObj->timestamp; # Revision link - } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { - $link = ''.$rcObj->timestamp.' '; + } elseif( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { + $link = ''.$rcObj->timestamp.' '; } else { - $rcIdEq = ($rcObj->unpatrolled && $rc_type == RC_NEW) ? '&rcid='.$rcObj->mAttribs['rc_id'] : ''; - - $link = ''.$this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o.$rcIdEq ).''; + if ( $rcObj->unpatrolled && $type == RC_NEW) { + $params['rcid'] = $rcObj->mAttribs['rc_id']; + } + + $link = Linker::linkKnown( + $rcObj->getTitle(), + $rcObj->timestamp, + array(), + $params + ); if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) $link = ''.$link.' '; } - $r .= $link; + $r .= $link . ''; - if ( !$rc_type == RC_LOG || $rc_type == RC_NEW ) { + if ( !$type == RC_LOG || $type == RC_NEW ) { $r .= ' ('; $r .= $rcObj->curlink; - $r .= $this->message['semicolon-separator']; + $r .= $this->message['pipe-separator']; $r .= $rcObj->lastlink; $r .= ')'; } $r .= ' . . '; # Character diff - if( $wgRCShowChangedSize ) { - $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ; + if( $wgRCShowChangedSize && $rcObj->getCharacterDifference() ) { + $r .= $rcObj->getCharacterDifference() . ' . . ' ; } + # User links $r .= $rcObj->userlink; $r .= $rcObj->usertalklink; // log action - parent::insertAction( $r, $rcObj ); + $this->insertAction( $r, $rcObj ); // log comment - parent::insertComment( $r, $rcObj ); - # Mark revision as deleted - if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) { - $r .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; - } + $this->insertComment( $r, $rcObj ); + # Rollback + $this->insertRollback( $r, $rcObj ); + # Tags + $this->insertTags( $r, $rcObj, $classes ); $r .= " |
' . $this->spacerArrow() . ' ';
+ $type = $rcObj->mAttribs['rc_type'];
+ $logType = $rcObj->mAttribs['rc_log_type'];
+ if( $logType ) {
+ # Log entry
+ $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType . '-' . $rcObj->mAttribs['rc_title'] );
+ } else {
+ $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
+ }
+ $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
+ Html::openElement( 'tr' );
+ $r .= '' . $this->spacerArrow();
# Flag and Timestamp
- if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
- $r .= ' '; // 4 flags -> 4 spaces
+ if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
+ $r .= ' '; // 4 flags -> 4 spaces
} else {
- $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot );
+ $r .= $this->recentChangesFlags( array(
+ 'newpage' => $type == RC_NEW,
+ 'mino' => $rcObj->mAttribs['rc_minor'],
+ 'unpatrolled' => $rcObj->unpatrolled,
+ 'bot' => $rcObj->mAttribs['rc_bot'],
+ ) );
}
- $r .= ' '.$rcObj->timestamp.' | ';
-
+ $r .= ' '.$rcObj->timestamp.' | ';
# Article or log link
- if( $rc_log_type ) {
- $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
- $logname = LogPage::logName( $rc_log_type );
- $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')';
- } else if( !$this->userCan($rcObj,Revision::DELETED_TEXT) ) {
- $r .= '' . $rcObj->link . '';
+ if( $logType ) {
+ $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
+ $logname = LogPage::logName( $logType );
+ $r .= '(' . Linker::linkKnown( $logtitle, htmlspecialchars( $logname ) ) . ')';
} else {
- $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched );
+ $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
}
-
# Diff and hist links
- if ( $rc_type != RC_LOG ) {
- $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
- $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
+ if ( $type != RC_LOG ) {
+ $r .= ' ('. $rcObj->difflink . $this->message['pipe-separator'];
+ $query['action'] = 'history';
+ $r .= Linker::linkKnown(
+ $rcObj->getTitle(),
+ $this->message['hist'],
+ array(),
+ $query
+ ) . ')';
}
$r .= ' . . ';
-
# Character diff
- if( $wgRCShowChangedSize ) {
- $r .= ( $rcObj->getCharacterDifference() == '' ? '' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
+ if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
+ $r .= "$cd . . ";
}
-
# User/talk
$r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
-
# Log action (if any)
- if( $rc_log_type ) {
+ if( $logType ) {
if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
$r .= ' ' . wfMsgHtml('rev-deleted-event') . '';
} else {
- $r .= ' ' . LogPage::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
- $this->skin, LogPage::extractParams($rc_params), true, true );
+ $r .= ' ' . LogPage::actionText( $logType, $rcObj->mAttribs['rc_log_action'], $rcObj->getTitle(),
+ $this->getSkin(), LogPage::extractParams( $rcObj->mAttribs['rc_params'] ), true, true );
}
}
-
- # Edit or log comment
- if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
- // log comment
- if ( $this->isDeleted($rcObj,LogPage::DELETED_COMMENT) ) {
- $r .= ' ' . wfMsg('rev-deleted-comment') . '';
- } else {
- $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
- }
- }
-
+ $this->insertComment( $r, $rcObj );
+ $this->insertRollback( $r, $rcObj );
+ # Tags
+ $classes = explode( ' ', $classes );
+ $this->insertTags( $r, $rcObj, $classes );
# Show how many people are watching this if enabled
$r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
$r .= " | |