X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=blobdiff_plain;f=includes%2FChangesList.php;h=119c7a223aceaa853a9393346ad9325e54723b37;hb=5bccf15053aaefd43bedc429db89d1f3626dfac9;hp=b51b166f3cdefc52ccea299a01833b22fafb103b;hpb=854a37a73ab0b901298dabb546e76ba8b012425c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index b51b166f3c..119c7a223a 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1,4 +1,12 @@ mAttribs = $rc->mAttribs; @@ -17,46 +29,70 @@ 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 IContextSource + */ + public function __construct( $obj ) { + if ( $obj instanceof IContextSource ) { + $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 ) { + wfDeprecated( __METHOD__, '1.18' ); + 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 IContextSource 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( IContextSource $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->getLanguage()->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->getLanguage()->formatNum( $n ) );
}
# Total change link
$r .= ' ';
if( !$allLogs ) {
$r .= '(';
- if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
+ if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$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(),
@@ -831,19 +920,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 .= ' . . ';
@@ -853,10 +941,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
@@ -873,56 +961,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 ) { - $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, $this->getUser() ) ) { + $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; + $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']; @@ -932,16 +1015,19 @@ class EnhancedChangesList extends ChangesList { $r .= ' . . '; # Character diff - if( $wgRCShowChangedSize ) { - $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ; + if( $wgRCShowChangedSize && $rcObj->getCharacterDifference() ) { + $r .= $rcObj->getCharacterDifference() . ' . . ' ; + } + + if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { + $r .= $this->insertLogEntry( $rcObj ); + } else { + # User links + $r .= $rcObj->userlink; + $r .= $rcObj->usertalklink; + $r .= $this->insertComment( $rcObj ); } - # User links - $r .= $rcObj->userlink; - $r .= $rcObj->usertalklink; - // log action - $this->insertAction( $r, $rcObj ); - // log comment - $this->insertComment( $r, $rcObj ); + # Rollback $this->insertRollback( $r, $rcObj ); # Tags @@ -949,7 +1035,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,
+ 'minor' => $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 .= ' . . ';
@@ -1065,20 +1149,17 @@ class EnhancedChangesList extends ChangesList {
if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
$r .= "$cd . . ";
}
- # User/talk
- $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
- # Log action (if any)
- if( $rc_log_type ) {
- 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 );
- }
+
+ 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 );
# Show how many people are watching this if enabled
$r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
@@ -1093,6 +1174,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 ) {
@@ -1116,8 +1199,9 @@ 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
+ * @return string
*/
public function endRecentChangesList() {
return $this->recentChangesBlock() . parent::endRecentChangesList();
| |