MediaWiki  master
LogFormatter.php
Go to the documentation of this file.
1 <?php
31 
44 class LogFormatter {
45  // Audience options for viewing usernames, comments, and actions
46  public const FOR_PUBLIC = 1;
47  public const FOR_THIS_USER = 2;
48 
49  // Static->
50 
56  public static function newFromEntry( LogEntry $entry ) {
57  $logActionsHandlers = MediaWikiServices::getInstance()->getMainConfig()
58  ->get( MainConfigNames::LogActionsHandlers );
59  $fulltype = $entry->getFullType();
60  $wildcard = $entry->getType() . '/*';
61  $handler = $logActionsHandlers[$fulltype] ?? $logActionsHandlers[$wildcard] ?? '';
62 
63  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
64  return new $handler( $entry );
65  }
66 
67  return new LegacyLogFormatter( $entry );
68  }
69 
77  public static function newFromRow( $row ) {
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 
110  private $linkRenderer;
111 
116  protected $parsedParameters;
117 
123  protected function __construct( LogEntry $entry ) {
124  $this->entry = $entry;
125  $this->context = RequestContext::getMain();
126  }
127 
132  public function setContext( IContextSource $context ) {
133  $this->context = $context;
134  }
135 
141  $this->linkRenderer = $linkRenderer;
142  }
143 
148  public function getLinkRenderer() {
149  if ( $this->linkRenderer !== null ) {
150  return $this->linkRenderer;
151  } else {
152  return MediaWikiServices::getInstance()->getLinkRenderer();
153  }
154  }
155 
162  public function setAudience( $audience ) {
163  $this->audience = ( $audience == self::FOR_THIS_USER )
164  ? self::FOR_THIS_USER
165  : self::FOR_PUBLIC;
166  }
167 
172  public function canViewLogType() {
173  // If the user doesn't have the right permission to view the specific
174  // log type, return false
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] );
179  }
180 
186  protected function canView( $field ) {
187  if ( $this->audience == self::FOR_THIS_USER ) {
189  $this->entry->getDeleted(), $field, $this->context->getUser() ) &&
191  } else {
192  return !$this->entry->isDeleted( $field ) && self::canViewLogType();
193  }
194  }
195 
202  public function setShowUserToolLinks( $value ) {
203  $this->linkFlood = $value;
204  }
205 
214  public function getPlainActionText() {
215  $this->plaintext = true;
216  $text = $this->getActionText();
217  $this->plaintext = false;
218 
219  return $text;
220  }
221 
228  public function getIRCActionComment() {
229  $actionComment = $this->getIRCActionText();
230  $comment = $this->entry->getComment();
231 
232  if ( $comment != '' ) {
233  if ( $actionComment == '' ) {
234  $actionComment = $comment;
235  } else {
236  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
237  }
238  }
239 
240  return $actionComment;
241  }
242 
250  public function getIRCActionText() {
251  $this->plaintext = true;
252  $this->irctext = true;
253 
255  $parameters = $entry->getParameters();
256  // @see LogPage::actionText()
257  // Text of title the action is aimed at.
258  $target = $entry->getTarget()->getPrefixedText();
259  $text = null;
260  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
261  switch ( $entry->getType() ) {
262  case 'move':
263  switch ( $entry->getSubtype() ) {
264  case 'move':
265  $movesource = $parameters['4::target'];
266  $text = wfMessage( '1movedto2' )
267  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
268  break;
269  case 'move_redir':
270  $movesource = $parameters['4::target'];
271  $text = wfMessage( '1movedto2_redir' )
272  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
273  break;
274  case 'move-noredirect':
275  break;
276  case 'move_redir-noredirect':
277  break;
278  }
279  break;
280 
281  case 'delete':
282  switch ( $entry->getSubtype() ) {
283  case 'delete':
284  $text = wfMessage( 'deletedarticle' )
285  ->rawParams( $target )->inContentLanguage()->escaped();
286  break;
287  case 'restore':
288  $text = wfMessage( 'undeletedarticle' )
289  ->rawParams( $target )->inContentLanguage()->escaped();
290  break;
291  }
292  break;
293 
294  case 'patrol':
295  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
296  // Create a diff link to the patrolled revision
297  if ( $entry->getSubtype() === 'patrol' ) {
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();
303  } else {
304  // broken??
305  }
306  break;
307 
308  case 'protect':
309  switch ( $entry->getSubtype() ) {
310  case 'protect':
311  $text = wfMessage( 'protectedarticle' )
312  ->rawParams( $target . ' ' . $parameters['4::description'] )
313  ->inContentLanguage()
314  ->escaped();
315  break;
316  case 'unprotect':
317  $text = wfMessage( 'unprotectedarticle' )
318  ->rawParams( $target )->inContentLanguage()->escaped();
319  break;
320  case 'modify':
321  $text = wfMessage( 'modifiedarticleprotection' )
322  ->rawParams( $target . ' ' . $parameters['4::description'] )
323  ->inContentLanguage()
324  ->escaped();
325  break;
326  case 'move_prot':
327  $text = wfMessage( 'movedarticleprotection' )
328  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
329  break;
330  }
331  break;
332 
333  case 'newusers':
334  switch ( $entry->getSubtype() ) {
335  case 'newusers':
336  case 'create':
337  $text = wfMessage( 'newuserlog-create-entry' )
338  ->inContentLanguage()->escaped();
339  break;
340  case 'create2':
341  case 'byemail':
342  $text = wfMessage( 'newuserlog-create2-entry' )
343  ->rawParams( $target )->inContentLanguage()->escaped();
344  break;
345  case 'autocreate':
346  $text = wfMessage( 'newuserlog-autocreate-entry' )
347  ->inContentLanguage()->escaped();
348  break;
349  }
350  break;
351 
352  case 'upload':
353  switch ( $entry->getSubtype() ) {
354  case 'upload':
355  $text = wfMessage( 'uploadedimage' )
356  ->rawParams( $target )->inContentLanguage()->escaped();
357  break;
358  case 'overwrite':
359  case 'revert':
360  $text = wfMessage( 'overwroteimage' )
361  ->rawParams( $target )->inContentLanguage()->escaped();
362  break;
363  }
364  break;
365 
366  case 'rights':
367  if ( count( $parameters['4::oldgroups'] ) ) {
368  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
369  } else {
370  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
371  }
372  if ( count( $parameters['5::newgroups'] ) ) {
373  $newgroups = implode( ', ', $parameters['5::newgroups'] );
374  } else {
375  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
376  }
377  switch ( $entry->getSubtype() ) {
378  case 'rights':
379  $text = wfMessage( 'rightslogentry' )
380  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
381  break;
382  case 'autopromote':
383  $text = wfMessage( 'rightslogentry-autopromote' )
384  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
385  break;
386  }
387  break;
388 
389  case 'merge':
390  $text = wfMessage( 'pagemerge-logentry' )
391  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
392  ->inContentLanguage()->escaped();
393  break;
394 
395  case 'block':
396  switch ( $entry->getSubtype() ) {
397  case 'block':
398  // Keep compatibility with extensions by checking for
399  // new key (5::duration/6::flags) or old key (0/optional 1)
400  if ( $entry->isLegacy() ) {
401  $rawDuration = $parameters[0];
402  $rawFlags = $parameters[1] ?? '';
403  } else {
404  $rawDuration = $parameters['5::duration'];
405  $rawFlags = $parameters['6::flags'];
406  }
407  $duration = $contLang->translateBlockExpiry(
408  $rawDuration,
409  null,
410  (int)wfTimestamp( TS_UNIX, $entry->getTimestamp() )
411  );
412  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
413  $text = wfMessage( 'blocklogentry' )
414  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
415  break;
416  case 'unblock':
417  $text = wfMessage( 'unblocklogentry' )
418  ->rawParams( $target )->inContentLanguage()->escaped();
419  break;
420  case 'reblock':
421  $duration = $contLang->translateBlockExpiry(
422  $parameters['5::duration'],
423  null,
424  (int)wfTimestamp( TS_UNIX, $entry->getTimestamp() )
425  );
426  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
427  $contLang );
428  $text = wfMessage( 'reblock-logentry' )
429  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
430  break;
431  }
432  break;
433 
434  case 'import':
435  switch ( $entry->getSubtype() ) {
436  case 'upload':
437  $text = wfMessage( 'import-logentry-upload' )
438  ->rawParams( $target )->inContentLanguage()->escaped();
439  break;
440  case 'interwiki':
441  $text = wfMessage( 'import-logentry-interwiki' )
442  ->rawParams( $target )->inContentLanguage()->escaped();
443  break;
444  }
445  break;
446  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
447  // default:
448  }
449  if ( $text === null ) {
450  $text = $this->getPlainActionText();
451  }
452 
453  $this->plaintext = false;
454  $this->irctext = false;
455 
456  return $text;
457  }
458 
466  public function getActionText() {
467  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
468  $element = $this->getActionMessage();
469  if ( $element instanceof Message ) {
470  $element = $this->plaintext ? $element->text() : $element->escaped();
471  }
472  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
473  $element = $this->styleRestrictedElement( $element );
474  }
475  } else {
476  $sep = $this->msg( 'word-separator' );
477  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
478  $performer = $this->getPerformerElement();
479  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
480  }
481 
482  return $element;
483  }
484 
491  protected function getActionMessage() {
492  $message = $this->msg( $this->getMessageKey() );
493  $message->params( $this->getMessageParameters() );
494 
495  return $message;
496  }
497 
506  protected function getMessageKey() {
507  $type = $this->entry->getType();
508  $subtype = $this->entry->getSubtype();
509 
510  return "logentry-$type-$subtype";
511  }
512 
519  public function getActionLinks() {
520  return '';
521  }
522 
529  protected function extractParameters() {
531  $params = [];
532 
533  if ( $entry->isLegacy() ) {
534  foreach ( $entry->getParameters() as $index => $value ) {
535  $params[$index + 3] = $value;
536  }
537  }
538 
539  // Filter out parameters which are not in format #:foo
540  foreach ( $entry->getParameters() as $key => $value ) {
541  if ( strpos( $key, ':' ) === false ) {
542  continue;
543  }
544  list( $index, $type, ) = explode( ':', $key, 3 );
545  if ( ctype_digit( $index ) ) {
546  $params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
547  }
548  }
549 
550  /* Message class doesn't like non consecutive numbering.
551  * Fill in missing indexes with empty strings to avoid
552  * incorrect renumbering.
553  */
554  if ( count( $params ) ) {
555  $max = max( array_keys( $params ) );
556  // index 0 to 2 are added in getMessageParameters
557  for ( $i = 3; $i < $max; $i++ ) {
558  if ( !isset( $params[$i] ) ) {
559  $params[$i] = '';
560  }
561  }
562  }
563 
564  return $params;
565  }
566 
577  protected function getMessageParameters() {
578  if ( isset( $this->parsedParameters ) ) {
580  }
581 
583  $params = $this->extractParameters();
584  $params[0] = Message::rawParam( $this->getPerformerElement() );
585  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() : '';
586  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
587 
588  // Bad things happens if the numbers are not in correct order
589  ksort( $params );
590 
591  $this->parsedParameters = $params;
593  }
594 
621  protected function formatParameterValue( $type, $value ) {
622  $saveLinkFlood = $this->linkFlood;
623 
624  switch ( strtolower( trim( $type ) ) ) {
625  case 'raw':
626  $value = Message::rawParam( $value );
627  break;
628  case 'list':
629  $value = $this->context->getLanguage()->commaList( $value );
630  break;
631  case 'msg':
632  $value = $this->msg( $value )->text();
633  break;
634  case 'msg-content':
635  $value = $this->msg( $value )->inContentLanguage()->text();
636  break;
637  case 'number':
638  $value = Message::numParam( $value );
639  break;
640  case 'user':
641  $user = User::newFromName( $value );
642  $value = $user->getName();
643  break;
644  case 'user-link':
645  $this->setShowUserToolLinks( false );
646 
647  $user = User::newFromName( $value );
648 
649  if ( !$user ) {
650  $value = $this->msg( 'empty-username' )->text();
651  } else {
652  $value = Message::rawParam( $this->makeUserLink( $user ) );
653  $this->setShowUserToolLinks( $saveLinkFlood );
654  }
655  break;
656  case 'title':
657  $title = Title::newFromText( $value );
658  $value = $title->getPrefixedText();
659  break;
660  case 'title-link':
661  $title = Title::newFromText( $value );
662  $value = Message::rawParam( $this->makePageLink( $title ) );
663  break;
664  case 'plain':
665  // Plain text, nothing to do
666  default:
667  // Catch other types and use the old behavior (return as-is)
668  }
669 
670  return $value;
671  }
672 
683  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
684  if ( !$title instanceof Title ) {
685  $msg = $this->msg( 'invalidtitle' )->text();
686  if ( $this->plaintext ) {
687  return $msg;
688  } else {
689  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
690  }
691  }
692 
693  if ( $this->plaintext ) {
694  $link = '[[' . $title->getPrefixedText() . ']]';
695  } else {
696  $html = $html !== null ? new HtmlArmor( $html ) : $html;
697  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
698  }
699 
700  return $link;
701  }
702 
709  public function getPerformerElement() {
710  if ( $this->canView( LogPage::DELETED_USER ) ) {
711  $performerIdentity = $this->entry->getPerformerIdentity();
712  $element = $this->makeUserLink( $performerIdentity );
713  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
714  $element = $this->styleRestrictedElement( $element );
715  }
716  } else {
717  $element = $this->getRestrictedElement( 'rev-deleted-user' );
718  }
719 
720  return $element;
721  }
722 
728  public function getComment() {
729  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
730  $comment = Linker::commentBlock( $this->entry->getComment() );
731  // No hard coded spaces thanx
732  $element = ltrim( $comment );
733  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
734  $element = $this->styleRestrictedElement( $element );
735  }
736  } else {
737  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
738  }
739 
740  return $element;
741  }
742 
749  protected function getRestrictedElement( $message ) {
750  if ( $this->plaintext ) {
751  return $this->msg( $message )->text();
752  }
753 
754  $content = $this->msg( $message )->escaped();
755  $attribs = [ 'class' => 'history-deleted' ];
756 
757  return Html::rawElement( 'span', $attribs, $content );
758  }
759 
765  protected function styleRestrictedElement( $content ) {
766  if ( $this->plaintext ) {
767  return $content;
768  }
769  $attribs = [ 'class' => 'history-deleted' ];
770 
771  return Html::rawElement( 'span', $attribs, $content );
772  }
773 
780  protected function styleRestricedElement( $content ) {
781  wfDeprecated( __METHOD__, '1.37' );
782  return $this->styleRestrictedElement( $content );
783  }
784 
791  protected function msg( $key, ...$params ) {
792  return $this->context->msg( $key, ...$params );
793  }
794 
801  protected function makeUserLink( UserIdentity $user, $toolFlags = 0 ) {
802  if ( $this->plaintext ) {
803  $element = $user->getName();
804  } else {
805  $element = Linker::userLink(
806  $user->getId(),
807  $user->getName()
808  );
809  if ( $this->linkFlood ) {
810  $editCount = $user->isRegistered()
811  ? MediaWikiServices::getInstance()->getUserEditTracker()->getUserEditCount( $user )
812  : null;
813 
814  $element .= Linker::userToolLinks(
815  $user->getId(),
816  $user->getName(),
817  true, // redContribsWhenNoEdits
818  $toolFlags,
819  $editCount,
820  // do not render parentheses in the HTML markup (CSS will provide)
821  false
822  );
823  }
824  }
825 
826  return $element;
827  }
828 
833  public function getPreloadTitles() {
834  return [];
835  }
836 
840  public function getMessageParametersForTesting() {
841  // This function was added because getMessageParameters() is
842  // protected and a change from protected to public caused
843  // problems with extensions
844  return $this->getMessageParameters();
845  }
846 
853  protected function getParametersForApi() {
854  return $this->entry->getParameters();
855  }
856 
872  public function formatParametersForApi() {
873  $logParams = [];
874  foreach ( $this->getParametersForApi() as $key => $value ) {
875  $vals = explode( ':', $key, 3 );
876  if ( count( $vals ) !== 3 ) {
877  if ( $value instanceof __PHP_Incomplete_Class ) {
878  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
879  ' contains unrecoverable extra parameters.' );
880  continue;
881  }
882  $logParams[$key] = $value;
883  continue;
884  }
885  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
886  }
887  ApiResult::setIndexedTagName( $logParams, 'param' );
888  ApiResult::setArrayType( $logParams, 'assoc' );
889 
890  return $logParams;
891  }
892 
902  protected function formatParameterValueForApi( $name, $type, $value ) {
903  $type = strtolower( trim( $type ) );
904  switch ( $type ) {
905  case 'bool':
906  $value = (bool)$value;
907  break;
908 
909  case 'number':
910  if ( ctype_digit( $value ) || is_int( $value ) ) {
911  $value = (int)$value;
912  } else {
913  $value = (float)$value;
914  }
915  break;
916 
917  case 'array':
918  case 'assoc':
919  case 'kvp':
920  if ( is_array( $value ) ) {
921  ApiResult::setArrayType( $value, $type );
922  }
923  break;
924 
925  case 'timestamp':
926  $value = wfTimestamp( TS_ISO_8601, $value );
927  break;
928 
929  case 'msg':
930  case 'msg-content':
931  $msg = $this->msg( $value );
932  if ( $type === 'msg-content' ) {
933  $msg->inContentLanguage();
934  }
935  $value = [];
936  $value["{$name}_key"] = $msg->getKey();
937  if ( $msg->getParams() ) {
938  $value["{$name}_params"] = $msg->getParams();
939  }
940  $value["{$name}_text"] = $msg->text();
941  return $value;
942 
943  case 'title':
944  case 'title-link':
945  $title = Title::newFromText( $value );
946  if ( !$title ) {
947  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
948  }
949  $value = [];
950  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
951  return $value;
952 
953  case 'user':
954  case 'user-link':
955  $user = User::newFromName( $value );
956  if ( $user ) {
957  $value = $user->getName();
958  }
959  break;
960 
961  default:
962  // do nothing
963  break;
964  }
965 
966  return [ $name => $value ];
967  }
968 }
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.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:716
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:604
static formatBlockFlags( $flags, Language $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form.
static newFromRow( $row)
Constructs new LogEntry from database result row.
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:236
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:214
This class formats all log entries for log types which have not been converted to the new system.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:1069
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:1538
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:1114
isLegacy()
Whether the parameters for this log are stored in new or old format.
getFullType()
The full logtype in format maintype/subtype.
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
Implements the default log formatting.
styleRestrictedElement( $content)
Helper method for styling restricted element.
LogEntryBase $entry
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
canView( $field)
Check if a log item can be displayed.
const FOR_PUBLIC
bool $linkFlood
Whether to output user tool links.
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
array $parsedParameters
getMessageParametersForTesting()
__construct(LogEntry $entry)
bool $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
getRestrictedElement( $message)
Helper method for displaying restricted element.
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
getActionMessage()
Returns a sentence describing the log action.
const FOR_THIS_USER
getActionText()
Gets the log action, including username.
canViewLogType()
Check if a log item type can be displayed.
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
getPerformerElement()
Provides the name of the user who performed the log action.
setLinkRenderer(LinkRenderer $linkRenderer)
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
IContextSource $context
Context for logging.
int $audience
Constant for handling log_deleted.
formatParametersForApi()
Format parameters for API output.
LinkRenderer null $linkRenderer
getComment()
Gets the user provided comment.
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
getMessageKey()
Returns a key to be used for formatting the action sentence.
makeUserLink(UserIdentity $user, $toolFlags=0)
styleRestricedElement( $content)
Helper method for styling restricted element.
setAudience( $audience)
Set the visibility restrictions for displaying content.
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
setContext(IContextSource $context)
Replace the default context.
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
getPlainActionText()
Ugly hack to produce plaintext version of the message.
extractParameters()
Extracts the optional extra parameters for use in action messages.
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
const DELETED_USER
Definition: LogPage.php:42
const DELETED_COMMENT
Definition: LogPage.php:41
const DELETED_ACTION
Definition: LogPage.php:40
Class that generates HTML anchor link elements for pages.
A class containing constants representing the names of configuration variables.
MediaWikiServices is the service locator for the application scope of MediaWiki.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:141
static rawParam( $raw)
Definition: Message.php:1155
static numParam( $num)
Definition: Message.php:1166
static getMain()
Get the RequestContext object associated with the main request.
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.
Definition: Title.php:49
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:370
static newFromName( $name, $validate='valid')
Definition: User.php:599
Interface for objects which can provide a MediaWiki context on request.
Interface for log entries.
Definition: LogEntry.php:34
getPerformerIdentity()
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.
getType()
The main log type.
Interface for objects representing user identity.
getId( $wikiId=self::LOCAL)
$content
Definition: router.php:76