[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> Message.php (summary)

Fetching and processing of interface messages. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Author: Niklas Laxström
File Size: 1106 lines (28 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

Message:: (46 methods):
  __construct()
  isMultiKey()
  getKeysToTry()
  getKey()
  getParams()
  getFormat()
  getLanguage()
  newFromKey()
  newFallbackSequence()
  params()
  rawParams()
  numParams()
  durationParams()
  expiryParams()
  timeperiodParams()
  sizeParams()
  bitrateParams()
  setContext()
  inLanguage()
  inContentLanguage()
  setInterfaceMessageFlag()
  useDatabase()
  title()
  content()
  toString()
  __toString()
  parse()
  text()
  plain()
  parseAsBlock()
  escaped()
  exists()
  isBlank()
  isDisabled()
  rawParam()
  numParam()
  durationParam()
  expiryParam()
  timeperiodParam()
  sizeParam()
  bitrateParam()
  replaceParameters()
  extractParam()
  parseText()
  transformText()
  fetchMessage()

RawMessage:: (2 methods):
  __construct()
  fetchMessage()


Class: Message  - X-Ref

The Message class provides methods which fulfil two basic services:
- fetching interface messages
- processing messages 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.
__construct( $key, $params = array()   X-Ref

param: string|string[] $key Message key or array of message keys to try and use the first
param: array $params Message parameters.
param: Language $language Optional language of the message, defaults to $wgLang.

isMultiKey()   X-Ref

return: bool True if this is a multi-key message, that is, if the key provided to the

getKeysToTry()   X-Ref

return: string[] The list of keys to try when fetching the message text,

getKey()   X-Ref
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 ahs been fetched, this method will return
the key that was actually used to fetch the message.

return: string

getParams()   X-Ref
Returns the message parameters.

return: array

getFormat()   X-Ref
Returns the message format.

return: string

getLanguage()   X-Ref
Returns the Language of the Message.

return: Language

newFromKey( $key )   X-Ref
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.

param: string|string[] $key Message key or array of keys.
param: mixed $param,... Parameters as strings.
return: Message

newFallbackSequence( )   X-Ref
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.

param: string|string[] $keys,... Message keys, or first argument as an array of all the
return: Message

params( )   X-Ref
Adds parameters to the parameter list of this message.

param: mixed $params,... Parameters as strings, or a single argument that is
return: Message $this

rawParams( )   X-Ref
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.

param: mixed $params,... Raw parameters as strings, or a single argument that is
return: Message $this

numParams( )   X-Ref
Add parameters that are numeric and will be passed through
Language::formatNum before substitution

param: mixed $param,... Numeric parameters, or a single argument that is
return: Message $this

durationParams( )   X-Ref
Add parameters that are durations of time and will be passed through
Language::formatDuration before substitution

param: int|int[] $param,... Duration parameters, or a single argument that is
return: Message $this

expiryParams( )   X-Ref
Add parameters that are expiration times and will be passed through
Language::formatExpiry before substitution

param: string|string[] $param,... Expiry parameters, or a single argument that is
return: Message $this

timeperiodParams( )   X-Ref
Add parameters that are time periods and will be passed through
Language::formatTimePeriod before substitution

param: int|int[] $param,... Time period parameters, or a single argument that is
return: Message $this

sizeParams( )   X-Ref
Add parameters that are file sizes and will be passed through
Language::formatSize before substitution

param: int|int[] $param,... Size parameters, or a single argument that is
return: Message $this

bitrateParams( )   X-Ref
Add parameters that are bitrates and will be passed through
Language::formatBitrate before substitution

param: int|int[] $param,... Bit rate parameters, or a single argument that is
return: Message $this

setContext( IContextSource $context )   X-Ref
Set the language and the title from a context object

param: IContextSource $context
return: Message $this

inLanguage( $lang )   X-Ref
Request the message in any language that is supported.
As a side effect interface message status is unconditionally
turned off.

param: Language|string $lang Language code or Language object.
return: Message $this

inContentLanguage()   X-Ref
Request the message in the wiki's content language,
unless it is disabled for this message.

return: Message $this

setInterfaceMessageFlag( $interface )   X-Ref
Allows manipulating the interface message flag directly.
Can be used to restore the flag after setting a language.

param: bool $interface
return: Message $this

useDatabase( $useDatabase )   X-Ref
Enable or disable database use.

param: bool $useDatabase
return: Message $this

title( $title )   X-Ref
Set the Title object to use as context when transforming the message

param: Title $title
return: Message $this

content()   X-Ref
Returns the message as a Content object.

return: Content

toString()   X-Ref
Returns the message parsed from wikitext to HTML.

return: string HTML

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

return: string

parse()   X-Ref
Fully parse the text from wikitext to HTML.

return: string Parsed HTML.

text()   X-Ref
Returns the message text. {{-transformation is done.

return: string Unescaped message text.

plain()   X-Ref
Returns the message text as-is, only parameters are substituted.

return: string Unescaped untransformed message text.

parseAsBlock()   X-Ref
Returns the parsed message text which is always surrounded by a block element.

return: string HTML

escaped()   X-Ref
Returns the message text. {{-transformation is done and the result
is escaped excluding any raw parameters.

return: string Escaped message text.

exists()   X-Ref
Check whether a message key has been defined currently.

return: bool

isBlank()   X-Ref
Check whether a message does not exist, or is an empty string

return: bool

isDisabled()   X-Ref
Check whether a message does not exist, is an empty string, or is "-".

return: bool

rawParam( $raw )   X-Ref

param: mixed $raw
return: array Array with a single "raw" key.

numParam( $num )   X-Ref

param: mixed $num
return: array Array with a single "num" key.

durationParam( $duration )   X-Ref

param: int $duration
return: int[] Array with a single "duration" key.

expiryParam( $expiry )   X-Ref

param: string $expiry
return: string[] Array with a single "expiry" key.

timeperiodParam( $period )   X-Ref

param: number $period
return: number[] Array with a single "period" key.

sizeParam( $size )   X-Ref

param: int $size
return: int[] Array with a single "size" key.

bitrateParam( $bitrate )   X-Ref

param: int $bitrate
return: int[] Array with a single "bitrate" key.

replaceParameters( $message, $type = 'before' )   X-Ref
Substitutes any parameters into the message text.

param: string $message The message text.
param: string $type Either "before" or "after".
return: string

extractParam( $param )   X-Ref
Extracts the parameter type and preprocessed the value if needed.

param: mixed $param Parameter as defined in this class.
return: array Array with the parameter type (either "before" or "after") and the value.

parseText( $string )   X-Ref
Wrapper for what ever method we use to parse wikitext.

param: string $string Wikitext message contents.
return: string Wikitext parsed into HTML.

transformText( $string )   X-Ref
Wrapper for what ever method we use to {{-transform wikitext.

param: string $string Wikitext message contents.
return: string Wikitext with {{-constructs replaced with their values.

fetchMessage()   X-Ref
Wrapper for what ever method we use to get message contents.

return: string

Class: RawMessage  - X-Ref

Variant of the Message class.

Rather than treating the message key as a lookup
value (which is passed to the MessageCache and
translated as necessary), a RawMessage key is
treated as the actual message.

All other functionality (parsing, escaping, etc.)
is preserved.

__construct( $text, $params = array()   X-Ref
Call the parent constructor, then store the key as
the message.

param: string $text Message to use.
param: array $params Parameters for the message.

fetchMessage()   X-Ref
Fetch the message (in this case, the key).

return: string



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1