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