MediaWiki  1.28.0
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  if ( $this->format !== 'parse' ) {
856  $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
857  \MediaWiki\Logger\LoggerFactory::getInstance( 'message-format' )->warning(
858  $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
859  }
860 
861  // PHP doesn't allow __toString to throw exceptions and will
862  // trigger a fatal error if it does. So, catch any exceptions.
863 
864  try {
865  return $this->toString();
866  } catch ( Exception $ex ) {
867  try {
868  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
869  . $ex, E_USER_WARNING );
870  } catch ( Exception $ex ) {
871  // Doh! Cause a fatal error after all?
872  }
873 
874  if ( $this->format === 'plain' || $this->format === 'text' ) {
875  return '<' . $this->key . '>';
876  }
877  return '&lt;' . htmlspecialchars( $this->key ) . '&gt;';
878  }
879  }
880 
888  public function parse() {
889  $this->format = 'parse';
890  return $this->toString();
891  }
892 
900  public function text() {
901  $this->format = 'text';
902  return $this->toString();
903  }
904 
912  public function plain() {
913  $this->format = 'plain';
914  return $this->toString();
915  }
916 
924  public function parseAsBlock() {
925  $this->format = 'block-parse';
926  return $this->toString();
927  }
928 
937  public function escaped() {
938  $this->format = 'escaped';
939  return $this->toString();
940  }
941 
949  public function exists() {
950  return $this->fetchMessage() !== false;
951  }
952 
961  public function isBlank() {
962  $message = $this->fetchMessage();
963  return $message === false || $message === '';
964  }
965 
973  public function isDisabled() {
974  $message = $this->fetchMessage();
975  return $message === false || $message === '' || $message === '-';
976  }
977 
985  public static function rawParam( $raw ) {
986  return [ 'raw' => $raw ];
987  }
988 
996  public static function numParam( $num ) {
997  return [ 'num' => $num ];
998  }
999 
1007  public static function durationParam( $duration ) {
1008  return [ 'duration' => $duration ];
1009  }
1010 
1018  public static function expiryParam( $expiry ) {
1019  return [ 'expiry' => $expiry ];
1020  }
1021 
1029  public static function timeperiodParam( $period ) {
1030  return [ 'period' => $period ];
1031  }
1032 
1040  public static function sizeParam( $size ) {
1041  return [ 'size' => $size ];
1042  }
1043 
1051  public static function bitrateParam( $bitrate ) {
1052  return [ 'bitrate' => $bitrate ];
1053  }
1054 
1062  public static function plaintextParam( $plaintext ) {
1063  return [ 'plaintext' => $plaintext ];
1064  }
1065 
1076  protected function replaceParameters( $message, $type = 'before' ) {
1077  $replacementKeys = [];
1078  foreach ( $this->parameters as $n => $param ) {
1079  list( $paramType, $value ) = $this->extractParam( $param );
1080  if ( $type === $paramType ) {
1081  $replacementKeys['$' . ( $n + 1 )] = $value;
1082  }
1083  }
1084  $message = strtr( $message, $replacementKeys );
1085  return $message;
1086  }
1087 
1097  protected function extractParam( $param ) {
1098  if ( is_array( $param ) ) {
1099  if ( isset( $param['raw'] ) ) {
1100  return [ 'after', $param['raw'] ];
1101  } elseif ( isset( $param['num'] ) ) {
1102  // Replace number params always in before step for now.
1103  // No support for combined raw and num params
1104  return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1105  } elseif ( isset( $param['duration'] ) ) {
1106  return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1107  } elseif ( isset( $param['expiry'] ) ) {
1108  return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1109  } elseif ( isset( $param['period'] ) ) {
1110  return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1111  } elseif ( isset( $param['size'] ) ) {
1112  return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1113  } elseif ( isset( $param['bitrate'] ) ) {
1114  return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1115  } elseif ( isset( $param['plaintext'] ) ) {
1116  return [ 'after', $this->formatPlaintext( $param['plaintext'] ) ];
1117  } else {
1118  $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' .
1119  htmlspecialchars( serialize( $param ) );
1120  trigger_error( $warning, E_USER_WARNING );
1121  $e = new Exception;
1122  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1123 
1124  return [ 'before', '[INVALID]' ];
1125  }
1126  } elseif ( $param instanceof Message ) {
1127  // Message objects should not be before parameters because
1128  // then they'll get double escaped. If the message needs to be
1129  // escaped, it'll happen right here when we call toString().
1130  return [ 'after', $param->toString() ];
1131  } else {
1132  return [ 'before', $param ];
1133  }
1134  }
1135 
1145  protected function parseText( $string ) {
1146  $out = MessageCache::singleton()->parse(
1147  $string,
1148  $this->title,
1149  /*linestart*/true,
1150  $this->interface,
1151  $this->getLanguage()
1152  );
1153 
1154  return $out instanceof ParserOutput ? $out->getText() : $out;
1155  }
1156 
1166  protected function transformText( $string ) {
1167  return MessageCache::singleton()->transform(
1168  $string,
1169  $this->interface,
1170  $this->getLanguage(),
1171  $this->title
1172  );
1173  }
1174 
1183  protected function fetchMessage() {
1184  if ( $this->message === null ) {
1186 
1187  foreach ( $this->keysToTry as $key ) {
1188  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1189  if ( $message !== false && $message !== '' ) {
1190  break;
1191  }
1192  }
1193 
1194  // NOTE: The constructor makes sure keysToTry isn't empty,
1195  // so we know that $key and $message are initialized.
1196  $this->key = $key;
1197  $this->message = $message;
1198  }
1199  return $this->message;
1200  }
1201 
1213  protected function formatPlaintext( $plaintext ) {
1214  switch ( $this->format ) {
1215  case 'text':
1216  case 'plain':
1217  return $plaintext;
1218 
1219  case 'parse':
1220  case 'block-parse':
1221  case 'escaped':
1222  default:
1223  return htmlspecialchars( $plaintext, ENT_QUOTES );
1224 
1225  }
1226  }
1227 }
1228 
1242 class RawMessage extends Message {
1243 
1255  public function __construct( $text, $params = [] ) {
1256  if ( !is_string( $text ) ) {
1257  throw new InvalidArgumentException( '$text must be a string' );
1258  }
1259 
1260  parent::__construct( $text, $params );
1261 
1262  // The key is the message.
1263  $this->message = $text;
1264  }
1265 
1271  public function fetchMessage() {
1272  // Just in case the message is unset somewhere.
1273  if ( $this->message === null ) {
1274  $this->message = $this->key;
1275  }
1276 
1277  return $this->message;
1278  }
1279 
1280 }
getKeysToTry()
Definition: Message.php:314
static rawParam($raw)
Definition: Message.php:985
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:1062
isBlank()
Check whether a message does not exist, or is an empty string.
Definition: Message.php:961
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:802
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:1166
$context
Definition: load.php:50
title($title)
Set the Title object to use as context when transforming the message.
Definition: Message.php:776
static durationParam($duration)
Definition: Message.php:1007
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:1213
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
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:2102
string $format
Format for the message.
Definition: Message.php:203
static expiryParam($expiry)
Definition: Message.php:1018
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
static getInstance($channel)
Get a named logger instance from the currently configured logger factory.
Language bool $language
In which language to get this message.
Definition: Message.php:174
$value
text()
Returns the message text.
Definition: Message.php:900
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
Definition: Message.php:924
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:1936
getParams()
Returns the message parameters.
Definition: Message.php:340
static timeperiodParam($period)
Definition: Message.php:1029
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:1271
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 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:2094
static getMain()
Static methods.
static stripOuterParagraph($html)
Strip outer.
Definition: Parser.php:6034
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:1145
isMultiKey()
Definition: Message.php:304
static sizeParam($size)
Definition: Message.php:1040
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
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
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:1097
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:802
parse()
Fully parse the text from wikitext to HTML.
Definition: Message.php:888
const NS_MEDIAWIKI
Definition: Defines.php:64
$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:1076
exists()
Check whether a message key has been defined currently.
Definition: Message.php:949
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:1242
__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:996
Stub object for the user language.
Definition: StubObject.php:179
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:1255
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:912
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:1183
escaped()
Returns the message text.
Definition: Message.php:937
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:181
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
Definition: Message.php:973
static bitrateParam($bitrate)
Definition: Message.php:1051
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:2491
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:511
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:1610
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