X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FChangesList.php;h=f75c5d5bc1a091f2154ef2a3a498ca7733d2436e;hb=b8880963ce764fa363072dc76cc698e809a93238;hp=3e34fe40c8ae92b6fd533550ac2c3882683757a8;hpb=eb1c7640db1670c9a5d8cf0f2da4f2b1d3816064;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 3e34fe40c8..f75c5d5bc1 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1,4 +1,12 @@ mAttribs = $rc->mAttribs; @@ -17,78 +29,144 @@ class RCCacheEntry extends RecentChange { } /** - * 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 - */ - public 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 + * @param $context RequestContext to use + * @return ChangesList|EnhancedChangesList|OldChangesList 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 ); + 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 if( $allLogs ) {
+ } 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 .= ' ';
@@ -745,22 +920,39 @@ class EnhancedChangesList extends ChangesList {
$r .= '(';
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' )
+ );
}
}
# History
if( $allLogs ) {
// don't show history link for logs
- } else if( $namehidden || !$block[0]->getTitle()->exists() ) {
- $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')';
+ } elseif( $namehidden || !$block[0]->getTitle()->exists() ) {
+ $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')';
} else {
- $r .= $this->message['semicolon-separator'] . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
- $this->message['hist'], $curIdEq . '&action=history' ) . ')';
+ $params = $queryParams;
+ $params['action'] = 'history';
+
+ $r .= $this->message['pipe-separator'] .
+ Linker::linkKnown(
+ $block[0]->getTitle(),
+ $this->message['hist'],
+ array(),
+ $params
+ ) . ')';
}
$r .= ' . . ';
@@ -769,10 +961,10 @@ class EnhancedChangesList extends ChangesList {
$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
@@ -789,58 +981,64 @@ class EnhancedChangesList extends ChangesList {
$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; @@ -852,15 +1050,10 @@ class EnhancedChangesList extends ChangesList { $this->insertRollback( $r, $rcObj ); # Tags $this->insertTags( $r, $rcObj, $classes ); - - # Mark revision as deleted - if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) { - $r .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; - } $r .= " |
' . $this->spacerArrow() . ' ';
+ $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 ) . ')';
+ if( $logType ) {
+ $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
+ $logname = LogPage::logName( $logType );
+ $r .= '(' . Linker::linkKnown( $logtitle, htmlspecialchars( $logname ) ) . ')';
} else {
$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(), $this->message['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
@@ -967,17 +1168,18 @@ class EnhancedChangesList extends ChangesList {
# 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 );
}
}
$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);
@@ -992,6 +1194,8 @@ class EnhancedChangesList extends ChangesList {
/**
* If enhanced RC is in use, this function takes the previously cached
* RC lines, arranges them, and outputs the HTML
+ *
+ * @return string
*/
protected function recentChangesBlock() {
if( count ( $this->rc_cache ) == 0 ) {
@@ -1015,7 +1219,7 @@ class EnhancedChangesList extends ChangesList {
}
/**
- * Returns text for the end of RC
+ * Returns text for the end of RC
* If enhanced RC is in use, returns pretty much all the text
*/
public function endRecentChangesList() {
| |