MediaWiki  master
LogFormatter.php
Go to the documentation of this file.
1 <?php
27 
38 class LogFormatter {
39  // Audience options for viewing usernames, comments, and actions
40  public const FOR_PUBLIC = 1;
41  public const FOR_THIS_USER = 2;
42 
43  // Static->
44 
50  public static function newFromEntry( LogEntry $entry ) {
51  global $wgLogActionsHandlers;
52  $fulltype = $entry->getFullType();
53  $wildcard = $entry->getType() . '/*';
54  $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
55 
56  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
57  return new $handler( $entry );
58  }
59 
60  return new LegacyLogFormatter( $entry );
61  }
62 
70  public static function newFromRow( $row ) {
72  }
73 
74  // Nonstatic->
75 
77  protected $entry;
78 
81 
83  public $context;
84 
86  protected $linkFlood = false;
87 
95  protected $plaintext = false;
96 
98  protected $irctext = false;
99 
103  private $linkRenderer;
104 
109  protected $parsedParameters;
110 
111  protected function __construct( LogEntry $entry ) {
112  $this->entry = $entry;
113  $this->context = RequestContext::getMain();
114  }
115 
120  public function setContext( IContextSource $context ) {
121  $this->context = $context;
122  }
123 
129  $this->linkRenderer = $linkRenderer;
130  }
131 
136  public function getLinkRenderer() {
137  if ( $this->linkRenderer !== null ) {
138  return $this->linkRenderer;
139  } else {
140  return MediaWikiServices::getInstance()->getLinkRenderer();
141  }
142  }
143 
150  public function setAudience( $audience ) {
151  $this->audience = ( $audience == self::FOR_THIS_USER )
152  ? self::FOR_THIS_USER
153  : self::FOR_PUBLIC;
154  }
155 
160  public function canViewLogType() {
161  // If the user doesn't have the right permission to view the specific
162  // log type, return false
163  $logRestrictions = $this->context->getConfig()->get( 'LogRestrictions' );
164  $type = $this->entry->getType();
165  return !isset( $logRestrictions[$type] )
166  || MediaWikiServices::getInstance()
167  ->getPermissionManager()
168  ->userHasRight( $this->context->getUser(), $logRestrictions[$type] );
169  }
170 
176  protected function canView( $field ) {
177  if ( $this->audience == self::FOR_THIS_USER ) {
179  $this->entry->getDeleted(), $field, $this->context->getUser() ) &&
180  self::canViewLogType();
181  } else {
182  return !$this->entry->isDeleted( $field ) && self::canViewLogType();
183  }
184  }
185 
192  public function setShowUserToolLinks( $value ) {
193  $this->linkFlood = $value;
194  }
195 
204  public function getPlainActionText() {
205  $this->plaintext = true;
206  $text = $this->getActionText();
207  $this->plaintext = false;
208 
209  return $text;
210  }
211 
218  public function getIRCActionComment() {
219  $actionComment = $this->getIRCActionText();
220  $comment = $this->entry->getComment();
221 
222  if ( $comment != '' ) {
223  if ( $actionComment == '' ) {
224  $actionComment = $comment;
225  } else {
226  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
227  }
228  }
229 
230  return $actionComment;
231  }
232 
239  public function getIRCActionText() {
240  $this->plaintext = true;
241  $this->irctext = true;
242 
244  $parameters = $entry->getParameters();
245  // @see LogPage::actionText()
246  // Text of title the action is aimed at.
247  $target = $entry->getTarget()->getPrefixedText();
248  $text = null;
249  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
250  switch ( $entry->getType() ) {
251  case 'move':
252  switch ( $entry->getSubtype() ) {
253  case 'move':
254  $movesource = $parameters['4::target'];
255  $text = wfMessage( '1movedto2' )
256  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
257  break;
258  case 'move_redir':
259  $movesource = $parameters['4::target'];
260  $text = wfMessage( '1movedto2_redir' )
261  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
262  break;
263  case 'move-noredirect':
264  break;
265  case 'move_redir-noredirect':
266  break;
267  }
268  break;
269 
270  case 'delete':
271  switch ( $entry->getSubtype() ) {
272  case 'delete':
273  $text = wfMessage( 'deletedarticle' )
274  ->rawParams( $target )->inContentLanguage()->escaped();
275  break;
276  case 'restore':
277  $text = wfMessage( 'undeletedarticle' )
278  ->rawParams( $target )->inContentLanguage()->escaped();
279  break;
280  //case 'revision': // Revision deletion
281  //case 'event': // Log deletion
282  // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
283  //default:
284  }
285  break;
286 
287  case 'patrol':
288  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
289  // Create a diff link to the patrolled revision
290  if ( $entry->getSubtype() === 'patrol' ) {
291  $diffLink = htmlspecialchars(
292  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
293  ->inContentLanguage()->text() );
294  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
295  ->inContentLanguage()->text();
296  } else {
297  // broken??
298  }
299  break;
300 
301  case 'protect':
302  switch ( $entry->getSubtype() ) {
303  case 'protect':
304  $text = wfMessage( 'protectedarticle' )
305  ->rawParams( $target . ' ' . $parameters['4::description'] )
306  ->inContentLanguage()
307  ->escaped();
308  break;
309  case 'unprotect':
310  $text = wfMessage( 'unprotectedarticle' )
311  ->rawParams( $target )->inContentLanguage()->escaped();
312  break;
313  case 'modify':
314  $text = wfMessage( 'modifiedarticleprotection' )
315  ->rawParams( $target . ' ' . $parameters['4::description'] )
316  ->inContentLanguage()
317  ->escaped();
318  break;
319  case 'move_prot':
320  $text = wfMessage( 'movedarticleprotection' )
321  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
322  break;
323  }
324  break;
325 
326  case 'newusers':
327  switch ( $entry->getSubtype() ) {
328  case 'newusers':
329  case 'create':
330  $text = wfMessage( 'newuserlog-create-entry' )
331  ->inContentLanguage()->escaped();
332  break;
333  case 'create2':
334  case 'byemail':
335  $text = wfMessage( 'newuserlog-create2-entry' )
336  ->rawParams( $target )->inContentLanguage()->escaped();
337  break;
338  case 'autocreate':
339  $text = wfMessage( 'newuserlog-autocreate-entry' )
340  ->inContentLanguage()->escaped();
341  break;
342  }
343  break;
344 
345  case 'upload':
346  switch ( $entry->getSubtype() ) {
347  case 'upload':
348  $text = wfMessage( 'uploadedimage' )
349  ->rawParams( $target )->inContentLanguage()->escaped();
350  break;
351  case 'overwrite':
352  case 'revert':
353  $text = wfMessage( 'overwroteimage' )
354  ->rawParams( $target )->inContentLanguage()->escaped();
355  break;
356  }
357  break;
358 
359  case 'rights':
360  if ( count( $parameters['4::oldgroups'] ) ) {
361  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
362  } else {
363  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
364  }
365  if ( count( $parameters['5::newgroups'] ) ) {
366  $newgroups = implode( ', ', $parameters['5::newgroups'] );
367  } else {
368  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
369  }
370  switch ( $entry->getSubtype() ) {
371  case 'rights':
372  $text = wfMessage( 'rightslogentry' )
373  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
374  break;
375  case 'autopromote':
376  $text = wfMessage( 'rightslogentry-autopromote' )
377  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
378  break;
379  }
380  break;
381 
382  case 'merge':
383  $text = wfMessage( 'pagemerge-logentry' )
384  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
385  ->inContentLanguage()->escaped();
386  break;
387 
388  case 'block':
389  switch ( $entry->getSubtype() ) {
390  case 'block':
391  // Keep compatibility with extensions by checking for
392  // new key (5::duration/6::flags) or old key (0/optional 1)
393  if ( $entry->isLegacy() ) {
394  $rawDuration = $parameters[0];
395  $rawFlags = $parameters[1] ?? '';
396  } else {
397  $rawDuration = $parameters['5::duration'];
398  $rawFlags = $parameters['6::flags'];
399  }
400  $duration = $contLang->translateBlockExpiry(
401  $rawDuration,
402  null,
403  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
404  );
405  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
406  $text = wfMessage( 'blocklogentry' )
407  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
408  break;
409  case 'unblock':
410  $text = wfMessage( 'unblocklogentry' )
411  ->rawParams( $target )->inContentLanguage()->escaped();
412  break;
413  case 'reblock':
414  $duration = $contLang->translateBlockExpiry(
415  $parameters['5::duration'],
416  null,
417  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
418  );
419  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
420  $contLang );
421  $text = wfMessage( 'reblock-logentry' )
422  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
423  break;
424  }
425  break;
426 
427  case 'import':
428  switch ( $entry->getSubtype() ) {
429  case 'upload':
430  $text = wfMessage( 'import-logentry-upload' )
431  ->rawParams( $target )->inContentLanguage()->escaped();
432  break;
433  case 'interwiki':
434  $text = wfMessage( 'import-logentry-interwiki' )
435  ->rawParams( $target )->inContentLanguage()->escaped();
436  break;
437  }
438  break;
439  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
440  // default:
441  }
442  if ( $text === null ) {
443  $text = $this->getPlainActionText();
444  }
445 
446  $this->plaintext = false;
447  $this->irctext = false;
448 
449  return $text;
450  }
451 
458  public function getActionText() {
459  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
460  $element = $this->getActionMessage();
461  if ( $element instanceof Message ) {
462  $element = $this->plaintext ? $element->text() : $element->escaped();
463  }
464  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
465  $element = $this->styleRestricedElement( $element );
466  }
467  } else {
468  $sep = $this->msg( 'word-separator' );
469  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
470  $performer = $this->getPerformerElement();
471  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
472  }
473 
474  return $element;
475  }
476 
483  protected function getActionMessage() {
484  $message = $this->msg( $this->getMessageKey() );
485  $message->params( $this->getMessageParameters() );
486 
487  return $message;
488  }
489 
497  protected function getMessageKey() {
498  $type = $this->entry->getType();
499  $subtype = $this->entry->getSubtype();
500 
501  return "logentry-$type-$subtype";
502  }
503 
509  public function getActionLinks() {
510  return '';
511  }
512 
518  protected function extractParameters() {
520  $params = [];
521 
522  if ( $entry->isLegacy() ) {
523  foreach ( $entry->getParameters() as $index => $value ) {
524  $params[$index + 3] = $value;
525  }
526  }
527 
528  // Filter out parameters which are not in format #:foo
529  foreach ( $entry->getParameters() as $key => $value ) {
530  if ( strpos( $key, ':' ) === false ) {
531  continue;
532  }
533  list( $index, $type, ) = explode( ':', $key, 3 );
534  if ( ctype_digit( $index ) ) {
535  $params[$index - 1] = $this->formatParameterValue( $type, $value );
536  }
537  }
538 
539  /* Message class doesn't like non consecutive numbering.
540  * Fill in missing indexes with empty strings to avoid
541  * incorrect renumbering.
542  */
543  if ( count( $params ) ) {
544  $max = max( array_keys( $params ) );
545  // index 0 to 2 are added in getMessageParameters
546  for ( $i = 3; $i < $max; $i++ ) {
547  if ( !isset( $params[$i] ) ) {
548  $params[$i] = '';
549  }
550  }
551  }
552 
553  return $params;
554  }
555 
565  protected function getMessageParameters() {
566  if ( isset( $this->parsedParameters ) ) {
568  }
569 
571  $params = $this->extractParameters();
572  $params[0] = Message::rawParam( $this->getPerformerElement() );
573  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
574  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
575 
576  // Bad things happens if the numbers are not in correct order
577  ksort( $params );
578 
579  $this->parsedParameters = $params;
581  }
582 
609  protected function formatParameterValue( $type, $value ) {
610  $saveLinkFlood = $this->linkFlood;
611 
612  switch ( strtolower( trim( $type ) ) ) {
613  case 'raw':
614  $value = Message::rawParam( $value );
615  break;
616  case 'list':
617  $value = $this->context->getLanguage()->commaList( $value );
618  break;
619  case 'msg':
620  $value = $this->msg( $value )->text();
621  break;
622  case 'msg-content':
623  $value = $this->msg( $value )->inContentLanguage()->text();
624  break;
625  case 'number':
626  $value = Message::numParam( $value );
627  break;
628  case 'user':
629  $user = User::newFromName( $value );
630  $value = $user->getName();
631  break;
632  case 'user-link':
633  $this->setShowUserToolLinks( false );
634 
635  $user = User::newFromName( $value );
636 
637  if ( !$user ) {
638  $value = $this->msg( 'empty-username' )->text();
639  } else {
640  $value = Message::rawParam( $this->makeUserLink( $user ) );
641  $this->setShowUserToolLinks( $saveLinkFlood );
642  }
643  break;
644  case 'title':
645  $title = Title::newFromText( $value );
646  $value = $title->getPrefixedText();
647  break;
648  case 'title-link':
649  $title = Title::newFromText( $value );
650  $value = Message::rawParam( $this->makePageLink( $title ) );
651  break;
652  case 'plain':
653  // Plain text, nothing to do
654  default:
655  // Catch other types and use the old behavior (return as-is)
656  }
657 
658  return $value;
659  }
660 
669  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
670  if ( !$title instanceof Title ) {
671  $msg = $this->msg( 'invalidtitle' )->text();
672  if ( $this->plaintext ) {
673  return $msg;
674  } else {
675  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
676  }
677  }
678 
679  if ( $this->plaintext ) {
680  $link = '[[' . $title->getPrefixedText() . ']]';
681  } else {
682  $html = $html !== null ? new HtmlArmor( $html ) : $html;
683  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
684  }
685 
686  return $link;
687  }
688 
695  public function getPerformerElement() {
696  if ( $this->canView( LogPage::DELETED_USER ) ) {
697  $performer = $this->entry->getPerformer();
698  $element = $this->makeUserLink( $performer );
699  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
700  $element = $this->styleRestricedElement( $element );
701  }
702  } else {
703  $element = $this->getRestrictedElement( 'rev-deleted-user' );
704  }
705 
706  return $element;
707  }
708 
713  public function getComment() {
714  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
715  $comment = Linker::commentBlock( $this->entry->getComment() );
716  // No hard coded spaces thanx
717  $element = ltrim( $comment );
718  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
719  $element = $this->styleRestricedElement( $element );
720  }
721  } else {
722  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
723  }
724 
725  return $element;
726  }
727 
734  protected function getRestrictedElement( $message ) {
735  if ( $this->plaintext ) {
736  return $this->msg( $message )->text();
737  }
738 
739  $content = $this->msg( $message )->escaped();
740  $attribs = [ 'class' => 'history-deleted' ];
741 
742  return Html::rawElement( 'span', $attribs, $content );
743  }
744 
750  protected function styleRestricedElement( $content ) {
751  if ( $this->plaintext ) {
752  return $content;
753  }
754  $attribs = [ 'class' => 'history-deleted' ];
755 
756  return Html::rawElement( 'span', $attribs, $content );
757  }
758 
765  protected function msg( $key, ...$params ) {
766  return $this->context->msg( $key, ...$params );
767  }
768 
775  protected function makeUserLink( User $user, $toolFlags = 0 ) {
776  if ( $this->plaintext ) {
777  $element = $user->getName();
778  } else {
779  $element = Linker::userLink(
780  $user->getId(),
781  $user->getName()
782  );
783 
784  if ( $this->linkFlood ) {
785  $element .= Linker::userToolLinks(
786  $user->getId(),
787  $user->getName(),
788  true, // redContribsWhenNoEdits
789  $toolFlags,
790  $user->getEditCount(),
791  // do not render parenthesises in the HTML markup (CSS will provide)
792  false
793  );
794  }
795  }
796 
797  return $element;
798  }
799 
803  public function getPreloadTitles() {
804  return [];
805  }
806 
810  public function getMessageParametersForTesting() {
811  // This function was added because getMessageParameters() is
812  // protected and a change from protected to public caused
813  // problems with extensions
814  return $this->getMessageParameters();
815  }
816 
822  protected function getParametersForApi() {
823  return $this->entry->getParameters();
824  }
825 
840  public function formatParametersForApi() {
841  $logParams = [];
842  foreach ( $this->getParametersForApi() as $key => $value ) {
843  $vals = explode( ':', $key, 3 );
844  if ( count( $vals ) !== 3 ) {
845  if ( $value instanceof __PHP_Incomplete_Class ) {
846  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
847  ' contains unrecoverable extra parameters.' );
848  continue;
849  }
850  $logParams[$key] = $value;
851  continue;
852  }
853  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
854  }
855  ApiResult::setIndexedTagName( $logParams, 'param' );
856  ApiResult::setArrayType( $logParams, 'assoc' );
857 
858  return $logParams;
859  }
860 
870  protected function formatParameterValueForApi( $name, $type, $value ) {
871  $type = strtolower( trim( $type ) );
872  switch ( $type ) {
873  case 'bool':
874  $value = (bool)$value;
875  break;
876 
877  case 'number':
878  if ( ctype_digit( $value ) || is_int( $value ) ) {
879  $value = (int)$value;
880  } else {
881  $value = (float)$value;
882  }
883  break;
884 
885  case 'array':
886  case 'assoc':
887  case 'kvp':
888  if ( is_array( $value ) ) {
889  ApiResult::setArrayType( $value, $type );
890  }
891  break;
892 
893  case 'timestamp':
894  $value = wfTimestamp( TS_ISO_8601, $value );
895  break;
896 
897  case 'msg':
898  case 'msg-content':
899  $msg = $this->msg( $value );
900  if ( $type === 'msg-content' ) {
901  $msg->inContentLanguage();
902  }
903  $value = [];
904  $value["{$name}_key"] = $msg->getKey();
905  if ( $msg->getParams() ) {
906  $value["{$name}_params"] = $msg->getParams();
907  }
908  $value["{$name}_text"] = $msg->text();
909  return $value;
910 
911  case 'title':
912  case 'title-link':
913  $title = Title::newFromText( $value );
914  if ( !$title ) {
915  // Huh? Do something halfway sane.
916  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
917  }
918  $value = [];
919  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
920  return $value;
921 
922  case 'user':
923  case 'user-link':
924  $user = User::newFromName( $value );
925  if ( $user ) {
926  $value = $user->getName();
927  }
928  break;
929 
930  default:
931  // do nothing
932  break;
933  }
934 
935  return [ $name => $value ];
936  }
937 }
LogFormatter\FOR_THIS_USER
const FOR_THIS_USER
Definition: LogFormatter.php:41
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:332
LogFormatter\setAudience
setAudience( $audience)
Set the visibility restrictions for displaying content.
Definition: LogFormatter.php:150
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:509
User\getId
getId()
Get the user's ID.
Definition: User.php:2158
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:204
LogEntry\getTimestamp
getTimestamp()
Get the timestamp when the action was executed.
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:899
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:137
User\getEditCount
getEditCount()
Get the user's edit count.
Definition: User.php:3381
LogFormatter\makeUserLink
makeUserLink(User $user, $toolFlags=0)
Definition: LogFormatter.php:775
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
LogFormatter\FOR_PUBLIC
const FOR_PUBLIC
Definition: LogFormatter.php:40
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:77
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1809
LogEntryBase\isLegacy
isLegacy()
Whether the parameters for this log are stored in new or old format.
Definition: LogEntryBase.php:47
Linker\userToolLinks
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:944
LogEntry\getTarget
getTarget()
Get the target page of this action.
LogFormatter\getIRCActionComment
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:218
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:822
LogFormatter\$audience
int $audience
Constant for handling log_deleted.
Definition: LogFormatter.php:80
LogFormatter\canView
canView( $field)
Check if a log item can be displayed.
Definition: LogFormatter.php:176
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:535
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1201
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:83
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1067
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:565
LogFormatter\$plaintext
string $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
Definition: LogFormatter.php:95
Message
LogFormatter\setContext
setContext(IContextSource $context)
Replace the default context.
Definition: LogFormatter.php:120
LogEntry\getType
getType()
The main log type.
LogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:713
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:695
LogFormatter\__construct
__construct(LogEntry $entry)
Definition: LogFormatter.php:111
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:716
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: DatabaseLogEntry.php:78
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:35
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:70
LogEntry
Interface for log entries.
Definition: LogEntry.php:31
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:36
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:810
$title
$title
Definition: testCompression.php:38
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:239
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:34
LogFormatter\styleRestricedElement
styleRestricedElement( $content)
Helper method for styling restricted element.
Definition: LogFormatter.php:750
LogEntryBase
Extends the LogEntry Interface with some basic functionality.
Definition: LogEntryBase.php:31
LogFormatter\formatParameterValue
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
Definition: LogFormatter.php:609
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:870
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:604
$content
$content
Definition: router.php:78
LogFormatter\formatParametersForApi
formatParametersForApi()
Format parameters for API output.
Definition: LogFormatter.php:840
Linker\commentBlock
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:1561
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:192
LogFormatter\setLinkRenderer
setLinkRenderer(LinkRenderer $linkRenderer)
Definition: LogFormatter.php:128
LogFormatter\$parsedParameters
array $parsedParameters
Definition: LogFormatter.php:109
LogFormatter\canViewLogType
canViewLogType()
Check if a log item type can be displayed.
Definition: LogFormatter.php:160
LogEntryBase\getFullType
getFullType()
The full logtype in format maintype/subtype.
Definition: LogEntryBase.php:33
LogFormatter\getActionText
getActionText()
Gets the log action, including username.
Definition: LogFormatter.php:458
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:451
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:8071
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:483
LogEntry\getSubtype
getSubtype()
The log subtype.
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
BlockLogFormatter\formatBlockFlags
static formatBlockFlags( $flags, Language $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form.
Definition: BlockLogFormatter.php:183
LogFormatter\getPreloadTitles
getPreloadTitles()
Definition: LogFormatter.php:803
Title
Represents a title within MediaWiki.
Definition: Title.php:42
LogFormatter\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogFormatter.php:103
LogFormatter\$linkFlood
bool $linkFlood
Whether to output user tool links.
Definition: LogFormatter.php:86
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:555
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:765
LogFormatter\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:734
LogFormatter\$irctext
string $irctext
Definition: LogFormatter.php:98
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LegacyLogFormatter.php:35
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:497
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
LogEntry\getPerformer
getPerformer()
Get the user who performed this action.
User\getName
getName()
Get the user name, or the IP of an anonymous user.
Definition: User.php:2187
LogFormatter\$context
IContextSource $context
Context for logging.
Definition: LogFormatter.php:83
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:518
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:462
LogFormatter\makePageLink
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
Definition: LogFormatter.php:669
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
$type
$type
Definition: testCompression.php:52