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
) {
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 $fname = 'Skin::recentChangesLineOld';
305 wfProfileIn( $fname );
307 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
310 if( !isset( $message ) ) {
311 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
312 $message[$msg] = wfMsg( $msg );
316 # Extract DB fields into local scope
317 extract( $rc->mAttribs
);
318 $curIdEq = 'curid=' . $rc_cur_id;
320 # Should patrol-related stuff be shown?
321 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
322 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
324 # Make date header if necessary
325 $date = $wgLang->date( $rc_timestamp, true);
327 if ( $date != $this->lastdate
) {
328 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
329 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
330 $this->lastdate
= $date;
331 $this->rclistOpen
= true;
336 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
338 $s .= '(' . $message['diff'] . ') (';
340 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
343 # "[[x]] moved to [[y]]"
344 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
345 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
346 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
347 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
349 $logtype = $matches[1];
350 $logname = LogPage
::logName( $logtype );
351 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
353 wfProfileIn("$fname-page");
355 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
356 $diffLink = $message['diff'];
359 $rcidparam = "&rcid={$rc_id}";
362 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
363 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
364 '', '', ' tabindex="'.$rc->counter
.'"');
366 $s .= '('.$diffLink.') (';
369 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
372 # M, N and ! (minor, new and unpatrolled)
373 if ( $rc_minor ) { $s .= ' <span class="minor">'.htmlspecialchars( $message["minoreditletter"] ).'</span>'; }
374 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.htmlspecialchars( $message["newpageletter"] ).'</span>'; }
375 if ( $unpatrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
378 # If it's a new article, there is no diff link, but if it hasn't been
379 # patrolled yet, we need to give users a way to do so
380 if ( $unpatrolled && $rc_type == RC_NEW
)
381 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
383 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
386 $articleLink = '<strong>'.$articleLink.'</strong>';
389 if ($rc->notificationtimestamp
) {
390 $articleLink .= wfMsg( 'updatedmarker' );
393 $s .= ' '.$articleLink;
394 wfProfileOut("$fname-page");
397 wfProfileIn( "$fname-rest" );
399 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
401 # User link (or contributions for unregistered users)
402 if ( 0 == $rc_user ) {
403 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
404 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
405 $rc_user_text, 'target=' . $rc_user_text );
407 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
408 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
413 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
414 global $wgDisableAnonTalk;
415 if( 0 == $rc_user && $wgDisableAnonTalk ) {
418 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
419 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
423 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
424 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
425 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
426 $message['blocklink'], 'ip='.$rc_user_text );
430 if($userTalkLink) $userTalkLink .= ' | ';
431 $userTalkLink .= $blockLink;
433 if($userTalkLink) $s.=' ('.$userTalkLink.')';
436 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
437 $rc_comment = $this->skin
->formatComment($rc_comment,$rc->getTitle());
438 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
441 if ($rc->numberofWatchingusers
> 0) {
442 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
447 wfProfileOut( "$fname-rest" );
448 wfProfileOut( $fname );
452 function recentChangesLineNew( &$baseRC, $watched = false ) {
453 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
454 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
457 if( !isset( $message ) ) {
458 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
459 $message[$msg] = wfMsg( $msg );
463 # Create a specialised object
464 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
466 # Extract fields from DB into the function scope (rc_xxxx variables)
467 extract( $rc->mAttribs
);
468 $curIdEq = 'curid=' . $rc_cur_id;
470 # If it's a new day, add the headline and flush the cache
471 $date = $wgLang->date( $rc_timestamp, true);
473 if ( $date != $this->lastdate
) {
474 # Process current cache
475 $ret = $this->recentChangesBlock () ;
476 $this->rc_cache
= array() ;
477 $ret .= "<h4>{$date}</h4>\n";
478 $this->lastdate
= $date;
481 # Should patrol-related stuff be shown?
482 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
483 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
484 $rc->unpatrolled
= !$rc_patrolled;
486 $rc->unpatrolled
= false;
490 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
491 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
492 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
493 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
494 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
496 $logtype = $matches[1];
497 $logname = LogPage
::logName( $logtype );
498 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
499 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
500 # Unpatrolled new page, give rc_id in query
501 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
503 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
506 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
507 $rc->watched
= $watched ;
509 $rc->timestamp
= $time;
510 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
511 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
513 # Make "cur" and "diff" links
514 $titleObj = $rc->getTitle();
515 if ( $rc->unpatrolled
) {
516 $rcIdQuery = "&rcid={$rc_id}";
520 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
521 $curLink = $message['cur'];
522 $diffLink = $message['diff'];
524 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
525 $aprops = ' tabindex="'.$baseRC->counter
.'"';
526 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
527 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
531 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
532 $lastLink = $message['last'];
534 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
535 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
538 # Make user link (or user contributions for unregistered users)
539 if ( $rc_user == 0 ) {
540 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
541 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
542 $rc_user_text, 'target=' . $rc_user_text );
544 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
545 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
548 $rc->userlink
= $userLink;
549 $rc->lastlink
= $lastLink;
550 $rc->curlink
= $curLink;
551 $rc->difflink
= $diffLink;
553 # Make user talk link
554 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
555 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
556 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
558 global $wgDisableAnonTalk;
559 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
560 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
561 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
562 $message['blocklink'], 'ip='.$rc_user_text );
563 if( $wgDisableAnonTalk )
564 $rc->usertalklink
= ' ('.$blockLink.')';
566 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
568 if( $wgDisableAnonTalk && ($rc_user == 0) )
569 $rc->usertalklink
= '';
571 $rc->usertalklink
= ' ('.$userTalkLink.')';
574 # Put accumulated information into the cache, for later display
575 # Page moves go on their own line
576 $title = $rc->getTitle();
577 $secureName = $title->getPrefixedDBkey();
578 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
579 # Use an @ character to prevent collision with page names
580 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
582 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
583 array_push ( $this->rc_cache
[$secureName] , $rc ) ;