MediaWiki master
LogFormatter.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Logging;
13
32use stdClass;
36use Wikimedia\Timestamp\TimestampFormat as TS;
37
51 // Audience options for viewing usernames, comments, and actions
52 public const FOR_PUBLIC = 1;
53 public const FOR_THIS_USER = 2;
54
55 // Static->
56
63 public static function newFromEntry( LogEntry $entry ) {
64 wfDeprecated( __METHOD__, '1.42' );
65 return MediaWikiServices::getInstance()->getLogFormatterFactory()->newFromEntry( $entry );
66 }
67
76 public static function newFromRow( $row ) {
77 wfDeprecated( __METHOD__, '1.42' );
79 }
80
81 // Nonstatic->
82
84 protected $entry;
85
88
90 public $context;
91
93 protected $linkFlood = false;
94
102 protected $plaintext = false;
103
105 protected $irctext = false;
106
108 private $linkRenderer;
109
111 private $contentLanguage;
112
114 private $commentFormatter;
115
117 private $userEditTracker;
118
124
130 public function __construct( LogEntry $entry ) {
131 $this->entry = $entry;
132 $this->context = RequestContext::getMain();
133 }
134
138 public function setContext( IContextSource $context ) {
139 $this->context = $context;
140 }
141
146 public function setLinkRenderer( LinkRenderer $linkRenderer ) {
147 $this->linkRenderer = $linkRenderer;
148 }
149
154 public function getLinkRenderer() {
155 if ( $this->linkRenderer !== null ) {
156 return $this->linkRenderer;
157 } else {
158 wfDeprecated( static::class . " without all required services", '1.42' );
159 return MediaWikiServices::getInstance()->getLinkRenderer();
160 }
161 }
162
168 final public function setContentLanguage( Language $contentLanguage ) {
169 $this->contentLanguage = $contentLanguage;
170 }
171
176 final public function getContentLanguage(): Language {
177 if ( $this->contentLanguage === null ) {
178 wfDeprecated( static::class . " without all required services", '1.42' );
179 $this->contentLanguage = MediaWikiServices::getInstance()->getContentLanguage();
180 }
181 return $this->contentLanguage;
182 }
183
189 final public function setCommentFormatter( CommentFormatter $commentFormatter ) {
190 $this->commentFormatter = $commentFormatter;
191 }
192
197 final public function getCommentFormatter(): CommentFormatter {
198 if ( $this->commentFormatter === null ) {
199 wfDeprecated( static::class . " without all required services", '1.42' );
200 $this->commentFormatter = MediaWikiServices::getInstance()->getCommentFormatter();
201 }
202 return $this->commentFormatter;
203 }
204
210 final public function setUserEditTracker( UserEditTracker $userEditTracker ) {
211 $this->userEditTracker = $userEditTracker;
212 }
213
218 final public function getUserEditTracker(): UserEditTracker {
219 if ( $this->userEditTracker === null ) {
220 wfDeprecated( static::class . " without all required services", '1.42' );
221 $this->userEditTracker = MediaWikiServices::getInstance()->getUserEditTracker();
222 }
223 return $this->userEditTracker;
224 }
225
232 public function setAudience( $audience ) {
233 $this->audience = ( $audience == self::FOR_THIS_USER )
234 ? self::FOR_THIS_USER
235 : self::FOR_PUBLIC;
236 }
237
242 public function canViewLogType() {
243 // If the user doesn't have the right permission to view the specific
244 // log type, return false
245 $logRestrictions = $this->context->getConfig()->get( MainConfigNames::LogRestrictions );
246 $type = $this->entry->getType();
247 return !isset( $logRestrictions[$type] )
248 || $this->context->getAuthority()->isAllowed( $logRestrictions[$type] );
249 }
250
256 protected function canView( $field ) {
257 if ( $this->audience == self::FOR_THIS_USER ) {
258 return LogEventsList::userCanBitfield(
259 $this->entry->getDeleted(), $field, $this->context->getAuthority() ) &&
260 self::canViewLogType();
261 } else {
262 return !$this->entry->isDeleted( $field ) && self::canViewLogType();
263 }
264 }
265
272 public function setShowUserToolLinks( $value ) {
273 $this->linkFlood = $value;
274 }
275
284 public function getPlainActionText() {
285 $this->plaintext = true;
286 $text = $this->getActionText();
287 $this->plaintext = false;
288
289 return $text;
290 }
291
298 public function getIRCActionComment() {
299 $actionComment = $this->getIRCActionText();
300 $comment = $this->entry->getComment();
301
302 if ( $comment != '' ) {
303 if ( $actionComment == '' ) {
304 $actionComment = $comment;
305 } else {
306 $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
307 }
308 }
309
310 return $actionComment;
311 }
312
320 public function getIRCActionText() {
321 $this->plaintext = true;
322 $this->irctext = true;
323
324 $entry = $this->entry;
325 $parameters = $entry->getParameters();
326 // @see LogPage::actionText()
327 // Text of title the action is aimed at.
328 $target = $entry->getTarget()->getPrefixedText();
329 $text = null;
330 $contLang = $this->getContentLanguage();
331 switch ( $entry->getType() ) {
332 case 'move':
333 switch ( $entry->getSubtype() ) {
334 case 'move':
335 $movesource = $parameters['4::target'];
336 $text = wfMessage( '1movedto2' )
337 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
338 break;
339 case 'move_redir':
340 $movesource = $parameters['4::target'];
341 $text = wfMessage( '1movedto2_redir' )
342 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
343 break;
344 case 'move-noredirect':
345 break;
346 case 'move_redir-noredirect':
347 break;
348 }
349 break;
350
351 case 'delete':
352 switch ( $entry->getSubtype() ) {
353 case 'delete':
354 $text = wfMessage( 'deletedarticle' )
355 ->rawParams( $target )->inContentLanguage()->escaped();
356 break;
357 case 'restore':
358 $text = wfMessage( 'undeletedarticle' )
359 ->rawParams( $target )->inContentLanguage()->escaped();
360 break;
361 }
362 break;
363
364 case 'patrol':
365 // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
366 // Create a diff link to the patrolled revision
367 if ( $entry->getSubtype() === 'patrol' ) {
368 $diffLink = htmlspecialchars(
369 wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
370 ->inContentLanguage()->text() );
371 $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
372 ->inContentLanguage()->text();
373 } else {
374 // broken??
375 }
376 break;
377
378 case 'protect':
379 switch ( $entry->getSubtype() ) {
380 case 'protect':
381 $text = wfMessage( 'protectedarticle' )
382 ->rawParams( $target . ' ' . $parameters['4::description'] )
383 ->inContentLanguage()
384 ->escaped();
385 break;
386 case 'unprotect':
387 $text = wfMessage( 'unprotectedarticle' )
388 ->rawParams( $target )->inContentLanguage()->escaped();
389 break;
390 case 'modify':
391 $text = wfMessage( 'modifiedarticleprotection' )
392 ->rawParams( $target . ' ' . $parameters['4::description'] )
393 ->inContentLanguage()
394 ->escaped();
395 break;
396 case 'move_prot':
397 $text = wfMessage( 'movedarticleprotection' )
398 ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
399 break;
400 }
401 break;
402
403 case 'newusers':
404 switch ( $entry->getSubtype() ) {
405 case 'newusers':
406 case 'create':
407 $text = wfMessage( 'newuserlog-create-entry' )
408 ->inContentLanguage()->escaped();
409 break;
410 case 'create2':
411 case 'byemail':
412 $text = wfMessage( 'newuserlog-create2-entry' )
413 ->rawParams( $target )->inContentLanguage()->escaped();
414 break;
415 case 'autocreate':
416 $text = wfMessage( 'newuserlog-autocreate-entry' )
417 ->inContentLanguage()->escaped();
418 break;
419 }
420 break;
421
422 case 'upload':
423 switch ( $entry->getSubtype() ) {
424 case 'upload':
425 $text = wfMessage( 'uploadedimage' )
426 ->rawParams( $target )->inContentLanguage()->escaped();
427 break;
428 case 'overwrite':
429 case 'revert':
430 $text = wfMessage( 'overwroteimage' )
431 ->rawParams( $target )->inContentLanguage()->escaped();
432 break;
433 }
434 break;
435
436 case 'rights':
437 if ( count( $parameters['4::oldgroups'] ) ) {
438 $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
439 } else {
440 $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
441 }
442 if ( count( $parameters['5::newgroups'] ) ) {
443 $newgroups = implode( ', ', $parameters['5::newgroups'] );
444 } else {
445 $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
446 }
447 switch ( $entry->getSubtype() ) {
448 case 'rights':
449 $text = wfMessage( 'rightslogentry' )
450 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
451 break;
452 case 'autopromote':
453 $text = wfMessage( 'rightslogentry-autopromote' )
454 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
455 break;
456 }
457 break;
458
459 case 'merge':
460 switch ( $entry->getSubtype() ) {
461 case 'merge':
462 $text = wfMessage( 'pagemerge-logentry' )
463 ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
464 ->inContentLanguage()->escaped();
465 break;
466
467 case 'merge-into':
468 // Nothing for IRC (already covered by the log at the source page)
469 return '';
470 }
471 break;
472
473 case 'block':
474 switch ( $entry->getSubtype() ) {
475 case 'block':
476 // Keep compatibility with extensions by checking for
477 // new key (5::duration/6::flags) or old key (0/optional 1)
478 if ( $entry->isLegacy() ) {
479 $rawDuration = $parameters[0];
480 $rawFlags = $parameters[1] ?? '';
481 } else {
482 $rawDuration = $parameters['5::duration'];
483 $rawFlags = $parameters['6::flags'];
484 }
485 $duration = $contLang->translateBlockExpiry(
486 $rawDuration,
487 null,
488 (int)wfTimestamp( TS::UNIX, $entry->getTimestamp() )
489 );
490 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
491 $text = wfMessage( 'blocklogentry' )
492 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
493 break;
494 case 'unblock':
495 $text = wfMessage( 'unblocklogentry' )
496 ->rawParams( $target )->inContentLanguage()->escaped();
497 break;
498 case 'reblock':
499 $duration = $contLang->translateBlockExpiry(
500 $parameters['5::duration'],
501 null,
502 (int)wfTimestamp( TS::UNIX, $entry->getTimestamp() )
503 );
504 $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
505 $contLang );
506 $text = wfMessage( 'reblock-logentry' )
507 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
508 break;
509 }
510 break;
511
512 case 'import':
513 switch ( $entry->getSubtype() ) {
514 case 'upload':
515 $text = wfMessage( 'import-logentry-upload' )
516 ->rawParams( $target )->inContentLanguage()->escaped();
517 break;
518 case 'interwiki':
519 $text = wfMessage( 'import-logentry-interwiki' )
520 ->rawParams( $target )->inContentLanguage()->escaped();
521 break;
522 }
523 break;
524 // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
525 // default:
526 }
527
528 $this->plaintext = false;
529 $this->irctext = false;
530
531 return $text ?? $this->getPlainActionText();
532 }
533
541 public function getActionText() {
542 if ( $this->canView( LogPage::DELETED_ACTION ) ) {
543 $element = $this->getActionMessage();
544 if ( $element instanceof Message ) {
545 $element = $this->plaintext ? $element->text() : $element->escaped();
546 }
547 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
548 $element = $this->styleRestrictedElement( $element );
549 }
550 } else {
551 $sep = $this->msg( 'word-separator' );
552 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
553 $performer = $this->getPerformerElement();
554 $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
555 }
556
557 return $element;
558 }
559
566 protected function getActionMessage() {
567 $message = $this->msg( $this->getMessageKey() );
568 $message->params( $this->getMessageParameters() );
569
570 return $message;
571 }
572
581 protected function getMessageKey() {
582 $type = $this->entry->getType();
583 $subtype = $this->entry->getSubtype();
584
585 return "logentry-$type-$subtype";
586 }
587
594 public function getActionLinks() {
595 return '';
596 }
597
605 protected function extractParameters() {
606 $entry = $this->entry;
607 $params = [];
608
609 if ( $entry->isLegacy() ) {
610 foreach ( $entry->getParameters() as $index => $value ) {
611 $params[$index + 3] = $value;
612 }
613 }
614
615 // Filter out parameters which are not in format #:foo
616 foreach ( $entry->getParameters() as $key => $value ) {
617 if ( !str_contains( $key, ':' ) ) {
618 continue;
619 }
620 [ $index, $type, ] = explode( ':', $key, 3 );
621 if ( ctype_digit( $index ) ) {
622 $params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
623 }
624 }
625
626 /* Message class doesn't like non consecutive numbering.
627 * Fill in missing indexes with empty strings to avoid
628 * incorrect renumbering.
629 */
630 if ( count( $params ) ) {
631 $max = max( array_keys( $params ) );
632 // index 0 to 2 are added in getMessageParameters
633 for ( $i = 3; $i < $max; $i++ ) {
634 if ( !isset( $params[$i] ) ) {
635 $params[$i] = '';
636 }
637 }
638 }
639
640 return $params;
641 }
642
661 protected function getMessageParameters() {
662 if ( $this->parsedParameters !== null ) {
663 return $this->parsedParameters;
664 }
665
666 $entry = $this->entry;
667 $params = $this->extractParameters();
668 $params[0] = Message::rawParam( $this->getPerformerElement() );
669 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() : '';
670 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
671
672 // Bad things happens if the numbers are not in correct order
673 ksort( $params );
674
675 $this->parsedParameters = $params;
676 return $this->parsedParameters;
677 }
678
706 protected function formatParameterValue( $type, $value ) {
707 $saveLinkFlood = $this->linkFlood;
708
709 switch ( strtolower( trim( $type ) ) ) {
710 case 'raw':
711 // This used to allow raw HTML params, until we realized that's a bad idea (T422244#11787820)
712 $value = Message::plaintextParam( $value );
713 break;
714 case 'list':
715 $value = $this->context->getLanguage()->commaList( $value );
716 break;
717 case 'msg':
718 $value = $this->msg( $value )->text();
719 break;
720 case 'msg-content':
721 $value = $this->msg( $value )->inContentLanguage()->text();
722 break;
723 case 'number':
724 $value = Message::numParam( $value );
725 break;
726 case 'user':
727 $user = User::newFromName( $value );
728 $value = $user->getName();
729 break;
730 case 'user-link':
731 $this->setShowUserToolLinks( false );
732
733 $user = User::newFromName( $value );
734
735 if ( !$user ) {
736 $value = $this->msg( 'empty-username' )->text();
737 } else {
738 $value = Message::rawParam( $this->makeUserLink( $user ) );
739 $this->setShowUserToolLinks( $saveLinkFlood );
740 }
741 break;
742 case 'title':
743 $title = Title::newFromText( $value );
744 $value = $title->getPrefixedText();
745 break;
746 case 'title-link':
747 $title = Title::newFromText( $value );
748 $value = Message::rawParam( $this->makePageLink( $title ) );
749 break;
750 case 'plain':
751 // Plain text, nothing to do
752 default:
753 // Catch other types and use the old behavior (return as-is)
754 }
755
756 return $value;
757 }
758
769 protected function makePageLink( ?Title $title = null, $parameters = [], $html = null ) {
770 if ( !$title instanceof Title ) {
771 $msg = $this->msg( 'invalidtitle' )->text();
772 if ( $this->plaintext ) {
773 return $msg;
774 } else {
775 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
776 }
777 }
778
779 if ( $this->plaintext ) {
780 $link = '[[' . $title->getPrefixedText() . ']]';
781 } else {
782 $html = $html !== null ? new HtmlArmor( $html ) : $html;
783 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
784 }
785
786 return $link;
787 }
788
795 public function getPerformerElement() {
796 if ( $this->canView( LogPage::DELETED_USER ) ) {
797 $performerIdentity = $this->entry->getPerformerIdentity();
798 $element = $this->makeUserLink( $performerIdentity );
799 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
800 $element = $this->styleRestrictedElement( $element );
801 }
802 } else {
803 $element = $this->getRestrictedElement( 'rev-deleted-user' );
804 }
805
806 return $element;
807 }
808
814 public function getComment() {
815 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
816 $comment = $this->getCommentFormatter()
817 ->formatBlock( $this->entry->getComment(), null, false, $this->getCommentWikiId() );
818 // No hard coded spaces thanx
819 $element = ltrim( $comment );
820 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
821 $element = $this->styleRestrictedElement( $element );
822 }
823 } else {
824 $element = $this->getRestrictedElement( 'rev-deleted-comment' );
825 }
826
827 return $element;
828 }
829
843 protected function getCommentWikiId() {
844 return false;
845 }
846
853 protected function getRestrictedElement( $message ) {
854 if ( $this->plaintext ) {
855 return $this->msg( $message )->text();
856 }
857
858 return $this->styleRestrictedElement( $this->msg( $message )->escaped() );
859 }
860
866 protected function styleRestrictedElement( $content ) {
867 if ( $this->plaintext ) {
868 return $content;
869 }
870 $attribs = [ 'class' => [ 'history-deleted' ] ];
871 if ( $this->entry->isDeleted( LogPage::DELETED_RESTRICTED ) ) {
872 $attribs['class'][] = 'mw-history-suppressed';
873 }
874
875 return Html::rawElement( 'span', $attribs, $content );
876 }
877
886 protected function msg( $key, ...$params ) {
887 return $this->context->msg( $key, ...$params );
888 }
889
896 protected function makeUserLink( UserIdentity $user, $toolFlags = 0 ) {
897 if ( $this->plaintext ) {
898 $element = $user->getName();
899 } else {
900 $element = Linker::userLink(
901 $user->getId(),
902 $user->getName()
903 );
904 if ( $this->linkFlood ) {
905 $editCount = $this->getUserEditTracker()->getUserEditCount( $user );
906
907 $element .= Linker::userToolLinks(
908 $user->getId(),
909 $user->getName(),
910 true, // redContribsWhenNoEdits
911 $toolFlags,
912 $editCount,
913 // do not render parentheses in the HTML markup (CSS will provide)
914 false
915 );
916 }
917 }
918
919 return $element;
920 }
921
926 public function getPreloadTitles() {
927 return [];
928 }
929
934 // This function was added because getMessageParameters() is
935 // protected and a change from protected to public caused
936 // problems with extensions
937 return $this->getMessageParameters();
938 }
939
946 protected function getParametersForApi() {
947 if ( LogEntryBase::containsUnsafeParams( $this->entry->getParameters() ) ) {
948 // Just in case, although this should be unreachable if LogFormatterFactory is used
949 return [];
950 }
951 return $this->entry->getParameters();
952 }
953
969 public function formatParametersForApi() {
970 $logParams = [];
971 foreach ( $this->getParametersForApi() as $key => $value ) {
972 $vals = explode( ':', $key, 3 );
973 if ( count( $vals ) !== 3 ) {
974 $logParams[$key] = $value;
975 continue;
976 }
977 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
978 }
979 ApiResult::setIndexedTagName( $logParams, 'param' );
980 ApiResult::setArrayType( $logParams, 'assoc' );
981
982 return $logParams;
983 }
984
994 protected function formatParameterValueForApi( $name, $type, $value ) {
995 $type = strtolower( trim( $type ) );
996 switch ( $type ) {
997 case 'bool':
998 $value = (bool)$value;
999 break;
1000
1001 case 'number':
1002 if ( is_int( $value ) || ctype_digit( (string)$value ) ) {
1003 $value = (int)$value;
1004 } else {
1005 $value = (float)$value;
1006 }
1007 break;
1008
1009 case 'array':
1010 case 'assoc':
1011 case 'kvp':
1012 if ( is_array( $value ) ) {
1013 ApiResult::setArrayType( $value, $type );
1014 }
1015 break;
1016
1017 case 'timestamp':
1018 $value = wfTimestamp( TS::ISO_8601, $value );
1019 break;
1020
1021 case 'msg':
1022 case 'msg-content':
1023 $msg = $this->msg( $value );
1024 if ( $type === 'msg-content' ) {
1025 $msg->inContentLanguage();
1026 }
1027 $value = [];
1028 $value["{$name}_key"] = $msg->getKey();
1029 if ( $msg->getParams() ) {
1030 $value["{$name}_params"] = $msg->getParams();
1031 }
1032 $value["{$name}_text"] = $msg->text();
1033 return $value;
1034
1035 case 'title':
1036 case 'title-link':
1037 $title = Title::newFromText( $value );
1038 if ( !$title ) {
1039 $title = SpecialPage::getTitleFor( 'Badtitle', $value );
1040 }
1041 $value = [];
1042 ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
1043 return $value;
1044
1045 case 'user':
1046 case 'user-link':
1047 $user = User::newFromName( $value );
1048 if ( $user ) {
1049 $value = $user->getName();
1050 }
1051 break;
1052
1053 default:
1054 // do nothing
1055 break;
1056 }
1057
1058 return [ $name => $value ];
1059 }
1060}
1061
1063class_alias( LogFormatter::class, 'LogFormatter' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:71
This is a base class for all Query modules.
This class represents the result of the API operations.
Definition ApiResult.php:34
This is the main service interface for converting single-line comments from various DB comment fields...
Group all the pieces relevant to the context of a request into one instance.
This class is a collection of static functions that serve two purposes:
Definition Html.php:44
Base class for language-specific code.
Definition Language.php:65
Class that generates HTML for internal links.
Some internal bits split of from Skin.php.
Definition Linker.php:48
static newFromRow( $row, string|false $wikiId=WikiAwareEntity::LOCAL)
Constructs new LogEntry from database result row.
Implements the default log formatting.
setContext(IContextSource $context)
Replace the default context.
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
canView( $field)
Check if a log item can be displayed.
styleRestrictedElement( $content)
Helper method for styling restricted element.
setLinkRenderer(LinkRenderer $linkRenderer)
makeUserLink(UserIdentity $user, $toolFlags=0)
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
makePageLink(?Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
extractParameters()
Extracts the optional extra parameters for use in action messages.
bool $linkFlood
Whether to output user tool links.
getActionText()
Gets the log action, including username.
setContentLanguage(Language $contentLanguage)
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
setCommentFormatter(CommentFormatter $commentFormatter)
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
setAudience( $audience)
Set the visibility restrictions for displaying content.
bool $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
canViewLogType()
Check if a log item type can be displayed.
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
getMessageKey()
Returns a key to be used for formatting the action sentence.
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
setUserEditTracker(UserEditTracker $userEditTracker)
getActionMessage()
Returns a sentence describing the log action.
getRestrictedElement( $message)
Helper method for displaying restricted element.
getPerformerElement()
Provides the name of the user who performed the log action.
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
formatParametersForApi()
Format parameters for API output.
int $audience
Constant for handling log_deleted.
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
getComment()
Gets the user provided comment.
getPlainActionText()
Ugly hack to produce plaintext version of the message.
getCommentWikiId()
Returns the wiki ID to use for resolving links in the log comment.
IContextSource $context
Context for logging.
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144
Parent class for all special pages.
Represents a title within MediaWiki.
Definition Title.php:69
Track info about user edit counts and timings.
User class for the MediaWiki software.
Definition User.php:130
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
Value object representing a message parameter with one of the types from {.
Interface for objects which can provide a MediaWiki context on request.
Represents the target of a wiki link.
An individual log entry.
Definition LogEntry.php:24
Interface for objects representing user identity.
getId( $wikiId=self::LOCAL)