MediaWiki  master
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 
398  public static function newFromSpecifier( $value ) {
399  $params = [];
400  if ( is_array( $value ) ) {
401  $params = $value;
402  $value = array_shift( $params );
403  }
404 
405  if ( $value instanceof Message ) { // Message, RawMessage, ApiMessage, etc
406  $message = clone( $value );
407  } elseif ( $value instanceof MessageSpecifier ) {
408  $message = new Message( $value );
409  } elseif ( is_string( $value ) ) {
410  $message = new Message( $value, $params );
411  } else {
412  throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
413  . gettype( $value ) );
414  }
415 
416  return $message;
417  }
418 
431  public static function newFallbackSequence( /*...*/ ) {
432  $keys = func_get_args();
433  if ( func_num_args() == 1 ) {
434  if ( is_array( $keys[0] ) ) {
435  // Allow an array to be passed as the first argument instead
436  $keys = array_values( $keys[0] );
437  } else {
438  // Optimize a single string to not need special fallback handling
439  $keys = $keys[0];
440  }
441  }
442  return new self( $keys );
443  }
444 
455  public function getTitle() {
457 
458  $title = $this->key;
459  if (
460  !$this->language->equals( $wgContLang )
461  && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
462  ) {
463  $code = $this->language->getCode();
464  $title .= '/' . $code;
465  }
466 
467  return Title::makeTitle( NS_MEDIAWIKI, $wgContLang->ucfirst( strtr( $title, ' ', '_' ) ) );
468  }
469 
480  public function params( /*...*/ ) {
481  $args = func_get_args();
482  if ( isset( $args[0] ) && is_array( $args[0] ) ) {
483  $args = $args[0];
484  }
485  $args_values = array_values( $args );
486  $this->parameters = array_merge( $this->parameters, $args_values );
487  return $this;
488  }
489 
503  public function rawParams( /*...*/ ) {
504  $params = func_get_args();
505  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
506  $params = $params[0];
507  }
508  foreach ( $params as $param ) {
509  $this->parameters[] = self::rawParam( $param );
510  }
511  return $this;
512  }
513 
525  public function numParams( /*...*/ ) {
526  $params = func_get_args();
527  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
528  $params = $params[0];
529  }
530  foreach ( $params as $param ) {
531  $this->parameters[] = self::numParam( $param );
532  }
533  return $this;
534  }
535 
547  public function durationParams( /*...*/ ) {
548  $params = func_get_args();
549  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
550  $params = $params[0];
551  }
552  foreach ( $params as $param ) {
553  $this->parameters[] = self::durationParam( $param );
554  }
555  return $this;
556  }
557 
569  public function expiryParams( /*...*/ ) {
570  $params = func_get_args();
571  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
572  $params = $params[0];
573  }
574  foreach ( $params as $param ) {
575  $this->parameters[] = self::expiryParam( $param );
576  }
577  return $this;
578  }
579 
591  public function timeperiodParams( /*...*/ ) {
592  $params = func_get_args();
593  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
594  $params = $params[0];
595  }
596  foreach ( $params as $param ) {
597  $this->parameters[] = self::timeperiodParam( $param );
598  }
599  return $this;
600  }
601 
613  public function sizeParams( /*...*/ ) {
614  $params = func_get_args();
615  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
616  $params = $params[0];
617  }
618  foreach ( $params as $param ) {
619  $this->parameters[] = self::sizeParam( $param );
620  }
621  return $this;
622  }
623 
635  public function bitrateParams( /*...*/ ) {
636  $params = func_get_args();
637  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
638  $params = $params[0];
639  }
640  foreach ( $params as $param ) {
641  $this->parameters[] = self::bitrateParam( $param );
642  }
643  return $this;
644  }
645 
659  public function plaintextParams( /*...*/ ) {
660  $params = func_get_args();
661  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
662  $params = $params[0];
663  }
664  foreach ( $params as $param ) {
665  $this->parameters[] = self::plaintextParam( $param );
666  }
667  return $this;
668  }
669 
679  public function setContext( IContextSource $context ) {
680  $this->inLanguage( $context->getLanguage() );
681  $this->title( $context->getTitle() );
682  $this->interface = true;
683 
684  return $this;
685  }
686 
698  public function inLanguage( $lang ) {
699  if ( $lang instanceof Language ) {
700  $this->language = $lang;
701  } elseif ( is_string( $lang ) ) {
702  if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
703  $this->language = Language::factory( $lang );
704  }
705  } elseif ( $lang instanceof StubUserLang ) {
706  $this->language = false;
707  } else {
708  $type = gettype( $lang );
709  throw new MWException( __METHOD__ . " must be "
710  . "passed a String or Language object; $type given"
711  );
712  }
713  $this->message = null;
714  $this->interface = false;
715  return $this;
716  }
717 
727  public function inContentLanguage() {
729  if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
730  return $this;
731  }
732 
734  $this->inLanguage( $wgContLang );
735  return $this;
736  }
737 
748  public function setInterfaceMessageFlag( $interface ) {
749  $this->interface = (bool)$interface;
750  return $this;
751  }
752 
762  public function useDatabase( $useDatabase ) {
763  $this->useDatabase = (bool)$useDatabase;
764  return $this;
765  }
766 
776  public function title( $title ) {
777  $this->title = $title;
778  return $this;
779  }
780 
786  public function content() {
787  if ( !$this->content ) {
788  $this->content = new MessageContent( $this );
789  }
790 
791  return $this->content;
792  }
793 
801  public function toString() {
802  $string = $this->fetchMessage();
803 
804  if ( $string === false ) {
805  // Err on the side of safety, ensure that the output
806  // is always html safe in the event the message key is
807  // missing, since in that case its highly likely the
808  // message key is user-controlled.
809  // '⧼' is used instead of '<' to side-step any
810  // double-escaping issues.
811  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
812  }
813 
814  # Replace $* with a list of parameters for &uselang=qqx.
815  if ( strpos( $string, '$*' ) !== false ) {
816  $paramlist = '';
817  if ( $this->parameters !== [] ) {
818  $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
819  }
820  $string = str_replace( '$*', $paramlist, $string );
821  }
822 
823  # Replace parameters before text parsing
824  $string = $this->replaceParameters( $string, 'before' );
825 
826  # Maybe transform using the full parser
827  if ( $this->format === 'parse' ) {
828  $string = $this->parseText( $string );
829  $string = Parser::stripOuterParagraph( $string );
830  } elseif ( $this->format === 'block-parse' ) {
831  $string = $this->parseText( $string );
832  } elseif ( $this->format === 'text' ) {
833  $string = $this->transformText( $string );
834  } elseif ( $this->format === 'escaped' ) {
835  $string = $this->transformText( $string );
836  $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
837  }
838 
839  # Raw parameter replacement
840  $string = $this->replaceParameters( $string, 'after' );
841 
842  return $string;
843  }
844 
854  public function __toString() {
855  // PHP doesn't allow __toString to throw exceptions and will
856  // trigger a fatal error if it does. So, catch any exceptions.
857 
858  try {
859  return $this->toString();
860  } catch ( Exception $ex ) {
861  try {
862  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
863  . $ex, E_USER_WARNING );
864  } catch ( Exception $ex ) {
865  // Doh! Cause a fatal error after all?
866  }
867 
868  if ( $this->format === 'plain' || $this->format === 'text' ) {
869  return '<' . $this->key . '>';
870  }
871  return '&lt;' . htmlspecialchars( $this->key ) . '&gt;';
872  }
873  }
874 
882  public function parse() {
883  $this->format = 'parse';
884  return $this->toString();
885  }
886 
894  public function text() {
895  $this->format = 'text';
896  return $this->toString();
897  }
898 
906  public function plain() {
907  $this->format = 'plain';
908  return $this->toString();
909  }
910 
918  public function parseAsBlock() {
919  $this->format = 'block-parse';
920  return $this->toString();
921  }
922 
931  public function escaped() {
932  $this->format = 'escaped';
933  return $this->toString();
934  }
935 
943  public function exists() {
944  return $this->fetchMessage() !== false;
945  }
946 
955  public function isBlank() {
956  $message = $this->fetchMessage();
957  return $message === false || $message === '';
958  }
959 
967  public function isDisabled() {
968  $message = $this->fetchMessage();
969  return $message === false || $message === '' || $message === '-';
970  }
971 
979  public static function rawParam( $raw ) {
980  return [ 'raw' => $raw ];
981  }
982 
990  public static function numParam( $num ) {
991  return [ 'num' => $num ];
992  }
993 
1001  public static function durationParam( $duration ) {
1002  return [ 'duration' => $duration ];
1003  }
1004 
1012  public static function expiryParam( $expiry ) {
1013  return [ 'expiry' => $expiry ];
1014  }
1015 
1023  public static function timeperiodParam( $period ) {
1024  return [ 'period' => $period ];
1025  }
1026 
1034  public static function sizeParam( $size ) {
1035  return [ 'size' => $size ];
1036  }
1037 
1045  public static function bitrateParam( $bitrate ) {
1046  return [ 'bitrate' => $bitrate ];
1047  }
1048 
1056  public static function plaintextParam( $plaintext ) {
1057  return [ 'plaintext' => $plaintext ];
1058  }
1059 
1070  protected function replaceParameters( $message, $type = 'before' ) {
1071  $replacementKeys = [];
1072  foreach ( $this->parameters as $n => $param ) {
1073  list( $paramType, $value ) = $this->extractParam( $param );
1074  if ( $type === $paramType ) {
1075  $replacementKeys['$' . ( $n + 1 )] = $value;
1076  }
1077  }
1078  $message = strtr( $message, $replacementKeys );
1079  return $message;
1080  }
1081 
1091  protected function extractParam( $param ) {
1092  if ( is_array( $param ) ) {
1093  if ( isset( $param['raw'] ) ) {
1094  return [ 'after', $param['raw'] ];
1095  } elseif ( isset( $param['num'] ) ) {
1096  // Replace number params always in before step for now.
1097  // No support for combined raw and num params
1098  return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1099  } elseif ( isset( $param['duration'] ) ) {
1100  return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1101  } elseif ( isset( $param['expiry'] ) ) {
1102  return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1103  } elseif ( isset( $param['period'] ) ) {
1104  return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1105  } elseif ( isset( $param['size'] ) ) {
1106  return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1107  } elseif ( isset( $param['bitrate'] ) ) {
1108  return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1109  } elseif ( isset( $param['plaintext'] ) ) {
1110  return [ 'after', $this->formatPlaintext( $param['plaintext'] ) ];
1111  } else {
1112  $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' .
1113  htmlspecialchars( serialize( $param ) );
1114  trigger_error( $warning, E_USER_WARNING );
1115  $e = new Exception;
1116  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1117 
1118  return [ 'before', '[INVALID]' ];
1119  }
1120  } elseif ( $param instanceof Message ) {
1121  // Message objects should not be before parameters because
1122  // then they'll get double escaped. If the message needs to be
1123  // escaped, it'll happen right here when we call toString().
1124  return [ 'after', $param->toString() ];
1125  } else {
1126  return [ 'before', $param ];
1127  }
1128  }
1129 
1139  protected function parseText( $string ) {
1140  $out = MessageCache::singleton()->parse(
1141  $string,
1142  $this->title,
1143  /*linestart*/true,
1144  $this->interface,
1145  $this->getLanguage()
1146  );
1147 
1148  return $out instanceof ParserOutput ? $out->getText() : $out;
1149  }
1150 
1160  protected function transformText( $string ) {
1161  return MessageCache::singleton()->transform(
1162  $string,
1163  $this->interface,
1164  $this->getLanguage(),
1165  $this->title
1166  );
1167  }
1168 
1177  protected function fetchMessage() {
1178  if ( $this->message === null ) {
1180 
1181  foreach ( $this->keysToTry as $key ) {
1182  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1183  if ( $message !== false && $message !== '' ) {
1184  break;
1185  }
1186  }
1187 
1188  // NOTE: The constructor makes sure keysToTry isn't empty,
1189  // so we know that $key and $message are initialized.
1190  $this->key = $key;
1191  $this->message = $message;
1192  }
1193  return $this->message;
1194  }
1195 
1207  protected function formatPlaintext( $plaintext ) {
1208  switch ( $this->format ) {
1209  case 'text':
1210  case 'plain':
1211  return $plaintext;
1212 
1213  case 'parse':
1214  case 'block-parse':
1215  case 'escaped':
1216  default:
1217  return htmlspecialchars( $plaintext, ENT_QUOTES );
1218 
1219  }
1220  }
1221 }
1222 
1236 class RawMessage extends Message {
1237 
1249  public function __construct( $text, $params = [] ) {
1250  if ( !is_string( $text ) ) {
1251  throw new InvalidArgumentException( '$text must be a string' );
1252  }
1253 
1254  parent::__construct( $text, $params );
1255 
1256  // The key is the message.
1257  $this->message = $text;
1258  }
1259 
1265  public function fetchMessage() {
1266  // Just in case the message is unset somewhere.
1267  if ( $this->message === null ) {
1268  $this->message = $this->key;
1269  }
1270 
1271  return $this->message;
1272  }
1273 
1274 }
getKeysToTry()
Definition: Message.php:314
static rawParam($raw)
Definition: Message.php:979
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:1056
isBlank()
Check whether a message does not exist, or is an empty string.
Definition: Message.php:955
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:776
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:547
transformText($string)
Wrapper for what ever method we use to {{-transform wikitext.
Definition: Message.php:1160
$context
Definition: load.php:43
title($title)
Set the Title object to use as context when transforming the message.
Definition: Message.php:776
static durationParam($duration)
Definition: Message.php:1001
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:1207
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
rawParams()
Add parameters that are substituted after parsing or escaping.
Definition: Message.php:503
setInterfaceMessageFlag($interface)
Allows manipulating the interface message flag directly.
Definition: Message.php:748
The Message class provides methods which fulfil two basic services:
Definition: Message.php:159
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1980
string $format
Format for the message.
Definition: Message.php:203
static expiryParam($expiry)
Definition: Message.php:1012
unserialize($serialized)
Definition: Message.php:286
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.
Definition: Message.php:801
Language bool $language
In which language to get this message.
Definition: Message.php:174
$value
text()
Returns the message text.
Definition: Message.php:894
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
Definition: Message.php:918
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:786
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:1816
getParams()
Returns the message parameters.
Definition: Message.php:340
static timeperiodParam($period)
Definition: Message.php:1023
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:1265
static getMain()
Static methods.
static stripOuterParagraph($html)
Strip outer.
Definition: Parser.php:5970
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:1139
isMultiKey()
Definition: Message.php:304
static sizeParam($size)
Definition: Message.php:1034
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 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 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:1972
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
Definition: Message.php:591
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
Definition: Message.php:569
MediaWiki exception.
Definition: MWException.php:26
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
Definition: Message.php:431
serialize()
Definition: Message.php:268
Internationalisation code.
Definition: Language.php:39
inLanguage($lang)
Request the message in any language that is supported.
Definition: Message.php:698
$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:480
setContext(IContextSource $context)
Set the language and the title from a context object.
Definition: Message.php:679
extractParam($param)
Extracts the parameter type and preprocessed the value if needed.
Definition: Message.php:1091
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:776
parse()
Fully parse the text from wikitext to HTML.
Definition: Message.php:882
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:1070
exists()
Check whether a message key has been defined currently.
Definition: Message.php:943
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution...
Definition: Message.php:525
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:613
Variant of the Message class.
Definition: Message.php:1236
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
Definition: Message.php:854
static numParam($num)
Definition: Message.php:990
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:455
__construct($text, $params=[])
Call the parent constructor, then store the key as the message.
Definition: Message.php:1249
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated...
Definition: Message.php:659
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
Definition: Message.php:635
__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:762
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:906
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message...
Definition: Message.php:727
fetchMessage()
Wrapper for what ever method we use to get message contents.
Definition: Message.php:1177
escaped()
Returns the message text.
Definition: Message.php:931
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:967
static bitrateParam($bitrate)
Definition: Message.php:1045
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:2376
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:503
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:1490
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:398