MediaWiki REL1_37
Message Class Reference

The Message class deals with fetching and processing of interface message into a variety of formats. More...

Inheritance diagram for Message:
Collaboration diagram for Message:

Public Member Functions

 __construct ( $key, $params=[], Language $language=null)
 
 __serialize ()
 
 __toString ()
 Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $key ); $string = "<abbr>$foo</abbr>";.
 
 __unserialize ( $data)
 
 bitrateParams (... $params)
 Add parameters that are bitrates and will be passed through Language::formatBitrate before substitution.
 
 content ()
 Returns the message as a Content object.
 
 dateParams (... $params)
 Add parameters that are dates and will be passed through Language::date before substitution.
 
 dateTimeParams (... $params)
 Add parameters that are date-times and will be passed through Language::timeanddate before substitution.
 
 durationParams (... $params)
 Add parameters that are durations of time and will be passed through Language::formatDuration before substitution.
 
 escaped ()
 Returns the message text.
 
 exists ()
 Check whether a message key has been defined currently.
 
 expiryParams (... $params)
 Add parameters that are expiration times and will be passed through Language::formatExpiry before substitution.
 
 getKey ()
 Returns the message key.
 
 getKeysToTry ()
 
 getLanguage ()
 Returns the Language of the Message.
 
 getParams ()
 Returns the message parameters.
 
 getTitle ()
 Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.
 
 inContentLanguage ()
 Request the message in the wiki's content language, unless it is disabled for this message.
 
 inLanguage ( $lang)
 Request the message in any language that is supported.
 
 isBlank ()
 Check whether a message does not exist, or is an empty string.
 
 isDisabled ()
 Check whether a message does not exist, is an empty string, or is "-".
 
 isMultiKey ()
 
 numParams (... $params)
 Add parameters that are numeric and will be passed through Language::formatNum before substitution.
 
 page (?PageReference $page)
 Set the page object to use as context when transforming the message.
 
 params (... $args)
 Adds parameters to the parameter list of this message.
 
 parse ()
 Fully parse the text from wikitext to HTML.
 
 parseAsBlock ()
 Returns the parsed message text which is always surrounded by a block element.
 
 plain ()
 Returns the message text as-is, only parameters are substituted.
 
 plaintextParams (... $params)
 Add parameters that are plaintext and will be passed through without the content being evaluated.
 
 rawParams (... $params)
 Add parameters that are substituted after parsing or escaping.
 
 serialize ()
 
 setContext (IContextSource $context)
 Set the language and the title from a context object.
 
 setInterfaceMessageFlag ( $interface)
 Allows manipulating the interface message flag directly.
 
 sizeParams (... $params)
 Add parameters that are file sizes and will be passed through Language::formatSize before substitution.
 
 text ()
 Returns the message text.
 
 timeParams (... $params)
 Add parameters that are times and will be passed through Language::time before substitution.
 
 timeperiodParams (... $params)
 Add parameters that are time periods and will be passed through Language::formatTimePeriod before substitution.
 
 title ( $title)
 Set the Title object to use as context when transforming the message.
 
 toString (string $format)
 Returns the message formatted a certain way.
 
 unserialize ( $serialized)
 
 useDatabase ( $useDatabase)
 Enable or disable database use.
 

Static Public Member Functions

static bitrateParam ( $bitrate)
 
static dateParam (string $date)
 
static dateTimeParam (string $dateTime)
 
static durationParam ( $duration)
 
static expiryParam ( $expiry)
 
static listParam (array $list, $type='text')
 
static newFallbackSequence (... $keys)
 Factory function accepting multiple message keys and returning a message instance for the first message which is non-empty.
 
static newFromKey ( $key,... $params)
 Factory function that is just wrapper for the real constructor.
 
static newFromSpecifier ( $value)
 Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key string, or a key + params array) into a proper Message.
 
static numParam ( $num)
 
static plaintextParam ( $plaintext)
 
static rawParam ( $raw)
 
static sizeParam ( $size)
 
static timeParam (string $time)
 
static timeperiodParam ( $period)
 

Public Attributes

const FORMAT_BLOCK_PARSE = 'block-parse'
 Use normal wikitext -> HTML parsing (the result will be wrapped in a block-level HTML tag)
 
const FORMAT_ESCAPED = 'escaped'
 Transform {{..}} constructs, HTML-escape the result.
 
const FORMAT_PARSE = 'parse'
 Use normal wikitext -> HTML parsing but strip the block-level wrapper.
 
const FORMAT_PLAIN = 'plain'
 Use message text as-is.
 
const FORMAT_TEXT = 'text'
 Transform {{..}} constructs but don't transform to HTML.
 

Protected Member Functions

 extractParam ( $param, $format)
 Extracts the parameter type and preprocessed the value if needed.
 
 fetchMessage ()
 Wrapper for what ever method we use to get message contents.
 
 formatListParam (array $params, $listType, $format)
 Formats a list of parameters as a concatenated string.
 
 formatPlaintext ( $plaintext, $format)
 Formats a message parameter wrapped with 'plaintext'.
 
 parseText ( $string)
 Wrapper for what ever method we use to parse wikitext.
 
 replaceParameters ( $message, $type, $format)
 Substitutes any parameters into the message text.
 
 transformText ( $string)
 Wrapper for what ever method we use to {{-transform wikitext.
 

Protected Attributes

Content $content = null
 Content object representing the message.
 
PageReference $contextPage = null
 page object to use as context.
 
bool $interface = true
 In which language to get this message.
 
string $key
 The message key.
 
string[] $keysToTry
 List of keys to try when fetching the message.
 
Language bool $language = false
 In which language to get this message.
 
string $message
 
array $parameters = []
 List of parameters which will be substituted into the message.
 
bool $useDatabase = true
 Whether database can be used.
 

Static Protected Attributes

static array $listTypeMap
 Mapping from Message::listParam() types to Language methods.
 

Private Member Functions

 format (string $format)
 Returns the message formatted a certain way.
 

Detailed Description

The Message class deals with fetching and processing of interface message into a variety of formats.

First implemented with MediaWiki 1.17, the Message class is intended to replace the old wfMsg* functions that over time grew unusable.

See also
https://www.mediawiki.org/wiki/Manual:Messages_API for equivalences between old and new functions.

The preferred way to create Message objects is via the msg() method of of an available RequestContext and ResourceLoaderContext object; this will ensure that the message uses the correct language. When that is not possible, the wfMessage() global function can be used, which will cause Message to get the language from the global RequestContext object. In rare circumstances when sessions are not available or not initialized, that can lead to errors.

The most basic usage cases would be:

// Initialize a Message object using the 'some_key' message key
$message = $context->msg( 'some_key' );
// Using two parameters those values are strings 'value1' and 'value2':
$message = $context->msg( 'some_key',
'value1', 'value2'
);
string $message
Definition Message.php:210

Global function wrapper:

Since msg() returns a Message instance, you can chain its call with a method. Some of them return a Message instance too so you can chain them. You will find below several examples of msg() usage.

Fetching a message text for interface message:

$button = Xml::button(
$context->msg( 'submit' )->text()
);

A Message instance can be passed parameters after it has been constructed, use the params() method to do so:

$context->msg( 'welcome-to' )
->params( $wgSitename )
->text();
$wgSitename
Name of the site.

{{GRAMMAR}} and friends work correctly:

$context->msg( 'are-friends',
$user, $friend
);
$context->msg( 'bad-message' )
->rawParams( '<script>...</script>' )
->escaped();

Changing language:

Messages can be requested in a different language or in whatever current content language is being used. The methods are:

Sometimes the message text ends up in the database, so content language is needed:

wfMessage( 'file-log',
$user, $filename
)->inContentLanguage()->text();
wfMessage( $key,... $params)
This is the function for getting translated interface messages.

Checking whether a message exists:

$context->msg( 'mysterious-message' )->exists()
// returns a boolean whether the 'mysterious-message' key exist.

If you want to use a different language:

$userLanguage = $user->getOption( 'language' );
wfMessage( 'email-header' )
->inLanguage( $userLanguage )
->plain();
Note
You can parse the text only in the content or interface languages

Appendix:

Todo:
  • test, can we have tests?
  • this documentation needs to be extended
See also
https://www.mediawiki.org/wiki/WfMessage()
https://www.mediawiki.org/wiki/New_messages_API
https://www.mediawiki.org/wiki/Localisation
Since
1.17 @newable

Definition at line 138 of file Message.php.

Constructor & Destructor Documentation

◆ __construct()

Message::__construct (   $key,
  $params = [],
Language  $language = null 
)
Stability: stable
to call
Since
1.17
Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of message keys to try and use the first non-empty message for, or a MessageSpecifier to copy from.
array$paramsMessage parameters.
Language | null$language[optional] Language to use (defaults to current user language).
Exceptions
InvalidArgumentException

Definition at line 222 of file Message.php.

References $key, and $language.

Member Function Documentation

◆ __serialize()

Message::__serialize ( )
See also
Serializable::serialize()
Since
1.37.2
Returns
array

Definition at line 265 of file Message.php.

◆ __toString()

Message::__toString ( )

Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $key ); $string = "<abbr>$foo</abbr>";.

Since
1.18
Returns
string

Definition at line 972 of file Message.php.

◆ __unserialize()

Message::__unserialize (   $data)
See also
Serializable::unserialize()
Since
1.26
Parameters
array$data

Definition at line 297 of file Message.php.

◆ bitrateParam()

static Message::bitrateParam (   $bitrate)
static
Since
1.22
Parameters
int$bitrate
Returns
int[] Array with a single "bitrate" key.

Definition at line 1189 of file Message.php.

◆ bitrateParams()

Message::bitrateParams (   $params)

Add parameters that are bitrates and will be passed through Language::formatBitrate before substitution.

Since
1.22
Parameters
int|int[]...$params Bit rate parameters, or a single argument that is an array of bit rate parameters.
Returns
Message $this

Definition at line 722 of file Message.php.

◆ content()

Message::content ( )

Returns the message as a Content object.

Returns
Content

Definition at line 892 of file Message.php.

References $content.

◆ dateParam()

static Message::dateParam ( string  $date)
static
Since
1.36
Parameters
string$date
Returns
string[] Array with a single "date" key.

Definition at line 1145 of file Message.php.

◆ dateParams()

Message::dateParams (   $params)

Add parameters that are dates and will be passed through Language::date before substitution.

Since
1.36
Parameters
string|string[]...$params Date parameters, or a single argument that is an array of date parameters.
Returns
Message $this

Definition at line 638 of file Message.php.

◆ dateTimeParam()

static Message::dateTimeParam ( string  $dateTime)
static
Since
1.36
Parameters
string$dateTime
Returns
string[] Array with a single "datetime" key.

Definition at line 1134 of file Message.php.

◆ dateTimeParams()

Message::dateTimeParams (   $params)

Add parameters that are date-times and will be passed through Language::timeanddate before substitution.

Since
1.36
Parameters
string|string[]...$params Date-time parameters, or a single argument that is an array of date-time parameters.
Returns
Message $this

Definition at line 617 of file Message.php.

◆ durationParam()

static Message::durationParam (   $duration)
static
Since
1.22
Parameters
int$duration
Returns
int[] Array with a single "duration" key.

Definition at line 1112 of file Message.php.

◆ durationParams()

Message::durationParams (   $params)

Add parameters that are durations of time and will be passed through Language::formatDuration before substitution.

Since
1.22
Parameters
int|int[]...$params Duration parameters, or a single argument that is an array of duration parameters.
Returns
Message $this

Definition at line 575 of file Message.php.

◆ escaped()

Message::escaped ( )

Returns the message text.

{{-transformation is done and the result is escaped excluding any raw parameters.

Since
1.17
Returns
string Escaped message text.

Definition at line 1042 of file Message.php.

Referenced by MediaWiki\Search\SearchWidgets\BasicSearchResultSetWidget\header().

◆ exists()

Message::exists ( )

Check whether a message key has been defined currently.

Since
1.17
Returns
bool

Definition at line 1053 of file Message.php.

◆ expiryParam()

static Message::expiryParam (   $expiry)
static
Since
1.22
Parameters
string$expiry
Returns
string[] Array with a single "expiry" key.

Definition at line 1123 of file Message.php.

◆ expiryParams()

Message::expiryParams (   $params)

Add parameters that are expiration times and will be passed through Language::formatExpiry before substitution.

Since
1.22
Parameters
string|string[]...$params Expiry parameters, or a single argument that is an array of expiry parameters.
Returns
Message $this

Definition at line 596 of file Message.php.

◆ extractParam()

Message::extractParam (   $param,
  $format 
)
protected

Extracts the parameter type and preprocessed the value if needed.

Since
1.18
Parameters
mixed$paramParameter as defined in this class.
string$formatOne of the FORMAT_* constants.
Returns
array Array with the parameter type (either "before" or "after") and the value.

Definition at line 1268 of file Message.php.

References serialize().

◆ fetchMessage()

Message::fetchMessage ( )
protected

Wrapper for what ever method we use to get message contents.

Since
1.17
Returns
string
Exceptions
MWExceptionIf message key array is empty.

Reimplemented in ApiHelpParamValueMessage, and RawMessage.

Definition at line 1390 of file Message.php.

References $cache.

◆ format()

Message::format ( string  $format)
private

Returns the message formatted a certain way.

Parameters
string$formatOne of the FORMAT_* constants.
Returns
string Text or HTML

Definition at line 918 of file Message.php.

◆ formatListParam()

Message::formatListParam ( array  $params,
  $listType,
  $format 
)
protected

Formats a list of parameters as a concatenated string.

Since
1.29
Parameters
array$params
string$listType
string$formatOne of the FORMAT_* constants.
Returns
array Array with the parameter type (either "before" or "after") and the value.

Definition at line 1443 of file Message.php.

References $type, serialize(), and wfDebugLog().

◆ formatPlaintext()

Message::formatPlaintext (   $plaintext,
  $format 
)
protected

Formats a message parameter wrapped with 'plaintext'.

Ensures that the entire string is displayed unchanged when displayed in the output format.

Since
1.25
Parameters
string$plaintextString to ensure plaintext output of
string$formatOne of the FORMAT_* constants.
Returns
string Input plaintext encoded for output to $format

Definition at line 1421 of file Message.php.

◆ getKey()

Message::getKey ( )

Returns the message key.

If a list of multiple possible keys was supplied to the constructor, this method may return any of these keys. After the message has been fetched, this method will return the key that was actually used to fetch the message.

Since
1.21
Returns
string

Implements MessageSpecifier.

Definition at line 357 of file Message.php.

Referenced by MediaWiki\Message\Converter\convertMessage(), CommentStore\encodeMessage(), and ApiAuthManagerHelper\formatMessage().

◆ getKeysToTry()

Message::getKeysToTry ( )
Since
1.24
Returns
string[] The list of keys to try when fetching the message text, in order of preference.

Definition at line 342 of file Message.php.

Referenced by CommentStore\encodeMessage().

◆ getLanguage()

Message::getLanguage ( )

Returns the Language of the Message.

Since
1.23
Returns
Language

Definition at line 379 of file Message.php.

Referenced by TransformTooBigImageAreaError\__construct().

◆ getParams()

Message::getParams ( )

Returns the message parameters.

Since
1.21
Returns
array

Implements MessageSpecifier.

Definition at line 368 of file Message.php.

Referenced by MediaWiki\Message\Converter\convertMessage(), CommentStore\encodeMessage(), and ApiAuthManagerHelper\formatMessage().

◆ getTitle()

Message::getTitle ( )

Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.

The title will be for the current language, if the message key is in $wgForceUIMsgAsContentMsg it will be append with the language code (except content language), because Message::inContentLanguage will also return in user language.

See also
$wgForceUIMsgAsContentMsg
Returns
Title
Since
1.26

Definition at line 471 of file Message.php.

References $lang, $title, $wgForceUIMsgAsContentMsg, and NS_MEDIAWIKI.

◆ inContentLanguage()

Message::inContentLanguage ( )

Request the message in the wiki's content language, unless it is disabled for this message.

Since
1.17
See also
$wgForceUIMsgAsContentMsg
Returns
Message $this

Definition at line 819 of file Message.php.

References $wgForceUIMsgAsContentMsg.

◆ inLanguage()

Message::inLanguage (   $lang)

Request the message in any language that is supported.

As a side effect interface message status is unconditionally turned off.

Since
1.17
Parameters
Language | StubUserLang | string$langLanguage code or Language object.
Returns
Message $this
Exceptions
MWException

Definition at line 783 of file Message.php.

References $lang, $type, and Language\getCode().

Referenced by Status\msgInLang(), and CommentStoreComment\newUnsavedComment().

◆ isBlank()

Message::isBlank ( )

Check whether a message does not exist, or is an empty string.

Since
1.18
Todo:
FIXME: Merge with isDisabled()?
Returns
bool

Definition at line 1065 of file Message.php.

◆ isDisabled()

Message::isDisabled ( )

Check whether a message does not exist, is an empty string, or is "-".

Since
1.18
Returns
bool

Definition at line 1077 of file Message.php.

◆ isMultiKey()

Message::isMultiKey ( )
Since
1.24
Returns
bool True if this is a multi-key message, that is, if the key provided to the constructor was a fallback list of keys to try.

Definition at line 332 of file Message.php.

◆ listParam()

static Message::listParam ( array  $list,
  $type = 'text' 
)
static

◆ newFallbackSequence()

static Message::newFallbackSequence (   $keys)
static

Factory function accepting multiple message keys and returning a message instance for the first message which is non-empty.

If all messages are empty then an instance of the first message key is returned.

Since
1.18
Parameters
string|string[]...$keys Message keys, or first argument as an array of all the message keys.
-taint$keystainted
Returns
Message

Definition at line 448 of file Message.php.

References $keys.

Referenced by wfMessageFallback().

◆ newFromKey()

static Message::newFromKey (   $key,
  $params 
)
static

Factory function that is just wrapper for the real constructor.

It is intended to be used instead of the real constructor, because it allows chaining method calls, while new objects don't.

Since
1.17
Parameters
string | string[] | MessageSpecifier$key
mixed...$params Parameters as strings.
Returns
Message

Definition at line 396 of file Message.php.

Referenced by MediaWiki\Auth\ButtonAuthenticationRequest\__set_state().

◆ newFromSpecifier()

static Message::newFromSpecifier (   $value)
static

Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key string, or a key + params array) into a proper Message.

Also accepts a MessageSpecifier inside an array: that's not considered a valid format but is an easy error to make due to how StatusValue stores messages internally. Further array elements are ignored in that case.

Parameters
string | array | MessageSpecifier$value
-taint$valuetainted
Returns
Message
Exceptions
InvalidArgumentException
Since
1.27

Definition at line 414 of file Message.php.

Referenced by PermissionsError\__construct(), ApiMain\errorMessagesFromException(), PasswordReset\execute(), ApiLogin\formatMessage(), MWExceptionRenderer\getCustomMessage(), HTMLForm\getMessage(), HTMLFormField\getMessage(), ApiErrorFormatter\getMessageFromException(), LocalizedException\getMessageObject(), and UploadStashException\getMessageObject().

◆ numParam()

◆ numParams()

Message::numParams (   $params)

Add parameters that are numeric and will be passed through Language::formatNum before substitution.

Since
1.18
Parameters
mixed...$params Numeric parameters, or a single argument that is an array of numeric parameters.
Returns
Message $this

Definition at line 554 of file Message.php.

◆ page()

Message::page ( ?PageReference  $page)

Set the page object to use as context when transforming the message.

Since
1.37
Parameters
?PageReference$page
Returns
Message $this

Definition at line 882 of file Message.php.

◆ params()

Message::params (   $args)

Adds parameters to the parameter list of this message.

Since
1.17
Parameters
mixed...$args Parameters as strings or arrays from Message::numParam() and the like, or a single array of parameters.
Returns
Message $this

Definition at line 498 of file Message.php.

References $args.

Referenced by TransformTooBigImageAreaError\__construct().

◆ parse()

Message::parse ( )

Fully parse the text from wikitext to HTML.

Since
1.17
Returns
string Parsed HTML.

Definition at line 997 of file Message.php.

Referenced by ApiHelp\wrap().

◆ parseAsBlock()

Message::parseAsBlock ( )

Returns the parsed message text which is always surrounded by a block element.

Since
1.17
Returns
string HTML

Definition at line 1030 of file Message.php.

◆ parseText()

Message::parseText (   $string)
protected

Wrapper for what ever method we use to parse wikitext.

Since
1.17
Parameters
string$stringWikitext message contents.
Returns
string Wikitext parsed into HTML.

Definition at line 1343 of file Message.php.

References ParserOutput\getText().

◆ plain()

Message::plain ( )

Returns the message text as-is, only parameters are substituted.

Since
1.17
Returns
string Unescaped untransformed message text.

Definition at line 1019 of file Message.php.

◆ plaintextParam()

static Message::plaintextParam (   $plaintext)
static
Since
1.25
Parameters
string$plaintext
Returns
string[] Array with a single "plaintext" key.

Definition at line 1200 of file Message.php.

Referenced by CommentStoreComment\__construct(), ContentModelChange\createNewContent(), ApiEditPage\execute(), EditPage\initialiseForm(), and ChangeTags\tagShortDescriptionMessage().

◆ plaintextParams()

Message::plaintextParams (   $params)

Add parameters that are plaintext and will be passed through without the content being evaluated.

Plaintext parameters are not valid as arguments to parser functions. This differs from self::rawParams in that the Message class handles escaping to match the output format.

Since
1.25
Parameters
string|string[]...$params plaintext parameters, or a single argument that is an array of plaintext parameters.
Returns
Message $this

Definition at line 745 of file Message.php.

◆ rawParam()

◆ rawParams()

Message::rawParams (   $params)

Add parameters that are substituted after parsing or escaping.

In other words the parsing process cannot access the contents of this type of parameter, and you need to make sure it is sanitized beforehand. The parser will see "$n", instead.

Since
1.17
Parameters
mixed...$params Raw parameters as strings, or a single argument that is an array of raw parameters.
Returns
Message $this

Definition at line 533 of file Message.php.

◆ replaceParameters()

Message::replaceParameters (   $message,
  $type,
  $format 
)
protected

Substitutes any parameters into the message text.

Since
1.17
Parameters
string$messageThe message text.
string$typeEither "before" or "after".
string$formatOne of the FORMAT_* constants.
Returns
string

Definition at line 1231 of file Message.php.

References $type.

◆ serialize()

Message::serialize ( )
See also
Serializable::serialize()
Since
1.26
Returns
string

Definition at line 256 of file Message.php.

◆ setContext()

Message::setContext ( IContextSource  $context)

Set the language and the title from a context object.

Since
1.19
Parameters
IContextSource$context
Returns
Message $this

Definition at line 764 of file Message.php.

References IContextSource\getLanguage(), IContextSource\getTitle(), and true.

Referenced by ApiAuthManagerHelper\formatMessage().

◆ setInterfaceMessageFlag()

Message::setInterfaceMessageFlag (   $interface)

Allows manipulating the interface message flag directly.

Can be used to restore the flag after setting a language.

Since
1.20
Parameters
bool$interface
Returns
Message $this

Definition at line 839 of file Message.php.

◆ sizeParam()

static Message::sizeParam (   $size)
static
Since
1.22
Parameters
int$size
Returns
int[] Array with a single "size" key.

Definition at line 1178 of file Message.php.

Referenced by UploadBase\checkFileSize().

◆ sizeParams()

Message::sizeParams (   $params)

Add parameters that are file sizes and will be passed through Language::formatSize before substitution.

Since
1.22
Parameters
int|int[]...$params Size parameters, or a single argument that is an array of size parameters.
Returns
Message $this

Definition at line 701 of file Message.php.

◆ text()

Message::text ( )

Returns the message text.

{{-transformation is done.

Since
1.17
Returns
string Unescaped message text.

Definition at line 1008 of file Message.php.

Referenced by HttpError\doLog().

◆ timeParam()

static Message::timeParam ( string  $time)
static
Since
1.36
Parameters
string$time
Returns
string[] Array with a single "time" key.

Definition at line 1156 of file Message.php.

◆ timeParams()

Message::timeParams (   $params)

Add parameters that are times and will be passed through Language::time before substitution.

Since
1.36
Parameters
string|string[]...$params Time parameters, or a single argument that is an array of time parameters.
Returns
Message $this

Definition at line 659 of file Message.php.

◆ timeperiodParam()

static Message::timeperiodParam (   $period)
static
Since
1.22
Parameters
int$period
Returns
int[] Array with a single "period" key.

Definition at line 1167 of file Message.php.

◆ timeperiodParams()

Message::timeperiodParams (   $params)

Add parameters that are time periods and will be passed through Language::formatTimePeriod before substitution.

Since
1.22
Parameters
int|int[]...$params Time period parameters, or a single argument that is an array of time period parameters.
Returns
Message $this

Definition at line 680 of file Message.php.

◆ title()

Message::title (   $title)

Set the Title object to use as context when transforming the message.

Since
1.18
Deprecated:
since 1.37. Use page instead
Parameters
Title$title
Returns
Message $this

Definition at line 869 of file Message.php.

References $title.

◆ toString()

Message::toString ( string  $format)

Returns the message formatted a certain way.

Since
1.17
Parameters
string$formatOne of the FORMAT_* constants.
Returns
string Text or HTML

Definition at line 907 of file Message.php.

◆ transformText()

Message::transformText (   $string)
protected

Wrapper for what ever method we use to {{-transform wikitext.

Since
1.17
Parameters
string$stringWikitext message contents.
Returns
string Wikitext with {{-constructs replaced with their values.

Definition at line 1373 of file Message.php.

◆ unserialize()

Message::unserialize (   $serialized)
See also
Serializable::unserialize()
Since
1.37.2
Parameters
string$serialized

Definition at line 288 of file Message.php.

◆ useDatabase()

Message::useDatabase (   $useDatabase)

Enable or disable database use.

Since
1.17
Parameters
bool$useDatabase
Returns
Message $this

Definition at line 853 of file Message.php.

Member Data Documentation

◆ $content

Content Message::$content = null
protected

Content object representing the message.

Definition at line 205 of file Message.php.

◆ $contextPage

PageReference Message::$contextPage = null
protected

page object to use as context.

Definition at line 200 of file Message.php.

Referenced by ApiHelpParamValueMessage\subMessage().

◆ $interface

bool Message::$interface = true
protected

In which language to get this message.

True, which is the default, means the current user language, false content language.

Definition at line 167 of file Message.php.

Referenced by ApiHelpParamValueMessage\subMessage().

◆ $key

string Message::$key
protected

The message key.

If $keysToTry has more than one element, this may change to one of the keys to try when fetching the message text.

Definition at line 180 of file Message.php.

Referenced by __construct(), ApiMessage\__construct(), ApiRawMessage\__construct(), and ApiHelpParamValueMessage\subMessage().

◆ $keysToTry

string [] Message::$keysToTry
protected

List of keys to try when fetching the message.

Definition at line 185 of file Message.php.

◆ $language

Language bool Message::$language = false
protected

In which language to get this message.

Overrides the $interface setting.

Explicit language object, or false for user language

Definition at line 174 of file Message.php.

Referenced by __construct(), and ApiHelpParamValueMessage\subMessage().

◆ $listTypeMap

array Message::$listTypeMap
staticprotected
Initial value:
= [
'comma' => 'commaList',
'semicolon' => 'semicolonList',
'pipe' => 'pipeList',
'text' => 'listToText',
]

Mapping from Message::listParam() types to Language methods.

Definition at line 154 of file Message.php.

◆ $message

string Message::$message
protected

Definition at line 210 of file Message.php.

Referenced by ApiHelpParamValueMessage\fetchMessage().

◆ $parameters

array Message::$parameters = []
protected

List of parameters which will be substituted into the message.

Definition at line 190 of file Message.php.

◆ $useDatabase

bool Message::$useDatabase = true
protected

Whether database can be used.

Definition at line 195 of file Message.php.

Referenced by ApiHelpParamValueMessage\subMessage().

◆ FORMAT_BLOCK_PARSE

const Message::FORMAT_BLOCK_PARSE = 'block-parse'

Use normal wikitext -> HTML parsing (the result will be wrapped in a block-level HTML tag)

Definition at line 142 of file Message.php.

◆ FORMAT_ESCAPED

const Message::FORMAT_ESCAPED = 'escaped'

Transform {{..}} constructs, HTML-escape the result.

Definition at line 148 of file Message.php.

◆ FORMAT_PARSE

const Message::FORMAT_PARSE = 'parse'

Use normal wikitext -> HTML parsing but strip the block-level wrapper.

Definition at line 144 of file Message.php.

◆ FORMAT_PLAIN

const Message::FORMAT_PLAIN = 'plain'

Use message text as-is.

Definition at line 140 of file Message.php.

◆ FORMAT_TEXT

const Message::FORMAT_TEXT = 'text'

Transform {{..}} constructs but don't transform to HTML.

Definition at line 146 of file Message.php.


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