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