177 'comma' =>
'commaList',
178 'semicolon' =>
'semicolonList',
179 'pipe' =>
'pipeList',
180 'text' =>
'listToText',
228 protected $title =
null;
252 throw new InvalidArgumentException(
253 '$params must be empty if $key is a MessageSpecifier'
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 );
285 'interface' => $this->interface,
288 'keysToTry' => $this->keysToTry,
289 'parameters' => $this->parameters,
290 'format' => $this->format,
291 'useDatabase' => $this->useDatabase,
292 'titlestr' => $this->
title ? $this->
title->getFullText() :
null,
304 throw new InvalidArgumentException( __METHOD__ .
': Invalid serialized data' );
307 $this->
interface =
$data['interface'];
309 $this->keysToTry =
$data[
'keysToTry'];
310 $this->parameters =
$data[
'parameters'];
311 $this->format =
$data[
'format'];
316 $this->
title = Title::newFromText(
$data[
'titlestr'] );
332 return count( $this->keysToTry ) > 1;
342 return $this->keysToTry;
368 return $this->parameters;
381 return $this->format;
393 return $this->
language ?: RequestContext::getMain()->getLanguage();
441 throw new InvalidArgumentException( __METHOD__ .
': invalid argument type '
471 return new self(
$keys );
487 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
491 !
$lang->equals( $contLang )
492 && in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg )
494 $title .=
'/' .
$lang->getCode();
497 return Title::makeTitle(
498 NS_MEDIAWIKI, $contLang->ucfirst( strtr( $title,
' ',
'_' ) ) );
519 if (
$args[0] === [] ) {
553 foreach (
$params as $param ) {
554 $this->parameters[] = self::rawParam( $param );
575 foreach (
$params as $param ) {
576 $this->parameters[] = self::numParam( $param );
597 foreach (
$params as $param ) {
598 $this->parameters[] = self::durationParam( $param );
619 foreach (
$params as $param ) {
620 $this->parameters[] = self::expiryParam( $param );
641 foreach (
$params as $param ) {
642 $this->parameters[] = self::timeperiodParam( $param );
663 foreach (
$params as $param ) {
664 $this->parameters[] = self::sizeParam( $param );
685 foreach (
$params as $param ) {
686 $this->parameters[] = self::bitrateParam( $param );
709 foreach (
$params as $param ) {
710 $this->parameters[] = self::plaintextParam( $param );
727 $this->
interface =
true;
744 $previousLanguage = $this->language;
757 .
"passed a String or Language object; $type given"
761 if ( $this->
language !== $previousLanguage ) {
763 $this->message =
null;
765 $this->
interface = false;
784 $this->
inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
799 $this->
interface = (bool)$interface;
814 $this->message =
null;
838 if ( !$this->content ) {
858 $ex =
new LogicException( __METHOD__ .
' using implicit format: ' . $this->format );
859 \MediaWiki\Logger\LoggerFactory::getInstance(
'message-format' )->warning(
860 $ex->getMessage(), [
'exception' => $ex,
'format' => $this->format,
'key' => $this->key ] );
865 if ( $string ===
false ) {
876 # Replace $* with a list of parameters for &uselang=qqx.
877 if (
strpos( $string,
'$*' ) !==
false ) {
879 if ( $this->parameters !== [] ) {
880 $paramlist =
': $' . implode(
', $',
range( 1, count( $this->parameters ) ) );
882 $string =
str_replace(
'$*', $paramlist, $string );
885 # Replace parameters before text parsing
888 # Maybe transform using the full parser
889 if (
$format === self::FORMAT_PARSE ) {
891 $string = Parser::stripOuterParagraph( $string );
901 # Raw parameter replacement
921 return $this->
toString( self::FORMAT_PARSE );
922 }
catch ( Exception $ex ) {
924 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
925 . $ex, E_USER_WARNING );
926 }
catch ( Exception $ex ) {
942 $this->format = self::FORMAT_PARSE;
943 return $this->
toString( self::FORMAT_PARSE );
954 $this->format = self::FORMAT_TEXT;
955 return $this->
toString( self::FORMAT_TEXT );
966 $this->format = self::FORMAT_PLAIN;
967 return $this->
toString( self::FORMAT_PLAIN );
978 $this->format = self::FORMAT_BLOCK_PARSE;
979 return $this->
toString( self::FORMAT_BLOCK_PARSE );
991 $this->format = self::FORMAT_ESCAPED;
992 return $this->
toString( self::FORMAT_ESCAPED );
1039 return [
'raw' => $raw ];
1050 return [
'num' =>
$num ];
1072 return [
'expiry' => $expiry ];
1083 return [
'period' => $period ];
1094 return [
'size' => $size ];
1116 return [
'plaintext' => $plaintext ];
1128 throw new InvalidArgumentException(
1129 "Invalid type '$type'. Known types are: " . implode(
', ',
array_keys( self::$listTypeMap ) )
1132 return [
'list' => $list,
'type' =>
$type ];
1151 $marker =
$format === self::FORMAT_ESCAPED ?
'$' :
'$\'"';
1152 $replacementKeys = [];
1153 foreach ( $this->parameters as $n => $param ) {
1155 if (
$type ===
'before' ) {
1156 if ( $paramType ===
'before' ) {
1157 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1164 $replacementKeys[
'$' . ( $n + 1 )] = $marker . ( $n + 1 );
1166 }
elseif ( $paramType ===
'after' ) {
1167 $replacementKeys[$marker . ( $n + 1 )] =
$value;
1185 if (
isset( $param[
'raw'] ) ) {
1186 return [
'after', $param[
'raw'] ];
1190 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1192 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1194 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1196 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1198 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1200 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1209 \MediaWiki\Logger\LoggerFactory::getInstance(
'Bug58676' )->warning(
1210 'Invalid parameter for message "{msgkey}": {param}',
1212 'exception' =>
new Exception,
1213 'msgkey' => $this->
getKey(),
1218 return [
'before',
'[INVALID]' ];
1223 if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1225 $msg->message =
null;
1227 $msg->interface = $this->interface;
1228 $msg->language = $this->language;
1229 $msg->useDatabase = $this->useDatabase;
1233 if (
$format ===
'block-parse' ) {
1241 return [
'after', $msg->toString(
$format ) ];
1243 return [
'before',
$param ];
1257 $out = MessageCache::singleton()->parse(
1267 'enableSectionEditLinks' =>
false,
1287 return MessageCache::singleton()->transform(
1304 if ( $this->message ===
null ) {
1305 $cache = MessageCache::singleton();
1307 foreach ( $this->keysToTry as
$key ) {
1319 return $this->message;
1336 case self::FORMAT_TEXT:
1337 case self::FORMAT_PLAIN:
1340 case self::FORMAT_PARSE:
1341 case self::FORMAT_BLOCK_PARSE:
1342 case self::FORMAT_ESCAPED:
1357 if ( !
isset( self::$listTypeMap[$listType] ) ) {
1358 $warning =
'Invalid list type for message "' . $this->
getKey() .
'": '
1363 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1364 return [
'before',
'[INVALID]' ];
1370 return [
'before', $this->
getLanguage()->$func( [] ) ];
1377 foreach (
$params as $n => $p ) {
1379 $types[
$type] =
true;
1381 $vars[] =
'$' . ( $n + 1 );
1386 if ( count( $types ) === 1 ) {
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
$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.
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.
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)
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
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 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
returning false will NOT prevent logging $e
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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