10 # Called by history lists and recent changes
14 function ChangesList( &$skin ) {
19 * Returns text for the start of the tabular part of RC
21 function beginRecentChangesList() {
22 $this->rc_cache
= array() ;
23 $this->rcMoveIndex
= 0;
24 $this->rcCacheIndex
= 0 ;
26 $this->rclistOpen
= false;
31 * Returns text for the end of RC
32 * If enhanced RC is in use, returns pretty much all the text
34 function endRecentChangesList() {
35 $s = $this->recentChangesBlock() ;
36 if( $this->rclistOpen
) {
43 * Enhanced RC ungrouped line
45 function recentChangesBlockLine ( $rcObj ) {
46 global $wgStylePath, $wgContLang ;
48 # Get rc_xxxx variables
49 extract( $rcObj->mAttribs
) ;
50 $curIdEq = 'curid='.$rc_cur_id;
55 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
58 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
59 $r .= ' ';
62 $M = wfMsg( 'minoreditletter' );
63 $N = wfMsg( 'newpageletter' );
65 if ( $rc_type == RC_NEW
) {
66 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
71 $r .= '<span class="minor">' . htmlspecialchars( $M ) . '</span>';
75 if ( $rcObj->unpatrolled
) {
76 $r .= '<span class="unpatrolled">!</span>';
83 $r .= ' '.$rcObj->timestamp
.' ' ;
87 $link = $rcObj->link
;
88 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
91 if ($rcObj->notificationtimestamp
) {
92 $r .= wfMsg( 'updatedmarker' );
97 $r .= $rcObj->difflink
;
101 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
104 $r .= ') . . '.$rcObj->userlink
;
105 $r .= $rcObj->usertalklink
;
108 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
109 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
112 if ($rcObj->numberofWatchingusers
> 0) {
113 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers
));
123 function recentChangesBlockGroup ( $block ) {
124 global $wgStylePath, $wgContLang ;
127 $M = wfMsg( 'minoreditletter' );
128 $N = wfMsg( 'newpageletter' );
130 # Collate list of users
132 $unpatrolled = false;
133 $userlinks = array () ;
134 foreach ( $block AS $rcObj ) {
135 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
136 if ( $rcObj->mAttribs
['rc_new'] ) {
139 $u = $rcObj->userlink
;
140 if ( !isset ( $userlinks[$u] ) ) {
143 if ( $rcObj->unpatrolled
) {
149 # Sort the list and convert to text
150 krsort ( $userlinks ) ;
151 asort ( $userlinks ) ;
153 foreach ( $userlinks as $userlink => $count) {
155 if ( $count > 1 ) $text .= " ({$count}×)" ;
156 array_push ( $users , $text ) ;
158 $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
161 $rci = 'RCI'.$this->rcCacheIndex
;
162 $rcl = 'RCL'.$this->rcCacheIndex
;
163 $rcm = 'RCM'.$this->rcCacheIndex
;
164 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
165 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
166 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
167 $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>' ;
174 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
178 $r .= ' '; # Minor
179 if ( $unpatrolled ) {
180 $r .= '<span class="unpatrolled">!</span>';
186 $r .= ' '.$block[0]->timestamp
.' ' ;
190 $link = $block[0]->link
;
191 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
194 if ($block[0]->notificationtimestamp
) {
195 $r .= wfMsg( 'updatedmarker' );
198 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
199 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
201 $r .= ' ('.count($block).' ' ;
202 if ( $isnew ) $r .= wfMsg('changes');
203 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
204 $curIdEq.'&diff=0&oldid='.$oldid ) ;
208 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
214 if ($block[0]->numberofWatchingusers
> 0) {
215 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
220 $r .= '<div id="'.$rci.'" style="display:none">' ;
221 foreach ( $block AS $rcObj ) {
222 # Get rc_xxxx variables
223 extract( $rcObj->mAttribs
);
225 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
226 $r .= '<tt> ' ;
228 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
234 $r .= '<span class="minoredit">' . htmlspecialchars( $M ) . '</span>';
239 if ( $rcObj->unpatrolled
) {
240 $r .= '<span class="unpatrolled">!</span>';
245 $r .= ' </tt>' ;
248 if ( $rc_last_oldid != 0 ) {
249 $o = 'oldid='.$rc_last_oldid ;
251 if ( $rc_type == RC_LOG
) {
252 $link = $rcObj->timestamp
;
254 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
256 $link = '<tt>'.$link.'</tt>' ;
260 $r .= $rcObj->curlink
;
262 $r .= $rcObj->lastlink
;
263 $r .= ') . . '.$rcObj->userlink
;
264 $r .= $rcObj->usertalklink
;
265 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
270 $this->rcCacheIndex++
;
275 * If enhanced RC is in use, this function takes the previously cached
276 * RC lines, arranges them, and outputs the HTML
278 function recentChangesBlock () {
279 global $wgStylePath ;
280 if ( count ( $this->rc_cache
) == 0 ) return '' ;
282 foreach ( $this->rc_cache
AS $secureName => $block ) {
283 if ( count ( $block ) < 2 ) {
284 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
286 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
290 return '<div>'.$blockOut.'</div>' ;
294 * Called in a loop over all displayed RC entries
295 * Either returns the line, or caches it for later use
297 function recentChangesLine( &$rc, $watched = false ) {
299 $usenew = $wgUser->getOption( 'usenewrc' );
301 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
303 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
308 function recentChangesLineOld( &$rc, $watched = false ) {
309 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol,
310 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
312 $fname = 'Skin::recentChangesLineOld';
313 wfProfileIn( $fname );
316 if( !isset( $message ) ) {
317 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
318 $message[$msg] = wfMsg( $msg );
322 # Extract DB fields into local scope
323 extract( $rc->mAttribs
);
324 $curIdEq = 'curid=' . $rc_cur_id;
326 # Should patrol-related stuff be shown?
327 $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() &&
328 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
330 # Make date header if necessary
331 $date = $wgLang->date( $rc_timestamp, true);
333 if ( $date != $this->lastdate
) {
334 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
335 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
336 $this->lastdate
= $date;
337 $this->rclistOpen
= true;
342 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
344 $s .= '(' . $message['diff'] . ') (';
346 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
349 # "[[x]] moved to [[y]]"
350 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
351 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
352 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
353 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
355 $logtype = $matches[1];
356 $logname = LogPage
::logName( $logtype );
357 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
359 wfProfileIn("$fname-page");
361 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
362 $diffLink = $message['diff'];
365 $rcidparam = "&rcid={$rc_id}";
368 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
369 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
370 '', '', ' tabindex="'.$rc->counter
.'"');
372 $s .= '('.$diffLink.') (';
375 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
378 # M, N and ! (minor, new and unpatrolled)
379 if ( $rc_minor ) { $s .= ' <span class="minor">'.htmlspecialchars( $message["minoreditletter"] ).'</span>'; }
380 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.htmlspecialchars( $message["newpageletter"] ).'</span>'; }
381 if ( $unpatrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
384 # If it's a new article, there is no diff link, but if it hasn't been
385 # patrolled yet, we need to give users a way to do so
386 if ( $unpatrolled && $rc_type == RC_NEW
)
387 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
389 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
392 $articleLink = '<strong>'.$articleLink.'</strong>';
395 if ($rc->notificationtimestamp
) {
396 $articleLink .= wfMsg( 'updatedmarker' );
399 $s .= ' '.$articleLink;
400 wfProfileOut("$fname-page");
403 wfProfileIn( "$fname-rest" );
405 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
407 # User link (or contributions for unregistered users)
408 if ( 0 == $rc_user ) {
409 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
410 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
411 $rc_user_text, 'target=' . $rc_user_text );
413 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
414 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
419 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
420 global $wgDisableAnonTalk;
421 if( 0 == $rc_user && $wgDisableAnonTalk ) {
424 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
425 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
429 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
430 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
431 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
432 $message['blocklink'], 'ip='.$rc_user_text );
436 if($userTalkLink) $userTalkLink .= ' | ';
437 $userTalkLink .= $blockLink;
439 if($userTalkLink) $s.=' ('.$userTalkLink.')';
442 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
443 $s .= $this->skin
->commentBlock( $rc_comment, $rc->getTitle() );
446 if ($rc->numberofWatchingusers
> 0) {
447 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
452 wfProfileOut( "$fname-rest" );
453 wfProfileOut( $fname );
457 function recentChangesLineNew( &$baseRC, $watched = false ) {
458 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds,
459 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
462 if( !isset( $message ) ) {
463 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
464 $message[$msg] = wfMsg( $msg );
468 # Create a specialised object
469 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
471 # Extract fields from DB into the function scope (rc_xxxx variables)
472 extract( $rc->mAttribs
);
473 $curIdEq = 'curid=' . $rc_cur_id;
475 # If it's a new day, add the headline and flush the cache
476 $date = $wgLang->date( $rc_timestamp, true);
478 if ( $date != $this->lastdate
) {
479 # Process current cache
480 $ret = $this->recentChangesBlock () ;
481 $this->rc_cache
= array() ;
482 $ret .= "<h4>{$date}</h4>\n";
483 $this->lastdate
= $date;
486 # Should patrol-related stuff be shown?
487 if ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
488 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
489 $rc->unpatrolled
= !$rc_patrolled;
491 $rc->unpatrolled
= false;
495 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
496 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
497 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
498 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
499 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
501 $logtype = $matches[1];
502 $logname = LogPage
::logName( $logtype );
503 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
504 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
505 # Unpatrolled new page, give rc_id in query
506 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
508 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
511 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
512 $rc->watched
= $watched ;
514 $rc->timestamp
= $time;
515 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
516 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
518 # Make "cur" and "diff" links
519 $titleObj = $rc->getTitle();
520 if ( $rc->unpatrolled
) {
521 $rcIdQuery = "&rcid={$rc_id}";
525 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
526 $curLink = $message['cur'];
527 $diffLink = $message['diff'];
529 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
530 $aprops = ' tabindex="'.$baseRC->counter
.'"';
531 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
532 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
536 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
537 $lastLink = $message['last'];
539 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
540 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
543 # Make user link (or user contributions for unregistered users)
544 if ( $rc_user == 0 ) {
545 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
546 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
547 $rc_user_text, 'target=' . $rc_user_text );
549 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
550 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
553 $rc->userlink
= $userLink;
554 $rc->lastlink
= $lastLink;
555 $rc->curlink
= $curLink;
556 $rc->difflink
= $diffLink;
558 # Make user talk link
559 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
560 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
561 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
563 global $wgDisableAnonTalk;
564 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
565 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
566 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
567 $message['blocklink'], 'ip='.$rc_user_text );
568 if( $wgDisableAnonTalk )
569 $rc->usertalklink
= ' ('.$blockLink.')';
571 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
573 if( $wgDisableAnonTalk && ($rc_user == 0) )
574 $rc->usertalklink
= '';
576 $rc->usertalklink
= ' ('.$userTalkLink.')';
579 # Put accumulated information into the cache, for later display
580 # Page moves go on their own line
581 $title = $rc->getTitle();
582 $secureName = $title->getPrefixedDBkey();
583 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
584 # Use an @ character to prevent collision with page names
585 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
587 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
588 array_push ( $this->rc_cache
[$secureName] , $rc ) ;