10 # Called by history lists and recent changes
14 function ChangesList( &$skin ) {
19 * Returns the appropiate flags for new page, minor change and patrolling
21 function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ' ) {
22 $f = $new ?
'<span class="newpage">' . htmlspecialchars( wfMsg( 'newpageletter' ) ) . '</span>'
24 $f .= $minor ?
'<span class="minor">' . htmlspecialchars( wfMsg( 'minoreditletter' ) ) . '</span>'
26 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
32 * Returns text for the start of the tabular part of RC
34 function beginRecentChangesList() {
35 $this->rc_cache
= array() ;
36 $this->rcMoveIndex
= 0;
37 $this->rcCacheIndex
= 0 ;
39 $this->rclistOpen
= false;
44 * Returns text for the end of RC
45 * If enhanced RC is in use, returns pretty much all the text
47 function endRecentChangesList() {
48 $s = $this->recentChangesBlock() ;
49 if( $this->rclistOpen
) {
56 * Enhanced RC ungrouped line
58 function recentChangesBlockLine ( $rcObj ) {
59 global $wgStylePath, $wgContLang ;
61 # Get rc_xxxx variables
62 extract( $rcObj->mAttribs
) ;
63 $curIdEq = 'curid='.$rc_cur_id;
68 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
71 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
72 $r .= ' ';
74 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
);
78 $r .= ' '.$rcObj->timestamp
.' ' ;
82 $link = $rcObj->link
;
83 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
86 if ($rcObj->notificationtimestamp
) {
87 $r .= wfMsg( 'updatedmarker' );
92 $r .= $rcObj->difflink
;
96 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
99 $r .= ') . . '.$rcObj->userlink
;
100 $r .= $rcObj->usertalklink
;
103 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
104 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
107 if ($rcObj->numberofWatchingusers
> 0) {
108 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers
));
118 function recentChangesBlockGroup ( $block ) {
119 global $wgStylePath, $wgContLang ;
123 # Collate list of users
125 $unpatrolled = false;
126 $userlinks = array () ;
127 foreach ( $block AS $rcObj ) {
128 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
129 if ( $rcObj->mAttribs
['rc_new'] ) {
132 $u = $rcObj->userlink
;
133 if ( !isset ( $userlinks[$u] ) ) {
136 if ( $rcObj->unpatrolled
) {
142 # Sort the list and convert to text
143 krsort ( $userlinks ) ;
144 asort ( $userlinks ) ;
146 foreach ( $userlinks as $userlink => $count) {
148 if ( $count > 1 ) $text .= " ({$count}×)" ;
149 array_push ( $users , $text ) ;
151 $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
154 $rci = 'RCI'.$this->rcCacheIndex
;
155 $rcl = 'RCL'.$this->rcCacheIndex
;
156 $rcm = 'RCM'.$this->rcCacheIndex
;
157 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
158 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
159 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
160 $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 .= $this->recentChangesFlags( $isnew, false, $unpatrolled );
169 $r .= ' '.$block[0]->timestamp
.' ' ;
173 $link = $block[0]->link
;
174 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
177 if ($block[0]->notificationtimestamp
) {
178 $r .= wfMsg( 'updatedmarker' );
181 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
182 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
184 $r .= ' ('.count($block).' ' ;
185 if ( $isnew ) $r .= wfMsg('changes');
186 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
187 $curIdEq.'&diff=0&oldid='.$oldid ) ;
191 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
197 if ($block[0]->numberofWatchingusers
> 0) {
198 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
203 $r .= '<div id="'.$rci.'" style="display:none">' ;
204 foreach ( $block AS $rcObj ) {
205 # Get rc_xxxx variables
206 extract( $rcObj->mAttribs
);
208 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
209 $r .= '<tt> ' ;
210 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
);
211 $r .= ' </tt>' ;
214 if ( $rc_last_oldid != 0 ) {
215 $o = 'oldid='.$rc_last_oldid ;
217 if ( $rc_type == RC_LOG
) {
218 $link = $rcObj->timestamp
;
220 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
222 $link = '<tt>'.$link.'</tt>' ;
226 $r .= $rcObj->curlink
;
228 $r .= $rcObj->lastlink
;
229 $r .= ') . . '.$rcObj->userlink
;
230 $r .= $rcObj->usertalklink
;
231 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
236 $this->rcCacheIndex++
;
241 * If enhanced RC is in use, this function takes the previously cached
242 * RC lines, arranges them, and outputs the HTML
244 function recentChangesBlock () {
245 global $wgStylePath ;
246 if ( count ( $this->rc_cache
) == 0 ) return '' ;
248 foreach ( $this->rc_cache
AS $secureName => $block ) {
249 if ( count ( $block ) < 2 ) {
250 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
252 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
256 return '<div>'.$blockOut.'</div>' ;
260 * Called in a loop over all displayed RC entries
261 * Either returns the line, or caches it for later use
263 function recentChangesLine( &$rc, $watched = false ) {
265 $usenew = $wgUser->getOption( 'usenewrc' );
267 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
269 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
274 function recentChangesLineOld( &$rc, $watched = false ) {
275 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
276 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
278 $fname = 'Skin::recentChangesLineOld';
279 wfProfileIn( $fname );
282 if( !isset( $message ) ) {
283 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
284 $message[$msg] = wfMsg( $msg );
288 # Extract DB fields into local scope
289 extract( $rc->mAttribs
);
290 $curIdEq = 'curid=' . $rc_cur_id;
292 # Should patrol-related stuff be shown?
293 $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() &&
294 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
296 # Make date header if necessary
297 $date = $wgLang->date( $rc_timestamp, true, true );
299 if ( $date != $this->lastdate
) {
300 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
301 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
302 $this->lastdate
= $date;
303 $this->rclistOpen
= true;
308 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
310 $s .= '(' . $message['diff'] . ') (';
312 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
315 # "[[x]] moved to [[y]]"
316 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
317 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
318 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
319 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
321 $logtype = $matches[1];
322 $logname = LogPage
::logName( $logtype );
323 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
325 wfProfileIn("$fname-page");
327 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
328 $diffLink = $message['diff'];
331 $rcidparam = "&rcid={$rc_id}";
334 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
335 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
336 '', '', ' tabindex="'.$rc->counter
.'"');
338 $s .= '('.$diffLink.') (';
341 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
344 # M, N and ! (minor, new and unpatrolled)
345 $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '' );
348 # If it's a new article, there is no diff link, but if it hasn't been
349 # patrolled yet, we need to give users a way to do so
350 if ( $unpatrolled && $rc_type == RC_NEW
)
351 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
353 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
356 $articleLink = '<strong>'.$articleLink.'</strong>';
359 if ($rc->notificationtimestamp
) {
360 $articleLink .= wfMsg( 'updatedmarker' );
363 $s .= ' '.$articleLink;
364 wfProfileOut("$fname-page");
367 wfProfileIn( "$fname-rest" );
369 $s .= '; ' . $wgLang->time( $rc_timestamp, true, true ) . ' . . ';
371 # User link (or contributions for unregistered users)
372 if ( 0 == $rc_user ) {
373 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
374 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
375 $rc_user_text, 'target=' . $rc_user_text );
377 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
378 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
383 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
384 global $wgDisableAnonTalk;
385 if( 0 == $rc_user && $wgDisableAnonTalk ) {
388 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
389 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
393 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
394 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
395 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
396 $message['blocklink'], 'ip='.$rc_user_text );
400 if($userTalkLink) $userTalkLink .= ' | ';
401 $userTalkLink .= $blockLink;
403 if($userTalkLink) $s.=' ('.$userTalkLink.')';
406 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
407 $s .= $this->skin
->commentBlock( $rc_comment, $rc->getTitle() );
410 if ($rc->numberofWatchingusers
> 0) {
411 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
416 wfProfileOut( "$fname-rest" );
417 wfProfileOut( $fname );
421 function recentChangesLineNew( &$baseRC, $watched = false ) {
422 global $wgTitle, $wgLang, $wgContLang, $wgUser,
423 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
426 if( !isset( $message ) ) {
427 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
428 $message[$msg] = wfMsg( $msg );
432 # Create a specialised object
433 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
435 # Extract fields from DB into the function scope (rc_xxxx variables)
436 extract( $rc->mAttribs
);
437 $curIdEq = 'curid=' . $rc_cur_id;
439 # If it's a new day, add the headline and flush the cache
440 $date = $wgLang->date( $rc_timestamp, true);
442 if ( $date != $this->lastdate
) {
443 # Process current cache
444 $ret = $this->recentChangesBlock () ;
445 $this->rc_cache
= array() ;
446 $ret .= "<h4>{$date}</h4>\n";
447 $this->lastdate
= $date;
450 # Should patrol-related stuff be shown?
451 if ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
452 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
453 $rc->unpatrolled
= !$rc_patrolled;
455 $rc->unpatrolled
= false;
459 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
460 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
461 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
462 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
463 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
465 $logtype = $matches[1];
466 $logname = LogPage
::logName( $logtype );
467 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
468 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
469 # Unpatrolled new page, give rc_id in query
470 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
472 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
475 $time = $wgContLang->time( $rc_timestamp, true, true );
476 $rc->watched
= $watched ;
478 $rc->timestamp
= $time;
479 $rc->notificationtimestamp
= $baseRC->notificationtimestamp
;
480 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
482 # Make "cur" and "diff" links
483 $titleObj = $rc->getTitle();
484 if ( $rc->unpatrolled
) {
485 $rcIdQuery = "&rcid={$rc_id}";
489 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
490 $curLink = $message['cur'];
491 $diffLink = $message['diff'];
493 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
494 $aprops = ' tabindex="'.$baseRC->counter
.'"';
495 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
496 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
500 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
501 $lastLink = $message['last'];
503 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
504 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
507 # Make user link (or user contributions for unregistered users)
508 if ( $rc_user == 0 ) {
509 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
510 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
511 $rc_user_text, 'target=' . $rc_user_text );
513 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
514 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
517 $rc->userlink
= $userLink;
518 $rc->lastlink
= $lastLink;
519 $rc->curlink
= $curLink;
520 $rc->difflink
= $diffLink;
522 # Make user talk link
523 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
524 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
525 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
527 global $wgDisableAnonTalk;
528 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
529 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
530 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
531 $message['blocklink'], 'ip='.$rc_user_text );
532 if( $wgDisableAnonTalk )
533 $rc->usertalklink
= ' ('.$blockLink.')';
535 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
537 if( $wgDisableAnonTalk && ($rc_user == 0) )
538 $rc->usertalklink
= '';
540 $rc->usertalklink
= ' ('.$userTalkLink.')';
543 # Put accumulated information into the cache, for later display
544 # Page moves go on their own line
545 $title = $rc->getTitle();
546 $secureName = $title->getPrefixedDBkey();
547 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
548 # Use an @ character to prevent collision with page names
549 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
551 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
552 array_push ( $this->rc_cache
[$secureName] , $rc ) ;