MediaWiki  1.33.0
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  const FOR_PUBLIC = 1;
41  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 
161  protected function canView( $field ) {
162  if ( $this->audience == self::FOR_THIS_USER ) {
164  $this->entry->getDeleted(), $field, $this->context->getUser() );
165  } else {
166  return !$this->entry->isDeleted( $field );
167  }
168  }
169 
176  public function setShowUserToolLinks( $value ) {
177  $this->linkFlood = $value;
178  }
179 
188  public function getPlainActionText() {
189  $this->plaintext = true;
190  $text = $this->getActionText();
191  $this->plaintext = false;
192 
193  return $text;
194  }
195 
202  public function getIRCActionComment() {
203  $actionComment = $this->getIRCActionText();
204  $comment = $this->entry->getComment();
205 
206  if ( $comment != '' ) {
207  if ( $actionComment == '' ) {
208  $actionComment = $comment;
209  } else {
210  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
211  }
212  }
213 
214  return $actionComment;
215  }
216 
223  public function getIRCActionText() {
224  $this->plaintext = true;
225  $this->irctext = true;
226 
228  $parameters = $entry->getParameters();
229  // @see LogPage::actionText()
230  // Text of title the action is aimed at.
231  $target = $entry->getTarget()->getPrefixedText();
232  $text = null;
233  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
234  switch ( $entry->getType() ) {
235  case 'move':
236  switch ( $entry->getSubtype() ) {
237  case 'move':
238  $movesource = $parameters['4::target'];
239  $text = wfMessage( '1movedto2' )
240  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
241  break;
242  case 'move_redir':
243  $movesource = $parameters['4::target'];
244  $text = wfMessage( '1movedto2_redir' )
245  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
246  break;
247  case 'move-noredirect':
248  break;
249  case 'move_redir-noredirect':
250  break;
251  }
252  break;
253 
254  case 'delete':
255  switch ( $entry->getSubtype() ) {
256  case 'delete':
257  $text = wfMessage( 'deletedarticle' )
258  ->rawParams( $target )->inContentLanguage()->escaped();
259  break;
260  case 'restore':
261  $text = wfMessage( 'undeletedarticle' )
262  ->rawParams( $target )->inContentLanguage()->escaped();
263  break;
264  //case 'revision': // Revision deletion
265  //case 'event': // Log deletion
266  // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
267  //default:
268  }
269  break;
270 
271  case 'patrol':
272  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
273  // Create a diff link to the patrolled revision
274  if ( $entry->getSubtype() === 'patrol' ) {
275  $diffLink = htmlspecialchars(
276  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
277  ->inContentLanguage()->text() );
278  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
279  ->inContentLanguage()->text();
280  } else {
281  // broken??
282  }
283  break;
284 
285  case 'protect':
286  switch ( $entry->getSubtype() ) {
287  case 'protect':
288  $text = wfMessage( 'protectedarticle' )
289  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
290  break;
291  case 'unprotect':
292  $text = wfMessage( 'unprotectedarticle' )
293  ->rawParams( $target )->inContentLanguage()->escaped();
294  break;
295  case 'modify':
296  $text = wfMessage( 'modifiedarticleprotection' )
297  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
298  break;
299  case 'move_prot':
300  $text = wfMessage( 'movedarticleprotection' )
301  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
302  break;
303  }
304  break;
305 
306  case 'newusers':
307  switch ( $entry->getSubtype() ) {
308  case 'newusers':
309  case 'create':
310  $text = wfMessage( 'newuserlog-create-entry' )
311  ->inContentLanguage()->escaped();
312  break;
313  case 'create2':
314  case 'byemail':
315  $text = wfMessage( 'newuserlog-create2-entry' )
316  ->rawParams( $target )->inContentLanguage()->escaped();
317  break;
318  case 'autocreate':
319  $text = wfMessage( 'newuserlog-autocreate-entry' )
320  ->inContentLanguage()->escaped();
321  break;
322  }
323  break;
324 
325  case 'upload':
326  switch ( $entry->getSubtype() ) {
327  case 'upload':
328  $text = wfMessage( 'uploadedimage' )
329  ->rawParams( $target )->inContentLanguage()->escaped();
330  break;
331  case 'overwrite':
332  case 'revert':
333  $text = wfMessage( 'overwroteimage' )
334  ->rawParams( $target )->inContentLanguage()->escaped();
335  break;
336  }
337  break;
338 
339  case 'rights':
340  if ( count( $parameters['4::oldgroups'] ) ) {
341  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
342  } else {
343  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
344  }
345  if ( count( $parameters['5::newgroups'] ) ) {
346  $newgroups = implode( ', ', $parameters['5::newgroups'] );
347  } else {
348  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
349  }
350  switch ( $entry->getSubtype() ) {
351  case 'rights':
352  $text = wfMessage( 'rightslogentry' )
353  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
354  break;
355  case 'autopromote':
356  $text = wfMessage( 'rightslogentry-autopromote' )
357  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
358  break;
359  }
360  break;
361 
362  case 'merge':
363  $text = wfMessage( 'pagemerge-logentry' )
364  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
365  ->inContentLanguage()->escaped();
366  break;
367 
368  case 'block':
369  switch ( $entry->getSubtype() ) {
370  case 'block':
371  // Keep compatibility with extensions by checking for
372  // new key (5::duration/6::flags) or old key (0/optional 1)
373  if ( $entry->isLegacy() ) {
374  $rawDuration = $parameters[0];
375  $rawFlags = $parameters[1] ?? '';
376  } else {
377  $rawDuration = $parameters['5::duration'];
378  $rawFlags = $parameters['6::flags'];
379  }
380  $duration = $contLang->translateBlockExpiry(
381  $rawDuration,
382  null,
383  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
384  );
385  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
386  $text = wfMessage( 'blocklogentry' )
387  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
388  break;
389  case 'unblock':
390  $text = wfMessage( 'unblocklogentry' )
391  ->rawParams( $target )->inContentLanguage()->escaped();
392  break;
393  case 'reblock':
394  $duration = $contLang->translateBlockExpiry(
395  $parameters['5::duration'],
396  null,
397  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
398  );
399  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
400  $contLang );
401  $text = wfMessage( 'reblock-logentry' )
402  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
403  break;
404  }
405  break;
406 
407  case 'import':
408  switch ( $entry->getSubtype() ) {
409  case 'upload':
410  $text = wfMessage( 'import-logentry-upload' )
411  ->rawParams( $target )->inContentLanguage()->escaped();
412  break;
413  case 'interwiki':
414  $text = wfMessage( 'import-logentry-interwiki' )
415  ->rawParams( $target )->inContentLanguage()->escaped();
416  break;
417  }
418  break;
419  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
420  // default:
421  }
422  if ( is_null( $text ) ) {
423  $text = $this->getPlainActionText();
424  }
425 
426  $this->plaintext = false;
427  $this->irctext = false;
428 
429  return $text;
430  }
431 
438  public function getActionText() {
439  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
440  $element = $this->getActionMessage();
441  if ( $element instanceof Message ) {
442  $element = $this->plaintext ? $element->text() : $element->escaped();
443  }
444  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
445  $element = $this->styleRestricedElement( $element );
446  }
447  } else {
448  $sep = $this->msg( 'word-separator' );
449  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
450  $performer = $this->getPerformerElement();
451  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
452  }
453 
454  return $element;
455  }
456 
463  protected function getActionMessage() {
464  $message = $this->msg( $this->getMessageKey() );
465  $message->params( $this->getMessageParameters() );
466 
467  return $message;
468  }
469 
477  protected function getMessageKey() {
478  $type = $this->entry->getType();
479  $subtype = $this->entry->getSubtype();
480 
481  return "logentry-$type-$subtype";
482  }
483 
489  public function getActionLinks() {
490  return '';
491  }
492 
498  protected function extractParameters() {
500  $params = [];
501 
502  if ( $entry->isLegacy() ) {
503  foreach ( $entry->getParameters() as $index => $value ) {
504  $params[$index + 3] = $value;
505  }
506  }
507 
508  // Filter out parameters which are not in format #:foo
509  foreach ( $entry->getParameters() as $key => $value ) {
510  if ( strpos( $key, ':' ) === false ) {
511  continue;
512  }
513  list( $index, $type, ) = explode( ':', $key, 3 );
514  if ( ctype_digit( $index ) ) {
515  $params[$index - 1] = $this->formatParameterValue( $type, $value );
516  }
517  }
518 
519  /* Message class doesn't like non consecutive numbering.
520  * Fill in missing indexes with empty strings to avoid
521  * incorrect renumbering.
522  */
523  if ( count( $params ) ) {
524  $max = max( array_keys( $params ) );
525  // index 0 to 2 are added in getMessageParameters
526  for ( $i = 3; $i < $max; $i++ ) {
527  if ( !isset( $params[$i] ) ) {
528  $params[$i] = '';
529  }
530  }
531  }
532 
533  return $params;
534  }
535 
545  protected function getMessageParameters() {
546  if ( isset( $this->parsedParameters ) ) {
548  }
549 
551  $params = $this->extractParameters();
552  $params[0] = Message::rawParam( $this->getPerformerElement() );
553  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
554  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
555 
556  // Bad things happens if the numbers are not in correct order
557  ksort( $params );
558 
559  $this->parsedParameters = $params;
561  }
562 
589  protected function formatParameterValue( $type, $value ) {
590  $saveLinkFlood = $this->linkFlood;
591 
592  switch ( strtolower( trim( $type ) ) ) {
593  case 'raw':
594  $value = Message::rawParam( $value );
595  break;
596  case 'list':
597  $value = $this->context->getLanguage()->commaList( $value );
598  break;
599  case 'msg':
600  $value = $this->msg( $value )->text();
601  break;
602  case 'msg-content':
603  $value = $this->msg( $value )->inContentLanguage()->text();
604  break;
605  case 'number':
606  $value = Message::numParam( $value );
607  break;
608  case 'user':
610  $value = $user->getName();
611  break;
612  case 'user-link':
613  $this->setShowUserToolLinks( false );
614 
616  $value = Message::rawParam( $this->makeUserLink( $user ) );
617 
618  $this->setShowUserToolLinks( $saveLinkFlood );
619  break;
620  case 'title':
622  $value = $title->getPrefixedText();
623  break;
624  case 'title-link':
626  $value = Message::rawParam( $this->makePageLink( $title ) );
627  break;
628  case 'plain':
629  // Plain text, nothing to do
630  default:
631  // Catch other types and use the old behavior (return as-is)
632  }
633 
634  return $value;
635  }
636 
645  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
646  if ( !$title instanceof Title ) {
647  $msg = $this->msg( 'invalidtitle' )->text();
648  if ( $this->plaintext ) {
649  return $msg;
650  } else {
651  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
652  }
653  }
654 
655  if ( $this->plaintext ) {
656  $link = '[[' . $title->getPrefixedText() . ']]';
657  } else {
658  $html = $html !== null ? new HtmlArmor( $html ) : $html;
659  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
660  }
661 
662  return $link;
663  }
664 
671  public function getPerformerElement() {
672  if ( $this->canView( LogPage::DELETED_USER ) ) {
673  $performer = $this->entry->getPerformer();
674  $element = $this->makeUserLink( $performer );
675  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
676  $element = $this->styleRestricedElement( $element );
677  }
678  } else {
679  $element = $this->getRestrictedElement( 'rev-deleted-user' );
680  }
681 
682  return $element;
683  }
684 
689  public function getComment() {
690  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
691  $comment = Linker::commentBlock( $this->entry->getComment() );
692  // No hard coded spaces thanx
693  $element = ltrim( $comment );
694  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
695  $element = $this->styleRestricedElement( $element );
696  }
697  } else {
698  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
699  }
700 
701  return $element;
702  }
703 
710  protected function getRestrictedElement( $message ) {
711  if ( $this->plaintext ) {
712  return $this->msg( $message )->text();
713  }
714 
715  $content = $this->msg( $message )->escaped();
716  $attribs = [ 'class' => 'history-deleted' ];
717 
718  return Html::rawElement( 'span', $attribs, $content );
719  }
720 
726  protected function styleRestricedElement( $content ) {
727  if ( $this->plaintext ) {
728  return $content;
729  }
730  $attribs = [ 'class' => 'history-deleted' ];
731 
732  return Html::rawElement( 'span', $attribs, $content );
733  }
734 
740  protected function msg( $key ) {
741  return $this->context->msg( $key );
742  }
743 
750  protected function makeUserLink( User $user, $toolFlags = 0 ) {
751  if ( $this->plaintext ) {
752  $element = $user->getName();
753  } else {
754  $element = Linker::userLink(
755  $user->getId(),
756  $user->getName()
757  );
758 
759  if ( $this->linkFlood ) {
760  $element .= Linker::userToolLinks(
761  $user->getId(),
762  $user->getName(),
763  true, // redContribsWhenNoEdits
764  $toolFlags,
765  $user->getEditCount(),
766  // do not render parenthesises in the HTML markup (CSS will provide)
767  false
768  );
769  }
770  }
771 
772  return $element;
773  }
774 
778  public function getPreloadTitles() {
779  return [];
780  }
781 
785  public function getMessageParametersForTesting() {
786  // This function was added because getMessageParameters() is
787  // protected and a change from protected to public caused
788  // problems with extensions
789  return $this->getMessageParameters();
790  }
791 
797  protected function getParametersForApi() {
798  return $this->entry->getParameters();
799  }
800 
815  public function formatParametersForApi() {
816  $logParams = [];
817  foreach ( $this->getParametersForApi() as $key => $value ) {
818  $vals = explode( ':', $key, 3 );
819  if ( count( $vals ) !== 3 ) {
820  if ( $value instanceof __PHP_Incomplete_Class ) {
821  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
822  ' contains unrecoverable extra parameters.' );
823  continue;
824  }
825  $logParams[$key] = $value;
826  continue;
827  }
828  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
829  }
830  ApiResult::setIndexedTagName( $logParams, 'param' );
831  ApiResult::setArrayType( $logParams, 'assoc' );
832 
833  return $logParams;
834  }
835 
845  protected function formatParameterValueForApi( $name, $type, $value ) {
846  $type = strtolower( trim( $type ) );
847  switch ( $type ) {
848  case 'bool':
849  $value = (bool)$value;
850  break;
851 
852  case 'number':
853  if ( ctype_digit( $value ) || is_int( $value ) ) {
854  $value = (int)$value;
855  } else {
856  $value = (float)$value;
857  }
858  break;
859 
860  case 'array':
861  case 'assoc':
862  case 'kvp':
863  if ( is_array( $value ) ) {
865  }
866  break;
867 
868  case 'timestamp':
869  $value = wfTimestamp( TS_ISO_8601, $value );
870  break;
871 
872  case 'msg':
873  case 'msg-content':
874  $msg = $this->msg( $value );
875  if ( $type === 'msg-content' ) {
876  $msg->inContentLanguage();
877  }
878  $value = [];
879  $value["{$name}_key"] = $msg->getKey();
880  if ( $msg->getParams() ) {
881  $value["{$name}_params"] = $msg->getParams();
882  }
883  $value["{$name}_text"] = $msg->text();
884  return $value;
885 
886  case 'title':
887  case 'title-link':
889  if ( !$title ) {
890  // Huh? Do something halfway sane.
891  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
892  }
893  $value = [];
894  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
895  return $value;
896 
897  case 'user':
898  case 'user-link':
900  if ( $user ) {
901  $value = $user->getName();
902  }
903  break;
904 
905  default:
906  // do nothing
907  break;
908  }
909 
910  return [ $name => $value ];
911  }
912 }
913 
933  private $comment = null;
934 
942  private $revert = null;
943 
944  public function getComment() {
945  if ( $this->comment === null ) {
946  $this->comment = parent::getComment();
947  }
948 
949  // Make sure we execute the LogLine hook so that we immediately return
950  // the correct value.
951  if ( $this->revert === null ) {
952  $this->getActionLinks();
953  }
954 
955  return $this->comment;
956  }
957 
962  protected function getActionMessage() {
964  $action = LogPage::actionText(
965  $entry->getType(),
966  $entry->getSubtype(),
967  $entry->getTarget(),
968  $this->plaintext ? null : $this->context->getSkin(),
970  !$this->plaintext // whether to filter [[]] links
971  );
972 
973  $performer = $this->getPerformerElement();
974  if ( !$this->irctext ) {
975  $sep = $this->msg( 'word-separator' );
976  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
977  $action = $performer . $sep . $action;
978  }
979 
980  return $action;
981  }
982 
983  public function getActionLinks() {
984  if ( $this->revert !== null ) {
985  return $this->revert;
986  }
987 
988  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
989  $this->revert = '';
990  return $this->revert;
991  }
992 
993  $title = $this->entry->getTarget();
994  $type = $this->entry->getType();
995  $subtype = $this->entry->getSubtype();
996 
997  // Do nothing. The implementation is handled by the hook modifiying the
998  // passed-by-ref parameters. This also changes the default value so that
999  // getComment() and getActionLinks() do not call them indefinitely.
1000  $this->revert = '';
1001 
1002  // This is to populate the $comment member of this instance so that it
1003  // can be modified when calling the hook just below.
1004  if ( $this->comment === null ) {
1005  $this->getComment();
1006  }
1007 
1008  $params = $this->entry->getParameters();
1009 
1010  Hooks::run( 'LogLine', [ $type, $subtype, $title, $params,
1011  &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
1012 
1013  return $this->revert;
1014  }
1015 }
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
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:306
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
LegacyLogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:944
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:489
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:188
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:892
LogFormatter\makeUserLink
makeUserLink(User $user, $toolFlags=0)
Definition: LogFormatter.php:750
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
captcha-old.count
count
Definition: captcha-old.py:249
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:1912
LogEntryBase\isLegacy
isLegacy()
Whether the parameters for this log are stored in new or old format.
Definition: LogEntry.php:135
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:931
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:202
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:797
$params
$params
Definition: styleTest.css.php:44
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:161
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:585
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:82
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1105
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:545
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
LogFormatter\setContext
setContext(IContextSource $context)
Replace the default context.
Definition: LogFormatter.php:120
LogPage\actionText
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition: LogPage.php:223
LegacyLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:983
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
LogEntry\getType
getType()
The main log type.
LogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:689
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:671
LogFormatter\__construct
__construct(LogEntry $entry)
Definition: LogFormatter.php:111
LogFormatter\msg
msg( $key)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:740
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1985
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:212
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:35
LegacyLogFormatter\$revert
string null $revert
Cache for the result of getActionLinks() so that it does not need to run multiple times depending on ...
Definition: LogFormatter.php:942
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:42
$handler
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:780
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:36
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:785
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1985
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:223
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:34
LogFormatter\styleRestricedElement
styleRestricedElement( $content)
Helper method for styling restricted element.
Definition: LogFormatter.php:726
LogEntryBase
Extends the LogEntryInterface with some basic functionality.
Definition: LogEntry.php:119
null
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
LogFormatter\formatParameterValue
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
Definition: LogFormatter.php:589
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:845
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
LogFormatter\formatParametersForApi
formatParametersForApi()
Format parameters for API output.
Definition: LogFormatter.php:815
$value
$value
Definition: styleTest.css.php:49
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:1480
LegacyLogFormatter\$comment
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
Definition: LogFormatter.php:933
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:176
LegacyLogFormatter\getActionMessage
getActionMessage()
Definition: LogFormatter.php:962
LogFormatter\setLinkRenderer
setLinkRenderer(LinkRenderer $linkRenderer)
Definition: LogFormatter.php:128
LogFormatter\$parsedParameters
array $parsedParameters
Definition: LogFormatter.php:109
LogEntryBase\getFullType
getFullType()
The full logtype in format maintype/subtype.
Definition: LogEntry.php:121
LogFormatter\getActionText
getActionText()
Gets the log action, including username.
Definition: LogFormatter.php:438
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:430
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:7788
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:463
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
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
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:171
LogFormatter\getPreloadTitles
getPreloadTitles()
Definition: LogFormatter.php:778
Title
Represents a title within MediaWiki.
Definition: Title.php:40
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
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3053
$content
$content
Definition: pageupdater.txt:72
LogFormatter\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:710
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: LogFormatter.php:923
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:477
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:48
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
LogEntry\getPerformer
getPerformer()
Get the user for performed this action.
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:498
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:510
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:645
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
$type
$type
Definition: testCompression.php:48