Merge "Further improve load order of RC and watchlist styling"
[lhc/web/wiklou.git] / includes / ChangesList.php
1 <?php
2 /**
3 * Classes to show lists of changes.
4 *
5 * These can be:
6 * - watchlist
7 * - related changes
8 * - recent changes
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 *
25 * @file
26 */
27
28 /**
29 * @todo document
30 */
31 class RCCacheEntry extends RecentChange {
32 var $secureName, $link;
33 var $curlink, $difflink, $lastlink, $usertalklink, $versionlink;
34 var $userlink, $timestamp, $watched;
35
36 /**
37 * @param $rc RecentChange
38 * @return RCCacheEntry
39 */
40 static function newFromParent( $rc ) {
41 $rc2 = new RCCacheEntry;
42 $rc2->mAttribs = $rc->mAttribs;
43 $rc2->mExtra = $rc->mExtra;
44 return $rc2;
45 }
46 }
47
48 /**
49 * Base class for all changes lists
50 */
51 class ChangesList extends ContextSource {
52
53 /**
54 * @var Skin
55 */
56 public $skin;
57
58 protected $watchlist = false;
59
60 protected $message;
61
62 /**
63 * Changeslist constructor
64 *
65 * @param $obj Skin or IContextSource
66 */
67 public function __construct( $obj ) {
68 if ( $obj instanceof IContextSource ) {
69 $this->setContext( $obj );
70 $this->skin = $obj->getSkin();
71 } else {
72 $this->setContext( $obj->getContext() );
73 $this->skin = $obj;
74 }
75 $this->preCacheMessages();
76 }
77
78 /**
79 * Fetch an appropriate changes list class for the main context
80 * This first argument used to be an User object.
81 *
82 * @deprecated in 1.18; use newFromContext() instead
83 * @param string|User $unused Unused
84 * @return ChangesList|EnhancedChangesList|OldChangesList derivative
85 */
86 public static function newFromUser( $unused ) {
87 wfDeprecated( __METHOD__, '1.18' );
88 return self::newFromContext( RequestContext::getMain() );
89 }
90
91 /**
92 * Fetch an appropriate changes list class for the specified context
93 * Some users might want to use an enhanced list format, for instance
94 *
95 * @param $context IContextSource to use
96 * @return ChangesList|EnhancedChangesList|OldChangesList derivative
97 */
98 public static function newFromContext( IContextSource $context ) {
99 $user = $context->getUser();
100 $sk = $context->getSkin();
101 $list = null;
102 if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
103 $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
104 return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
105 } else {
106 return $list;
107 }
108 }
109
110 /**
111 * Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag
112 * @param $value Boolean
113 */
114 public function setWatchlistDivs( $value = true ) {
115 $this->watchlist = $value;
116 }
117
118 /**
119 * As we use the same small set of messages in various methods and that
120 * they are called often, we call them once and save them in $this->message
121 */
122 private function preCacheMessages() {
123 if ( !isset( $this->message ) ) {
124 foreach ( array(
125 'cur', 'diff', 'hist', 'last', 'blocklink', 'history',
126 'semicolon-separator', 'pipe-separator' ) as $msg
127 ) {
128 $this->message[$msg] = $this->msg( $msg )->escaped();
129 }
130 }
131 }
132
133 /**
134 * Returns the appropriate flags for new page, minor change and patrolling
135 * @param array $flags Associative array of 'flag' => Bool
136 * @param string $nothing to use for empty space
137 * @return String
138 */
139 public function recentChangesFlags( $flags, $nothing = '&#160;' ) {
140 global $wgRecentChangesFlags;
141 $f = '';
142 foreach ( array_keys( $wgRecentChangesFlags ) as $flag ) {
143 $f .= isset( $flags[$flag] ) && $flags[$flag]
144 ? self::flag( $flag )
145 : $nothing;
146 }
147 return $f;
148 }
149
150 /**
151 * Provide the "<abbr>" element appropriate to a given abbreviated flag,
152 * namely the flag indicating a new page, a minor edit, a bot edit, or an
153 * unpatrolled edit. By default in English it will contain "N", "m", "b",
154 * "!" respectively, plus it will have an appropriate title and class.
155 *
156 * @param string $flag One key of $wgRecentChangesFlags
157 * @return String: Raw HTML
158 */
159 public static function flag( $flag ) {
160 static $flagInfos = null;
161 if ( is_null( $flagInfos ) ) {
162 global $wgRecentChangesFlags;
163 $flagInfos = array();
164 foreach ( $wgRecentChangesFlags as $key => $value ) {
165 $flagInfos[$key]['letter'] = wfMessage( $value['letter'] )->escaped();
166 $flagInfos[$key]['title'] = wfMessage( $value['title'] )->escaped();
167 // Allow customized class name, fall back to flag name
168 $flagInfos[$key]['class'] = Sanitizer::escapeClass(
169 isset( $value['class'] ) ? $value['class'] : $key );
170 }
171 }
172
173 // Inconsistent naming, bleh, kepted for b/c
174 $map = array(
175 'minoredit' => 'minor',
176 'botedit' => 'bot',
177 );
178 if ( isset( $map[$flag] ) ) {
179 $flag = $map[$flag];
180 }
181
182 return "<abbr class='" . $flagInfos[$flag]['class'] . "' title='" . $flagInfos[$flag]['title'] . "'>" .
183 $flagInfos[$flag]['letter'] .
184 '</abbr>';
185 }
186
187 /**
188 * Returns text for the start of the tabular part of RC
189 * @return String
190 */
191 public function beginRecentChangesList() {
192 $this->rc_cache = array();
193 $this->rcMoveIndex = 0;
194 $this->rcCacheIndex = 0;
195 $this->lastdate = '';
196 $this->rclistOpen = false;
197 $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
198 return '';
199 }
200
201 /**
202 * Show formatted char difference
203 * @param $old Integer: bytes
204 * @param $new Integer: bytes
205 * @param $context IContextSource context to use
206 * @return String
207 */
208 public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
209 global $wgRCChangedSizeThreshold, $wgMiserMode;
210
211 if ( !$context ) {
212 $context = RequestContext::getMain();
213 }
214
215 $new = (int)$new;
216 $old = (int)$old;
217 $szdiff = $new - $old;
218
219 $lang = $context->getLanguage();
220 $code = $lang->getCode();
221 static $fastCharDiff = array();
222 if ( !isset( $fastCharDiff[$code] ) ) {
223 $fastCharDiff[$code] = $wgMiserMode || $context->msg( 'rc-change-size' )->plain() === '$1';
224 }
225
226 $formattedSize = $lang->formatNum( $szdiff );
227
228 if ( !$fastCharDiff[$code] ) {
229 $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
230 }
231
232 if ( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
233 $tag = 'strong';
234 } else {
235 $tag = 'span';
236 }
237
238 if ( $szdiff === 0 ) {
239 $formattedSizeClass = 'mw-plusminus-null';
240 }
241 if ( $szdiff > 0 ) {
242 $formattedSize = '+' . $formattedSize;
243 $formattedSizeClass = 'mw-plusminus-pos';
244 }
245 if ( $szdiff < 0 ) {
246 $formattedSizeClass = 'mw-plusminus-neg';
247 }
248
249 $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
250
251 return Html::element( $tag,
252 array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
253 $context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
254 }
255
256 /**
257 * Format the character difference of one or several changes.
258 *
259 * @param $old RecentChange
260 * @param $new RecentChange last change to use, if not provided, $old will be used
261 * @return string HTML fragment
262 */
263 public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
264 $oldlen = $old->mAttribs['rc_old_len'];
265
266 if ( $new ) {
267 $newlen = $new->mAttribs['rc_new_len'];
268 } else {
269 $newlen = $old->mAttribs['rc_new_len'];
270 }
271
272 if ( $oldlen === null || $newlen === null ) {
273 return '';
274 }
275
276 return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
277 }
278
279 /**
280 * Returns text for the end of RC
281 * @return String
282 */
283 public function endRecentChangesList() {
284 if ( $this->rclistOpen ) {
285 return "</ul>\n";
286 } else {
287 return '';
288 }
289 }
290
291 /**
292 * @param string $s HTML to update
293 * @param $rc_timestamp mixed
294 */
295 public function insertDateHeader( &$s, $rc_timestamp ) {
296 # Make date header if necessary
297 $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
298 if ( $date != $this->lastdate ) {
299 if ( $this->lastdate != '' ) {
300 $s .= "</ul>\n";
301 }
302 $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
303 $this->lastdate = $date;
304 $this->rclistOpen = true;
305 }
306 }
307
308 /**
309 * @param string $s HTML to update
310 * @param $title Title
311 * @param $logtype string
312 */
313 public function insertLog( &$s, $title, $logtype ) {
314 $page = new LogPage( $logtype );
315 $logname = $page->getName()->escaped();
316 $s .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $title, $logname ) )->escaped();
317 }
318
319 /**
320 * @param string $s HTML to update
321 * @param $rc RecentChange
322 * @param $unpatrolled
323 */
324 public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
325 # Diff link
326 if ( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
327 $diffLink = $this->message['diff'];
328 } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
329 $diffLink = $this->message['diff'];
330 } else {
331 $query = array(
332 'curid' => $rc->mAttribs['rc_cur_id'],
333 'diff' => $rc->mAttribs['rc_this_oldid'],
334 'oldid' => $rc->mAttribs['rc_last_oldid']
335 );
336
337 $diffLink = Linker::linkKnown(
338 $rc->getTitle(),
339 $this->message['diff'],
340 array( 'tabindex' => $rc->counter ),
341 $query
342 );
343 }
344 $diffhist = $diffLink . $this->message['pipe-separator'];
345 # History link
346 $diffhist .= Linker::linkKnown(
347 $rc->getTitle(),
348 $this->message['hist'],
349 array(),
350 array(
351 'curid' => $rc->mAttribs['rc_cur_id'],
352 'action' => 'history'
353 )
354 );
355 $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . ' <span class="mw-changeslist-separator">. .</span> ';
356 }
357
358 /**
359 * @param string $s HTML to update
360 * @param $rc RecentChange
361 * @param $unpatrolled
362 * @param $watched
363 */
364 public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
365 global $wgUseRCPatrol;
366
367 $params = array();
368
369 $articlelink = Linker::linkKnown(
370 $rc->getTitle(),
371 null,
372 array( 'class' => 'mw-changeslist-title' ),
373 $params
374 );
375 if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
376 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
377 }
378 # To allow for boldening pages watched by this user
379 $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
380 # RTL/LTR marker
381 $articlelink .= $this->getLanguage()->getDirMark();
382
383 wfRunHooks( 'ChangesListInsertArticleLink',
384 array( &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ) );
385
386 $s .= " $articlelink";
387 }
388
389 /**
390 * Get the timestamp from $rc formatted with current user's settings
391 * and a separator
392 *
393 * @param $rc RecentChange
394 * @return string HTML fragment
395 */
396 public function getTimestamp( $rc ) {
397 return $this->message['semicolon-separator'] . '<span class="mw-changeslist-date">' .
398 $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
399 }
400
401 /**
402 * Insert time timestamp string from $rc into $s
403 *
404 * @param string $s HTML to update
405 * @param $rc RecentChange
406 */
407 public function insertTimestamp( &$s, $rc ) {
408 $s .= $this->getTimestamp( $rc );
409 }
410
411 /**
412 * Insert links to user page, user talk page and eventually a blocking link
413 *
414 * @param &$s String HTML to update
415 * @param &$rc RecentChange
416 */
417 public function insertUserRelatedLinks( &$s, &$rc ) {
418 if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
419 $s .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
420 } else {
421 $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
422 $rc->mAttribs['rc_user_text'] );
423 $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
424 }
425 }
426
427 /**
428 * Insert a formatted action
429 *
430 * @param $rc RecentChange
431 * @return string
432 */
433 public function insertLogEntry( $rc ) {
434 $formatter = LogFormatter::newFromRow( $rc->mAttribs );
435 $formatter->setContext( $this->getContext() );
436 $formatter->setShowUserToolLinks( true );
437 $mark = $this->getLanguage()->getDirMark();
438 return $formatter->getActionText() . " $mark" . $formatter->getComment();
439 }
440
441 /**
442 * Insert a formatted comment
443 * @param $rc RecentChange
444 * @return string
445 */
446 public function insertComment( $rc ) {
447 if ( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
448 if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
449 return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
450 } else {
451 return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
452 }
453 }
454 return '';
455 }
456
457 /**
458 * Check whether to enable recent changes patrol features
459 * @return Boolean
460 */
461 public static function usePatrol() {
462 global $wgUser;
463 return $wgUser->useRCPatrol();
464 }
465
466 /**
467 * Returns the string which indicates the number of watching users
468 * @return string
469 */
470 protected function numberofWatchingusers( $count ) {
471 static $cache = array();
472 if ( $count > 0 ) {
473 if ( !isset( $cache[$count] ) ) {
474 $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
475 }
476 return $cache[$count];
477 } else {
478 return '';
479 }
480 }
481
482 /**
483 * Determine if said field of a revision is hidden
484 * @param $rc RCCacheEntry
485 * @param $field Integer: one of DELETED_* bitfield constants
486 * @return Boolean
487 */
488 public static function isDeleted( $rc, $field ) {
489 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
490 }
491
492 /**
493 * Determine if the current user is allowed to view a particular
494 * field of this revision, if it's marked as deleted.
495 * @param $rc RCCacheEntry
496 * @param $field Integer
497 * @param $user User object to check, or null to use $wgUser
498 * @return Boolean
499 */
500 public static function userCan( $rc, $field, User $user = null ) {
501 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
502 return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
503 } else {
504 return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
505 }
506 }
507
508 /**
509 * @param $link string
510 * @param $watched bool
511 * @return string
512 */
513 protected function maybeWatchedLink( $link, $watched = false ) {
514 if ( $watched ) {
515 return '<strong class="mw-watched">' . $link . '</strong>';
516 } else {
517 return '<span class="mw-rc-unwatched">' . $link . '</span>';
518 }
519 }
520
521 /** Inserts a rollback link
522 *
523 * @param $s string
524 * @param $rc RecentChange
525 */
526 public function insertRollback( &$s, &$rc ) {
527 if ( $rc->mAttribs['rc_type'] == RC_EDIT && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
528 $page = $rc->getTitle();
529 /** Check for rollback and edit permissions, disallow special pages, and only
530 * show a link on the top-most revision */
531 if ( $this->getUser()->isAllowed( 'rollback' ) && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
532 {
533 $rev = new Revision( array(
534 'title' => $page,
535 'id' => $rc->mAttribs['rc_this_oldid'],
536 'user' => $rc->mAttribs['rc_user'],
537 'user_text' => $rc->mAttribs['rc_user_text'],
538 'deleted' => $rc->mAttribs['rc_deleted']
539 ) );
540 $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
541 }
542 }
543 }
544
545 /**
546 * @param $s string
547 * @param $rc RecentChange
548 * @param $classes
549 */
550 public function insertTags( &$s, &$rc, &$classes ) {
551 if ( empty( $rc->mAttribs['ts_tags'] ) ) {
552 return;
553 }
554
555 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
556 $classes = array_merge( $classes, $newClasses );
557 $s .= ' ' . $tagSummary;
558 }
559
560 public function insertExtra( &$s, &$rc, &$classes ) {
561 // Empty, used for subclasses to add anything special.
562 }
563
564 protected function showAsUnpatrolled( RecentChange $rc ) {
565 $unpatrolled = false;
566 if ( !$rc->mAttribs['rc_patrolled'] ) {
567 if ( $this->getUser()->useRCPatrol() ) {
568 $unpatrolled = true;
569 } elseif ( $this->getUser()->useNPPatrol() && $rc->mAttribs['rc_type'] == RC_NEW ) {
570 $unpatrolled = true;
571 }
572 }
573 return $unpatrolled;
574 }
575 }
576
577 /**
578 * Generate a list of changes using the good old system (no javascript)
579 */
580 class OldChangesList extends ChangesList {
581 /**
582 * Format a line using the old system (aka without any javascript).
583 *
584 * @param $rc RecentChange, passed by reference
585 * @param bool $watched (default false)
586 * @param int $linenumber (default null)
587 *
588 * @return string|bool
589 */
590 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
591 global $wgRCShowChangedSize;
592 wfProfileIn( __METHOD__ );
593
594 # Should patrol-related stuff be shown?
595 $unpatrolled = $this->showAsUnpatrolled( $rc );
596
597 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
598 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
599
600 $s = '';
601 $classes = array();
602 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
603 if ( $linenumber ) {
604 if ( $linenumber & 1 ) {
605 $classes[] = 'mw-line-odd';
606 } else {
607 $classes[] = 'mw-line-even';
608 }
609 }
610
611 // Indicate watched status on the line to allow for more
612 // comprehensive styling.
613 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
614 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
615
616 // Moved pages (very very old, not supported anymore)
617 if ( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
618 // Log entries
619 } elseif ( $rc->mAttribs['rc_log_type'] ) {
620 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
621 $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
622 // Log entries (old format) or log targets, and special pages
623 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
624 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
625 if ( $name == 'Log' ) {
626 $this->insertLog( $s, $rc->getTitle(), $subpage );
627 }
628 // Regular entries
629 } else {
630 $this->insertDiffHist( $s, $rc, $unpatrolled );
631 # M, N, b and ! (minor, new, bot and unpatrolled)
632 $s .= $this->recentChangesFlags(
633 array(
634 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
635 'minor' => $rc->mAttribs['rc_minor'],
636 'unpatrolled' => $unpatrolled,
637 'bot' => $rc->mAttribs['rc_bot']
638 ),
639 ''
640 );
641 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
642 }
643 # Edit/log timestamp
644 $this->insertTimestamp( $s, $rc );
645 # Bytes added or removed
646 if ( $wgRCShowChangedSize ) {
647 $cd = $this->formatCharacterDifference( $rc );
648 if ( $cd !== '' ) {
649 $s .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
650 }
651 }
652
653 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
654 $s .= $this->insertLogEntry( $rc );
655 } else {
656 # User tool links
657 $this->insertUserRelatedLinks( $s, $rc );
658 # LTR/RTL direction mark
659 $s .= $this->getLanguage()->getDirMark();
660 $s .= $this->insertComment( $rc );
661 }
662
663 # Tags
664 $this->insertTags( $s, $rc, $classes );
665 # Rollback
666 $this->insertRollback( $s, $rc );
667 # For subclasses
668 $this->insertExtra( $s, $rc, $classes );
669
670 # How many users watch this page
671 if ( $rc->numberofWatchingusers > 0 ) {
672 $s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
673 }
674
675 if ( $this->watchlist ) {
676 $classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
677 }
678
679 if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc, &$classes ) ) ) {
680 wfProfileOut( __METHOD__ );
681 return false;
682 }
683
684 wfProfileOut( __METHOD__ );
685 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $s . "</li>\n";
686 }
687 }
688
689 /**
690 * Generate a list of changes using an Enhanced system (uses javascript).
691 */
692 class EnhancedChangesList extends ChangesList {
693
694 protected $rc_cache;
695
696 /**
697 * Add the JavaScript file for enhanced changeslist
698 * @return String
699 */
700 public function beginRecentChangesList() {
701 $this->rc_cache = array();
702 $this->rcMoveIndex = 0;
703 $this->rcCacheIndex = 0;
704 $this->lastdate = '';
705 $this->rclistOpen = false;
706 $this->getOutput()->addModuleStyles( array(
707 'mediawiki.special.changeslist',
708 'mediawiki.special.changeslist.enhanced',
709 ) );
710 $this->getOutput()->addModules( array(
711 'jquery.makeCollapsible',
712 'mediawiki.icon',
713 ) );
714 return '';
715 }
716 /**
717 * Format a line for enhanced recentchange (aka with javascript and block of lines).
718 *
719 * @param $baseRC RecentChange
720 * @param $watched bool
721 *
722 * @return string
723 */
724 public function recentChangesLine( &$baseRC, $watched = false ) {
725 wfProfileIn( __METHOD__ );
726
727 # Create a specialised object
728 $rc = RCCacheEntry::newFromParent( $baseRC );
729
730 $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
731
732 # If it's a new day, add the headline and flush the cache
733 $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
734 $ret = '';
735 if ( $date != $this->lastdate ) {
736 # Process current cache
737 $ret = $this->recentChangesBlock();
738 $this->rc_cache = array();
739 $ret .= Xml::element( 'h4', null, $date ) . "\n";
740 $this->lastdate = $date;
741 }
742
743 # Should patrol-related stuff be shown?
744 $rc->unpatrolled = $this->showAsUnpatrolled( $rc );
745
746 $showdifflinks = true;
747 # Make article link
748 $type = $rc->mAttribs['rc_type'];
749 $logType = $rc->mAttribs['rc_log_type'];
750 // Page moves, very old style, not supported anymore
751 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
752 // New unpatrolled pages
753 } elseif ( $rc->unpatrolled && $type == RC_NEW ) {
754 $clink = Linker::linkKnown( $rc->getTitle() );
755 // Log entries
756 } elseif ( $type == RC_LOG ) {
757 if ( $logType ) {
758 $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
759 $logpage = new LogPage( $logType );
760 $logname = $logpage->getName()->escaped();
761 $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped();
762 } else {
763 $clink = Linker::link( $rc->getTitle() );
764 }
765 $watched = false;
766 // Log entries (old format) and special pages
767 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
768 wfDebug( "Unexpected special page in recentchanges\n" );
769 $clink = '';
770 // Edits
771 } else {
772 $clink = Linker::linkKnown( $rc->getTitle() );
773 }
774
775 # Don't show unusable diff links
776 if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
777 $showdifflinks = false;
778 }
779
780 $time = $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() );
781 $rc->watched = $watched;
782 $rc->link = $clink;
783 $rc->timestamp = $time;
784 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
785
786 # Make "cur" and "diff" links. Do not use link(), it is too slow if
787 # called too many times (50% of CPU time on RecentChanges!).
788 $thisOldid = $rc->mAttribs['rc_this_oldid'];
789 $lastOldid = $rc->mAttribs['rc_last_oldid'];
790
791 $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid );
792 $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid );
793
794 if ( !$showdifflinks ) {
795 $curLink = $this->message['cur'];
796 $diffLink = $this->message['diff'];
797 } elseif ( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
798 if ( $type != RC_NEW ) {
799 $curLink = $this->message['cur'];
800 } else {
801 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
802 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
803 }
804 $diffLink = $this->message['diff'];
805 } else {
806 $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querydiff ) );
807 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
808 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
809 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
810 }
811
812 # Make "last" link
813 if ( !$showdifflinks || !$lastOldid ) {
814 $lastLink = $this->message['last'];
815 } elseif ( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
816 $lastLink = $this->message['last'];
817 } else {
818 $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
819 array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) );
820 }
821
822 # Make user links
823 if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
824 $rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
825 } else {
826 $rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
827 $rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
828 }
829
830 $rc->lastlink = $lastLink;
831 $rc->curlink = $curLink;
832 $rc->difflink = $diffLink;
833
834 # Put accumulated information into the cache, for later display
835 # Page moves go on their own line
836 $title = $rc->getTitle();
837 $secureName = $title->getPrefixedDBkey();
838 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
839 # Use an @ character to prevent collision with page names
840 $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $rc );
841 } else {
842 # Logs are grouped by type
843 if ( $type == RC_LOG ) {
844 $secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
845 }
846 if ( !isset( $this->rc_cache[$secureName] ) ) {
847 $this->rc_cache[$secureName] = array();
848 }
849
850 array_push( $this->rc_cache[$secureName], $rc );
851 }
852
853 wfProfileOut( __METHOD__ );
854
855 return $ret;
856 }
857
858 /**
859 * Enhanced RC group
860 * @return string
861 */
862 protected function recentChangesBlockGroup( $block ) {
863 global $wgRCShowChangedSize;
864
865 wfProfileIn( __METHOD__ );
866
867 # Add the namespace and title of the block as part of the class
868 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
869 if ( $block[0]->mAttribs['rc_log_type'] ) {
870 # Log entry
871 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
872 . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
873 } else {
874 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
875 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
876 }
877 $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
878 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
879 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
880 Html::openElement( 'tr' );
881
882 # Collate list of users
883 $userlinks = array();
884 # Other properties
885 $unpatrolled = false;
886 $isnew = false;
887 $allBots = true;
888 $allMinors = true;
889 $curId = $currentRevision = 0;
890 # Some catalyst variables...
891 $namehidden = true;
892 $allLogs = true;
893 foreach ( $block as $rcObj ) {
894 $oldid = $rcObj->mAttribs['rc_last_oldid'];
895 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
896 $isnew = true;
897 }
898 // If all log actions to this page were hidden, then don't
899 // give the name of the affected page for this block!
900 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
901 $namehidden = false;
902 }
903 $u = $rcObj->userlink;
904 if ( !isset( $userlinks[$u] ) ) {
905 $userlinks[$u] = 0;
906 }
907 if ( $rcObj->unpatrolled ) {
908 $unpatrolled = true;
909 }
910 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
911 $allLogs = false;
912 }
913 # Get the latest entry with a page_id and oldid
914 # since logs may not have these.
915 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
916 $curId = $rcObj->mAttribs['rc_cur_id'];
917 }
918 if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
919 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
920 }
921
922 if ( !$rcObj->mAttribs['rc_bot'] ) {
923 $allBots = false;
924 }
925 if ( !$rcObj->mAttribs['rc_minor'] ) {
926 $allMinors = false;
927 }
928
929 $userlinks[$u]++;
930 }
931
932 # Sort the list and convert to text
933 krsort( $userlinks );
934 asort( $userlinks );
935 $users = array();
936 foreach ( $userlinks as $userlink => $count ) {
937 $text = $userlink;
938 $text .= $this->getLanguage()->getDirMark();
939 if ( $count > 1 ) {
940 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
941 }
942 array_push( $users, $text );
943 }
944
945 $users = ' <span class="changedby">'
946 . $this->msg( 'brackets' )->rawParams(
947 implode( $this->message['semicolon-separator'], $users )
948 )->escaped() . '</span>';
949
950 $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
951 $r .= "<td>$tl</td>";
952
953 # Main line
954 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
955 'newpage' => $isnew, # show, when one have this flag
956 'minor' => $allMinors, # show only, when all have this flag
957 'unpatrolled' => $unpatrolled, # show, when one have this flag
958 'bot' => $allBots, # show only, when all have this flag
959 ) );
960
961 # Timestamp
962 $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
963
964 # Article link
965 if ( $namehidden ) {
966 $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
967 } elseif ( $allLogs ) {
968 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
969 } else {
970 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
971 }
972
973 $r .= $this->getLanguage()->getDirMark();
974
975 $queryParams['curid'] = $curId;
976 # Changes message
977 $n = count( $block );
978 static $nchanges = array();
979 if ( !isset( $nchanges[$n] ) ) {
980 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
981 }
982 # Total change link
983 $r .= ' ';
984 $logtext = '';
985 if ( !$allLogs ) {
986 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
987 $logtext .= $nchanges[$n];
988 } elseif ( $isnew ) {
989 $logtext .= $nchanges[$n];
990 } else {
991 $params = $queryParams;
992 $params['diff'] = $currentRevision;
993 $params['oldid'] = $oldid;
994
995 $logtext .= Linker::link(
996 $block[0]->getTitle(),
997 $nchanges[$n],
998 array(),
999 $params,
1000 array( 'known', 'noclasses' )
1001 );
1002 }
1003 }
1004
1005 # History
1006 if ( $allLogs ) {
1007 // don't show history link for logs
1008 } elseif ( $namehidden || !$block[0]->getTitle()->exists() ) {
1009 $logtext .= $this->message['pipe-separator'] . $this->message['hist'];
1010 } else {
1011 $params = $queryParams;
1012 $params['action'] = 'history';
1013
1014 $logtext .= $this->message['pipe-separator'] .
1015 Linker::linkKnown(
1016 $block[0]->getTitle(),
1017 $this->message['hist'],
1018 array(),
1019 $params
1020 );
1021 }
1022
1023 if ( $logtext !== '' ) {
1024 $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
1025 }
1026
1027 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1028
1029 # Character difference (does not apply if only log items)
1030 if ( $wgRCShowChangedSize && !$allLogs ) {
1031 $last = 0;
1032 $first = count( $block ) - 1;
1033 # Some events (like logs) have an "empty" size, so we need to skip those...
1034 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
1035 $last++;
1036 }
1037 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
1038 $first--;
1039 }
1040 # Get net change
1041 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
1042
1043 if ( $chardiff == '' ) {
1044 $r .= ' ';
1045 } else {
1046 $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
1047 }
1048 }
1049
1050 $r .= $users;
1051 $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
1052
1053 # Sub-entries
1054 foreach ( $block as $rcObj ) {
1055 # Classes to apply -- TODO implement
1056 $classes = array();
1057 $type = $rcObj->mAttribs['rc_type'];
1058
1059 $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
1060 ? ' class="mw-enhanced-watched"' : '';
1061
1062 $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
1063 $r .= $this->recentChangesFlags( array(
1064 'newpage' => $type == RC_NEW,
1065 'minor' => $rcObj->mAttribs['rc_minor'],
1066 'unpatrolled' => $rcObj->unpatrolled,
1067 'bot' => $rcObj->mAttribs['rc_bot'],
1068 ) );
1069 $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
1070
1071 $params = $queryParams;
1072
1073 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
1074 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
1075 }
1076
1077 # Log timestamp
1078 if ( $type == RC_LOG ) {
1079 $link = $rcObj->timestamp;
1080 # Revision link
1081 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
1082 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
1083 } else {
1084
1085 $link = Linker::linkKnown(
1086 $rcObj->getTitle(),
1087 $rcObj->timestamp,
1088 array(),
1089 $params
1090 );
1091 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
1092 $link = '<span class="history-deleted">' . $link . '</span> ';
1093 }
1094 }
1095 $r .= $link . '</span>';
1096
1097 if ( !$type == RC_LOG || $type == RC_NEW ) {
1098 $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped();
1099 }
1100 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1101
1102 # Character diff
1103 if ( $wgRCShowChangedSize ) {
1104 $cd = $this->formatCharacterDifference( $rcObj );
1105 if ( $cd !== '' ) {
1106 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
1107 }
1108 }
1109
1110 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
1111 $r .= $this->insertLogEntry( $rcObj );
1112 } else {
1113 # User links
1114 $r .= $rcObj->userlink;
1115 $r .= $rcObj->usertalklink;
1116 $r .= $this->insertComment( $rcObj );
1117 }
1118
1119 # Rollback
1120 $this->insertRollback( $r, $rcObj );
1121 # Tags
1122 $this->insertTags( $r, $rcObj, $classes );
1123
1124 $r .= "</td></tr>\n";
1125 }
1126 $r .= "</table>\n";
1127
1128 $this->rcCacheIndex++;
1129
1130 wfProfileOut( __METHOD__ );
1131
1132 return $r;
1133 }
1134
1135 /**
1136 * Generate HTML for an arrow or placeholder graphic
1137 * @param string $dir one of '', 'd', 'l', 'r'
1138 * @param string $alt text
1139 * @param string $title text
1140 * @return String: HTML "<img>" tag
1141 */
1142 protected function arrow( $dir, $alt = '', $title = '' ) {
1143 global $wgStylePath;
1144 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
1145 $encAlt = htmlspecialchars( $alt );
1146 $encTitle = htmlspecialchars( $title );
1147 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
1148 }
1149
1150 /**
1151 * Generate HTML for a right- or left-facing arrow,
1152 * depending on language direction.
1153 * @return String: HTML "<img>" tag
1154 */
1155 protected function sideArrow() {
1156 $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
1157 return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
1158 }
1159
1160 /**
1161 * Generate HTML for a down-facing arrow
1162 * depending on language direction.
1163 * @return String: HTML "<img>" tag
1164 */
1165 protected function downArrow() {
1166 return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
1167 }
1168
1169 /**
1170 * Generate HTML for a spacer image
1171 * @return String: HTML "<img>" tag
1172 */
1173 protected function spacerArrow() {
1174 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
1175 }
1176
1177 /**
1178 * Enhanced RC ungrouped line.
1179 *
1180 * @param $rcObj RecentChange
1181 * @return String: a HTML formatted line (generated using $r)
1182 */
1183 protected function recentChangesBlockLine( $rcObj ) {
1184 global $wgRCShowChangedSize;
1185
1186 wfProfileIn( __METHOD__ );
1187 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
1188
1189 $type = $rcObj->mAttribs['rc_type'];
1190 $logType = $rcObj->mAttribs['rc_log_type'];
1191 $classes = array( 'mw-enhanced-rc' );
1192 if ( $logType ) {
1193 # Log entry
1194 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
1195 . $logType . '-' . $rcObj->mAttribs['rc_title'] );
1196 } else {
1197 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
1198 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
1199 }
1200 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
1201 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
1202 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
1203 Html::openElement( 'tr' );
1204
1205 $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
1206 # Flag and Timestamp
1207 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
1208 $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
1209 } else {
1210 $r .= $this->recentChangesFlags( array(
1211 'newpage' => $type == RC_NEW,
1212 'minor' => $rcObj->mAttribs['rc_minor'],
1213 'unpatrolled' => $rcObj->unpatrolled,
1214 'bot' => $rcObj->mAttribs['rc_bot'],
1215 ) );
1216 }
1217 $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
1218 # Article or log link
1219 if ( $logType ) {
1220 $logPage = new LogPage( $logType );
1221 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
1222 $logName = $logPage->getName()->escaped();
1223 $r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
1224 } else {
1225 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
1226 }
1227 # Diff and hist links
1228 if ( $type != RC_LOG ) {
1229 $query['action'] = 'history';
1230 $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
1231 $rcObj->getTitle(),
1232 $this->message['hist'],
1233 array(),
1234 $query
1235 ) )->escaped();
1236 }
1237 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1238 # Character diff
1239 if ( $wgRCShowChangedSize ) {
1240 $cd = $this->formatCharacterDifference( $rcObj );
1241 if ( $cd !== '' ) {
1242 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
1243 }
1244 }
1245
1246 if ( $type == RC_LOG ) {
1247 $r .= $this->insertLogEntry( $rcObj );
1248 } else {
1249 $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink;
1250 $r .= $this->insertComment( $rcObj );
1251 $this->insertRollback( $r, $rcObj );
1252 }
1253
1254 # Tags
1255 $this->insertTags( $r, $rcObj, $classes );
1256 # Show how many people are watching this if enabled
1257 $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
1258
1259 $r .= "</td></tr></table>\n";
1260
1261 wfProfileOut( __METHOD__ );
1262
1263 return $r;
1264 }
1265
1266 /**
1267 * If enhanced RC is in use, this function takes the previously cached
1268 * RC lines, arranges them, and outputs the HTML
1269 *
1270 * @return string
1271 */
1272 protected function recentChangesBlock() {
1273 if ( count ( $this->rc_cache ) == 0 ) {
1274 return '';
1275 }
1276
1277 wfProfileIn( __METHOD__ );
1278
1279 $blockOut = '';
1280 foreach ( $this->rc_cache as $block ) {
1281 if ( count( $block ) < 2 ) {
1282 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1283 } else {
1284 $blockOut .= $this->recentChangesBlockGroup( $block );
1285 }
1286 }
1287
1288 wfProfileOut( __METHOD__ );
1289
1290 return '<div>' . $blockOut . '</div>';
1291 }
1292
1293 /**
1294 * Returns text for the end of RC
1295 * If enhanced RC is in use, returns pretty much all the text
1296 * @return string
1297 */
1298 public function endRecentChangesList() {
1299 return $this->recentChangesBlock() . parent::endRecentChangesList();
1300 }
1301
1302 }