45fef5ff39b26dba89023e7fa8b90886d2fb12e7
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
) {
66 if ( $rcObj->unpatrolled
) {
74 $r .= ' '.$rcObj->timestamp
.' ' ;
78 $link = $rcObj->link
;
79 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
84 $r .= $rcObj->difflink
;
88 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
91 $r .= ') . . '.$rcObj->userlink
;
92 $r .= $rcObj->usertalklink
;
95 if ( ($rc_comment != '' ||
$rc_type == RC_EDIT_COMMENT
) &&
96 $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
98 $rc_comment = $this->skin
->formatComment($rc_comment, $rcObj->getTitle());
100 # If a summary comment change, we want to form the message "was ($rc_moved_to_title)
101 # now ($rc_comment)".
102 if ( $rc_type == RC_EDIT_COMMENT
) {
103 $rc_comment = $wgContLang->emphasize( '(' . $rc_comment . ')' );
104 $rc_moved_to_title = $this->skin
->formatComment( $rc_moved_to_title, $rcObj->getTitle() );
105 $rc_moved_to_title = $wgContLang->emphasize( '(' . $rc_moved_to_title . ')' );
106 $r .= ' ' . wfMsg( 'ecrccommentformat', $rc_moved_to_title, $rc_comment );
108 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
118 function recentChangesBlockGroup ( $block ) {
119 global $wgStylePath, $wgContLang ;
122 $M = wfMsg( 'minoreditletter' );
123 $N = wfMsg( 'newpageletter' );
125 # Collate list of users
127 $unpatrolled = false;
128 $userlinks = array () ;
129 foreach ( $block AS $rcObj ) {
130 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
131 if ( $rcObj->mAttribs
['rc_new'] ) {
134 $u = $rcObj->userlink
;
135 if ( !isset ( $userlinks[$u] ) ) {
138 if ( $rcObj->unpatrolled
) {
144 # Sort the list and convert to text
145 krsort ( $userlinks ) ;
146 asort ( $userlinks ) ;
148 foreach ( $userlinks as $userlink => $count) {
150 if ( $count > 1 ) $text .= " ({$count}×)" ;
151 array_push ( $users , $text ) ;
153 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
156 $rci = 'RCI'.$this->rcCacheIndex
;
157 $rcl = 'RCL'.$this->rcCacheIndex
;
158 $rcm = 'RCM'.$this->rcCacheIndex
;
159 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
160 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
161 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
162 $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>' ;
168 if ( $isnew ) $r .= $N ;
169 else $r .= ' ' ;
170 $r .= ' ' ; # Minor
171 if ( $unpatrolled ) {
178 $r .= ' '.$block[0]->timestamp
.' ' ;
182 $link = $block[0]->link
;
183 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
186 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
187 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
189 $r .= ' ('.count($block).' ' ;
190 if ( $isnew ) $r .= wfMsg('changes');
191 else $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
192 $curIdEq.'&diff=0&oldid='.$oldid ) ;
196 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
204 $r .= '<div id="'.$rci.'" style="display:none">' ;
205 foreach ( $block AS $rcObj ) {
206 # Get rc_xxxx variables
207 extract( $rcObj->mAttribs
);
209 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
210 $r .= '<tt> ' ;
223 if ( $rcObj->unpatrolled
) {
229 $r .= ' </tt>' ;
232 if ( $rc_last_oldid != 0 ) {
233 $o = 'oldid='.$rc_last_oldid ;
235 if ( $rc_type == RC_LOG
) {
236 $link = $rcObj->timestamp
;
238 $link = $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
240 $link = '<tt>'.$link.'</tt>' ;
244 $r .= $rcObj->curlink
;
246 $r .= $rcObj->lastlink
;
247 $r .= ') . . '.$rcObj->userlink
;
248 $r .= $rcObj->usertalklink
;
249 if ( $rc_comment != '' ) {
250 $rc_comment=$this->skin
->formatComment($rc_comment, $rcObj->getTitle());
251 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
257 $this->rcCacheIndex++
;
262 * If enhanced RC is in use, this function takes the previously cached
263 * RC lines, arranges them, and outputs the HTML
265 function recentChangesBlock () {
266 global $wgStylePath ;
267 if ( count ( $this->rc_cache
) == 0 ) return '' ;
269 foreach ( $this->rc_cache
AS $secureName => $block ) {
270 if ( count ( $block ) < 2 ) {
271 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
273 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
277 return '<div>'.$blockOut.'</div>' ;
281 * Called in a loop over all displayed RC entries
282 * Either returns the line, or caches it for later use
284 function recentChangesLine( &$rc, $watched = false ) {
286 $usenew = $wgUser->getOption( 'usenewrc' );
288 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
290 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
294 function recentChangesLineOld( &$rc, $watched = false ) {
295 $fname = 'Skin::recentChangesLineOld';
296 wfProfileIn( $fname );
298 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
301 if( !isset( $message ) ) {
302 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
303 $message[$msg] = wfMsg( $msg );
307 # Extract DB fields into local scope
308 extract( $rc->mAttribs
);
309 $curIdEq = 'curid=' . $rc_cur_id;
311 # Should patrol-related stuff be shown?
312 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
313 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
315 # Make date header if necessary
316 $date = $wgLang->date( $rc_timestamp, true);
318 if ( $date != $this->lastdate
) {
319 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
320 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
321 $this->lastdate
= $date;
322 $this->rclistOpen
= true;
327 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
329 $s .= '(' . $message['diff'] . ') (';
331 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
334 # "[[x]] moved to [[y]]"
335 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
336 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
337 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
338 } else if ( $rc_type == RC_EDIT_COMMENT
) {
340 $s .= '(' . wfMsg( 'diff' ) . ') (';
342 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
345 # M and ! (minor and unpatrolled)
346 if ( $rc_minor ) { $s .= '<span class="minor">'.$message["minoreditletter"].'</span> '; }
347 if ( !$rc_patrolled ) { $s .= '<span class="unpatrolled">!</span> '; }
349 # Put a link to the revision the comment is for, in a message.
350 $s .= wfMsg( "eccommentchanged" ,
351 $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no&oldid=' . $rc_this_oldid ) );
352 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
354 $logtype = $matches[1];
355 $logname = LogPage
::logName( $logtype );
356 $s .= '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
358 wfProfileIn("$fname-page");
360 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
361 $diffLink = $message['diff'];
364 $rcidparam = "&rcid={$rc_id}";
367 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
368 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
369 '', '', ' tabindex="'.$rc->counter
.'"');
371 $s .= '('.$diffLink.') (';
374 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
377 # M, N and ! (minor, new and unpatrolled)
378 if ( $rc_minor ) { $s .= ' <span class="minor">'.$message["minoreditletter"].'</span>'; }
379 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.$message["newpageletter"].'</span>'; }
380 if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
383 # If it's a new article, there is no diff link, but if it hasn't been
384 # patrolled yet, we need to give users a way to do so
385 if ( $unpatrolled && $rc_type == RC_NEW
)
386 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
388 $articleLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
391 $articleLink = '<strong>'.$articleLink.'</strong>';
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_EDIT_COMMENT
) &&
437 $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
439 $rc_comment = $this->skin
->formatComment( $rc_comment, $rc->getTitle() );
441 # If a summary comment change, we want to form the message "was ($rc_moved_to_title)
442 # now ($rc_comment)".
443 if ( $rc_type == RC_EDIT_COMMENT
) {
444 $rc_comment = $wgContLang->emphasize( '(' . $rc_comment . ')' );
445 $rc_moved_to_title = $this->skin
->formatComment( $rc_moved_to_title, $rc->getTitle() );
446 $rc_moved_to_title = $wgContLang->emphasize( '(' . $rc_moved_to_title . ')' );
447 $s .= ' ' . wfMsg( 'ecrccommentformat', $rc_moved_to_title, $rc_comment );
449 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
453 wfProfileOut( "$fname-rest" );
454 wfProfileOut( $fname );
458 function recentChangesLineNew( &$baseRC, $watched = false ) {
459 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
460 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
463 if( !isset( $message ) ) {
464 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
465 $message[$msg] = wfMsg( $msg );
469 # Create a specialised object
470 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
472 # Extract fields from DB into the function scope (rc_xxxx variables)
473 extract( $rc->mAttribs
);
474 $curIdEq = 'curid=' . $rc_cur_id;
476 # If it's a new day, add the headline and flush the cache
477 $date = $wgLang->date( $rc_timestamp, true);
479 if ( $date != $this->lastdate
) {
480 # Process current cache
481 $ret = $this->recentChangesBlock () ;
482 $this->rc_cache
= array() ;
483 $ret .= "<h4>{$date}</h4>\n";
484 $this->lastdate
= $date;
487 # Should patrol-related stuff be shown?
488 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
489 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
490 $rc->unpatrolled
= !$rc_patrolled;
492 $rc->unpatrolled
= false;
496 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
497 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
498 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
499 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
500 } else if ( $rc_type == RC_EDIT_COMMENT
) {
501 # Put a link to the revision the comment is for, in a message.
502 $clink = wfMsg( "eccommentchanged" ,
503 $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no&oldid=' . $rc_this_oldid ) );
504 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
506 $logtype = $matches[1];
507 $logname = LogPage
::logName( $logtype );
508 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
509 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
510 # Unpatrolled new page, give rc_id in query
511 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
513 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' ) ;
516 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
517 $rc->watched
= $watched ;
519 $rc->timestamp
= $time;
521 # Make "cur" and "diff" links
522 $titleObj = $rc->getTitle();
523 if ( $rc->unpatrolled
) {
524 $rcIdQuery = "&rcid={$rc_id}";
528 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
529 $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT ||
530 $rc_type == RC_EDIT_COMMENT
) {
531 $curLink = $message['cur'];
532 $diffLink = $message['diff'];
534 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
535 $aprops = ' tabindex="'.$baseRC->counter
.'"';
536 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
537 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
541 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
542 $lastLink = $message['last'];
544 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $message['last'],
545 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
548 # Make user link (or user contributions for unregistered users)
549 if ( $rc_user == 0 ) {
550 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
551 $userLink = $this->skin
->makeKnownLinkObj( $contribsPage,
552 $rc_user_text, 'target=' . $rc_user_text );
554 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
555 $userLink = $this->skin
->makeLinkObj( $userPage, $rc_user_text );
558 $rc->userlink
= $userLink;
559 $rc->lastlink
= $lastLink;
560 $rc->curlink
= $curLink;
561 $rc->difflink
= $diffLink;
563 # Make user talk link
564 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
565 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
566 $userTalkLink = $this->skin
->makeLinkObj( $userTalkPage, $talkname );
568 global $wgDisableAnonTalk;
569 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
570 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
571 $blockLink = $this->skin
->makeKnownLinkObj( $blockPage,
572 $message['blocklink'], 'ip='.$rc_user_text );
573 if( $wgDisableAnonTalk )
574 $rc->usertalklink
= ' ('.$blockLink.')';
576 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
578 if( $wgDisableAnonTalk && ($rc_user == 0) )
579 $rc->usertalklink
= '';
581 $rc->usertalklink
= ' ('.$userTalkLink.')';
584 # Put accumulated information into the cache, for later display
585 # Page moves go on their own line
586 $title = $rc->getTitle();
587 $secureName = $title->getPrefixedDBkey();
588 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT ||
$rc_type == RC_EDIT_COMMENT
) {
589 # Use an @ character to prevent collision with page names
590 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
592 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
593 array_push ( $this->rc_cache
[$secureName] , $rc ) ;