4 # Called by history lists and recent changes
7 function ChangesList( &$skin ) {
11 # Returns text for the start of the tabular part of RC
12 function beginRecentChangesList() {
13 $this->rc_cache
= array() ;
14 $this->rcMoveIndex
= 0;
15 $this->rcCacheIndex
= 0 ;
17 $this->rclistOpen
= false;
22 * Returns text for the end of RC
23 * If enhanced RC is in use, returns pretty much all the text
25 function endRecentChangesList() {
26 $s = $this->recentChangesBlock() ;
27 if( $this->rclistOpen
) {
34 * Enhanced RC ungrouped line
36 function recentChangesBlockLine ( $rcObj ) {
37 global $wgStylePath, $wgContLang ;
39 # Get rc_xxxx variables
40 extract( $rcObj->mAttribs
) ;
41 $curIdEq = 'curid='.$rc_cur_id;
46 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
49 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
53 $M = wfMsg( 'minoreditletter' );
54 $N = wfMsg( 'newpageletter' );
56 if ( $rc_type == RC_NEW
) {
66 if ( $rcObj->unpatrolled
) {
74 $r .= ' '.$rcObj->timestamp
.' ' ;
78 $link = $rcObj->link
;
79 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
84 $r .= $rcObj->difflink
;
88 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
91 $r .= ') . . '.$rcObj->userlink
;
92 $r .= $rcObj->usertalklink
;
95 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
96 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
97 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
107 function recentChangesBlockGroup ( $block ) {
108 global $wgStylePath, $wgContLang ;
111 $M = wfMsg( 'minoreditletter' );
112 $N = wfMsg( 'newpageletter' );
114 # Collate list of users
116 $unpatrolled = false;
117 $userlinks = array () ;
118 foreach ( $block AS $rcObj ) {
119 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
120 if ( $rcObj->mAttribs
['rc_new'] ) {
123 $u = $rcObj->userlink
;
124 if ( !isset ( $userlinks[$u] ) ) {
127 if ( $rcObj->unpatrolled
) {
133 # Sort the list and convert to text
134 krsort ( $userlinks ) ;
135 asort ( $userlinks ) ;
137 foreach ( $userlinks as $userlink => $count) {
139 if ( $count > 1 ) $text .= " ({$count}×)" ;
140 array_push ( $users , $text ) ;
142 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
145 $rci = 'RCI'.$this->rcCacheIndex
;
146 $rcl = 'RCL'.$this->rcCacheIndex
;
147 $rcm = 'RCM'.$this->rcCacheIndex
;
148 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
149 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
150 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
151 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" alt="-" /></a></span>' ;
157 if ( $isnew ) $r .= $N ;
158 else $r .= ' ' ;
159 $r .= ' ' ; # Minor
160 if ( $unpatrolled ) {
167 $r .= ' '.$block[0]->timestamp
.' ' ;
171 $link = $block[0]->link
;
172 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
175 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
176 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
178 $r .= ' ('.count($block).' ' ;
179 if ( $isnew ) $r .= wfMsg('changes');
180 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
181 $curIdEq.'&diff=0&oldid='.$oldid ) ;
185 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
193 $r .= '<div id="'.$rci.'" style="display:none">' ;
194 foreach ( $block AS $rcObj ) {
195 # Get rc_xxxx variables
196 extract( $rcObj->mAttribs
);
198 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
199 $r .= '<tt> ' ;
212 if ( $rcObj->unpatrolled
) {
218 $r .= ' </tt>' ;
221 if ( $rc_last_oldid != 0 ) {
222 $o = 'oldid='.$rc_last_oldid ;
224 if ( $rc_type == RC_LOG
) {
225 $link = $rcObj->timestamp
;
227 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
229 $link = '<tt>'.$link.'</tt>' ;
233 $r .= $rcObj->curlink
;
235 $r .= $rcObj->lastlink
;
236 $r .= ') . . '.$rcObj->userlink
;
237 $r .= $rcObj->usertalklink
;
238 if ( $rc_comment != '' ) {
239 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
240 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
246 $this->rcCacheIndex++
;
251 * If enhanced RC is in use, this function takes the previously cached
252 * RC lines, arranges them, and outputs the HTML
254 function recentChangesBlock () {
255 global $wgStylePath ;
256 if ( count ( $this->rc_cache
) == 0 ) return '' ;
258 foreach ( $this->rc_cache
AS $secureName => $block ) {
259 if ( count ( $block ) < 2 ) {
260 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
262 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
266 return '<div>'.$blockOut.'</div>' ;
270 * Called in a loop over all displayed RC entries
271 * Either returns the line, or caches it for later use
273 function recentChangesLine( &$rc, $watched = false ) {
275 $usenew = $wgUser->getOption( 'usenewrc' );
277 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
279 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
283 function recentChangesLineOld( &$rc, $watched = false ) {
284 $fname = 'Skin::recentChangesLineOld';
285 wfProfileIn( $fname );
287 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
290 if( !isset( $message ) ) {
291 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
292 $message[$msg] = wfMsg( $msg );
296 # Extract DB fields into local scope
297 extract( $rc->mAttribs
);
298 $curIdEq = 'curid=' . $rc_cur_id;
300 # Should patrol-related stuff be shown?
301 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
302 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
304 # Make date header if necessary
305 $date = $wgLang->date( $rc_timestamp, true);
307 if ( $date != $this->lastdate
) {
308 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
309 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
310 $this->lastdate
= $date;
311 $this->rclistOpen
= true;
316 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
318 $s .= '(' . $message['diff'] . ') (';
320 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
323 # "[[x]] moved to [[y]]"
324 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
325 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
326 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
327 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
329 $logtype = $matches[1];
330 $logname = LogPage
::logName( $logtype );
331 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
333 wfProfileIn("$fname-page");
335 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
336 $diffLink = $message['diff'];
339 $rcidparam = "&rcid={$rc_id}";
342 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
343 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
344 '', '', ' tabindex="'.$rc->counter
.'"');
346 $s .= '('.$diffLink.') (';
349 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
352 # M, N and ! (minor, new and unpatrolled)
353 if ( $rc_minor ) { $s .= ' <span class="minor">'.$message["minoreditletter"].'</span>'; }
354 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.$message["newpageletter"].'</span>'; }
355 if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
358 # If it's a new article, there is no diff link, but if it hasn't been
359 # patrolled yet, we need to give users a way to do so
360 if ( $unpatrolled && $rc_type == RC_NEW
)
361 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
363 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
366 $articleLink = '<strong>'.$articleLink.'</strong>';
368 $s .= ' '.$articleLink;
369 wfProfileOut("$fname-page");
372 wfProfileIn( "$fname-rest" );
374 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
376 # User link (or contributions for unregistered users)
377 if ( 0 == $rc_user ) {
378 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
379 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
380 $rc_user_text, 'target=' . $rc_user_text );
382 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
383 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
388 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
389 global $wgDisableAnonTalk;
390 if( 0 == $rc_user && $wgDisableAnonTalk ) {
393 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
394 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
398 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
399 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
400 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
401 $message['blocklink'], 'ip='.$rc_user_text );
405 if($userTalkLink) $userTalkLink .= ' | ';
406 $userTalkLink .= $blockLink;
408 if($userTalkLink) $s.=' ('.$userTalkLink.')';
411 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
412 $rc_comment = $this->skin
->formatComment($rc_comment,$rc->getTitle());
413 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
417 wfProfileOut( "$fname-rest" );
418 wfProfileOut( $fname );
422 function recentChangesLineNew( &$baseRC, $watched = false ) {
423 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
424 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
427 if( !isset( $message ) ) {
428 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
429 $message[$msg] = wfMsg( $msg );
433 # Create a specialised object
434 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
436 # Extract fields from DB into the function scope (rc_xxxx variables)
437 extract( $rc->mAttribs
);
438 $curIdEq = 'curid=' . $rc_cur_id;
440 # If it's a new day, add the headline and flush the cache
441 $date = $wgLang->date( $rc_timestamp, true);
443 if ( $date != $this->lastdate
) {
444 # Process current cache
445 $ret = $this->recentChangesBlock () ;
446 $this->rc_cache
= array() ;
447 $ret .= "<h4>{$date}</h4>\n";
448 $this->lastdate
= $date;
451 # Should patrol-related stuff be shown?
452 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
453 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
454 $rc->unpatrolled
= !$rc_patrolled;
456 $rc->unpatrolled
= false;
460 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
461 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
462 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
463 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
464 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
466 $logtype = $matches[1];
467 $logname = LogPage
::logName( $logtype );
468 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
469 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
470 # Unpatrolled new page, give rc_id in query
471 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
473 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
476 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
477 $rc->watched
= $watched ;
479 $rc->timestamp
= $time;
481 # Make "cur" and "diff" links
482 $titleObj = $rc->getTitle();
483 if ( $rc->unpatrolled
) {
484 $rcIdQuery = "&rcid={$rc_id}";
488 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
489 $curLink = $message['cur'];
490 $diffLink = $message['diff'];
492 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
493 $aprops = ' tabindex="'.$baseRC->counter
.'"';
494 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
495 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
499 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
500 $lastLink = $message['last'];
502 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
503 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
506 # Make user link (or user contributions for unregistered users)
507 if ( $rc_user == 0 ) {
508 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
509 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
510 $rc_user_text, 'target=' . $rc_user_text );
512 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
513 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
516 $rc->userlink
= $userLink;
517 $rc->lastlink
= $lastLink;
518 $rc->curlink
= $curLink;
519 $rc->difflink
= $diffLink;
521 # Make user talk link
522 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
523 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
524 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
526 global $wgDisableAnonTalk;
527 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
528 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
529 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
530 $message['blocklink'], 'ip='.$rc_user_text );
531 if( $wgDisableAnonTalk )
532 $rc->usertalklink
= ' ('.$blockLink.')';
534 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
536 if( $wgDisableAnonTalk && ($rc_user == 0) )
537 $rc->usertalklink
= '';
539 $rc->usertalklink
= ' ('.$userTalkLink.')';
542 # Put accumulated information into the cache, for later display
543 # Page moves go on their own line
544 $title = $rc->getTitle();
545 $secureName = $title->getPrefixedDBkey();
546 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
547 # Use an @ character to prevent collision with page names
548 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
550 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
551 array_push ( $this->rc_cache
[$secureName] , $rc ) ;