MediaWiki master
ApiHelpParamValueMessage.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Api;
10
12
25
38 public function __construct(
39 protected readonly string $paramValue,
40 $text,
41 $params = [],
42 protected readonly bool $deprecated = false,
43 protected readonly bool $internal = false,
44 ) {
45 parent::__construct( $text, $params );
46 }
47
52 public function getParamValue() {
53 return $this->paramValue;
54 }
55
61 public function isDeprecated() {
62 return $this->deprecated;
63 }
64
70 public function isInternal() {
71 return $this->internal;
72 }
73
77 public function fetchMessage() {
78 if ( $this->message === null ) {
79 $prefix = ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:";
80 if ( $this->isDeprecated() ) {
81 $prefix .= '<span class="apihelp-deprecated">' .
82 $this->subMessage( 'api-help-param-deprecated' ) .
83 '</span>' .
84 $this->subMessage( 'word-separator' );
85 }
86 if ( $this->isInternal() ) {
87 $prefix .= '<span class="apihelp-internal">' .
88 $this->subMessage( 'api-help-param-internal' ) .
89 '</span>' .
90 $this->subMessage( 'word-separator' );
91 }
92
93 if ( $this->getLanguage()->getCode() === 'qqx' ) {
94 # Insert a list of alternative message keys for &uselang=qqx.
95 $keylist = implode( ' / ', $this->keysToTry );
96 if ( $this->overriddenKey !== null ) {
97 $keylist .= ' = ' . $this->overriddenKey;
98 }
99 $this->message = $prefix . "($keylist$*)";
100 } else {
101 $this->message = $prefix . parent::fetchMessage();
102 }
103 }
104 return $this->message;
105 }
106
107 private function subMessage( string $key ): string {
108 $msg = new Message( $key );
109 $msg->isInterface = $this->isInterface;
110 $msg->language = $this->language;
111 $msg->useDatabase = $this->useDatabase;
112 $msg->contextPage = $this->contextPage;
113 return $msg->plain();
114 }
115
116}
117
119class_alias( ApiHelpParamValueMessage::class, 'ApiHelpParamValueMessage' );
Message subclass that prepends wikitext for API help.
__construct(protected readonly string $paramValue, $text, $params=[], protected readonly bool $deprecated=false, protected readonly bool $internal=false,)
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144
string $key
The message key.
Definition Message.php:192
PageReference $contextPage
page object to use as context.
Definition Message.php:221
Language string null $language
In which language to get this message.
Definition Message.php:172
bool $useDatabase
If messages in the local MediaWiki namespace should be loaded; false to use only the compiled Localis...
Definition Message.php:216
string $overriddenKey
The message key that the message was fetched from, if different from all of the requested $keysToTry ...
Definition Message.php:204
getLanguage()
Returns the Language of the Message.
Definition Message.php:413
bool $isInterface
In which language to get this message.
Definition Message.php:164
string null false $message
Definition Message.php:231