177 'comma' =>
'commaList',
178 'semicolon' =>
'semicolonList',
179 'pipe' =>
'pipeList',
180 'text' =>
'listToText',
252 throw new InvalidArgumentException(
253 '$params must be empty if $key is a MessageSpecifier'
260 if ( !is_string(
$key ) && !is_array(
$key ) ) {
261 throw new InvalidArgumentException(
'$key must be a string or an array' );
266 if ( empty( $this->keysToTry ) ) {
267 throw new InvalidArgumentException(
'$key must not be an empty list' );
270 $this->
key = reset( $this->keysToTry );
272 $this->parameters = array_values(
$params );
285 'interface' => $this->interface,
286 'language' => $this->language ? $this->language->getCode() :
false,
288 'keysToTry' => $this->keysToTry,
289 'parameters' => $this->parameters,
290 'format' => $this->format,
291 'useDatabase' => $this->useDatabase,
292 'title' => $this->title,
303 $this->
interface = $data['interface'];
304 $this->
key = $data[
'key'];
305 $this->keysToTry = $data[
'keysToTry'];
306 $this->parameters = $data[
'parameters'];
307 $this->
format = $data[
'format'];
309 $this->language = $data[
'language'] ? Language::factory( $data[
'language'] ) :
false;
310 $this->
title = $data[
'title'];
320 return count( $this->keysToTry ) > 1;
330 return $this->keysToTry;
356 return $this->parameters;
369 return $this->format;
381 return $this->language ?: RequestContext::getMain()->getLanguage();
417 if ( is_array(
$value ) ) {
426 } elseif ( is_string(
$value ) ) {
429 throw new InvalidArgumentException( __METHOD__ .
': invalid argument type '
449 $keys = func_get_args();
450 if ( func_num_args() == 1 ) {
451 if ( is_array(
$keys[0] ) ) {
459 return new self(
$keys );
475 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
479 !
$lang->equals( $contLang )
480 && in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg )
485 return Title::makeTitle(
500 $args = func_get_args();
506 if ( count(
$args ) === 1 && isset(
$args[0] ) && is_array(
$args[0] ) ) {
507 if (
$args[0] === [] ) {
511 if ( is_int(
$key ) ) {
519 $this->parameters = array_merge( $this->parameters, array_values(
$args ) );
542 $this->parameters[] = self::rawParam( $param );
564 $this->parameters[] = self::numParam( $param );
586 $this->parameters[] = self::durationParam( $param );
608 $this->parameters[] = self::expiryParam( $param );
630 $this->parameters[] = self::timeperiodParam( $param );
652 $this->parameters[] = self::sizeParam( $param );
674 $this->parameters[] = self::bitrateParam( $param );
698 $this->parameters[] = self::plaintextParam( $param );
715 $this->
interface =
true;
732 $previousLanguage = $this->language;
735 $this->language =
$lang;
736 } elseif ( is_string(
$lang ) ) {
738 $this->language = Language::factory(
$lang );
741 $this->language =
false;
745 .
"passed a String or Language object; $type given"
749 if ( $this->language !== $previousLanguage ) {
753 $this->
interface =
false;
768 if ( in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg ) ) {
772 $this->
inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
787 $this->
interface = (bool)$interface;
846 $ex =
new LogicException( __METHOD__ .
' using implicit format: ' . $this->
format );
847 \MediaWiki\Logger\LoggerFactory::getInstance(
'message-format' )->warning(
848 $ex->getMessage(), [
'exception' => $ex,
'format' => $this->format,
'key' => $this->key ] );
853 if ( $string ===
false ) {
861 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
864 # Replace $* with a list of parameters for &uselang=qqx.
865 if ( strpos( $string,
'$*' ) !==
false ) {
867 if ( $this->parameters !== [] ) {
868 $paramlist =
': $' . implode(
', $', range( 1, count( $this->parameters ) ) );
870 $string = str_replace(
'$*', $paramlist, $string );
873 # Replace parameters before text parsing
876 # Maybe transform using the full parser
877 if (
$format === self::FORMAT_PARSE ) {
879 $string = Parser::stripOuterParagraph( $string );
880 } elseif (
$format === self::FORMAT_BLOCK_PARSE ) {
882 } elseif (
$format === self::FORMAT_TEXT ) {
884 } elseif (
$format === self::FORMAT_ESCAPED ) {
886 $string = htmlspecialchars( $string, ENT_QUOTES,
'UTF-8',
false );
889 # Raw parameter replacement
909 return $this->
toString( self::FORMAT_PARSE );
910 }
catch ( Exception $ex ) {
912 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
913 . $ex, E_USER_WARNING );
914 }
catch ( Exception $ex ) {
918 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
930 $this->
format = self::FORMAT_PARSE;
931 return $this->
toString( self::FORMAT_PARSE );
942 $this->
format = self::FORMAT_TEXT;
943 return $this->
toString( self::FORMAT_TEXT );
954 $this->
format = self::FORMAT_PLAIN;
955 return $this->
toString( self::FORMAT_PLAIN );
966 $this->
format = self::FORMAT_BLOCK_PARSE;
967 return $this->
toString( self::FORMAT_BLOCK_PARSE );
979 $this->
format = self::FORMAT_ESCAPED;
980 return $this->
toString( self::FORMAT_ESCAPED );
1027 return [
'raw' => $raw ];
1038 return [
'num' => $num ];
1049 return [
'duration' => $duration ];
1060 return [
'expiry' => $expiry ];
1071 return [
'period' => $period ];
1082 return [
'size' => $size ];
1093 return [
'bitrate' => $bitrate ];
1104 return [
'plaintext' => $plaintext ];
1115 if ( !isset( self::$listTypeMap[
$type] ) ) {
1116 throw new InvalidArgumentException(
1117 "Invalid type '$type'. Known types are: " . implode(
', ', array_keys( self::$listTypeMap ) )
1120 return [
'list' => $list,
'type' =>
$type ];
1139 $marker =
$format === self::FORMAT_ESCAPED ?
'$' :
'$\'"';
1140 $replacementKeys = [];
1141 foreach ( $this->parameters
as $n => $param ) {
1143 if (
$type ===
'before' ) {
1144 if ( $paramType ===
'before' ) {
1145 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1152 $replacementKeys[
'$' . ( $n + 1 )] = $marker . ( $n + 1 );
1155 if ( $paramType ===
'after' ) {
1156 $replacementKeys[$marker . ( $n + 1 )] =
$value;
1175 if ( is_array( $param ) ) {
1176 if ( isset( $param[
'raw'] ) ) {
1177 return [
'after', $param[
'raw'] ];
1178 } elseif ( isset( $param[
'num'] ) ) {
1181 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1182 } elseif ( isset( $param[
'duration'] ) ) {
1183 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1184 } elseif ( isset( $param[
'expiry'] ) ) {
1185 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1186 } elseif ( isset( $param[
'period'] ) ) {
1187 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1188 } elseif ( isset( $param[
'size'] ) ) {
1189 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1190 } elseif ( isset( $param[
'bitrate'] ) ) {
1191 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1192 } elseif ( isset( $param[
'plaintext'] ) ) {
1194 } elseif ( isset( $param[
'list'] ) ) {
1197 if ( !is_scalar( $param ) ) {
1200 \MediaWiki\Logger\LoggerFactory::getInstance(
'Bug58676' )->warning(
1201 'Invalid parameter for message "{msgkey}": {param}',
1203 'exception' =>
new Exception,
1204 'msgkey' => $this->
getKey(),
1205 'param' => htmlspecialchars( $param ),
1209 return [
'before',
'[INVALID]' ];
1211 } elseif ( $param instanceof
Message ) {
1213 $msg = clone $param;
1214 if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1216 $msg->message =
null;
1218 $msg->interface = $this->interface;
1219 $msg->language = $this->language;
1220 $msg->useDatabase = $this->useDatabase;
1221 $msg->title = $this->title;
1224 if (
$format ===
'block-parse' ) {
1232 return [
'after', $msg->toString(
$format ) ];
1234 return [
'before', $param ];
1248 $out = MessageCache::singleton()->parse(
1258 'enableSectionEditLinks' =>
false,
1278 return MessageCache::singleton()->transform(
1295 if ( $this->
message ===
null ) {
1296 $cache = MessageCache::singleton();
1298 foreach ( $this->keysToTry
as $key ) {
1310 return $this->message;
1327 case self::FORMAT_TEXT:
1328 case self::FORMAT_PLAIN:
1331 case self::FORMAT_PARSE:
1332 case self::FORMAT_BLOCK_PARSE:
1333 case self::FORMAT_ESCAPED:
1335 return htmlspecialchars( $plaintext, ENT_QUOTES );
1348 if ( !isset( self::$listTypeMap[$listType] ) ) {
1349 $warning =
'Invalid list type for message "' . $this->
getKey() .
'": '
1350 . htmlspecialchars( $listType )
1352 trigger_error( $warning, E_USER_WARNING );
1354 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1355 return [
'before',
'[INVALID]' ];
1357 $func = self::$listTypeMap[$listType];
1361 return [
'before', $this->
getLanguage()->$func( [] ) ];
1370 $types[
$type] =
true;
1372 $vars[] =
'$' . ( $n + 1 );
1377 if ( count( $types ) === 1 ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
getCode()
Get the internal language code for this language object.
Wrapper allowing us to handle a system message as a Content object.
The Message class provides methods which fulfil two basic services:
extractParam( $param, $format)
Extracts the parameter type and preprocessed the value if needed.
static listParam(array $list, $type='text')
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
transformText( $string)
Wrapper for what ever method we use to {{-transform wikitext.
getParams()
Returns the message parameters.
durationParams()
Add parameters that are durations of time and will be passed through Language::formatDuration before ...
static bitrateParam( $bitrate)
static newFromKey( $key)
Factory function that is just wrapper for the real constructor.
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution.
static array $listTypeMap
Mapping from Message::listParam() types to Language methods.
isBlank()
Check whether a message does not exist, or is an empty string.
setInterfaceMessageFlag( $interface)
Allows manipulating the interface message flag directly.
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
__construct( $key, $params=[], Language $language=null)
bool $useDatabase
Whether database can be used.
parse()
Fully parse the text from wikitext to HTML.
const FORMAT_PARSE
Use normal wikitext -> HTML parsing but strip the block-level wrapper.
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
unserialize( $serialized)
const FORMAT_BLOCK_PARSE
Use normal wikitext -> HTML parsing (the result will be wrapped in a block-level HTML tag)
formatListParam(array $params, $listType, $format)
Formats a list of parameters as a concatenated string.
static timeperiodParam( $period)
array $parameters
List of parameters which will be substituted into the message.
static plaintextParam( $plaintext)
const FORMAT_PLAIN
Use message text as-is.
static durationParam( $duration)
const FORMAT_ESCAPED
Transform {{..}} constructs, HTML-escape the result.
inLanguage( $lang)
Request the message in any language that is supported.
replaceParameters( $message, $type, $format)
Substitutes any parameters into the message text.
string $key
The message key.
sizeParams()
Add parameters that are file sizes and will be passed through Language::formatSize before substitutio...
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message.
plain()
Returns the message text as-is, only parameters are substituted.
exists()
Check whether a message key has been defined currently.
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated.
rawParams()
Add parameters that are substituted after parsing or escaping.
title( $title)
Set the Title object to use as context when transforming the message.
Language bool $language
In which language to get this message.
getFormat()
Returns the message format.
useDatabase( $useDatabase)
Enable or disable database use.
fetchMessage()
Wrapper for what ever method we use to get message contents.
content()
Returns the message as a Content object.
formatPlaintext( $plaintext, $format)
Formats a message parameter wrapped with 'plaintext'.
getTitle()
Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
parseText( $string)
Wrapper for what ever method we use to parse wikitext.
getKey()
Returns the message key.
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
escaped()
Returns the message text.
params()
Adds parameters to the parameter list of this message.
getLanguage()
Returns the Language of the Message.
string[] $keysToTry
List of keys to try when fetching the message.
setContext(IContextSource $context)
Set the language and the title from a context object.
toString( $format=null)
Returns the message parsed from wikitext to HTML.
Title $title
Title object to use as context.
text()
Returns the message text.
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
bool $interface
In which language to get this message.
static expiryParam( $expiry)
getText( $options=[])
Get the output HTML.
Variant of the Message class.
Stub object for the user language.
Represents a title within MediaWiki.
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
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
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
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 use $formDescriptor instead 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 set this to the key of the message First element is the message key
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
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
if the prop value should be in the metadata multi language array format
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
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 use $formDescriptor instead 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
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
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
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
foreach( $res as $row) $serialized
if(!isset( $args[0])) $lang