MediaWiki  master
LogFormatter.php
Go to the documentation of this file.
1 <?php
27 
40 class LogFormatter {
41  // Audience options for viewing usernames, comments, and actions
42  public const FOR_PUBLIC = 1;
43  public const FOR_THIS_USER = 2;
44 
45  // Static->
46 
52  public static function newFromEntry( LogEntry $entry ) {
53  global $wgLogActionsHandlers;
54  $fulltype = $entry->getFullType();
55  $wildcard = $entry->getType() . '/*';
56  $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
57 
58  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
59  return new $handler( $entry );
60  }
61 
62  return new LegacyLogFormatter( $entry );
63  }
64 
72  public static function newFromRow( $row ) {
74  }
75 
76  // Nonstatic->
77 
79  protected $entry;
80 
83 
85  public $context;
86 
88  protected $linkFlood = false;
89 
97  protected $plaintext = false;
98 
100  protected $irctext = false;
101 
105  private $linkRenderer;
106 
111  protected $parsedParameters;
112 
118  protected function __construct( LogEntry $entry ) {
119  $this->entry = $entry;
120  $this->context = RequestContext::getMain();
121  }
122 
127  public function setContext( IContextSource $context ) {
128  $this->context = $context;
129  }
130 
136  $this->linkRenderer = $linkRenderer;
137  }
138 
143  public function getLinkRenderer() {
144  if ( $this->linkRenderer !== null ) {
145  return $this->linkRenderer;
146  } else {
147  return MediaWikiServices::getInstance()->getLinkRenderer();
148  }
149  }
150 
157  public function setAudience( $audience ) {
158  $this->audience = ( $audience == self::FOR_THIS_USER )
159  ? self::FOR_THIS_USER
160  : self::FOR_PUBLIC;
161  }
162 
167  public function canViewLogType() {
168  // If the user doesn't have the right permission to view the specific
169  // log type, return false
170  $logRestrictions = $this->context->getConfig()->get( 'LogRestrictions' );
171  $type = $this->entry->getType();
172  return !isset( $logRestrictions[$type] )
173  || MediaWikiServices::getInstance()
174  ->getPermissionManager()
175  ->userHasRight( $this->context->getUser(), $logRestrictions[$type] );
176  }
177 
183  protected function canView( $field ) {
184  if ( $this->audience == self::FOR_THIS_USER ) {
186  $this->entry->getDeleted(), $field, $this->context->getUser() ) &&
188  } else {
189  return !$this->entry->isDeleted( $field ) && self::canViewLogType();
190  }
191  }
192 
199  public function setShowUserToolLinks( $value ) {
200  $this->linkFlood = $value;
201  }
202 
211  public function getPlainActionText() {
212  $this->plaintext = true;
213  $text = $this->getActionText();
214  $this->plaintext = false;
215 
216  return $text;
217  }
218 
225  public function getIRCActionComment() {
226  $actionComment = $this->getIRCActionText();
227  $comment = $this->entry->getComment();
228 
229  if ( $comment != '' ) {
230  if ( $actionComment == '' ) {
231  $actionComment = $comment;
232  } else {
233  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
234  }
235  }
236 
237  return $actionComment;
238  }
239 
246  public function getIRCActionText() {
247  $this->plaintext = true;
248  $this->irctext = true;
249 
251  $parameters = $entry->getParameters();
252  // @see LogPage::actionText()
253  // Text of title the action is aimed at.
254  $target = $entry->getTarget()->getPrefixedText();
255  $text = null;
256  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
257  switch ( $entry->getType() ) {
258  case 'move':
259  switch ( $entry->getSubtype() ) {
260  case 'move':
261  $movesource = $parameters['4::target'];
262  $text = wfMessage( '1movedto2' )
263  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
264  break;
265  case 'move_redir':
266  $movesource = $parameters['4::target'];
267  $text = wfMessage( '1movedto2_redir' )
268  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
269  break;
270  case 'move-noredirect':
271  break;
272  case 'move_redir-noredirect':
273  break;
274  }
275  break;
276 
277  case 'delete':
278  switch ( $entry->getSubtype() ) {
279  case 'delete':
280  $text = wfMessage( 'deletedarticle' )
281  ->rawParams( $target )->inContentLanguage()->escaped();
282  break;
283  case 'restore':
284  $text = wfMessage( 'undeletedarticle' )
285  ->rawParams( $target )->inContentLanguage()->escaped();
286  break;
287  }
288  break;
289 
290  case 'patrol':
291  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
292  // Create a diff link to the patrolled revision
293  if ( $entry->getSubtype() === 'patrol' ) {
294  $diffLink = htmlspecialchars(
295  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
296  ->inContentLanguage()->text() );
297  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
298  ->inContentLanguage()->text();
299  } else {
300  // broken??
301  }
302  break;
303 
304  case 'protect':
305  switch ( $entry->getSubtype() ) {
306  case 'protect':
307  $text = wfMessage( 'protectedarticle' )
308  ->rawParams( $target . ' ' . $parameters['4::description'] )
309  ->inContentLanguage()
310  ->escaped();
311  break;
312  case 'unprotect':
313  $text = wfMessage( 'unprotectedarticle' )
314  ->rawParams( $target )->inContentLanguage()->escaped();
315  break;
316  case 'modify':
317  $text = wfMessage( 'modifiedarticleprotection' )
318  ->rawParams( $target . ' ' . $parameters['4::description'] )
319  ->inContentLanguage()
320  ->escaped();
321  break;
322  case 'move_prot':
323  $text = wfMessage( 'movedarticleprotection' )
324  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
325  break;
326  }
327  break;
328 
329  case 'newusers':
330  switch ( $entry->getSubtype() ) {
331  case 'newusers':
332  case 'create':
333  $text = wfMessage( 'newuserlog-create-entry' )
334  ->inContentLanguage()->escaped();
335  break;
336  case 'create2':
337  case 'byemail':
338  $text = wfMessage( 'newuserlog-create2-entry' )
339  ->rawParams( $target )->inContentLanguage()->escaped();
340  break;
341  case 'autocreate':
342  $text = wfMessage( 'newuserlog-autocreate-entry' )
343  ->inContentLanguage()->escaped();
344  break;
345  }
346  break;
347 
348  case 'upload':
349  switch ( $entry->getSubtype() ) {
350  case 'upload':
351  $text = wfMessage( 'uploadedimage' )
352  ->rawParams( $target )->inContentLanguage()->escaped();
353  break;
354  case 'overwrite':
355  case 'revert':
356  $text = wfMessage( 'overwroteimage' )
357  ->rawParams( $target )->inContentLanguage()->escaped();
358  break;
359  }
360  break;
361 
362  case 'rights':
363  if ( count( $parameters['4::oldgroups'] ) ) {
364  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
365  } else {
366  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
367  }
368  if ( count( $parameters['5::newgroups'] ) ) {
369  $newgroups = implode( ', ', $parameters['5::newgroups'] );
370  } else {
371  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
372  }
373  switch ( $entry->getSubtype() ) {
374  case 'rights':
375  $text = wfMessage( 'rightslogentry' )
376  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
377  break;
378  case 'autopromote':
379  $text = wfMessage( 'rightslogentry-autopromote' )
380  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
381  break;
382  }
383  break;
384 
385  case 'merge':
386  $text = wfMessage( 'pagemerge-logentry' )
387  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
388  ->inContentLanguage()->escaped();
389  break;
390 
391  case 'block':
392  switch ( $entry->getSubtype() ) {
393  case 'block':
394  // Keep compatibility with extensions by checking for
395  // new key (5::duration/6::flags) or old key (0/optional 1)
396  if ( $entry->isLegacy() ) {
397  $rawDuration = $parameters[0];
398  $rawFlags = $parameters[1] ?? '';
399  } else {
400  $rawDuration = $parameters['5::duration'];
401  $rawFlags = $parameters['6::flags'];
402  }
403  $duration = $contLang->translateBlockExpiry(
404  $rawDuration,
405  null,
406  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
407  );
408  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
409  $text = wfMessage( 'blocklogentry' )
410  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
411  break;
412  case 'unblock':
413  $text = wfMessage( 'unblocklogentry' )
414  ->rawParams( $target )->inContentLanguage()->escaped();
415  break;
416  case 'reblock':
417  $duration = $contLang->translateBlockExpiry(
418  $parameters['5::duration'],
419  null,
420  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
421  );
422  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
423  $contLang );
424  $text = wfMessage( 'reblock-logentry' )
425  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
426  break;
427  }
428  break;
429 
430  case 'import':
431  switch ( $entry->getSubtype() ) {
432  case 'upload':
433  $text = wfMessage( 'import-logentry-upload' )
434  ->rawParams( $target )->inContentLanguage()->escaped();
435  break;
436  case 'interwiki':
437  $text = wfMessage( 'import-logentry-interwiki' )
438  ->rawParams( $target )->inContentLanguage()->escaped();
439  break;
440  }
441  break;
442  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
443  // default:
444  }
445  if ( $text === null ) {
446  $text = $this->getPlainActionText();
447  }
448 
449  $this->plaintext = false;
450  $this->irctext = false;
451 
452  return $text;
453  }
454 
462  public function getActionText() {
463  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
464  $element = $this->getActionMessage();
465  if ( $element instanceof Message ) {
466  $element = $this->plaintext ? $element->text() : $element->escaped();
467  }
468  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
469  $element = $this->styleRestricedElement( $element );
470  }
471  } else {
472  $sep = $this->msg( 'word-separator' );
473  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
474  $performer = $this->getPerformerElement();
475  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
476  }
477 
478  return $element;
479  }
480 
487  protected function getActionMessage() {
488  $message = $this->msg( $this->getMessageKey() );
489  $message->params( $this->getMessageParameters() );
490 
491  return $message;
492  }
493 
502  protected function getMessageKey() {
503  $type = $this->entry->getType();
504  $subtype = $this->entry->getSubtype();
505 
506  return "logentry-$type-$subtype";
507  }
508 
515  public function getActionLinks() {
516  return '';
517  }
518 
525  protected function extractParameters() {
527  $params = [];
528 
529  if ( $entry->isLegacy() ) {
530  foreach ( $entry->getParameters() as $index => $value ) {
531  $params[$index + 3] = $value;
532  }
533  }
534 
535  // Filter out parameters which are not in format #:foo
536  foreach ( $entry->getParameters() as $key => $value ) {
537  if ( strpos( $key, ':' ) === false ) {
538  continue;
539  }
540  list( $index, $type, ) = explode( ':', $key, 3 );
541  if ( ctype_digit( $index ) ) {
542  $params[$index - 1] = $this->formatParameterValue( $type, $value );
543  }
544  }
545 
546  /* Message class doesn't like non consecutive numbering.
547  * Fill in missing indexes with empty strings to avoid
548  * incorrect renumbering.
549  */
550  if ( count( $params ) ) {
551  $max = max( array_keys( $params ) );
552  // index 0 to 2 are added in getMessageParameters
553  for ( $i = 3; $i < $max; $i++ ) {
554  if ( !isset( $params[$i] ) ) {
555  $params[$i] = '';
556  }
557  }
558  }
559 
560  return $params;
561  }
562 
573  protected function getMessageParameters() {
574  if ( isset( $this->parsedParameters ) ) {
576  }
577 
579  $params = $this->extractParameters();
580  $params[0] = Message::rawParam( $this->getPerformerElement() );
581  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
582  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
583 
584  // Bad things happens if the numbers are not in correct order
585  ksort( $params );
586 
587  $this->parsedParameters = $params;
589  }
590 
617  protected function formatParameterValue( $type, $value ) {
618  $saveLinkFlood = $this->linkFlood;
619 
620  switch ( strtolower( trim( $type ) ) ) {
621  case 'raw':
622  $value = Message::rawParam( $value );
623  break;
624  case 'list':
625  $value = $this->context->getLanguage()->commaList( $value );
626  break;
627  case 'msg':
628  $value = $this->msg( $value )->text();
629  break;
630  case 'msg-content':
631  $value = $this->msg( $value )->inContentLanguage()->text();
632  break;
633  case 'number':
634  $value = Message::numParam( $value );
635  break;
636  case 'user':
637  $user = User::newFromName( $value );
638  $value = $user->getName();
639  break;
640  case 'user-link':
641  $this->setShowUserToolLinks( false );
642 
643  $user = User::newFromName( $value );
644 
645  if ( !$user ) {
646  $value = $this->msg( 'empty-username' )->text();
647  } else {
648  $value = Message::rawParam( $this->makeUserLink( $user ) );
649  $this->setShowUserToolLinks( $saveLinkFlood );
650  }
651  break;
652  case 'title':
653  $title = Title::newFromText( $value );
654  $value = $title->getPrefixedText();
655  break;
656  case 'title-link':
657  $title = Title::newFromText( $value );
658  $value = Message::rawParam( $this->makePageLink( $title ) );
659  break;
660  case 'plain':
661  // Plain text, nothing to do
662  default:
663  // Catch other types and use the old behavior (return as-is)
664  }
665 
666  return $value;
667  }
668 
678  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
679  if ( !$title instanceof Title ) {
680  $msg = $this->msg( 'invalidtitle' )->text();
681  if ( $this->plaintext ) {
682  return $msg;
683  } else {
684  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
685  }
686  }
687 
688  if ( $this->plaintext ) {
689  $link = '[[' . $title->getPrefixedText() . ']]';
690  } else {
691  $html = $html !== null ? new HtmlArmor( $html ) : $html;
692  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
693  }
694 
695  return $link;
696  }
697 
704  public function getPerformerElement() {
705  if ( $this->canView( LogPage::DELETED_USER ) ) {
706  $performer = $this->entry->getPerformer();
707  $element = $this->makeUserLink( $performer );
708  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
709  $element = $this->styleRestricedElement( $element );
710  }
711  } else {
712  $element = $this->getRestrictedElement( 'rev-deleted-user' );
713  }
714 
715  return $element;
716  }
717 
723  public function getComment() {
724  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
725  $comment = Linker::commentBlock( $this->entry->getComment() );
726  // No hard coded spaces thanx
727  $element = ltrim( $comment );
728  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
729  $element = $this->styleRestricedElement( $element );
730  }
731  } else {
732  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
733  }
734 
735  return $element;
736  }
737 
744  protected function getRestrictedElement( $message ) {
745  if ( $this->plaintext ) {
746  return $this->msg( $message )->text();
747  }
748 
749  $content = $this->msg( $message )->escaped();
750  $attribs = [ 'class' => 'history-deleted' ];
751 
752  return Html::rawElement( 'span', $attribs, $content );
753  }
754 
760  protected function styleRestricedElement( $content ) {
761  if ( $this->plaintext ) {
762  return $content;
763  }
764  $attribs = [ 'class' => 'history-deleted' ];
765 
766  return Html::rawElement( 'span', $attribs, $content );
767  }
768 
775  protected function msg( $key, ...$params ) {
776  return $this->context->msg( $key, ...$params );
777  }
778 
785  protected function makeUserLink( User $user, $toolFlags = 0 ) {
786  if ( $this->plaintext ) {
787  $element = $user->getName();
788  } else {
789  $element = Linker::userLink(
790  $user->getId(),
791  $user->getName()
792  );
793 
794  if ( $this->linkFlood ) {
795  $element .= Linker::userToolLinks(
796  $user->getId(),
797  $user->getName(),
798  true, // redContribsWhenNoEdits
799  $toolFlags,
800  $user->getEditCount(),
801  // do not render parenthesises in the HTML markup (CSS will provide)
802  false
803  );
804  }
805  }
806 
807  return $element;
808  }
809 
814  public function getPreloadTitles() {
815  return [];
816  }
817 
821  public function getMessageParametersForTesting() {
822  // This function was added because getMessageParameters() is
823  // protected and a change from protected to public caused
824  // problems with extensions
825  return $this->getMessageParameters();
826  }
827 
834  protected function getParametersForApi() {
835  return $this->entry->getParameters();
836  }
837 
853  public function formatParametersForApi() {
854  $logParams = [];
855  foreach ( $this->getParametersForApi() as $key => $value ) {
856  $vals = explode( ':', $key, 3 );
857  if ( count( $vals ) !== 3 ) {
858  if ( $value instanceof __PHP_Incomplete_Class ) {
859  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
860  ' contains unrecoverable extra parameters.' );
861  continue;
862  }
863  $logParams[$key] = $value;
864  continue;
865  }
866  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
867  }
868  ApiResult::setIndexedTagName( $logParams, 'param' );
869  ApiResult::setArrayType( $logParams, 'assoc' );
870 
871  return $logParams;
872  }
873 
883  protected function formatParameterValueForApi( $name, $type, $value ) {
884  $type = strtolower( trim( $type ) );
885  switch ( $type ) {
886  case 'bool':
887  $value = (bool)$value;
888  break;
889 
890  case 'number':
891  if ( ctype_digit( $value ) || is_int( $value ) ) {
892  $value = (int)$value;
893  } else {
894  $value = (float)$value;
895  }
896  break;
897 
898  case 'array':
899  case 'assoc':
900  case 'kvp':
901  if ( is_array( $value ) ) {
902  ApiResult::setArrayType( $value, $type );
903  }
904  break;
905 
906  case 'timestamp':
907  $value = wfTimestamp( TS_ISO_8601, $value );
908  break;
909 
910  case 'msg':
911  case 'msg-content':
912  $msg = $this->msg( $value );
913  if ( $type === 'msg-content' ) {
914  $msg->inContentLanguage();
915  }
916  $value = [];
917  $value["{$name}_key"] = $msg->getKey();
918  if ( $msg->getParams() ) {
919  $value["{$name}_params"] = $msg->getParams();
920  }
921  $value["{$name}_text"] = $msg->text();
922  return $value;
923 
924  case 'title':
925  case 'title-link':
926  $title = Title::newFromText( $value );
927  if ( !$title ) {
928  // Huh? Do something halfway sane.
929  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
930  }
931  $value = [];
932  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
933  return $value;
934 
935  case 'user':
936  case 'user-link':
937  $user = User::newFromName( $value );
938  if ( $user ) {
939  $value = $user->getName();
940  }
941  break;
942 
943  default:
944  // do nothing
945  break;
946  }
947 
948  return [ $name => $value ];
949  }
950 }
Message\numParam
static numParam( $num)
Definition: Message.php:1035
LogFormatter\FOR_THIS_USER
const FOR_THIS_USER
Definition: LogFormatter.php:43
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:328
LogFormatter\setAudience
setAudience( $audience)
Set the visibility restrictions for displaying content.
Definition: LogFormatter.php:157
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:515
User\getId
getId()
Get the user's ID.
Definition: User.php:2033
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:211
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:896
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
User\getEditCount
getEditCount()
Get the user's edit count.
Definition: User.php:2925
LogFormatter\makeUserLink
makeUserLink(User $user, $toolFlags=0)
Definition: LogFormatter.php:785
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
LogFormatter\FOR_PUBLIC
const FOR_PUBLIC
Definition: LogFormatter.php:42
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:79
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1815
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:941
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:225
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:834
LogFormatter\$audience
int $audience
Constant for handling log_deleted.
Definition: LogFormatter.php:82
LogFormatter\canView
canView( $field)
Check if a log item can be displayed.
Definition: LogFormatter.php:183
User\newFromName
static newFromName( $name, $validate='valid')
Definition: User.php:542
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
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:92
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1087
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:573
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:97
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:540
LogFormatter\setContext
setContext(IContextSource $context)
Replace the default context.
Definition: LogFormatter.php:127
LogEntry\getType
getType()
The main log type.
LogFormatter\getComment
getComment()
Gets the user provided comment Stable to override.
Definition: LogFormatter.php:723
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:704
LogFormatter\__construct
__construct(LogEntry $entry)
Stable to call.
Definition: LogFormatter.php:118
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:80
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:39
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:72
LogEntry
Interface for log entries.
Definition: LogEntry.php:32
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:40
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:821
$title
$title
Definition: testCompression.php:38
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:246
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:38
LogFormatter\styleRestricedElement
styleRestricedElement( $content)
Helper method for styling restricted element.
Definition: LogFormatter.php:760
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:617
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:883
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:76
LogFormatter\formatParametersForApi
formatParametersForApi()
Format parameters for API output.
Definition: LogFormatter.php:853
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:1574
Message\rawParam
static rawParam( $raw)
Definition: Message.php:1024
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:199
LogFormatter\setLinkRenderer
setLinkRenderer(LinkRenderer $linkRenderer)
Definition: LogFormatter.php:135
LogFormatter\$parsedParameters
array $parsedParameters
Definition: LogFormatter.php:111
LogFormatter\canViewLogType
canViewLogType()
Check if a log item type can be displayed.
Definition: LogFormatter.php:167
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:462
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:454
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:8241
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:487
LogEntry\getSubtype
getSubtype()
The log subtype.
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:40
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
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()
Stable to override.
Definition: LogFormatter.php:814
Title
Represents a title within MediaWiki.
Definition: Title.php:41
LogFormatter\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogFormatter.php:105
LogFormatter\$linkFlood
bool $linkFlood
Whether to output user tool links.
Definition: LogFormatter.php:88
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:775
LogFormatter\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:744
LogFormatter\$irctext
string $irctext
Definition: LogFormatter.php:100
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LegacyLogFormatter.php:35
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:143
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:502
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
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:2062
LogFormatter\$context
IContextSource $context
Context for logging.
Definition: LogFormatter.php:85
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:525
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:470
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:678
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:52
$type
$type
Definition: testCompression.php:52