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_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
109 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
110 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
113 if ($rcObj->numberofWatchingusers
> 0) {
114 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers
));
124 function recentChangesBlockGroup ( $block ) {
125 global $wgStylePath, $wgContLang ;
128 $M = wfMsg( 'minoreditletter' );
129 $N = wfMsg( 'newpageletter' );
131 # Collate list of users
133 $unpatrolled = false;
134 $userlinks = array () ;
135 foreach ( $block AS $rcObj ) {
136 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
137 if ( $rcObj->mAttribs
['rc_new'] ) {
140 $u = $rcObj->userlink
;
141 if ( !isset ( $userlinks[$u] ) ) {
144 if ( $rcObj->unpatrolled
) {
150 # Sort the list and convert to text
151 krsort ( $userlinks ) ;
152 asort ( $userlinks ) ;
154 foreach ( $userlinks as $userlink => $count) {
156 if ( $count > 1 ) $text .= " ({$count}×)" ;
157 array_push ( $users , $text ) ;
159 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
162 $rci = 'RCI'.$this->rcCacheIndex
;
163 $rcl = 'RCL'.$this->rcCacheIndex
;
164 $rcm = 'RCM'.$this->rcCacheIndex
;
165 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
166 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
167 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
168 $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>' ;
175 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
179 $r .= ' '; # Minor
180 if ( $unpatrolled ) {
181 $r .= '<span class="unpatrolled">!</span>';
187 $r .= ' '.$block[0]->timestamp
.' ' ;
191 $link = $block[0]->link
;
192 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
195 if ($block[0]->notificationtimestamp
) {
196 $r .= wfMsg( 'updatedmarker' );
199 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
200 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
202 $r .= ' ('.count($block).' ' ;
203 if ( $isnew ) $r .= wfMsg('changes');
204 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
205 $curIdEq.'&diff=0&oldid='.$oldid ) ;
209 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
215 if ($block[0]->numberofWatchingusers
> 0) {
216 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
221 $r .= '<div id="'.$rci.'" style="display:none">' ;
222 foreach ( $block AS $rcObj ) {
223 # Get rc_xxxx variables
224 extract( $rcObj->mAttribs
);
226 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
227 $r .= '<tt> ' ;
229 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
235 $r .= '<span class="minoredit">' . htmlspecialchars( $M ) . '</span>';
240 if ( $rcObj->unpatrolled
) {
241 $r .= '<span class="unpatrolled">!</span>';
246 $r .= ' </tt>' ;
249 if ( $rc_last_oldid != 0 ) {
250 $o = 'oldid='.$rc_last_oldid ;
252 if ( $rc_type == RC_LOG
) {
253 $link = $rcObj->timestamp
;
255 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
257 $link = '<tt>'.$link.'</tt>' ;
261 $r .= $rcObj->curlink
;
263 $r .= $rcObj->lastlink
;
264 $r .= ') . . '.$rcObj->userlink
;
265 $r .= $rcObj->usertalklink
;
266 if ( $rc_comment != '' ) {
267 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
268 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
274 $this->rcCacheIndex++
;
279 * If enhanced RC is in use, this function takes the previously cached
280 * RC lines, arranges them, and outputs the HTML
282 function recentChangesBlock () {
283 global $wgStylePath ;
284 if ( count ( $this->rc_cache
) == 0 ) return '' ;
286 foreach ( $this->rc_cache
AS $secureName => $block ) {
287 if ( count ( $block ) < 2 ) {
288 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
290 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
294 return '<div>'.$blockOut.'</div>' ;
298 * Called in a loop over all displayed RC entries
299 * Either returns the line, or caches it for later use
301 function recentChangesLine( &$rc, $watched = false ) {
303 $usenew = $wgUser->getOption( 'usenewrc' );
305 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
307 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
312 function recentChangesLineOld( &$rc, $watched = false ) {
313 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol,
314 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
316 $fname = 'Skin::recentChangesLineOld';
317 wfProfileIn( $fname );
320 if( !isset( $message ) ) {
321 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
322 $message[$msg] = wfMsg( $msg );
326 # Extract DB fields into local scope
327 extract( $rc->mAttribs
);
328 $curIdEq = 'curid=' . $rc_cur_id;
330 # Should patrol-related stuff be shown?
331 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
332 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
334 # Make date header if necessary
335 $date = $wgLang->date( $rc_timestamp, true);
337 if ( $date != $this->lastdate
) {
338 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
339 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
340 $this->lastdate
= $date;
341 $this->rclistOpen
= true;
346 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
348 $s .= '(' . $message['diff'] . ') (';
350 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
353 # "[[x]] moved to [[y]]"
354 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
355 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
356 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
357 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
359 $logtype = $matches[1];
360 $logname = LogPage
::logName( $logtype );
361 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
363 wfProfileIn("$fname-page");
365 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
366 $diffLink = $message['diff'];
369 $rcidparam = "&rcid={$rc_id}";
372 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
373 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
374 '', '', ' tabindex="'.$rc->counter
.'"');
376 $s .= '('.$diffLink.') (';
379 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
382 # M, N and ! (minor, new and unpatrolled)
383 if ( $rc_minor ) { $s .= ' <span class="minor">'.htmlspecialchars( $message["minoreditletter"] ).'</span>'; }
384 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.htmlspecialchars( $message["newpageletter"] ).'</span>'; }
385 if ( $unpatrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
388 # If it's a new article, there is no diff link, but if it hasn't been
389 # patrolled yet, we need to give users a way to do so
390 if ( $unpatrolled && $rc_type == RC_NEW
)
391 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
393 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
396 $articleLink = '<strong>'.$articleLink.'</strong>';
399 if ($rc->notificationtimestamp
) {
400 $articleLink .= wfMsg( 'updatedmarker' );
403 $s .= ' '.$articleLink;
404 wfProfileOut("$fname-page");
407 wfProfileIn( "$fname-rest" );
409 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
411 # User link (or contributions for unregistered users)
412 if ( 0 == $rc_user ) {
413 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
414 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
415 $rc_user_text, 'target=' . $rc_user_text );
417 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
418 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
423 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
424 global $wgDisableAnonTalk;
425 if( 0 == $rc_user && $wgDisableAnonTalk ) {
428 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
429 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
433 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
434 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
435 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
436 $message['blocklink'], 'ip='.$rc_user_text );
440 if($userTalkLink) $userTalkLink .= ' | ';
441 $userTalkLink .= $blockLink;
443 if($userTalkLink) $s.=' ('.$userTalkLink.')';
446 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
447 $rc_comment = $this->skin
->formatComment($rc_comment,$rc->getTitle());
448 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
451 if ($rc->numberofWatchingusers
> 0) {
452 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
457 wfProfileOut( "$fname-rest" );
458 wfProfileOut( $fname );
462 function recentChangesLineNew( &$baseRC, $watched = false ) {
463 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds,
464 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
467 if( !isset( $message ) ) {
468 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
469 $message[$msg] = wfMsg( $msg );
473 # Create a specialised object
474 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
476 # Extract fields from DB into the function scope (rc_xxxx variables)
477 extract( $rc->mAttribs
);
478 $curIdEq = 'curid=' . $rc_cur_id;
480 # If it's a new day, add the headline and flush the cache
481 $date = $wgLang->date( $rc_timestamp, true);
483 if ( $date != $this->lastdate
) {
484 # Process current cache
485 $ret = $this->recentChangesBlock () ;
486 $this->rc_cache
= array() ;
487 $ret .= "<h4>{$date}</h4>\n";
488 $this->lastdate
= $date;
491 # Should patrol-related stuff be shown?
492 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
493 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
494 $rc->unpatrolled
= !$rc_patrolled;
496 $rc->unpatrolled
= false;
500 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
501 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
502 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
503 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
504 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
506 $logtype = $matches[1];
507 $logname = LogPage
::logName( $logtype );
508 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
509 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
510 # Unpatrolled new page, give rc_id in query
511 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
513 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
516 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
517 $rc->watched
= $watched ;
519 $rc->timestamp
= $time;
520 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
521 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
523 # Make "cur" and "diff" links
524 $titleObj = $rc->getTitle();
525 if ( $rc->unpatrolled
) {
526 $rcIdQuery = "&rcid={$rc_id}";
530 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
531 $curLink = $message['cur'];
532 $diffLink = $message['diff'];
534 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
535 $aprops = ' tabindex="'.$baseRC->counter
.'"';
536 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
537 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
541 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
542 $lastLink = $message['last'];
544 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
545 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
548 # Make user link (or user contributions for unregistered users)
549 if ( $rc_user == 0 ) {
550 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
551 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
552 $rc_user_text, 'target=' . $rc_user_text );
554 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
555 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
558 $rc->userlink
= $userLink;
559 $rc->lastlink
= $lastLink;
560 $rc->curlink
= $curLink;
561 $rc->difflink
= $diffLink;
563 # Make user talk link
564 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
565 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
566 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
568 global $wgDisableAnonTalk;
569 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
570 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
571 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
572 $message['blocklink'], 'ip='.$rc_user_text );
573 if( $wgDisableAnonTalk )
574 $rc->usertalklink
= ' ('.$blockLink.')';
576 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
578 if( $wgDisableAnonTalk && ($rc_user == 0) )
579 $rc->usertalklink
= '';
581 $rc->usertalklink
= ' ('.$userTalkLink.')';
584 # Put accumulated information into the cache, for later display
585 # Page moves go on their own line
586 $title = $rc->getTitle();
587 $secureName = $title->getPrefixedDBkey();
588 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
589 # Use an @ character to prevent collision with page names
590 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
592 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
593 array_push ( $this->rc_cache
[$secureName] , $rc ) ;