MediaWiki REL1_37
ChangesList.php
Go to the documentation of this file.
1<?php
25use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
32use OOUI\IconWidget;
34
36 use ProtectedHookAccessorTrait;
37
38 public const CSS_CLASS_PREFIX = 'mw-changeslist-';
39
40 protected $watchlist = false;
41 protected $lastdate;
42 protected $message;
43 protected $rc_cache;
44 protected $rcCacheIndex;
45 protected $rclistOpen;
46 protected $rcMoveIndex;
47
50
52 protected $watchMsgCache;
53
57 protected $linkRenderer;
58
62 protected $filterGroups;
63
68 public function __construct( $context, array $filterGroups = [] ) {
69 $this->setContext( $context );
70 $this->preCacheMessages();
71 $this->watchMsgCache = new MapCacheLRU( 50 );
72 $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
73 $this->filterGroups = $filterGroups;
74 }
75
84 public static function newFromContext( IContextSource $context, array $groups = [] ) {
85 $user = $context->getUser();
86 $sk = $context->getSkin();
87 $list = null;
88 if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
89 $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
90
91 return $new ?
92 new EnhancedChangesList( $context, $groups ) :
93 new OldChangesList( $context, $groups );
94 } else {
95 return $list;
96 }
97 }
98
110 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
111 throw new RuntimeException( 'recentChangesLine should be implemented' );
112 }
113
120 protected function getHighlightsContainerDiv() {
121 $highlightColorDivs = '';
122 foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
123 $highlightColorDivs .= Html::rawElement(
124 'div',
125 [
126 'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
127 'data-color' => $color
128 ]
129 );
130 }
131
132 return Html::rawElement(
133 'div',
134 [ 'class' => 'mw-rcfilters-ui-highlights' ],
135 $highlightColorDivs
136 );
137 }
138
143 public function setWatchlistDivs( $value = true ) {
144 $this->watchlist = $value;
145 }
146
151 public function isWatchlist() {
152 return (bool)$this->watchlist;
153 }
154
159 private function preCacheMessages() {
160 if ( !isset( $this->message ) ) {
161 $this->message = [];
162 foreach ( [
163 'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
164 'semicolon-separator', 'pipe-separator' ] as $msg
165 ) {
166 $this->message[$msg] = $this->msg( $msg )->escaped();
167 }
168 }
169 }
170
177 public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
178 $f = '';
179 foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
180 $f .= isset( $flags[$flag] ) && $flags[$flag]
181 ? self::flag( $flag, $this->getContext() )
182 : $nothing;
183 }
184
185 return $f;
186 }
187
196 protected function getHTMLClasses( $rc, $watched ) {
197 $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
198 $logType = $rc->mAttribs['rc_log_type'];
199
200 if ( $logType ) {
201 $classes[] = self::CSS_CLASS_PREFIX . 'log';
202 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
203 } else {
204 $classes[] = self::CSS_CLASS_PREFIX . 'edit';
205 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
206 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
207 }
208
209 // Indicate watched status on the line to allow for more
210 // comprehensive styling.
211 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
212 ? self::CSS_CLASS_PREFIX . 'line-watched'
213 : self::CSS_CLASS_PREFIX . 'line-not-watched';
214
215 $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
216
217 return $classes;
218 }
219
227 protected function getHTMLClassesForFilters( $rc ) {
228 $classes = [];
229
230 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
231 $rc->mAttribs['rc_namespace'] );
232
233 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
234 $classes[] = Sanitizer::escapeClass(
235 self::CSS_CLASS_PREFIX .
236 'ns-' .
237 ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
238 );
239
240 foreach ( $this->filterGroups as $filterGroup ) {
241 foreach ( $filterGroup->getFilters() as $filter ) {
242 $filter->applyCssClassIfNeeded( $this, $rc, $classes );
243 }
244 }
245
246 return $classes;
247 }
248
259 public static function flag( $flag, IContextSource $context = null ) {
260 static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
261 static $flagInfos = null;
262
263 if ( $flagInfos === null ) {
265 $flagInfos = [];
266 foreach ( $wgRecentChangesFlags as $key => $value ) {
267 $flagInfos[$key]['letter'] = $value['letter'];
268 $flagInfos[$key]['title'] = $value['title'];
269 // Allow customized class name, fall back to flag name
270 $flagInfos[$key]['class'] = $value['class'] ?? $key;
271 }
272 }
273
274 $context = $context ?: RequestContext::getMain();
275
276 // Inconsistent naming, kepted for b/c
277 if ( isset( $map[$flag] ) ) {
278 $flag = $map[$flag];
279 }
280
281 $info = $flagInfos[$flag];
282 return Html::element( 'abbr', [
283 'class' => $info['class'],
284 'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
285 ], wfMessage( $info['letter'] )->setContext( $context )->text() );
286 }
287
292 public function beginRecentChangesList() {
293 $this->rc_cache = [];
294 $this->rcMoveIndex = 0;
295 $this->rcCacheIndex = 0;
296 $this->lastdate = '';
297 $this->rclistOpen = false;
298 $this->getOutput()->addModuleStyles( [
299 'mediawiki.interface.helpers.styles',
300 'mediawiki.special.changeslist'
301 ] );
302
303 return '<div class="mw-changeslist">';
304 }
305
309 public function initChangesListRows( $rows ) {
310 $this->getHookRunner()->onChangesListInitRows( $this, $rows );
311 }
312
323 public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
324 if ( !$context ) {
325 $context = RequestContext::getMain();
326 }
327
328 $new = (int)$new;
329 $old = (int)$old;
330 $szdiff = $new - $old;
331
333 $config = $context->getConfig();
334 $code = $lang->getCode();
335 static $fastCharDiff = [];
336 if ( !isset( $fastCharDiff[$code] ) ) {
337 $fastCharDiff[$code] = $config->get( 'MiserMode' )
338 || $context->msg( 'rc-change-size' )->plain() === '$1';
339 }
340
341 $formattedSize = $lang->formatNum( $szdiff );
342
343 if ( !$fastCharDiff[$code] ) {
344 $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
345 }
346
347 if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
348 $tag = 'strong';
349 } else {
350 $tag = 'span';
351 }
352
353 if ( $szdiff === 0 ) {
354 $formattedSizeClass = 'mw-plusminus-null';
355 } elseif ( $szdiff > 0 ) {
356 $formattedSize = '+' . $formattedSize;
357 $formattedSizeClass = 'mw-plusminus-pos';
358 } else {
359 $formattedSizeClass = 'mw-plusminus-neg';
360 }
361 $formattedSizeClass .= ' mw-diff-bytes';
362
363 $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
364
365 return Html::element( $tag,
366 [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
367 $formattedSize ) . $lang->getDirMark();
368 }
369
377 public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
378 $oldlen = $old->mAttribs['rc_old_len'];
379
380 if ( $new ) {
381 $newlen = $new->mAttribs['rc_new_len'];
382 } else {
383 $newlen = $old->mAttribs['rc_new_len'];
384 }
385
386 if ( $oldlen === null || $newlen === null ) {
387 return '';
388 }
389
390 return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
391 }
392
397 public function endRecentChangesList() {
398 $out = $this->rclistOpen ? "</ul>\n" : '';
399 $out .= '</div>';
400
401 return $out;
402 }
403
415 public static function revDateLink(
416 RevisionRecord $rev,
417 Authority $performer,
419 $title = null
420 ) {
421 $ts = $rev->getTimestamp();
422 $date = $lang->userTimeAndDate( $ts, $performer->getUser() );
423 if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
424 $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
425 $title ?? $rev->getPageAsLinkTarget(),
426 $date,
427 [ 'class' => 'mw-changeslist-date' ],
428 [ 'oldid' => $rev->getId() ]
429 );
430 } else {
431 $link = htmlspecialchars( $date );
432 }
433 if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
434 $deletedClass = Linker::getRevisionDeletedClass( $rev );
435 $link = "<span class=\"$deletedClass mw-changeslist-date\">$link</span>";
436 }
437 return $link;
438 }
439
444 public function insertDateHeader( &$s, $rc_timestamp ) {
445 # Make date header if necessary
446 $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
447 if ( $date != $this->lastdate ) {
448 if ( $this->lastdate != '' ) {
449 $s .= "</ul>\n";
450 }
451 $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
452 $this->lastdate = $date;
453 $this->rclistOpen = true;
454 }
455 }
456
463 public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
464 $page = new LogPage( $logtype );
465 $logname = $page->getName()->setContext( $this->getContext() )->text();
466 $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
467 'class' => $useParentheses ? '' : 'mw-changeslist-links'
468 ] );
469 if ( $useParentheses ) {
470 $s .= $this->msg( 'parentheses' )->rawParams(
471 $link
472 )->escaped();
473 } else {
474 $s .= $link;
475 }
476 }
477
483 public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
484 # Diff link
485 if (
486 $rc->mAttribs['rc_type'] == RC_NEW ||
487 $rc->mAttribs['rc_type'] == RC_LOG ||
488 $rc->mAttribs['rc_type'] == RC_CATEGORIZE
489 ) {
490 $diffLink = $this->message['diff'];
491 } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
492 $diffLink = $this->message['diff'];
493 } else {
494 $query = [
495 'curid' => $rc->mAttribs['rc_cur_id'],
496 'diff' => $rc->mAttribs['rc_this_oldid'],
497 'oldid' => $rc->mAttribs['rc_last_oldid']
498 ];
499
500 $diffLink = $this->linkRenderer->makeKnownLink(
501 $rc->getTitle(),
502 new HtmlArmor( $this->message['diff'] ),
503 [ 'class' => 'mw-changeslist-diff' ],
504 $query
505 );
506 }
507 if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
508 $histLink = $this->message['hist'];
509 } else {
510 $histLink = $this->linkRenderer->makeKnownLink(
511 $rc->getTitle(),
512 new HtmlArmor( $this->message['hist'] ),
513 [ 'class' => 'mw-changeslist-history' ],
514 [
515 'curid' => $rc->mAttribs['rc_cur_id'],
516 'action' => 'history'
517 ]
518 );
519 }
520
521 $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ],
522 Html::rawElement( 'span', [], $diffLink ) .
523 Html::rawElement( 'span', [], $histLink )
524 ) .
525 ' <span class="mw-changeslist-separator"></span> ';
526 }
527
538 public function getArticleLink( &$rc, $unpatrolled, $watched ) {
539 $params = [];
540 if ( $rc->getTitle()->isRedirect() ) {
541 $params = [ 'redirect' => 'no' ];
542 }
543
544 $articlelink = $this->linkRenderer->makeLink(
545 $rc->getTitle(),
546 null,
547 [ 'class' => 'mw-changeslist-title' ],
548 $params
549 );
550 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
551 $class = 'history-deleted';
552 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
553 $class .= ' mw-history-suppressed';
554 }
555 $articlelink = '<span class="' . $class . '">' . $articlelink . '</span>';
556 }
557 # To allow for boldening pages watched by this user
558 $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
559 # RTL/LTR marker
560 $articlelink .= $this->getLanguage()->getDirMark();
561
562 # TODO: Deprecate the $s argument, it seems happily unused.
563 $s = '';
564 $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
565 $s, $rc, $unpatrolled, $watched );
566
567 // Watchlist expiry icon.
568 $watchlistExpiry = '';
569 if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
570 $watchlistExpiry = $this->getWatchlistExpiry( $rc );
571 }
572
573 return "{$s} {$articlelink}{$watchlistExpiry}";
574 }
575
582 public function getWatchlistExpiry( RecentChange $recentChange ): string {
583 $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
584 // Guard against expired items, even though they shouldn't come here.
585 if ( $item->isExpired() ) {
586 return '';
587 }
588 $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
589 // Matching widget is also created in ChangesListSpecialPage, for the legend.
590 $widget = new IconWidget( [
591 'icon' => 'clock',
592 'title' => $daysLeftText,
593 'classes' => [ 'mw-changesList-watchlistExpiry' ],
594 ] );
595 $widget->setAttributes( [
596 // Add labels for assistive technologies.
597 'role' => 'img',
598 'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
599 // Days-left is used in resources/src/mediawiki.special.changeslist.watchlistexpiry/watchlistexpiry.js
600 'data-days-left' => $item->getExpiryInDays(),
601 ] );
602 // Add spaces around the widget (the page title is to one side,
603 // and a semicolon or opening-parenthesis to the other).
604 return " $widget ";
605 }
606
615 public function getTimestamp( $rc ) {
616 // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
617 // because in that case the timestamp is preceeded by a clock icon.
618 // A space is important after mw-changeslist-separator--semicolon to make sure
619 // that whatever comes before it is distinguishable.
620 // (Otherwise your have the text of titles pushing up against the timestamp)
621 // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
622 // of other places with a different position and the information proceeding getTimestamp can vary.
623 $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
624 return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
625 '<span class="mw-changeslist-date">' .
626 htmlspecialchars( $this->getLanguage()->userTime(
627 $rc->mAttribs['rc_timestamp'],
628 $this->getUser()
629 ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
630 }
631
638 public function insertTimestamp( &$s, $rc ) {
639 $s .= $this->getTimestamp( $rc );
640 }
641
648 public function insertUserRelatedLinks( &$s, &$rc ) {
649 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
650 $deletedClass = 'history-deleted';
651 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
652 $deletedClass = ' mw-history-suppressed';
653 }
654 $s .= ' <span class="' . $deletedClass . '">' .
655 $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
656 } else {
657 $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
658 $rc->mAttribs['rc_user_text'] );
660 $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
661 false, 0, null,
662 // The text content of tools is not wrapped with parenthesises or "piped".
663 // This will be handled in CSS (T205581).
664 false
665 );
666 }
667 }
668
675 public function insertLogEntry( $rc ) {
676 $formatter = LogFormatter::newFromRow( $rc->mAttribs );
677 $formatter->setContext( $this->getContext() );
678 $formatter->setShowUserToolLinks( true );
679 $mark = $this->getLanguage()->getDirMark();
680
681 return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
682 . $formatter->getActionText() . " $mark" . $formatter->getComment()
683 . Html::closeElement( 'span' );
684 }
685
691 public function insertComment( $rc ) {
692 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
693 $deletedClass = 'history-deleted';
694 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
695 $deletedClass .= ' mw-history-suppressed';
696 }
697 return ' <span class="' . $deletedClass . ' comment">' .
698 $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
699 } else {
700 return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
701 // Whether section links should refer to local page (using default false)
702 false,
703 // wikid to generate links for (using default null) */
704 null,
705 // whether parentheses should be rendered as part of the message
706 false );
707 }
708 }
709
715 protected function numberofWatchingusers( $count ) {
716 if ( $count <= 0 ) {
717 return '';
718 }
719
720 return $this->watchMsgCache->getWithSetCallback(
721 "watching-users-msg:$count",
722 function () use ( $count ) {
723 return $this->msg( 'number-of-watching-users-for-recent-changes' )
724 ->numParams( $count )->escaped();
725 }
726 );
727 }
728
735 public static function isDeleted( $rc, $field ) {
736 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
737 }
738
748 public static function userCan( $rc, $field, Authority $performer = null ) {
749 if ( $performer === null ) {
750 $performer = RequestContext::getMain()->getAuthority();
751 }
752
753 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
754 return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
755 }
756
757 return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
758 }
759
765 protected function maybeWatchedLink( $link, $watched = false ) {
766 if ( $watched ) {
767 return '<strong class="mw-watched">' . $link . '</strong>';
768 } else {
769 return '<span class="mw-rc-unwatched">' . $link . '</span>';
770 }
771 }
772
779 public function insertRollback( &$s, &$rc ) {
780 if ( $rc->mAttribs['rc_type'] == RC_EDIT
781 && $rc->mAttribs['rc_this_oldid']
782 && $rc->mAttribs['rc_cur_id']
783 && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
784 ) {
785 $title = $rc->getTitle();
789 if ( $this->getAuthority()->probablyCan( 'rollback', $title ) ) {
790 $revRecord = new MutableRevisionRecord( $title );
791 $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
792 $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
793 $user = new UserIdentityValue(
794 (int)$rc->mAttribs['rc_user'],
795 $rc->mAttribs['rc_user_text']
796 );
797 $revRecord->setUser( $user );
798
799 $s .= ' ';
801 $revRecord,
802 $this->getContext(),
803 [ 'noBrackets' ]
804 );
805 }
806 }
807 }
808
814 public function getRollback( RecentChange $rc ) {
815 $s = '';
816 $this->insertRollback( $s, $rc );
817 return $s;
818 }
819
825 public function insertTags( &$s, &$rc, &$classes ) {
826 if ( empty( $rc->mAttribs['ts_tags'] ) ) {
827 return;
828 }
829
830 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
831 $rc->mAttribs['ts_tags'],
832 'changeslist',
833 $this->getContext()
834 );
835 $classes = array_merge( $classes, $newClasses );
836 $s .= ' ' . $tagSummary;
837 }
838
845 public function getTags( RecentChange $rc, array &$classes ) {
846 $s = '';
847 $this->insertTags( $s, $rc, $classes );
848 return $s;
849 }
850
851 public function insertExtra( &$s, &$rc, &$classes ) {
852 // Empty, used for subclasses to add anything special.
853 }
854
855 protected function showAsUnpatrolled( RecentChange $rc ) {
856 return self::isUnpatrolled( $rc, $this->getUser() );
857 }
858
864 public static function isUnpatrolled( $rc, User $user ) {
865 if ( $rc instanceof RecentChange ) {
866 $isPatrolled = $rc->mAttribs['rc_patrolled'];
867 $rcType = $rc->mAttribs['rc_type'];
868 $rcLogType = $rc->mAttribs['rc_log_type'];
869 } else {
870 $isPatrolled = $rc->rc_patrolled;
871 $rcType = $rc->rc_type;
872 $rcLogType = $rc->rc_log_type;
873 }
874
875 if ( !$isPatrolled ) {
876 if ( $user->useRCPatrol() ) {
877 return true;
878 }
879 if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
880 return true;
881 }
882 if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
883 return true;
884 }
885 }
886
887 return false;
888 }
889
899 protected function isCategorizationWithoutRevision( $rcObj ) {
900 return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
901 && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
902 }
903
909 protected function getDataAttributes( RecentChange $rc ) {
910 $attrs = [];
911
912 $type = $rc->getAttribute( 'rc_source' );
913 switch ( $type ) {
914 case RecentChange::SRC_EDIT:
915 case RecentChange::SRC_NEW:
916 $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
917 break;
918 case RecentChange::SRC_LOG:
919 $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
920 $attrs['data-mw-logaction'] =
921 $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
922 break;
923 }
924
925 $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
926
927 return $attrs;
928 }
929
937 public function setChangeLinePrefixer( callable $prefixer ) {
938 $this->changeLinePrefixer = $prefixer;
939 }
940}
getAuthority()
getWatchlistExpiry(WatchedItemStoreInterface $store, Title $title, UserIdentity $user)
Get existing expiry from the database.
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
const RC_NEW
Definition Defines.php:116
const RC_LOG
Definition Defines.php:117
const RC_EDIT
Definition Defines.php:115
const RC_CATEGORIZE
Definition Defines.php:119
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
getContext()
static formatSummaryRow( $tags, $page, MessageLocalizer $localizer=null)
Creates HTML for the given tags.
Represents a filter group (used on ChangesListSpecialPage and descendants)
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
maybeWatchedLink( $link, $watched=false)
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
insertDateHeader(&$s, $rc_timestamp)
insertRollback(&$s, &$rc)
Insert a rollback link.
showAsUnpatrolled(RecentChange $rc)
static isUnpatrolled( $rc, User $user)
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
static revDateLink(RevisionRecord $rev, Authority $performer, Language $lang, $title=null)
Render the date and time of a revision in the current user language based on whether the user is able...
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
__construct( $context, array $filterGroups=[])
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
getWatchlistExpiry(RecentChange $recentChange)
Get HTML to display the clock icon for watched items that have a watchlist expiry time.
callable $changeLinePrefixer
getTags(RecentChange $rc, array &$classes)
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
getRollback(RecentChange $rc)
MapCacheLRU $watchMsgCache
endRecentChangesList()
Returns text for the end of RC.
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
LinkRenderer $linkRenderer
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
insertLogEntry( $rc)
Insert a formatted action.
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
const CSS_CLASS_PREFIX
insertLog(&$s, $title, $logtype, $useParentheses=true)
insertTags(&$s, &$rc, &$classes)
ChangesListFilterGroup[] $filterGroups
insertComment( $rc)
Insert a formatted comment.
static userCan( $rc, $field, Authority $performer=null)
Determine if the current user is allowed to view a particular field of this revision,...
insertExtra(&$s, &$rc, &$classes)
initChangesListRows( $rows)
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
IContextSource $context
setContext(IContextSource $context)
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition Language.php:42
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:1064
static getRevisionDeletedClass(RevisionRecord $revisionRecord)
Returns css class of a deleted revision.
Definition Linker.php:1299
static generateRollback(RevisionRecord $revRecord, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition Linker.php:2031
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition Linker.php:1749
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition Linker.php:1109
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Class to simplify the use of log pages.
Definition LogPage.php:38
Handles a simple LRU key/value map with a maximum number of entries.
Class that generates HTML links for pages.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Page revision base class.
getTimestamp()
MCR migration note: this replaced Revision::getTimestamp.
getPageAsLinkTarget()
Returns the title of the page this revision is associated with as a LinkTarget object.
userCan( $field, Authority $performer)
Determine if the give authority is allowed to view a particular field of this revision,...
isDeleted( $field)
MCR migration note: this replaced Revision::isDeleted.
getId( $wikiId=self::LOCAL)
Get revision ID.
Value object representing a user's identity.
Utility class for creating new RC entries.
getAttribute( $name)
Get an attribute value.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:69
useFilePatrol()
Check whether to enable new files patrol features for this user.
Definition User.php:3062
useNPPatrol()
Check whether to enable new pages patrol features for this user.
Definition User.php:3050
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition User.php:3041
Representation of a pair of user and title for watchlist entries.
getExpiryInDaysText(MessageLocalizer $msgLocalizer, $isDropdownOption=false)
Get days remaining until a watched item expires as a text.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
This interface represents the authority associated the current execution context, such as a web reque...
Definition Authority.php:37
getUser()
Returns the performer of the actions associated with this authority.
msg( $key,... $params)
This is the method for getting translated interface messages.
Result wrapper for grabbing data queried from an IDatabase object.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s
if(!isset( $args[0])) $lang