Add Blob to accepted types for uploads
[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 $tableClasses = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
165 if ( $block[0]->mAttribs['rc_log_type'] ) {
166 # Log entry
167 $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
168 . $block[0]->mAttribs['rc_log_type'] );
169 } else {
170 $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
171 . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
172 }
173 if ( $block[0]->watched
174 && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
175 ) {
176 $tableClasses[] = 'mw-changeslist-line-watched';
177 } else {
178 $tableClasses[] = 'mw-changeslist-line-not-watched';
179 }
180
181 # Collate list of users
182 $userlinks = array();
183 # Other properties
184 $curId = 0;
185 # Some catalyst variables...
186 $namehidden = true;
187 $allLogs = true;
188 $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
189 $collectedRcFlags = array(
190 // All are by bots?
191 'bot' => true,
192 // Includes a new page?
193 'newpage' => false,
194 // All are minor edits?
195 'minor' => true,
196 // Contains an unpatrolled edit?
197 'unpatrolled' => false,
198 );
199 foreach ( $block as $rcObj ) {
200 if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
201 $collectedRcFlags['newpage'] = true;
202 }
203 // If all log actions to this page were hidden, then don't
204 // give the name of the affected page for this block!
205 if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
206 $namehidden = false;
207 }
208 $u = $rcObj->userlink;
209 if ( !isset( $userlinks[$u] ) ) {
210 $userlinks[$u] = 0;
211 }
212 if ( $rcObj->unpatrolled ) {
213 $collectedRcFlags['unpatrolled'] = true;
214 }
215 if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
216 $allLogs = false;
217 }
218 # Get the latest entry with a page_id and oldid
219 # since logs may not have these.
220 if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
221 $curId = $rcObj->mAttribs['rc_cur_id'];
222 }
223
224 if ( !$rcObj->mAttribs['rc_bot'] ) {
225 $collectedRcFlags['bot'] = false;
226 }
227 if ( !$rcObj->mAttribs['rc_minor'] ) {
228 $collectedRcFlags['minor'] = false;
229 }
230
231 $userlinks[$u]++;
232 }
233
234 # Sort the list and convert to text
235 krsort( $userlinks );
236 asort( $userlinks );
237 $users = array();
238 foreach ( $userlinks as $userlink => $count ) {
239 $text = $userlink;
240 $text .= $this->getLanguage()->getDirMark();
241 if ( $count > 1 ) {
242 // @todo FIXME: Hardcoded '×'. Should be a message.
243 $formattedCount = $this->getLanguage()->formatNum( $count ) . '×';
244 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
245 }
246 array_push( $users, $text );
247 }
248
249 # Article link
250 $articleLink = '';
251 $revDeletedMsg = false;
252 if ( $namehidden ) {
253 $revDeletedMsg = $this->msg( 'rev-deleted-event' )->escaped();
254 } elseif ( $allLogs ) {
255 $articleLink = $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
256 } else {
257 $articleLink = $this->getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
258 }
259
260 $queryParams['curid'] = $curId;
261
262 # Sub-entries
263 $lines = array();
264 foreach ( $block as $i => $rcObj ) {
265 $line = $this->getLineData( $block, $rcObj, $queryParams );
266 if ( !$line ) {
267 // completely ignore this RC entry if we don't want to render it
268 unset( $block[$i] );
269 }
270 $lines[] = $line;
271 }
272 // Further down are some assumptions that $block is a 0-indexed array
273 // with (count-1) as last key. Let's make sure it is.
274 $block = array_values( $block );
275
276 if ( empty( $block ) || !$lines ) {
277 // if we can't show anything, don't display this block altogether
278 return '';
279 }
280
281 $logText = $this->getLogText( $block, $queryParams, $allLogs,
282 $collectedRcFlags['newpage'], $namehidden
283 );
284
285 # Character difference (does not apply if only log items)
286 $charDifference = false;
287 if ( $RCShowChangedSize && !$allLogs ) {
288 $last = 0;
289 $first = count( $block ) - 1;
290 # Some events (like logs) have an "empty" size, so we need to skip those...
291 while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
292 $last++;
293 }
294 while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
295 $first--;
296 }
297 # Get net change
298 $charDifference = $this->formatCharacterDifference( $block[$first], $block[$last] );
299 }
300
301 $numberofWatchingusers = $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
302 $usersList = $this->msg( 'brackets' )->rawParams(
303 implode( $this->message['semicolon-separator'], $users )
304 )->escaped();
305
306 $templateParams = array(
307 'articleLink' => $articleLink,
308 'charDifference' => $charDifference,
309 'collectedRcFlags' => $this->recentChangesFlags( $collectedRcFlags ),
310 'languageDirMark' => $this->getLanguage()->getDirMark(),
311 'lines' => $lines,
312 'logText' => $logText,
313 'numberofWatchingusers' => $numberofWatchingusers,
314 'rev-deleted-event' => $revDeletedMsg,
315 'tableClasses' => $tableClasses,
316 'timestamp' => $block[0]->timestamp,
317 'users' => $usersList,
318 );
319
320 $this->rcCacheIndex++;
321
322 $templateParser = new TemplateParser();
323 return $templateParser->processTemplate(
324 'EnhancedChangesListGroup',
325 $templateParams
326 );
327 }
328
329 /**
330 * @param RCCacheEntry[] $block
331 * @param RCCacheEntry $rcObj
332 * @param array $queryParams
333 * @return array
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 $lineParams = array();
346
347 if ( $rcObj->watched
348 && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
349 ) {
350 $lineParams['classes'] = array( 'mw-enhanced-watched' );
351 }
352 $separator = ' <span class="mw-changeslist-separator">. .</span> ';
353
354 $data['recentChangesFlags'] = array(
355 'newpage' => $type == RC_NEW,
356 'minor' => $rcObj->mAttribs['rc_minor'],
357 'unpatrolled' => $rcObj->unpatrolled,
358 'bot' => $rcObj->mAttribs['rc_bot'],
359 );
360
361 $params = $queryParams;
362
363 if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
364 $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
365 }
366
367 # Log timestamp
368 if ( $type == RC_LOG ) {
369 $link = $rcObj->timestamp;
370 # Revision link
371 } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
372 $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
373 } else {
374 $link = Linker::linkKnown(
375 $rcObj->getTitle(),
376 $rcObj->timestamp,
377 array(),
378 $params
379 );
380 if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
381 $link = '<span class="history-deleted">' . $link . '</span> ';
382 }
383 }
384 $data['timestampLink'] = $link;
385
386 $currentAndLastLinks = '';
387 if ( !$type == RC_LOG || $type == RC_NEW ) {
388 $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams(
389 $rcObj->curlink .
390 $this->message['pipe-separator'] .
391 $rcObj->lastlink
392 )->escaped();
393 }
394 $data['currentAndLastLinks'] = $currentAndLastLinks;
395 $data['separatorAfterCurrentAndLastLinks'] = $separator;
396
397 # Character diff
398 if ( $RCShowChangedSize ) {
399 $cd = $this->formatCharacterDifference( $rcObj );
400 if ( $cd !== '' ) {
401 $data['characterDiff'] = $cd;
402 $data['separatorAfterCharacterDiff'] = $separator;
403 }
404 }
405
406 if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
407 $data['logEntry'] = $this->insertLogEntry( $rcObj );
408 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
409 $data['comment'] = $this->insertComment( $rcObj );
410 } else {
411 # User links
412 $data['userLink'] = $rcObj->userlink;
413 $data['userTalkLink'] = $rcObj->usertalklink;
414 $data['comment'] = $this->insertComment( $rcObj );
415 }
416
417 # Rollback
418 $data['rollback'] = $this->getRollback( $rcObj );
419
420 # Tags
421 $data['tags'] = $this->getTags( $rcObj, $classes );
422
423 // give the hook a chance to modify the data
424 $success = Hooks::run( 'EnhancedChangesListModifyLineData',
425 array( $this, &$data, $block, $rcObj ) );
426 if ( !$success ) {
427 // skip entry if hook aborted it
428 return array();
429 }
430
431 if ( isset( $data['recentChangesFlags'] ) ) {
432 $lineParams['recentChangesFlags'] = $this->recentChangesFlags( $data['recentChangesFlags'] );
433 unset( $data['recentChangesFlags'] );
434 }
435
436 if ( isset( $data['timestampLink'] ) ) {
437 $lineParams['timestampLink'] = $data['timestampLink'];
438 unset( $data['timestampLink'] );
439 }
440
441 // everything else: makes it easier for extensions to add or remove data
442 $lineParams['data'] = array_values( $data );
443
444 return $lineParams;
445 }
446
447 /**
448 * Generates amount of changes (linking to diff ) & link to history.
449 *
450 * @param array $block
451 * @param array $queryParams
452 * @param bool $allLogs
453 * @param bool $isnew
454 * @param bool $namehidden
455 * @return string
456 */
457 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
458 if ( empty( $block ) ) {
459 return '';
460 }
461
462 # Changes message
463 static $nchanges = array();
464 static $sinceLastVisitMsg = array();
465
466 $n = count( $block );
467 if ( !isset( $nchanges[$n] ) ) {
468 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
469 }
470
471 $sinceLast = 0;
472 $unvisitedOldid = null;
473 /** @var $rcObj RCCacheEntry */
474 foreach ( $block as $rcObj ) {
475 // Same logic as below inside main foreach
476 if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
477 $sinceLast++;
478 $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
479 }
480 }
481 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
482 $sinceLastVisitMsg[$sinceLast] =
483 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
484 }
485
486 $currentRevision = 0;
487 foreach ( $block as $rcObj ) {
488 if ( !$currentRevision ) {
489 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
490 }
491 }
492
493 # Total change link
494 $links = array();
495 /** @var $block0 RecentChange */
496 $block0 = $block[0];
497 $last = $block[count( $block ) - 1];
498 if ( !$allLogs && $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE ) {
499 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
500 $links['total-changes'] = $nchanges[$n];
501 } elseif ( $isnew ) {
502 $links['total-changes'] = $nchanges[$n];
503 } else {
504 $links['total-changes'] = Linker::link(
505 $block0->getTitle(),
506 $nchanges[$n],
507 array(),
508 $queryParams + array(
509 'diff' => $currentRevision,
510 'oldid' => $last->mAttribs['rc_last_oldid'],
511 ),
512 array( 'known', 'noclasses' )
513 );
514 if ( $sinceLast > 0 && $sinceLast < $n ) {
515 $links['total-changes-since-last'] = Linker::link(
516 $block0->getTitle(),
517 $sinceLastVisitMsg[$sinceLast],
518 array(),
519 $queryParams + array(
520 'diff' => $currentRevision,
521 'oldid' => $unvisitedOldid,
522 ),
523 array( 'known', 'noclasses' )
524 );
525 }
526 }
527 }
528
529 # History
530 if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
531 // don't show history link for logs
532 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
533 $links['history'] = $this->message['enhancedrc-history'];
534 } else {
535 $params = $queryParams;
536 $params['action'] = 'history';
537
538 $links['history'] = Linker::linkKnown(
539 $block0->getTitle(),
540 $this->message['enhancedrc-history'],
541 array(),
542 $params
543 );
544 }
545
546 # Allow others to alter, remove or add to these links
547 Hooks::run( 'EnhancedChangesList::getLogText',
548 array( $this, &$links, $block ) );
549
550 if ( !$links ) {
551 return '';
552 }
553
554 $logtext = implode( $this->message['pipe-separator'], $links );
555 $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
556 return ' ' . $logtext;
557 }
558
559 /**
560 * Enhanced RC ungrouped line.
561 *
562 * @param RecentChange|RCCacheEntry $rcObj
563 * @return string A HTML formatted line (generated using $r)
564 */
565 protected function recentChangesBlockLine( $rcObj ) {
566 $data = array();
567
568 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
569
570 $type = $rcObj->mAttribs['rc_type'];
571 $logType = $rcObj->mAttribs['rc_log_type'];
572 $classes = array( 'mw-enhanced-rc' );
573 if ( $logType ) {
574 # Log entry
575 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
576 } else {
577 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
578 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
579 }
580 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
581 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
582
583 # Flag and Timestamp
584 $data['recentChangesFlags'] = array(
585 'newpage' => $type == RC_NEW,
586 'minor' => $rcObj->mAttribs['rc_minor'],
587 'unpatrolled' => $rcObj->unpatrolled,
588 'bot' => $rcObj->mAttribs['rc_bot'],
589 );
590 // timestamp is not really a link here, but is called timestampLink
591 // for consistency with EnhancedChangesListModifyLineData
592 $data['timestampLink'] = $rcObj->timestamp;
593
594 # Article or log link
595 if ( $logType ) {
596 $logPage = new LogPage( $logType );
597 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
598 $logName = $logPage->getName()->escaped();
599 $data['logLink'] = $this->msg( 'parentheses' )
600 ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
601 } else {
602 $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
603 }
604
605 # Diff and hist links
606 if ( $type != RC_LOG && $type != RC_CATEGORIZE ) {
607 $query['action'] = 'history';
608 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
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 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
624 $data['comment'] = $this->insertComment( $rcObj );
625 } else {
626 $data['userLink'] = $rcObj->userlink;
627 $data['userTalkLink'] = $rcObj->usertalklink;
628 $data['comment'] = $this->insertComment( $rcObj );
629 if ( $type == RC_CATEGORIZE ) {
630 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
631 }
632 $data['rollback'] = $this->getRollback( $rcObj );
633 }
634
635 # Tags
636 $data['tags'] = $this->getTags( $rcObj, $classes );
637
638 # Show how many people are watching this if enabled
639 $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
640
641 // give the hook a chance to modify the data
642 $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData',
643 array( $this, &$data, $rcObj ) );
644 if ( !$success ) {
645 // skip entry if hook aborted it
646 return '';
647 }
648
649 $line = Html::openElement( 'table', array( 'class' => $classes ) ) .
650 Html::openElement( 'tr' );
651 $line .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
652
653 if ( isset( $data['recentChangesFlags'] ) ) {
654 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
655 unset( $data['recentChangesFlags'] );
656 }
657
658 if ( isset( $data['timestampLink'] ) ) {
659 $line .= '&#160;' . $data['timestampLink'];
660 unset( $data['timestampLink'] );
661 }
662 $line .= '&#160;</td><td>';
663
664 // everything else: makes it easier for extensions to add or remove data
665 $line .= implode( '', $data );
666
667 $line .= "</td></tr></table>\n";
668
669 return $line;
670 }
671
672 /**
673 * Returns value to be used in 'historyLink' element of $data param in
674 * EnhancedChangesListModifyBlockLineData hook.
675 *
676 * @since 1.27
677 *
678 * @param RCCacheEntry $rc
679 * @param array $query array of key/value pairs to append as a query string
680 * @return string HTML
681 */
682 public function getDiffHistLinks( RCCacheEntry $rc, array $query ) {
683 $pageTitle = $rc->getTitle();
684 if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
685 // For categorizations we must swap the category title with the page title!
686 $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
687 }
688
689 $retVal = ' ' . $this->msg( 'parentheses' )
690 ->rawParams( $rc->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
691 $pageTitle,
692 $this->message['hist'],
693 array(),
694 $query
695 ) )->escaped();
696 return $retVal;
697 }
698
699 /**
700 * If enhanced RC is in use, this function takes the previously cached
701 * RC lines, arranges them, and outputs the HTML
702 *
703 * @return string
704 */
705 protected function recentChangesBlock() {
706 if ( count( $this->rc_cache ) == 0 ) {
707 return '';
708 }
709
710 $blockOut = '';
711 foreach ( $this->rc_cache as $block ) {
712 if ( count( $block ) < 2 ) {
713 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
714 } else {
715 $blockOut .= $this->recentChangesBlockGroup( $block );
716 }
717 }
718
719 return '<div>' . $blockOut . '</div>';
720 }
721
722 /**
723 * Returns text for the end of RC
724 * If enhanced RC is in use, returns pretty much all the text
725 * @return string
726 */
727 public function endRecentChangesList() {
728 return $this->recentChangesBlock() . '</div>';
729 }
730 }