MediaWiki  1.27.1
Message.php
Go to the documentation of this file.
1 <?php
159 class Message implements MessageSpecifier, Serializable {
160 
167  protected $interface = true;
168 
174  protected $language = false;
175 
180  protected $key;
181 
185  protected $keysToTry;
186 
190  protected $parameters = [];
191 
203  protected $format = 'parse';
204 
208  protected $useDatabase = true;
209 
213  protected $title = null;
214 
218  protected $content = null;
219 
223  protected $message;
224 
234  public function __construct( $key, $params = [], Language $language = null ) {
235  if ( $key instanceof MessageSpecifier ) {
236  if ( $params ) {
237  throw new InvalidArgumentException(
238  '$params must be empty if $key is a MessageSpecifier'
239  );
240  }
241  $params = $key->getParams();
242  $key = $key->getKey();
243  }
244 
245  if ( !is_string( $key ) && !is_array( $key ) ) {
246  throw new InvalidArgumentException( '$key must be a string or an array' );
247  }
248 
249  $this->keysToTry = (array)$key;
250 
251  if ( empty( $this->keysToTry ) ) {
252  throw new InvalidArgumentException( '$key must not be an empty list' );
253  }
254 
255  $this->key = reset( $this->keysToTry );
256 
257  $this->parameters = array_values( $params );
258  // User language is only resolved in getLanguage(). This helps preserve the
259  // semantic intent of "user language" across serialize() and unserialize().
260  $this->language = $language ?: false;
261  }
262 
268  public function serialize() {
269  return serialize( [
270  'interface' => $this->interface,
271  'language' => $this->language ? $this->language->getCode() : false,
272  'key' => $this->key,
273  'keysToTry' => $this->keysToTry,
274  'parameters' => $this->parameters,
275  'format' => $this->format,
276  'useDatabase' => $this->useDatabase,
277  'title' => $this->title,
278  ] );
279  }
280 
286  public function unserialize( $serialized ) {
287  $data = unserialize( $serialized );
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'];
293  $this->useDatabase = $data['useDatabase'];
294  $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
295  $this->title = $data['title'];
296  }
297 
304  public function isMultiKey() {
305  return count( $this->keysToTry ) > 1;
306  }
307 
314  public function getKeysToTry() {
315  return $this->keysToTry;
316  }
317 
329  public function getKey() {
330  return $this->key;
331  }
332 
340  public function getParams() {
341  return $this->parameters;
342  }
343 
351  public function getFormat() {
352  return $this->format;
353  }
354 
362  public function getLanguage() {
363  // Defaults to false which means current user language
364  return $this->language ?: RequestContext::getMain()->getLanguage();
365  }
366 
379  public static function newFromKey( $key /*...*/ ) {
380  $params = func_get_args();
381  array_shift( $params );
382  return new self( $key, $params );
383  }
384 
397  public static function newFromSpecifier( $value ) {
398  $params = [];
399  if ( is_array( $value ) ) {
400  $params = $value;
401  $value = array_shift( $params );
402  }
403 
404  if ( $value instanceof RawMessage ) {
405  $message = new RawMessage( $value->getKey(), $value->getParams() );
406  } elseif ( $value instanceof MessageSpecifier ) {
407  $message = new Message( $value );
408  } elseif ( is_string( $value ) ) {
409  $message = new Message( $value, $params );
410  } else {
411  throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
412  . gettype( $value ) );
413  }
414 
415  return $message;
416  }
417 
430  public static function newFallbackSequence( /*...*/ ) {
431  $keys = func_get_args();
432  if ( func_num_args() == 1 ) {
433  if ( is_array( $keys[0] ) ) {
434  // Allow an array to be passed as the first argument instead
435  $keys = array_values( $keys[0] );
436  } else {
437  // Optimize a single string to not need special fallback handling
438  $keys = $keys[0];
439  }
440  }
441  return new self( $keys );
442  }
443 
454  public function getTitle() {
456 
457  $code = $this->getLanguage()->getCode();
458  $title = $this->key;
459  if (
460  $wgContLang->getCode() !== $code
461  && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
462  ) {
463  $title .= '/' . $code;
464  }
465 
466  return Title::makeTitle( NS_MEDIAWIKI, $wgContLang->ucfirst( strtr( $title, ' ', '_' ) ) );
467  }
468 
479  public function params( /*...*/ ) {
480  $args = func_get_args();
481  if ( isset( $args[0] ) && is_array( $args[0] ) ) {
482  $args = $args[0];
483  }
484  $args_values = array_values( $args );
485  $this->parameters = array_merge( $this->parameters, $args_values );
486  return $this;
487  }
488 
502  public function rawParams( /*...*/ ) {
503  $params = func_get_args();
504  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
505  $params = $params[0];
506  }
507  foreach ( $params as $param ) {
508  $this->parameters[] = self::rawParam( $param );
509  }
510  return $this;
511  }
512 
524  public function numParams( /*...*/ ) {
525  $params = func_get_args();
526  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
527  $params = $params[0];
528  }
529  foreach ( $params as $param ) {
530  $this->parameters[] = self::numParam( $param );
531  }
532  return $this;
533  }
534 
546  public function durationParams( /*...*/ ) {
547  $params = func_get_args();
548  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
549  $params = $params[0];
550  }
551  foreach ( $params as $param ) {
552  $this->parameters[] = self::durationParam( $param );
553  }
554  return $this;
555  }
556 
568  public function expiryParams( /*...*/ ) {
569  $params = func_get_args();
570  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
571  $params = $params[0];
572  }
573  foreach ( $params as $param ) {
574  $this->parameters[] = self::expiryParam( $param );
575  }
576  return $this;
577  }
578 
590  public function timeperiodParams( /*...*/ ) {
591  $params = func_get_args();
592  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
593  $params = $params[0];
594  }
595  foreach ( $params as $param ) {
596  $this->parameters[] = self::timeperiodParam( $param );
597  }
598  return $this;
599  }
600 
612  public function sizeParams( /*...*/ ) {
613  $params = func_get_args();
614  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
615  $params = $params[0];
616  }
617  foreach ( $params as $param ) {
618  $this->parameters[] = self::sizeParam( $param );
619  }
620  return $this;
621  }
622 
634  public function bitrateParams( /*...*/ ) {
635  $params = func_get_args();
636  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
637  $params = $params[0];
638  }
639  foreach ( $params as $param ) {
640  $this->parameters[] = self::bitrateParam( $param );
641  }
642  return $this;
643  }
644 
658  public function plaintextParams( /*...*/ ) {
659  $params = func_get_args();
660  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
661  $params = $params[0];
662  }
663  foreach ( $params as $param ) {
664  $this->parameters[] = self::plaintextParam( $param );
665  }
666  return $this;
667  }
668 
678  public function setContext( IContextSource $context ) {
679  $this->inLanguage( $context->getLanguage() );
680  $this->title( $context->getTitle() );
681  $this->interface = true;
682 
683  return $this;
684  }
685 
697  public function inLanguage( $lang ) {
698  if ( $lang instanceof Language ) {
699  $this->language = $lang;
700  } elseif ( is_string( $lang ) ) {
701  if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
702  $this->language = Language::factory( $lang );
703  }
704  } elseif ( $lang instanceof StubUserLang ) {
705  $this->language = false;
706  } else {
707  $type = gettype( $lang );
708  throw new MWException( __METHOD__ . " must be "
709  . "passed a String or Language object; $type given"
710  );
711  }
712  $this->message = null;
713  $this->interface = false;
714  return $this;
715  }
716 
726  public function inContentLanguage() {
728  if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
729  return $this;
730  }
731 
733  $this->inLanguage( $wgContLang );
734  return $this;
735  }
736 
747  public function setInterfaceMessageFlag( $interface ) {
748  $this->interface = (bool)$interface;
749  return $this;
750  }
751 
761  public function useDatabase( $useDatabase ) {
762  $this->useDatabase = (bool)$useDatabase;
763  return $this;
764  }
765 
775  public function title( $title ) {
776  $this->title = $title;
777  return $this;
778  }
779 
785  public function content() {
786  if ( !$this->content ) {
787  $this->content = new MessageContent( $this );
788  }
789 
790  return $this->content;
791  }
792 
800  public function toString() {
801  $string = $this->fetchMessage();
802 
803  if ( $string === false ) {
804  if ( $this->format === 'plain' || $this->format === 'text' ) {
805  return '<' . $this->key . '>';
806  }
807  return '&lt;' . htmlspecialchars( $this->key ) . '&gt;';
808  }
809 
810  # Replace $* with a list of parameters for &uselang=qqx.
811  if ( strpos( $string, '$*' ) !== false ) {
812  $paramlist = '';
813  if ( $this->parameters !== [] ) {
814  $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
815  }
816  $string = str_replace( '$*', $paramlist, $string );
817  }
818 
819  # Replace parameters before text parsing
820  $string = $this->replaceParameters( $string, 'before' );
821 
822  # Maybe transform using the full parser
823  if ( $this->format === 'parse' ) {
824  $string = $this->parseText( $string );
825  $string = Parser::stripOuterParagraph( $string );
826  } elseif ( $this->format === 'block-parse' ) {
827  $string = $this->parseText( $string );
828  } elseif ( $this->format === 'text' ) {
829  $string = $this->transformText( $string );
830  } elseif ( $this->format === 'escaped' ) {
831  $string = $this->transformText( $string );
832  $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
833  }
834 
835  # Raw parameter replacement
836  $string = $this->replaceParameters( $string, 'after' );
837 
838  return $string;
839  }
840 
850  public function __toString() {
851  // PHP doesn't allow __toString to throw exceptions and will
852  // trigger a fatal error if it does. So, catch any exceptions.
853 
854  try {
855  return $this->toString();
856  } catch ( Exception $ex ) {
857  try {
858  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
859  . $ex, E_USER_WARNING );
860  } catch ( Exception $ex ) {
861  // Doh! Cause a fatal error after all?
862  }
863 
864  if ( $this->format === 'plain' || $this->format === 'text' ) {
865  return '<' . $this->key . '>';
866  }
867  return '&lt;' . htmlspecialchars( $this->key ) . '&gt;';
868  }
869  }
870 
878  public function parse() {
879  $this->format = 'parse';
880  return $this->toString();
881  }
882 
890  public function text() {
891  $this->format = 'text';
892  return $this->toString();
893  }
894 
902  public function plain() {
903  $this->format = 'plain';
904  return $this->toString();
905  }
906 
914  public function parseAsBlock() {
915  $this->format = 'block-parse';
916  return $this->toString();
917  }
918 
927  public function escaped() {
928  $this->format = 'escaped';
929  return $this->toString();
930  }
931 
939  public function exists() {
940  return $this->fetchMessage() !== false;
941  }
942 
951  public function isBlank() {
952  $message = $this->fetchMessage();
953  return $message === false || $message === '';
954  }
955 
963  public function isDisabled() {
964  $message = $this->fetchMessage();
965  return $message === false || $message === '' || $message === '-';
966  }
967 
975  public static function rawParam( $raw ) {
976  return [ 'raw' => $raw ];
977  }
978 
986  public static function numParam( $num ) {
987  return [ 'num' => $num ];
988  }
989 
997  public static function durationParam( $duration ) {
998  return [ 'duration' => $duration ];
999  }
1000 
1008  public static function expiryParam( $expiry ) {
1009  return [ 'expiry' => $expiry ];
1010  }
1011 
1019  public static function timeperiodParam( $period ) {
1020  return [ 'period' => $period ];
1021  }
1022 
1030  public static function sizeParam( $size ) {
1031  return [ 'size' => $size ];
1032  }
1033 
1041  public static function bitrateParam( $bitrate ) {
1042  return [ 'bitrate' => $bitrate ];
1043  }
1044 
1052  public static function plaintextParam( $plaintext ) {
1053  return [ 'plaintext' => $plaintext ];
1054  }
1055 
1066  protected function replaceParameters( $message, $type = 'before' ) {
1067  $replacementKeys = [];
1068  foreach ( $this->parameters as $n => $param ) {
1069  list( $paramType, $value ) = $this->extractParam( $param );
1070  if ( $type === $paramType ) {
1071  $replacementKeys['$' . ( $n + 1 )] = $value;
1072  }
1073  }
1074  $message = strtr( $message, $replacementKeys );
1075  return $message;
1076  }
1077 
1087  protected function extractParam( $param ) {
1088  if ( is_array( $param ) ) {
1089  if ( isset( $param['raw'] ) ) {
1090  return [ 'after', $param['raw'] ];
1091  } elseif ( isset( $param['num'] ) ) {
1092  // Replace number params always in before step for now.
1093  // No support for combined raw and num params
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'] ) ) {
1106  return [ 'after', $this->formatPlaintext( $param['plaintext'] ) ];
1107  } else {
1108  $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' .
1109  htmlspecialchars( serialize( $param ) );
1110  trigger_error( $warning, E_USER_WARNING );
1111  $e = new Exception;
1112  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1113 
1114  return [ 'before', '[INVALID]' ];
1115  }
1116  } elseif ( $param instanceof Message ) {
1117  // Message objects should not be before parameters because
1118  // then they'll get double escaped. If the message needs to be
1119  // escaped, it'll happen right here when we call toString().
1120  return [ 'after', $param->toString() ];
1121  } else {
1122  return [ 'before', $param ];
1123  }
1124  }
1125 
1135  protected function parseText( $string ) {
1136  $out = MessageCache::singleton()->parse(
1137  $string,
1138  $this->title,
1139  /*linestart*/true,
1140  $this->interface,
1141  $this->getLanguage()
1142  );
1143 
1144  return $out instanceof ParserOutput ? $out->getText() : $out;
1145  }
1146 
1156  protected function transformText( $string ) {
1157  return MessageCache::singleton()->transform(
1158  $string,
1159  $this->interface,
1160  $this->getLanguage(),
1161  $this->title
1162  );
1163  }
1164 
1173  protected function fetchMessage() {
1174  if ( $this->message === null ) {
1176 
1177  foreach ( $this->keysToTry as $key ) {
1178  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1179  if ( $message !== false && $message !== '' ) {
1180  break;
1181  }
1182  }
1183 
1184  // NOTE: The constructor makes sure keysToTry isn't empty,
1185  // so we know that $key and $message are initialized.
1186  $this->key = $key;
1187  $this->message = $message;
1188  }
1189  return $this->message;
1190  }
1191 
1203  protected function formatPlaintext( $plaintext ) {
1204  switch ( $this->format ) {
1205  case 'text':
1206  case 'plain':
1207  return $plaintext;
1208 
1209  case 'parse':
1210  case 'block-parse':
1211  case 'escaped':
1212  default:
1213  return htmlspecialchars( $plaintext, ENT_QUOTES );
1214 
1215  }
1216  }
1217 }
1218 
1232 class RawMessage extends Message {
1233 
1245  public function __construct( $text, $params = [] ) {
1246  if ( !is_string( $text ) ) {
1247  throw new InvalidArgumentException( '$text must be a string' );
1248  }
1249 
1250  parent::__construct( $text, $params );
1251 
1252  // The key is the message.
1253  $this->message = $text;
1254  }
1255 
1261  public function fetchMessage() {
1262  // Just in case the message is unset somewhere.
1263  if ( $this->message === null ) {
1264  $this->message = $this->key;
1265  }
1266 
1267  return $this->message;
1268  }
1269 
1270 }
getKeysToTry()
Definition: Message.php:314
static rawParam($raw)
Definition: Message.php:975
getKey()
Returns the message key.
Definition: Message.php:329
string[] $keysToTry
List of keys to try when fetching the message.
Definition: Message.php:185
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
Definition: deferred.txt:11
Interface for objects which can provide a MediaWiki context on request.
static plaintextParam($plaintext)
Definition: Message.php:1052
isBlank()
Check whether a message does not exist, or is an empty string.
Definition: Message.php:951
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
Definition: hooks.txt:762
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 ...
Definition: Message.php:546
transformText($string)
Wrapper for what ever method we use to {{-transform wikitext.
Definition: Message.php:1156
$context
Definition: load.php:44
title($title)
Set the Title object to use as context when transforming the message.
Definition: Message.php:775
static durationParam($duration)
Definition: Message.php:997
bool $useDatabase
Whether database can be used.
Definition: Message.php:208
Content $content
Content object representing the message.
Definition: Message.php:218
Title $title
Title object to use as context.
Definition: Message.php:213
formatPlaintext($plaintext)
Formats a message parameter wrapped with 'plaintext'.
Definition: Message.php:1203
rawParams()
Add parameters that are substituted after parsing or escaping.
Definition: Message.php:502
setInterfaceMessageFlag($interface)
Allows manipulating the interface message flag directly.
Definition: Message.php:747
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
string $format
Format for the message.
Definition: Message.php:203
static expiryParam($expiry)
Definition: Message.php:1008
unserialize($serialized)
Definition: Message.php:286
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
Definition: hooks.txt:189
toString()
Returns the message parsed from wikitext to HTML.
Definition: Message.php:800
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
Definition: hooks.txt:1924
Language bool $language
In which language to get this message.
Definition: Message.php:174
$value
text()
Returns the message text.
Definition: Message.php:890
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
Definition: Message.php:914
getFormat()
Returns the message format.
Definition: Message.php:351
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
content()
Returns the message as a Content object.
Definition: Message.php:785
if($line===false) $args
Definition: cdb.php:64
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
Definition: hooks.txt:1798
getParams()
Returns the message parameters.
Definition: Message.php:340
static timeperiodParam($period)
Definition: Message.php:1019
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).
Definition: Message.php:1261
static getMain()
Static methods.
static stripOuterParagraph($html)
Strip outer.
Definition: Parser.php:6442
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
Definition: design.txt:25
parseText($string)
Wrapper for what ever method we use to parse wikitext.
Definition: Message.php:1135
isMultiKey()
Definition: Message.php:304
static sizeParam($size)
Definition: Message.php:1030
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
Definition: Message.php:590
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
Definition: Message.php:568
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
Definition: Message.php:430
serialize()
Definition: Message.php:268
inLanguage($lang)
Request the message in any language that is supported.
Definition: Message.php:697
$cache
Definition: mcc.php:33
$params
string $key
The message key.
Definition: Message.php:180
array $parameters
List of parameters which will be substituted into the message.
Definition: Message.php:190
params()
Adds parameters to the parameter list of this message.
Definition: Message.php:479
setContext(IContextSource $context)
Set the language and the title from a context object.
Definition: Message.php:678
extractParam($param)
Extracts the parameter type and preprocessed the value if needed.
Definition: Message.php:1087
getLanguage()
Returns the Language of the Message.
Definition: Message.php:362
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
Definition: distributors.txt:9
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
Definition: hooks.txt:762
parse()
Fully parse the text from wikitext to HTML.
Definition: Message.php:878
const NS_MEDIAWIKI
Definition: Defines.php:77
$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.
Definition: Message.php:1066
exists()
Check whether a message key has been defined currently.
Definition: Message.php:939
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution...
Definition: Message.php:524
static newFromKey($key)
Factory function that is just wrapper for the real constructor.
Definition: Message.php:379
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
Definition: injection.txt:35
sizeParams()
Add parameters that are file sizes and will be passed through Language::formatSize before substitutio...
Definition: Message.php:612
Variant of the Message class.
Definition: Message.php:1232
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
Definition: Message.php:850
static numParam($num)
Definition: Message.php:986
Stub object for the user language.
Definition: StubObject.php:169
getTitle()
Get a title object for a mediawiki message, where it can be found in the mediawiki namespace...
Definition: Message.php:454
__construct($text, $params=[])
Call the parent constructor, then store the key as the message.
Definition: Message.php:1245
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated...
Definition: Message.php:658
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
Definition: Message.php:634
__construct($key, $params=[], Language $language=null)
Definition: Message.php:234
getTitle()
Get the Title object.
useDatabase($useDatabase)
Enable or disable database use.
Definition: Message.php:761
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
Definition: design.txt:56
plain()
Returns the message text as-is, only parameters are substituted.
Definition: Message.php:902
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message...
Definition: Message.php:726
fetchMessage()
Wrapper for what ever method we use to get message contents.
Definition: Message.php:1173
escaped()
Returns the message text.
Definition: Message.php:927
string $message
Definition: Message.php:223
foreach($res as $row) $serialized
static factory($code)
Get a cached or new language object for a given language code.
Definition: Language.php:179
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
Definition: Message.php:963
static bitrateParam($bitrate)
Definition: Message.php:1041
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
Definition: hooks.txt:2338
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
static singleton()
Get the signleton instance of this class.
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1473
bool $interface
In which language to get this message.
Definition: Message.php:167
static newFromSpecifier($value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
Definition: Message.php:397