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;
400 if ( is_array(
$value ) ) {
409 } elseif ( is_string(
$value ) ) {
432 $keys = func_get_args();
433 if ( func_num_args() == 1 ) {
434 if ( is_array(
$keys[0] ) ) {
442 return new self(
$keys );
460 !$this->language->equals( $wgContLang )
461 && in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg )
463 $code = $this->language->getCode();
481 $args = func_get_args();
482 if ( isset(
$args[0] ) && is_array(
$args[0] ) ) {
485 $args_values = array_values(
$args );
486 $this->parameters = array_merge( $this->parameters, $args_values );
509 $this->parameters[] = self::rawParam( $param );
531 $this->parameters[] = self::numParam( $param );
553 $this->parameters[] = self::durationParam( $param );
575 $this->parameters[] = self::expiryParam( $param );
597 $this->parameters[] = self::timeperiodParam( $param );
619 $this->parameters[] = self::sizeParam( $param );
641 $this->parameters[] = self::bitrateParam( $param );
665 $this->parameters[] = self::plaintextParam( $param );
682 $this->
interface =
true;
700 $this->language =
$lang;
701 } elseif ( is_string(
$lang ) ) {
702 if ( !$this->language instanceof Language || $this->language->getCode() !=
$lang ) {
706 $this->language =
false;
710 .
"passed a String or Language object; $type given"
714 $this->
interface =
false;
729 if ( in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg ) ) {
749 $this->
interface = (bool)$interface;
804 if ( $string ===
false ) {
811 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
814 # Replace $* with a list of parameters for &uselang=qqx.
815 if ( strpos( $string,
'$*' ) !==
false ) {
817 if ( $this->parameters !== [] ) {
818 $paramlist =
': $' . implode(
', $', range( 1, count( $this->parameters ) ) );
820 $string = str_replace(
'$*', $paramlist, $string );
823 # Replace parameters before text parsing
826 # Maybe transform using the full parser
827 if ( $this->
format ===
'parse' ) {
830 } elseif ( $this->
format ===
'block-parse' ) {
832 } elseif ( $this->
format ===
'text' ) {
834 } elseif ( $this->
format ===
'escaped' ) {
836 $string = htmlspecialchars( $string, ENT_QUOTES,
'UTF-8',
false );
839 # Raw parameter replacement
855 if ( $this->
format !==
'parse' ) {
868 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
869 . $ex, E_USER_WARNING );
874 if ( $this->
format ===
'plain' || $this->
format ===
'text' ) {
875 return '<' . $this->
key .
'>';
877 return '<' . htmlspecialchars( $this->
key ) .
'>';
925 $this->
format =
'block-parse';
938 $this->
format =
'escaped';
986 return [
'raw' => $raw ];
997 return [
'num' => $num ];
1008 return [
'duration' => $duration ];
1019 return [
'expiry' => $expiry ];
1030 return [
'period' => $period ];
1041 return [
'size' => $size ];
1052 return [
'bitrate' => $bitrate ];
1063 return [
'plaintext' => $plaintext ];
1077 $replacementKeys = [];
1078 foreach ( $this->parameters
as $n => $param ) {
1080 if (
$type === $paramType ) {
1081 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1098 if ( is_array( $param ) ) {
1099 if ( isset( $param[
'raw'] ) ) {
1100 return [
'after', $param[
'raw'] ];
1101 } elseif ( isset( $param[
'num'] ) ) {
1104 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1105 } elseif ( isset( $param[
'duration'] ) ) {
1106 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1107 } elseif ( isset( $param[
'expiry'] ) ) {
1108 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1109 } elseif ( isset( $param[
'period'] ) ) {
1110 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1111 } elseif ( isset( $param[
'size'] ) ) {
1112 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1113 } elseif ( isset( $param[
'bitrate'] ) ) {
1114 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1115 } elseif ( isset( $param[
'plaintext'] ) ) {
1118 $warning =
'Invalid parameter for message "' . $this->
getKey() .
'": ' .
1119 htmlspecialchars(
serialize( $param ) );
1120 trigger_error( $warning, E_USER_WARNING );
1122 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1124 return [
'before',
'[INVALID]' ];
1126 } elseif ( $param instanceof
Message ) {
1130 return [
'after', $param->toString() ];
1132 return [
'before', $param ];
1184 if ( $this->
message === null ) {
1187 foreach ( $this->keysToTry
as $key ) {
1214 switch ( $this->
format ) {
1223 return htmlspecialchars( $plaintext, ENT_QUOTES );
1256 if ( !is_string( $text ) ) {
1260 parent::__construct( $text,
$params );
1273 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'.
processing should stop and the error should be shown to the user * false
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
toString()
Returns the message parsed from wikitext to HTML.
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).
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 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
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...