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  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 ) {
71  return self::newFromEntry( DatabaseLogEntry::newFromRow( $row ) );
72  }
73 
74  // Nonstatic->
75 
77  protected $entry;
78 
80  protected $audience = self::FOR_PUBLIC;
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  || $this->context->getUser()->isAllowed( $logRestrictions[$type] );
167  }
168 
174  protected function canView( $field ) {
175  if ( $this->audience == self::FOR_THIS_USER ) {
177  $this->entry->getDeleted(), $field, $this->context->getUser() ) &&
178  self::canViewLogType();
179  } else {
180  return !$this->entry->isDeleted( $field ) && self::canViewLogType();
181  }
182  }
183 
190  public function setShowUserToolLinks( $value ) {
191  $this->linkFlood = $value;
192  }
193 
202  public function getPlainActionText() {
203  $this->plaintext = true;
204  $text = $this->getActionText();
205  $this->plaintext = false;
206 
207  return $text;
208  }
209 
216  public function getIRCActionComment() {
217  $actionComment = $this->getIRCActionText();
218  $comment = $this->entry->getComment();
219 
220  if ( $comment != '' ) {
221  if ( $actionComment == '' ) {
222  $actionComment = $comment;
223  } else {
224  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
225  }
226  }
227 
228  return $actionComment;
229  }
230 
237  public function getIRCActionText() {
238  $this->plaintext = true;
239  $this->irctext = true;
240 
242  $parameters = $entry->getParameters();
243  // @see LogPage::actionText()
244  // Text of title the action is aimed at.
245  $target = $entry->getTarget()->getPrefixedText();
246  $text = null;
247  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
248  switch ( $entry->getType() ) {
249  case 'move':
250  switch ( $entry->getSubtype() ) {
251  case 'move':
252  $movesource = $parameters['4::target'];
253  $text = wfMessage( '1movedto2' )
254  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
255  break;
256  case 'move_redir':
257  $movesource = $parameters['4::target'];
258  $text = wfMessage( '1movedto2_redir' )
259  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
260  break;
261  case 'move-noredirect':
262  break;
263  case 'move_redir-noredirect':
264  break;
265  }
266  break;
267 
268  case 'delete':
269  switch ( $entry->getSubtype() ) {
270  case 'delete':
271  $text = wfMessage( 'deletedarticle' )
272  ->rawParams( $target )->inContentLanguage()->escaped();
273  break;
274  case 'restore':
275  $text = wfMessage( 'undeletedarticle' )
276  ->rawParams( $target )->inContentLanguage()->escaped();
277  break;
278  //case 'revision': // Revision deletion
279  //case 'event': // Log deletion
280  // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
281  //default:
282  }
283  break;
284 
285  case 'patrol':
286  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
287  // Create a diff link to the patrolled revision
288  if ( $entry->getSubtype() === 'patrol' ) {
289  $diffLink = htmlspecialchars(
290  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
291  ->inContentLanguage()->text() );
292  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
293  ->inContentLanguage()->text();
294  } else {
295  // broken??
296  }
297  break;
298 
299  case 'protect':
300  switch ( $entry->getSubtype() ) {
301  case 'protect':
302  $text = wfMessage( 'protectedarticle' )
303  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
304  break;
305  case 'unprotect':
306  $text = wfMessage( 'unprotectedarticle' )
307  ->rawParams( $target )->inContentLanguage()->escaped();
308  break;
309  case 'modify':
310  $text = wfMessage( 'modifiedarticleprotection' )
311  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
312  break;
313  case 'move_prot':
314  $text = wfMessage( 'movedarticleprotection' )
315  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
316  break;
317  }
318  break;
319 
320  case 'newusers':
321  switch ( $entry->getSubtype() ) {
322  case 'newusers':
323  case 'create':
324  $text = wfMessage( 'newuserlog-create-entry' )
325  ->inContentLanguage()->escaped();
326  break;
327  case 'create2':
328  case 'byemail':
329  $text = wfMessage( 'newuserlog-create2-entry' )
330  ->rawParams( $target )->inContentLanguage()->escaped();
331  break;
332  case 'autocreate':
333  $text = wfMessage( 'newuserlog-autocreate-entry' )
334  ->inContentLanguage()->escaped();
335  break;
336  }
337  break;
338 
339  case 'upload':
340  switch ( $entry->getSubtype() ) {
341  case 'upload':
342  $text = wfMessage( 'uploadedimage' )
343  ->rawParams( $target )->inContentLanguage()->escaped();
344  break;
345  case 'overwrite':
346  case 'revert':
347  $text = wfMessage( 'overwroteimage' )
348  ->rawParams( $target )->inContentLanguage()->escaped();
349  break;
350  }
351  break;
352 
353  case 'rights':
354  if ( count( $parameters['4::oldgroups'] ) ) {
355  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
356  } else {
357  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
358  }
359  if ( count( $parameters['5::newgroups'] ) ) {
360  $newgroups = implode( ', ', $parameters['5::newgroups'] );
361  } else {
362  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
363  }
364  switch ( $entry->getSubtype() ) {
365  case 'rights':
366  $text = wfMessage( 'rightslogentry' )
367  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
368  break;
369  case 'autopromote':
370  $text = wfMessage( 'rightslogentry-autopromote' )
371  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
372  break;
373  }
374  break;
375 
376  case 'merge':
377  $text = wfMessage( 'pagemerge-logentry' )
378  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
379  ->inContentLanguage()->escaped();
380  break;
381 
382  case 'block':
383  switch ( $entry->getSubtype() ) {
384  case 'block':
385  // Keep compatibility with extensions by checking for
386  // new key (5::duration/6::flags) or old key (0/optional 1)
387  if ( $entry->isLegacy() ) {
388  $rawDuration = $parameters[0];
389  $rawFlags = $parameters[1] ?? '';
390  } else {
391  $rawDuration = $parameters['5::duration'];
392  $rawFlags = $parameters['6::flags'];
393  }
394  $duration = $contLang->translateBlockExpiry(
395  $rawDuration,
396  null,
397  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
398  );
399  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
400  $text = wfMessage( 'blocklogentry' )
401  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
402  break;
403  case 'unblock':
404  $text = wfMessage( 'unblocklogentry' )
405  ->rawParams( $target )->inContentLanguage()->escaped();
406  break;
407  case 'reblock':
408  $duration = $contLang->translateBlockExpiry(
409  $parameters['5::duration'],
410  null,
411  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
412  );
413  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
414  $contLang );
415  $text = wfMessage( 'reblock-logentry' )
416  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
417  break;
418  }
419  break;
420 
421  case 'import':
422  switch ( $entry->getSubtype() ) {
423  case 'upload':
424  $text = wfMessage( 'import-logentry-upload' )
425  ->rawParams( $target )->inContentLanguage()->escaped();
426  break;
427  case 'interwiki':
428  $text = wfMessage( 'import-logentry-interwiki' )
429  ->rawParams( $target )->inContentLanguage()->escaped();
430  break;
431  }
432  break;
433  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
434  // default:
435  }
436  if ( is_null( $text ) ) {
437  $text = $this->getPlainActionText();
438  }
439 
440  $this->plaintext = false;
441  $this->irctext = false;
442 
443  return $text;
444  }
445 
452  public function getActionText() {
453  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
454  $element = $this->getActionMessage();
455  if ( $element instanceof Message ) {
456  $element = $this->plaintext ? $element->text() : $element->escaped();
457  }
458  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
459  $element = $this->styleRestricedElement( $element );
460  }
461  } else {
462  $sep = $this->msg( 'word-separator' );
463  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
464  $performer = $this->getPerformerElement();
465  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
466  }
467 
468  return $element;
469  }
470 
477  protected function getActionMessage() {
478  $message = $this->msg( $this->getMessageKey() );
479  $message->params( $this->getMessageParameters() );
480 
481  return $message;
482  }
483 
491  protected function getMessageKey() {
492  $type = $this->entry->getType();
493  $subtype = $this->entry->getSubtype();
494 
495  return "logentry-$type-$subtype";
496  }
497 
503  public function getActionLinks() {
504  return '';
505  }
506 
512  protected function extractParameters() {
514  $params = [];
515 
516  if ( $entry->isLegacy() ) {
517  foreach ( $entry->getParameters() as $index => $value ) {
518  $params[$index + 3] = $value;
519  }
520  }
521 
522  // Filter out parameters which are not in format #:foo
523  foreach ( $entry->getParameters() as $key => $value ) {
524  if ( strpos( $key, ':' ) === false ) {
525  continue;
526  }
527  list( $index, $type, ) = explode( ':', $key, 3 );
528  if ( ctype_digit( $index ) ) {
529  $params[$index - 1] = $this->formatParameterValue( $type, $value );
530  }
531  }
532 
533  /* Message class doesn't like non consecutive numbering.
534  * Fill in missing indexes with empty strings to avoid
535  * incorrect renumbering.
536  */
537  if ( count( $params ) ) {
538  $max = max( array_keys( $params ) );
539  // index 0 to 2 are added in getMessageParameters
540  for ( $i = 3; $i < $max; $i++ ) {
541  if ( !isset( $params[$i] ) ) {
542  $params[$i] = '';
543  }
544  }
545  }
546 
547  return $params;
548  }
549 
559  protected function getMessageParameters() {
560  if ( isset( $this->parsedParameters ) ) {
562  }
563 
565  $params = $this->extractParameters();
567  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
569 
570  // Bad things happens if the numbers are not in correct order
571  ksort( $params );
572 
573  $this->parsedParameters = $params;
575  }
576 
603  protected function formatParameterValue( $type, $value ) {
604  $saveLinkFlood = $this->linkFlood;
605 
606  switch ( strtolower( trim( $type ) ) ) {
607  case 'raw':
609  break;
610  case 'list':
611  $value = $this->context->getLanguage()->commaList( $value );
612  break;
613  case 'msg':
614  $value = $this->msg( $value )->text();
615  break;
616  case 'msg-content':
617  $value = $this->msg( $value )->inContentLanguage()->text();
618  break;
619  case 'number':
621  break;
622  case 'user':
624  $value = $user->getName();
625  break;
626  case 'user-link':
627  $this->setShowUserToolLinks( false );
628 
630 
631  if ( !$user ) {
632  $value = $this->msg( 'empty-username' )->text();
633  } else {
635  $this->setShowUserToolLinks( $saveLinkFlood );
636  }
637  break;
638  case 'title':
640  $value = $title->getPrefixedText();
641  break;
642  case 'title-link':
645  break;
646  case 'plain':
647  // Plain text, nothing to do
648  default:
649  // Catch other types and use the old behavior (return as-is)
650  }
651 
652  return $value;
653  }
654 
663  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
664  if ( !$title instanceof Title ) {
665  $msg = $this->msg( 'invalidtitle' )->text();
666  if ( $this->plaintext ) {
667  return $msg;
668  } else {
669  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
670  }
671  }
672 
673  if ( $this->plaintext ) {
674  $link = '[[' . $title->getPrefixedText() . ']]';
675  } else {
676  $html = $html !== null ? new HtmlArmor( $html ) : $html;
677  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
678  }
679 
680  return $link;
681  }
682 
689  public function getPerformerElement() {
690  if ( $this->canView( LogPage::DELETED_USER ) ) {
691  $performer = $this->entry->getPerformer();
692  $element = $this->makeUserLink( $performer );
693  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
694  $element = $this->styleRestricedElement( $element );
695  }
696  } else {
697  $element = $this->getRestrictedElement( 'rev-deleted-user' );
698  }
699 
700  return $element;
701  }
702 
707  public function getComment() {
708  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
709  $comment = Linker::commentBlock( $this->entry->getComment() );
710  // No hard coded spaces thanx
711  $element = ltrim( $comment );
712  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
713  $element = $this->styleRestricedElement( $element );
714  }
715  } else {
716  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
717  }
718 
719  return $element;
720  }
721 
728  protected function getRestrictedElement( $message ) {
729  if ( $this->plaintext ) {
730  return $this->msg( $message )->text();
731  }
732 
733  $content = $this->msg( $message )->escaped();
734  $attribs = [ 'class' => 'history-deleted' ];
735 
736  return Html::rawElement( 'span', $attribs, $content );
737  }
738 
744  protected function styleRestricedElement( $content ) {
745  if ( $this->plaintext ) {
746  return $content;
747  }
748  $attribs = [ 'class' => 'history-deleted' ];
749 
750  return Html::rawElement( 'span', $attribs, $content );
751  }
752 
758  protected function msg( $key ) {
759  return $this->context->msg( $key );
760  }
761 
768  protected function makeUserLink( User $user, $toolFlags = 0 ) {
769  if ( $this->plaintext ) {
770  $element = $user->getName();
771  } else {
772  $element = Linker::userLink(
773  $user->getId(),
774  $user->getName()
775  );
776 
777  if ( $this->linkFlood ) {
778  $element .= Linker::userToolLinks(
779  $user->getId(),
780  $user->getName(),
781  true, // redContribsWhenNoEdits
782  $toolFlags,
783  $user->getEditCount(),
784  // do not render parenthesises in the HTML markup (CSS will provide)
785  false
786  );
787  }
788  }
789 
790  return $element;
791  }
792 
796  public function getPreloadTitles() {
797  return [];
798  }
799 
803  public function getMessageParametersForTesting() {
804  // This function was added because getMessageParameters() is
805  // protected and a change from protected to public caused
806  // problems with extensions
807  return $this->getMessageParameters();
808  }
809 
815  protected function getParametersForApi() {
816  return $this->entry->getParameters();
817  }
818 
833  public function formatParametersForApi() {
834  $logParams = [];
835  foreach ( $this->getParametersForApi() as $key => $value ) {
836  $vals = explode( ':', $key, 3 );
837  if ( count( $vals ) !== 3 ) {
838  if ( $value instanceof __PHP_Incomplete_Class ) {
839  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
840  ' contains unrecoverable extra parameters.' );
841  continue;
842  }
843  $logParams[$key] = $value;
844  continue;
845  }
846  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
847  }
848  ApiResult::setIndexedTagName( $logParams, 'param' );
849  ApiResult::setArrayType( $logParams, 'assoc' );
850 
851  return $logParams;
852  }
853 
863  protected function formatParameterValueForApi( $name, $type, $value ) {
864  $type = strtolower( trim( $type ) );
865  switch ( $type ) {
866  case 'bool':
867  $value = (bool)$value;
868  break;
869 
870  case 'number':
871  if ( ctype_digit( $value ) || is_int( $value ) ) {
872  $value = (int)$value;
873  } else {
874  $value = (float)$value;
875  }
876  break;
877 
878  case 'array':
879  case 'assoc':
880  case 'kvp':
881  if ( is_array( $value ) ) {
883  }
884  break;
885 
886  case 'timestamp':
887  $value = wfTimestamp( TS_ISO_8601, $value );
888  break;
889 
890  case 'msg':
891  case 'msg-content':
892  $msg = $this->msg( $value );
893  if ( $type === 'msg-content' ) {
894  $msg->inContentLanguage();
895  }
896  $value = [];
897  $value["{$name}_key"] = $msg->getKey();
898  if ( $msg->getParams() ) {
899  $value["{$name}_params"] = $msg->getParams();
900  }
901  $value["{$name}_text"] = $msg->text();
902  return $value;
903 
904  case 'title':
905  case 'title-link':
907  if ( !$title ) {
908  // Huh? Do something halfway sane.
909  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
910  }
911  $value = [];
912  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
913  return $value;
914 
915  case 'user':
916  case 'user-link':
918  if ( $user ) {
919  $value = $user->getName();
920  }
921  break;
922 
923  default:
924  // do nothing
925  break;
926  }
927 
928  return [ $name => $value ];
929  }
930 }
isLegacy()
Whether the parameters for this log are stored in new or old format.
setLinkRenderer(LinkRenderer $linkRenderer)
static rawParam( $raw)
Definition: Message.php:1040
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:1972
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
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
makeUserLink(User $user, $toolFlags=0)
styleRestricedElement( $content)
Helper method for styling restricted element.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
setContext(IContextSource $context)
Replace the default context.
Interface for log entries.
Definition: LogEntry.php:31
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
LogEntryBase $entry
static newFromRow( $row)
Constructs new LogEntry from database result row.
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
string $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
$value
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
array $parsedParameters
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
getRestrictedElement( $message)
Helper method for displaying restricted element.
getSubtype()
The log subtype.
static numParam( $num)
Definition: Message.php:1051
getPerformer()
Get the user for performed this action.
LinkRenderer null $linkRenderer
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
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
getName()
Get the user name, or the IP of an anonymous user.
Definition: User.php:2251
getMessageKey()
Returns a key to be used for formatting the action sentence.
getActionMessage()
Returns a sentence describing the log action.
getFullType()
The full logtype in format maintype/subtype.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3039
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:51
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:767
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const DELETED_COMMENT
Definition: LogPage.php:35
string $irctext
Class that generates HTML links for pages.
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
static getMain()
Get the RequestContext object associated with the main request.
__construct(LogEntry $entry)
getMessageParametersForTesting()
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:940
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row, if it&#39;s marked as deleted.
getType()
The main log type.
This class formats all log entries for log types which have not been converted to the new system...
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
$params
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:1972
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:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
const FOR_THIS_USER
setAudience( $audience)
Set the visibility restrictions for displaying content.
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
IContextSource $context
Context for logging.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:83
bool $linkFlood
Whether to output user tool links.
formatParametersForApi()
Format parameters for API output.
getPlainActionText()
Ugly hack to produce plaintext version of the message.
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
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
const DELETED_USER
Definition: LogPage.php:36
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:895
Implements the default log formatting.
const FOR_PUBLIC
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
getParameters()
Get the extra parameters stored for this message.
getId()
Get the user&#39;s ID.
Definition: User.php:2224
getPerformerElement()
Provides the name of the user who performed the log action.
msg( $key)
Shortcut for wfMessage which honors local context.
int $audience
Constant for handling log_deleted.
getEditCount()
Get the user&#39;s edit count.
Definition: User.php:3462
static formatBlockFlags( $flags, Language $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form...
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
canViewLogType()
Check if a log item type can be displayed.
extractParameters()
Extracts the optional extra parameters for use in action messages.
canView( $field)
Check if a log item can be displayed.
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
getActionText()
Gets the log action, including username.
getTarget()
Get the target page of this action.
getComment()
Gets the user provided comment.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
const DELETED_ACTION
Definition: LogPage.php:34
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:535
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
$content
Definition: pageupdater.txt:72
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it&#39;s non-empty, otherwise return empty strin...
Definition: Linker.php:1542
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1454
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:322
getTimestamp()
Get the timestamp when the action was executed.