62 $logActionsHandlers = MediaWikiServices::getInstance()->getMainConfig()
63 ->get( MainConfigNames::LogActionsHandlers );
65 $wildcard = $entry->
getType() .
'/*';
66 $handler = $logActionsHandlers[$fulltype] ?? $logActionsHandlers[$wildcard] ??
'';
68 if ( $handler !==
'' && is_string( $handler ) && class_exists( $handler ) ) {
69 return new $handler( $entry );
83 return self::newFromEntry( DatabaseLogEntry::newFromRow( $row ) );
115 private $linkRenderer;
129 $this->entry = $entry;
130 $this->context = RequestContext::getMain();
138 $this->context = $context;
146 $this->linkRenderer = $linkRenderer;
154 if ( $this->linkRenderer !==
null ) {
155 return $this->linkRenderer;
157 return MediaWikiServices::getInstance()->getLinkRenderer();
168 $this->audience = (
$audience == self::FOR_THIS_USER )
169 ? self::FOR_THIS_USER
180 $logRestrictions = $this->context->getConfig()->get( MainConfigNames::LogRestrictions );
181 $type = $this->entry->getType();
182 return !isset( $logRestrictions[$type] )
183 || $this->context->getAuthority()->isAllowed( $logRestrictions[$type] );
192 if ( $this->audience == self::FOR_THIS_USER ) {
193 return LogEventsList::userCanBitfield(
194 $this->entry->getDeleted(), $field, $this->context->getAuthority() ) &&
195 self::canViewLogType();
197 return !$this->entry->isDeleted( $field ) && self::canViewLogType();
208 $this->linkFlood = $value;
220 $this->plaintext =
true;
222 $this->plaintext =
false;
235 $comment = $this->entry->getComment();
237 if ( $comment !=
'' ) {
238 if ( $actionComment ==
'' ) {
239 $actionComment = $comment;
241 $actionComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $comment;
245 return $actionComment;
256 $this->plaintext =
true;
257 $this->irctext =
true;
265 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
270 $movesource = $parameters[
'4::target'];
272 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
275 $movesource = $parameters[
'4::target'];
277 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
279 case 'move-noredirect':
281 case 'move_redir-noredirect':
290 ->rawParams( $target )->inContentLanguage()->escaped();
294 ->rawParams( $target )->inContentLanguage()->escaped();
303 $diffLink = htmlspecialchars(
304 wfMessage(
'patrol-log-diff', $parameters[
'4::curid'] )
305 ->inContentLanguage()->text() );
306 $text =
wfMessage(
'patrol-log-line', $diffLink,
"[[$target]]",
"" )
307 ->inContentLanguage()->text();
317 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
318 ->inContentLanguage()
322 $text =
wfMessage(
'unprotectedarticle' )
323 ->rawParams( $target )->inContentLanguage()->escaped();
326 $text =
wfMessage(
'modifiedarticleprotection' )
327 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
328 ->inContentLanguage()
332 $text =
wfMessage(
'movedarticleprotection' )
333 ->rawParams( $target, $parameters[
'4::oldtitle'] )->inContentLanguage()->escaped();
342 $text =
wfMessage(
'newuserlog-create-entry' )
343 ->inContentLanguage()->escaped();
347 $text =
wfMessage(
'newuserlog-create2-entry' )
348 ->rawParams( $target )->inContentLanguage()->escaped();
351 $text =
wfMessage(
'newuserlog-autocreate-entry' )
352 ->inContentLanguage()->escaped();
361 ->rawParams( $target )->inContentLanguage()->escaped();
366 ->rawParams( $target )->inContentLanguage()->escaped();
372 if ( count( $parameters[
'4::oldgroups'] ) ) {
373 $oldgroups = implode(
', ', $parameters[
'4::oldgroups'] );
375 $oldgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
377 if ( count( $parameters[
'5::newgroups'] ) ) {
378 $newgroups = implode(
', ', $parameters[
'5::newgroups'] );
380 $newgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
385 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
388 $text =
wfMessage(
'rightslogentry-autopromote' )
389 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
395 $text =
wfMessage(
'pagemerge-logentry' )
396 ->rawParams( $target, $parameters[
'4::dest'], $parameters[
'5::mergepoint'] )
397 ->inContentLanguage()->escaped();
406 $rawDuration = $parameters[0];
407 $rawFlags = $parameters[1] ??
'';
409 $rawDuration = $parameters[
'5::duration'];
410 $rawFlags = $parameters[
'6::flags'];
412 $duration = $contLang->translateBlockExpiry(
417 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
419 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
423 ->rawParams( $target )->inContentLanguage()->escaped();
426 $duration = $contLang->translateBlockExpiry(
427 $parameters[
'5::duration'],
431 $flags = BlockLogFormatter::formatBlockFlags( $parameters[
'6::flags'],
434 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
442 $text =
wfMessage(
'import-logentry-upload' )
443 ->rawParams( $target )->inContentLanguage()->escaped();
446 $text =
wfMessage(
'import-logentry-interwiki' )
447 ->rawParams( $target )->inContentLanguage()->escaped();
455 $this->plaintext =
false;
456 $this->irctext =
false;
469 if ( $this->
canView( LogPage::DELETED_ACTION ) ) {
471 if ( $element instanceof
Message ) {
472 $element = $this->plaintext ? $element->text() : $element->escaped();
474 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
478 $sep = $this->
msg(
'word-separator' );
479 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
509 $type = $this->entry->getType();
510 $subtype = $this->entry->getSubtype();
512 return "logentry-$type-$subtype";
537 $params[$index + 3] = $value;
543 if ( strpos( $key,
':' ) ===
false ) {
546 [ $index, $type, ] = explode(
':', $key, 3 );
547 if ( ctype_digit( $index ) ) {
556 if ( count( $params ) ) {
557 $max = max( array_keys( $params ) );
559 for ( $i = 3; $i < $max; $i++ ) {
560 if ( !isset( $params[$i] ) ) {
587 if ( isset( $this->parsedParameters ) ) {
588 return $this->parsedParameters;
600 $this->parsedParameters = $params;
601 return $this->parsedParameters;
631 $saveLinkFlood = $this->linkFlood;
633 switch ( strtolower( trim( $type ) ) ) {
638 $value = $this->context->getLanguage()->commaList( $value );
641 $value = $this->
msg( $value )->text();
644 $value = $this->
msg( $value )->inContentLanguage()->text();
650 $user = User::newFromName( $value );
651 $value = $user->getName();
656 $user = User::newFromName( $value );
659 $value = $this->
msg(
'empty-username' )->text();
666 $title = Title::newFromText( $value );
667 $value = $title->getPrefixedText();
670 $title = Title::newFromText( $value );
693 if ( !$title instanceof
Title ) {
694 $msg = $this->
msg(
'invalidtitle' )->text();
695 if ( $this->plaintext ) {
698 return Html::element(
'span', [
'class' =>
'mw-invalidtitle' ], $msg );
702 if ( $this->plaintext ) {
703 $link =
'[[' . $title->getPrefixedText() .
']]';
705 $html = $html !==
null ?
new HtmlArmor( $html ) : $html;
706 $link = $this->
getLinkRenderer()->makeLink( $title, $html, [], $parameters );
719 if ( $this->
canView( LogPage::DELETED_USER ) ) {
720 $performerIdentity = $this->entry->getPerformerIdentity();
722 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
738 if ( $this->
canView( LogPage::DELETED_COMMENT ) ) {
739 $comment = MediaWikiServices::getInstance()->getCommentFormatter()
740 ->formatBlock( $this->entry->getComment() );
742 $element = ltrim( $comment );
743 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
760 if ( $this->plaintext ) {
761 return $this->
msg( $message )->text();
773 if ( $this->plaintext ) {
776 $attribs = [
'class' => [
'history-deleted' ] ];
777 if ( $this->entry->isDeleted( LogPage::DELETED_RESTRICTED ) ) {
778 $attribs[
'class'][] =
'mw-history-suppressed';
781 return Html::rawElement(
'span', $attribs,
$content );
790 protected function msg( $key, ...$params ) {
791 return $this->context->msg( $key, ...$params );
801 if ( $this->plaintext ) {
804 $element = Linker::userLink(
808 if ( $this->linkFlood ) {
809 $editCount = $user->
getId()
810 ? MediaWikiServices::getInstance()->getUserEditTracker()->getUserEditCount( $user )
813 $element .= Linker::userToolLinks(
853 return $this->entry->getParameters();
874 $vals = explode(
':', $key, 3 );
875 if ( count( $vals ) !== 3 ) {
876 if ( $value instanceof __PHP_Incomplete_Class ) {
877 wfLogWarning(
'Log entry of type ' . $this->entry->getFullType() .
878 ' contains unrecoverable extra parameters.' );
881 $logParams[$key] = $value;
886 ApiResult::setIndexedTagName( $logParams,
'param' );
887 ApiResult::setArrayType( $logParams,
'assoc' );
902 $type = strtolower( trim( $type ) );
905 $value = (bool)$value;
909 if ( is_int( $value ) || ctype_digit( (
string)$value ) ) {
910 $value = (int)$value;
912 $value = (float)$value;
919 if ( is_array( $value ) ) {
920 ApiResult::setArrayType( $value, $type );
930 $msg = $this->
msg( $value );
931 if ( $type ===
'msg-content' ) {
932 $msg->inContentLanguage();
935 $value[
"{$name}_key"] = $msg->getKey();
936 if ( $msg->getParams() ) {
937 $value[
"{$name}_params"] = $msg->getParams();
939 $value[
"{$name}_text"] = $msg->text();
944 $title = Title::newFromText( $value );
946 $title = SpecialPage::getTitleFor(
'Badtitle', $value );
949 ApiQueryBase::addTitleInfo( $value, $title,
"{$name}_" );
954 $user = User::newFromName( $value );
956 $value = $user->getName();
965 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.
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.
Parent class for all special pages.
The Message class deals with fetching and processing of interface message into a variety of formats.
Interface for objects which can provide a MediaWiki context on request.
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.