Merge "Provide correct type as input for LoadMonitor::postConnectionBackoff()"
[lhc/web/wiklou.git] / includes / changes / EnhancedChangesList.php
1 <?php
2 /**
3 * Generates a list of changes using an Enhanced system (uses javascript).
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 class EnhancedChangesList extends ChangesList {
24 /** @var array Array of array of RCCacheEntry */
25 protected $rc_cache;
26
27 /**
28 * Add the JavaScript file for enhanced changeslist
29 * @return string
30 */
31 public function beginRecentChangesList() {
32 $this->rc_cache = array();
33 $this->rcMoveIndex = 0;
34 $this->rcCacheIndex = 0;
35 $this->lastdate = '';
36 $this->rclistOpen = false;
37 $this->getOutput()->addModuleStyles( array(
38 'mediawiki.special.changeslist',
39 'mediawiki.special.changeslist.enhanced',
40 ) );
41 $this->getOutput()->addModules( array(
42 'jquery.makeCollapsible',
43 'mediawiki.icon',
44 'mediawiki.special.changeslist.js',
45 ) );
46
47 return '<div class="mw-changeslist">';
48 }
49
50 /**
51 * Format a line for enhanced recentchange (aka with javascript and block of lines).
52 *
53 * @param RecentChange $baseRC
54 * @param bool $watched
55 *
56 * @return string
57 */
58 public function recentChangesLine( &$baseRC, $watched = false ) {
59 wfProfileIn( __METHOD__ );
60
61 # If it's a new day, add the headline and flush the cache
62 $date = $this->getLanguage()->userDate(
63 $baseRC->mAttribs['rc_timestamp'],
64 $this->getUser()
65 );
66
67 $ret = '';
68
69 if ( $date != $this->lastdate ) {
70 # Process current cache
71 $ret = $this->recentChangesBlock();
72 $this->rc_cache = array();
73 $ret .= Xml::element( 'h4', null, $date ) . "\n";
74 $this->lastdate = $date;
75 }
76
77 # Create a specialised object
78 $cacheEntry = RCCacheEntry::newFromParent( $baseRC );
79
80 $curIdEq = array( 'curid' => $cacheEntry->mAttribs['rc_cur_id'] );
81
82 # Should patrol-related stuff be shown?
83 $cacheEntry->unpatrolled = $this->showAsUnpatrolled( $cacheEntry );
84
85 $showdifflinks = true;
86
87 # Make article link
88 $type = $cacheEntry->mAttribs['rc_type'];
89 $logType = $cacheEntry->mAttribs['rc_log_type'];
90
91 // Page moves, very old style, not supported anymore
92 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
93 $clink = '';
94 // New unpatrolled pages
95 } elseif ( $cacheEntry->unpatrolled && $type == RC_NEW ) {
96 $clink = Linker::linkKnown( $cacheEntry->getTitle() );
97 // Log entries
98 } elseif ( $type == RC_LOG ) {
99 if ( $logType ) {
100 $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
101 $logpage = new LogPage( $logType );
102 $logname = $logpage->getName()->escaped();
103 $clink = $this->msg( 'parentheses' )
104 ->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped();
105 } else {
106 $clink = Linker::link( $cacheEntry->getTitle() );
107 }
108 $watched = false;
109 // Log entries (old format) and special pages
110 } elseif ( $cacheEntry->mAttribs['rc_namespace'] == NS_SPECIAL ) {
111 wfDebug( "Unexpected special page in recentchanges\n" );
112 $clink = '';
113 // Edits
114 } else {
115 $clink = Linker::linkKnown( $cacheEntry->getTitle() );
116 }
117
118 # Don't show unusable diff links
119 if ( !ChangesList::userCan( $cacheEntry, Revision::DELETED_TEXT, $this->getUser() ) ) {
120 $showdifflinks = false;
121 }
122
123 $time = $this->getLanguage()->userTime( $cacheEntry->mAttribs['rc_timestamp'], $this->getUser() );
124
125 $cacheEntry->watched = $watched;
126 $cacheEntry->link = $clink;
127 $cacheEntry->timestamp = $time;
128 $cacheEntry->numberofWatchingusers = $baseRC->numberofWatchingusers;
129
130 # Make "cur" and "diff" links. Do not use link(), it is too slow if
131 # called too many times (50% of CPU time on RecentChanges!).
132 $thisOldid = $cacheEntry->mAttribs['rc_this_oldid'];
133 $lastOldid = $cacheEntry->mAttribs['rc_last_oldid'];
134
135 $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid );
136 $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid );
137
138 if ( !$showdifflinks ) {
139 $curLink = $this->message['cur'];
140 $diffLink = $this->message['diff'];
141 } elseif ( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
142 if ( $type != RC_NEW ) {
143 $curLink = $this->message['cur'];
144 } else {
145 $curUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querycur ) );
146 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
147 }
148 $diffLink = $this->message['diff'];
149 } else {
150 $diffUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querydiff ) );
151 $curUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querycur ) );
152 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
153 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
154 }
155
156 # Make "last" link
157 if ( !$showdifflinks || !$lastOldid ) {
158 $lastLink = $this->message['last'];
159 } elseif ( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
160 $lastLink = $this->message['last'];
161 } else {
162 $lastLink = Linker::linkKnown( $cacheEntry->getTitle(), $this->message['last'],
163 array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) );
164 }
165
166 # Make user links
167 if ( $this->isDeleted( $cacheEntry, Revision::DELETED_USER ) ) {
168 $cacheEntry->userlink = ' <span class="history-deleted">' .
169 $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
170 } else {
171 $cacheEntry->userlink = Linker::userLink(
172 $cacheEntry->mAttribs['rc_user'],
173 $cacheEntry->mAttribs['rc_user_text']
174 );
175
176 $cacheEntry->usertalklink = Linker::userToolLinks(
177 $cacheEntry->mAttribs['rc_user'],
178 $cacheEntry->mAttribs['rc_user_text']
179 );
180 }
181
182 $cacheEntry->lastlink = $lastLink;
183 $cacheEntry->curlink = $curLink;
184 $cacheEntry->difflink = $diffLink;
185
186 # Put accumulated information into the cache, for later display
187 # Page moves go on their own line
188 $title = $cacheEntry->getTitle();
189 $secureName = $title->getPrefixedDBkey();
190
191 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
192 # Use an @ character to prevent collision with page names
193 $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $cacheEntry );
194 } else {
195 # Logs are grouped by type
196 if ( $type == RC_LOG ) {
197 $secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
198 }
199 if ( !isset( $this->rc_cache[$secureName] ) ) {
200 $this->rc_cache[$secureName] = array();
201 }
202
203 array_push( $this->rc_cache[$secureName], $cacheEntry );
204 }
205
206 wfProfileOut( __METHOD__ );
207
208 return $ret;
209 }
210
211 /**
212 * Enhanced RC group
213 * @param RCCacheEntry[] $block
214 * @return string
215 */
216 protected function recentChangesBlockGroup( $block ) {
217 global $wgRCShowChangedSize;
218
219 wfProfileIn( __METHOD__ );
220
221 # Add the namespace and title of the block as part of the class
222 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
223 if ( $block[0]->mAttribs['rc_log_type'] ) {
224 # Log entry
225 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
226 . $block[0]->mAttribs['rc_log_type'] );
227 } else {
228 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
229 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
230 }
231 $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
232 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
233 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
234 Html::openElement( 'tr' );
235
236 # Collate list of users
237 $userlinks = array();
238 # Other properties
239 $unpatrolled = false;
240 $isnew = false;
241 $allBots = true;
242 $allMinors = true;
243 $curId = $currentRevision = 0;
244 # Some catalyst variables...
245 $namehidden = true;
246 $allLogs = true;
247 $oldid = '';
248 foreach ( $block as $rcObj ) {
249 $oldid = $rcObj->mAttribs['rc_last_oldid'];
250 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
251 $isnew = true;
252 }
253 // If all log actions to this page were hidden, then don't
254 // give the name of the affected page for this block!
255 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
256 $namehidden = false;
257 }
258 $u = $rcObj->userlink;
259 if ( !isset( $userlinks[$u] ) ) {
260 $userlinks[$u] = 0;
261 }
262 if ( $rcObj->unpatrolled ) {
263 $unpatrolled = true;
264 }
265 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
266 $allLogs = false;
267 }
268 # Get the latest entry with a page_id and oldid
269 # since logs may not have these.
270 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
271 $curId = $rcObj->mAttribs['rc_cur_id'];
272 }
273 if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
274 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
275 }
276
277 if ( !$rcObj->mAttribs['rc_bot'] ) {
278 $allBots = false;
279 }
280 if ( !$rcObj->mAttribs['rc_minor'] ) {
281 $allMinors = false;
282 }
283
284 $userlinks[$u]++;
285 }
286
287 # Sort the list and convert to text
288 krsort( $userlinks );
289 asort( $userlinks );
290 $users = array();
291 foreach ( $userlinks as $userlink => $count ) {
292 $text = $userlink;
293 $text .= $this->getLanguage()->getDirMark();
294 if ( $count > 1 ) {
295 // @todo FIXME: Hardcoded '×'. Should be a message.
296 $formattedCount = $this->getLanguage()->formatNum( $count ) . '×';
297 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
298 }
299 array_push( $users, $text );
300 }
301
302 $users = ' <span class="changedby">'
303 . $this->msg( 'brackets' )->rawParams(
304 implode( $this->message['semicolon-separator'], $users )
305 )->escaped() . '</span>';
306
307 $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow ' .
308 'mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
309 $r .= "<td>$tl</td>";
310
311 # Main line
312 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
313 'newpage' => $isnew, # show, when one have this flag
314 'minor' => $allMinors, # show only, when all have this flag
315 'unpatrolled' => $unpatrolled, # show, when one have this flag
316 'bot' => $allBots, # show only, when all have this flag
317 ) );
318
319 # Timestamp
320 $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
321
322 # Article link
323 if ( $namehidden ) {
324 $r .= ' <span class="history-deleted">' .
325 $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
326 } elseif ( $allLogs ) {
327 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
328 } else {
329 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
330 }
331
332 $r .= $this->getLanguage()->getDirMark();
333
334 $queryParams['curid'] = $curId;
335
336 # Changes message
337 static $nchanges = array();
338 static $sinceLastVisitMsg = array();
339
340 $n = count( $block );
341 if ( !isset( $nchanges[$n] ) ) {
342 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
343 }
344
345 $sinceLast = 0;
346 $unvisitedOldid = null;
347 /** @var $rcObj RCCacheEntry */
348 foreach ( $block as $rcObj ) {
349 // Same logic as below inside main foreach
350 if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
351 $sinceLast++;
352 $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
353 }
354 }
355 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
356 $sinceLastVisitMsg[$sinceLast] =
357 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
358 }
359
360 # Total change link
361 $r .= ' ';
362 $logtext = '';
363 /** @var $block0 RecentChange */
364 $block0 = $block[0];
365 if ( !$allLogs ) {
366 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
367 $logtext .= $nchanges[$n];
368 } elseif ( $isnew ) {
369 $logtext .= $nchanges[$n];
370 } else {
371 $logtext .= Linker::link(
372 $block0->getTitle(),
373 $nchanges[$n],
374 array(),
375 $queryParams + array(
376 'diff' => $currentRevision,
377 'oldid' => $oldid,
378 ),
379 array( 'known', 'noclasses' )
380 );
381 if ( $sinceLast > 0 && $sinceLast < $n ) {
382 $logtext .= $this->message['pipe-separator'] . Linker::link(
383 $block0->getTitle(),
384 $sinceLastVisitMsg[$sinceLast],
385 array(),
386 $queryParams + array(
387 'diff' => $currentRevision,
388 'oldid' => $unvisitedOldid,
389 ),
390 array( 'known', 'noclasses' )
391 );
392 }
393 }
394 }
395
396 # History
397 if ( $allLogs ) {
398 // don't show history link for logs
399 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
400 $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history'];
401 } else {
402 $params = $queryParams;
403 $params['action'] = 'history';
404
405 $logtext .= $this->message['pipe-separator'] .
406 Linker::linkKnown(
407 $block0->getTitle(),
408 $this->message['enhancedrc-history'],
409 array(),
410 $params
411 );
412 }
413
414 if ( $logtext !== '' ) {
415 $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
416 }
417
418 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
419
420 # Character difference (does not apply if only log items)
421 if ( $wgRCShowChangedSize && !$allLogs ) {
422 $last = 0;
423 $first = count( $block ) - 1;
424 # Some events (like logs) have an "empty" size, so we need to skip those...
425 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
426 $last++;
427 }
428 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
429 $first--;
430 }
431 # Get net change
432 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
433
434 if ( $chardiff == '' ) {
435 $r .= ' ';
436 } else {
437 $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
438 }
439 }
440
441 $r .= $users;
442 $r .= $this->numberofWatchingusers( $block0->numberofWatchingusers );
443 $r .= '</td></tr>';
444
445 # Sub-entries
446 foreach ( $block as $rcObj ) {
447 # Classes to apply -- TODO implement
448 $classes = array();
449 $type = $rcObj->mAttribs['rc_type'];
450
451 $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
452 ? ' class="mw-enhanced-watched"' : '';
453
454 $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
455 $r .= $this->recentChangesFlags( array(
456 'newpage' => $type == RC_NEW,
457 'minor' => $rcObj->mAttribs['rc_minor'],
458 'unpatrolled' => $rcObj->unpatrolled,
459 'bot' => $rcObj->mAttribs['rc_bot'],
460 ) );
461 $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
462
463 $params = $queryParams;
464
465 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
466 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
467 }
468
469 # Log timestamp
470 if ( $type == RC_LOG ) {
471 $link = $rcObj->timestamp;
472 # Revision link
473 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
474 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
475 } else {
476
477 $link = Linker::linkKnown(
478 $rcObj->getTitle(),
479 $rcObj->timestamp,
480 array(),
481 $params
482 );
483 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
484 $link = '<span class="history-deleted">' . $link . '</span> ';
485 }
486 }
487 $r .= $link . '</span>';
488
489 if ( !$type == RC_LOG || $type == RC_NEW ) {
490 $r .= ' ' . $this->msg( 'parentheses' )->rawParams(
491 $rcObj->curlink .
492 $this->message['pipe-separator'] .
493 $rcObj->lastlink
494 )->escaped();
495 }
496 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
497
498 # Character diff
499 if ( $wgRCShowChangedSize ) {
500 $cd = $this->formatCharacterDifference( $rcObj );
501 if ( $cd !== '' ) {
502 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
503 }
504 }
505
506 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
507 $r .= $this->insertLogEntry( $rcObj );
508 } else {
509 # User links
510 $r .= $rcObj->userlink;
511 $r .= $rcObj->usertalklink;
512 $r .= $this->insertComment( $rcObj );
513 }
514
515 # Rollback
516 $this->insertRollback( $r, $rcObj );
517 # Tags
518 $this->insertTags( $r, $rcObj, $classes );
519
520 $r .= "</td></tr>\n";
521 }
522 $r .= "</table>\n";
523
524 $this->rcCacheIndex++;
525
526 wfProfileOut( __METHOD__ );
527
528 return $r;
529 }
530
531 /**
532 * Generate HTML for an arrow or placeholder graphic
533 * @param string $dir One of '', 'd', 'l', 'r'
534 * @param string $alt
535 * @param string $title
536 * @return string HTML "<img>" tag
537 */
538 protected function arrow( $dir, $alt = '', $title = '' ) {
539 global $wgStylePath;
540 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
541 $encAlt = htmlspecialchars( $alt );
542 $encTitle = htmlspecialchars( $title );
543
544 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
545 }
546
547 /**
548 * Generate HTML for a right- or left-facing arrow,
549 * depending on language direction.
550 * @return string HTML "<img>" tag
551 */
552 protected function sideArrow() {
553 $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
554
555 return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
556 }
557
558 /**
559 * Generate HTML for a down-facing arrow
560 * depending on language direction.
561 * @return string HTML "<img>" tag
562 */
563 protected function downArrow() {
564 return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
565 }
566
567 /**
568 * Generate HTML for a spacer image
569 * @return string HTML "<img>" tag
570 */
571 protected function spacerArrow() {
572 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
573 }
574
575 /**
576 * Enhanced RC ungrouped line.
577 *
578 * @param RecentChange|RCCacheEntry $rcObj
579 * @return string A HTML formatted line (generated using $r)
580 */
581 protected function recentChangesBlockLine( $rcObj ) {
582 global $wgRCShowChangedSize;
583
584 wfProfileIn( __METHOD__ );
585 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
586
587 $type = $rcObj->mAttribs['rc_type'];
588 $logType = $rcObj->mAttribs['rc_log_type'];
589 $classes = array( 'mw-enhanced-rc' );
590 if ( $logType ) {
591 # Log entry
592 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
593 } else {
594 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
595 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
596 }
597 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
598 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
599 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
600 Html::openElement( 'tr' );
601
602 $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
603 # Flag and Timestamp
604 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
605 $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
606 } else {
607 $r .= $this->recentChangesFlags( array(
608 'newpage' => $type == RC_NEW,
609 'minor' => $rcObj->mAttribs['rc_minor'],
610 'unpatrolled' => $rcObj->unpatrolled,
611 'bot' => $rcObj->mAttribs['rc_bot'],
612 ) );
613 }
614 $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
615 # Article or log link
616 if ( $logType ) {
617 $logPage = new LogPage( $logType );
618 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
619 $logName = $logPage->getName()->escaped();
620 $r .= $this->msg( 'parentheses' )
621 ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
622 } else {
623 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
624 }
625 # Diff and hist links
626 if ( $type != RC_LOG ) {
627 $query['action'] = 'history';
628 $r .= ' ' . $this->msg( 'parentheses' )
629 ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
630 $rcObj->getTitle(),
631 $this->message['hist'],
632 array(),
633 $query
634 ) )->escaped();
635 }
636 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
637 # Character diff
638 if ( $wgRCShowChangedSize ) {
639 $cd = $this->formatCharacterDifference( $rcObj );
640 if ( $cd !== '' ) {
641 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
642 }
643 }
644
645 if ( $type == RC_LOG ) {
646 $r .= $this->insertLogEntry( $rcObj );
647 } else {
648 $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink;
649 $r .= $this->insertComment( $rcObj );
650 $this->insertRollback( $r, $rcObj );
651 }
652
653 # Tags
654 $this->insertTags( $r, $rcObj, $classes );
655 # Show how many people are watching this if enabled
656 $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
657
658 $r .= "</td></tr></table>\n";
659
660 wfProfileOut( __METHOD__ );
661
662 return $r;
663 }
664
665 /**
666 * If enhanced RC is in use, this function takes the previously cached
667 * RC lines, arranges them, and outputs the HTML
668 *
669 * @return string
670 */
671 protected function recentChangesBlock() {
672 if ( count( $this->rc_cache ) == 0 ) {
673 return '';
674 }
675
676 wfProfileIn( __METHOD__ );
677
678 $blockOut = '';
679 foreach ( $this->rc_cache as $block ) {
680 if ( count( $block ) < 2 ) {
681 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
682 } else {
683 $blockOut .= $this->recentChangesBlockGroup( $block );
684 }
685 }
686
687 wfProfileOut( __METHOD__ );
688
689 return '<div>' . $blockOut . '</div>';
690 }
691
692 /**
693 * Returns text for the end of RC
694 * If enhanced RC is in use, returns pretty much all the text
695 * @return string
696 */
697 public function endRecentChangesList() {
698 return $this->recentChangesBlock() . '</div>';
699 }
700 }