MediaWiki  1.30.0
EnhancedChangesList.php
Go to the documentation of this file.
1 <?php
24 
28  protected $cacheEntryFactory;
29 
33  protected $rc_cache;
34 
38  protected $templateParser;
39 
45  public function __construct( $obj, array $filterGroups = [] ) {
46  if ( $obj instanceof Skin ) {
47  // @todo: deprecate constructing with Skin
48  $context = $obj->getContext();
49  } else {
50  if ( !$obj instanceof IContextSource ) {
51  throw new MWException( 'EnhancedChangesList must be constructed with a '
52  . 'context source or skin.' );
53  }
54 
55  $context = $obj;
56  }
57 
58  parent::__construct( $context, $filterGroups );
59 
60  // message is set by the parent ChangesList class
61  $this->cacheEntryFactory = new RCCacheEntryFactory(
62  $context,
63  $this->message,
64  $this->linkRenderer
65  );
66  $this->templateParser = new TemplateParser();
67  }
68 
73  public function beginRecentChangesList() {
74  $this->rc_cache = [];
75  $this->rcMoveIndex = 0;
76  $this->rcCacheIndex = 0;
77  $this->lastdate = '';
78  $this->rclistOpen = false;
79  $this->getOutput()->addModuleStyles( [
80  'mediawiki.special.changeslist',
81  'mediawiki.special.changeslist.enhanced',
82  ] );
83  $this->getOutput()->addModules( [
84  'jquery.makeCollapsible',
85  'mediawiki.icon',
86  ] );
87 
88  return '<div class="mw-changeslist">';
89  }
90 
100  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
101  $date = $this->getLanguage()->userDate(
102  $rc->mAttribs['rc_timestamp'],
103  $this->getUser()
104  );
105  if ( $this->lastdate === '' ) {
106  $this->lastdate = $date;
107  }
108 
109  $ret = '';
110 
111  # If it's a new day, flush the cache and update $this->lastdate
112  if ( $date !== $this->lastdate ) {
113  # Process current cache (uses $this->lastdate to generate a heading)
114  $ret = $this->recentChangesBlock();
115  $this->rc_cache = [];
116  $this->lastdate = $date;
117  }
118 
119  $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
120  $this->addCacheEntry( $cacheEntry );
121 
122  return $ret;
123  }
124 
131  protected function addCacheEntry( RCCacheEntry $cacheEntry ) {
132  $cacheGroupingKey = $this->makeCacheGroupingKey( $cacheEntry );
133 
134  if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
135  $this->rc_cache[$cacheGroupingKey] = [];
136  }
137 
138  array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
139  }
140 
148  protected function makeCacheGroupingKey( RCCacheEntry $cacheEntry ) {
149  $title = $cacheEntry->getTitle();
150  $cacheGroupingKey = $title->getPrefixedDBkey();
151 
152  $type = $cacheEntry->mAttribs['rc_type'];
153 
154  if ( $type == RC_LOG ) {
155  // Group by log type
156  $cacheGroupingKey = SpecialPage::getTitleFor(
157  'Log',
158  $cacheEntry->mAttribs['rc_log_type']
159  )->getPrefixedDBkey();
160  }
161 
162  return $cacheGroupingKey;
163  }
164 
171  protected function recentChangesBlockGroup( $block ) {
172  $recentChangesFlags = $this->getConfig()->get( 'RecentChangesFlags' );
173 
174  # Add the namespace and title of the block as part of the class
175  $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc', 'mw-changeslist-line' ];
176  if ( $block[0]->mAttribs['rc_log_type'] ) {
177  # Log entry
178  $tableClasses[] = 'mw-changeslist-log';
179  $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
180  . $block[0]->mAttribs['rc_log_type'] );
181  } else {
182  $tableClasses[] = 'mw-changeslist-edit';
183  $tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
184  . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
185  }
186  if ( $block[0]->watched
187  && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
188  ) {
189  $tableClasses[] = 'mw-changeslist-line-watched';
190  } else {
191  $tableClasses[] = 'mw-changeslist-line-not-watched';
192  }
193 
194  # Collate list of users
195  $userlinks = [];
196  # Other properties
197  $curId = 0;
198  # Some catalyst variables...
199  $namehidden = true;
200  $allLogs = true;
201  $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
202 
203  # Default values for RC flags
204  $collectedRcFlags = [];
205  foreach ( $recentChangesFlags as $key => $value ) {
206  $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
207  $recentChangesFlags[$key]['grouping'] : 'any' );
208  switch ( $flagGrouping ) {
209  case 'all':
210  $collectedRcFlags[$key] = true;
211  break;
212  case 'any':
213  $collectedRcFlags[$key] = false;
214  break;
215  default:
216  throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
217  }
218  }
219  foreach ( $block as $rcObj ) {
220  // If all log actions to this page were hidden, then don't
221  // give the name of the affected page for this block!
222  if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
223  $namehidden = false;
224  }
225  $u = $rcObj->userlink;
226  if ( !isset( $userlinks[$u] ) ) {
227  $userlinks[$u] = 0;
228  }
229  if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
230  $allLogs = false;
231  }
232  # Get the latest entry with a page_id and oldid
233  # since logs may not have these.
234  if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
235  $curId = $rcObj->mAttribs['rc_cur_id'];
236  }
237 
238  $userlinks[$u]++;
239  }
240 
241  # Sort the list and convert to text
242  krsort( $userlinks );
243  asort( $userlinks );
244  $users = [];
245  foreach ( $userlinks as $userlink => $count ) {
246  $text = $userlink;
247  $text .= $this->getLanguage()->getDirMark();
248  if ( $count > 1 ) {
249  $formattedCount = $this->msg( 'ntimes' )->numParams( $count )->escaped();
250  $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
251  }
252  array_push( $users, $text );
253  }
254 
255  # Article link
256  $articleLink = '';
257  $revDeletedMsg = false;
258  if ( $namehidden ) {
259  $revDeletedMsg = $this->msg( 'rev-deleted-event' )->escaped();
260  } elseif ( $allLogs ) {
261  $articleLink = $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
262  } else {
263  $articleLink = $this->getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
264  }
265 
266  $queryParams['curid'] = $curId;
267 
268  # Sub-entries
269  $lines = [];
270  foreach ( $block as $i => $rcObj ) {
271  $line = $this->getLineData( $block, $rcObj, $queryParams );
272  if ( !$line ) {
273  // completely ignore this RC entry if we don't want to render it
274  unset( $block[$i] );
275  continue;
276  }
277 
278  // Roll up flags
279  foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
280  $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
281  $recentChangesFlags[$key]['grouping'] : 'any' );
282  switch ( $flagGrouping ) {
283  case 'all':
284  if ( !$value ) {
285  $collectedRcFlags[$key] = false;
286  }
287  break;
288  case 'any':
289  if ( $value ) {
290  $collectedRcFlags[$key] = true;
291  }
292  break;
293  default:
294  throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
295  }
296  }
297 
298  $lines[] = $line;
299  }
300 
301  // Further down are some assumptions that $block is a 0-indexed array
302  // with (count-1) as last key. Let's make sure it is.
303  $block = array_values( $block );
304 
305  if ( empty( $block ) || !$lines ) {
306  // if we can't show anything, don't display this block altogether
307  return '';
308  }
309 
310  $logText = $this->getLogText( $block, $queryParams, $allLogs,
311  $collectedRcFlags['newpage'], $namehidden
312  );
313 
314  # Character difference (does not apply if only log items)
315  $charDifference = false;
316  if ( $RCShowChangedSize && !$allLogs ) {
317  $last = 0;
318  $first = count( $block ) - 1;
319  # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
320  while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
321  $last++;
322  }
323  while ( $last < $first && $block[$first]->mAttribs['rc_old_len'] === null ) {
324  $first--;
325  }
326  # Get net change
327  $charDifference = $this->formatCharacterDifference( $block[$first], $block[$last] );
328  }
329 
330  $numberofWatchingusers = $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
331  $usersList = $this->msg( 'brackets' )->rawParams(
332  implode( $this->message['semicolon-separator'], $users )
333  )->escaped();
334 
335  $prefix = '';
336  if ( is_callable( $this->changeLinePrefixer ) ) {
337  $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this, true );
338  }
339 
340  $templateParams = [
341  'articleLink' => $articleLink,
342  'charDifference' => $charDifference,
343  'collectedRcFlags' => $this->recentChangesFlags( $collectedRcFlags ),
344  'languageDirMark' => $this->getLanguage()->getDirMark(),
345  'lines' => $lines,
346  'logText' => $logText,
347  'numberofWatchingusers' => $numberofWatchingusers,
348  'prefix' => $prefix,
349  'rev-deleted-event' => $revDeletedMsg,
350  'tableClasses' => $tableClasses,
351  'timestamp' => $block[0]->timestamp,
352  'fullTimestamp' => $block[0]->getAttribute( 'rc_timestamp' ),
353  'users' => $usersList,
354  ];
355 
356  $this->rcCacheIndex++;
357 
358  return $this->templateParser->processTemplate(
359  'EnhancedChangesListGroup',
360  $templateParams
361  );
362  }
363 
373  protected function getLineData( array $block, RCCacheEntry $rcObj, array $queryParams = [] ) {
374  $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
375 
376  $type = $rcObj->mAttribs['rc_type'];
377  $data = [];
378  $lineParams = [ 'targetTitle' => $rcObj->getTitle() ];
379 
380  $classes = [ 'mw-enhanced-rc' ];
381  if ( $rcObj->watched
382  && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
383  ) {
384  $classes[] = 'mw-enhanced-watched';
385  }
386  $classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched ) );
387 
388  $separator = ' <span class="mw-changeslist-separator">. .</span> ';
389 
390  $data['recentChangesFlags'] = [
391  'newpage' => $type == RC_NEW,
392  'minor' => $rcObj->mAttribs['rc_minor'],
393  'unpatrolled' => $rcObj->unpatrolled,
394  'bot' => $rcObj->mAttribs['rc_bot'],
395  ];
396 
397  $params = $queryParams;
398 
399  if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
400  $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
401  }
402 
403  # Log timestamp
404  if ( $type == RC_LOG ) {
405  $link = $rcObj->timestamp;
406  # Revision link
407  } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
408  $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
409  } else {
410  $link = $this->linkRenderer->makeKnownLink(
411  $rcObj->getTitle(),
412  new HtmlArmor( $rcObj->timestamp ),
413  [],
414  $params
415  );
416  if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
417  $link = '<span class="history-deleted">' . $link . '</span> ';
418  }
419  }
420  $data['timestampLink'] = $link;
421 
422  $currentAndLastLinks = '';
423  if ( !$type == RC_LOG || $type == RC_NEW ) {
424  $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams(
425  $rcObj->curlink .
426  $this->message['pipe-separator'] .
427  $rcObj->lastlink
428  )->escaped();
429  }
430  $data['currentAndLastLinks'] = $currentAndLastLinks;
431  $data['separatorAfterCurrentAndLastLinks'] = $separator;
432 
433  # Character diff
434  if ( $RCShowChangedSize ) {
435  $cd = $this->formatCharacterDifference( $rcObj );
436  if ( $cd !== '' ) {
437  $data['characterDiff'] = $cd;
438  $data['separatorAfterCharacterDiff'] = $separator;
439  }
440  }
441 
442  if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
443  $data['logEntry'] = $this->insertLogEntry( $rcObj );
444  } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
445  $data['comment'] = $this->insertComment( $rcObj );
446  } else {
447  # User links
448  $data['userLink'] = $rcObj->userlink;
449  $data['userTalkLink'] = $rcObj->usertalklink;
450  $data['comment'] = $this->insertComment( $rcObj );
451  }
452 
453  # Rollback
454  $data['rollback'] = $this->getRollback( $rcObj );
455 
456  # Tags
457  $data['tags'] = $this->getTags( $rcObj, $classes );
458 
459  $attribs = $this->getDataAttributes( $rcObj );
460 
461  // give the hook a chance to modify the data
462  $success = Hooks::run( 'EnhancedChangesListModifyLineData',
463  [ $this, &$data, $block, $rcObj, &$classes, &$attribs ] );
464  if ( !$success ) {
465  // skip entry if hook aborted it
466  return [];
467  }
468  $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
469 
470  $lineParams['recentChangesFlagsRaw'] = [];
471  if ( isset( $data['recentChangesFlags'] ) ) {
472  $lineParams['recentChangesFlags'] = $this->recentChangesFlags( $data['recentChangesFlags'] );
473  # FIXME: This is used by logic, don't return it in the template params.
474  $lineParams['recentChangesFlagsRaw'] = $data['recentChangesFlags'];
475  unset( $data['recentChangesFlags'] );
476  }
477 
478  if ( isset( $data['timestampLink'] ) ) {
479  $lineParams['timestampLink'] = $data['timestampLink'];
480  unset( $data['timestampLink'] );
481  }
482 
483  $lineParams['classes'] = array_values( $classes );
484  $lineParams['attribs'] = Html::expandAttributes( $attribs );
485 
486  // everything else: makes it easier for extensions to add or remove data
487  $lineParams['data'] = array_values( $data );
488 
489  return $lineParams;
490  }
491 
502  protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
503  if ( empty( $block ) ) {
504  return '';
505  }
506 
507  # Changes message
508  static $nchanges = [];
509  static $sinceLastVisitMsg = [];
510 
511  $n = count( $block );
512  if ( !isset( $nchanges[$n] ) ) {
513  $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
514  }
515 
516  $sinceLast = 0;
517  $unvisitedOldid = null;
519  foreach ( $block as $rcObj ) {
520  // Same logic as below inside main foreach
521  if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
522  $sinceLast++;
523  $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
524  }
525  }
526  if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
527  $sinceLastVisitMsg[$sinceLast] =
528  $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
529  }
530 
531  $currentRevision = 0;
532  foreach ( $block as $rcObj ) {
533  if ( !$currentRevision ) {
534  $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
535  }
536  }
537 
538  # Total change link
539  $links = [];
541  $block0 = $block[0];
542  $last = $block[count( $block ) - 1];
543  if ( !$allLogs ) {
544  if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ||
545  $isnew ||
546  $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE
547  ) {
548  $links['total-changes'] = $nchanges[$n];
549  } else {
550  $links['total-changes'] = $this->linkRenderer->makeKnownLink(
551  $block0->getTitle(),
552  new HtmlArmor( $nchanges[$n] ),
553  [ 'class' => 'mw-changeslist-groupdiff' ],
554  $queryParams + [
555  'diff' => $currentRevision,
556  'oldid' => $last->mAttribs['rc_last_oldid'],
557  ]
558  );
559  if ( $sinceLast > 0 && $sinceLast < $n ) {
560  $links['total-changes-since-last'] = $this->linkRenderer->makeKnownLink(
561  $block0->getTitle(),
562  new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
563  [ 'class' => 'mw-changeslist-groupdiff' ],
564  $queryParams + [
565  'diff' => $currentRevision,
566  'oldid' => $unvisitedOldid,
567  ]
568  );
569  }
570  }
571  }
572 
573  # History
574  if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
575  // don't show history link for logs
576  } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
577  $links['history'] = $this->message['enhancedrc-history'];
578  } else {
579  $params = $queryParams;
580  $params['action'] = 'history';
581 
582  $links['history'] = $this->linkRenderer->makeKnownLink(
583  $block0->getTitle(),
584  new HtmlArmor( $this->message['enhancedrc-history'] ),
585  [ 'class' => 'mw-changeslist-history' ],
586  $params
587  );
588  }
589 
590  # Allow others to alter, remove or add to these links
591  Hooks::run( 'EnhancedChangesList::getLogText',
592  [ $this, &$links, $block ] );
593 
594  if ( !$links ) {
595  return '';
596  }
597 
598  $logtext = implode( $this->message['pipe-separator'], $links );
599  $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
600  return ' ' . $logtext;
601  }
602 
609  protected function recentChangesBlockLine( $rcObj ) {
610  $data = [];
611 
612  $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
613 
614  $type = $rcObj->mAttribs['rc_type'];
615  $logType = $rcObj->mAttribs['rc_log_type'];
616  $classes = $this->getHTMLClasses( $rcObj, $rcObj->watched );
617  $classes[] = 'mw-enhanced-rc';
618 
619  if ( $logType ) {
620  # Log entry
621  $classes[] = 'mw-changeslist-log';
622  $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
623  } else {
624  $classes[] = 'mw-changeslist-edit';
625  $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
626  $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
627  }
628 
629  # Flag and Timestamp
630  $data['recentChangesFlags'] = [
631  'newpage' => $type == RC_NEW,
632  'minor' => $rcObj->mAttribs['rc_minor'],
633  'unpatrolled' => $rcObj->unpatrolled,
634  'bot' => $rcObj->mAttribs['rc_bot'],
635  ];
636  // timestamp is not really a link here, but is called timestampLink
637  // for consistency with EnhancedChangesListModifyLineData
638  $data['timestampLink'] = $rcObj->timestamp;
639 
640  # Article or log link
641  if ( $logType ) {
642  $logPage = new LogPage( $logType );
643  $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
644  $logName = $logPage->getName()->text();
645  $data['logLink'] = $this->msg( 'parentheses' )
646  ->rawParams(
647  $this->linkRenderer->makeKnownLink( $logTitle, $logName )
648  )->escaped();
649  } else {
650  $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
651  }
652 
653  # Diff and hist links
654  if ( $type != RC_LOG && $type != RC_CATEGORIZE ) {
655  $query['action'] = 'history';
656  $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
657  }
658  $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
659 
660  # Character diff
661  if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
662  $cd = $this->formatCharacterDifference( $rcObj );
663  if ( $cd !== '' ) {
664  $data['characterDiff'] = $cd;
665  $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> ';
666  }
667  }
668 
669  if ( $type == RC_LOG ) {
670  $data['logEntry'] = $this->insertLogEntry( $rcObj );
671  } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
672  $data['comment'] = $this->insertComment( $rcObj );
673  } else {
674  $data['userLink'] = $rcObj->userlink;
675  $data['userTalkLink'] = $rcObj->usertalklink;
676  $data['comment'] = $this->insertComment( $rcObj );
677  if ( $type == RC_CATEGORIZE ) {
678  $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
679  }
680  $data['rollback'] = $this->getRollback( $rcObj );
681  }
682 
683  # Tags
684  $data['tags'] = $this->getTags( $rcObj, $classes );
685 
686  # Show how many people are watching this if enabled
687  $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
688 
689  $data['attribs'] = array_merge( $this->getDataAttributes( $rcObj ), [ 'class' => $classes ] );
690 
691  // give the hook a chance to modify the data
692  $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData',
693  [ $this, &$data, $rcObj ] );
694  if ( !$success ) {
695  // skip entry if hook aborted it
696  return '';
697  }
698  $attribs = $data['attribs'];
699  unset( $data['attribs'] );
700  $attribs = wfArrayFilterByKey( $attribs, function ( $key ) {
701  return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
702  } );
703 
704  $prefix = '';
705  if ( is_callable( $this->changeLinePrefixer ) ) {
706  $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this, false );
707  }
708 
709  $line = Html::openElement( 'table', $attribs ) . Html::openElement( 'tr' );
710  $line .= Html::rawElement( 'td', [], '<span class="mw-enhancedchanges-arrow-space"></span>' );
711  $line .= Html::rawElement( 'td', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix );
712  $line .= '<td class="mw-enhanced-rc">';
713 
714  if ( isset( $data['recentChangesFlags'] ) ) {
715  $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
716  unset( $data['recentChangesFlags'] );
717  }
718 
719  if ( isset( $data['timestampLink'] ) ) {
720  $line .= '&#160;' . $data['timestampLink'];
721  unset( $data['timestampLink'] );
722  }
723  $line .= '&#160;</td>';
724  $line .= Html::openElement( 'td', [
725  'class' => 'mw-changeslist-line-inner',
726  // Used for reliable determination of the affiliated page
727  'data-target-page' => $rcObj->getTitle(),
728  ] );
729 
730  // everything else: makes it easier for extensions to add or remove data
731  $line .= implode( '', $data );
732 
733  $line .= "</td></tr></table>\n";
734 
735  return $line;
736  }
737 
748  public function getDiffHistLinks( RCCacheEntry $rc, array $query ) {
749  $pageTitle = $rc->getTitle();
750  if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
751  // For categorizations we must swap the category title with the page title!
752  $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
753  if ( !$pageTitle ) {
754  // The page has been deleted, but the RC entry
755  // deletion job has not run yet. Just skip.
756  return '';
757  }
758  }
759 
760  $retVal = ' ' . $this->msg( 'parentheses' )
761  ->rawParams( $rc->difflink . $this->message['pipe-separator']
762  . $this->linkRenderer->makeKnownLink(
763  $pageTitle,
764  new HtmlArmor( $this->message['hist'] ),
765  [ 'class' => 'mw-changeslist-history' ],
766  $query
767  ) )->escaped();
768  return $retVal;
769  }
770 
777  protected function recentChangesBlock() {
778  if ( count( $this->rc_cache ) == 0 ) {
779  return '';
780  }
781 
782  $blockOut = '';
783  foreach ( $this->rc_cache as $block ) {
784  if ( count( $block ) < 2 ) {
785  $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
786  } else {
787  $blockOut .= $this->recentChangesBlockGroup( $block );
788  }
789  }
790 
791  if ( $blockOut === '' ) {
792  return '';
793  }
794  // $this->lastdate is kept up to date by recentChangesLine()
795  return Xml::element( 'h4', null, $this->lastdate ) . "\n<div>" . $blockOut . '</div>';
796  }
797 
803  public function endRecentChangesList() {
804  return $this->recentChangesBlock() . '</div>';
805  }
806 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
ContextSource\getConfig
getConfig()
Get the Config object.
Definition: ContextSource.php:68
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
EnhancedChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line for enhanced recentchange (aka with javascript and block of lines).
Definition: EnhancedChangesList.php:100
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:560
captcha-old.count
count
Definition: captcha-old.py:249
$last
$last
Definition: profileinfo.php:415
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:189
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:618
RC_LOG
const RC_LOG
Definition: Defines.php:145
EnhancedChangesList\getDiffHistLinks
getDiffHistLinks(RCCacheEntry $rc, array $query)
Returns value to be used in 'historyLink' element of $data param in EnhancedChangesListModifyBlockLin...
Definition: EnhancedChangesList.php:748
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:690
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:474
$params
$params
Definition: styleTest.css.php:40
EnhancedChangesList\makeCacheGroupingKey
makeCacheGroupingKey(RCCacheEntry $cacheEntry)
Definition: EnhancedChangesList.php:148
link
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
Definition: hooks.txt:2981
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:82
RCCacheEntryFactory
Definition: RCCacheEntryFactory.php:24
wfArrayFilterByKey
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
Definition: GlobalFunctions.php:233
$success
$success
Definition: NoLocalSettings.php:44
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:342
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ChangesList\isDeleted
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
Definition: ChangesList.php:593
EnhancedChangesList\$cacheEntryFactory
RCCacheEntryFactory $cacheEntryFactory
Definition: EnhancedChangesList.php:28
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
EnhancedChangesList\getLineData
getLineData(array $block, RCCacheEntry $rcObj, array $queryParams=[])
Definition: EnhancedChangesList.php:373
ChangesList\$filterGroups
array $filterGroups
Definition: ChangesList.php:58
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1581
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:803
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:546
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1965
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:31
EnhancedChangesList\beginRecentChangesList
beginRecentChangesList()
Add the JavaScript file for enhanced changeslist.
Definition: EnhancedChangesList.php:73
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
message
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:2133
$lines
$lines
Definition: router.php:67
EnhancedChangesList\recentChangesBlockGroup
recentChangesBlockGroup( $block)
Enhanced RC group.
Definition: EnhancedChangesList.php:171
EnhancedChangesList\__construct
__construct( $obj, array $filterGroups=[])
Definition: EnhancedChangesList.php:45
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:659
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:32
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Definition: ChangesList.php:467
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:754
$line
$line
Definition: cdb.php:58
EnhancedChangesList
Definition: EnhancedChangesList.php:23
EnhancedChangesList\getLogText
getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden)
Generates amount of changes (linking to diff ) & link to history.
Definition: EnhancedChangesList.php:502
$value
$value
Definition: styleTest.css.php:45
EnhancedChangesList\$rc_cache
array $rc_cache
Array of array of RCCacheEntry.
Definition: EnhancedChangesList.php:33
EnhancedChangesList\$templateParser
TemplateParser $templateParser
Definition: EnhancedChangesList.php:38
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:574
EnhancedChangesList\recentChangesBlock
recentChangesBlock()
If enhanced RC is in use, this function takes the previously cached RC lines, arranges them,...
Definition: EnhancedChangesList.php:777
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1965
RC_NEW
const RC_NEW
Definition: Defines.php:144
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:174
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:967
RCCacheEntry
Definition: RCCacheEntry.php:21
EnhancedChangesList\recentChangesBlockLine
recentChangesBlockLine( $rcObj)
Enhanced RC ungrouped line.
Definition: EnhancedChangesList.php:609
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:744
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing='&#160;')
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:155
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:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
ChangesList
Definition: ChangesList.php:28
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:147
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:36
RecentChange\getTitle
& getTitle()
Definition: RecentChange.php:257
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:411
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
ChangesList\userCan
static userCan( $rc, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: ChangesList.php:605
array
the array() calling protocol came about after MediaWiki 1.4rc1.
EnhancedChangesList\addCacheEntry
addCacheEntry(RCCacheEntry $cacheEntry)
Put accumulated information into the cache, for later display.
Definition: EnhancedChangesList.php:131
$type
$type
Definition: testCompression.php:48