X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FChangesList.php;h=f75c5d5bc1a091f2154ef2a3a498ca7733d2436e;hb=b8880963ce764fa363072dc76cc698e809a93238;hp=1bfdc39bf5ea779bdc024279118d346298fb1b7f;hpb=eb62ec3e7086b3da23ff24c5c0c0867844e1a6f9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 1bfdc39bf5..f75c5d5bc1 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1,4 +1,12 @@ mAttribs = $rc->mAttribs; @@ -17,46 +29,69 @@ 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(); $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 .= ' '; @@ -878,14 +920,14 @@ class EnhancedChangesList extends ChangesList { $r .= '('; if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) { $r .= $nchanges[$n]; - } else if( $isnew ) { + } elseif( $isnew ) { $r .= $nchanges[$n]; } else { $params = $queryParams; $params['diff'] = $currentRevision; $params['oldid'] = $oldid; - - $r .= $this->skin->link( + + $r .= Linker::link( $block[0]->getTitle(), $nchanges[$n], array(), @@ -898,19 +940,18 @@ class EnhancedChangesList extends ChangesList { # History if( $allLogs ) { // don't show history link for logs - } else if( $namehidden || !$block[0]->getTitle()->exists() ) { + } 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'] . - $this->skin->link( + Linker::linkKnown( $block[0]->getTitle(), $this->message['hist'], array(), - $params, - array( 'known', 'noclasses' ) + $params ) . ')'; } $r .= ' . . '; @@ -920,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 @@ -940,55 +981,51 @@ 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 .= ' | ';
+ $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( $rc_this_oldid != 0 ) {
- $params['oldid'] = $rc_this_oldid;
+ if( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
+ $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
}
# Log timestamp
- if( $rc_type == RC_LOG ) {
+ if( $type == RC_LOG ) {
$link = $rcObj->timestamp;
# Revision link
- } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+ } elseif( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
$link = ''.$rcObj->timestamp.' ';
} else {
- if ( $rcObj->unpatrolled && $rc_type == RC_NEW) {
+ if ( $rcObj->unpatrolled && $type == RC_NEW) {
$params['rcid'] = $rcObj->mAttribs['rc_id'];
}
- $link = $this->skin->link(
+ $link = Linker::linkKnown(
$rcObj->getTitle(),
$rcObj->timestamp,
array(),
- $params,
- array( 'known', 'noclasses' )
+ $params
);
if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
$link = ''.$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['pipe-separator'];
@@ -998,9 +1035,10 @@ class EnhancedChangesList extends ChangesList {
$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;
@@ -1015,7 +1053,7 @@ class EnhancedChangesList extends ChangesList {
$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->link( - $logtitle, - $logname, - array(), - array(), - array( 'known', 'noclasses' ) - ) . ')'; + 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 ) { + if ( $type != RC_LOG ) { $r .= ' ('. $rcObj->difflink . $this->message['pipe-separator']; $query['action'] = 'history'; - $r .= $this->skin->link( + $r .= Linker::linkKnown( $rcObj->getTitle(), $this->message['hist'], array(), - $query, - array( 'known', 'noclasses' ) + $query ) . ')'; } $r .= ' . . '; @@ -1134,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); @@ -1159,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 ) { @@ -1182,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() { |