MediaWiki REL1_31
LogFormatter.php
Go to the documentation of this file.
1<?php
27
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] ) ) {
58 } elseif ( isset( $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
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
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'] )
290 ->inContentLanguage()
291 ->escaped();
292 break;
293 case 'unprotect':
294 $text = wfMessage( 'unprotectedarticle' )
295 ->rawParams( $target )->inContentLanguage()->escaped();
296 break;
297 case 'modify':
298 $text = wfMessage( 'modifiedarticleprotection' )
299 ->rawParams( $target . ' ' . $parameters['4::description'] )
300 ->inContentLanguage()
301 ->escaped();
302 break;
303 case 'move_prot':
304 $text = wfMessage( 'movedarticleprotection' )
305 ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
306 break;
307 }
308 break;
309
310 case 'newusers':
311 switch ( $entry->getSubtype() ) {
312 case 'newusers':
313 case 'create':
314 $text = wfMessage( 'newuserlog-create-entry' )
315 ->inContentLanguage()->escaped();
316 break;
317 case 'create2':
318 case 'byemail':
319 $text = wfMessage( 'newuserlog-create2-entry' )
320 ->rawParams( $target )->inContentLanguage()->escaped();
321 break;
322 case 'autocreate':
323 $text = wfMessage( 'newuserlog-autocreate-entry' )
324 ->inContentLanguage()->escaped();
325 break;
326 }
327 break;
328
329 case 'upload':
330 switch ( $entry->getSubtype() ) {
331 case 'upload':
332 $text = wfMessage( 'uploadedimage' )
333 ->rawParams( $target )->inContentLanguage()->escaped();
334 break;
335 case 'overwrite':
336 $text = wfMessage( 'overwroteimage' )
337 ->rawParams( $target )->inContentLanguage()->escaped();
338 break;
339 }
340 break;
341
342 case 'rights':
343 if ( count( $parameters['4::oldgroups'] ) ) {
344 $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
345 } else {
346 $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
347 }
348 if ( count( $parameters['5::newgroups'] ) ) {
349 $newgroups = implode( ', ', $parameters['5::newgroups'] );
350 } else {
351 $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
352 }
353 switch ( $entry->getSubtype() ) {
354 case 'rights':
355 $text = wfMessage( 'rightslogentry' )
356 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
357 break;
358 case 'autopromote':
359 $text = wfMessage( 'rightslogentry-autopromote' )
360 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
361 break;
362 }
363 break;
364
365 case 'merge':
366 $text = wfMessage( 'pagemerge-logentry' )
367 ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
368 ->inContentLanguage()->escaped();
369 break;
370
371 case 'block':
372 switch ( $entry->getSubtype() ) {
373 case 'block':
374 // Keep compatibility with extensions by checking for
375 // new key (5::duration/6::flags) or old key (0/optional 1)
376 if ( $entry->isLegacy() ) {
377 $rawDuration = $parameters[0];
378 $rawFlags = isset( $parameters[1] ) ? $parameters[1] : '';
379 } else {
380 $rawDuration = $parameters['5::duration'];
381 $rawFlags = $parameters['6::flags'];
382 }
383 $duration = $wgContLang->translateBlockExpiry(
384 $rawDuration,
385 null,
386 wfTimestamp( TS_UNIX, $entry->getTimestamp() )
387 );
389 $text = wfMessage( 'blocklogentry' )
390 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
391 break;
392 case 'unblock':
393 $text = wfMessage( 'unblocklogentry' )
394 ->rawParams( $target )->inContentLanguage()->escaped();
395 break;
396 case 'reblock':
397 $duration = $wgContLang->translateBlockExpiry(
398 $parameters['5::duration'],
399 null,
400 wfTimestamp( TS_UNIX, $entry->getTimestamp() )
401 );
402 $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang );
403 $text = wfMessage( 'reblock-logentry' )
404 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
405 break;
406 }
407 break;
408
409 case 'import':
410 switch ( $entry->getSubtype() ) {
411 case 'upload':
412 $text = wfMessage( 'import-logentry-upload' )
413 ->rawParams( $target )->inContentLanguage()->escaped();
414 break;
415 case 'interwiki':
416 $text = wfMessage( 'import-logentry-interwiki' )
417 ->rawParams( $target )->inContentLanguage()->escaped();
418 break;
419 }
420 break;
421 // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
422 // default:
423 }
424 if ( is_null( $text ) ) {
425 $text = $this->getPlainActionText();
426 }
427
428 $this->plaintext = false;
429 $this->irctext = false;
430
431 return $text;
432 }
433
438 public function getActionText() {
439 if ( $this->canView( LogPage::DELETED_ACTION ) ) {
440 $element = $this->getActionMessage();
441 if ( $element instanceof Message ) {
442 $element = $this->plaintext ? $element->text() : $element->escaped();
443 }
444 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
445 $element = $this->styleRestricedElement( $element );
446 }
447 } else {
448 $sep = $this->msg( 'word-separator' );
449 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
450 $performer = $this->getPerformerElement();
451 $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
452 }
453
454 return $element;
455 }
456
463 protected function getActionMessage() {
464 $message = $this->msg( $this->getMessageKey() );
465 $message->params( $this->getMessageParameters() );
466
467 return $message;
468 }
469
477 protected function getMessageKey() {
478 $type = $this->entry->getType();
479 $subtype = $this->entry->getSubtype();
480
481 return "logentry-$type-$subtype";
482 }
483
489 public function getActionLinks() {
490 return '';
491 }
492
498 protected function extractParameters() {
500 $params = [];
501
502 if ( $entry->isLegacy() ) {
503 foreach ( $entry->getParameters() as $index => $value ) {
504 $params[$index + 3] = $value;
505 }
506 }
507
508 // Filter out parameters which are not in format #:foo
509 foreach ( $entry->getParameters() as $key => $value ) {
510 if ( strpos( $key, ':' ) === false ) {
511 continue;
512 }
513 list( $index, $type, ) = explode( ':', $key, 3 );
514 if ( ctype_digit( $index ) ) {
515 $params[$index - 1] = $this->formatParameterValue( $type, $value );
516 }
517 }
518
519 /* Message class doesn't like non consecutive numbering.
520 * Fill in missing indexes with empty strings to avoid
521 * incorrect renumbering.
522 */
523 if ( count( $params ) ) {
524 $max = max( array_keys( $params ) );
525 // index 0 to 2 are added in getMessageParameters
526 for ( $i = 3; $i < $max; $i++ ) {
527 if ( !isset( $params[$i] ) ) {
528 $params[$i] = '';
529 }
530 }
531 }
532
533 return $params;
534 }
535
545 protected function getMessageParameters() {
546 if ( isset( $this->parsedParameters ) ) {
547 return $this->parsedParameters;
548 }
549
551 $params = $this->extractParameters();
552 $params[0] = Message::rawParam( $this->getPerformerElement() );
553 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
554 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
555
556 // Bad things happens if the numbers are not in correct order
557 ksort( $params );
558
559 $this->parsedParameters = $params;
560 return $this->parsedParameters;
561 }
562
589 protected function formatParameterValue( $type, $value ) {
590 $saveLinkFlood = $this->linkFlood;
591
592 switch ( strtolower( trim( $type ) ) ) {
593 case 'raw':
594 $value = Message::rawParam( $value );
595 break;
596 case 'list':
597 $value = $this->context->getLanguage()->commaList( $value );
598 break;
599 case 'msg':
600 $value = $this->msg( $value )->text();
601 break;
602 case 'msg-content':
603 $value = $this->msg( $value )->inContentLanguage()->text();
604 break;
605 case 'number':
606 $value = Message::numParam( $value );
607 break;
608 case 'user':
610 $value = $user->getName();
611 break;
612 case 'user-link':
613 $this->setShowUserToolLinks( false );
614
616 $value = Message::rawParam( $this->makeUserLink( $user ) );
617
618 $this->setShowUserToolLinks( $saveLinkFlood );
619 break;
620 case 'title':
621 $title = Title::newFromText( $value );
622 $value = $title->getPrefixedText();
623 break;
624 case 'title-link':
625 $title = Title::newFromText( $value );
626 $value = Message::rawParam( $this->makePageLink( $title ) );
627 break;
628 case 'plain':
629 // Plain text, nothing to do
630 default:
631 // Catch other types and use the old behavior (return as-is)
632 }
633
634 return $value;
635 }
636
645 protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
646 if ( !$title instanceof Title ) {
647 $msg = $this->msg( 'invalidtitle' )->text();
648 if ( !$this->plaintext ) {
649 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
650 } else {
651 return $msg;
652 }
653 }
654
655 if ( !$this->plaintext ) {
656 $html = $html !== null ? new HtmlArmor( $html ) : $html;
657 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
658 } else {
659 $link = '[[' . $title->getPrefixedText() . ']]';
660 }
661
662 return $link;
663 }
664
671 public function getPerformerElement() {
672 if ( $this->canView( LogPage::DELETED_USER ) ) {
673 $performer = $this->entry->getPerformer();
674 $element = $this->makeUserLink( $performer );
675 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
676 $element = $this->styleRestricedElement( $element );
677 }
678 } else {
679 $element = $this->getRestrictedElement( 'rev-deleted-user' );
680 }
681
682 return $element;
683 }
684
689 public function getComment() {
690 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
691 $comment = Linker::commentBlock( $this->entry->getComment() );
692 // No hard coded spaces thanx
693 $element = ltrim( $comment );
694 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
695 $element = $this->styleRestricedElement( $element );
696 }
697 } else {
698 $element = $this->getRestrictedElement( 'rev-deleted-comment' );
699 }
700
701 return $element;
702 }
703
709 protected function getRestrictedElement( $message ) {
710 if ( $this->plaintext ) {
711 return $this->msg( $message )->text();
712 }
713
714 $content = $this->msg( $message )->escaped();
715 $attribs = [ 'class' => 'history-deleted' ];
716
717 return Html::rawElement( 'span', $attribs, $content );
718 }
719
725 protected function styleRestricedElement( $content ) {
726 if ( $this->plaintext ) {
727 return $content;
728 }
729 $attribs = [ 'class' => 'history-deleted' ];
730
731 return Html::rawElement( 'span', $attribs, $content );
732 }
733
739 protected function msg( $key ) {
740 return $this->context->msg( $key );
741 }
742
743 protected function makeUserLink( User $user, $toolFlags = 0 ) {
744 if ( $this->plaintext ) {
745 $element = $user->getName();
746 } else {
747 $element = Linker::userLink(
748 $user->getId(),
749 $user->getName()
750 );
751
752 if ( $this->linkFlood ) {
753 $element .= Linker::userToolLinks(
754 $user->getId(),
755 $user->getName(),
756 true, // redContribsWhenNoEdits
757 $toolFlags,
758 $user->getEditCount()
759 );
760 }
761 }
762
763 return $element;
764 }
765
769 public function getPreloadTitles() {
770 return [];
771 }
772
777 // This function was added because getMessageParameters() is
778 // protected and a change from protected to public caused
779 // problems with extensions
780 return $this->getMessageParameters();
781 }
782
788 protected function getParametersForApi() {
789 return $this->entry->getParameters();
790 }
791
806 public function formatParametersForApi() {
807 $logParams = [];
808 foreach ( $this->getParametersForApi() as $key => $value ) {
809 $vals = explode( ':', $key, 3 );
810 if ( count( $vals ) !== 3 ) {
811 $logParams[$key] = $value;
812 continue;
813 }
814 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
815 }
816 ApiResult::setIndexedTagName( $logParams, 'param' );
817 ApiResult::setArrayType( $logParams, 'assoc' );
818
819 return $logParams;
820 }
821
831 protected function formatParameterValueForApi( $name, $type, $value ) {
832 $type = strtolower( trim( $type ) );
833 switch ( $type ) {
834 case 'bool':
835 $value = (bool)$value;
836 break;
837
838 case 'number':
839 if ( ctype_digit( $value ) || is_int( $value ) ) {
840 $value = (int)$value;
841 } else {
842 $value = (float)$value;
843 }
844 break;
845
846 case 'array':
847 case 'assoc':
848 case 'kvp':
849 if ( is_array( $value ) ) {
851 }
852 break;
853
854 case 'timestamp':
855 $value = wfTimestamp( TS_ISO_8601, $value );
856 break;
857
858 case 'msg':
859 case 'msg-content':
860 $msg = $this->msg( $value );
861 if ( $type === 'msg-content' ) {
862 $msg->inContentLanguage();
863 }
864 $value = [];
865 $value["{$name}_key"] = $msg->getKey();
866 if ( $msg->getParams() ) {
867 $value["{$name}_params"] = $msg->getParams();
868 }
869 $value["{$name}_text"] = $msg->text();
870 return $value;
871
872 case 'title':
873 case 'title-link':
874 $title = Title::newFromText( $value );
875 if ( !$title ) {
876 // Huh? Do something halfway sane.
877 $title = SpecialPage::getTitleFor( 'Badtitle', $value );
878 }
879 $value = [];
881 return $value;
882
883 case 'user':
884 case 'user-link':
886 if ( $user ) {
887 $value = $user->getName();
888 }
889 break;
890
891 default:
892 // do nothing
893 break;
894 }
895
896 return [ $name => $value ];
897 }
898}
899
919 private $comment = null;
920
928 private $revert = null;
929
930 public function getComment() {
931 if ( $this->comment === null ) {
932 $this->comment = parent::getComment();
933 }
934
935 // Make sure we execute the LogLine hook so that we immediately return
936 // the correct value.
937 if ( $this->revert === null ) {
938 $this->getActionLinks();
939 }
940
941 return $this->comment;
942 }
943
944 protected function getActionMessage() {
946 $action = LogPage::actionText(
947 $entry->getType(),
949 $entry->getTarget(),
950 $this->plaintext ? null : $this->context->getSkin(),
952 !$this->plaintext // whether to filter [[]] links
953 );
954
955 $performer = $this->getPerformerElement();
956 if ( !$this->irctext ) {
957 $sep = $this->msg( 'word-separator' );
958 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
959 $action = $performer . $sep . $action;
960 }
961
962 return $action;
963 }
964
965 public function getActionLinks() {
966 if ( $this->revert !== null ) {
967 return $this->revert;
968 }
969
970 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
971 $this->revert = '';
972 return $this->revert;
973 }
974
975 $title = $this->entry->getTarget();
976 $type = $this->entry->getType();
977 $subtype = $this->entry->getSubtype();
978
979 // Do nothing. The implementation is handled by the hook modifiying the
980 // passed-by-ref parameters. This also changes the default value so that
981 // getComment() and getActionLinks() do not call them indefinitely.
982 $this->revert = '';
983
984 // This is to populate the $comment member of this instance so that it
985 // can be modified when calling the hook just below.
986 if ( $this->comment === null ) {
987 $this->getComment();
988 }
989
990 $params = $this->entry->getParameters();
991
992 Hooks::run( 'LogLine', [ $type, $subtype, $title, $params,
993 &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
994
995 return $this->revert;
996 }
997}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static formatBlockFlags( $flags, $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form.
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition LogEntry.php:207
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:28
This class formats all log entries for log types which have not been converted to the new system.
string null $revert
Cache for the result of getActionLinks() so that it does not need to run multiple times depending on ...
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
getActionMessage()
Returns a sentence describing the log action.
getComment()
Gets the user provided comment.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:893
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
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition Linker.php:931
Extends the LogEntryInterface with some basic functionality.
Definition LogEntry.php:115
isLegacy()
Whether the parameters for this log are stored in new or old format.
Definition LogEntry.php:131
getFullType()
The full logtype in format maintype/subtype.
Definition LogEntry.php:117
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Implements the default log formatting.
LogEntryBase $entry
msg( $key)
Shortcut for wfMessage which honors local context.
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
canView( $field)
Check if a log item can be displayed.
bool $linkFlood
Whether to output user tool links.
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
getMessageParametersForTesting()
__construct(LogEntry $entry)
getRestrictedElement( $message)
Helper method for displaying restricted element.
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
getActionMessage()
Returns a sentence describing the log action.
const FOR_THIS_USER
getActionText()
Gets the log action, including username.
getPerformerElement()
Provides the name of the user who performed the log action.
makeUserLink(User $user, $toolFlags=0)
setLinkRenderer(LinkRenderer $linkRenderer)
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
IContextSource $context
Context for logging.
int $audience
Constant for handling log_deleted.
formatParametersForApi()
Format parameters for API output.
LinkRenderer null $linkRenderer
getComment()
Gets the user provided comment.
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
getMessageKey()
Returns a key to be used for formatting the action sentence.
styleRestricedElement( $content)
Helper method for styling restricted element.
setAudience( $audience)
Set the visibility restrictions for displaying content.
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
setContext(IContextSource $context)
Replace the default context.
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
getPlainActionText()
Ugly hack to produce plaintext version of the message.
string $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
extractParameters()
Extracts the optional extra parameters for use in action messages.
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition LogPage.php:221
const DELETED_USER
Definition LogPage.php:34
const DELETED_COMMENT
Definition LogPage.php:33
const DELETED_ACTION
Definition LogPage.php:32
Class that generates HTML links for pages.
MediaWikiServices is the service locator for the application scope of MediaWiki.
The Message class provides methods which fulfil two basic services:
Definition Message.php:159
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:53
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:591
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
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 local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
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
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
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;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3021
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
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
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
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 local account $user
Definition hooks.txt:247
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
Interface for objects which can provide a MediaWiki context on request.
Interface for log entries.
Definition LogEntry.php:38
getParameters()
Get the extra parameters stored for this message.
getTimestamp()
Get the timestamp when the action was executed.
getTarget()
Get the target page of this action.
getSubtype()
The log subtype.
getPerformer()
Get the user for performed this action.
getType()
The main log type.
$params