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>' ;
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_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
100 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
103 if ($rcObj->numberofWatchingusers
> 0) {
104 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers
));
114 function recentChangesBlockGroup ( $block ) {
115 global $wgStylePath, $wgContLang ;
119 # Collate list of users
121 $unpatrolled = false;
122 $userlinks = array () ;
123 foreach ( $block AS $rcObj ) {
124 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
125 if ( $rcObj->mAttribs
['rc_new'] ) {
128 $u = $rcObj->userlink
;
129 if ( !isset ( $userlinks[$u] ) ) {
132 if ( $rcObj->unpatrolled
) {
138 # Sort the list and convert to text
139 krsort ( $userlinks ) ;
140 asort ( $userlinks ) ;
142 foreach ( $userlinks as $userlink => $count) {
144 if ( $count > 1 ) $text .= " ({$count}×)" ;
145 array_push ( $users , $text ) ;
147 $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
150 $rci = 'RCI'.$this->rcCacheIndex
;
151 $rcl = 'RCL'.$this->rcCacheIndex
;
152 $rcm = 'RCM'.$this->rcCacheIndex
;
153 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
154 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
155 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
156 $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>' ;
162 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled );
165 $r .= ' '.$block[0]->timestamp
.' ' ;
169 $link = $block[0]->link
;
170 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
173 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
174 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
176 $r .= ' ('.count($block).' ' ;
177 if ( $isnew ) $r .= wfMsg('changes');
178 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
179 $curIdEq.'&diff=0&oldid='.$oldid ) ;
183 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
189 if ($block[0]->numberofWatchingusers
> 0) {
190 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
195 $r .= '<div id="'.$rci.'" style="display:none">' ;
196 foreach ( $block AS $rcObj ) {
197 # Get rc_xxxx variables
198 extract( $rcObj->mAttribs
);
200 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
201 $r .= '<tt> ' ;
202 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
);
203 $r .= ' </tt>' ;
206 if ( $rc_last_oldid != 0 ) {
207 $o = 'oldid='.$rc_last_oldid ;
209 if ( $rc_type == RC_LOG
) {
210 $link = $rcObj->timestamp
;
212 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
214 $link = '<tt>'.$link.'</tt>' ;
218 $r .= $rcObj->curlink
;
220 $r .= $rcObj->lastlink
;
221 $r .= ') . . '.$rcObj->userlink
;
222 $r .= $rcObj->usertalklink
;
223 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
228 $this->rcCacheIndex++
;
233 * If enhanced RC is in use, this function takes the previously cached
234 * RC lines, arranges them, and outputs the HTML
236 function recentChangesBlock () {
237 global $wgStylePath ;
238 if ( count ( $this->rc_cache
) == 0 ) return '' ;
240 foreach ( $this->rc_cache
AS $secureName => $block ) {
241 if ( count ( $block ) < 2 ) {
242 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
244 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
248 return '<div>'.$blockOut.'</div>' ;
252 * Called in a loop over all displayed RC entries
253 * Either returns the line, or caches it for later use
255 function recentChangesLine( &$rc, $watched = false ) {
257 $usenew = $wgUser->getOption( 'usenewrc' );
259 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
261 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
266 function recentChangesLineOld( &$rc, $watched = false ) {
267 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
268 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
270 $fname = 'Skin::recentChangesLineOld';
271 wfProfileIn( $fname );
274 if( !isset( $message ) ) {
275 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
276 $message[$msg] = wfMsg( $msg );
280 # Extract DB fields into local scope
281 extract( $rc->mAttribs
);
282 $curIdEq = 'curid=' . $rc_cur_id;
284 # Should patrol-related stuff be shown?
285 $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() &&
286 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
288 # Make date header if necessary
289 $date = $wgLang->date( $rc_timestamp, true, true );
291 if ( $date != $this->lastdate
) {
292 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
293 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
294 $this->lastdate
= $date;
295 $this->rclistOpen
= true;
300 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
302 $s .= '(' . $message['diff'] . ') (';
304 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
307 # "[[x]] moved to [[y]]"
308 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
309 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
310 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
311 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
313 $logtype = $matches[1];
314 $logname = LogPage
::logName( $logtype );
315 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
317 wfProfileIn("$fname-page");
319 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
320 $diffLink = $message['diff'];
323 $rcidparam = "&rcid={$rc_id}";
326 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
327 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
328 '', '', ' tabindex="'.$rc->counter
.'"');
330 $s .= '('.$diffLink.') (';
333 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
336 # M, N and ! (minor, new and unpatrolled)
337 $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '' );
340 # If it's a new article, there is no diff link, but if it hasn't been
341 # patrolled yet, we need to give users a way to do so
342 if ( $unpatrolled && $rc_type == RC_NEW
)
343 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
345 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
348 $articleLink = '<strong>'.$articleLink.'</strong>';
351 $s .= ' '.$articleLink;
352 wfProfileOut("$fname-page");
355 wfProfileIn( "$fname-rest" );
357 $s .= '; ' . $wgLang->time( $rc_timestamp, true, true ) . ' . . ';
359 # User link (or contributions for unregistered users)
360 if ( 0 == $rc_user ) {
361 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
362 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
363 $rc_user_text, 'target=' . $rc_user_text );
365 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
366 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
371 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
372 global $wgDisableAnonTalk;
373 if( 0 == $rc_user && $wgDisableAnonTalk ) {
376 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
377 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
381 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
382 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
383 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
384 $message['blocklink'], 'ip='.$rc_user_text );
388 if($userTalkLink) $userTalkLink .= ' | ';
389 $userTalkLink .= $blockLink;
391 if($userTalkLink) $s.=' ('.$userTalkLink.')';
394 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
395 $s .= $this->skin
->commentBlock( $rc_comment, $rc->getTitle() );
398 if ($rc->numberofWatchingusers
> 0) {
399 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
404 wfProfileOut( "$fname-rest" );
405 wfProfileOut( $fname );
409 function recentChangesLineNew( &$baseRC, $watched = false ) {
410 global $wgTitle, $wgLang, $wgContLang, $wgUser,
411 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
414 if( !isset( $message ) ) {
415 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
416 $message[$msg] = wfMsg( $msg );
420 # Create a specialised object
421 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
423 # Extract fields from DB into the function scope (rc_xxxx variables)
424 extract( $rc->mAttribs
);
425 $curIdEq = 'curid=' . $rc_cur_id;
427 # If it's a new day, add the headline and flush the cache
428 $date = $wgLang->date( $rc_timestamp, true);
430 if ( $date != $this->lastdate
) {
431 # Process current cache
432 $ret = $this->recentChangesBlock () ;
433 $this->rc_cache
= array() ;
434 $ret .= "<h4>{$date}</h4>\n";
435 $this->lastdate
= $date;
438 # Should patrol-related stuff be shown?
439 if ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
440 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
441 $rc->unpatrolled
= !$rc_patrolled;
443 $rc->unpatrolled
= false;
447 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
448 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
449 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
450 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
451 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
453 $logtype = $matches[1];
454 $logname = LogPage
::logName( $logtype );
455 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
456 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
457 # Unpatrolled new page, give rc_id in query
458 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
460 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
463 $time = $wgContLang->time( $rc_timestamp, true, true );
464 $rc->watched
= $watched ;
466 $rc->timestamp
= $time;
467 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
469 # Make "cur" and "diff" links
470 $titleObj = $rc->getTitle();
471 if ( $rc->unpatrolled
) {
472 $rcIdQuery = "&rcid={$rc_id}";
476 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
477 $curLink = $message['cur'];
478 $diffLink = $message['diff'];
480 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
481 $aprops = ' tabindex="'.$baseRC->counter
.'"';
482 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
483 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
487 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
488 $lastLink = $message['last'];
490 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
491 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
494 # Make user link (or user contributions for unregistered users)
495 if ( $rc_user == 0 ) {
496 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
497 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
498 $rc_user_text, 'target=' . $rc_user_text );
500 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
501 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
504 $rc->userlink
= $userLink;
505 $rc->lastlink
= $lastLink;
506 $rc->curlink
= $curLink;
507 $rc->difflink
= $diffLink;
509 # Make user talk link
510 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
511 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
512 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
514 global $wgDisableAnonTalk;
515 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
516 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
517 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
518 $message['blocklink'], 'ip='.$rc_user_text );
519 if( $wgDisableAnonTalk )
520 $rc->usertalklink
= ' ('.$blockLink.')';
522 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
524 if( $wgDisableAnonTalk && ($rc_user == 0) )
525 $rc->usertalklink
= '';
527 $rc->usertalklink
= ' ('.$userTalkLink.')';
530 # Put accumulated information into the cache, for later display
531 # Page moves go on their own line
532 $title = $rc->getTitle();
533 $secureName = $title->getPrefixedDBkey();
534 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
535 # Use an @ character to prevent collision with page names
536 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
538 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
539 array_push ( $this->rc_cache
[$secureName] , $rc ) ;