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
604 protected function extractParameters() {
605 $entry = $this->entry;
606 $params = [];
607
608 if ( $entry->isLegacy() ) {
609 foreach ( $entry->getParameters() as $index => $value ) {
610 $params[$index + 3] = $value;
611 }
612 }
613
614 // Filter out parameters which are not in format #:foo
615 foreach ( $entry->getParameters() as $key => $value ) {
616 if ( !str_contains( $key, ':' ) ) {
617 continue;
618 }
619 [ $index, $type, ] = explode( ':', $key, 3 );
620 if ( ctype_digit( $index ) ) {
621 $params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
622 }
623 }
624
625 /* Message class doesn't like non consecutive numbering.
626 * Fill in missing indexes with empty strings to avoid
627 * incorrect renumbering.
628 */
629 if ( count( $params ) ) {
630 $max = max( array_keys( $params ) );
631 // index 0 to 2 are added in getMessageParameters
632 for ( $i = 3; $i < $max; $i++ ) {
633 if ( !isset( $params[$i] ) ) {
634 $params[$i] = '';
635 }
636 }
637 }
638
639 return $params;
640 }
641
659 protected function getMessageParameters() {
660 if ( $this->parsedParameters !== null ) {
661 return $this->parsedParameters;
662 }
663
664 $entry = $this->entry;
665 $params = $this->extractParameters();
666 $params[0] = Message::rawParam( $this->getPerformerElement() );
667 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() : '';
668 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
669
670 // Bad things happens if the numbers are not in correct order
671 ksort( $params );
672
673 $this->parsedParameters = $params;
674 return $this->parsedParameters;
675 }
676
703 protected function formatParameterValue( $type, $value ) {
704 $saveLinkFlood = $this->linkFlood;
705
706 switch ( strtolower( trim( $type ) ) ) {
707 case 'raw':
708 $value = Message::rawParam( $value );
709 break;
710 case 'list':
711 $value = $this->context->getLanguage()->commaList( $value );
712 break;
713 case 'msg':
714 $value = $this->msg( $value )->text();
715 break;
716 case 'msg-content':
717 $value = $this->msg( $value )->inContentLanguage()->text();
718 break;
719 case 'number':
720 $value = Message::numParam( $value );
721 break;
722 case 'user':
723 $user = User::newFromName( $value );
724 $value = $user->getName();
725 break;
726 case 'user-link':
727 $this->setShowUserToolLinks( false );
728
729 $user = User::newFromName( $value );
730
731 if ( !$user ) {
732 $value = $this->msg( 'empty-username' )->text();
733 } else {
734 $value = Message::rawParam( $this->makeUserLink( $user ) );
735 $this->setShowUserToolLinks( $saveLinkFlood );
736 }
737 break;
738 case 'title':
739 $title = Title::newFromText( $value );
740 $value = $title->getPrefixedText();
741 break;
742 case 'title-link':
743 $title = Title::newFromText( $value );
744 $value = Message::rawParam( $this->makePageLink( $title ) );
745 break;
746 case 'plain':
747 // Plain text, nothing to do
748 default:
749 // Catch other types and use the old behavior (return as-is)
750 }
751
752 return $value;
753 }
754
765 protected function makePageLink( ?Title $title = null, $parameters = [], $html = null ) {
766 if ( !$title instanceof Title ) {
767 $msg = $this->msg( 'invalidtitle' )->text();
768 if ( $this->plaintext ) {
769 return $msg;
770 } else {
771 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
772 }
773 }
774
775 if ( $this->plaintext ) {
776 $link = '[[' . $title->getPrefixedText() . ']]';
777 } else {
778 $html = $html !== null ? new HtmlArmor( $html ) : $html;
779 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
780 }
781
782 return $link;
783 }
784
791 public function getPerformerElement() {
792 if ( $this->canView( LogPage::DELETED_USER ) ) {
793 $performerIdentity = $this->entry->getPerformerIdentity();
794 $element = $this->makeUserLink( $performerIdentity );
795 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
796 $element = $this->styleRestrictedElement( $element );
797 }
798 } else {
799 $element = $this->getRestrictedElement( 'rev-deleted-user' );
800 }
801
802 return $element;
803 }
804
810 public function getComment() {
811 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
812 $comment = $this->getCommentFormatter()
813 ->formatBlock( $this->entry->getComment() );
814 // No hard coded spaces thanx
815 $element = ltrim( $comment );
816 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
817 $element = $this->styleRestrictedElement( $element );
818 }
819 } else {
820 $element = $this->getRestrictedElement( 'rev-deleted-comment' );
821 }
822
823 return $element;
824 }
825
832 protected function getRestrictedElement( $message ) {
833 if ( $this->plaintext ) {
834 return $this->msg( $message )->text();
835 }
836
837 return $this->styleRestrictedElement( $this->msg( $message )->escaped() );
838 }
839
845 protected function styleRestrictedElement( $content ) {
846 if ( $this->plaintext ) {
847 return $content;
848 }
849 $attribs = [ 'class' => [ 'history-deleted' ] ];
850 if ( $this->entry->isDeleted( LogPage::DELETED_RESTRICTED ) ) {
851 $attribs['class'][] = 'mw-history-suppressed';
852 }
853
854 return Html::rawElement( 'span', $attribs, $content );
855 }
856
865 protected function msg( $key, ...$params ) {
866 return $this->context->msg( $key, ...$params );
867 }
868
875 protected function makeUserLink( UserIdentity $user, $toolFlags = 0 ) {
876 if ( $this->plaintext ) {
877 $element = $user->getName();
878 } else {
879 $element = Linker::userLink(
880 $user->getId(),
881 $user->getName()
882 );
883 if ( $this->linkFlood ) {
884 $editCount = $this->getUserEditTracker()->getUserEditCount( $user );
885
886 $element .= Linker::userToolLinks(
887 $user->getId(),
888 $user->getName(),
889 true, // redContribsWhenNoEdits
890 $toolFlags,
891 $editCount,
892 // do not render parentheses in the HTML markup (CSS will provide)
893 false
894 );
895 }
896 }
897
898 return $element;
899 }
900
905 public function getPreloadTitles() {
906 return [];
907 }
908
913 // This function was added because getMessageParameters() is
914 // protected and a change from protected to public caused
915 // problems with extensions
916 return $this->getMessageParameters();
917 }
918
925 protected function getParametersForApi() {
926 return $this->entry->getParameters();
927 }
928
944 public function formatParametersForApi() {
945 $logParams = [];
946 foreach ( $this->getParametersForApi() as $key => $value ) {
947 $vals = explode( ':', $key, 3 );
948 if ( count( $vals ) !== 3 ) {
949 if ( $value instanceof \__PHP_Incomplete_Class ) {
950 wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
951 ' contains unrecoverable extra parameters.' );
952 continue;
953 }
954 $logParams[$key] = $value;
955 continue;
956 }
957 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
958 }
959 ApiResult::setIndexedTagName( $logParams, 'param' );
960 ApiResult::setArrayType( $logParams, 'assoc' );
961
962 return $logParams;
963 }
964
974 protected function formatParameterValueForApi( $name, $type, $value ) {
975 $type = strtolower( trim( $type ) );
976 switch ( $type ) {
977 case 'bool':
978 $value = (bool)$value;
979 break;
980
981 case 'number':
982 if ( is_int( $value ) || ctype_digit( (string)$value ) ) {
983 $value = (int)$value;
984 } else {
985 $value = (float)$value;
986 }
987 break;
988
989 case 'array':
990 case 'assoc':
991 case 'kvp':
992 if ( is_array( $value ) ) {
993 ApiResult::setArrayType( $value, $type );
994 }
995 break;
996
997 case 'timestamp':
998 $value = wfTimestamp( TS::ISO_8601, $value );
999 break;
1000
1001 case 'msg':
1002 case 'msg-content':
1003 $msg = $this->msg( $value );
1004 if ( $type === 'msg-content' ) {
1005 $msg->inContentLanguage();
1006 }
1007 $value = [];
1008 $value["{$name}_key"] = $msg->getKey();
1009 if ( $msg->getParams() ) {
1010 $value["{$name}_params"] = $msg->getParams();
1011 }
1012 $value["{$name}_text"] = $msg->text();
1013 return $value;
1014
1015 case 'title':
1016 case 'title-link':
1017 $title = Title::newFromText( $value );
1018 if ( !$title ) {
1019 $title = SpecialPage::getTitleFor( 'Badtitle', $value );
1020 }
1021 $value = [];
1022 ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
1023 return $value;
1024
1025 case 'user':
1026 case 'user-link':
1027 $user = User::newFromName( $value );
1028 if ( $user ) {
1029 $value = $user->getName();
1030 }
1031 break;
1032
1033 default:
1034 // do nothing
1035 break;
1036 }
1037
1038 return [ $name => $value ];
1039 }
1040}
1041
1043class_alias( LogFormatter::class, 'LogFormatter' );
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
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:69
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:43
Base class for language-specific code.
Definition Language.php:68
Class that generates HTML for internal links.
Some internal bits split of from Skin.php.
Definition Linker.php:47
static newFromRow( $row)
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.
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:23
Interface for objects representing user identity.
getId( $wikiId=self::LOCAL)