57 $logActionsHandlers = MediaWikiServices::getInstance()->getMainConfig()
58 ->get( MainConfigNames::LogActionsHandlers );
60 $wildcard = $entry->
getType() .
'/*';
61 $handler = $logActionsHandlers[$fulltype] ?? $logActionsHandlers[$wildcard] ??
'';
63 if ( $handler !==
'' && is_string( $handler ) && class_exists( $handler ) ) {
64 return new $handler( $entry );
78 return self::newFromEntry( DatabaseLogEntry::newFromRow( $row ) );
110 private $linkRenderer;
124 $this->entry = $entry;
125 $this->context = RequestContext::getMain();
133 $this->context = $context;
141 $this->linkRenderer = $linkRenderer;
149 if ( $this->linkRenderer !==
null ) {
150 return $this->linkRenderer;
152 return MediaWikiServices::getInstance()->getLinkRenderer();
163 $this->audience = (
$audience == self::FOR_THIS_USER )
164 ? self::FOR_THIS_USER
175 $logRestrictions = $this->context->getConfig()->get( MainConfigNames::LogRestrictions );
176 $type = $this->entry->getType();
177 return !isset( $logRestrictions[
$type] )
178 || $this->context->getAuthority()->isAllowed( $logRestrictions[
$type] );
187 if ( $this->audience == self::FOR_THIS_USER ) {
188 return LogEventsList::userCanBitfield(
189 $this->entry->getDeleted(), $field, $this->context->getAuthority() ) &&
190 self::canViewLogType();
192 return !$this->entry->isDeleted( $field ) && self::canViewLogType();
203 $this->linkFlood = $value;
215 $this->plaintext =
true;
217 $this->plaintext =
false;
230 $comment = $this->entry->getComment();
232 if ( $comment !=
'' ) {
233 if ( $actionComment ==
'' ) {
234 $actionComment = $comment;
236 $actionComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $comment;
240 return $actionComment;
251 $this->plaintext =
true;
252 $this->irctext =
true;
260 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
265 $movesource = $parameters[
'4::target'];
267 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
270 $movesource = $parameters[
'4::target'];
272 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
274 case 'move-noredirect':
276 case 'move_redir-noredirect':
285 ->rawParams( $target )->inContentLanguage()->escaped();
289 ->rawParams( $target )->inContentLanguage()->escaped();
298 $diffLink = htmlspecialchars(
299 wfMessage(
'patrol-log-diff', $parameters[
'4::curid'] )
300 ->inContentLanguage()->text() );
301 $text =
wfMessage(
'patrol-log-line', $diffLink,
"[[$target]]",
"" )
302 ->inContentLanguage()->text();
312 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
313 ->inContentLanguage()
317 $text =
wfMessage(
'unprotectedarticle' )
318 ->rawParams( $target )->inContentLanguage()->escaped();
321 $text =
wfMessage(
'modifiedarticleprotection' )
322 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
323 ->inContentLanguage()
327 $text =
wfMessage(
'movedarticleprotection' )
328 ->rawParams( $target, $parameters[
'4::oldtitle'] )->inContentLanguage()->escaped();
337 $text =
wfMessage(
'newuserlog-create-entry' )
338 ->inContentLanguage()->escaped();
342 $text =
wfMessage(
'newuserlog-create2-entry' )
343 ->rawParams( $target )->inContentLanguage()->escaped();
346 $text =
wfMessage(
'newuserlog-autocreate-entry' )
347 ->inContentLanguage()->escaped();
356 ->rawParams( $target )->inContentLanguage()->escaped();
361 ->rawParams( $target )->inContentLanguage()->escaped();
367 if ( count( $parameters[
'4::oldgroups'] ) ) {
368 $oldgroups = implode(
', ', $parameters[
'4::oldgroups'] );
370 $oldgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
372 if ( count( $parameters[
'5::newgroups'] ) ) {
373 $newgroups = implode(
', ', $parameters[
'5::newgroups'] );
375 $newgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
380 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
383 $text =
wfMessage(
'rightslogentry-autopromote' )
384 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
390 $text =
wfMessage(
'pagemerge-logentry' )
391 ->rawParams( $target, $parameters[
'4::dest'], $parameters[
'5::mergepoint'] )
392 ->inContentLanguage()->escaped();
401 $rawDuration = $parameters[0];
402 $rawFlags = $parameters[1] ??
'';
404 $rawDuration = $parameters[
'5::duration'];
405 $rawFlags = $parameters[
'6::flags'];
407 $duration = $contLang->translateBlockExpiry(
412 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
414 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
418 ->rawParams( $target )->inContentLanguage()->escaped();
421 $duration = $contLang->translateBlockExpiry(
422 $parameters[
'5::duration'],
426 $flags = BlockLogFormatter::formatBlockFlags( $parameters[
'6::flags'],
429 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
437 $text =
wfMessage(
'import-logentry-upload' )
438 ->rawParams( $target )->inContentLanguage()->escaped();
441 $text =
wfMessage(
'import-logentry-interwiki' )
442 ->rawParams( $target )->inContentLanguage()->escaped();
449 if ( $text ===
null ) {
453 $this->plaintext =
false;
454 $this->irctext =
false;
469 if ( $element instanceof
Message ) {
470 $element = $this->plaintext ? $element->text() : $element->escaped();
476 $sep = $this->
msg(
'word-separator' );
477 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
507 $type = $this->entry->getType();
508 $subtype = $this->entry->getSubtype();
510 return "logentry-$type-$subtype";
535 $params[$index + 3] = $value;
541 if ( strpos( $key,
':' ) ===
false ) {
544 list( $index,
$type, ) = explode(
':', $key, 3 );
545 if ( ctype_digit( $index ) ) {
554 if ( count( $params ) ) {
555 $max = max( array_keys( $params ) );
557 for ( $i = 3; $i < $max; $i++ ) {
558 if ( !isset( $params[$i] ) ) {
578 if ( isset( $this->parsedParameters ) ) {
579 return $this->parsedParameters;
591 $this->parsedParameters = $params;
592 return $this->parsedParameters;
622 $saveLinkFlood = $this->linkFlood;
624 switch ( strtolower( trim(
$type ) ) ) {
629 $value = $this->context->getLanguage()->commaList( $value );
632 $value = $this->
msg( $value )->text();
635 $value = $this->
msg( $value )->inContentLanguage()->text();
642 $value = $user->getName();
650 $value = $this->
msg(
'empty-username' )->text();
657 $title = Title::newFromText( $value );
658 $value =
$title->getPrefixedText();
661 $title = Title::newFromText( $value );
685 $msg = $this->
msg(
'invalidtitle' )->text();
686 if ( $this->plaintext ) {
689 return Html::element(
'span', [
'class' =>
'mw-invalidtitle' ], $msg );
693 if ( $this->plaintext ) {
694 $link =
'[[' .
$title->getPrefixedText() .
']]';
696 $html = $html !==
null ?
new HtmlArmor( $html ) : $html;
711 $performerIdentity = $this->entry->getPerformerIdentity();
732 $element = ltrim( $comment );
750 if ( $this->plaintext ) {
751 return $this->
msg( $message )->text();
755 $attribs = [
'class' =>
'history-deleted' ];
757 return Html::rawElement(
'span', $attribs,
$content );
766 if ( $this->plaintext ) {
769 $attribs = [
'class' =>
'history-deleted' ];
771 return Html::rawElement(
'span', $attribs,
$content );
780 protected function msg( $key, ...$params ) {
781 return $this->context->msg( $key, ...$params );
791 if ( $this->plaintext ) {
798 if ( $this->linkFlood ) {
800 ? MediaWikiServices::getInstance()->getUserEditTracker()->getUserEditCount( $user )
843 return $this->entry->getParameters();
864 $vals = explode(
':', $key, 3 );
865 if ( count( $vals ) !== 3 ) {
866 if ( $value instanceof __PHP_Incomplete_Class ) {
867 wfLogWarning(
'Log entry of type ' . $this->entry->getFullType() .
868 ' contains unrecoverable extra parameters.' );
871 $logParams[$key] = $value;
876 ApiResult::setIndexedTagName( $logParams,
'param' );
877 ApiResult::setArrayType( $logParams,
'assoc' );
895 $value = (bool)$value;
899 if ( is_int( $value ) || ctype_digit( (
string)$value ) ) {
900 $value = (int)$value;
902 $value = (float)$value;
909 if ( is_array( $value ) ) {
910 ApiResult::setArrayType( $value,
$type );
920 $msg = $this->
msg( $value );
921 if (
$type ===
'msg-content' ) {
922 $msg->inContentLanguage();
925 $value[
"{$name}_key"] = $msg->getKey();
926 if ( $msg->getParams() ) {
927 $value[
"{$name}_params"] = $msg->getParams();
929 $value[
"{$name}_text"] = $msg->text();
934 $title = Title::newFromText( $value );
939 ApiQueryBase::addTitleInfo( $value,
$title,
"{$name}_" );
946 $value = $user->getName();
955 return [ $name => $value ];
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.
Marks HTML that shouldn't be escaped.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
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...
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Extends the LogEntry Interface with some basic functionality.
isLegacy()
Whether the parameters for this log are stored in new or old format.
A class containing constants representing the names of configuration variables.
The Message class deals with fetching and processing of interface message into a variety of formats.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
static newFromName( $name, $validate='valid')
Interface for objects which can provide a MediaWiki context on request.
Interface for log entries.
getParameters()
Get the extra parameters stored for this message.
getTimestamp()
Get the timestamp when the action was executed.
getTarget()
Get the target page of this action.
getSubtype()
The log subtype.
getFullType()
The full logtype in format maintype/subtype.
getType()
The main log type.