238 '$params must be empty if $key is a MessageSpecifier'
245 if ( !is_string(
$key ) && !is_array(
$key ) ) {
251 if ( empty( $this->keysToTry ) ) {
255 $this->
key = reset( $this->keysToTry );
257 $this->parameters = array_values(
$params );
270 'interface' => $this->interface,
271 'language' => $this->language ? $this->language->getCode() :
false,
288 $this->
interface = $data['interface'];
289 $this->
key = $data[
'key'];
290 $this->keysToTry = $data[
'keysToTry'];
291 $this->parameters = $data[
'parameters'];
292 $this->
format = $data[
'format'];
294 $this->language = $data[
'language'] ?
Language::factory( $data[
'language'] ) :
false;
295 $this->
title = $data[
'title'];
305 return count( $this->keysToTry ) > 1;
399 if ( is_array(
$value ) ) {
408 } elseif ( is_string(
$value ) ) {
431 $keys = func_get_args();
432 if ( func_num_args() == 1 ) {
433 if ( is_array(
$keys[0] ) ) {
441 return new self(
$keys );
460 $wgContLang->getCode() !==
$code
461 && in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg )
480 $args = func_get_args();
481 if ( isset(
$args[0] ) && is_array(
$args[0] ) ) {
484 $args_values = array_values(
$args );
485 $this->parameters = array_merge( $this->parameters, $args_values );
508 $this->parameters[] = self::rawParam( $param );
530 $this->parameters[] = self::numParam( $param );
552 $this->parameters[] = self::durationParam( $param );
574 $this->parameters[] = self::expiryParam( $param );
596 $this->parameters[] = self::timeperiodParam( $param );
618 $this->parameters[] = self::sizeParam( $param );
640 $this->parameters[] = self::bitrateParam( $param );
664 $this->parameters[] = self::plaintextParam( $param );
681 $this->
interface =
true;
699 $this->language =
$lang;
700 } elseif ( is_string(
$lang ) ) {
701 if ( !$this->language instanceof Language || $this->language->getCode() !=
$lang ) {
705 $this->language =
false;
709 .
"passed a String or Language object; $type given"
713 $this->
interface =
false;
728 if ( in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg ) ) {
748 $this->
interface = (bool)$interface;
803 if ( $string ===
false ) {
804 if ( $this->
format ===
'plain' || $this->
format ===
'text' ) {
805 return '<' . $this->
key .
'>';
807 return '<' . htmlspecialchars( $this->
key ) .
'>';
810 # Replace $* with a list of parameters for &uselang=qqx.
811 if ( strpos( $string,
'$*' ) !==
false ) {
813 if ( $this->parameters !== [] ) {
814 $paramlist =
': $' . implode(
', $', range( 1, count( $this->parameters ) ) );
816 $string = str_replace(
'$*', $paramlist, $string );
819 # Replace parameters before text parsing
822 # Maybe transform using the full parser
823 if ( $this->
format ===
'parse' ) {
826 } elseif ( $this->
format ===
'block-parse' ) {
828 } elseif ( $this->
format ===
'text' ) {
830 } elseif ( $this->
format ===
'escaped' ) {
832 $string = htmlspecialchars( $string, ENT_QUOTES,
'UTF-8',
false );
835 # Raw parameter replacement
858 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
859 . $ex, E_USER_WARNING );
864 if ( $this->
format ===
'plain' || $this->
format ===
'text' ) {
865 return '<' . $this->
key .
'>';
867 return '<' . htmlspecialchars( $this->
key ) .
'>';
915 $this->
format =
'block-parse';
928 $this->
format =
'escaped';
976 return [
'raw' => $raw ];
987 return [
'num' => $num ];
998 return [
'duration' => $duration ];
1009 return [
'expiry' => $expiry ];
1020 return [
'period' => $period ];
1031 return [
'size' => $size ];
1042 return [
'bitrate' => $bitrate ];
1053 return [
'plaintext' => $plaintext ];
1067 $replacementKeys = [];
1068 foreach ( $this->parameters
as $n => $param ) {
1070 if (
$type === $paramType ) {
1071 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1088 if ( is_array( $param ) ) {
1089 if ( isset( $param[
'raw'] ) ) {
1090 return [
'after', $param[
'raw'] ];
1091 } elseif ( isset( $param[
'num'] ) ) {
1094 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1095 } elseif ( isset( $param[
'duration'] ) ) {
1096 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1097 } elseif ( isset( $param[
'expiry'] ) ) {
1098 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1099 } elseif ( isset( $param[
'period'] ) ) {
1100 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1101 } elseif ( isset( $param[
'size'] ) ) {
1102 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1103 } elseif ( isset( $param[
'bitrate'] ) ) {
1104 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1105 } elseif ( isset( $param[
'plaintext'] ) ) {
1108 $warning =
'Invalid parameter for message "' . $this->
getKey() .
'": ' .
1109 htmlspecialchars(
serialize( $param ) );
1110 trigger_error( $warning, E_USER_WARNING );
1112 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1114 return [
'before',
'[INVALID]' ];
1116 } elseif ( $param instanceof
Message ) {
1120 return [
'after', $param->toString() ];
1122 return [
'before', $param ];
1174 if ( $this->
message === null ) {
1177 foreach ( $this->keysToTry
as $key ) {
1204 switch ( $this->
format ) {
1213 return htmlspecialchars( $plaintext, ENT_QUOTES );
1246 if ( !is_string( $text ) ) {
1250 parent::__construct( $text,
$params );
1263 if ( $this->
message === null ) {
getKey()
Returns the message key.
string[] $keysToTry
List of keys to try when fetching the message.
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
Interface for objects which can provide a MediaWiki context on request.
static plaintextParam($plaintext)
isBlank()
Check whether a message does not exist, or is an empty string.
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 $out
the array() calling protocol came about after MediaWiki 1.4rc1.
durationParams()
Add parameters that are durations of time and will be passed through Language::formatDuration before ...
transformText($string)
Wrapper for what ever method we use to {{-transform wikitext.
title($title)
Set the Title object to use as context when transforming the message.
static durationParam($duration)
bool $useDatabase
Whether database can be used.
Content $content
Content object representing the message.
Title $title
Title object to use as context.
formatPlaintext($plaintext)
Formats a message parameter wrapped with 'plaintext'.
rawParams()
Add parameters that are substituted after parsing or escaping.
setInterfaceMessageFlag($interface)
Allows manipulating the interface message flag directly.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
string $format
Format for the message.
static expiryParam($expiry)
Wrapper allowing us to handle a system message as a Content object.
if(!isset($args[0])) $lang
processing should stop and the error should be shown to the user * false
toString()
Returns the message parsed from wikitext to HTML.
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 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 message
Language bool $language
In which language to get this message.
text()
Returns the message text.
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
getFormat()
Returns the message format.
when a variable name is used in a it is silently declared as a new local masking the global
content()
Returns the message as a Content object.
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 true
getParams()
Returns the message parameters.
static timeperiodParam($period)
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
fetchMessage()
Fetch the message (in this case, the key).
static getMain()
Static methods.
static stripOuterParagraph($html)
Strip outer.
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 in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
parseText($string)
Wrapper for what ever method we use to parse wikitext.
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
inLanguage($lang)
Request the message in any language that is supported.
string $key
The message key.
array $parameters
List of parameters which will be substituted into the message.
params()
Adds parameters to the parameter list of this message.
setContext(IContextSource $context)
Set the language and the title from a context object.
extractParam($param)
Extracts the parameter type and preprocessed the value if needed.
getLanguage()
Returns the Language of the Message.
getLanguage()
Get the Language object.
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
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 & $code
parse()
Fully parse the text from wikitext to HTML.
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
replaceParameters($message, $type= 'before')
Substitutes any parameters into the message text.
exists()
Check whether a message key has been defined currently.
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution...
static newFromKey($key)
Factory function that is just wrapper for the real constructor.
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
sizeParams()
Add parameters that are file sizes and will be passed through Language::formatSize before substitutio...
Variant of the Message class.
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
Stub object for the user language.
getTitle()
Get a title object for a mediawiki message, where it can be found in the mediawiki namespace...
__construct($text, $params=[])
Call the parent constructor, then store the key as the message.
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated...
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
__construct($key, $params=[], Language $language=null)
getTitle()
Get the Title object.
useDatabase($useDatabase)
Enable or disable database use.
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
plain()
Returns the message text as-is, only parameters are substituted.
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message...
fetchMessage()
Wrapper for what ever method we use to get message contents.
escaped()
Returns the message text.
foreach($res as $row) $serialized
static factory($code)
Get a cached or new language object for a given language code.
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
static bitrateParam($bitrate)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static singleton()
Get the signleton instance of this class.
if the prop value should be in the metadata multi language array format
bool $interface
In which language to get this message.
static newFromSpecifier($value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...