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
) {
50 $r .= ' ';
53 $M = wfMsg( 'minoreditletter' );
54 $N = wfMsg( 'newpageletter' );
56 if ( $rc_type == RC_NEW
) {
57 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
62 $r .= '<span class="minor">' . htmlspecialchars( $M ) . '</span>';
66 if ( $rcObj->unpatrolled
) {
67 $r .= '<span class="unpatrolled">!</span>';
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>' ;
166 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
170 $r .= ' '; # Minor
171 if ( $unpatrolled ) {
172 $r .= '<span class="unpatrolled">!</span>';
178 $r .= ' '.$block[0]->timestamp
.' ' ;
182 $link = $block[0]->link
;
183 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
186 if ($block[0]->notificationtimestamp
) {
187 $r .= wfMsg( 'updatedmarker' );
190 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
191 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
193 $r .= ' ('.count($block).' ' ;
194 if ( $isnew ) $r .= wfMsg('changes');
195 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
196 $curIdEq.'&diff=0&oldid='.$oldid ) ;
200 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
206 if ($block[0]->numberofWatchingusers
> 0) {
207 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
212 $r .= '<div id="'.$rci.'" style="display:none">' ;
213 foreach ( $block AS $rcObj ) {
214 # Get rc_xxxx variables
215 extract( $rcObj->mAttribs
);
217 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
218 $r .= '<tt> ' ;
220 $r .= '<span class="newpage">' . htmlspecialchars( $N ) . '</span>';
226 $r .= '<span class="minoredit">' . htmlspecialchars( $M ) . '</span>';
231 if ( $rcObj->unpatrolled
) {
232 $r .= '<span class="unpatrolled">!</span>';
237 $r .= ' </tt>' ;
240 if ( $rc_last_oldid != 0 ) {
241 $o = 'oldid='.$rc_last_oldid ;
243 if ( $rc_type == RC_LOG
) {
244 $link = $rcObj->timestamp
;
246 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
248 $link = '<tt>'.$link.'</tt>' ;
252 $r .= $rcObj->curlink
;
254 $r .= $rcObj->lastlink
;
255 $r .= ') . . '.$rcObj->userlink
;
256 $r .= $rcObj->usertalklink
;
257 if ( $rc_comment != '' ) {
258 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
259 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
265 $this->rcCacheIndex++
;
270 * If enhanced RC is in use, this function takes the previously cached
271 * RC lines, arranges them, and outputs the HTML
273 function recentChangesBlock () {
274 global $wgStylePath ;
275 if ( count ( $this->rc_cache
) == 0 ) return '' ;
277 foreach ( $this->rc_cache
AS $secureName => $block ) {
278 if ( count ( $block ) < 2 ) {
279 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
281 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
285 return '<div>'.$blockOut.'</div>' ;
289 * Called in a loop over all displayed RC entries
290 * Either returns the line, or caches it for later use
292 function recentChangesLine( &$rc, $watched = false ) {
294 $usenew = $wgUser->getOption( 'usenewrc' );
296 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
298 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
303 function recentChangesLineOld( &$rc, $watched = false ) {
304 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol,
305 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
307 $fname = 'Skin::recentChangesLineOld';
308 wfProfileIn( $fname );
311 if( !isset( $message ) ) {
312 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
313 $message[$msg] = wfMsg( $msg );
317 # Extract DB fields into local scope
318 extract( $rc->mAttribs
);
319 $curIdEq = 'curid=' . $rc_cur_id;
321 # Should patrol-related stuff be shown?
322 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
323 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
325 # Make date header if necessary
326 $date = $wgLang->date( $rc_timestamp, true);
328 if ( $date != $this->lastdate
) {
329 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
330 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
331 $this->lastdate
= $date;
332 $this->rclistOpen
= true;
337 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
339 $s .= '(' . $message['diff'] . ') (';
341 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
344 # "[[x]] moved to [[y]]"
345 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
346 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
347 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
348 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
350 $logtype = $matches[1];
351 $logname = LogPage
::logName( $logtype );
352 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
354 wfProfileIn("$fname-page");
356 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
357 $diffLink = $message['diff'];
360 $rcidparam = "&rcid={$rc_id}";
363 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
364 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
365 '', '', ' tabindex="'.$rc->counter
.'"');
367 $s .= '('.$diffLink.') (';
370 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
373 # M, N and ! (minor, new and unpatrolled)
374 if ( $rc_minor ) { $s .= ' <span class="minor">'.htmlspecialchars( $message["minoreditletter"] ).'</span>'; }
375 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.htmlspecialchars( $message["newpageletter"] ).'</span>'; }
376 if ( $unpatrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
379 # If it's a new article, there is no diff link, but if it hasn't been
380 # patrolled yet, we need to give users a way to do so
381 if ( $unpatrolled && $rc_type == RC_NEW
)
382 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
384 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
387 $articleLink = '<strong>'.$articleLink.'</strong>';
390 if ($rc->notificationtimestamp
) {
391 $articleLink .= wfMsg( 'updatedmarker' );
394 $s .= ' '.$articleLink;
395 wfProfileOut("$fname-page");
398 wfProfileIn( "$fname-rest" );
400 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
402 # User link (or contributions for unregistered users)
403 if ( 0 == $rc_user ) {
404 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
405 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
406 $rc_user_text, 'target=' . $rc_user_text );
408 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
409 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
414 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
415 global $wgDisableAnonTalk;
416 if( 0 == $rc_user && $wgDisableAnonTalk ) {
419 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
420 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
424 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
425 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
426 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
427 $message['blocklink'], 'ip='.$rc_user_text );
431 if($userTalkLink) $userTalkLink .= ' | ';
432 $userTalkLink .= $blockLink;
434 if($userTalkLink) $s.=' ('.$userTalkLink.')';
437 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
438 $rc_comment = $this->skin
->formatComment($rc_comment,$rc->getTitle());
439 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
442 if ($rc->numberofWatchingusers
> 0) {
443 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
448 wfProfileOut( "$fname-rest" );
449 wfProfileOut( $fname );
453 function recentChangesLineNew( &$baseRC, $watched = false ) {
454 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds,
455 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
458 if( !isset( $message ) ) {
459 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
460 $message[$msg] = wfMsg( $msg );
464 # Create a specialised object
465 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
467 # Extract fields from DB into the function scope (rc_xxxx variables)
468 extract( $rc->mAttribs
);
469 $curIdEq = 'curid=' . $rc_cur_id;
471 # If it's a new day, add the headline and flush the cache
472 $date = $wgLang->date( $rc_timestamp, true);
474 if ( $date != $this->lastdate
) {
475 # Process current cache
476 $ret = $this->recentChangesBlock () ;
477 $this->rc_cache
= array() ;
478 $ret .= "<h4>{$date}</h4>\n";
479 $this->lastdate
= $date;
482 # Should patrol-related stuff be shown?
483 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
484 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
485 $rc->unpatrolled
= !$rc_patrolled;
487 $rc->unpatrolled
= false;
491 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
492 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
493 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
494 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
495 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
497 $logtype = $matches[1];
498 $logname = LogPage
::logName( $logtype );
499 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
500 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
501 # Unpatrolled new page, give rc_id in query
502 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
504 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
507 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
508 $rc->watched
= $watched ;
510 $rc->timestamp
= $time;
511 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
512 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
514 # Make "cur" and "diff" links
515 $titleObj = $rc->getTitle();
516 if ( $rc->unpatrolled
) {
517 $rcIdQuery = "&rcid={$rc_id}";
521 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
522 $curLink = $message['cur'];
523 $diffLink = $message['diff'];
525 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
526 $aprops = ' tabindex="'.$baseRC->counter
.'"';
527 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
528 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
532 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
533 $lastLink = $message['last'];
535 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
536 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
539 # Make user link (or user contributions for unregistered users)
540 if ( $rc_user == 0 ) {
541 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
542 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
543 $rc_user_text, 'target=' . $rc_user_text );
545 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
546 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
549 $rc->userlink
= $userLink;
550 $rc->lastlink
= $lastLink;
551 $rc->curlink
= $curLink;
552 $rc->difflink
= $diffLink;
554 # Make user talk link
555 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
556 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
557 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
559 global $wgDisableAnonTalk;
560 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
561 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
562 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
563 $message['blocklink'], 'ip='.$rc_user_text );
564 if( $wgDisableAnonTalk )
565 $rc->usertalklink
= ' ('.$blockLink.')';
567 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
569 if( $wgDisableAnonTalk && ($rc_user == 0) )
570 $rc->usertalklink
= '';
572 $rc->usertalklink
= ' ('.$userTalkLink.')';
575 # Put accumulated information into the cache, for later display
576 # Page moves go on their own line
577 $title = $rc->getTitle();
578 $secureName = $title->getPrefixedDBkey();
579 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
580 # Use an @ character to prevent collision with page names
581 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
583 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
584 array_push ( $this->rc_cache
[$secureName] , $rc ) ;