MediaWiki REL1_32
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
116
117 protected function __construct( LogEntry $entry ) {
118 $this->entry = $entry;
119 $this->context = RequestContext::getMain();
120 }
121
126 public function setContext( IContextSource $context ) {
127 $this->context = $context;
128 }
129
135 $this->linkRenderer = $linkRenderer;
136 }
137
142 public function getLinkRenderer() {
143 if ( $this->linkRenderer !== null ) {
144 return $this->linkRenderer;
145 } else {
146 return MediaWikiServices::getInstance()->getLinkRenderer();
147 }
148 }
149
156 public function setAudience( $audience ) {
157 $this->audience = ( $audience == self::FOR_THIS_USER )
158 ? self::FOR_THIS_USER
160 }
161
167 protected function canView( $field ) {
168 if ( $this->audience == self::FOR_THIS_USER ) {
170 $this->entry->getDeleted(), $field, $this->context->getUser() );
171 } else {
172 return !$this->entry->isDeleted( $field );
173 }
174 }
175
182 public function setShowUserToolLinks( $value ) {
183 $this->linkFlood = $value;
184 }
185
194 public function getPlainActionText() {
195 $this->plaintext = true;
196 $text = $this->getActionText();
197 $this->plaintext = false;
198
199 return $text;
200 }
201
208 public function getIRCActionComment() {
209 $actionComment = $this->getIRCActionText();
210 $comment = $this->entry->getComment();
211
212 if ( $comment != '' ) {
213 if ( $actionComment == '' ) {
214 $actionComment = $comment;
215 } else {
216 $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
217 }
218 }
219
220 return $actionComment;
221 }
222
229 public function getIRCActionText() {
230 $this->plaintext = true;
231 $this->irctext = true;
232
234 $parameters = $entry->getParameters();
235 // @see LogPage::actionText()
236 // Text of title the action is aimed at.
237 $target = $entry->getTarget()->getPrefixedText();
238 $text = null;
239 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
240 switch ( $entry->getType() ) {
241 case 'move':
242 switch ( $entry->getSubtype() ) {
243 case 'move':
244 $movesource = $parameters['4::target'];
245 $text = wfMessage( '1movedto2' )
246 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
247 break;
248 case 'move_redir':
249 $movesource = $parameters['4::target'];
250 $text = wfMessage( '1movedto2_redir' )
251 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
252 break;
253 case 'move-noredirect':
254 break;
255 case 'move_redir-noredirect':
256 break;
257 }
258 break;
259
260 case 'delete':
261 switch ( $entry->getSubtype() ) {
262 case 'delete':
263 $text = wfMessage( 'deletedarticle' )
264 ->rawParams( $target )->inContentLanguage()->escaped();
265 break;
266 case 'restore':
267 $text = wfMessage( 'undeletedarticle' )
268 ->rawParams( $target )->inContentLanguage()->escaped();
269 break;
270 //case 'revision': // Revision deletion
271 //case 'event': // Log deletion
272 // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
273 //default:
274 }
275 break;
276
277 case 'patrol':
278 // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
279 // Create a diff link to the patrolled revision
280 if ( $entry->getSubtype() === 'patrol' ) {
281 $diffLink = htmlspecialchars(
282 wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
283 ->inContentLanguage()->text() );
284 $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
285 ->inContentLanguage()->text();
286 } else {
287 // broken??
288 }
289 break;
290
291 case 'protect':
292 switch ( $entry->getSubtype() ) {
293 case 'protect':
294 $text = wfMessage( 'protectedarticle' )
295 ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
296 break;
297 case 'unprotect':
298 $text = wfMessage( 'unprotectedarticle' )
299 ->rawParams( $target )->inContentLanguage()->escaped();
300 break;
301 case 'modify':
302 $text = wfMessage( 'modifiedarticleprotection' )
303 ->rawParams( $target . ' ' . $parameters['4::description'] )->inContentLanguage()->escaped();
304 break;
305 case 'move_prot':
306 $text = wfMessage( 'movedarticleprotection' )
307 ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
308 break;
309 }
310 break;
311
312 case 'newusers':
313 switch ( $entry->getSubtype() ) {
314 case 'newusers':
315 case 'create':
316 $text = wfMessage( 'newuserlog-create-entry' )
317 ->inContentLanguage()->escaped();
318 break;
319 case 'create2':
320 case 'byemail':
321 $text = wfMessage( 'newuserlog-create2-entry' )
322 ->rawParams( $target )->inContentLanguage()->escaped();
323 break;
324 case 'autocreate':
325 $text = wfMessage( 'newuserlog-autocreate-entry' )
326 ->inContentLanguage()->escaped();
327 break;
328 }
329 break;
330
331 case 'upload':
332 switch ( $entry->getSubtype() ) {
333 case 'upload':
334 $text = wfMessage( 'uploadedimage' )
335 ->rawParams( $target )->inContentLanguage()->escaped();
336 break;
337 case 'overwrite':
338 $text = wfMessage( 'overwroteimage' )
339 ->rawParams( $target )->inContentLanguage()->escaped();
340 break;
341 }
342 break;
343
344 case 'rights':
345 if ( count( $parameters['4::oldgroups'] ) ) {
346 $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
347 } else {
348 $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
349 }
350 if ( count( $parameters['5::newgroups'] ) ) {
351 $newgroups = implode( ', ', $parameters['5::newgroups'] );
352 } else {
353 $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
354 }
355 switch ( $entry->getSubtype() ) {
356 case 'rights':
357 $text = wfMessage( 'rightslogentry' )
358 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
359 break;
360 case 'autopromote':
361 $text = wfMessage( 'rightslogentry-autopromote' )
362 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
363 break;
364 }
365 break;
366
367 case 'merge':
368 $text = wfMessage( 'pagemerge-logentry' )
369 ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
370 ->inContentLanguage()->escaped();
371 break;
372
373 case 'block':
374 switch ( $entry->getSubtype() ) {
375 case 'block':
376 // Keep compatibility with extensions by checking for
377 // new key (5::duration/6::flags) or old key (0/optional 1)
378 if ( $entry->isLegacy() ) {
379 $rawDuration = $parameters[0];
380 $rawFlags = $parameters[1] ?? '';
381 } else {
382 $rawDuration = $parameters['5::duration'];
383 $rawFlags = $parameters['6::flags'];
384 }
385 $duration = $contLang->translateBlockExpiry(
386 $rawDuration,
387 null,
388 wfTimestamp( TS_UNIX, $entry->getTimestamp() )
389 );
390 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
391 $text = wfMessage( 'blocklogentry' )
392 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
393 break;
394 case 'unblock':
395 $text = wfMessage( 'unblocklogentry' )
396 ->rawParams( $target )->inContentLanguage()->escaped();
397 break;
398 case 'reblock':
399 $duration = $contLang->translateBlockExpiry(
400 $parameters['5::duration'],
401 null,
402 wfTimestamp( TS_UNIX, $entry->getTimestamp() )
403 );
404 $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
405 $contLang );
406 $text = wfMessage( 'reblock-logentry' )
407 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
408 break;
409 }
410 break;
411
412 case 'import':
413 switch ( $entry->getSubtype() ) {
414 case 'upload':
415 $text = wfMessage( 'import-logentry-upload' )
416 ->rawParams( $target )->inContentLanguage()->escaped();
417 break;
418 case 'interwiki':
419 $text = wfMessage( 'import-logentry-interwiki' )
420 ->rawParams( $target )->inContentLanguage()->escaped();
421 break;
422 }
423 break;
424 // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
425 // default:
426 }
427 if ( is_null( $text ) ) {
428 $text = $this->getPlainActionText();
429 }
430
431 $this->plaintext = false;
432 $this->irctext = false;
433
434 return $text;
435 }
436
443 public function getActionText() {
444 if ( $this->canView( LogPage::DELETED_ACTION ) ) {
445 $element = $this->getActionMessage();
446 if ( $element instanceof Message ) {
447 $element = $this->plaintext ? $element->text() : $element->escaped();
448 }
449 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
450 $element = $this->styleRestricedElement( $element );
451 }
452 } else {
453 $sep = $this->msg( 'word-separator' );
454 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
455 $performer = $this->getPerformerElement();
456 $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
457 }
458
459 return $element;
460 }
461
468 protected function getActionMessage() {
469 $message = $this->msg( $this->getMessageKey() );
470 $message->params( $this->getMessageParameters() );
471
472 return $message;
473 }
474
482 protected function getMessageKey() {
483 $type = $this->entry->getType();
484 $subtype = $this->entry->getSubtype();
485
486 return "logentry-$type-$subtype";
487 }
488
494 public function getActionLinks() {
495 return '';
496 }
497
503 protected function extractParameters() {
505 $params = [];
506
507 if ( $entry->isLegacy() ) {
508 foreach ( $entry->getParameters() as $index => $value ) {
509 $params[$index + 3] = $value;
510 }
511 }
512
513 // Filter out parameters which are not in format #:foo
514 foreach ( $entry->getParameters() as $key => $value ) {
515 if ( strpos( $key, ':' ) === false ) {
516 continue;
517 }
518 list( $index, $type, ) = explode( ':', $key, 3 );
519 if ( ctype_digit( $index ) ) {
520 $params[$index - 1] = $this->formatParameterValue( $type, $value );
521 }
522 }
523
524 /* Message class doesn't like non consecutive numbering.
525 * Fill in missing indexes with empty strings to avoid
526 * incorrect renumbering.
527 */
528 if ( count( $params ) ) {
529 $max = max( array_keys( $params ) );
530 // index 0 to 2 are added in getMessageParameters
531 for ( $i = 3; $i < $max; $i++ ) {
532 if ( !isset( $params[$i] ) ) {
533 $params[$i] = '';
534 }
535 }
536 }
537
538 return $params;
539 }
540
550 protected function getMessageParameters() {
551 if ( isset( $this->parsedParameters ) ) {
553 }
554
556 $params = $this->extractParameters();
557 $params[0] = Message::rawParam( $this->getPerformerElement() );
558 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
559 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
560
561 // Bad things happens if the numbers are not in correct order
562 ksort( $params );
563
564 $this->parsedParameters = $params;
566 }
567
594 protected function formatParameterValue( $type, $value ) {
595 $saveLinkFlood = $this->linkFlood;
596
597 switch ( strtolower( trim( $type ) ) ) {
598 case 'raw':
599 $value = Message::rawParam( $value );
600 break;
601 case 'list':
602 $value = $this->context->getLanguage()->commaList( $value );
603 break;
604 case 'msg':
605 $value = $this->msg( $value )->text();
606 break;
607 case 'msg-content':
608 $value = $this->msg( $value )->inContentLanguage()->text();
609 break;
610 case 'number':
611 $value = Message::numParam( $value );
612 break;
613 case 'user':
615 $value = $user->getName();
616 break;
617 case 'user-link':
618 $this->setShowUserToolLinks( false );
619
621 $value = Message::rawParam( $this->makeUserLink( $user ) );
622
623 $this->setShowUserToolLinks( $saveLinkFlood );
624 break;
625 case 'title':
626 $title = Title::newFromText( $value );
627 $value = $title->getPrefixedText();
628 break;
629 case 'title-link':
630 $title = Title::newFromText( $value );
631 $value = Message::rawParam( $this->makePageLink( $title ) );
632 break;
633 case 'plain':
634 // Plain text, nothing to do
635 default:
636 // Catch other types and use the old behavior (return as-is)
637 }
638
639 return $value;
640 }
641
650 protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
651 if ( !$title instanceof Title ) {
652 $msg = $this->msg( 'invalidtitle' )->text();
653 if ( !$this->plaintext ) {
654 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
655 } else {
656 return $msg;
657 }
658 }
659
660 if ( !$this->plaintext ) {
661 $html = $html !== null ? new HtmlArmor( $html ) : $html;
662 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
663 } else {
664 $link = '[[' . $title->getPrefixedText() . ']]';
665 }
666
667 return $link;
668 }
669
676 public function getPerformerElement() {
677 if ( $this->canView( LogPage::DELETED_USER ) ) {
678 $performer = $this->entry->getPerformer();
679 $element = $this->makeUserLink( $performer );
680 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
681 $element = $this->styleRestricedElement( $element );
682 }
683 } else {
684 $element = $this->getRestrictedElement( 'rev-deleted-user' );
685 }
686
687 return $element;
688 }
689
694 public function getComment() {
695 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
696 $comment = Linker::commentBlock( $this->entry->getComment() );
697 // No hard coded spaces thanx
698 $element = ltrim( $comment );
699 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
700 $element = $this->styleRestricedElement( $element );
701 }
702 } else {
703 $element = $this->getRestrictedElement( 'rev-deleted-comment' );
704 }
705
706 return $element;
707 }
708
715 protected function getRestrictedElement( $message ) {
716 if ( $this->plaintext ) {
717 return $this->msg( $message )->text();
718 }
719
720 $content = $this->msg( $message )->escaped();
721 $attribs = [ 'class' => 'history-deleted' ];
722
723 return Html::rawElement( 'span', $attribs, $content );
724 }
725
731 protected function styleRestricedElement( $content ) {
732 if ( $this->plaintext ) {
733 return $content;
734 }
735 $attribs = [ 'class' => 'history-deleted' ];
736
737 return Html::rawElement( 'span', $attribs, $content );
738 }
739
745 protected function msg( $key ) {
746 return $this->context->msg( $key );
747 }
748
755 protected function makeUserLink( User $user, $toolFlags = 0 ) {
756 if ( $this->plaintext ) {
757 $element = $user->getName();
758 } else {
759 $element = Linker::userLink(
760 $user->getId(),
761 $user->getName()
762 );
763
764 if ( $this->linkFlood ) {
765 $element .= Linker::userToolLinks(
766 $user->getId(),
767 $user->getName(),
768 true, // redContribsWhenNoEdits
769 $toolFlags,
770 $user->getEditCount()
771 );
772 }
773 }
774
775 return $element;
776 }
777
781 public function getPreloadTitles() {
782 return [];
783 }
784
789 // This function was added because getMessageParameters() is
790 // protected and a change from protected to public caused
791 // problems with extensions
792 return $this->getMessageParameters();
793 }
794
800 protected function getParametersForApi() {
801 return $this->entry->getParameters();
802 }
803
818 public function formatParametersForApi() {
819 $logParams = [];
820 foreach ( $this->getParametersForApi() as $key => $value ) {
821 $vals = explode( ':', $key, 3 );
822 if ( count( $vals ) !== 3 ) {
823 $logParams[$key] = $value;
824 continue;
825 }
826 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
827 }
828 ApiResult::setIndexedTagName( $logParams, 'param' );
829 ApiResult::setArrayType( $logParams, 'assoc' );
830
831 return $logParams;
832 }
833
843 protected function formatParameterValueForApi( $name, $type, $value ) {
844 $type = strtolower( trim( $type ) );
845 switch ( $type ) {
846 case 'bool':
847 $value = (bool)$value;
848 break;
849
850 case 'number':
851 if ( ctype_digit( $value ) || is_int( $value ) ) {
852 $value = (int)$value;
853 } else {
854 $value = (float)$value;
855 }
856 break;
857
858 case 'array':
859 case 'assoc':
860 case 'kvp':
861 if ( is_array( $value ) ) {
863 }
864 break;
865
866 case 'timestamp':
867 $value = wfTimestamp( TS_ISO_8601, $value );
868 break;
869
870 case 'msg':
871 case 'msg-content':
872 $msg = $this->msg( $value );
873 if ( $type === 'msg-content' ) {
874 $msg->inContentLanguage();
875 }
876 $value = [];
877 $value["{$name}_key"] = $msg->getKey();
878 if ( $msg->getParams() ) {
879 $value["{$name}_params"] = $msg->getParams();
880 }
881 $value["{$name}_text"] = $msg->text();
882 return $value;
883
884 case 'title':
885 case 'title-link':
886 $title = Title::newFromText( $value );
887 if ( !$title ) {
888 // Huh? Do something halfway sane.
889 $title = SpecialPage::getTitleFor( 'Badtitle', $value );
890 }
891 $value = [];
893 return $value;
894
895 case 'user':
896 case 'user-link':
898 if ( $user ) {
899 $value = $user->getName();
900 }
901 break;
902
903 default:
904 // do nothing
905 break;
906 }
907
908 return [ $name => $value ];
909 }
910}
911
931 private $comment = null;
932
940 private $revert = null;
941
942 public function getComment() {
943 if ( $this->comment === null ) {
944 $this->comment = parent::getComment();
945 }
946
947 // Make sure we execute the LogLine hook so that we immediately return
948 // the correct value.
949 if ( $this->revert === null ) {
950 $this->getActionLinks();
951 }
952
953 return $this->comment;
954 }
955
960 protected function getActionMessage() {
962 $action = LogPage::actionText(
963 $entry->getType(),
965 $entry->getTarget(),
966 $this->plaintext ? null : $this->context->getSkin(),
968 !$this->plaintext // whether to filter [[]] links
969 );
970
971 $performer = $this->getPerformerElement();
972 if ( !$this->irctext ) {
973 $sep = $this->msg( 'word-separator' );
974 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
975 $action = $performer . $sep . $action;
976 }
977
978 return $action;
979 }
980
981 public function getActionLinks() {
982 if ( $this->revert !== null ) {
983 return $this->revert;
984 }
985
986 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
987 $this->revert = '';
988 return $this->revert;
989 }
990
991 $title = $this->entry->getTarget();
992 $type = $this->entry->getType();
993 $subtype = $this->entry->getSubtype();
994
995 // Do nothing. The implementation is handled by the hook modifiying the
996 // passed-by-ref parameters. This also changes the default value so that
997 // getComment() and getActionLinks() do not call them indefinitely.
998 $this->revert = '';
999
1000 // This is to populate the $comment member of this instance so that it
1001 // can be modified when calling the hook just below.
1002 if ( $this->comment === null ) {
1003 $this->getComment();
1004 }
1005
1006 $params = $this->entry->getParameters();
1007
1008 Hooks::run( 'LogLine', [ $type, $subtype, $title, $params,
1009 &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
1010
1011 return $this->revert;
1012 }
1013}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$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, Language $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:208
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.
getComment()
Gets the user provided comment.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:876
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:1441
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition Linker.php:914
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.
array $parsedParameters
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:223
const DELETED_USER
Definition LogPage.php:36
const DELETED_COMMENT
Definition LogPage.php:35
const DELETED_ACTION
Definition LogPage.php:34
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:160
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:47
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:592
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 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
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;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:2062
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3106
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:2063
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:933
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.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$content
$params