Merge "Remove unused $entryPoint from Preferences::tryFormSubmit"
[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 ) );
45
46 return '<div class="mw-changeslist">';
47 }
48
49 /**
50 * Format a line for enhanced recentchange (aka with javascript and block of lines).
51 *
52 * @param RecentChange $baseRC
53 * @param bool $watched
54 *
55 * @return string
56 */
57 public function recentChangesLine( &$baseRC, $watched = false ) {
58 wfProfileIn( __METHOD__ );
59
60 # If it's a new day, add the headline and flush the cache
61 $date = $this->getLanguage()->userDate(
62 $baseRC->mAttribs['rc_timestamp'],
63 $this->getUser()
64 );
65
66 $ret = '';
67
68 if ( $date != $this->lastdate ) {
69 # Process current cache
70 $ret = $this->recentChangesBlock();
71 $this->rc_cache = array();
72 $ret .= Xml::element( 'h4', null, $date ) . "\n";
73 $this->lastdate = $date;
74 }
75
76 # Create a specialised object
77 $cacheEntry = RCCacheEntry::newFromParent( $baseRC );
78
79 $curIdEq = array( 'curid' => $cacheEntry->mAttribs['rc_cur_id'] );
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 $clink = '';
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 * @param RCCacheEntry[] $block
213 * @return string
214 */
215 protected function recentChangesBlockGroup( $block ) {
216 global $wgRCShowChangedSize;
217
218 wfProfileIn( __METHOD__ );
219
220 # Add the namespace and title of the block as part of the class
221 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
222 if ( $block[0]->mAttribs['rc_log_type'] ) {
223 # Log entry
224 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
225 . $block[0]->mAttribs['rc_log_type'] );
226 } else {
227 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
228 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
229 }
230 $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
231 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
232 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
233 Html::openElement( 'tr' );
234
235 # Collate list of users
236 $userlinks = array();
237 # Other properties
238 $unpatrolled = false;
239 $isnew = false;
240 $allBots = true;
241 $allMinors = true;
242 $curId = $currentRevision = 0;
243 # Some catalyst variables...
244 $namehidden = true;
245 $allLogs = true;
246 $oldid = '';
247 foreach ( $block as $rcObj ) {
248 $oldid = $rcObj->mAttribs['rc_last_oldid'];
249 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
250 $isnew = true;
251 }
252 // If all log actions to this page were hidden, then don't
253 // give the name of the affected page for this block!
254 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
255 $namehidden = false;
256 }
257 $u = $rcObj->userlink;
258 if ( !isset( $userlinks[$u] ) ) {
259 $userlinks[$u] = 0;
260 }
261 if ( $rcObj->unpatrolled ) {
262 $unpatrolled = true;
263 }
264 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
265 $allLogs = false;
266 }
267 # Get the latest entry with a page_id and oldid
268 # since logs may not have these.
269 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
270 $curId = $rcObj->mAttribs['rc_cur_id'];
271 }
272 if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
273 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
274 }
275
276 if ( !$rcObj->mAttribs['rc_bot'] ) {
277 $allBots = false;
278 }
279 if ( !$rcObj->mAttribs['rc_minor'] ) {
280 $allMinors = false;
281 }
282
283 $userlinks[$u]++;
284 }
285
286 # Sort the list and convert to text
287 krsort( $userlinks );
288 asort( $userlinks );
289 $users = array();
290 foreach ( $userlinks as $userlink => $count ) {
291 $text = $userlink;
292 $text .= $this->getLanguage()->getDirMark();
293 if ( $count > 1 ) {
294 // @todo FIXME: Hardcoded '×'. Should be a message.
295 $formattedCount = $this->getLanguage()->formatNum( $count ) . '×';
296 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
297 }
298 array_push( $users, $text );
299 }
300
301 $users = ' <span class="changedby">'
302 . $this->msg( 'brackets' )->rawParams(
303 implode( $this->message['semicolon-separator'], $users )
304 )->escaped() . '</span>';
305
306 $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow ' .
307 'mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
308 $r .= "<td>$tl</td>";
309
310 # Main line
311 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
312 'newpage' => $isnew, # show, when one have this flag
313 'minor' => $allMinors, # show only, when all have this flag
314 'unpatrolled' => $unpatrolled, # show, when one have this flag
315 'bot' => $allBots, # show only, when all have this flag
316 ) );
317
318 # Timestamp
319 $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
320
321 # Article link
322 if ( $namehidden ) {
323 $r .= ' <span class="history-deleted">' .
324 $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
325 } elseif ( $allLogs ) {
326 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
327 } else {
328 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
329 }
330
331 $r .= $this->getLanguage()->getDirMark();
332
333 $queryParams['curid'] = $curId;
334
335 # Changes message
336 static $nchanges = array();
337 static $sinceLastVisitMsg = array();
338
339 $n = count( $block );
340 if ( !isset( $nchanges[$n] ) ) {
341 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
342 }
343
344 $sinceLast = 0;
345 $unvisitedOldid = null;
346 /** @var $rcObj RCCacheEntry */
347 foreach ( $block as $rcObj ) {
348 // Same logic as below inside main foreach
349 if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
350 $sinceLast++;
351 $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
352 }
353 }
354 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
355 $sinceLastVisitMsg[$sinceLast] =
356 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
357 }
358
359 # Total change link
360 $r .= ' ';
361 $logtext = '';
362 /** @var $block0 RecentChange */
363 $block0 = $block[0];
364 if ( !$allLogs ) {
365 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
366 $logtext .= $nchanges[$n];
367 } elseif ( $isnew ) {
368 $logtext .= $nchanges[$n];
369 } else {
370 $logtext .= Linker::link(
371 $block0->getTitle(),
372 $nchanges[$n],
373 array(),
374 $queryParams + array(
375 'diff' => $currentRevision,
376 'oldid' => $oldid,
377 ),
378 array( 'known', 'noclasses' )
379 );
380 if ( $sinceLast > 0 && $sinceLast < $n ) {
381 $logtext .= $this->message['pipe-separator'] . Linker::link(
382 $block0->getTitle(),
383 $sinceLastVisitMsg[$sinceLast],
384 array(),
385 $queryParams + array(
386 'diff' => $currentRevision,
387 'oldid' => $unvisitedOldid,
388 ),
389 array( 'known', 'noclasses' )
390 );
391 }
392 }
393 }
394
395 # History
396 if ( $allLogs ) {
397 // don't show history link for logs
398 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
399 $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history'];
400 } else {
401 $params = $queryParams;
402 $params['action'] = 'history';
403
404 $logtext .= $this->message['pipe-separator'] .
405 Linker::linkKnown(
406 $block0->getTitle(),
407 $this->message['enhancedrc-history'],
408 array(),
409 $params
410 );
411 }
412
413 if ( $logtext !== '' ) {
414 $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
415 }
416
417 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
418
419 # Character difference (does not apply if only log items)
420 if ( $wgRCShowChangedSize && !$allLogs ) {
421 $last = 0;
422 $first = count( $block ) - 1;
423 # Some events (like logs) have an "empty" size, so we need to skip those...
424 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
425 $last++;
426 }
427 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
428 $first--;
429 }
430 # Get net change
431 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
432
433 if ( $chardiff == '' ) {
434 $r .= ' ';
435 } else {
436 $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
437 }
438 }
439
440 $r .= $users;
441 $r .= $this->numberofWatchingusers( $block0->numberofWatchingusers );
442 $r .= '</td></tr>';
443
444 # Sub-entries
445 foreach ( $block as $rcObj ) {
446 # Classes to apply -- TODO implement
447 $classes = array();
448 $type = $rcObj->mAttribs['rc_type'];
449
450 $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
451 ? ' class="mw-enhanced-watched"' : '';
452
453 $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
454 $r .= $this->recentChangesFlags( array(
455 'newpage' => $type == RC_NEW,
456 'minor' => $rcObj->mAttribs['rc_minor'],
457 'unpatrolled' => $rcObj->unpatrolled,
458 'bot' => $rcObj->mAttribs['rc_bot'],
459 ) );
460 $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
461
462 $params = $queryParams;
463
464 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
465 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
466 }
467
468 # Log timestamp
469 if ( $type == RC_LOG ) {
470 $link = $rcObj->timestamp;
471 # Revision link
472 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
473 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
474 } else {
475
476 $link = Linker::linkKnown(
477 $rcObj->getTitle(),
478 $rcObj->timestamp,
479 array(),
480 $params
481 );
482 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
483 $link = '<span class="history-deleted">' . $link . '</span> ';
484 }
485 }
486 $r .= $link . '</span>';
487
488 if ( !$type == RC_LOG || $type == RC_NEW ) {
489 $r .= ' ' . $this->msg( 'parentheses' )->rawParams(
490 $rcObj->curlink .
491 $this->message['pipe-separator'] .
492 $rcObj->lastlink
493 )->escaped();
494 }
495 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
496
497 # Character diff
498 if ( $wgRCShowChangedSize ) {
499 $cd = $this->formatCharacterDifference( $rcObj );
500 if ( $cd !== '' ) {
501 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
502 }
503 }
504
505 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
506 $r .= $this->insertLogEntry( $rcObj );
507 } else {
508 # User links
509 $r .= $rcObj->userlink;
510 $r .= $rcObj->usertalklink;
511 $r .= $this->insertComment( $rcObj );
512 }
513
514 # Rollback
515 $this->insertRollback( $r, $rcObj );
516 # Tags
517 $this->insertTags( $r, $rcObj, $classes );
518
519 $r .= "</td></tr>\n";
520 }
521 $r .= "</table>\n";
522
523 $this->rcCacheIndex++;
524
525 wfProfileOut( __METHOD__ );
526
527 return $r;
528 }
529
530 /**
531 * Generate HTML for an arrow or placeholder graphic
532 * @param string $dir One of '', 'd', 'l', 'r'
533 * @param string $alt
534 * @param string $title
535 * @return string HTML "<img>" tag
536 */
537 protected function arrow( $dir, $alt = '', $title = '' ) {
538 global $wgStylePath;
539 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
540 $encAlt = htmlspecialchars( $alt );
541 $encTitle = htmlspecialchars( $title );
542
543 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
544 }
545
546 /**
547 * Generate HTML for a right- or left-facing arrow,
548 * depending on language direction.
549 * @return string HTML "<img>" tag
550 */
551 protected function sideArrow() {
552 $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
553
554 return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
555 }
556
557 /**
558 * Generate HTML for a down-facing arrow
559 * depending on language direction.
560 * @return string HTML "<img>" tag
561 */
562 protected function downArrow() {
563 return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
564 }
565
566 /**
567 * Generate HTML for a spacer image
568 * @return string HTML "<img>" tag
569 */
570 protected function spacerArrow() {
571 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
572 }
573
574 /**
575 * Enhanced RC ungrouped line.
576 *
577 * @param RecentChange|RCCacheEntry $rcObj
578 * @return string A HTML formatted line (generated using $r)
579 */
580 protected function recentChangesBlockLine( $rcObj ) {
581 global $wgRCShowChangedSize;
582
583 wfProfileIn( __METHOD__ );
584 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
585
586 $type = $rcObj->mAttribs['rc_type'];
587 $logType = $rcObj->mAttribs['rc_log_type'];
588 $classes = array( 'mw-enhanced-rc' );
589 if ( $logType ) {
590 # Log entry
591 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
592 } else {
593 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
594 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
595 }
596 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
597 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
598 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
599 Html::openElement( 'tr' );
600
601 $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
602 # Flag and Timestamp
603 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
604 $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
605 } else {
606 $r .= $this->recentChangesFlags( array(
607 'newpage' => $type == RC_NEW,
608 'minor' => $rcObj->mAttribs['rc_minor'],
609 'unpatrolled' => $rcObj->unpatrolled,
610 'bot' => $rcObj->mAttribs['rc_bot'],
611 ) );
612 }
613 $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
614 # Article or log link
615 if ( $logType ) {
616 $logPage = new LogPage( $logType );
617 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
618 $logName = $logPage->getName()->escaped();
619 $r .= $this->msg( 'parentheses' )
620 ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
621 } else {
622 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
623 }
624 # Diff and hist links
625 if ( $type != RC_LOG ) {
626 $query['action'] = 'history';
627 $r .= ' ' . $this->msg( 'parentheses' )
628 ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
629 $rcObj->getTitle(),
630 $this->message['hist'],
631 array(),
632 $query
633 ) )->escaped();
634 }
635 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
636 # Character diff
637 if ( $wgRCShowChangedSize ) {
638 $cd = $this->formatCharacterDifference( $rcObj );
639 if ( $cd !== '' ) {
640 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
641 }
642 }
643
644 if ( $type == RC_LOG ) {
645 $r .= $this->insertLogEntry( $rcObj );
646 } else {
647 $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink;
648 $r .= $this->insertComment( $rcObj );
649 $this->insertRollback( $r, $rcObj );
650 }
651
652 # Tags
653 $this->insertTags( $r, $rcObj, $classes );
654 # Show how many people are watching this if enabled
655 $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
656
657 $r .= "</td></tr></table>\n";
658
659 wfProfileOut( __METHOD__ );
660
661 return $r;
662 }
663
664 /**
665 * If enhanced RC is in use, this function takes the previously cached
666 * RC lines, arranges them, and outputs the HTML
667 *
668 * @return string
669 */
670 protected function recentChangesBlock() {
671 if ( count( $this->rc_cache ) == 0 ) {
672 return '';
673 }
674
675 wfProfileIn( __METHOD__ );
676
677 $blockOut = '';
678 foreach ( $this->rc_cache as $block ) {
679 if ( count( $block ) < 2 ) {
680 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
681 } else {
682 $blockOut .= $this->recentChangesBlockGroup( $block );
683 }
684 }
685
686 wfProfileOut( __METHOD__ );
687
688 return '<div>' . $blockOut . '</div>';
689 }
690
691 /**
692 * Returns text for the end of RC
693 * If enhanced RC is in use, returns pretty much all the text
694 * @return string
695 */
696 public function endRecentChangesList() {
697 return $this->recentChangesBlock() . '</div>';
698 }
699 }