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">' . wfMsgHtml( 'newpageletter' ) . '</span>'
24 $f .= $minor ?
'<span class="minor">' . wfMsgHtml( '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 $newid = $rcObj->mAttribs
['rc_this_oldid'];
126 if ( $rcObj->mAttribs
['rc_new'] ) {
129 $u = $rcObj->userlink
;
130 if ( !isset ( $userlinks[$u] ) ) {
133 if ( $rcObj->unpatrolled
) {
139 # Sort the list and convert to text
140 krsort ( $userlinks ) ;
141 asort ( $userlinks ) ;
143 foreach ( $userlinks as $userlink => $count) {
145 if ( $count > 1 ) $text .= " ({$count}×)" ;
146 array_push ( $users , $text ) ;
148 $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
151 $rci = 'RCI'.$this->rcCacheIndex
;
152 $rcl = 'RCL'.$this->rcCacheIndex
;
153 $rcm = 'RCM'.$this->rcCacheIndex
;
154 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
155 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
156 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
157 $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>' ;
163 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled );
166 $r .= ' '.$block[0]->timestamp
.' ' ;
170 $link = $block[0]->link
;
171 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
174 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
175 $currentRevision = $block[0]->mAttribs
['rc_this_oldid'];
176 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
178 $r .= ' ('.count($block).' ' ;
179 if ( $isnew ) $r .= wfMsg('changes');
180 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
181 $curIdEq."&diff=$currentRevision&oldid=$oldid" ) ;
185 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
191 if ($block[0]->numberofWatchingusers
> 0) {
192 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
197 $r .= '<div id="'.$rci.'" style="display:none">' ;
198 foreach ( $block AS $rcObj ) {
199 # Get rc_xxxx variables
200 extract( $rcObj->mAttribs
);
202 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
203 $r .= '<tt> ' ;
204 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
);
205 $r .= ' </tt>' ;
208 if ( $rc_last_oldid != 0 ) {
209 $o = 'oldid='.$rc_last_oldid ;
211 if ( $rc_type == RC_LOG
) {
212 $link = $rcObj->timestamp
;
214 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
216 $link = '<tt>'.$link.'</tt>' ;
220 $r .= $rcObj->curlink
;
222 $r .= $rcObj->lastlink
;
223 $r .= ') . . '.$rcObj->userlink
;
224 $r .= $rcObj->usertalklink
;
225 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
230 $this->rcCacheIndex++
;
235 * If enhanced RC is in use, this function takes the previously cached
236 * RC lines, arranges them, and outputs the HTML
238 function recentChangesBlock () {
239 global $wgStylePath ;
240 if ( count ( $this->rc_cache
) == 0 ) return '' ;
242 foreach ( $this->rc_cache
AS $secureName => $block ) {
243 if ( count ( $block ) < 2 ) {
244 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
246 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
250 return '<div>'.$blockOut.'</div>' ;
254 * Called in a loop over all displayed RC entries
255 * Either returns the line, or caches it for later use
257 function recentChangesLine( &$rc, $watched = false ) {
259 $usenew = $wgUser->getOption( 'usenewrc' );
261 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
263 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
268 function recentChangesLineOld( &$rc, $watched = false ) {
269 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
270 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
272 $fname = 'Skin::recentChangesLineOld';
273 wfProfileIn( $fname );
276 if( !isset( $message ) ) {
277 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
278 $message[$msg] = wfMsg( $msg );
282 # Extract DB fields into local scope
283 extract( $rc->mAttribs
);
284 $curIdEq = 'curid=' . $rc_cur_id;
286 # Should patrol-related stuff be shown?
287 $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() &&
288 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
290 # Make date header if necessary
291 $date = $wgLang->date( $rc_timestamp, true, true );
293 if ( $date != $this->lastdate
) {
294 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
295 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
296 $this->lastdate
= $date;
297 $this->rclistOpen
= true;
302 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
304 $s .= '(' . $message['diff'] . ') (';
306 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
309 # "[[x]] moved to [[y]]"
310 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
311 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
312 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
313 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
315 $logtype = $matches[1];
316 $logname = LogPage
::logName( $logtype );
317 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
319 wfProfileIn("$fname-page");
321 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
322 $diffLink = $message['diff'];
325 $rcidparam = "&rcid={$rc_id}";
328 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
329 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
330 '', '', ' tabindex="'.$rc->counter
.'"');
332 $s .= '('.$diffLink.') (';
335 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
338 # M, N and ! (minor, new and unpatrolled)
339 $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '' );
342 # If it's a new article, there is no diff link, but if it hasn't been
343 # patrolled yet, we need to give users a way to do so
344 if ( $unpatrolled && $rc_type == RC_NEW
)
345 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
347 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
350 $articleLink = '<strong>'.$articleLink.'</strong>';
353 $s .= ' '.$articleLink;
354 wfProfileOut("$fname-page");
357 wfProfileIn( "$fname-rest" );
359 $s .= '; ' . $wgLang->time( $rc_timestamp, true, true ) . ' . . ';
361 # User link (or contributions for unregistered users)
362 if ( 0 == $rc_user ) {
363 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
364 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
365 $rc_user_text, 'target=' . $rc_user_text );
367 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
368 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
373 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
374 global $wgDisableAnonTalk;
375 if( 0 == $rc_user && $wgDisableAnonTalk ) {
378 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
379 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
383 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
384 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
385 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
386 $message['blocklink'], 'ip='.$rc_user_text );
390 if($userTalkLink) $userTalkLink .= ' | ';
391 $userTalkLink .= $blockLink;
393 if($userTalkLink) $s.=' ('.$userTalkLink.')';
396 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
397 $s .= $this->skin
->commentBlock( $rc_comment, $rc->getTitle() );
400 if ($rc->numberofWatchingusers
> 0) {
401 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
406 wfProfileOut( "$fname-rest" );
407 wfProfileOut( $fname );
411 function recentChangesLineNew( &$baseRC, $watched = false ) {
412 global $wgTitle, $wgLang, $wgContLang, $wgUser,
413 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
416 if( !isset( $message ) ) {
417 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
418 $message[$msg] = wfMsg( $msg );
422 # Create a specialised object
423 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
425 # Extract fields from DB into the function scope (rc_xxxx variables)
426 extract( $rc->mAttribs
);
427 $curIdEq = 'curid=' . $rc_cur_id;
429 # If it's a new day, add the headline and flush the cache
430 $date = $wgLang->date( $rc_timestamp, true);
432 if ( $date != $this->lastdate
) {
433 # Process current cache
434 $ret = $this->recentChangesBlock () ;
435 $this->rc_cache
= array() ;
436 $ret .= "<h4>{$date}</h4>\n";
437 $this->lastdate
= $date;
440 # Should patrol-related stuff be shown?
441 if ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
442 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
443 $rc->unpatrolled
= !$rc_patrolled;
445 $rc->unpatrolled
= false;
449 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
450 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
451 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
452 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
453 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
455 $logtype = $matches[1];
456 $logname = LogPage
::logName( $logtype );
457 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
458 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
459 # Unpatrolled new page, give rc_id in query
460 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
462 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
465 $time = $wgContLang->time( $rc_timestamp, true, true );
466 $rc->watched
= $watched ;
468 $rc->timestamp
= $time;
469 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
471 # Make "cur" and "diff" links
472 $titleObj = $rc->getTitle();
473 if ( $rc->unpatrolled
) {
474 $rcIdQuery = "&rcid={$rc_id}";
478 $query = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid";
479 $aprops = ' tabindex="'.$baseRC->counter
.'"';
480 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
481 if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
482 if( $rc_type != RC_NEW
) {
483 $curLink = $message['cur'];
485 $diffLink = $message['diff'];
487 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
491 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
492 $lastLink = $message['last'];
494 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
495 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
498 # Make user link (or user contributions for unregistered users)
499 if ( $rc_user == 0 ) {
500 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
501 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
502 $rc_user_text, 'target=' . $rc_user_text );
504 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
505 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
508 $rc->userlink
= $userLink;
509 $rc->lastlink
= $lastLink;
510 $rc->curlink
= $curLink;
511 $rc->difflink
= $diffLink;
513 # Make user talk link
514 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
515 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
516 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
518 global $wgDisableAnonTalk;
519 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
520 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
521 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
522 $message['blocklink'], 'ip='.$rc_user_text );
523 if( $wgDisableAnonTalk )
524 $rc->usertalklink
= ' ('.$blockLink.')';
526 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
528 if( $wgDisableAnonTalk && ($rc_user == 0) )
529 $rc->usertalklink
= '';
531 $rc->usertalklink
= ' ('.$userTalkLink.')';
534 # Put accumulated information into the cache, for later display
535 # Page moves go on their own line
536 $title = $rc->getTitle();
537 $secureName = $title->getPrefixedDBkey();
538 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
539 # Use an @ character to prevent collision with page names
540 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
542 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
543 array_push ( $this->rc_cache
[$secureName] , $rc ) ;