Merge "Hook to allow manipulation of image data"
[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 contructor
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 $unused string|User 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 ( explode( ' ', 'cur diff hist last blocklink history ' .
125 'semicolon-separator pipe-separator' ) as $msg ) {
126 $this->message[$msg] = $this->msg( $msg )->escaped();
127 }
128 }
129 }
130
131 /**
132 * Returns the appropriate flags for new page, minor change and patrolling
133 * @param $flags Array Associative array of 'flag' => Bool
134 * @param $nothing String to use for empty space
135 * @return String
136 */
137 protected function recentChangesFlags( $flags, $nothing = '&#160;' ) {
138 $f = '';
139 foreach( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ){
140 $f .= isset( $flags[$flag] ) && $flags[$flag]
141 ? self::flag( $flag )
142 : $nothing;
143 }
144 return $f;
145 }
146
147 /**
148 * Provide the "<abbr>" element appropriate to a given abbreviated flag,
149 * namely the flag indicating a new page, a minor edit, a bot edit, or an
150 * unpatrolled edit. By default in English it will contain "N", "m", "b",
151 * "!" respectively, plus it will have an appropriate title and class.
152 *
153 * @param $flag String: 'newpage', 'unpatrolled', 'minor', or 'bot'
154 * @return String: Raw HTML
155 */
156 public static function flag( $flag ) {
157 static $messages = null;
158 if ( is_null( $messages ) ) {
159 $messages = array(
160 'newpage' => array( 'newpageletter', 'recentchanges-label-newpage' ),
161 'minoredit' => array( 'minoreditletter', 'recentchanges-label-minor' ),
162 'botedit' => array( 'boteditletter', 'recentchanges-label-bot' ),
163 'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ),
164 );
165 foreach( $messages as &$value ) {
166 $value[0] = wfMessage( $value[0] )->escaped();
167 $value[1] = wfMessage( $value[1] )->escaped();
168 }
169 }
170
171 # Inconsistent naming, bleh
172 $map = array(
173 'newpage' => 'newpage',
174 'minor' => 'minoredit',
175 'bot' => 'botedit',
176 'unpatrolled' => 'unpatrolled',
177 'minoredit' => 'minoredit',
178 'botedit' => 'botedit',
179 );
180 $flag = $map[$flag];
181
182 return "<abbr class='$flag' title='" . $messages[$flag][1] . "'>" . $messages[$flag][0] . '</abbr>';
183 }
184
185 /**
186 * Returns text for the start of the tabular part of RC
187 * @return String
188 */
189 public function beginRecentChangesList() {
190 $this->rc_cache = array();
191 $this->rcMoveIndex = 0;
192 $this->rcCacheIndex = 0;
193 $this->lastdate = '';
194 $this->rclistOpen = false;
195 $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
196 return '';
197 }
198
199 /**
200 * Show formatted char difference
201 * @param $old Integer: bytes
202 * @param $new Integer: bytes
203 * @param $context IContextSource context to use
204 * @return String
205 */
206 public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
207 global $wgRCChangedSizeThreshold, $wgMiserMode;
208
209 if ( !$context ) {
210 $context = RequestContext::getMain();
211 }
212
213 $new = (int)$new;
214 $old = (int)$old;
215 $szdiff = $new - $old;
216
217 $lang = $context->getLanguage();
218 $code = $lang->getCode();
219 static $fastCharDiff = array();
220 if ( !isset($fastCharDiff[$code]) ) {
221 $fastCharDiff[$code] = $wgMiserMode || $context->msg( 'rc-change-size' )->plain() === '$1';
222 }
223
224 $formattedSize = $lang->formatNum( $szdiff );
225
226 if ( !$fastCharDiff[$code] ) {
227 $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
228 }
229
230 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
231 $tag = 'strong';
232 } else {
233 $tag = 'span';
234 }
235
236 if ( $szdiff === 0 ) {
237 $formattedSizeClass = 'mw-plusminus-null';
238 }
239 if ( $szdiff > 0 ) {
240 $formattedSize = '+' . $formattedSize;
241 $formattedSizeClass = 'mw-plusminus-pos';
242 }
243 if ( $szdiff < 0 ) {
244 $formattedSizeClass = 'mw-plusminus-neg';
245 }
246
247 $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
248
249 return Html::element( $tag,
250 array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
251 $context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
252 }
253
254 /**
255 * Format the character difference of one or several changes.
256 *
257 * @param $old RecentChange
258 * @param $new RecentChange last change to use, if not provided, $old will be used
259 * @return string HTML fragment
260 */
261 public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
262 $oldlen = $old->mAttribs['rc_old_len'];
263
264 if ( $new ) {
265 $newlen = $new->mAttribs['rc_new_len'];
266 } else {
267 $newlen = $old->mAttribs['rc_new_len'];
268 }
269
270 if( $oldlen === null || $newlen === null ) {
271 return '';
272 }
273
274 return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
275 }
276
277 /**
278 * Returns text for the end of RC
279 * @return String
280 */
281 public function endRecentChangesList() {
282 if( $this->rclistOpen ) {
283 return "</ul>\n";
284 } else {
285 return '';
286 }
287 }
288
289 /**
290 * @param $s string HTML to update
291 * @param $rc_timestamp mixed
292 */
293 public function insertDateHeader( &$s, $rc_timestamp ) {
294 # Make date header if necessary
295 $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
296 if( $date != $this->lastdate ) {
297 if( $this->lastdate != '' ) {
298 $s .= "</ul>\n";
299 }
300 $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
301 $this->lastdate = $date;
302 $this->rclistOpen = true;
303 }
304 }
305
306 /**
307 * @param $s string HTML to update
308 * @param $title Title
309 * @param $logtype string
310 */
311 public function insertLog( &$s, $title, $logtype ) {
312 $page = new LogPage( $logtype );
313 $logname = $page->getName()->escaped();
314 $s .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $title, $logname ) )->escaped();
315 }
316
317 /**
318 * @param $s string HTML to update
319 * @param $rc RecentChange
320 * @param $unpatrolled
321 */
322 public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
323 # Diff link
324 if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
325 $diffLink = $this->message['diff'];
326 } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
327 $diffLink = $this->message['diff'];
328 } else {
329 $query = array(
330 'curid' => $rc->mAttribs['rc_cur_id'],
331 'diff' => $rc->mAttribs['rc_this_oldid'],
332 'oldid' => $rc->mAttribs['rc_last_oldid']
333 );
334
335 if( $unpatrolled ) {
336 $query['rcid'] = $rc->mAttribs['rc_id'];
337 };
338
339 $diffLink = Linker::linkKnown(
340 $rc->getTitle(),
341 $this->message['diff'],
342 array( 'tabindex' => $rc->counter ),
343 $query
344 );
345 }
346 $diffhist = $diffLink . $this->message['pipe-separator'];
347 # History link
348 $diffhist .= Linker::linkKnown(
349 $rc->getTitle(),
350 $this->message['hist'],
351 array(),
352 array(
353 'curid' => $rc->mAttribs['rc_cur_id'],
354 'action' => 'history'
355 )
356 );
357 $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . ' <span class="mw-changeslist-separator">. .</span> ';
358 }
359
360 /**
361 * @param $s string HTML to update
362 * @param $rc RecentChange
363 * @param $unpatrolled
364 * @param $watched
365 */
366 public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
367 # If it's a new article, there is no diff link, but if it hasn't been
368 # patrolled yet, we need to give users a way to do so
369 $params = array();
370
371 if ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) {
372 $params['rcid'] = $rc->mAttribs['rc_id'];
373 }
374
375 $articlelink = Linker::linkKnown(
376 $rc->getTitle(),
377 null,
378 array( 'class' => 'mw-changeslist-title' ),
379 $params
380 );
381 if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
382 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
383 }
384 # To allow for boldening pages watched by this user
385 $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
386 # RTL/LTR marker
387 $articlelink .= $this->getLanguage()->getDirMark();
388
389 wfRunHooks( 'ChangesListInsertArticleLink',
390 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
391
392 $s .= " $articlelink";
393 }
394
395 /**
396 * Get the timestamp from $rc formatted with current user's settings
397 * and a separator
398 *
399 * @param $rc RecentChange
400 * @return string HTML fragment
401 */
402 public function getTimestamp( $rc ) {
403 return $this->message['semicolon-separator'] . '<span class="mw-changeslist-date">' .
404 $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
405 }
406
407 /**
408 * Insert time timestamp string from $rc into $s
409 *
410 * @param $s string HTML to update
411 * @param $rc RecentChange
412 */
413 public function insertTimestamp( &$s, $rc ) {
414 $s .= $this->getTimestamp( $rc );
415 }
416
417 /**
418 * Insert links to user page, user talk page and eventually a blocking link
419 *
420 * @param &$s String HTML to update
421 * @param &$rc RecentChange
422 */
423 public function insertUserRelatedLinks( &$s, &$rc ) {
424 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
425 $s .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
426 } else {
427 $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
428 $rc->mAttribs['rc_user_text'] );
429 $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
430 }
431 }
432
433 /**
434 * Insert a formatted action
435 *
436 * @param $rc RecentChange
437 * @return string
438 */
439 public function insertLogEntry( $rc ) {
440 $formatter = LogFormatter::newFromRow( $rc->mAttribs );
441 $formatter->setContext( $this->getContext() );
442 $formatter->setShowUserToolLinks( true );
443 $mark = $this->getLanguage()->getDirMark();
444 return $formatter->getActionText() . " $mark" . $formatter->getComment();
445 }
446
447 /**
448 * Insert a formatted comment
449 * @param $rc RecentChange
450 * @return string
451 */
452 public function insertComment( $rc ) {
453 if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
454 if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
455 return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
456 } else {
457 return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
458 }
459 }
460 return '';
461 }
462
463 /**
464 * Check whether to enable recent changes patrol features
465 * @return Boolean
466 */
467 public static function usePatrol() {
468 global $wgUser;
469 return $wgUser->useRCPatrol();
470 }
471
472 /**
473 * Returns the string which indicates the number of watching users
474 * @return string
475 */
476 protected function numberofWatchingusers( $count ) {
477 static $cache = array();
478 if( $count > 0 ) {
479 if( !isset( $cache[$count] ) ) {
480 $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
481 }
482 return $cache[$count];
483 } else {
484 return '';
485 }
486 }
487
488 /**
489 * Determine if said field of a revision is hidden
490 * @param $rc RCCacheEntry
491 * @param $field Integer: one of DELETED_* bitfield constants
492 * @return Boolean
493 */
494 public static function isDeleted( $rc, $field ) {
495 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
496 }
497
498 /**
499 * Determine if the current user is allowed to view a particular
500 * field of this revision, if it's marked as deleted.
501 * @param $rc RCCacheEntry
502 * @param $field Integer
503 * @param $user User object to check, or null to use $wgUser
504 * @return Boolean
505 */
506 public static function userCan( $rc, $field, User $user = null ) {
507 if( $rc->mAttribs['rc_type'] == RC_LOG ) {
508 return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
509 } else {
510 return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
511 }
512 }
513
514 /**
515 * @param $link string
516 * @param $watched bool
517 * @return string
518 */
519 protected function maybeWatchedLink( $link, $watched = false ) {
520 if( $watched ) {
521 return '<strong class="mw-watched">' . $link . '</strong>';
522 } else {
523 return '<span class="mw-rc-unwatched">' . $link . '</span>';
524 }
525 }
526
527 /** Inserts a rollback link
528 *
529 * @param $s string
530 * @param $rc RecentChange
531 */
532 public function insertRollback( &$s, &$rc ) {
533 if( $rc->mAttribs['rc_type'] != RC_NEW && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
534 $page = $rc->getTitle();
535 /** Check for rollback and edit permissions, disallow special pages, and only
536 * show a link on the top-most revision */
537 if ( $this->getUser()->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
538 {
539 $rev = new Revision( array(
540 'title' => $page,
541 'id' => $rc->mAttribs['rc_this_oldid'],
542 'user' => $rc->mAttribs['rc_user'],
543 'user_text' => $rc->mAttribs['rc_user_text'],
544 'deleted' => $rc->mAttribs['rc_deleted']
545 ) );
546 $s .= ' '.Linker::generateRollback( $rev, $this->getContext() );
547 }
548 }
549 }
550
551 /**
552 * @param $s string
553 * @param $rc RecentChange
554 * @param $classes
555 */
556 public function insertTags( &$s, &$rc, &$classes ) {
557 if ( empty($rc->mAttribs['ts_tags']) )
558 return;
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 subclassers 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 /**
584 * Generate a list of changes using the good old system (no javascript)
585 */
586 class OldChangesList extends ChangesList {
587 /**
588 * Format a line using the old system (aka without any javascript).
589 *
590 * @param $rc RecentChange, passed by reference
591 * @param $watched Bool (default false)
592 * @param $linenumber Int (default null)
593 * @return string
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 }
612 else {
613 $classes[] = 'mw-line-even';
614 }
615 }
616
617 // Indicate watched status on the line to allow for more
618 // comprehensive styling.
619 $classes[] = $watched ? '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 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
685
686 wfProfileOut( __METHOD__ );
687 return "$dateheader<li class=\"".implode( ' ', $classes )."\">".$s."</li>\n";
688 }
689 }
690
691
692 /**
693 * Generate a list of changes using an Enhanced system (uses javascript).
694 */
695 class EnhancedChangesList extends ChangesList {
696
697 protected $rc_cache;
698
699 /**
700 * Add the JavaScript file for enhanced changeslist
701 * @return String
702 */
703 public function beginRecentChangesList() {
704 $this->rc_cache = array();
705 $this->rcMoveIndex = 0;
706 $this->rcCacheIndex = 0;
707 $this->lastdate = '';
708 $this->rclistOpen = false;
709 $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
710 return '';
711 }
712 /**
713 * Format a line for enhanced recentchange (aka with javascript and block of lines).
714 *
715 * @param $baseRC RecentChange
716 * @param $watched bool
717 *
718 * @return string
719 */
720 public function recentChangesLine( &$baseRC, $watched = false ) {
721 wfProfileIn( __METHOD__ );
722
723 # Create a specialised object
724 $rc = RCCacheEntry::newFromParent( $baseRC );
725
726 $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
727
728 # If it's a new day, add the headline and flush the cache
729 $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
730 $ret = '';
731 if( $date != $this->lastdate ) {
732 # Process current cache
733 $ret = $this->recentChangesBlock();
734 $this->rc_cache = array();
735 $ret .= Xml::element( 'h4', null, $date ) . "\n";
736 $this->lastdate = $date;
737 }
738
739 # Should patrol-related stuff be shown?
740 $rc->unpatrolled = $this->showAsUnpatrolled( $rc );
741
742 $showdifflinks = true;
743 # Make article link
744 $type = $rc->mAttribs['rc_type'];
745 $logType = $rc->mAttribs['rc_log_type'];
746 // Page moves, very old style, not supported anymore
747 if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
748 // New unpatrolled pages
749 } elseif( $rc->unpatrolled && $type == RC_NEW ) {
750 $clink = Linker::linkKnown( $rc->getTitle(), null, array(),
751 array( 'rcid' => $rc->mAttribs['rc_id'] ) );
752 // Log entries
753 } elseif( $type == RC_LOG ) {
754 if( $logType ) {
755 $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
756 $logpage = new LogPage( $logType );
757 $logname = $logpage->getName()->escaped();
758 $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped();
759 } else {
760 $clink = Linker::link( $rc->getTitle() );
761 }
762 $watched = false;
763 // Log entries (old format) and special pages
764 } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
765 wfDebug( "Unexpected special page in recentchanges\n" );
766 $clink = '';
767 // Edits
768 } else {
769 $clink = Linker::linkKnown( $rc->getTitle() );
770 }
771
772 # Don't show unusable diff links
773 if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
774 $showdifflinks = false;
775 }
776
777 $time = $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() );
778 $rc->watched = $watched;
779 $rc->link = $clink;
780 $rc->timestamp = $time;
781 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
782
783 # Make "cur" and "diff" links. Do not use link(), it is too slow if
784 # called too many times (50% of CPU time on RecentChanges!).
785 $thisOldid = $rc->mAttribs['rc_this_oldid'];
786 $lastOldid = $rc->mAttribs['rc_last_oldid'];
787 if( $rc->unpatrolled ) {
788 $rcIdQuery = array( 'rcid' => $rc->mAttribs['rc_id'] );
789 } else {
790 $rcIdQuery = array();
791 }
792 $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid );
793 $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' =>
794 $lastOldid ) + $rcIdQuery;
795
796 if( !$showdifflinks ) {
797 $curLink = $this->message['cur'];
798 $diffLink = $this->message['diff'];
799 } elseif( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
800 if ( $type != RC_NEW ) {
801 $curLink = $this->message['cur'];
802 } else {
803 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
804 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
805 }
806 $diffLink = $this->message['diff'];
807 } else {
808 $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querydiff ) );
809 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
810 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
811 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
812 }
813
814 # Make "last" link
815 if( !$showdifflinks || !$lastOldid ) {
816 $lastLink = $this->message['last'];
817 } elseif( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
818 $lastLink = $this->message['last'];
819 } else {
820 $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
821 array(), $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery );
822 }
823
824 # Make user links
825 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
826 $rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
827 } else {
828 $rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
829 $rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
830 }
831
832 $rc->lastlink = $lastLink;
833 $rc->curlink = $curLink;
834 $rc->difflink = $diffLink;
835
836 # Put accumulated information into the cache, for later display
837 # Page moves go on their own line
838 $title = $rc->getTitle();
839 $secureName = $title->getPrefixedDBkey();
840 if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
841 # Use an @ character to prevent collision with page names
842 $this->rc_cache['@@' . ($this->rcMoveIndex++)] = array($rc);
843 } else {
844 # Logs are grouped by type
845 if( $type == RC_LOG ){
846 $secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
847 }
848 if( !isset( $this->rc_cache[$secureName] ) ) {
849 $this->rc_cache[$secureName] = array();
850 }
851
852 array_push( $this->rc_cache[$secureName], $rc );
853 }
854
855 wfProfileOut( __METHOD__ );
856
857 return $ret;
858 }
859
860 /**
861 * Enhanced RC group
862 * @return string
863 */
864 protected function recentChangesBlockGroup( $block ) {
865 global $wgRCShowChangedSize;
866
867 wfProfileIn( __METHOD__ );
868
869 # Add the namespace and title of the block as part of the class
870 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
871 if ( $block[0]->mAttribs['rc_log_type'] ) {
872 # Log entry
873 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
874 . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
875 } else {
876 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
877 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
878 }
879 $classes[] = $block[0]->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
880 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
881 Html::openElement( 'tr' );
882
883 # Collate list of users
884 $userlinks = array();
885 # Other properties
886 $unpatrolled = false;
887 $isnew = false;
888 $allBots = true;
889 $allMinors = true;
890 $curId = $currentRevision = 0;
891 # Some catalyst variables...
892 $namehidden = true;
893 $allLogs = true;
894 foreach( $block as $rcObj ) {
895 $oldid = $rcObj->mAttribs['rc_last_oldid'];
896 if( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
897 $isnew = true;
898 }
899 // If all log actions to this page were hidden, then don't
900 // give the name of the affected page for this block!
901 if( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
902 $namehidden = false;
903 }
904 $u = $rcObj->userlink;
905 if( !isset( $userlinks[$u] ) ) {
906 $userlinks[$u] = 0;
907 }
908 if( $rcObj->unpatrolled ) {
909 $unpatrolled = true;
910 }
911 if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
912 $allLogs = false;
913 }
914 # Get the latest entry with a page_id and oldid
915 # since logs may not have these.
916 if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
917 $curId = $rcObj->mAttribs['rc_cur_id'];
918 }
919 if( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
920 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
921 }
922
923 if( !$rcObj->mAttribs['rc_bot'] ) {
924 $allBots = false;
925 }
926 if( !$rcObj->mAttribs['rc_minor'] ) {
927 $allMinors = false;
928 }
929
930 $userlinks[$u]++;
931 }
932
933 # Sort the list and convert to text
934 krsort( $userlinks );
935 asort( $userlinks );
936 $users = array();
937 foreach( $userlinks as $userlink => $count) {
938 $text = $userlink;
939 $text .= $this->getLanguage()->getDirMark();
940 if( $count > 1 ) {
941 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
942 }
943 array_push( $users, $text );
944 }
945
946 $users = ' <span class="changedby">'
947 . $this->msg( 'brackets' )->rawParams(
948 implode( $this->message['semicolon-separator'], $users )
949 )->escaped() . '</span>';
950
951 $tl = '<span class="mw-collapsible-toggle mw-enhancedchanges-arrow"></span>';
952 $r .= "<td>$tl</td>";
953
954 # Main line
955 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
956 'newpage' => $isnew, # show, when one have this flag
957 'minor' => $allMinors, # show only, when all have this flag
958 'unpatrolled' => $unpatrolled, # show, when one have this flag
959 'bot' => $allBots, # show only, when all have this flag
960 ) );
961
962 # Timestamp
963 $r .= '&#160;'.$block[0]->timestamp.'&#160;</td><td>';
964
965 # Article link
966 if( $namehidden ) {
967 $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
968 } elseif( $allLogs ) {
969 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
970 } else {
971 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
972 }
973
974 $r .= $this->getLanguage()->getDirMark();
975
976 $queryParams['curid'] = $curId;
977 # Changes message
978 $n = count($block);
979 static $nchanges = array();
980 if ( !isset( $nchanges[$n] ) ) {
981 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
982 }
983 # Total change link
984 $r .= ' ';
985 $logtext = '';
986 if( !$allLogs ) {
987 if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
988 $logtext .= $nchanges[$n];
989 } elseif( $isnew ) {
990 $logtext .= $nchanges[$n];
991 } else {
992 $params = $queryParams;
993 $params['diff'] = $currentRevision;
994 $params['oldid'] = $oldid;
995
996 $logtext .= Linker::link(
997 $block[0]->getTitle(),
998 $nchanges[$n],
999 array(),
1000 $params,
1001 array( 'known', 'noclasses' )
1002 );
1003 }
1004 }
1005
1006 # History
1007 if( $allLogs ) {
1008 // don't show history link for logs
1009 } elseif( $namehidden || !$block[0]->getTitle()->exists() ) {
1010 $logtext .= $this->message['pipe-separator'] . $this->message['hist'];
1011 } else {
1012 $params = $queryParams;
1013 $params['action'] = 'history';
1014
1015 $logtext .= $this->message['pipe-separator'] .
1016 Linker::linkKnown(
1017 $block[0]->getTitle(),
1018 $this->message['hist'],
1019 array(),
1020 $params
1021 );
1022 }
1023
1024 if( $logtext !== '' ) {
1025 $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
1026 }
1027
1028 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1029
1030 # Character difference (does not apply if only log items)
1031 if( $wgRCShowChangedSize && !$allLogs ) {
1032 $last = 0;
1033 $first = count($block) - 1;
1034 # Some events (like logs) have an "empty" size, so we need to skip those...
1035 while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
1036 $last++;
1037 }
1038 while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
1039 $first--;
1040 }
1041 # Get net change
1042 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
1043
1044 if( $chardiff == '' ) {
1045 $r .= ' ';
1046 } else {
1047 $r .= ' ' . $chardiff. ' <span class="mw-changeslist-separator">. .</span> ';
1048 }
1049 }
1050
1051 $r .= $users;
1052 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
1053
1054 # Sub-entries
1055 foreach( $block as $rcObj ) {
1056 # Classes to apply -- TODO implement
1057 $classes = array();
1058 $type = $rcObj->mAttribs['rc_type'];
1059
1060 $r .= '<tr><td></td><td class="mw-enhanced-rc">';
1061 $r .= $this->recentChangesFlags( array(
1062 'newpage' => $type == RC_NEW,
1063 'minor' => $rcObj->mAttribs['rc_minor'],
1064 'unpatrolled' => $rcObj->unpatrolled,
1065 'bot' => $rcObj->mAttribs['rc_bot'],
1066 ) );
1067 $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
1068
1069 $params = $queryParams;
1070
1071 if( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
1072 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
1073 }
1074
1075 # Log timestamp
1076 if( $type == RC_LOG ) {
1077 $link = $rcObj->timestamp;
1078 # Revision link
1079 } elseif( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
1080 $link = '<span class="history-deleted">'.$rcObj->timestamp.'</span> ';
1081 } else {
1082 if ( $rcObj->unpatrolled && $type == RC_NEW) {
1083 $params['rcid'] = $rcObj->mAttribs['rc_id'];
1084 }
1085
1086 $link = Linker::linkKnown(
1087 $rcObj->getTitle(),
1088 $rcObj->timestamp,
1089 array(),
1090 $params
1091 );
1092 if( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
1093 $link = '<span class="history-deleted">'.$link.'</span> ';
1094 }
1095 }
1096 $r .= $link . '</span>';
1097
1098 if ( !$type == RC_LOG || $type == RC_NEW ) {
1099 $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped();
1100 }
1101 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
1102
1103 # Character diff
1104 if ( $wgRCShowChangedSize ) {
1105 $cd = $this->formatCharacterDifference( $rcObj );
1106 if ( $cd !== '' ) {
1107 $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
1108 }
1109 }
1110
1111 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
1112 $r .= $this->insertLogEntry( $rcObj );
1113 } else {
1114 # User links
1115 $r .= $rcObj->userlink;
1116 $r .= $rcObj->usertalklink;
1117 $r .= $this->insertComment( $rcObj );
1118 }
1119
1120 # Rollback
1121 $this->insertRollback( $r, $rcObj );
1122 # Tags
1123 $this->insertTags( $r, $rcObj, $classes );
1124
1125 $r .= "</td></tr>\n";
1126 }
1127 $r .= "</table>\n";
1128
1129 $this->rcCacheIndex++;
1130
1131 wfProfileOut( __METHOD__ );
1132
1133 return $r;
1134 }
1135
1136 /**
1137 * Generate HTML for an arrow or placeholder graphic
1138 * @param $dir String: one of '', 'd', 'l', 'r'
1139 * @param $alt String: text
1140 * @param $title String: text
1141 * @return String: HTML "<img>" tag
1142 */
1143 protected function arrow( $dir, $alt='', $title='' ) {
1144 global $wgStylePath;
1145 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
1146 $encAlt = htmlspecialchars( $alt );
1147 $encTitle = htmlspecialchars( $title );
1148 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
1149 }
1150
1151 /**
1152 * Generate HTML for a right- or left-facing arrow,
1153 * depending on language direction.
1154 * @return String: HTML "<img>" tag
1155 */
1156 protected function sideArrow() {
1157 $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
1158 return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
1159 }
1160
1161 /**
1162 * Generate HTML for a down-facing arrow
1163 * depending on language direction.
1164 * @return String: HTML "<img>" tag
1165 */
1166 protected function downArrow() {
1167 return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
1168 }
1169
1170 /**
1171 * Generate HTML for a spacer image
1172 * @return String: HTML "<img>" tag
1173 */
1174 protected function spacerArrow() {
1175 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
1176 }
1177
1178 /**
1179 * Enhanced RC ungrouped line.
1180 *
1181 * @param $rcObj RecentChange
1182 * @return String: a HTML formatted line (generated using $r)
1183 */
1184 protected function recentChangesBlockLine( $rcObj ) {
1185 global $wgRCShowChangedSize;
1186
1187 wfProfileIn( __METHOD__ );
1188 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
1189
1190 $type = $rcObj->mAttribs['rc_type'];
1191 $logType = $rcObj->mAttribs['rc_log_type'];
1192 $classes = array( 'mw-enhanced-rc' );
1193 if( $logType ) {
1194 # Log entry
1195 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
1196 . $logType . '-' . $rcObj->mAttribs['rc_title'] );
1197 } else {
1198 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
1199 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
1200 }
1201 $classes[] = $rcObj->watched ? '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 mw-enhancedchanges-arrow-space"></span>';
1206 # Flag and Timestamp
1207 if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
1208 $r .= '&#160;&#160;&#160;&#160;'; // 4 flags -> 4 spaces
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 }