MediaWiki  REL1_31
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 ) {
52  $fulltype = $entry->getFullType();
53  $wildcard = $entry->getType() . '/*';
54  $handler = '';
55 
56  if ( isset( $wgLogActionsHandlers[$fulltype] ) ) {
57  $handler = $wgLogActionsHandlers[$fulltype];
58  } elseif ( isset( $wgLogActionsHandlers[$wildcard] ) ) {
59  $handler = $wgLogActionsHandlers[$wildcard];
60  }
61 
62  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
63  return new $handler( $entry );
64  }
65 
66  return new LegacyLogFormatter( $entry );
67  }
68 
76  public static function newFromRow( $row ) {
78  }
79 
80  // Nonstatic->
81 
83  protected $entry;
84 
87 
89  public $context;
90 
92  protected $linkFlood = false;
93 
101  protected $plaintext = false;
102 
104  protected $irctext = false;
105 
109  private $linkRenderer;
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 
187  public function getPlainActionText() {
188  $this->plaintext = true;
189  $text = $this->getActionText();
190  $this->plaintext = false;
191 
192  return $text;
193  }
194 
201  public function getIRCActionComment() {
202  $actionComment = $this->getIRCActionText();
203  $comment = $this->entry->getComment();
204 
205  if ( $comment != '' ) {
206  if ( $actionComment == '' ) {
207  $actionComment = $comment;
208  } else {
209  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
210  }
211  }
212 
213  return $actionComment;
214  }
215 
222  public function getIRCActionText() {
224 
225  $this->plaintext = true;
226  $this->irctext = true;
227 
229  $parameters = $entry->getParameters();
230  // @see LogPage::actionText()
231  // Text of title the action is aimed at.
232  $target = $entry->getTarget()->getPrefixedText();
233  $text = null;
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  $text = wfMessage( 'overwroteimage' )
333  ->rawParams( $target )->inContentLanguage()->escaped();
334  break;
335  }
336  break;
337 
338  case 'rights':
339  if ( count( $parameters['4::oldgroups'] ) ) {
340  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
341  } else {
342  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
343  }
344  if ( count( $parameters['5::newgroups'] ) ) {
345  $newgroups = implode( ', ', $parameters['5::newgroups'] );
346  } else {
347  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
348  }
349  switch ( $entry->getSubtype() ) {
350  case 'rights':
351  $text = wfMessage( 'rightslogentry' )
352  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
353  break;
354  case 'autopromote':
355  $text = wfMessage( 'rightslogentry-autopromote' )
356  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
357  break;
358  }
359  break;
360 
361  case 'merge':
362  $text = wfMessage( 'pagemerge-logentry' )
363  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
364  ->inContentLanguage()->escaped();
365  break;
366 
367  case 'block':
368  switch ( $entry->getSubtype() ) {
369  case 'block':
370  // Keep compatibility with extensions by checking for
371  // new key (5::duration/6::flags) or old key (0/optional 1)
372  if ( $entry->isLegacy() ) {
373  $rawDuration = $parameters[0];
374  $rawFlags = isset( $parameters[1] ) ? $parameters[1] : '';
375  } else {
376  $rawDuration = $parameters['5::duration'];
377  $rawFlags = $parameters['6::flags'];
378  }
379  $duration = $wgContLang->translateBlockExpiry(
380  $rawDuration,
381  null,
382  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
383  );
384  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $wgContLang );
385  $text = wfMessage( 'blocklogentry' )
386  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
387  break;
388  case 'unblock':
389  $text = wfMessage( 'unblocklogentry' )
390  ->rawParams( $target )->inContentLanguage()->escaped();
391  break;
392  case 'reblock':
393  $duration = $wgContLang->translateBlockExpiry(
394  $parameters['5::duration'],
395  null,
396  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
397  );
398  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang );
399  $text = wfMessage( 'reblock-logentry' )
400  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
401  break;
402  }
403  break;
404 
405  case 'import':
406  switch ( $entry->getSubtype() ) {
407  case 'upload':
408  $text = wfMessage( 'import-logentry-upload' )
409  ->rawParams( $target )->inContentLanguage()->escaped();
410  break;
411  case 'interwiki':
412  $text = wfMessage( 'import-logentry-interwiki' )
413  ->rawParams( $target )->inContentLanguage()->escaped();
414  break;
415  }
416  break;
417  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
418  // default:
419  }
420  if ( is_null( $text ) ) {
421  $text = $this->getPlainActionText();
422  }
423 
424  $this->plaintext = false;
425  $this->irctext = false;
426 
427  return $text;
428  }
429 
434  public function getActionText() {
435  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
436  $element = $this->getActionMessage();
437  if ( $element instanceof Message ) {
438  $element = $this->plaintext ? $element->text() : $element->escaped();
439  }
440  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
441  $element = $this->styleRestricedElement( $element );
442  }
443  } else {
444  $sep = $this->msg( 'word-separator' );
445  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
446  $performer = $this->getPerformerElement();
447  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
448  }
449 
450  return $element;
451  }
452 
459  protected function getActionMessage() {
460  $message = $this->msg( $this->getMessageKey() );
461  $message->params( $this->getMessageParameters() );
462 
463  return $message;
464  }
465 
473  protected function getMessageKey() {
474  $type = $this->entry->getType();
475  $subtype = $this->entry->getSubtype();
476 
477  return "logentry-$type-$subtype";
478  }
479 
485  public function getActionLinks() {
486  return '';
487  }
488 
494  protected function extractParameters() {
496  $params = [];
497 
498  if ( $entry->isLegacy() ) {
499  foreach ( $entry->getParameters() as $index => $value ) {
500  $params[$index + 3] = $value;
501  }
502  }
503 
504  // Filter out parameters which are not in format #:foo
505  foreach ( $entry->getParameters() as $key => $value ) {
506  if ( strpos( $key, ':' ) === false ) {
507  continue;
508  }
509  list( $index, $type, ) = explode( ':', $key, 3 );
510  if ( ctype_digit( $index ) ) {
511  $params[$index - 1] = $this->formatParameterValue( $type, $value );
512  }
513  }
514 
515  /* Message class doesn't like non consecutive numbering.
516  * Fill in missing indexes with empty strings to avoid
517  * incorrect renumbering.
518  */
519  if ( count( $params ) ) {
520  $max = max( array_keys( $params ) );
521  // index 0 to 2 are added in getMessageParameters
522  for ( $i = 3; $i < $max; $i++ ) {
523  if ( !isset( $params[$i] ) ) {
524  $params[$i] = '';
525  }
526  }
527  }
528 
529  return $params;
530  }
531 
541  protected function getMessageParameters() {
542  if ( isset( $this->parsedParameters ) ) {
543  return $this->parsedParameters;
544  }
545 
547  $params = $this->extractParameters();
549  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
551 
552  // Bad things happens if the numbers are not in correct order
553  ksort( $params );
554 
555  $this->parsedParameters = $params;
556  return $this->parsedParameters;
557  }
558 
585  protected function formatParameterValue( $type, $value ) {
586  $saveLinkFlood = $this->linkFlood;
587 
588  switch ( strtolower( trim( $type ) ) ) {
589  case 'raw':
591  break;
592  case 'list':
593  $value = $this->context->getLanguage()->commaList( $value );
594  break;
595  case 'msg':
596  $value = $this->msg( $value )->text();
597  break;
598  case 'msg-content':
599  $value = $this->msg( $value )->inContentLanguage()->text();
600  break;
601  case 'number':
603  break;
604  case 'user':
606  $value = $user->getName();
607  break;
608  case 'user-link':
609  $this->setShowUserToolLinks( false );
610 
613 
614  $this->setShowUserToolLinks( $saveLinkFlood );
615  break;
616  case 'title':
618  $value = $title->getPrefixedText();
619  break;
620  case 'title-link':
623  break;
624  case 'plain':
625  // Plain text, nothing to do
626  default:
627  // Catch other types and use the old behavior (return as-is)
628  }
629 
630  return $value;
631  }
632 
641  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
642  if ( !$title instanceof Title ) {
643  $msg = $this->msg( 'invalidtitle' )->text();
644  if ( !$this->plaintext ) {
645  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
646  } else {
647  return $msg;
648  }
649  }
650 
651  if ( !$this->plaintext ) {
652  $html = $html !== null ? new HtmlArmor( $html ) : $html;
653  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
654  } else {
655  $link = '[[' . $title->getPrefixedText() . ']]';
656  }
657 
658  return $link;
659  }
660 
667  public function getPerformerElement() {
668  if ( $this->canView( LogPage::DELETED_USER ) ) {
669  $performer = $this->entry->getPerformer();
670  $element = $this->makeUserLink( $performer );
671  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
672  $element = $this->styleRestricedElement( $element );
673  }
674  } else {
675  $element = $this->getRestrictedElement( 'rev-deleted-user' );
676  }
677 
678  return $element;
679  }
680 
685  public function getComment() {
686  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
687  $comment = Linker::commentBlock( $this->entry->getComment() );
688  // No hard coded spaces thanx
689  $element = ltrim( $comment );
690  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
691  $element = $this->styleRestricedElement( $element );
692  }
693  } else {
694  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
695  }
696 
697  return $element;
698  }
699 
705  protected function getRestrictedElement( $message ) {
706  if ( $this->plaintext ) {
707  return $this->msg( $message )->text();
708  }
709 
710  $content = $this->msg( $message )->escaped();
711  $attribs = [ 'class' => 'history-deleted' ];
712 
713  return Html::rawElement( 'span', $attribs, $content );
714  }
715 
721  protected function styleRestricedElement( $content ) {
722  if ( $this->plaintext ) {
723  return $content;
724  }
725  $attribs = [ 'class' => 'history-deleted' ];
726 
727  return Html::rawElement( 'span', $attribs, $content );
728  }
729 
735  protected function msg( $key ) {
736  return $this->context->msg( $key );
737  }
738 
739  protected function makeUserLink( User $user, $toolFlags = 0 ) {
740  if ( $this->plaintext ) {
741  $element = $user->getName();
742  } else {
743  $element = Linker::userLink(
744  $user->getId(),
745  $user->getName()
746  );
747 
748  if ( $this->linkFlood ) {
749  $element .= Linker::userToolLinks(
750  $user->getId(),
751  $user->getName(),
752  true, // redContribsWhenNoEdits
753  $toolFlags,
754  $user->getEditCount()
755  );
756  }
757  }
758 
759  return $element;
760  }
761 
765  public function getPreloadTitles() {
766  return [];
767  }
768 
772  public function getMessageParametersForTesting() {
773  // This function was added because getMessageParameters() is
774  // protected and a change from protected to public caused
775  // problems with extensions
776  return $this->getMessageParameters();
777  }
778 
784  protected function getParametersForApi() {
785  return $this->entry->getParameters();
786  }
787 
802  public function formatParametersForApi() {
803  $logParams = [];
804  foreach ( $this->getParametersForApi() as $key => $value ) {
805  $vals = explode( ':', $key, 3 );
806  if ( count( $vals ) !== 3 ) {
807  $logParams[$key] = $value;
808  continue;
809  }
810  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
811  }
812  ApiResult::setIndexedTagName( $logParams, 'param' );
813  ApiResult::setArrayType( $logParams, 'assoc' );
814 
815  return $logParams;
816  }
817 
827  protected function formatParameterValueForApi( $name, $type, $value ) {
828  $type = strtolower( trim( $type ) );
829  switch ( $type ) {
830  case 'bool':
831  $value = (bool)$value;
832  break;
833 
834  case 'number':
835  if ( ctype_digit( $value ) || is_int( $value ) ) {
836  $value = (int)$value;
837  } else {
838  $value = (float)$value;
839  }
840  break;
841 
842  case 'array':
843  case 'assoc':
844  case 'kvp':
845  if ( is_array( $value ) ) {
847  }
848  break;
849 
850  case 'timestamp':
851  $value = wfTimestamp( TS_ISO_8601, $value );
852  break;
853 
854  case 'msg':
855  case 'msg-content':
856  $msg = $this->msg( $value );
857  if ( $type === 'msg-content' ) {
858  $msg->inContentLanguage();
859  }
860  $value = [];
861  $value["{$name}_key"] = $msg->getKey();
862  if ( $msg->getParams() ) {
863  $value["{$name}_params"] = $msg->getParams();
864  }
865  $value["{$name}_text"] = $msg->text();
866  return $value;
867 
868  case 'title':
869  case 'title-link':
871  if ( !$title ) {
872  // Huh? Do something halfway sane.
873  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
874  }
875  $value = [];
876  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
877  return $value;
878 
879  case 'user':
880  case 'user-link':
882  if ( $user ) {
883  $value = $user->getName();
884  }
885  break;
886 
887  default:
888  // do nothing
889  break;
890  }
891 
892  return [ $name => $value ];
893  }
894 }
895 
915  private $comment = null;
916 
924  private $revert = null;
925 
926  public function getComment() {
927  if ( $this->comment === null ) {
928  $this->comment = parent::getComment();
929  }
930 
931  // Make sure we execute the LogLine hook so that we immediately return
932  // the correct value.
933  if ( $this->revert === null ) {
934  $this->getActionLinks();
935  }
936 
937  return $this->comment;
938  }
939 
940  protected function getActionMessage() {
942  $action = LogPage::actionText(
943  $entry->getType(),
944  $entry->getSubtype(),
945  $entry->getTarget(),
946  $this->plaintext ? null : $this->context->getSkin(),
948  !$this->plaintext // whether to filter [[]] links
949  );
950 
951  $performer = $this->getPerformerElement();
952  if ( !$this->irctext ) {
953  $sep = $this->msg( 'word-separator' );
954  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
955  $action = $performer . $sep . $action;
956  }
957 
958  return $action;
959  }
960 
961  public function getActionLinks() {
962  if ( $this->revert !== null ) {
963  return $this->revert;
964  }
965 
966  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
967  $this->revert = '';
968  return $this->revert;
969  }
970 
971  $title = $this->entry->getTarget();
972  $type = $this->entry->getType();
973  $subtype = $this->entry->getSubtype();
974 
975  // Do nothing. The implementation is handled by the hook modifiying the
976  // passed-by-ref parameters. This also changes the default value so that
977  // getComment() and getActionLinks() do not call them indefinitely.
978  $this->revert = '';
979 
980  // This is to populate the $comment member of this instance so that it
981  // can be modified when calling the hook just below.
982  if ( $this->comment === null ) {
983  $this->getComment();
984  }
985 
986  $params = $this->entry->getParameters();
987 
988  Hooks::run( 'LogLine', [ $type, $subtype, $title, $params,
989  &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
990 
991  return $this->revert;
992  }
993 }
$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:247
$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:903
Message\numParam
static numParam( $num)
Definition: Message.php:1028
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:273
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:926
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:485
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:187
$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:2013
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:893
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
array
the array() calling protocol came about after MediaWiki 1.4rc1.
LogFormatter\makeUserLink
makeUserLink(User $user, $toolFlags=0)
Definition: LogFormatter.php:739
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
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:18
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:83
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1980
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.
LogFormatter\getIRCActionComment
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:201
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:784
$params
$params
Definition: styleTest.css.php:40
LogFormatter\$audience
int $audience
Constant for handling log_deleted.
Definition: LogFormatter.php:86
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:591
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
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:541
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:101
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:221
LegacyLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:961
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:37
LogEntry\getType
getType()
The main log type.
LogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:685
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:667
LogFormatter\__construct
__construct(LogEntry $entry)
Definition: LogFormatter.php:111
LogFormatter\msg
msg( $key)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:735
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:207
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:924
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:76
LogEntry
Interface for log entries.
Definition: LogEntry.php:38
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:34
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:772
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3021
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:222
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:721
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:585
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:827
$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:2014
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:802
$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:931
Message\rawParam
static rawParam( $raw)
Definition: Message.php:1017
LegacyLogFormatter\$comment
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
Definition: LogFormatter.php:915
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:176
LegacyLogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:940
LogFormatter\setLinkRenderer
setLinkRenderer(LinkRenderer $linkRenderer)
Definition: LogFormatter.php:128
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:434
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:7764
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:459
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
LogFormatter\getPreloadTitles
getPreloadTitles()
Definition: LogFormatter.php:765
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
LogFormatter\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogFormatter.php:109
LogFormatter\$linkFlood
bool $linkFlood
Whether to output user tool links.
Definition: LogFormatter.php:92
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:544
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:22
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
Message
The Message class provides methods which fulfil two basic services:
Definition: Message.php:159
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:1455
LogFormatter\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:705
LogFormatter\$irctext
string $irctext
Definition: LogFormatter.php:104
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LogFormatter.php:905
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
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:25
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:473
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
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:133
LogFormatter\$context
IContextSource $context
Context for logging.
Definition: LogFormatter.php:89
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:494
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:482
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:641
$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:57
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
$type
$type
Definition: testCompression.php:48