Http::getProxy() method to get proxy configuration
[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 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
410 $data['comment'] = $this->insertComment( $rcObj );
411 } else {
412 # User links
413 $data['userLink'] = $rcObj->userlink;
414 $data['userTalkLink'] = $rcObj->usertalklink;
415 $data['comment'] = $this->insertComment( $rcObj );
416 }
417
418 # Rollback
419 $data['rollback'] = $this->getRollback( $rcObj );
420
421 # Tags
422 $data['tags'] = $this->getTags( $rcObj, $classes );
423
424 // give the hook a chance to modify the data
425 $success = Hooks::run( 'EnhancedChangesListModifyLineData',
426 array( $this, &$data, $block, $rcObj ) );
427 if ( !$success ) {
428 // skip entry if hook aborted it
429 return '';
430 }
431
432 $line = '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
433 if ( isset( $data['recentChangesFlags'] ) ) {
434 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
435 unset( $data['recentChangesFlags'] );
436 }
437 $line .= '&#160;</td><td class="mw-enhanced-rc-nested">';
438
439 if ( isset( $data['timestampLink'] ) ) {
440 $line .= '<span class="mw-enhanced-rc-time">' . $data['timestampLink'] . '</span>';
441 unset( $data['timestampLink'] );
442 }
443
444 // everything else: makes it easier for extensions to add or remove data
445 $line .= implode( '', $data );
446
447 $line .= "</td></tr>\n";
448
449 return $line;
450 }
451
452 /**
453 * Generates amount of changes (linking to diff ) & link to history.
454 *
455 * @param array $block
456 * @param array $queryParams
457 * @param bool $allLogs
458 * @param bool $isnew
459 * @param bool $namehidden
460 * @return string
461 */
462 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
463 if ( empty( $block ) ) {
464 return '';
465 }
466
467 # Changes message
468 static $nchanges = array();
469 static $sinceLastVisitMsg = array();
470
471 $n = count( $block );
472 if ( !isset( $nchanges[$n] ) ) {
473 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
474 }
475
476 $sinceLast = 0;
477 $unvisitedOldid = null;
478 /** @var $rcObj RCCacheEntry */
479 foreach ( $block as $rcObj ) {
480 // Same logic as below inside main foreach
481 if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
482 $sinceLast++;
483 $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
484 }
485 }
486 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
487 $sinceLastVisitMsg[$sinceLast] =
488 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
489 }
490
491 $currentRevision = 0;
492 foreach ( $block as $rcObj ) {
493 if ( !$currentRevision ) {
494 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
495 }
496 }
497
498 # Total change link
499 $links = array();
500 /** @var $block0 RecentChange */
501 $block0 = $block[0];
502 $last = $block[count( $block ) - 1];
503 if ( !$allLogs && $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE ) {
504 if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
505 $links['total-changes'] = $nchanges[$n];
506 } elseif ( $isnew ) {
507 $links['total-changes'] = $nchanges[$n];
508 } else {
509 $links['total-changes'] = Linker::link(
510 $block0->getTitle(),
511 $nchanges[$n],
512 array(),
513 $queryParams + array(
514 'diff' => $currentRevision,
515 'oldid' => $last->mAttribs['rc_last_oldid'],
516 ),
517 array( 'known', 'noclasses' )
518 );
519 if ( $sinceLast > 0 && $sinceLast < $n ) {
520 $links['total-changes-since-last'] = Linker::link(
521 $block0->getTitle(),
522 $sinceLastVisitMsg[$sinceLast],
523 array(),
524 $queryParams + array(
525 'diff' => $currentRevision,
526 'oldid' => $unvisitedOldid,
527 ),
528 array( 'known', 'noclasses' )
529 );
530 }
531 }
532 }
533
534 # History
535 if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
536 // don't show history link for logs
537 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
538 $links['history'] = $this->message['enhancedrc-history'];
539 } else {
540 $params = $queryParams;
541 $params['action'] = 'history';
542
543 $links['history'] = Linker::linkKnown(
544 $block0->getTitle(),
545 $this->message['enhancedrc-history'],
546 array(),
547 $params
548 );
549 }
550
551 # Allow others to alter, remove or add to these links
552 Hooks::run( 'EnhancedChangesList::getLogText',
553 array( $this, &$links, $block ) );
554
555 if ( !$links ) {
556 return '';
557 }
558
559 $logtext = implode( $this->message['pipe-separator'], $links );
560 $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
561 return ' ' . $logtext;
562 }
563
564 /**
565 * Enhanced RC ungrouped line.
566 *
567 * @param RecentChange|RCCacheEntry $rcObj
568 * @return string A HTML formatted line (generated using $r)
569 */
570 protected function recentChangesBlockLine( $rcObj ) {
571 $data = array();
572
573 $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
574
575 $type = $rcObj->mAttribs['rc_type'];
576 $logType = $rcObj->mAttribs['rc_log_type'];
577 $classes = array( 'mw-enhanced-rc' );
578 if ( $logType ) {
579 # Log entry
580 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
581 } else {
582 $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
583 $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
584 }
585 $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
586 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
587
588 # Flag and Timestamp
589 $data['recentChangesFlags'] = array(
590 'newpage' => $type == RC_NEW,
591 'minor' => $rcObj->mAttribs['rc_minor'],
592 'unpatrolled' => $rcObj->unpatrolled,
593 'bot' => $rcObj->mAttribs['rc_bot'],
594 );
595 // timestamp is not really a link here, but is called timestampLink
596 // for consistency with EnhancedChangesListModifyLineData
597 $data['timestampLink'] = $rcObj->timestamp;
598
599 # Article or log link
600 if ( $logType ) {
601 $logPage = new LogPage( $logType );
602 $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
603 $logName = $logPage->getName()->escaped();
604 $data['logLink'] = $this->msg( 'parentheses' )
605 ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
606 } else {
607 $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
608 }
609
610 # Diff and hist links
611 if ( $type != RC_LOG && $type != RC_CATEGORIZE ) {
612 $query['action'] = 'history';
613 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
614 }
615 $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
616
617 # Character diff
618 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
619 $cd = $this->formatCharacterDifference( $rcObj );
620 if ( $cd !== '' ) {
621 $data['characterDiff'] = $cd;
622 $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> ';
623 }
624 }
625
626 if ( $type == RC_LOG ) {
627 $data['logEntry'] = $this->insertLogEntry( $rcObj );
628 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
629 $data['comment'] = $this->insertComment( $rcObj );
630 } else {
631 $data['userLink'] = $rcObj->userlink;
632 $data['userTalkLink'] = $rcObj->usertalklink;
633 $data['comment'] = $this->insertComment( $rcObj );
634 if ( $type == RC_CATEGORIZE ) {
635 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
636 }
637 $data['rollback'] = $this->getRollback( $rcObj );
638 }
639
640 # Tags
641 $data['tags'] = $this->getTags( $rcObj, $classes );
642
643 # Show how many people are watching this if enabled
644 $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
645
646 // give the hook a chance to modify the data
647 $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData',
648 array( $this, &$data, $rcObj ) );
649 if ( !$success ) {
650 // skip entry if hook aborted it
651 return '';
652 }
653
654 $line = Html::openElement( 'table', array( 'class' => $classes ) ) .
655 Html::openElement( 'tr' );
656 $line .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
657
658 if ( isset( $data['recentChangesFlags'] ) ) {
659 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
660 unset( $data['recentChangesFlags'] );
661 }
662
663 if ( isset( $data['timestampLink'] ) ) {
664 $line .= '&#160;' . $data['timestampLink'];
665 unset( $data['timestampLink'] );
666 }
667 $line .= '&#160;</td><td>';
668
669 // everything else: makes it easier for extensions to add or remove data
670 $line .= implode( '', $data );
671
672 $line .= "</td></tr></table>\n";
673
674 return $line;
675 }
676
677 /**
678 * Returns value to be used in 'historyLink' element of $data param in
679 * EnhancedChangesListModifyBlockLineData hook.
680 *
681 * @since 1.27
682 *
683 * @param RCCacheEntry $rc
684 * @param array $query array of key/value pairs to append as a query string
685 * @return string HTML
686 */
687 public function getDiffHistLinks( RCCacheEntry $rc, array $query ) {
688 $pageTitle = $rc->getTitle();
689 if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
690 // For categorizations we must swap the category title with the page title!
691 $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
692 }
693
694 $retVal = ' ' . $this->msg( 'parentheses' )
695 ->rawParams( $rc->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
696 $pageTitle,
697 $this->message['hist'],
698 array(),
699 $query
700 ) )->escaped();
701 return $retVal;
702 }
703
704 /**
705 * If enhanced RC is in use, this function takes the previously cached
706 * RC lines, arranges them, and outputs the HTML
707 *
708 * @return string
709 */
710 protected function recentChangesBlock() {
711 if ( count( $this->rc_cache ) == 0 ) {
712 return '';
713 }
714
715 $blockOut = '';
716 foreach ( $this->rc_cache as $block ) {
717 if ( count( $block ) < 2 ) {
718 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
719 } else {
720 $blockOut .= $this->recentChangesBlockGroup( $block );
721 }
722 }
723
724 return '<div>' . $blockOut . '</div>';
725 }
726
727 /**
728 * Returns text for the end of RC
729 * If enhanced RC is in use, returns pretty much all the text
730 * @return string
731 */
732 public function endRecentChangesList() {
733 return $this->recentChangesBlock() . '</div>';
734 }
735 }