MediaWiki REL1_36
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
43 public $skin;
44
45 protected $watchlist = false;
46 protected $lastdate;
47 protected $message;
48 protected $rc_cache;
49 protected $rcCacheIndex;
50 protected $rclistOpen;
51 protected $rcMoveIndex;
52
55
57 protected $watchMsgCache;
58
62 protected $linkRenderer;
63
67 protected $filterGroups;
68
73 public function __construct( $obj, array $filterGroups = [] ) {
74 if ( $obj instanceof IContextSource ) {
75 $this->setContext( $obj );
76 $this->skin = $obj->getSkin();
77 } else {
78 $this->setContext( $obj->getContext() );
79 $this->skin = $obj;
80 }
81 $this->preCacheMessages();
82 $this->watchMsgCache = new MapCacheLRU( 50 );
83 $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
84 $this->filterGroups = $filterGroups;
85 }
86
95 public static function newFromContext( IContextSource $context, array $groups = [] ) {
96 $user = $context->getUser();
97 $sk = $context->getSkin();
98 $list = null;
99 if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
100 $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
101
102 return $new ?
103 new EnhancedChangesList( $context, $groups ) :
104 new OldChangesList( $context, $groups );
105 } else {
106 return $list;
107 }
108 }
109
121 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
122 throw new RuntimeException( 'recentChangesLine should be implemented' );
123 }
124
131 protected function getHighlightsContainerDiv() {
132 $highlightColorDivs = '';
133 foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
134 $highlightColorDivs .= Html::rawElement(
135 'div',
136 [
137 'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
138 'data-color' => $color
139 ]
140 );
141 }
142
143 return Html::rawElement(
144 'div',
145 [ 'class' => 'mw-rcfilters-ui-highlights' ],
146 $highlightColorDivs
147 );
148 }
149
154 public function setWatchlistDivs( $value = true ) {
155 $this->watchlist = $value;
156 }
157
162 public function isWatchlist() {
163 return (bool)$this->watchlist;
164 }
165
170 private function preCacheMessages() {
171 if ( !isset( $this->message ) ) {
172 $this->message = [];
173 foreach ( [
174 'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
175 'semicolon-separator', 'pipe-separator' ] as $msg
176 ) {
177 $this->message[$msg] = $this->msg( $msg )->escaped();
178 }
179 }
180 }
181
188 public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
189 $f = '';
190 foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
191 $f .= isset( $flags[$flag] ) && $flags[$flag]
192 ? self::flag( $flag, $this->getContext() )
193 : $nothing;
194 }
195
196 return $f;
197 }
198
207 protected function getHTMLClasses( $rc, $watched ) {
208 $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
209 $logType = $rc->mAttribs['rc_log_type'];
210
211 if ( $logType ) {
212 $classes[] = self::CSS_CLASS_PREFIX . 'log';
213 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
214 } else {
215 $classes[] = self::CSS_CLASS_PREFIX . 'edit';
216 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
217 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
218 }
219
220 // Indicate watched status on the line to allow for more
221 // comprehensive styling.
222 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
223 ? self::CSS_CLASS_PREFIX . 'line-watched'
224 : self::CSS_CLASS_PREFIX . 'line-not-watched';
225
226 $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
227
228 return $classes;
229 }
230
238 protected function getHTMLClassesForFilters( $rc ) {
239 $classes = [];
240
241 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
242 $rc->mAttribs['rc_namespace'] );
243
244 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
245 $classes[] = Sanitizer::escapeClass(
246 self::CSS_CLASS_PREFIX .
247 'ns-' .
248 ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
249 );
250
251 if ( $this->filterGroups !== null ) {
252 foreach ( $this->filterGroups as $filterGroup ) {
253 foreach ( $filterGroup->getFilters() as $filter ) {
254 $filter->applyCssClassIfNeeded( $this, $rc, $classes );
255 }
256 }
257 }
258
259 return $classes;
260 }
261
272 public static function flag( $flag, IContextSource $context = null ) {
273 static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
274 static $flagInfos = null;
275
276 if ( $flagInfos === null ) {
278 $flagInfos = [];
279 foreach ( $wgRecentChangesFlags as $key => $value ) {
280 $flagInfos[$key]['letter'] = $value['letter'];
281 $flagInfos[$key]['title'] = $value['title'];
282 // Allow customized class name, fall back to flag name
283 $flagInfos[$key]['class'] = $value['class'] ?? $key;
284 }
285 }
286
287 $context = $context ?: RequestContext::getMain();
288
289 // Inconsistent naming, kepted for b/c
290 if ( isset( $map[$flag] ) ) {
291 $flag = $map[$flag];
292 }
293
294 $info = $flagInfos[$flag];
295 return Html::element( 'abbr', [
296 'class' => $info['class'],
297 'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
298 ], wfMessage( $info['letter'] )->setContext( $context )->text() );
299 }
300
305 public function beginRecentChangesList() {
306 $this->rc_cache = [];
307 $this->rcMoveIndex = 0;
308 $this->rcCacheIndex = 0;
309 $this->lastdate = '';
310 $this->rclistOpen = false;
311 $this->getOutput()->addModuleStyles( [
312 'mediawiki.interface.helpers.styles',
313 'mediawiki.special.changeslist'
314 ] );
315
316 return '<div class="mw-changeslist">';
317 }
318
322 public function initChangesListRows( $rows ) {
323 $this->getHookRunner()->onChangesListInitRows( $this, $rows );
324 }
325
336 public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
337 if ( !$context ) {
338 $context = RequestContext::getMain();
339 }
340
341 $new = (int)$new;
342 $old = (int)$old;
343 $szdiff = $new - $old;
344
346 $config = $context->getConfig();
347 $code = $lang->getCode();
348 static $fastCharDiff = [];
349 if ( !isset( $fastCharDiff[$code] ) ) {
350 $fastCharDiff[$code] = $config->get( 'MiserMode' )
351 || $context->msg( 'rc-change-size' )->plain() === '$1';
352 }
353
354 $formattedSize = $lang->formatNum( $szdiff );
355
356 if ( !$fastCharDiff[$code] ) {
357 $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
358 }
359
360 if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
361 $tag = 'strong';
362 } else {
363 $tag = 'span';
364 }
365
366 if ( $szdiff === 0 ) {
367 $formattedSizeClass = 'mw-plusminus-null';
368 } elseif ( $szdiff > 0 ) {
369 $formattedSize = '+' . $formattedSize;
370 $formattedSizeClass = 'mw-plusminus-pos';
371 } else {
372 $formattedSizeClass = 'mw-plusminus-neg';
373 }
374 $formattedSizeClass .= ' mw-diff-bytes';
375
376 $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
377
378 return Html::element( $tag,
379 [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
380 $formattedSize ) . $lang->getDirMark();
381 }
382
390 public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
391 $oldlen = $old->mAttribs['rc_old_len'];
392
393 if ( $new ) {
394 $newlen = $new->mAttribs['rc_new_len'];
395 } else {
396 $newlen = $old->mAttribs['rc_new_len'];
397 }
398
399 if ( $oldlen === null || $newlen === null ) {
400 return '';
401 }
402
403 return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
404 }
405
410 public function endRecentChangesList() {
411 $out = $this->rclistOpen ? "</ul>\n" : '';
412 $out .= '</div>';
413
414 return $out;
415 }
416
428 public static function revDateLink(
429 RevisionRecord $rev,
430 Authority $performer,
432 $title = null
433 ) {
434 $ts = $rev->getTimestamp();
435 $date = $lang->userTimeAndDate( $ts, $performer->getUser() );
436 if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
437 $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
438 $title ?? $rev->getPageAsLinkTarget(),
439 $date,
440 [ 'class' => 'mw-changeslist-date' ],
441 [ 'oldid' => $rev->getId() ]
442 );
443 } else {
444 $link = htmlspecialchars( $date );
445 }
446 if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
447 $link = "<span class=\"history-deleted mw-changeslist-date\">$link</span>";
448 }
449 return $link;
450 }
451
456 public function insertDateHeader( &$s, $rc_timestamp ) {
457 # Make date header if necessary
458 $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
459 if ( $date != $this->lastdate ) {
460 if ( $this->lastdate != '' ) {
461 $s .= "</ul>\n";
462 }
463 $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
464 $this->lastdate = $date;
465 $this->rclistOpen = true;
466 }
467 }
468
475 public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
476 $page = new LogPage( $logtype );
477 $logname = $page->getName()->setContext( $this->getContext() )->text();
478 $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
479 'class' => $useParentheses ? '' : 'mw-changeslist-links'
480 ] );
481 if ( $useParentheses ) {
482 $s .= $this->msg( 'parentheses' )->rawParams(
483 $link
484 )->escaped();
485 } else {
486 $s .= $link;
487 }
488 }
489
495 public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
496 # Diff link
497 if (
498 $rc->mAttribs['rc_type'] == RC_NEW ||
499 $rc->mAttribs['rc_type'] == RC_LOG ||
500 $rc->mAttribs['rc_type'] == RC_CATEGORIZE
501 ) {
502 $diffLink = $this->message['diff'];
503 } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
504 $diffLink = $this->message['diff'];
505 } else {
506 $query = [
507 'curid' => $rc->mAttribs['rc_cur_id'],
508 'diff' => $rc->mAttribs['rc_this_oldid'],
509 'oldid' => $rc->mAttribs['rc_last_oldid']
510 ];
511
512 $diffLink = $this->linkRenderer->makeKnownLink(
513 $rc->getTitle(),
514 new HtmlArmor( $this->message['diff'] ),
515 [ 'class' => 'mw-changeslist-diff' ],
516 $query
517 );
518 }
519 if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
520 $histLink = $this->message['hist'];
521 } else {
522 $histLink = $this->linkRenderer->makeKnownLink(
523 $rc->getTitle(),
524 new HtmlArmor( $this->message['hist'] ),
525 [ 'class' => 'mw-changeslist-history' ],
526 [
527 'curid' => $rc->mAttribs['rc_cur_id'],
528 'action' => 'history'
529 ]
530 );
531 }
532
533 $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ],
534 Html::rawElement( 'span', [], $diffLink ) .
535 Html::rawElement( 'span', [], $histLink )
536 ) .
537 ' <span class="mw-changeslist-separator"></span> ';
538 }
539
550 public function getArticleLink( &$rc, $unpatrolled, $watched ) {
551 $params = [];
552 if ( $rc->getTitle()->isRedirect() ) {
553 $params = [ 'redirect' => 'no' ];
554 }
555
556 $articlelink = $this->linkRenderer->makeLink(
557 $rc->getTitle(),
558 null,
559 [ 'class' => 'mw-changeslist-title' ],
560 $params
561 );
562 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
563 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
564 }
565 # To allow for boldening pages watched by this user
566 $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
567 # RTL/LTR marker
568 $articlelink .= $this->getLanguage()->getDirMark();
569
570 # TODO: Deprecate the $s argument, it seems happily unused.
571 $s = '';
572 $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
573 $s, $rc, $unpatrolled, $watched );
574
575 // Watchlist expiry icon.
576 $watchlistExpiry = '';
577 if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
578 $watchlistExpiry = $this->getWatchlistExpiry( $rc );
579 }
580
581 return "{$s} {$articlelink}{$watchlistExpiry}";
582 }
583
590 public function getWatchlistExpiry( RecentChange $recentChange ): string {
591 $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
592 // Guard against expired items, even though they shouldn't come here.
593 if ( $item->isExpired() ) {
594 return '';
595 }
596 $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
597 // Matching widget is also created in ChangesListSpecialPage, for the legend.
598 $widget = new IconWidget( [
599 'icon' => 'clock',
600 'title' => $daysLeftText,
601 'classes' => [ 'mw-changesList-watchlistExpiry' ],
602 ] );
603 $widget->setAttributes( [
604 // Add labels for assistive technologies.
605 'role' => 'img',
606 'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
607 // Days-left is used in resources/src/mediawiki.special.changeslist.watchlistexpiry/watchlistexpiry.js
608 'data-days-left' => $item->getExpiryInDays(),
609 ] );
610 // Add spaces around the widget (the page title is to one side,
611 // and a semicolon or opening-parenthesis to the other).
612 return " $widget ";
613 }
614
623 public function getTimestamp( $rc ) {
624 // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
625 // because in that case the timestamp is preceeded by a clock icon.
626 // A space is important after mw-changeslist-separator--semicolon to make sure
627 // that whatever comes before it is distinguishable.
628 // (Otherwise your have the text of titles pushing up against the timestamp)
629 // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
630 // of other places with a different position and the information proceeding getTimestamp can vary.
631 $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
632 return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
633 '<span class="mw-changeslist-date">' .
634 htmlspecialchars( $this->getLanguage()->userTime(
635 $rc->mAttribs['rc_timestamp'],
636 $this->getUser()
637 ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
638 }
639
646 public function insertTimestamp( &$s, $rc ) {
647 $s .= $this->getTimestamp( $rc );
648 }
649
656 public function insertUserRelatedLinks( &$s, &$rc ) {
657 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
658 $s .= ' <span class="history-deleted">' .
659 $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
660 } else {
661 $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
662 $rc->mAttribs['rc_user_text'] );
664 $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
665 false, 0, null,
666 // The text content of tools is not wrapped with parenthesises or "piped".
667 // This will be handled in CSS (T205581).
668 false
669 );
670 }
671 }
672
679 public function insertLogEntry( $rc ) {
680 $formatter = LogFormatter::newFromRow( $rc->mAttribs );
681 $formatter->setContext( $this->getContext() );
682 $formatter->setShowUserToolLinks( true );
683 $mark = $this->getLanguage()->getDirMark();
684
685 return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
686 . $formatter->getActionText() . " $mark" . $formatter->getComment()
687 . Html::closeElement( 'span' );
688 }
689
695 public function insertComment( $rc ) {
696 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
697 return ' <span class="history-deleted 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 // @phan-suppress-next-line PhanTypeInvalidLeftOperandOfBitwiseOp false positive
737 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
738 }
739
749 public static function userCan( $rc, $field, Authority $performer = null ) {
750 if ( $performer === null ) {
751 $performer = RequestContext::getMain()->getAuthority();
752 }
753
754 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
755 return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
756 }
757
758 return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
759 }
760
766 protected function maybeWatchedLink( $link, $watched = false ) {
767 if ( $watched ) {
768 return '<strong class="mw-watched">' . $link . '</strong>';
769 } else {
770 return '<span class="mw-rc-unwatched">' . $link . '</span>';
771 }
772 }
773
780 public function insertRollback( &$s, &$rc ) {
781 if ( $rc->mAttribs['rc_type'] == RC_EDIT
782 && $rc->mAttribs['rc_this_oldid']
783 && $rc->mAttribs['rc_cur_id']
784 && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
785 ) {
786 $title = $rc->getTitle();
790 if ( $this->getAuthority()->probablyCan( 'rollback', $title ) ) {
791 $revRecord = new MutableRevisionRecord( $title );
792 $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
793 $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
794 $user = new UserIdentityValue(
795 (int)$rc->mAttribs['rc_user'],
796 $rc->mAttribs['rc_user_text']
797 );
798 $revRecord->setUser( $user );
799
800 $s .= ' ';
802 $revRecord,
803 $this->getContext(),
804 [ 'noBrackets' ]
805 );
806 }
807 }
808 }
809
815 public function getRollback( RecentChange $rc ) {
816 $s = '';
817 $this->insertRollback( $s, $rc );
818 return $s;
819 }
820
826 public function insertTags( &$s, &$rc, &$classes ) {
827 if ( empty( $rc->mAttribs['ts_tags'] ) ) {
828 return;
829 }
830
831 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
832 $rc->mAttribs['ts_tags'],
833 'changeslist',
834 $this->getContext()
835 );
836 $classes = array_merge( $classes, $newClasses );
837 $s .= ' ' . $tagSummary;
838 }
839
846 public function getTags( RecentChange $rc, array &$classes ) {
847 $s = '';
848 $this->insertTags( $s, $rc, $classes );
849 return $s;
850 }
851
852 public function insertExtra( &$s, &$rc, &$classes ) {
853 // Empty, used for subclasses to add anything special.
854 }
855
856 protected function showAsUnpatrolled( RecentChange $rc ) {
857 return self::isUnpatrolled( $rc, $this->getUser() );
858 }
859
865 public static function isUnpatrolled( $rc, User $user ) {
866 if ( $rc instanceof RecentChange ) {
867 $isPatrolled = $rc->mAttribs['rc_patrolled'];
868 $rcType = $rc->mAttribs['rc_type'];
869 $rcLogType = $rc->mAttribs['rc_log_type'];
870 } else {
871 $isPatrolled = $rc->rc_patrolled;
872 $rcType = $rc->rc_type;
873 $rcLogType = $rc->rc_log_type;
874 }
875
876 if ( !$isPatrolled ) {
877 if ( $user->useRCPatrol() ) {
878 return true;
879 }
880 if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
881 return true;
882 }
883 if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
884 return true;
885 }
886 }
887
888 return false;
889 }
890
900 protected function isCategorizationWithoutRevision( $rcObj ) {
901 return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
902 && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
903 }
904
910 protected function getDataAttributes( RecentChange $rc ) {
911 $attrs = [];
912
913 $type = $rc->getAttribute( 'rc_source' );
914 switch ( $type ) {
915 case RecentChange::SRC_EDIT:
916 case RecentChange::SRC_NEW:
917 $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
918 break;
919 case RecentChange::SRC_LOG:
920 $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
921 $attrs['data-mw-logaction'] =
922 $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
923 break;
924 }
925
926 $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
927
928 return $attrs;
929 }
930
938 public function setChangeLinePrefixer( callable $prefixer ) {
939 $this->changeLinePrefixer = $prefixer;
940 }
941}
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:127
const RC_LOG
Definition Defines.php:128
const RC_EDIT
Definition Defines.php:126
const RC_CATEGORIZE
Definition Defines.php:130
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
getContext()
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
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)
array $filterGroups
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.
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)
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)
__construct( $obj, array $filterGroups=[])
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:43
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition Linker.php:1862
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:900
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:1577
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:945
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 replaces 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 replaces 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 main skin class which provides methods and properties for all other skins.
Definition Skin.php:42
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:67
useFilePatrol()
Check whether to enable new files patrol features for this user.
Definition User.php:3165
useNPPatrol()
Check whether to enable new pages patrol features for this user.
Definition User.php:3153
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition User.php:3144
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:35
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