MediaWiki  1.29.2
LogFormatter.php
Go to the documentation of this file.
1 <?php
36 class LogFormatter {
37  // Audience options for viewing usernames, comments, and actions
38  const FOR_PUBLIC = 1;
39  const FOR_THIS_USER = 2;
40 
41  // Static->
42 
48  public static function newFromEntry( LogEntry $entry ) {
49  global $wgLogActionsHandlers;
50  $fulltype = $entry->getFullType();
51  $wildcard = $entry->getType() . '/*';
52  $handler = '';
53 
54  if ( isset( $wgLogActionsHandlers[$fulltype] ) ) {
55  $handler = $wgLogActionsHandlers[$fulltype];
56  } elseif ( isset( $wgLogActionsHandlers[$wildcard] ) ) {
57  $handler = $wgLogActionsHandlers[$wildcard];
58  }
59 
60  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
61  return new $handler( $entry );
62  }
63 
64  return new LegacyLogFormatter( $entry );
65  }
66 
74  public static function newFromRow( $row ) {
76  }
77 
78  // Nonstatic->
79 
81  protected $entry;
82 
85 
87  public $context;
88 
90  protected $linkFlood = false;
91 
99  protected $plaintext = false;
100 
102  protected $irctext = false;
103 
104  protected function __construct( LogEntry $entry ) {
105  $this->entry = $entry;
106  $this->context = RequestContext::getMain();
107  }
108 
113  public function setContext( IContextSource $context ) {
114  $this->context = $context;
115  }
116 
123  public function setAudience( $audience ) {
124  $this->audience = ( $audience == self::FOR_THIS_USER )
125  ? self::FOR_THIS_USER
126  : self::FOR_PUBLIC;
127  }
128 
134  protected function canView( $field ) {
135  if ( $this->audience == self::FOR_THIS_USER ) {
137  $this->entry->getDeleted(), $field, $this->context->getUser() );
138  } else {
139  return !$this->entry->isDeleted( $field );
140  }
141  }
142 
149  public function setShowUserToolLinks( $value ) {
150  $this->linkFlood = $value;
151  }
152 
160  public function getPlainActionText() {
161  $this->plaintext = true;
162  $text = $this->getActionText();
163  $this->plaintext = false;
164 
165  return $text;
166  }
167 
174  public function getIRCActionComment() {
175  $actionComment = $this->getIRCActionText();
176  $comment = $this->entry->getComment();
177 
178  if ( $comment != '' ) {
179  if ( $actionComment == '' ) {
180  $actionComment = $comment;
181  } else {
182  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
183  }
184  }
185 
186  return $actionComment;
187  }
188 
195  public function getIRCActionText() {
197 
198  $this->plaintext = true;
199  $this->irctext = true;
200 
202  $parameters = $entry->getParameters();
203  // @see LogPage::actionText()
204  // Text of title the action is aimed at.
205  $target = $entry->getTarget()->getPrefixedText();
206  $text = null;
207  switch ( $entry->getType() ) {
208  case 'move':
209  switch ( $entry->getSubtype() ) {
210  case 'move':
211  $movesource = $parameters['4::target'];
212  $text = wfMessage( '1movedto2' )
213  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
214  break;
215  case 'move_redir':
216  $movesource = $parameters['4::target'];
217  $text = wfMessage( '1movedto2_redir' )
218  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
219  break;
220  case 'move-noredirect':
221  break;
222  case 'move_redir-noredirect':
223  break;
224  }
225  break;
226 
227  case 'delete':
228  switch ( $entry->getSubtype() ) {
229  case 'delete':
230  $text = wfMessage( 'deletedarticle' )
231  ->rawParams( $target )->inContentLanguage()->escaped();
232  break;
233  case 'restore':
234  $text = wfMessage( 'undeletedarticle' )
235  ->rawParams( $target )->inContentLanguage()->escaped();
236  break;
237  // @codingStandardsIgnoreStart Long line
238  //case 'revision': // Revision deletion
239  //case 'event': // Log deletion
240  // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
241  //default:
242  // @codingStandardsIgnoreEnd
243  }
244  break;
245 
246  case 'patrol':
247  // @codingStandardsIgnoreStart Long line
248  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
249  // @codingStandardsIgnoreEnd
250  // Create a diff link to the patrolled revision
251  if ( $entry->getSubtype() === 'patrol' ) {
252  $diffLink = htmlspecialchars(
253  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
254  ->inContentLanguage()->text() );
255  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
256  ->inContentLanguage()->text();
257  } else {
258  // broken??
259  }
260  break;
261 
262  case 'protect':
263  switch ( $entry->getSubtype() ) {
264  case 'protect':
265  $text = wfMessage( 'protectedarticle' )
266  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
267  break;
268  case 'unprotect':
269  $text = wfMessage( 'unprotectedarticle' )
270  ->rawParams( $target )->inContentLanguage()->escaped();
271  break;
272  case 'modify':
273  $text = wfMessage( 'modifiedarticleprotection' )
274  ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
275  break;
276  case 'move_prot':
277  $text = wfMessage( 'movedarticleprotection' )
278  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
279  break;
280  }
281  break;
282 
283  case 'newusers':
284  switch ( $entry->getSubtype() ) {
285  case 'newusers':
286  case 'create':
287  $text = wfMessage( 'newuserlog-create-entry' )
288  ->inContentLanguage()->escaped();
289  break;
290  case 'create2':
291  case 'byemail':
292  $text = wfMessage( 'newuserlog-create2-entry' )
293  ->rawParams( $target )->inContentLanguage()->escaped();
294  break;
295  case 'autocreate':
296  $text = wfMessage( 'newuserlog-autocreate-entry' )
297  ->inContentLanguage()->escaped();
298  break;
299  }
300  break;
301 
302  case 'upload':
303  switch ( $entry->getSubtype() ) {
304  case 'upload':
305  $text = wfMessage( 'uploadedimage' )
306  ->rawParams( $target )->inContentLanguage()->escaped();
307  break;
308  case 'overwrite':
309  $text = wfMessage( 'overwroteimage' )
310  ->rawParams( $target )->inContentLanguage()->escaped();
311  break;
312  }
313  break;
314 
315  case 'rights':
316  if ( count( $parameters['4::oldgroups'] ) ) {
317  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
318  } else {
319  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
320  }
321  if ( count( $parameters['5::newgroups'] ) ) {
322  $newgroups = implode( ', ', $parameters['5::newgroups'] );
323  } else {
324  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
325  }
326  switch ( $entry->getSubtype() ) {
327  case 'rights':
328  $text = wfMessage( 'rightslogentry' )
329  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
330  break;
331  case 'autopromote':
332  $text = wfMessage( 'rightslogentry-autopromote' )
333  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
334  break;
335  }
336  break;
337 
338  case 'merge':
339  $text = wfMessage( 'pagemerge-logentry' )
340  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
341  ->inContentLanguage()->escaped();
342  break;
343 
344  case 'block':
345  switch ( $entry->getSubtype() ) {
346  case 'block':
347  // Keep compatibility with extensions by checking for
348  // new key (5::duration/6::flags) or old key (0/optional 1)
349  if ( $entry->isLegacy() ) {
350  $rawDuration = $parameters[0];
351  $rawFlags = isset( $parameters[1] ) ? $parameters[1] : '';
352  } else {
353  $rawDuration = $parameters['5::duration'];
354  $rawFlags = $parameters['6::flags'];
355  }
356  $duration = $wgContLang->translateBlockExpiry(
357  $rawDuration,
358  null,
359  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
360  );
362  $text = wfMessage( 'blocklogentry' )
363  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
364  break;
365  case 'unblock':
366  $text = wfMessage( 'unblocklogentry' )
367  ->rawParams( $target )->inContentLanguage()->escaped();
368  break;
369  case 'reblock':
370  $duration = $wgContLang->translateBlockExpiry(
371  $parameters['5::duration'],
372  null,
373  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
374  );
375  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang );
376  $text = wfMessage( 'reblock-logentry' )
377  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
378  break;
379  }
380  break;
381 
382  case 'import':
383  switch ( $entry->getSubtype() ) {
384  case 'upload':
385  $text = wfMessage( 'import-logentry-upload' )
386  ->rawParams( $target )->inContentLanguage()->escaped();
387  break;
388  case 'interwiki':
389  $text = wfMessage( 'import-logentry-interwiki' )
390  ->rawParams( $target )->inContentLanguage()->escaped();
391  break;
392  }
393  break;
394  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
395  // default:
396  }
397  if ( is_null( $text ) ) {
398  $text = $this->getPlainActionText();
399  }
400 
401  $this->plaintext = false;
402  $this->irctext = false;
403 
404  return $text;
405  }
406 
411  public function getActionText() {
412  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
413  $element = $this->getActionMessage();
414  if ( $element instanceof Message ) {
415  $element = $this->plaintext ? $element->text() : $element->escaped();
416  }
417  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
418  $element = $this->styleRestricedElement( $element );
419  }
420  } else {
421  $sep = $this->msg( 'word-separator' );
422  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
423  $performer = $this->getPerformerElement();
424  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
425  }
426 
427  return $element;
428  }
429 
436  protected function getActionMessage() {
437  $message = $this->msg( $this->getMessageKey() );
438  $message->params( $this->getMessageParameters() );
439 
440  return $message;
441  }
442 
450  protected function getMessageKey() {
451  $type = $this->entry->getType();
452  $subtype = $this->entry->getSubtype();
453 
454  return "logentry-$type-$subtype";
455  }
456 
462  public function getActionLinks() {
463  return '';
464  }
465 
471  protected function extractParameters() {
473  $params = [];
474 
475  if ( $entry->isLegacy() ) {
476  foreach ( $entry->getParameters() as $index => $value ) {
477  $params[$index + 3] = $value;
478  }
479  }
480 
481  // Filter out parameters which are not in format #:foo
482  foreach ( $entry->getParameters() as $key => $value ) {
483  if ( strpos( $key, ':' ) === false ) {
484  continue;
485  }
486  list( $index, $type, ) = explode( ':', $key, 3 );
487  if ( ctype_digit( $index ) ) {
488  $params[$index - 1] = $this->formatParameterValue( $type, $value );
489  }
490  }
491 
492  /* Message class doesn't like non consecutive numbering.
493  * Fill in missing indexes with empty strings to avoid
494  * incorrect renumbering.
495  */
496  if ( count( $params ) ) {
497  $max = max( array_keys( $params ) );
498  // index 0 to 2 are added in getMessageParameters
499  for ( $i = 3; $i < $max; $i++ ) {
500  if ( !isset( $params[$i] ) ) {
501  $params[$i] = '';
502  }
503  }
504  }
505 
506  return $params;
507  }
508 
518  protected function getMessageParameters() {
519  if ( isset( $this->parsedParameters ) ) {
520  return $this->parsedParameters;
521  }
522 
524  $params = $this->extractParameters();
525  $params[0] = Message::rawParam( $this->getPerformerElement() );
526  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
527  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
528 
529  // Bad things happens if the numbers are not in correct order
530  ksort( $params );
531 
532  $this->parsedParameters = $params;
533  return $this->parsedParameters;
534  }
535 
562  protected function formatParameterValue( $type, $value ) {
563  $saveLinkFlood = $this->linkFlood;
564 
565  switch ( strtolower( trim( $type ) ) ) {
566  case 'raw':
567  $value = Message::rawParam( $value );
568  break;
569  case 'list':
570  $value = $this->context->getLanguage()->commaList( $value );
571  break;
572  case 'msg':
573  $value = $this->msg( $value )->text();
574  break;
575  case 'msg-content':
576  $value = $this->msg( $value )->inContentLanguage()->text();
577  break;
578  case 'number':
579  $value = Message::numParam( $value );
580  break;
581  case 'user':
583  $value = $user->getName();
584  break;
585  case 'user-link':
586  $this->setShowUserToolLinks( false );
587 
589  $value = Message::rawParam( $this->makeUserLink( $user ) );
590 
591  $this->setShowUserToolLinks( $saveLinkFlood );
592  break;
593  case 'title':
595  $value = $title->getPrefixedText();
596  break;
597  case 'title-link':
599  $value = Message::rawParam( $this->makePageLink( $title ) );
600  break;
601  case 'plain':
602  // Plain text, nothing to do
603  default:
604  // Catch other types and use the old behavior (return as-is)
605  }
606 
607  return $value;
608  }
609 
619  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
620  if ( !$this->plaintext ) {
621  $link = Linker::link( $title, $html, [], $parameters );
622  } else {
623  if ( !$title instanceof Title ) {
624  throw new MWException( "Expected title, got null" );
625  }
626  $link = '[[' . $title->getPrefixedText() . ']]';
627  }
628 
629  return $link;
630  }
631 
638  public function getPerformerElement() {
639  if ( $this->canView( LogPage::DELETED_USER ) ) {
640  $performer = $this->entry->getPerformer();
641  $element = $this->makeUserLink( $performer );
642  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
643  $element = $this->styleRestricedElement( $element );
644  }
645  } else {
646  $element = $this->getRestrictedElement( 'rev-deleted-user' );
647  }
648 
649  return $element;
650  }
651 
656  public function getComment() {
657  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
658  $comment = Linker::commentBlock( $this->entry->getComment() );
659  // No hard coded spaces thanx
660  $element = ltrim( $comment );
661  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
662  $element = $this->styleRestricedElement( $element );
663  }
664  } else {
665  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
666  }
667 
668  return $element;
669  }
670 
676  protected function getRestrictedElement( $message ) {
677  if ( $this->plaintext ) {
678  return $this->msg( $message )->text();
679  }
680 
681  $content = $this->msg( $message )->escaped();
682  $attribs = [ 'class' => 'history-deleted' ];
683 
684  return Html::rawElement( 'span', $attribs, $content );
685  }
686 
692  protected function styleRestricedElement( $content ) {
693  if ( $this->plaintext ) {
694  return $content;
695  }
696  $attribs = [ 'class' => 'history-deleted' ];
697 
698  return Html::rawElement( 'span', $attribs, $content );
699  }
700 
706  protected function msg( $key ) {
707  return $this->context->msg( $key );
708  }
709 
710  protected function makeUserLink( User $user, $toolFlags = 0 ) {
711  if ( $this->plaintext ) {
712  $element = $user->getName();
713  } else {
714  $element = Linker::userLink(
715  $user->getId(),
716  $user->getName()
717  );
718 
719  if ( $this->linkFlood ) {
720  $element .= Linker::userToolLinks(
721  $user->getId(),
722  $user->getName(),
723  true, // redContribsWhenNoEdits
724  $toolFlags,
725  $user->getEditCount()
726  );
727  }
728  }
729 
730  return $element;
731  }
732 
736  public function getPreloadTitles() {
737  return [];
738  }
739 
743  public function getMessageParametersForTesting() {
744  // This function was added because getMessageParameters() is
745  // protected and a change from protected to public caused
746  // problems with extensions
747  return $this->getMessageParameters();
748  }
749 
755  protected function getParametersForApi() {
756  return $this->entry->getParameters();
757  }
758 
773  public function formatParametersForApi() {
774  $logParams = [];
775  foreach ( $this->getParametersForApi() as $key => $value ) {
776  $vals = explode( ':', $key, 3 );
777  if ( count( $vals ) !== 3 ) {
778  $logParams[$key] = $value;
779  continue;
780  }
781  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
782  }
783  ApiResult::setIndexedTagName( $logParams, 'param' );
784  ApiResult::setArrayType( $logParams, 'assoc' );
785 
786  return $logParams;
787  }
788 
798  protected function formatParameterValueForApi( $name, $type, $value ) {
799  $type = strtolower( trim( $type ) );
800  switch ( $type ) {
801  case 'bool':
802  $value = (bool)$value;
803  break;
804 
805  case 'number':
806  if ( ctype_digit( $value ) || is_int( $value ) ) {
807  $value = (int)$value;
808  } else {
809  $value = (float)$value;
810  }
811  break;
812 
813  case 'array':
814  case 'assoc':
815  case 'kvp':
816  if ( is_array( $value ) ) {
818  }
819  break;
820 
821  case 'timestamp':
822  $value = wfTimestamp( TS_ISO_8601, $value );
823  break;
824 
825  case 'msg':
826  case 'msg-content':
827  $msg = $this->msg( $value );
828  if ( $type === 'msg-content' ) {
829  $msg->inContentLanguage();
830  }
831  $value = [];
832  $value["{$name}_key"] = $msg->getKey();
833  if ( $msg->getParams() ) {
834  $value["{$name}_params"] = $msg->getParams();
835  }
836  $value["{$name}_text"] = $msg->text();
837  return $value;
838 
839  case 'title':
840  case 'title-link':
842  if ( $title ) {
843  $value = [];
844  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
845  }
846  return $value;
847 
848  case 'user':
849  case 'user-link':
851  if ( $user ) {
852  $value = $user->getName();
853  }
854  break;
855 
856  default:
857  // do nothing
858  break;
859  }
860 
861  return [ $name => $value ];
862  }
863 }
864 
884  private $comment = null;
885 
893  private $revert = null;
894 
895  public function getComment() {
896  if ( $this->comment === null ) {
897  $this->comment = parent::getComment();
898  }
899 
900  // Make sure we execute the LogLine hook so that we immediately return
901  // the correct value.
902  if ( $this->revert === null ) {
903  $this->getActionLinks();
904  }
905 
906  return $this->comment;
907  }
908 
909  protected function getActionMessage() {
911  $action = LogPage::actionText(
912  $entry->getType(),
913  $entry->getSubtype(),
914  $entry->getTarget(),
915  $this->plaintext ? null : $this->context->getSkin(),
917  !$this->plaintext // whether to filter [[]] links
918  );
919 
920  $performer = $this->getPerformerElement();
921  if ( !$this->irctext ) {
922  $sep = $this->msg( 'word-separator' );
923  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
924  $action = $performer . $sep . $action;
925  }
926 
927  return $action;
928  }
929 
930  public function getActionLinks() {
931  if ( $this->revert !== null ) {
932  return $this->revert;
933  }
934 
935  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
936  $this->revert = '';
937  return $this->revert;
938  }
939 
940  $title = $this->entry->getTarget();
941  $type = $this->entry->getType();
942  $subtype = $this->entry->getSubtype();
943 
944  // Do nothing. The implementation is handled by the hook modifiying the
945  // passed-by-ref parameters. This also changes the default value so that
946  // getComment() and getActionLinks() do not call them indefinitely.
947  $this->revert = '';
948 
949  // This is to populate the $comment member of this instance so that it
950  // can be modified when calling the hook just below.
951  if ( $this->comment === null ) {
952  $this->getComment();
953  }
954 
955  $params = $this->entry->getParameters();
956 
957  Hooks::run( 'LogLine', [ $type, $subtype, $title, $params,
958  &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
959 
960  return $this->revert;
961  }
962 }
LogFormatter\FOR_THIS_USER
const FOR_THIS_USER
Definition: LogFormatter.php:39
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:265
LogFormatter\setAudience
setAudience( $audience)
Set the visibility restrictions for displaying content.
Definition: LogFormatter.php:123
LegacyLogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:895
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:462
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:160
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:888
LogFormatter\makeUserLink
makeUserLink(User $user, $toolFlags=0)
Definition: LogFormatter.php:710
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
captcha-old.count
count
Definition: captcha-old.py:225
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
LogFormatter\FOR_PUBLIC
const FOR_PUBLIC
Definition: LogFormatter.php:38
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:81
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
LogEntryBase\isLegacy
isLegacy()
Whether the parameters for this log are stored in new or old format.
Definition: LogEntry.php:131
LogEntry\getTarget
getTarget()
Get the target page of this action.
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
LogFormatter\getIRCActionComment
getIRCActionComment()
Even uglier hack to maintain backwards compatibilty with IRC bots (T36508).
Definition: LogFormatter.php:174
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:755
$params
$params
Definition: styleTest.css.php:40
LogFormatter\$audience
int $audience
Constant for handling log_deleted.
Definition: LogFormatter.php:84
LogFormatter\canView
canView( $field)
Check if a log item can be displayed.
Definition: LogFormatter.php:134
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:518
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:99
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
LogFormatter\setContext
setContext(IContextSource $context)
Replace the default context.
Definition: LogFormatter.php:113
LogPage\actionText
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition: LogPage.php:226
LegacyLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:930
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:656
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:638
LogFormatter\__construct
__construct(LogEntry $entry)
Definition: LogFormatter.php:104
LogFormatter\msg
msg( $key)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:706
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:1956
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:203
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:33
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:893
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:74
LogEntry
Interface for log entries.
Definition: LogEntry.php:38
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:34
$content
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition: hooks.txt:1049
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:743
$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:1956
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibilty with IRC bots (T36508).
Definition: LogFormatter.php:195
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:32
LogFormatter\styleRestricedElement
styleRestricedElement( $content)
Helper method for styling restricted element.
Definition: LogFormatter.php:692
LogEntryBase
Extends the LogEntryInterface with some basic functionality.
Definition: LogEntry.php:115
LogFormatter\formatParameterValue
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
Definition: LogFormatter.php:562
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:798
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:773
$value
$value
Definition: styleTest.css.php:45
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:921
LegacyLogFormatter\$comment
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
Definition: LogFormatter.php:884
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:149
LegacyLogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:909
Linker\link
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:107
LogEntryBase\getFullType
getFullType()
The full logtype in format maintype/subtype.
Definition: LogEntry.php:117
LogFormatter\getActionText
getActionText()
Gets the log action, including username.
Definition: LogFormatter.php:411
$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 probably a stub 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:783
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:468
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:436
LogEntry\getSubtype
getSubtype()
The log subtype.
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:36
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
LogFormatter\getPreloadTitles
getPreloadTitles()
Definition: LogFormatter.php:736
Title
Represents a title within MediaWiki.
Definition: Title.php:39
LogFormatter\$linkFlood
bool $linkFlood
Whether to output user tool links.
Definition: LogFormatter.php:90
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:512
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
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
Linker\commentBlock
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition: Linker.php:1439
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
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 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\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:676
LogFormatter\$irctext
string $irctext
Definition: LogFormatter.php:102
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LogFormatter.php:874
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:450
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
LogEntry\getPerformer
getPerformer()
Get the user for performed this action.
BlockLogFormatter\formatBlockFlags
static formatBlockFlags( $flags, $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form.
Definition: BlockLogFormatter.php:135
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2749
LogFormatter\$context
IContextSource $context
Context for logging.
Definition: LogFormatter.php:87
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:471
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:486
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:619
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:48