Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Formatters\AutoCommentFormatter Class Reference

Formatter for machine-readable autocomments as generated by SummaryFormatter in the repo. More...

Public Member Functions

 __construct (Language $language, array $messagePrefixes)
 
 formatAutoComment ( $auto)
 Pretty formatting of autocomments.
 
 wrapAutoComment ( $pre, $comment, $post)
 Wraps a comment by applying the appropriate directionality markers and pre and/or postfix separators.
 

Private Member Functions

 getSummaryMessage ( $name)
 Gets the summary message.
 

Private Attributes

 $language
 
 $messagePrefixes
 
 $messages = []
 

Detailed Description

Formatter for machine-readable autocomments as generated by SummaryFormatter in the repo.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\AutoCommentFormatter::__construct ( Language $language,
array $messagePrefixes )
Parameters
Language$language
string[]$messagePrefixesPrefixes to try when constructing the message key from the name given in the autocomment block. Typically something like [ 'wikibase-item', 'wikibase-entity' ].

Member Function Documentation

◆ formatAutoComment()

Wikibase\Lib\Formatters\AutoCommentFormatter::formatAutoComment ( $auto)

Pretty formatting of autocomments.

Warning
This method is used to parse and format autocomment strings from the revision history. It should remain compatible with any old autocomment strings that may be in the database.
See also
https://www.mediawiki.org/wiki/Manual:Hooks/FormatAutocomments
Summaries
Parameters
string$autothe autocomment unformatted
Returns
string|null The localized summary (HTML), or null

◆ getSummaryMessage()

Wikibase\Lib\Formatters\AutoCommentFormatter::getSummaryMessage ( $name)
private

Gets the summary message.

Parameters
string$name
Returns
Message|false

◆ wrapAutoComment()

Wikibase\Lib\Formatters\AutoCommentFormatter::wrapAutoComment ( $pre,
$comment,
$post )

Wraps a comment by applying the appropriate directionality markers and pre and/or postfix separators.

Note
This code should be kept in sync with what MediaWiki\CommentFormatter\CommentParser::doSectionLinks does.
Parameters
bool$preTrue if there is text before the comment, so a prefix separator is needed.
string$commentthe localized comment, as returned by formatAutoComment()
bool$postTrue if there is text after the comment, so a postfix separator is needed.
Returns
string

Member Data Documentation

◆ $language

Wikibase\Lib\Formatters\AutoCommentFormatter::$language
private

◆ $messagePrefixes

Wikibase\Lib\Formatters\AutoCommentFormatter::$messagePrefixes
private

◆ $messages

Wikibase\Lib\Formatters\AutoCommentFormatter::$messages = []
private

The documentation for this class was generated from the following file: