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 $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 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
177 $r .= ' ('.count($block).' ' ;
178 if ( $isnew ) $r .= wfMsg('changes');
179 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
180 $curIdEq."&diff=$oldid&oldid=$newid" ) ;
184 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
190 if ($block[0]->numberofWatchingusers
> 0) {
191 $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers
));
196 $r .= '<div id="'.$rci.'" style="display:none">' ;
197 foreach ( $block AS $rcObj ) {
198 # Get rc_xxxx variables
199 extract( $rcObj->mAttribs
);
201 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
202 $r .= '<tt> ' ;
203 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
);
204 $r .= ' </tt>' ;
207 if ( $rc_last_oldid != 0 ) {
208 $o = 'oldid='.$rc_last_oldid ;
210 if ( $rc_type == RC_LOG
) {
211 $link = $rcObj->timestamp
;
213 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
215 $link = '<tt>'.$link.'</tt>' ;
219 $r .= $rcObj->curlink
;
221 $r .= $rcObj->lastlink
;
222 $r .= ') . . '.$rcObj->userlink
;
223 $r .= $rcObj->usertalklink
;
224 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
229 $this->rcCacheIndex++
;
234 * If enhanced RC is in use, this function takes the previously cached
235 * RC lines, arranges them, and outputs the HTML
237 function recentChangesBlock () {
238 global $wgStylePath ;
239 if ( count ( $this->rc_cache
) == 0 ) return '' ;
241 foreach ( $this->rc_cache
AS $secureName => $block ) {
242 if ( count ( $block ) < 2 ) {
243 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
245 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
249 return '<div>'.$blockOut.'</div>' ;
253 * Called in a loop over all displayed RC entries
254 * Either returns the line, or caches it for later use
256 function recentChangesLine( &$rc, $watched = false ) {
258 $usenew = $wgUser->getOption( 'usenewrc' );
260 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
262 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
267 function recentChangesLineOld( &$rc, $watched = false ) {
268 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
269 $wgOnlySysopsCanPatrol, $wgSysopUserBans;
271 $fname = 'Skin::recentChangesLineOld';
272 wfProfileIn( $fname );
275 if( !isset( $message ) ) {
276 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
277 $message[$msg] = wfMsg( $msg );
281 # Extract DB fields into local scope
282 extract( $rc->mAttribs
);
283 $curIdEq = 'curid=' . $rc_cur_id;
285 # Should patrol-related stuff be shown?
286 $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() &&
287 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
289 # Make date header if necessary
290 $date = $wgLang->date( $rc_timestamp, true, true );
292 if ( $date != $this->lastdate
) {
293 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
294 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
295 $this->lastdate
= $date;
296 $this->rclistOpen
= true;
301 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
303 $s .= '(' . $message['diff'] . ') (';
305 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
308 # "[[x]] moved to [[y]]"
309 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
310 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
311 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
312 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
314 $logtype = $matches[1];
315 $logname = LogPage
::logName( $logtype );
316 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
318 wfProfileIn("$fname-page");
320 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
321 $diffLink = $message['diff'];
324 $rcidparam = "&rcid={$rc_id}";
327 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
328 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
329 '', '', ' tabindex="'.$rc->counter
.'"');
331 $s .= '('.$diffLink.') (';
334 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
337 # M, N and ! (minor, new and unpatrolled)
338 $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '' );
341 # If it's a new article, there is no diff link, but if it hasn't been
342 # patrolled yet, we need to give users a way to do so
343 if ( $unpatrolled && $rc_type == RC_NEW
)
344 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
346 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
349 $articleLink = '<strong>'.$articleLink.'</strong>';
352 $s .= ' '.$articleLink;
353 wfProfileOut("$fname-page");
356 wfProfileIn( "$fname-rest" );
358 $s .= '; ' . $wgLang->time( $rc_timestamp, true, true ) . ' . . ';
360 # User link (or contributions for unregistered users)
361 if ( 0 == $rc_user ) {
362 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
363 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
364 $rc_user_text, 'target=' . $rc_user_text );
366 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
367 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
372 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
373 global $wgDisableAnonTalk;
374 if( 0 == $rc_user && $wgDisableAnonTalk ) {
377 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
378 $userTalkLink= $this->skin
->makeLinkObj( $userTalkPage, $talkname );
382 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
383 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
384 $blockLink = $this->skin
->makeKnownLinkObj( $blockLinkPage,
385 $message['blocklink'], 'ip='.$rc_user_text );
389 if($userTalkLink) $userTalkLink .= ' | ';
390 $userTalkLink .= $blockLink;
392 if($userTalkLink) $s.=' ('.$userTalkLink.')';
395 if ( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
396 $s .= $this->skin
->commentBlock( $rc_comment, $rc->getTitle() );
399 if ($rc->numberofWatchingusers
> 0) {
400 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
405 wfProfileOut( "$fname-rest" );
406 wfProfileOut( $fname );
410 function recentChangesLineNew( &$baseRC, $watched = false ) {
411 global $wgTitle, $wgLang, $wgContLang, $wgUser,
412 $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
415 if( !isset( $message ) ) {
416 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
417 $message[$msg] = wfMsg( $msg );
421 # Create a specialised object
422 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
424 # Extract fields from DB into the function scope (rc_xxxx variables)
425 extract( $rc->mAttribs
);
426 $curIdEq = 'curid=' . $rc_cur_id;
428 # If it's a new day, add the headline and flush the cache
429 $date = $wgLang->date( $rc_timestamp, true);
431 if ( $date != $this->lastdate
) {
432 # Process current cache
433 $ret = $this->recentChangesBlock () ;
434 $this->rc_cache
= array() ;
435 $ret .= "<h4>{$date}</h4>\n";
436 $this->lastdate
= $date;
439 # Should patrol-related stuff be shown?
440 if ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
441 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
442 $rc->unpatrolled
= !$rc_patrolled;
444 $rc->unpatrolled
= false;
448 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
449 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
450 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
451 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
452 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
454 $logtype = $matches[1];
455 $logname = LogPage
::logName( $logtype );
456 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
457 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
458 # Unpatrolled new page, give rc_id in query
459 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
461 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
464 $time = $wgContLang->time( $rc_timestamp, true, true );
465 $rc->watched
= $watched ;
467 $rc->timestamp
= $time;
468 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
470 # Make "cur" and "diff" links
471 $titleObj = $rc->getTitle();
472 if ( $rc->unpatrolled
) {
473 $rcIdQuery = "&rcid={$rc_id}";
477 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
478 $curLink = $message['cur'];
479 $diffLink = $message['diff'];
481 # $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
482 $query = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid";
483 $aprops = ' tabindex="'.$baseRC->counter
.'"';
484 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
485 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
489 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
490 $lastLink = $message['last'];
492 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
493 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
496 # Make user link (or user contributions for unregistered users)
497 if ( $rc_user == 0 ) {
498 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
499 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
500 $rc_user_text, 'target=' . $rc_user_text );
502 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
503 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
506 $rc->userlink
= $userLink;
507 $rc->lastlink
= $lastLink;
508 $rc->curlink
= $curLink;
509 $rc->difflink
= $diffLink;
511 # Make user talk link
512 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
513 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
514 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
516 global $wgDisableAnonTalk;
517 if ( ( $wgSysopUserBans ||
0 == $rc_user ) && $wgUser->isAllowed('block') ) {
518 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
519 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
520 $message['blocklink'], 'ip='.$rc_user_text );
521 if( $wgDisableAnonTalk )
522 $rc->usertalklink
= ' ('.$blockLink.')';
524 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
526 if( $wgDisableAnonTalk && ($rc_user == 0) )
527 $rc->usertalklink
= '';
529 $rc->usertalklink
= ' ('.$userTalkLink.')';
532 # Put accumulated information into the cache, for later display
533 # Page moves go on their own line
534 $title = $rc->getTitle();
535 $secureName = $title->getPrefixedDBkey();
536 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
537 # Use an @ character to prevent collision with page names
538 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
540 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
541 array_push ( $this->rc_cache
[$secureName] , $rc ) ;