176 'comma' =>
'commaList',
177 'semicolon' =>
'semicolonList',
178 'pipe' =>
'pipeList',
179 'text' =>
'listToText',
227 protected $title =
null;
251 throw new InvalidArgumentException(
252 '$params must be empty if $key is a MessageSpecifier'
259 if ( !is_string(
$key ) && !is_array(
$key ) ) {
260 throw new InvalidArgumentException(
'$key must be a string or an array' );
265 if ( empty( $this->keysToTry ) ) {
266 throw new InvalidArgumentException(
'$key must not be an empty list' );
269 $this->
key = reset( $this->keysToTry );
271 $this->parameters = array_values(
$params );
284 'interface' => $this->interface,
287 'keysToTry' => $this->keysToTry,
288 'parameters' => $this->parameters,
289 'format' => $this->format,
290 'useDatabase' => $this->useDatabase,
302 $this->
interface = $data['interface'];
303 $this->
key = $data[
'key'];
304 $this->keysToTry = $data[
'keysToTry'];
305 $this->parameters = $data[
'parameters'];
306 $this->format = $data[
'format'];
308 $this->
language = $data[
'language'] ? Language::factory( $data[
'language'] ) :
false;
309 $this->title = $data[
'title'];
319 return count( $this->keysToTry ) > 1;
329 return $this->keysToTry;
355 return $this->parameters;
368 return $this->format;
416 if ( is_array(
$value ) ) {
425 } elseif ( is_string(
$value ) ) {
428 throw new InvalidArgumentException( __METHOD__ .
': invalid argument type '
448 $keys = func_get_args();
449 if ( func_num_args() == 1 ) {
450 if ( is_array(
$keys[0] ) ) {
458 return new self(
$keys );
476 !$this->
language->equals( $wgContLang )
480 $title .=
'/' .
$code;
483 return Title::makeTitle( NS_MEDIAWIKI,
$wgContLang->ucfirst( strtr( $title,
' ',
'_' ) ) );
497 $args = func_get_args();
503 if ( count(
$args ) === 1 && isset(
$args[0] ) && is_array(
$args[0] ) ) {
504 if (
$args[0] === [] ) {
508 if ( is_int(
$key ) ) {
516 $this->parameters = array_merge( $this->parameters, array_values(
$args ) );
538 foreach (
$params as $param ) {
539 $this->parameters[] = self::rawParam( $param );
560 foreach (
$params as $param ) {
561 $this->parameters[] = self::numParam( $param );
582 foreach (
$params as $param ) {
583 $this->parameters[] = self::durationParam( $param );
604 foreach (
$params as $param ) {
605 $this->parameters[] = self::expiryParam( $param );
626 foreach (
$params as $param ) {
627 $this->parameters[] = self::timeperiodParam( $param );
648 foreach (
$params as $param ) {
649 $this->parameters[] = self::sizeParam( $param );
670 foreach (
$params as $param ) {
671 $this->parameters[] = self::bitrateParam( $param );
694 foreach (
$params as $param ) {
695 $this->parameters[] = self::plaintextParam( $param );
712 $this->
interface =
true;
731 } elseif ( is_string(
$lang ) ) {
740 .
"passed a String or Language object; $type given"
743 $this->message =
null;
744 $this->
interface = false;
779 $this->
interface = (bool)$interface;
794 $this->message =
null;
818 if ( !$this->content ) {
822 return $this->content;
837 $ex =
new LogicException( __METHOD__ .
' using implicit format: ' . $this->format );
838 \MediaWiki\Logger\LoggerFactory::getInstance(
'message-format' )->warning(
839 $ex->getMessage(), [
'exception' => $ex,
'format' => $this->format,
'key' => $this->key ] );
844 if ( $string ===
false ) {
852 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
855 # Replace $* with a list of parameters for &uselang=qqx.
856 if ( strpos( $string,
'$*' ) !==
false ) {
858 if ( $this->parameters !== [] ) {
859 $paramlist =
': $' . implode(
', $', range( 1, count( $this->parameters ) ) );
861 $string = str_replace(
'$*', $paramlist, $string );
864 # Replace parameters before text parsing
867 # Maybe transform using the full parser
868 if (
$format === self::FORMAT_PARSE ) {
870 $string = Parser::stripOuterParagraph( $string );
871 } elseif (
$format === self::FORMAT_BLOCK_PARSE ) {
873 } elseif (
$format === self::FORMAT_TEXT ) {
875 } elseif (
$format === self::FORMAT_ESCAPED ) {
877 $string = htmlspecialchars( $string, ENT_QUOTES,
'UTF-8',
false );
880 # Raw parameter replacement
900 return $this->
toString( self::FORMAT_PARSE );
901 }
catch ( Exception $ex ) {
903 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
904 . $ex, E_USER_WARNING );
905 }
catch ( Exception $ex ) {
909 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
921 $this->format = self::FORMAT_PARSE;
922 return $this->
toString( self::FORMAT_PARSE );
933 $this->format = self::FORMAT_TEXT;
934 return $this->
toString( self::FORMAT_TEXT );
945 $this->format = self::FORMAT_PLAIN;
946 return $this->
toString( self::FORMAT_PLAIN );
957 $this->format = self::FORMAT_BLOCK_PARSE;
958 return $this->
toString( self::FORMAT_BLOCK_PARSE );
970 $this->format = self::FORMAT_ESCAPED;
971 return $this->
toString( self::FORMAT_ESCAPED );
1018 return [
'raw' => $raw ];
1029 return [
'num' => $num ];
1040 return [
'duration' => $duration ];
1051 return [
'expiry' => $expiry ];
1062 return [
'period' => $period ];
1073 return [
'size' => $size ];
1084 return [
'bitrate' => $bitrate ];
1095 return [
'plaintext' => $plaintext ];
1106 if ( !isset( self::$listTypeMap[
$type] ) ) {
1107 throw new InvalidArgumentException(
1108 "Invalid type '$type'. Known types are: " . implode(
', ', array_keys( self::$listTypeMap ) )
1111 return [
'list' => $list,
'type' =>
$type ];
1130 $marker =
$format === self::FORMAT_ESCAPED ?
'$' :
'$\'"';
1131 $replacementKeys = [];
1132 foreach ( $this->parameters as $n => $param ) {
1134 if (
$type ===
'before' ) {
1135 if ( $paramType ===
'before' ) {
1136 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1143 $replacementKeys[
'$' . ( $n + 1 )] = $marker . ( $n + 1 );
1146 if ( $paramType ===
'after' ) {
1147 $replacementKeys[$marker . ( $n + 1 )] =
$value;
1166 if ( is_array( $param ) ) {
1167 if ( isset( $param[
'raw'] ) ) {
1168 return [
'after', $param[
'raw'] ];
1169 } elseif ( isset( $param[
'num'] ) ) {
1172 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1173 } elseif ( isset( $param[
'duration'] ) ) {
1174 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1175 } elseif ( isset( $param[
'expiry'] ) ) {
1176 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1177 } elseif ( isset( $param[
'period'] ) ) {
1178 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1179 } elseif ( isset( $param[
'size'] ) ) {
1180 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1181 } elseif ( isset( $param[
'bitrate'] ) ) {
1182 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1183 } elseif ( isset( $param[
'plaintext'] ) ) {
1185 } elseif ( isset( $param[
'list'] ) ) {
1188 if ( !is_scalar( $param ) ) {
1191 \MediaWiki\Logger\LoggerFactory::getInstance(
'Bug58676' )->warning(
1192 'Invalid parameter for message "{msgkey}": {param}',
1194 'exception' =>
new Exception,
1195 'msgkey' => $this->
getKey(),
1196 'param' => htmlspecialchars( $param ),
1200 return [
'before',
'[INVALID]' ];
1202 } elseif ( $param instanceof
Message ) {
1204 $msg = clone $param;
1205 if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1207 $msg->message =
null;
1209 $msg->interface = $this->interface;
1210 $msg->language = $this->language;
1211 $msg->useDatabase = $this->useDatabase;
1215 if (
$format ===
'block-parse' ) {
1223 return [
'after', $msg->toString(
$format ) ];
1225 return [
'before', $param ];
1249 'enableSectionEditLinks' =>
false,
1286 if ( $this->message ===
null ) {
1289 foreach ( $this->keysToTry as
$key ) {
1301 return $this->message;
1318 case self::FORMAT_TEXT:
1319 case self::FORMAT_PLAIN:
1322 case self::FORMAT_PARSE:
1323 case self::FORMAT_BLOCK_PARSE:
1324 case self::FORMAT_ESCAPED:
1326 return htmlspecialchars( $plaintext, ENT_QUOTES );
1339 if ( !isset( self::$listTypeMap[$listType] ) ) {
1340 $warning =
'Invalid list type for message "' . $this->
getKey() .
'": '
1341 . htmlspecialchars( $listType )
1343 trigger_error( $warning, E_USER_WARNING );
1345 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1346 return [
'before',
'[INVALID]' ];
1348 $func = self::$listTypeMap[$listType];
1352 return [
'before', $this->
getLanguage()->$func( [] ) ];
1359 foreach (
$params as $n => $p ) {
1361 $types[
$type] =
true;
1363 $vars[] =
'$' . ( $n + 1 );
1368 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 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.
static singleton()
Get the signleton instance of this class.
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.
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...
replaceParameters( $message, $type='before', $format)
Substitutes any parameters into the message text.
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.
Content $content
Content object representing the message.
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.
static getMain()
Get the RequestContext object associated with the main request.
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 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
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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 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
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
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
returning false will NOT prevent logging $e
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
foreach( $res as $row) $serialized
if(!isset( $args[0])) $lang