Merge "Add Special:Login and Special:Logout as aliases."
[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 *
460 * @deprecated since 1.22
461 * @return Boolean
462 */
463 public static function usePatrol() {
464 global $wgUser;
465
466 wfDeprecated( __METHOD__, '1.22' );
467
468 return $wgUser->useRCPatrol();
469 }
470
471 /**
472 * Returns the string which indicates the number of watching users
473 * @return string
474 */
475 protected function numberofWatchingusers( $count ) {
476 static $cache = array();
477 if ( $count > 0 ) {
478 if ( !isset( $cache[$count] ) ) {
479 $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
480 }
481 return $cache[$count];
482 } else {
483 return '';
484 }
485 }
486
487 /**
488 * Determine if said field of a revision is hidden
489 * @param $rc RCCacheEntry
490 * @param $field Integer: one of DELETED_* bitfield constants
491 * @return Boolean
492 */
493 public static function isDeleted( $rc, $field ) {
494 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
495 }
496
497 /**
498 * Determine if the current user is allowed to view a particular
499 * field of this revision, if it's marked as deleted.
500 * @param $rc RCCacheEntry
501 * @param $field Integer
502 * @param $user User object to check, or null to use $wgUser
503 * @return Boolean
504 */
505 public static function userCan( $rc, $field, User $user = null ) {
506 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
507 return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
508 } else {
509 return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
510 }
511 }
512
513 /**
514 * @param $link string
515 * @param $watched bool
516 * @return string
517 */
518 protected function maybeWatchedLink( $link, $watched = false ) {
519 if ( $watched ) {
520 return '<strong class="mw-watched">' . $link . '</strong>';
521 } else {
522 return '<span class="mw-rc-unwatched">' . $link . '</span>';
523 }
524 }
525
526 /** Inserts a rollback link
527 *
528 * @param $s string
529 * @param $rc RecentChange
530 */
531 public function insertRollback( &$s, &$rc ) {
532 if ( $rc->mAttribs['rc_type'] == RC_EDIT && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
533 $page = $rc->getTitle();
534 /** Check for rollback and edit permissions, disallow special pages, and only
535 * show a link on the top-most revision */
536 if ( $this->getUser()->isAllowed( 'rollback' ) && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
537 {
538 $rev = new Revision( array(
539 'title' => $page,
540 'id' => $rc->mAttribs['rc_this_oldid'],
541 'user' => $rc->mAttribs['rc_user'],
542 'user_text' => $rc->mAttribs['rc_user_text'],
543 'deleted' => $rc->mAttribs['rc_deleted']
544 ) );
545 $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
546 }
547 }
548 }
549
550 /**
551 * @param $s string
552 * @param $rc RecentChange
553 * @param $classes
554 */
555 public function insertTags( &$s, &$rc, &$classes ) {
556 if ( empty( $rc->mAttribs['ts_tags'] ) ) {
557 return;
558 }
559
560 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
561 $classes = array_merge( $classes, $newClasses );
562 $s .= ' ' . $tagSummary;
563 }
564
565 public function insertExtra( &$s, &$rc, &$classes ) {
566 // Empty, used for subclasses to add anything special.
567 }
568
569 protected function showAsUnpatrolled( RecentChange $rc ) {
570 $unpatrolled = false;
571 if ( !$rc->mAttribs['rc_patrolled'] ) {
572 if ( $this->getUser()->useRCPatrol() ) {
573 $unpatrolled = true;
574 } elseif ( $this->getUser()->useNPPatrol() && $rc->mAttribs['rc_type'] == RC_NEW ) {
575 $unpatrolled = true;
576 }
577 }
578 return $unpatrolled;
579 }
580 }
581
582 /**
583 * Generate a list of changes using the good old system (no javascript)
584 */
585 class OldChangesList extends ChangesList {
586 /**
587 * Format a line using the old system (aka without any javascript).
588 *
589 * @param $rc RecentChange, passed by reference
590 * @param bool $watched (default false)
591 * @param int $linenumber (default null)
592 *
593 * @return string|bool
594 */
595 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
596 global $wgRCShowChangedSize;
597 wfProfileIn( __METHOD__ );
598
599 # Should patrol-related stuff be shown?
600 $unpatrolled = $this->showAsUnpatrolled( $rc );
601
602 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
603 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
604
605 $s = '';
606 $classes = array();
607 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
608 if ( $linenumber ) {
609 if ( $linenumber & 1 ) {
610 $classes[] = 'mw-line-odd';
611 } else {
612 $classes[] = 'mw-line-even';
613 }
614 }
615
616 // Indicate watched status on the line to allow for more
617 // comprehensive styling.
618 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
619 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
620
621 // Moved pages (very very old, not supported anymore)
622 if ( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
623 // Log entries
624 } elseif ( $rc->mAttribs['rc_log_type'] ) {
625 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
626 $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
627 // Log entries (old format) or log targets, and special pages
628 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
629 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
630 if ( $name == 'Log' ) {
631 $this->insertLog( $s, $rc->getTitle(), $subpage );
632 }
633 // Regular entries
634 } else {
635 $this->insertDiffHist( $s, $rc, $unpatrolled );
636 # M, N, b and ! (minor, new, bot and unpatrolled)
637 $s .= $this->recentChangesFlags(
638 array(
639 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
640 'minor' => $rc->mAttribs['rc_minor'],
641 'unpatrolled' => $unpatrolled,
642 'bot' => $rc->mAttribs['rc_bot']
643 ),
644 ''
645 );
646 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
647 }
648 # Edit/log timestamp
649 $this->insertTimestamp( $s, $rc );
650 # Bytes added or removed
651 if ( $wgRCShowChangedSize ) {
652 $cd = $this->formatCharacterDifference( $rc );
653 if ( $cd !== '' ) {
654 $s .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
655 }
656 }
657
658 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
659 $s .= $this->insertLogEntry( $rc );
660 } else {
661 # User tool links
662 $this->insertUserRelatedLinks( $s, $rc );
663 # LTR/RTL direction mark
664 $s .= $this->getLanguage()->getDirMark();
665 $s .= $this->insertComment( $rc );
666 }
667
668 # Tags
669 $this->insertTags( $s, $rc, $classes );
670 # Rollback
671 $this->insertRollback( $s, $rc );
672 # For subclasses
673 $this->insertExtra( $s, $rc, $classes );
674
675 # How many users watch this page
676 if ( $rc->numberofWatchingusers > 0 ) {
677 $s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
678 }
679
680 if ( $this->watchlist ) {
681 $classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
682 }
683
684 if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc, &$classes ) ) ) {
685 wfProfileOut( __METHOD__ );
686 return false;
687 }
688
689 wfProfileOut( __METHOD__ );
690 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $s . "</li>\n";
691 }
692 }
693
694 /**
695 * Generate a list of changes using an Enhanced system (uses javascript).
696 */
697 class EnhancedChangesList extends ChangesList {
698
699 protected $rc_cache;
700
701 /**
702 * Add the JavaScript file for enhanced changeslist
703 * @return String
704 */
705 public function beginRecentChangesList() {
706 $this->rc_cache = array();
707 $this->rcMoveIndex = 0;
708 $this->rcCacheIndex = 0;
709 $this->lastdate = '';
710 $this->rclistOpen = false;
711 $this->getOutput()->addModuleStyles( array(
712 'mediawiki.special.changeslist',
713 'mediawiki.special.changeslist.enhanced',
714 ) );
715 $this->getOutput()->addModules( array(
716 'jquery.makeCollapsible',
717 'mediawiki.icon',
718 ) );
719 return '';
720 }
721 /**
722 * Format a line for enhanced recentchange (aka with javascript and block of lines).
723 *
724 * @param $baseRC RecentChange
725 * @param $watched bool
726 *
727 * @return string
728 */
729 public function recentChangesLine( &$baseRC, $watched = false ) {
730 wfProfileIn( __METHOD__ );
731
732 # Create a specialised object
733 $rc = RCCacheEntry::newFromParent( $baseRC );
734
735 $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
736
737 # If it's a new day, add the headline and flush the cache
738 $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
739 $ret = '';
740 if ( $date != $this->lastdate ) {
741 # Process current cache
742 $ret = $this->recentChangesBlock();
743 $this->rc_cache = array();
744 $ret .= Xml::element( 'h4', null, $date ) . "\n";
745 $this->lastdate = $date;
746 }
747
748 # Should patrol-related stuff be shown?
749 $rc->unpatrolled = $this->showAsUnpatrolled( $rc );
750
751 $showdifflinks = true;
752 # Make article link
753 $type = $rc->mAttribs['rc_type'];
754 $logType = $rc->mAttribs['rc_log_type'];
755 // Page moves, very old style, not supported anymore
756 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
757 // New unpatrolled pages
758 } elseif ( $rc->unpatrolled && $type == RC_NEW ) {
759 $clink = Linker::linkKnown( $rc->getTitle() );
760 // Log entries
761 } elseif ( $type == RC_LOG ) {
762 if ( $logType ) {
763 $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
764 $logpage = new LogPage( $logType );
765 $logname = $logpage->getName()->escaped();
766 $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped();
767 } else {
768 $clink = Linker::link( $rc->getTitle() );
769 }
770 $watched = false;
771 // Log entries (old format) and special pages
772 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
773 wfDebug( "Unexpected special page in recentchanges\n" );
774 $clink = '';
775 // Edits
776 } else {
777 $clink = Linker::linkKnown( $rc->getTitle() );
778 }
779
780 # Don't show unusable diff links
781 if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
782 $showdifflinks = false;
783 }
784
785 $time = $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() );
786 $rc->watched = $watched;
787 $rc->link = $clink;
788 $rc->timestamp = $time;
789 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
790
791 # Make "cur" and "diff" links. Do not use link(), it is too slow if
792 # called too many times (50% of CPU time on RecentChanges!).
793 $thisOldid = $rc->mAttribs['rc_this_oldid'];
794 $lastOldid = $rc->mAttribs['rc_last_oldid'];
795
796 $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid );
797 $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid );
798
799 if ( !$showdifflinks ) {
800 $curLink = $this->message['cur'];
801 $diffLink = $this->message['diff'];
802 } elseif ( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
803 if ( $type != RC_NEW ) {
804 $curLink = $this->message['cur'];
805 } else {
806 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
807 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
808 }
809 $diffLink = $this->message['diff'];
810 } else {
811 $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querydiff ) );
812 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
813 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
814 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
815 }
816
817 # Make "last" link
818 if ( !$showdifflinks || !$lastOldid ) {
819 $lastLink = $this->message['last'];
820 } elseif ( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
821 $lastLink = $this->message['last'];
822 } else {
823 $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
824 array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) );
825 }
826
827 # Make user links
828 if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
829 $rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
830 } else {
831 $rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
832 $rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
833 }
834
835 $rc->lastlink = $lastLink;
836 $rc->curlink = $curLink;
837 $rc->difflink = $diffLink;
838
839 # Put accumulated information into the cache, for later display
840 # Page moves go on their own line
841 $title = $rc->getTitle();
842 $secureName = $title->getPrefixedDBkey();
843 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
844 # Use an @ character to prevent collision with page names
845 $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $rc );
846 } else {
847 # Logs are grouped by type
848 if ( $type == RC_LOG ) {
849 $secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
850 }
851 if ( !isset( $this->rc_cache[$secureName] ) ) {
852 $this->rc_cache[$secureName] = array();
853 }
854
855 array_push( $this->rc_cache[$secureName], $rc );
856 }
857
858 wfProfileOut( __METHOD__ );
859
860 return $ret;
861 }
862
863 /**
864 * Enhanced RC group
865 * @return string
866 */
867 protected function recentChangesBlockGroup( $block ) {
868 global $wgRCShowChangedSize;
869
870 wfProfileIn( __METHOD__ );
871
872 # Add the namespace and title of the block as part of the class
873 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
874 if ( $block[0]->mAttribs['rc_log_type'] ) {
875 # Log entry
876 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
877 . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
878 } else {
879 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
880 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
881 }
882 $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
883 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
884 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
885 Html::openElement( 'tr' );
886
887 # Collate list of users
888 $userlinks = array();
889 # Other properties
890 $unpatrolled = false;
891 $isnew = false;
892 $allBots = true;
893 $allMinors = true;
894 $curId = $currentRevision = 0;
895 # Some catalyst variables...
896 $namehidden = true;
897 $allLogs = true;
898 foreach ( $block as $rcObj ) {
899 $oldid = $rcObj->mAttribs['rc_last_oldid'];
900 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
901 $isnew = true;
902 }
903 // If all log actions to this page were hidden, then don't
904 // give the name of the affected page for this block!
905 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
906 $namehidden = false;
907 }
908 $u = $rcObj->userlink;
909 if ( !isset( $userlinks[$u] ) ) {
910 $userlinks[$u] = 0;
911 }
912 if ( $rcObj->unpatrolled ) {
913 $unpatrolled = true;
914 }
915 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
916 $allLogs = false;
917 }
918 # Get the latest entry with a page_id and oldid
919 # since logs may not have these.
920 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
921 $curId = $rcObj->mAttribs['rc_cur_id'];
922 }
923 if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
924 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
925 }
926
927 if ( !$rcObj->mAttribs['rc_bot'] ) {
928 $allBots = false;
929 }
930 if ( !$rcObj->mAttribs['rc_minor'] ) {
931 $allMinors = false;
932 }
933
934 $userlinks[$u]++;
935 }
936
937 # Sort the list and convert to text
938 krsort( $userlinks );
939 asort( $userlinks );
940 $users = array();
941 foreach ( $userlinks as $userlink => $count ) {
942 $text = $userlink;
943 $text .= $this->getLanguage()->getDirMark();
944 if ( $count > 1 ) {
945 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
946 }
947 array_push( $users, $text );
948 }
949
950 $users = ' <span class="changedby">'
951 . $this->msg( 'brackets' )->rawParams(
952 implode( $this->message['semicolon-separator'], $users )
953 )->escaped() . '</span>';
954
955 $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
956 $r .= "<td>$tl</td>";
957
958 # Main line
959 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
960 'newpage' => $isnew, # show, when one have this flag
961 'minor' => $allMinors, # show only, when all have this flag
962 'unpatrolled' => $unpatrolled, # show, when one have this flag
963 'bot' => $allBots, # show only, when all have this flag
964 ) );
965
966 # Timestamp
967 $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
968
969 # Article link
970 if ( $namehidden ) {
971 $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
972 } elseif ( $allLogs ) {
973 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
974 } else {
975 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
976 }
977
978 $r .= $this->getLanguage()->getDirMark();
979
980 $queryParams['curid'] = $curId;
981 # Changes message
982 $n = count( $block );
983 static $nchanges = array();
984 if ( !isset( $nchanges[$n] ) ) {
985 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
986 }
987 # Total change link
988 $r .= ' ';
989 $logtext = '';
990 if ( !$allLogs ) {
991 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
992 $logtext .= $nchanges[$n];
993 } elseif ( $isnew ) {
994 $logtext .= $nchanges[$n];
995 } else {
996 $params = $queryParams;
997 $params['diff'] = $currentRevision;
998 $params['oldid'] = $oldid;
999
1000 $logtext .= Linker::link(
1001 $block[0]->getTitle(),
1002 $nchanges[$n],
1003 array(),
1004 $params,
1005 array( 'known', 'noclasses' )
1006 );
1007 }
1008 }
1009
1010 # History
1011 if ( $allLogs ) {
1012 // don't show history link for logs
1013 } elseif ( $namehidden || !$block[0]->getTitle()->exists() ) {
1014 $logtext .= $this->message['pipe-separator'] . $this->message['hist'];
1015 } else {
1016 $params = $queryParams;
1017 $params['action'] = 'history';
1018
1019 $logtext .= $this->message['pipe-separator'] .
1020 Linker::linkKnown(
1021 $block[0]->getTitle(),
1022 $this->message['hist'],
1023 array(),
1024 $params
1025 );
1026 }
1027
1028 if ( $logtext !== '' ) {
1029 $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
1030 }
1031
1032 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1033
1034 # Character difference (does not apply if only log items)
1035 if ( $wgRCShowChangedSize && !$allLogs ) {
1036 $last = 0;
1037 $first = count( $block ) - 1;
1038 # Some events (like logs) have an "empty" size, so we need to skip those...
1039 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
1040 $last++;
1041 }
1042 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
1043 $first--;
1044 }
1045 # Get net change
1046 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
1047
1048 if ( $chardiff == '' ) {
1049 $r .= ' ';
1050 } else {
1051 $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
1052 }
1053 }
1054
1055 $r .= $users;
1056 $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
1057
1058 # Sub-entries
1059 foreach ( $block as $rcObj ) {
1060 # Classes to apply -- TODO implement
1061 $classes = array();
1062 $type = $rcObj->mAttribs['rc_type'];
1063
1064 $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
1065 ? ' class="mw-enhanced-watched"' : '';
1066
1067 $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
1068 $r .= $this->recentChangesFlags( array(
1069 'newpage' => $type == RC_NEW,
1070 'minor' => $rcObj->mAttribs['rc_minor'],
1071 'unpatrolled' => $rcObj->unpatrolled,
1072 'bot' => $rcObj->mAttribs['rc_bot'],
1073 ) );
1074 $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
1075
1076 $params = $queryParams;
1077
1078 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
1079 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
1080 }
1081
1082 # Log timestamp
1083 if ( $type == RC_LOG ) {
1084 $link = $rcObj->timestamp;
1085 # Revision link
1086 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
1087 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
1088 } else {
1089
1090 $link = Linker::linkKnown(
1091 $rcObj->getTitle(),
1092 $rcObj->timestamp,
1093 array(),
1094 $params
1095 );
1096 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
1097 $link = '<span class="history-deleted">' . $link . '</span> ';
1098 }
1099 }
1100 $r .= $link . '</span>';
1101
1102 if ( !$type == RC_LOG || $type == RC_NEW ) {
1103 $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped();
1104 }
1105 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1106
1107 # Character diff
1108 if ( $wgRCShowChangedSize ) {
1109 $cd = $this->formatCharacterDifference( $rcObj );
1110 if ( $cd !== '' ) {
1111 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
1112 }
1113 }
1114
1115 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
1116 $r .= $this->insertLogEntry( $rcObj );
1117 } else {
1118 # User links
1119 $r .= $rcObj->userlink;
1120 $r .= $rcObj->usertalklink;
1121 $r .= $this->insertComment( $rcObj );
1122 }
1123
1124 # Rollback
1125 $this->insertRollback( $r, $rcObj );
1126 # Tags
1127 $this->insertTags( $r, $rcObj, $classes );
1128
1129 $r .= "</td></tr>\n";
1130 }
1131 $r .= "</table>\n";
1132
1133 $this->rcCacheIndex++;
1134
1135 wfProfileOut( __METHOD__ );
1136
1137 return $r;
1138 }
1139
1140 /**
1141 * Generate HTML for an arrow or placeholder graphic
1142 * @param string $dir one of '', 'd', 'l', 'r'
1143 * @param string $alt text
1144 * @param string $title text
1145 * @return String: HTML "<img>" tag
1146 */
1147 protected function arrow( $dir, $alt = '', $title = '' ) {
1148 global $wgStylePath;
1149 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
1150 $encAlt = htmlspecialchars( $alt );
1151 $encTitle = htmlspecialchars( $title );
1152 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
1153 }
1154
1155 /**
1156 * Generate HTML for a right- or left-facing arrow,
1157 * depending on language direction.
1158 * @return String: HTML "<img>" tag
1159 */
1160 protected function sideArrow() {
1161 $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
1162 return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
1163 }
1164
1165 /**
1166 * Generate HTML for a down-facing arrow
1167 * depending on language direction.
1168 * @return String: HTML "<img>" tag
1169 */
1170 protected function downArrow() {
1171 return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
1172 }
1173
1174 /**
1175 * Generate HTML for a spacer image
1176 * @return String: HTML "<img>" tag
1177 */
1178 protected function spacerArrow() {
1179 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
1180 }
1181
1182 /**
1183 * Enhanced RC ungrouped line.
1184 *
1185 * @param $rcObj RecentChange
1186 * @return String: a HTML formatted line (generated using $r)
1187 */
1188 protected function recentChangesBlockLine( $rcObj ) {
1189 global $wgRCShowChangedSize;
1190
1191 wfProfileIn( __METHOD__ );
1192 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
1193
1194 $type = $rcObj->mAttribs['rc_type'];
1195 $logType = $rcObj->mAttribs['rc_log_type'];
1196 $classes = array( 'mw-enhanced-rc' );
1197 if ( $logType ) {
1198 # Log entry
1199 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
1200 . $logType . '-' . $rcObj->mAttribs['rc_title'] );
1201 } else {
1202 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
1203 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
1204 }
1205 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
1206 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
1207 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
1208 Html::openElement( 'tr' );
1209
1210 $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
1211 # Flag and Timestamp
1212 if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
1213 $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
1214 } else {
1215 $r .= $this->recentChangesFlags( array(
1216 'newpage' => $type == RC_NEW,
1217 'minor' => $rcObj->mAttribs['rc_minor'],
1218 'unpatrolled' => $rcObj->unpatrolled,
1219 'bot' => $rcObj->mAttribs['rc_bot'],
1220 ) );
1221 }
1222 $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
1223 # Article or log link
1224 if ( $logType ) {
1225 $logPage = new LogPage( $logType );
1226 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
1227 $logName = $logPage->getName()->escaped();
1228 $r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
1229 } else {
1230 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
1231 }
1232 # Diff and hist links
1233 if ( $type != RC_LOG ) {
1234 $query['action'] = 'history';
1235 $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
1236 $rcObj->getTitle(),
1237 $this->message['hist'],
1238 array(),
1239 $query
1240 ) )->escaped();
1241 }
1242 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1243 # Character diff
1244 if ( $wgRCShowChangedSize ) {
1245 $cd = $this->formatCharacterDifference( $rcObj );
1246 if ( $cd !== '' ) {
1247 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
1248 }
1249 }
1250
1251 if ( $type == RC_LOG ) {
1252 $r .= $this->insertLogEntry( $rcObj );
1253 } else {
1254 $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink;
1255 $r .= $this->insertComment( $rcObj );
1256 $this->insertRollback( $r, $rcObj );
1257 }
1258
1259 # Tags
1260 $this->insertTags( $r, $rcObj, $classes );
1261 # Show how many people are watching this if enabled
1262 $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
1263
1264 $r .= "</td></tr></table>\n";
1265
1266 wfProfileOut( __METHOD__ );
1267
1268 return $r;
1269 }
1270
1271 /**
1272 * If enhanced RC is in use, this function takes the previously cached
1273 * RC lines, arranges them, and outputs the HTML
1274 *
1275 * @return string
1276 */
1277 protected function recentChangesBlock() {
1278 if ( count ( $this->rc_cache ) == 0 ) {
1279 return '';
1280 }
1281
1282 wfProfileIn( __METHOD__ );
1283
1284 $blockOut = '';
1285 foreach ( $this->rc_cache as $block ) {
1286 if ( count( $block ) < 2 ) {
1287 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1288 } else {
1289 $blockOut .= $this->recentChangesBlockGroup( $block );
1290 }
1291 }
1292
1293 wfProfileOut( __METHOD__ );
1294
1295 return '<div>' . $blockOut . '</div>';
1296 }
1297
1298 /**
1299 * Returns text for the end of RC
1300 * If enhanced RC is in use, returns pretty much all the text
1301 * @return string
1302 */
1303 public function endRecentChangesList() {
1304 return $this->recentChangesBlock() . parent::endRecentChangesList();
1305 }
1306
1307 }