Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git] / includes / changes / EnhancedChangesList.php
1 <?php
2 /**
3 * Generates a list of changes using an Enhanced system (uses javascript).
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 class EnhancedChangesList extends ChangesList {
24
25 /**
26 * @var RCCacheEntryFactory
27 */
28 protected $cacheEntryFactory;
29
30 /**
31 * @var array Array of array of RCCacheEntry
32 */
33 protected $rc_cache;
34
35 /**
36 * @param IContextSource|Skin $obj
37 * @throws MWException
38 */
39 public function __construct( $obj ) {
40 if ( $obj instanceof Skin ) {
41 // @todo: deprecate constructing with Skin
42 $context = $obj->getContext();
43 } else {
44 if ( !$obj instanceof IContextSource ) {
45 throw new MWException( 'EnhancedChangesList must be constructed with a '
46 . 'context source or skin.' );
47 }
48
49 $context = $obj;
50 }
51
52 parent::__construct( $context );
53
54 // message is set by the parent ChangesList class
55 $this->cacheEntryFactory = new RCCacheEntryFactory(
56 $context,
57 $this->message
58 );
59 }
60
61 /**
62 * Add the JavaScript file for enhanced changeslist
63 * @return string
64 */
65 public function beginRecentChangesList() {
66 $this->rc_cache = array();
67 $this->rcMoveIndex = 0;
68 $this->rcCacheIndex = 0;
69 $this->lastdate = '';
70 $this->rclistOpen = false;
71 $this->getOutput()->addModuleStyles( array(
72 'mediawiki.special.changeslist',
73 'mediawiki.special.changeslist.enhanced',
74 ) );
75 $this->getOutput()->addModules( array(
76 'jquery.makeCollapsible',
77 'mediawiki.icon',
78 ) );
79
80 return '<div class="mw-changeslist">';
81 }
82
83 /**
84 * Format a line for enhanced recentchange (aka with javascript and block of lines).
85 *
86 * @param RecentChange $baseRC
87 * @param bool $watched
88 *
89 * @return string
90 */
91 public function recentChangesLine( &$baseRC, $watched = false ) {
92
93 $date = $this->getLanguage()->userDate(
94 $baseRC->mAttribs['rc_timestamp'],
95 $this->getUser()
96 );
97
98 $ret = '';
99
100 # If it's a new day, add the headline and flush the cache
101 if ( $date != $this->lastdate ) {
102 # Process current cache
103 $ret = $this->recentChangesBlock();
104 $this->rc_cache = array();
105 $ret .= Xml::element( 'h4', null, $date ) . "\n";
106 $this->lastdate = $date;
107 }
108
109 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $baseRC, $watched );
110 $this->addCacheEntry( $cacheEntry );
111
112 return $ret;
113 }
114
115 /**
116 * Put accumulated information into the cache, for later display.
117 * Page moves go on their own line.
118 *
119 * @param RCCacheEntry $cacheEntry
120 */
121 protected function addCacheEntry( RCCacheEntry $cacheEntry ) {
122 $cacheGroupingKey = $this->makeCacheGroupingKey( $cacheEntry );
123
124 if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
125 $this->rc_cache[$cacheGroupingKey] = array();
126 }
127
128 array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
129 }
130
131 /**
132 * @todo use rc_source to group, if set; fallback to rc_type
133 *
134 * @param RCCacheEntry $cacheEntry
135 *
136 * @return string
137 */
138 protected function makeCacheGroupingKey( RCCacheEntry $cacheEntry ) {
139 $title = $cacheEntry->getTitle();
140 $cacheGroupingKey = $title->getPrefixedDBkey();
141
142 $type = $cacheEntry->mAttribs['rc_type'];
143
144 if ( $type == RC_LOG ) {
145 // Group by log type
146 $cacheGroupingKey = SpecialPage::getTitleFor(
147 'Log',
148 $cacheEntry->mAttribs['rc_log_type']
149 )->getPrefixedDBkey();
150 }
151
152 return $cacheGroupingKey;
153 }
154
155 /**
156 * Enhanced RC group
157 * @param RCCacheEntry[] $block
158 * @return string
159 */
160 protected function recentChangesBlockGroup( $block ) {
161
162 # Add the namespace and title of the block as part of the class
163 $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
164 if ( $block[0]->mAttribs['rc_log_type'] ) {
165 # Log entry
166 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
167 . $block[0]->mAttribs['rc_log_type'] );
168 } else {
169 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
170 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
171 }
172 $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
173 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
174 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
175 Html::openElement( 'tr' );
176
177 # Collate list of users
178 $userlinks = array();
179 # Other properties
180 $unpatrolled = false;
181 $isnew = false;
182 $allBots = true;
183 $allMinors = true;
184 $curId = 0;
185 # Some catalyst variables...
186 $namehidden = true;
187 $allLogs = true;
188 $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
189 foreach ( $block as $rcObj ) {
190 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
191 $isnew = true;
192 }
193 // If all log actions to this page were hidden, then don't
194 // give the name of the affected page for this block!
195 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
196 $namehidden = false;
197 }
198 $u = $rcObj->userlink;
199 if ( !isset( $userlinks[$u] ) ) {
200 $userlinks[$u] = 0;
201 }
202 if ( $rcObj->unpatrolled ) {
203 $unpatrolled = true;
204 }
205 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
206 $allLogs = false;
207 }
208 # Get the latest entry with a page_id and oldid
209 # since logs may not have these.
210 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
211 $curId = $rcObj->mAttribs['rc_cur_id'];
212 }
213
214 if ( !$rcObj->mAttribs['rc_bot'] ) {
215 $allBots = false;
216 }
217 if ( !$rcObj->mAttribs['rc_minor'] ) {
218 $allMinors = false;
219 }
220
221 $userlinks[$u]++;
222 }
223
224 # Sort the list and convert to text
225 krsort( $userlinks );
226 asort( $userlinks );
227 $users = array();
228 foreach ( $userlinks as $userlink => $count ) {
229 $text = $userlink;
230 $text .= $this->getLanguage()->getDirMark();
231 if ( $count > 1 ) {
232 // @todo FIXME: Hardcoded '×'. Should be a message.
233 $formattedCount = $this->getLanguage()->formatNum( $count ) . '×';
234 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
235 }
236 array_push( $users, $text );
237 }
238
239 $users = ' <span class="changedby">'
240 . $this->msg( 'brackets' )->rawParams(
241 implode( $this->message['semicolon-separator'], $users )
242 )->escaped() . '</span>';
243
244 $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow ' .
245 'mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
246 $r .= "<td>$tl</td>";
247
248 # Main line
249 $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
250 'newpage' => $isnew, # show, when one have this flag
251 'minor' => $allMinors, # show only, when all have this flag
252 'unpatrolled' => $unpatrolled, # show, when one have this flag
253 'bot' => $allBots, # show only, when all have this flag
254 ) );
255
256 # Timestamp
257 $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
258
259 # Article link
260 if ( $namehidden ) {
261 $r .= ' <span class="history-deleted">' .
262 $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
263 } elseif ( $allLogs ) {
264 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
265 } else {
266 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
267 }
268
269 $r .= $this->getLanguage()->getDirMark();
270
271 $queryParams['curid'] = $curId;
272
273 # Sub-entries
274 $lines = '';
275 foreach ( $block as $i => $rcObj ) {
276 $line = $this->getLineData( $block, $rcObj, $queryParams );
277 $lines .= $line;
278 if ( !$line ) {
279 // completely ignore this RC entry if we don't want to render it
280 unset( $block[$i] );
281 }
282 }
283 // Further down are some assumptions that $block is a 0-indexed array
284 // with (count-1) as last key. Let's make sure it is.
285 $block = array_values( $block );
286
287 $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden );
288
289 $r .= ' <span class="mw-changeslist-separator">. .</span> ';
290
291 # Character difference (does not apply if only log items)
292 if ( $RCShowChangedSize && !$allLogs ) {
293 $last = 0;
294 $first = count( $block ) - 1;
295 # Some events (like logs) have an "empty" size, so we need to skip those...
296 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
297 $last++;
298 }
299 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
300 $first--;
301 }
302 # Get net change
303 $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
304
305 if ( $chardiff == '' ) {
306 $r .= ' ';
307 } else {
308 $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
309 }
310 }
311
312 $r .= $users;
313 $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
314 $r .= '</td></tr>';
315
316 if ( !$lines ) {
317 // if there are no lines to be rendered (all aborted by hook), don't render the block
318 return '';
319 }
320
321 $r .= $lines;
322 $r .= "</table>\n";
323
324 $this->rcCacheIndex++;
325
326 return $r;
327 }
328
329 /**
330 * @param RCCacheEntry[] $block
331 * @param RCCacheEntry $rcObj
332 * @param array $queryParams
333 * @return string
334 * @throws Exception
335 * @throws FatalError
336 * @throws MWException
337 */
338 protected function getLineData( array $block, RCCacheEntry $rcObj, array $queryParams = array() ) {
339 $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
340
341 # Classes to apply -- TODO implement
342 $classes = array();
343 $type = $rcObj->mAttribs['rc_type'];
344 $data = array();
345
346 $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
347 ? ' class="mw-enhanced-watched"' : '';
348 $separator = ' <span class="mw-changeslist-separator">. .</span> ';
349
350 $data['recentChangesFlags'] = array(
351 'newpage' => $type == RC_NEW,
352 'minor' => $rcObj->mAttribs['rc_minor'],
353 'unpatrolled' => $rcObj->unpatrolled,
354 'bot' => $rcObj->mAttribs['rc_bot'],
355 );
356
357 $params = $queryParams;
358
359 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
360 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
361 }
362
363 # Log timestamp
364 if ( $type == RC_LOG ) {
365 $link = $rcObj->timestamp;
366 # Revision link
367 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
368 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
369 } else {
370 $link = Linker::linkKnown(
371 $rcObj->getTitle(),
372 $rcObj->timestamp,
373 array(),
374 $params
375 );
376 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
377 $link = '<span class="history-deleted">' . $link . '</span> ';
378 }
379 }
380 $data['timestampLink'] = $link;
381
382 $currentAndLastLinks = '';
383 if ( !$type == RC_LOG || $type == RC_NEW ) {
384 $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams(
385 $rcObj->curlink .
386 $this->message['pipe-separator'] .
387 $rcObj->lastlink
388 )->escaped();
389 }
390 $data['currentAndLastLinks'] = $currentAndLastLinks;
391 $data['separatorAfterCurrentAndLastLinks'] = $separator;
392
393 # Character diff
394 if ( $RCShowChangedSize ) {
395 $cd = $this->formatCharacterDifference( $rcObj );
396 if ( $cd !== '' ) {
397 $data['characterDiff'] = $cd;
398 $data['separatorAfterCharacterDiff'] = $separator;
399 }
400 }
401
402 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
403 $data['logEntry'] = $this->insertLogEntry( $rcObj );
404 } else {
405 # User links
406 $data['userLink'] = $rcObj->userlink;
407 $data['userTalkLink'] = $rcObj->usertalklink;
408 $data['comment'] = $this->insertComment( $rcObj );
409 }
410
411 # Rollback
412 $data['rollback'] = $this->getRollback( $rcObj );
413
414 # Tags
415 $data['tags'] = $this->getTags( $rcObj, $classes );
416
417 // give the hook a chance to modify the data
418 $success = Hooks::run( 'EnhancedChangesListModifyLineData',
419 array( $this, &$data, $block, $rcObj ) );
420 if ( !$success ) {
421 // skip entry if hook aborted it
422 return '';
423 }
424
425 $line = '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
426 if ( isset( $data['recentChangesFlags'] ) ) {
427 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
428 unset( $data['recentChangesFlags'] );
429 }
430 $line .= '&#160;</td><td class="mw-enhanced-rc-nested">';
431
432 if ( isset( $data['timestampLink'] ) ) {
433 $line .= '<span class="mw-enhanced-rc-time">' . $data['timestampLink'] . '</span>';
434 unset( $data['timestampLink'] );
435 }
436
437 // everything else: makes it easier for extensions to add or remove data
438 $line .= implode( '', $data );
439
440 $line .= "</td></tr>\n";
441
442 return $line;
443 }
444
445 /**
446 * Generates amount of changes (linking to diff ) & link to history.
447 *
448 * @param array $block
449 * @param array $queryParams
450 * @param bool $allLogs
451 * @param bool $isnew
452 * @param bool $namehidden
453 * @return string
454 */
455 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
456 # Changes message
457 static $nchanges = array();
458 static $sinceLastVisitMsg = array();
459
460 $n = count( $block );
461 if ( !isset( $nchanges[$n] ) ) {
462 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
463 }
464
465 $sinceLast = 0;
466 $unvisitedOldid = null;
467 /** @var $rcObj RCCacheEntry */
468 foreach ( $block as $rcObj ) {
469 // Same logic as below inside main foreach
470 if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
471 $sinceLast++;
472 $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
473 }
474 }
475 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
476 $sinceLastVisitMsg[$sinceLast] =
477 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
478 }
479
480 $currentRevision = 0;
481 foreach ( $block as $rcObj ) {
482 if ( !$currentRevision ) {
483 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
484 }
485 }
486
487 # Total change link
488 $links = array();
489 /** @var $block0 RecentChange */
490 $block0 = $block[0];
491 $last = $block[count( $block ) - 1];
492 if ( !$allLogs ) {
493 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
494 $links['total-changes'] = $nchanges[$n];
495 } elseif ( $isnew ) {
496 $links['total-changes'] = $nchanges[$n];
497 } else {
498 $links['total-changes'] = Linker::link(
499 $block0->getTitle(),
500 $nchanges[$n],
501 array(),
502 $queryParams + array(
503 'diff' => $currentRevision,
504 'oldid' => $last->mAttribs['rc_last_oldid'],
505 ),
506 array( 'known', 'noclasses' )
507 );
508 if ( $sinceLast > 0 && $sinceLast < $n ) {
509 $links['total-changes-since-last'] = Linker::link(
510 $block0->getTitle(),
511 $sinceLastVisitMsg[$sinceLast],
512 array(),
513 $queryParams + array(
514 'diff' => $currentRevision,
515 'oldid' => $unvisitedOldid,
516 ),
517 array( 'known', 'noclasses' )
518 );
519 }
520 }
521 }
522
523 # History
524 if ( $allLogs ) {
525 // don't show history link for logs
526 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
527 $links['history'] = $this->message['enhancedrc-history'];
528 } else {
529 $params = $queryParams;
530 $params['action'] = 'history';
531
532 $links['history'] = Linker::linkKnown(
533 $block0->getTitle(),
534 $this->message['enhancedrc-history'],
535 array(),
536 $params
537 );
538 }
539
540 # Allow others to alter, remove or add to these links
541 Hooks::run( 'EnhancedChangesList::getLogText',
542 array( $this, &$links, $block ) );
543
544 if ( !$links ) {
545 return '';
546 }
547
548 $logtext = implode( $this->message['pipe-separator'], $links );
549 $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
550 return ' ' . $logtext;
551 }
552
553 /**
554 * Enhanced RC ungrouped line.
555 *
556 * @param RecentChange|RCCacheEntry $rcObj
557 * @return string A HTML formatted line (generated using $r)
558 */
559 protected function recentChangesBlockLine( $rcObj ) {
560 $data = array();
561
562 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
563
564 $type = $rcObj->mAttribs['rc_type'];
565 $logType = $rcObj->mAttribs['rc_log_type'];
566 $classes = array( 'mw-enhanced-rc' );
567 if ( $logType ) {
568 # Log entry
569 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
570 } else {
571 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
572 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
573 }
574 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
575 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
576
577 # Flag and Timestamp
578 $data['recentChangesFlags'] = array(
579 'newpage' => $type == RC_NEW,
580 'minor' => $rcObj->mAttribs['rc_minor'],
581 'unpatrolled' => $rcObj->unpatrolled,
582 'bot' => $rcObj->mAttribs['rc_bot'],
583 );
584 // timestamp is not really a link here, but is called timestampLink
585 // for consistency with EnhancedChangesListModifyLineData
586 $data['timestampLink'] = $rcObj->timestamp;
587
588 # Article or log link
589 if ( $logType ) {
590 $logPage = new LogPage( $logType );
591 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
592 $logName = $logPage->getName()->escaped();
593 $data['logLink'] = $this->msg( 'parentheses' )
594 ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
595 } else {
596 $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
597 }
598
599 # Diff and hist links
600 if ( $type != RC_LOG ) {
601 $query['action'] = 'history';
602 $data['historyLink'] = ' ' . $this->msg( 'parentheses' )
603 ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
604 $rcObj->getTitle(),
605 $this->message['hist'],
606 array(),
607 $query
608 ) )->escaped();
609 }
610 $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
611
612 # Character diff
613 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
614 $cd = $this->formatCharacterDifference( $rcObj );
615 if ( $cd !== '' ) {
616 $data['characterDiff'] = $cd;
617 $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> ';
618 }
619 }
620
621 if ( $type == RC_LOG ) {
622 $data['logEntry'] = $this->insertLogEntry( $rcObj );
623 } else {
624 $data['userLink'] = $rcObj->userlink;
625 $data['userTalkLink'] = $rcObj->usertalklink;
626 $data['comment'] = $this->insertComment( $rcObj );
627 $data['rollback'] = $this->getRollback( $rcObj );
628 }
629
630 # Tags
631 $data['tags'] = $this->getTags( $rcObj, $classes );
632
633 # Show how many people are watching this if enabled
634 $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
635
636 // give the hook a chance to modify the data
637 $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData',
638 array( $this, &$data, $rcObj ) );
639 if ( !$success ) {
640 // skip entry if hook aborted it
641 return '';
642 }
643
644 $line = Html::openElement( 'table', array( 'class' => $classes ) ) .
645 Html::openElement( 'tr' );
646 $line .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
647
648 if ( isset( $data['recentChangesFlags'] ) ) {
649 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
650 unset( $data['recentChangesFlags'] );
651 }
652
653 if ( isset( $data['timestampLink'] ) ) {
654 $line .= '&#160;' . $data['timestampLink'];
655 unset( $data['timestampLink'] );
656 }
657 $line .= '&#160;</td><td>';
658
659 // everything else: makes it easier for extensions to add or remove data
660 $line .= implode( '', $data );
661
662 $line .= "</td></tr></table>\n";
663
664 return $line;
665 }
666
667 /**
668 * If enhanced RC is in use, this function takes the previously cached
669 * RC lines, arranges them, and outputs the HTML
670 *
671 * @return string
672 */
673 protected function recentChangesBlock() {
674 if ( count( $this->rc_cache ) == 0 ) {
675 return '';
676 }
677
678 $blockOut = '';
679 foreach ( $this->rc_cache as $block ) {
680 if ( count( $block ) < 2 ) {
681 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
682 } else {
683 $blockOut .= $this->recentChangesBlockGroup( $block );
684 }
685 }
686
687 return '<div>' . $blockOut . '</div>';
688 }
689
690 /**
691 * Returns text for the end of RC
692 * If enhanced RC is in use, returns pretty much all the text
693 * @return string
694 */
695 public function endRecentChangesList() {
696 return $this->recentChangesBlock() . '</div>';
697 }
698 }