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