MediaWiki  master
EnhancedChangesList.php
Go to the documentation of this file.
1 <?php
2 
4 
27 
31  protected $cacheEntryFactory;
32 
36  protected $rc_cache;
37 
41  protected $templateParser;
42 
48  public function __construct( $obj, array $filterGroups = [] ) {
49  if ( $obj instanceof Skin ) {
50  // @todo: deprecate constructing with Skin
51  $context = $obj->getContext();
52  } else {
53  if ( !$obj instanceof IContextSource ) {
54  throw new MWException( 'EnhancedChangesList must be constructed with a '
55  . 'context source or skin.' );
56  }
57 
58  $context = $obj;
59  }
60 
61  parent::__construct( $context, $filterGroups );
62 
63  // message is set by the parent ChangesList class
64  $this->cacheEntryFactory = new RCCacheEntryFactory(
65  $context,
66  $this->message,
67  $this->linkRenderer
68  );
69  $this->templateParser = new TemplateParser();
70  }
71 
76  public function beginRecentChangesList() {
77  $this->getOutput()->addModuleStyles( [
78  'mediawiki.icon',
79  'mediawiki.special.changeslist.enhanced',
80  ] );
81  $this->getOutput()->addModules( [
82  'jquery.makeCollapsible',
83  ] );
84 
85  parent::beginRecentChangesList();
86  return '<div class="mw-changeslist" aria-live="polite">';
87  }
88 
98  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
99  $date = $this->getLanguage()->userDate(
100  $rc->mAttribs['rc_timestamp'],
101  $this->getUser()
102  );
103  if ( $this->lastdate === '' ) {
104  $this->lastdate = $date;
105  }
106 
107  $ret = '';
108 
109  # If it's a new day, flush the cache and update $this->lastdate
110  if ( $date !== $this->lastdate ) {
111  # Process current cache (uses $this->lastdate to generate a heading)
112  $ret = $this->recentChangesBlock();
113  $this->rc_cache = [];
114  $this->lastdate = $date;
115  }
116 
117  $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
118  $this->addCacheEntry( $cacheEntry );
119 
120  return $ret;
121  }
122 
129  protected function addCacheEntry( RCCacheEntry $cacheEntry ) {
130  $cacheGroupingKey = $this->makeCacheGroupingKey( $cacheEntry );
131 
132  if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
133  $this->rc_cache[$cacheGroupingKey] = [];
134  }
135 
136  array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
137  }
138 
146  protected function makeCacheGroupingKey( RCCacheEntry $cacheEntry ) {
147  $title = $cacheEntry->getTitle();
148  $cacheGroupingKey = $title->getPrefixedDBkey();
149 
150  $type = $cacheEntry->mAttribs['rc_type'];
151 
152  if ( $type == RC_LOG ) {
153  // Group by log type
154  $cacheGroupingKey = SpecialPage::getTitleFor(
155  'Log',
156  $cacheEntry->mAttribs['rc_log_type']
157  )->getPrefixedDBkey();
158  }
159 
160  return $cacheGroupingKey;
161  }
162 
169  protected function recentChangesBlockGroup( $block ) {
170  $recentChangesFlags = $this->getConfig()->get( 'RecentChangesFlags' );
171 
172  # Add the namespace and title of the block as part of the class
173  $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc', 'mw-changeslist-line' ];
174  if ( $block[0]->mAttribs['rc_log_type'] ) {
175  # Log entry
176  $tableClasses[] = 'mw-changeslist-log';
177  $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
178  . $block[0]->mAttribs['rc_log_type'] );
179  } else {
180  $tableClasses[] = 'mw-changeslist-edit';
181  $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
182  . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
183  }
184  if ( $block[0]->watched ) {
185  $tableClasses[] = 'mw-changeslist-line-watched';
186  } else {
187  $tableClasses[] = 'mw-changeslist-line-not-watched';
188  }
189 
190  # Collate list of users
191  $userlinks = [];
192  # Other properties
193  $curId = 0;
194  # Some catalyst variables...
195  $namehidden = true;
196  $allLogs = true;
197  $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
198 
199  # Default values for RC flags
200  $collectedRcFlags = [];
201  foreach ( $recentChangesFlags as $key => $value ) {
202  $flagGrouping = $value['grouping'] ?? 'any';
203  switch ( $flagGrouping ) {
204  case 'all':
205  $collectedRcFlags[$key] = true;
206  break;
207  case 'any':
208  $collectedRcFlags[$key] = false;
209  break;
210  default:
211  throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
212  }
213  }
214  foreach ( $block as $rcObj ) {
215  // If all log actions to this page were hidden, then don't
216  // give the name of the affected page for this block!
217  if ( !static::isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
218  $namehidden = false;
219  }
220  $u = $rcObj->userlink;
221  if ( !isset( $userlinks[$u] ) ) {
222  $userlinks[$u] = 0;
223  }
224  if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
225  $allLogs = false;
226  }
227  # Get the latest entry with a page_id and oldid
228  # since logs may not have these.
229  if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
230  $curId = $rcObj->mAttribs['rc_cur_id'];
231  }
232 
233  $userlinks[$u]++;
234  }
235 
236  # Sort the list and convert to text
237  krsort( $userlinks );
238  asort( $userlinks );
239  $users = [];
240  foreach ( $userlinks as $userlink => $count ) {
241  $text = $userlink;
242  $text .= $this->getLanguage()->getDirMark();
243  if ( $count > 1 ) {
244  $formattedCount = $this->msg( 'ntimes' )->numParams( $count )->escaped();
245  $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
246  }
247  array_push( $users, $text );
248  }
249 
250  # Article link
251  $articleLink = '';
252  $revDeletedMsg = false;
253  if ( $namehidden ) {
254  $revDeletedMsg = $this->msg( 'rev-deleted-event' )->escaped();
255  } elseif ( $allLogs ) {
256  $articleLink = $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
257  } else {
258  $articleLink = $this->getArticleLink(
259  $block[0], $block[0]->unpatrolled, $block[0]->watched );
260  }
261 
262  $queryParams = [ 'curid' => $curId ];
263 
264  # Sub-entries
265  $lines = [];
266  $filterClasses = [];
267  foreach ( $block as $i => $rcObj ) {
268  $line = $this->getLineData( $block, $rcObj, $queryParams );
269  if ( !$line ) {
270  // completely ignore this RC entry if we don't want to render it
271  unset( $block[$i] );
272  continue;
273  }
274 
275  // Roll up flags
276  foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
277  $flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
278  switch ( $flagGrouping ) {
279  case 'all':
280  if ( !$value ) {
281  $collectedRcFlags[$key] = false;
282  }
283  break;
284  case 'any':
285  if ( $value ) {
286  $collectedRcFlags[$key] = true;
287  }
288  break;
289  default:
290  throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
291  }
292  }
293 
294  // Roll up filter-based CSS classes
295  $filterClasses = array_merge( $filterClasses, $this->getHTMLClassesForFilters( $rcObj ) );
296  // Add classes for change tags separately, getHTMLClassesForFilters() doesn't add them
297  $this->getTags( $rcObj, $filterClasses );
298  $filterClasses = array_unique( $filterClasses );
299 
300  $lines[] = $line;
301  }
302 
303  // Further down are some assumptions that $block is a 0-indexed array
304  // with (count-1) as last key. Let's make sure it is.
305  $block = array_values( $block );
306  $filterClasses = array_values( $filterClasses );
307 
308  if ( empty( $block ) || !$lines ) {
309  // if we can't show anything, don't display this block altogether
310  return '';
311  }
312 
313  $logText = $this->getLogText( $block, $queryParams, $allLogs,
314  $collectedRcFlags['newpage'], $namehidden
315  );
316 
317  # Character difference (does not apply if only log items)
318  $charDifference = false;
319  if ( $RCShowChangedSize && !$allLogs ) {
320  $last = 0;
321  $first = count( $block ) - 1;
322  # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
323  while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
324  $last++;
325  }
326  while ( $last < $first && $block[$first]->mAttribs['rc_old_len'] === null ) {
327  $first--;
328  }
329  # Get net change
330  $charDifference = $this->formatCharacterDifference( $block[$first], $block[$last] ) ?: false;
331  }
332 
333  $numberofWatchingusers = $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
334  $usersList = $this->msg( 'brackets' )->rawParams(
335  implode( $this->message['semicolon-separator'], $users )
336  )->escaped();
337 
338  $prefix = '';
339  if ( is_callable( $this->changeLinePrefixer ) ) {
340  $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this, true );
341  }
342 
343  $templateParams = [
344  'articleLink' => $articleLink,
345  'charDifference' => $charDifference,
346  'collectedRcFlags' => $this->recentChangesFlags( $collectedRcFlags ),
347  'filterClasses' => $filterClasses,
348  'languageDirMark' => $this->getLanguage()->getDirMark(),
349  'lines' => $lines,
350  'logText' => $logText,
351  'numberofWatchingusers' => $numberofWatchingusers,
352  'prefix' => $prefix,
353  'rev-deleted-event' => $revDeletedMsg,
354  'tableClasses' => $tableClasses,
355  'timestamp' => $block[0]->timestamp,
356  'fullTimestamp' => $block[0]->getAttribute( 'rc_timestamp' ),
357  'users' => $usersList,
358  ];
359 
360  $this->rcCacheIndex++;
361 
362  return $this->templateParser->processTemplate(
363  'EnhancedChangesListGroup',
364  $templateParams
365  );
366  }
367 
377  protected function getLineData( array $block, RCCacheEntry $rcObj, array $queryParams = [] ) {
378  $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
379 
380  $type = $rcObj->mAttribs['rc_type'];
381  $data = [];
382  $lineParams = [ 'targetTitle' => $rcObj->getTitle() ];
383 
384  $classes = [ 'mw-enhanced-rc' ];
385  if ( $rcObj->watched ) {
386  $classes[] = 'mw-enhanced-watched';
387  }
388  $classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched ) );
389 
390  $separator = ' <span class="mw-changeslist-separator"></span> ';
391 
392  $data['recentChangesFlags'] = [
393  'newpage' => $type == RC_NEW,
394  'minor' => $rcObj->mAttribs['rc_minor'],
395  'unpatrolled' => $rcObj->unpatrolled,
396  'bot' => $rcObj->mAttribs['rc_bot'],
397  ];
398 
399  $params = $queryParams;
400 
401  if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
402  $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
403  }
404 
405  # Log timestamp
406  if ( $type == RC_LOG ) {
407  $link = htmlspecialchars( $rcObj->timestamp );
408  # Revision link
409  } elseif ( !ChangesList::userCan( $rcObj, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
410  $link = Html::element( 'span', [ 'class' => 'history-deleted' ], $rcObj->timestamp );
411  } else {
412  $link = $this->linkRenderer->makeKnownLink(
413  $rcObj->getTitle(),
414  $rcObj->timestamp,
415  [],
416  $params
417  );
418  if ( static::isDeleted( $rcObj, RevisionRecord::DELETED_TEXT ) ) {
419  $link = '<span class="history-deleted">' . $link . '</span> ';
420  }
421  }
422  $data['timestampLink'] = $link;
423 
424  $currentAndLastLinks = '';
425  if ( !$type == RC_LOG || $type == RC_NEW ) {
426  $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams(
427  $rcObj->curlink .
428  $this->message['pipe-separator'] .
429  $rcObj->lastlink
430  )->escaped();
431  }
432  $data['currentAndLastLinks'] = $currentAndLastLinks;
433  $data['separatorAfterCurrentAndLastLinks'] = $separator;
434 
435  # Character diff
436  if ( $RCShowChangedSize ) {
437  $cd = $this->formatCharacterDifference( $rcObj );
438  if ( $cd !== '' ) {
439  $data['characterDiff'] = $cd;
440  $data['separatorAfterCharacterDiff'] = $separator;
441  }
442  }
443 
444  if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
445  $data['logEntry'] = $this->insertLogEntry( $rcObj );
446  } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
447  $data['comment'] = $this->insertComment( $rcObj );
448  } else {
449  # User links
450  $data['userLink'] = $rcObj->userlink;
451  $data['userTalkLink'] = $rcObj->usertalklink;
452  $data['comment'] = $this->insertComment( $rcObj );
453  }
454 
455  # Rollback
456  $data['rollback'] = $this->getRollback( $rcObj );
457 
458  # Tags
459  $data['tags'] = $this->getTags( $rcObj, $classes );
460 
461  $attribs = $this->getDataAttributes( $rcObj );
462 
463  // give the hook a chance to modify the data
464  $success = $this->getHookRunner()->onEnhancedChangesListModifyLineData(
465  $this, $data, $block, $rcObj, $classes, $attribs );
466  if ( !$success ) {
467  // skip entry if hook aborted it
468  return [];
469  }
470  $attribs = array_filter( $attribs,
471  [ Sanitizer::class, 'isReservedDataAttribute' ],
472  ARRAY_FILTER_USE_KEY
473  );
474 
475  $lineParams['recentChangesFlagsRaw'] = [];
476  if ( isset( $data['recentChangesFlags'] ) ) {
477  $lineParams['recentChangesFlags'] = $this->recentChangesFlags( $data['recentChangesFlags'] );
478  # FIXME: This is used by logic, don't return it in the template params.
479  $lineParams['recentChangesFlagsRaw'] = $data['recentChangesFlags'];
480  unset( $data['recentChangesFlags'] );
481  }
482 
483  if ( isset( $data['timestampLink'] ) ) {
484  $lineParams['timestampLink'] = $data['timestampLink'];
485  unset( $data['timestampLink'] );
486  }
487 
488  $lineParams['classes'] = array_values( $classes );
489  $lineParams['attribs'] = Html::expandAttributes( $attribs );
490 
491  // everything else: makes it easier for extensions to add or remove data
492  $lineParams['data'] = array_values( $data );
493 
494  return $lineParams;
495  }
496 
507  protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
508  if ( empty( $block ) ) {
509  return '';
510  }
511 
512  # Changes message
513  static $nchanges = [];
514  static $sinceLastVisitMsg = [];
515 
516  $n = count( $block );
517  if ( !isset( $nchanges[$n] ) ) {
518  $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
519  }
520 
521  $sinceLast = 0;
522  $unvisitedOldid = null;
524  foreach ( $block as $rcObj ) {
525  // Same logic as below inside main foreach
526  if ( $rcObj->watched ) {
527  $sinceLast++;
528  $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
529  }
530  }
531  if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
532  $sinceLastVisitMsg[$sinceLast] =
533  $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
534  }
535 
536  $currentRevision = 0;
537  foreach ( $block as $rcObj ) {
538  if ( !$currentRevision ) {
539  $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
540  }
541  }
542 
543  # Total change link
544  $links = [];
546  $block0 = $block[0];
547  $last = $block[count( $block ) - 1];
548  if ( !$allLogs ) {
549  if (
550  $isnew ||
551  $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ||
552  !ChangesList::userCan( $rcObj, RevisionRecord::DELETED_TEXT, $this->getAuthority() )
553  ) {
554  $links['total-changes'] = Html::rawElement( 'span', [], $nchanges[$n] );
555  } else {
556  $links['total-changes'] = Html::rawElement( 'span', [],
557  $this->linkRenderer->makeKnownLink(
558  $block0->getTitle(),
559  new HtmlArmor( $nchanges[$n] ),
560  [ 'class' => 'mw-changeslist-groupdiff' ],
561  $queryParams + [
562  'diff' => $currentRevision,
563  'oldid' => $last->mAttribs['rc_last_oldid'],
564  ]
565  )
566  );
567  }
568 
569  if (
570  $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE &&
571  $sinceLast > 0 &&
572  $sinceLast < $n
573  ) {
574  $links['total-changes-since-last'] = Html::rawElement( 'span', [],
575  $this->linkRenderer->makeKnownLink(
576  $block0->getTitle(),
577  new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
578  [ 'class' => 'mw-changeslist-groupdiff' ],
579  $queryParams + [
580  'diff' => $currentRevision,
581  'oldid' => $unvisitedOldid,
582  ]
583  )
584  );
585  }
586  }
587 
588  # History
589  if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
590  // don't show history link for logs
591  } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
592  $links['history'] = Html::rawElement( 'span', [], $this->message['enhancedrc-history'] );
593  } else {
594  $params = $queryParams;
595  $params['action'] = 'history';
596 
597  $links['history'] = Html::rawElement( 'span', [],
598  $this->linkRenderer->makeKnownLink(
599  $block0->getTitle(),
600  new HtmlArmor( $this->message['enhancedrc-history'] ),
601  [ 'class' => 'mw-changeslist-history' ],
602  $params
603  )
604  );
605  }
606 
607  # Allow others to alter, remove or add to these links
608  $this->getHookRunner()->onEnhancedChangesList__getLogText( $this, $links, $block );
609 
610  if ( !$links ) {
611  return '';
612  }
613 
614  $logtext = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
615  implode( ' ', $links ) );
616  return ' ' . $logtext;
617  }
618 
625  protected function recentChangesBlockLine( $rcObj ) {
626  $data = [];
627 
628  $type = $rcObj->mAttribs['rc_type'];
629  $logType = $rcObj->mAttribs['rc_log_type'];
630  $classes = $this->getHTMLClasses( $rcObj, $rcObj->watched );
631  $classes[] = 'mw-enhanced-rc';
632 
633  if ( $logType ) {
634  # Log entry
635  $classes[] = 'mw-changeslist-log';
636  $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
637  } else {
638  $classes[] = 'mw-changeslist-edit';
639  $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
640  $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
641  }
642 
643  # Flag and Timestamp
644  $data['recentChangesFlags'] = [
645  'newpage' => $type == RC_NEW,
646  'minor' => $rcObj->mAttribs['rc_minor'],
647  'unpatrolled' => $rcObj->unpatrolled,
648  'bot' => $rcObj->mAttribs['rc_bot'],
649  ];
650  // timestamp is not really a link here, but is called timestampLink
651  // for consistency with EnhancedChangesListModifyLineData
652  $data['timestampLink'] = htmlspecialchars( $rcObj->timestamp );
653 
654  # Article or log link
655  if ( $logType ) {
656  $logPage = new LogPage( $logType );
657  $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
658  $logName = $logPage->getName()->text();
659  $data['logLink'] = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
660  $this->linkRenderer->makeKnownLink( $logTitle, $logName )
661  );
662  } else {
663  $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
664  }
665 
666  # Diff and hist links
667  if ( $type != RC_LOG && $type != RC_CATEGORIZE ) {
668  $data['historyLink'] = $this->getDiffHistLinks( $rcObj, false );
669  }
670  $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator"></span> ';
671 
672  # Character diff
673  if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
674  $cd = $this->formatCharacterDifference( $rcObj );
675  if ( $cd !== '' ) {
676  $data['characterDiff'] = $cd;
677  $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator"></span> ';
678  }
679  }
680 
681  if ( $type == RC_LOG ) {
682  $data['logEntry'] = $this->insertLogEntry( $rcObj );
683  } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
684  $data['comment'] = $this->insertComment( $rcObj );
685  } else {
686  $data['userLink'] = $rcObj->userlink;
687  $data['userTalkLink'] = $rcObj->usertalklink;
688  $data['comment'] = $this->insertComment( $rcObj );
689  if ( $type == RC_CATEGORIZE ) {
690  $data['historyLink'] = $this->getDiffHistLinks( $rcObj, false );
691  }
692  $data['rollback'] = $this->getRollback( $rcObj );
693  }
694 
695  # Tags
696  $data['tags'] = $this->getTags( $rcObj, $classes );
697 
698  # Show how many people are watching this if enabled
699  $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
700 
701  $data['attribs'] = array_merge( $this->getDataAttributes( $rcObj ), [ 'class' => $classes ] );
702 
703  // give the hook a chance to modify the data
704  $success = $this->getHookRunner()->onEnhancedChangesListModifyBlockLineData(
705  $this, $data, $rcObj );
706  if ( !$success ) {
707  // skip entry if hook aborted it
708  return '';
709  }
710  $attribs = $data['attribs'];
711  unset( $data['attribs'] );
712  $attribs = array_filter( $attribs, static function ( $key ) {
713  return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
714  }, ARRAY_FILTER_USE_KEY );
715 
716  $prefix = '';
717  if ( is_callable( $this->changeLinePrefixer ) ) {
718  $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this, false );
719  }
720 
721  $line = Html::openElement( 'table', $attribs ) . Html::openElement( 'tr' );
722  // Highlight block
723  $line .= Html::rawElement( 'td', [],
725  );
726 
727  $line .= Html::rawElement( 'td', [], '<span class="mw-enhancedchanges-arrow-space"></span>' );
728  $line .= Html::rawElement( 'td', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix );
729  $line .= '<td class="mw-enhanced-rc" colspan="2">';
730 
731  if ( isset( $data['recentChangesFlags'] ) ) {
732  $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
733  unset( $data['recentChangesFlags'] );
734  }
735 
736  if ( isset( $data['timestampLink'] ) ) {
737  $line .= "\u{00A0}" . $data['timestampLink'];
738  unset( $data['timestampLink'] );
739  }
740  $line .= "\u{00A0}</td>";
741  $line .= Html::openElement( 'td', [
742  'class' => 'mw-changeslist-line-inner',
743  // Used for reliable determination of the affiliated page
744  'data-target-page' => $rcObj->getTitle(),
745  ] );
746 
747  // everything else: makes it easier for extensions to add or remove data
748  foreach ( $data as $key => $dataItem ) {
749  $line .= Html::rawElement( 'span', [
750  'class' => 'mw-changeslist-line-inner-' . $key,
751  ], $dataItem );
752  }
753 
754  $line .= "</td></tr></table>\n";
755 
756  return $line;
757  }
758 
770  public function getDiffHistLinks( RCCacheEntry $rc, $query = null, $useParentheses = null ) {
771  if ( is_bool( $query ) ) {
772  $useParentheses = $query;
773  } elseif ( $query !== null ) {
774  wfDeprecated( __METHOD__ . ' with $query parameter', '1.36' );
775  }
776  if ( $useParentheses === null ) {
777  $useParentheses = true;
778  }
779  $pageTitle = $rc->getTitle();
780  if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
781  // For categorizations we must swap the category title with the page title!
782  $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
783  if ( !$pageTitle ) {
784  // The page has been deleted, but the RC entry
785  // deletion job has not run yet. Just skip.
786  return '';
787  }
788  }
789 
790  $histLink = $this->linkRenderer->makeKnownLink(
791  $pageTitle,
792  new HtmlArmor( $this->message['hist'] ),
793  [ 'class' => 'mw-changeslist-history' ],
794  [
795  'action' => 'history',
796  'curid' => $rc->getAttribute( 'rc_cur_id' )
797  ]
798  );
799  if ( $useParentheses ) {
800  $retVal = $this->msg( 'parentheses' )
801  ->rawParams( $rc->difflink . $this->message['pipe-separator']
802  . $histLink )->escaped();
803  } else {
804  $retVal = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
805  Html::rawElement( 'span', [], $rc->difflink ) .
806  Html::rawElement( 'span', [], $histLink )
807  );
808  }
809  return ' ' . $retVal;
810  }
811 
818  protected function recentChangesBlock() {
819  if ( count( $this->rc_cache ) == 0 ) {
820  return '';
821  }
822 
823  $blockOut = '';
824  foreach ( $this->rc_cache as $block ) {
825  if ( count( $block ) < 2 ) {
826  $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
827  } else {
828  $blockOut .= $this->recentChangesBlockGroup( $block );
829  }
830  }
831 
832  if ( $blockOut === '' ) {
833  return '';
834  }
835  // $this->lastdate is kept up to date by recentChangesLine()
836  return Xml::element( 'h4', null, $this->lastdate ) . "\n<div>" . $blockOut . '</div>';
837  }
838 
844  public function endRecentChangesList() {
845  return $this->recentChangesBlock() . '</div>';
846  }
847 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:39
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:72
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
EnhancedChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line for enhanced recentchange (aka with javascript and block of lines).
Definition: EnhancedChangesList.php:98
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:704
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:47
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:779
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:859
Html\expandAttributes
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
Definition: Html.php:483
EnhancedChangesList\makeCacheGroupingKey
makeCacheGroupingKey(RCCacheEntry $cacheEntry)
Definition: EnhancedChangesList.php:146
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:131
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:107
RCCacheEntryFactory
Definition: RCCacheEntryFactory.php:26
Sanitizer\escapeClass
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:972
$success
$success
Definition: NoLocalSettings.php:42
RC_NEW
const RC_NEW
Definition: Defines.php:116
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:390
RecentChange\getTitle
getTitle()
Definition: RecentChange.php:329
EnhancedChangesList\$cacheEntryFactory
RCCacheEntryFactory $cacheEntryFactory
Definition: EnhancedChangesList.php:31
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:153
EnhancedChangesList\getLineData
getLineData(array $block, RCCacheEntry $rcObj, array $queryParams=[])
Definition: EnhancedChangesList.php:377
ChangesList\$filterGroups
array $filterGroups
Definition: ChangesList.php:67
RC_LOG
const RC_LOG
Definition: Defines.php:117
EnhancedChangesList\endRecentChangesList
endRecentChangesList()
Returns text for the end of RC If enhanced RC is in use, returns pretty much all the text.
Definition: EnhancedChangesList.php:844
MWException
MediaWiki exception.
Definition: MWException.php:29
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:996
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:688
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:126
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:38
EnhancedChangesList\beginRecentChangesList
beginRecentChangesList()
Add the JavaScript file for enhanced changeslist.
Definition: EnhancedChangesList.php:76
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
$title
$title
Definition: testCompression.php:38
EnhancedChangesList\recentChangesBlockGroup
recentChangesBlockGroup( $block)
Enhanced RC group.
Definition: EnhancedChangesList.php:169
EnhancedChangesList\__construct
__construct( $obj, array $filterGroups=[])
Definition: EnhancedChangesList.php:48
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:828
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:39
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
Definition: ChangesList.php:551
EnhancedChangesList\getDiffHistLinks
getDiffHistLinks(RCCacheEntry $rc, $query=null, $useParentheses=null)
Returns value to be used in 'historyLink' element of $data param in EnhancedChangesListModifyBlockLin...
Definition: EnhancedChangesList.php:770
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:923
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:197
EnhancedChangesList
Definition: EnhancedChangesList.php:26
EnhancedChangesList\getLogText
getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden)
Generates amount of changes (linking to diff ) & link to history.
Definition: EnhancedChangesList.php:507
ContextSource\getAuthority
getAuthority()
Definition: ContextSource.php:144
$line
$line
Definition: mcc.php:119
Sanitizer\isReservedDataAttribute
static isReservedDataAttribute( $attr)
Given an attribute name, checks whether it is a reserved data attribute (such as data-mw-foo) which i...
Definition: Sanitizer.php:520
EnhancedChangesList\$templateParser
TemplateParser $templateParser
Definition: EnhancedChangesList.php:41
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:728
EnhancedChangesList\recentChangesBlock
recentChangesBlock()
If enhanced RC is in use, this function takes the previously cached RC lines, arranges them,...
Definition: EnhancedChangesList.php:818
$lines
if(!file_exists( $CREDITS)) $lines
Definition: updateCredits.php:45
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:58
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:207
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:1167
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:188
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:119
RCCacheEntry
Definition: RCCacheEntry.php:21
EnhancedChangesList\recentChangesBlockLine
recentChangesBlockLine( $rcObj)
Enhanced RC ungrouped line.
Definition: EnhancedChangesList.php:625
ChangesList\isCategorizationWithoutRevision
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
Definition: ChangesList.php:913
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:254
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:212
ChangesList
Definition: ChangesList.php:35
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:234
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:44
ChangesList\userCan
static userCan( $rc, $field, Authority $performer=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: ChangesList.php:762
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:561
TemplateParser
Definition: TemplateParser.php:27
ChangesList\getHTMLClassesForFilters
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
Definition: ChangesList.php:238
EnhancedChangesList\addCacheEntry
addCacheEntry(RCCacheEntry $cacheEntry)
Put accumulated information into the cache, for later display.
Definition: EnhancedChangesList.php:129
EnhancedChangesList\$rc_cache
RCCacheEntry[][] $rc_cache
Definition: EnhancedChangesList.php:36
$type
$type
Definition: testCompression.php:52