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>' ;
82 if ($rcObj->notificationtimestamp
) {
83 $r .= wfMsg( 'updatedmarker' );
88 $r .= $rcObj->difflink
;
92 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
95 $r .= ') . . '.$rcObj->userlink
;
96 $r .= $rcObj->usertalklink
;
99 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
100 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
101 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
104 if ($rcObj->numberofWatchingusers
> 0) {
105 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers
));
115 function recentChangesBlockGroup ( $block ) {
116 global $wgStylePath, $wgContLang ;
119 $M = wfMsg( 'minoreditletter' );
120 $N = wfMsg( 'newpageletter' );
122 # Collate list of users
124 $unpatrolled = false;
125 $userlinks = array () ;
126 foreach ( $block AS $rcObj ) {
127 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
128 if ( $rcObj->mAttribs
['rc_new'] ) {
131 $u = $rcObj->userlink
;
132 if ( !isset ( $userlinks[$u] ) ) {
135 if ( $rcObj->unpatrolled
) {
141 # Sort the list and convert to text
142 krsort ( $userlinks ) ;
143 asort ( $userlinks ) ;
145 foreach ( $userlinks as $userlink => $count) {
147 if ( $count > 1 ) $text .= " ({$count}×)" ;
148 array_push ( $users , $text ) ;
150 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
153 $rci = 'RCI'.$this->rcCacheIndex
;
154 $rcl = 'RCL'.$this->rcCacheIndex
;
155 $rcm = 'RCM'.$this->rcCacheIndex
;
156 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
157 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
158 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
159 $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>' ;
165 if ( $isnew ) $r .= $N ;
166 else $r .= ' ' ;
167 $r .= ' ' ; # Minor
168 if ( $unpatrolled ) {
175 $r .= ' '.$block[0]->timestamp
.' ' ;
179 $link = $block[0]->link
;
180 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
183 if ($block[0]->notificationtimestamp
) {
184 $r .= wfMsg( 'updatedmarker' );
187 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
188 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
190 $r .= ' ('.count($block).' ' ;
191 if ( $isnew ) $r .= wfMsg('changes');
192 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
193 $curIdEq.'&diff=0&oldid='.$oldid ) ;
197 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
203 if ($block[0]->numberofWatchingusers
> 0) {
204 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
209 $r .= '<div id="'.$rci.'" style="display:none">' ;
210 foreach ( $block AS $rcObj ) {
211 # Get rc_xxxx variables
212 extract( $rcObj->mAttribs
);
214 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
215 $r .= '<tt> ' ;
228 if ( $rcObj->unpatrolled
) {
234 $r .= ' </tt>' ;
237 if ( $rc_last_oldid != 0 ) {
238 $o = 'oldid='.$rc_last_oldid ;
240 if ( $rc_type == RC_LOG
) {
241 $link = $rcObj->timestamp
;
243 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
245 $link = '<tt>'.$link.'</tt>' ;
249 $r .= $rcObj->curlink
;
251 $r .= $rcObj->lastlink
;
252 $r .= ') . . '.$rcObj->userlink
;
253 $r .= $rcObj->usertalklink
;
254 if ( $rc_comment != '' ) {
255 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
256 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
262 $this->rcCacheIndex++
;
267 * If enhanced RC is in use, this function takes the previously cached
268 * RC lines, arranges them, and outputs the HTML
270 function recentChangesBlock () {
271 global $wgStylePath ;
272 if ( count ( $this->rc_cache
) == 0 ) return '' ;
274 foreach ( $this->rc_cache
AS $secureName => $block ) {
275 if ( count ( $block ) < 2 ) {
276 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
278 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
282 return '<div>'.$blockOut.'</div>' ;
286 * Called in a loop over all displayed RC entries
287 * Either returns the line, or caches it for later use
289 function recentChangesLine( &$rc, $watched = false ) {
291 $usenew = $wgUser->getOption( 'usenewrc' );
293 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
295 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
300 function recentChangesLineOld( &$rc, $watched = false ) {
301 $fname = 'Skin::recentChangesLineOld';
302 wfProfileIn( $fname );
304 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
307 if( !isset( $message ) ) {
308 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
309 $message[$msg] = wfMsg( $msg );
313 # Extract DB fields into local scope
314 extract( $rc->mAttribs
);
315 $curIdEq = 'curid=' . $rc_cur_id;
317 # Should patrol-related stuff be shown?
318 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
319 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
321 # Make date header if necessary
322 $date = $wgLang->date( $rc_timestamp, true);
324 if ( $date != $this->lastdate
) {
325 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
326 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
327 $this->lastdate
= $date;
328 $this->rclistOpen
= true;
333 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
335 $s .= '(' . $message['diff'] . ') (';
337 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
340 # "[[x]] moved to [[y]]"
341 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
342 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
343 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
344 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
346 $logtype = $matches[1];
347 $logname = LogPage
::logName( $logtype );
348 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
350 wfProfileIn("$fname-page");
352 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
353 $diffLink = $message['diff'];
356 $rcidparam = "&rcid={$rc_id}";
359 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
360 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
361 '', '', ' tabindex="'.$rc->counter
.'"');
363 $s .= '('.$diffLink.') (';
366 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
369 # M, N and ! (minor, new and unpatrolled)
370 if ( $rc_minor ) { $s .= ' <span class="minoreditletter">'.$message["minoreditletter"].'</span>'; }
371 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpageletter">'.$message["newpageletter"].'</span>'; }
372 if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
375 # If it's a new article, there is no diff link, but if it hasn't been
376 # patrolled yet, we need to give users a way to do so
377 if ( $unpatrolled && $rc_type == RC_NEW
)
378 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
380 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
383 $articleLink = '<strong>'.$articleLink.'</strong>';
386 if ($rc->notificationtimestamp
) {
387 $articleLink .= wfMsg( 'updatedmarker' );
390 $s .= ' '.$articleLink;
391 wfProfileOut("$fname-page");
394 wfProfileIn( "$fname-rest" );
396 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
398 # User link (or contributions for unregistered users)
399 if ( 0 == $rc_user ) {
400 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
401 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
402 $rc_user_text, 'target=' . $rc_user_text );
404 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
405 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
410 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
411 global $wgDisableAnonTalk;
412 if( 0 == $rc_user && $wgDisableAnonTalk ) {
415 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
416 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
420 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
421 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
422 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
423 $message['blocklink'], 'ip='.$rc_user_text );
427 if($userTalkLink) $userTalkLink .= ' | ';
428 $userTalkLink .= $blockLink;
430 if($userTalkLink) $s.=' ('.$userTalkLink.')';
433 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
434 $rc_comment = $this->skin
->formatComment($rc_comment,$rc->getTitle());
435 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
438 if ($rc->numberofWatchingusers
> 0) {
439 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
444 wfProfileOut( "$fname-rest" );
445 wfProfileOut( $fname );
449 function recentChangesLineNew( &$baseRC, $watched = false ) {
450 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
451 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
454 if( !isset( $message ) ) {
455 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
456 $message[$msg] = wfMsg( $msg );
460 # Create a specialised object
461 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
463 # Extract fields from DB into the function scope (rc_xxxx variables)
464 extract( $rc->mAttribs
);
465 $curIdEq = 'curid=' . $rc_cur_id;
467 # If it's a new day, add the headline and flush the cache
468 $date = $wgLang->date( $rc_timestamp, true);
470 if ( $date != $this->lastdate
) {
471 # Process current cache
472 $ret = $this->recentChangesBlock () ;
473 $this->rc_cache
= array() ;
474 $ret .= "<h4>{$date}</h4>\n";
475 $this->lastdate
= $date;
478 # Should patrol-related stuff be shown?
479 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
480 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
481 $rc->unpatrolled
= !$rc_patrolled;
483 $rc->unpatrolled
= false;
487 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
488 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
489 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
490 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
491 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
493 $logtype = $matches[1];
494 $logname = LogPage
::logName( $logtype );
495 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
496 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
497 # Unpatrolled new page, give rc_id in query
498 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
500 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
503 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
504 $rc->watched
= $watched ;
506 $rc->timestamp
= $time;
507 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
508 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
510 # Make "cur" and "diff" links
511 $titleObj = $rc->getTitle();
512 if ( $rc->unpatrolled
) {
513 $rcIdQuery = "&rcid={$rc_id}";
517 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
518 $curLink = $message['cur'];
519 $diffLink = $message['diff'];
521 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
522 $aprops = ' tabindex="'.$baseRC->counter
.'"';
523 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
524 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
528 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
529 $lastLink = $message['last'];
531 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
532 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
535 # Make user link (or user contributions for unregistered users)
536 if ( $rc_user == 0 ) {
537 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
538 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
539 $rc_user_text, 'target=' . $rc_user_text );
541 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
542 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
545 $rc->userlink
= $userLink;
546 $rc->lastlink
= $lastLink;
547 $rc->curlink
= $curLink;
548 $rc->difflink
= $diffLink;
550 # Make user talk link
551 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
552 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
553 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
555 global $wgDisableAnonTalk;
556 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
557 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
558 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
559 $message['blocklink'], 'ip='.$rc_user_text );
560 if( $wgDisableAnonTalk )
561 $rc->usertalklink
= ' ('.$blockLink.')';
563 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
565 if( $wgDisableAnonTalk && ($rc_user == 0) )
566 $rc->usertalklink
= '';
568 $rc->usertalklink
= ' ('.$userTalkLink.')';
571 # Put accumulated information into the cache, for later display
572 # Page moves go on their own line
573 $title = $rc->getTitle();
574 $secureName = $title->getPrefixedDBkey();
575 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
576 # Use an @ character to prevent collision with page names
577 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
579 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
580 array_push ( $this->rc_cache
[$secureName] , $rc ) ;