MediaWiki master
ApiHelpParamValueMessage.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Api;
24
26
39
41 protected $paramValue;
43 protected $deprecated;
45 protected $internal;
46
59 public function __construct(
61 $text,
62 $params = [],
63 $deprecated = false,
64 $internal = false
65 ) {
66 parent::__construct( $text, $params );
67 $this->paramValue = $paramValue;
68 $this->deprecated = (bool)$deprecated;
69 $this->internal = (bool)$internal;
70 }
71
76 public function getParamValue() {
77 return $this->paramValue;
78 }
79
85 public function isDeprecated() {
86 return $this->deprecated;
87 }
88
94 public function isInternal() {
95 return $this->internal;
96 }
97
101 public function fetchMessage() {
102 if ( $this->message === null ) {
103 $prefix = ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:";
104 if ( $this->isDeprecated() ) {
105 $prefix .= '<span class="apihelp-deprecated">' .
106 $this->subMessage( 'api-help-param-deprecated' ) .
107 '</span>' .
108 $this->subMessage( 'word-separator' );
109 }
110 if ( $this->isInternal() ) {
111 $prefix .= '<span class="apihelp-internal">' .
112 $this->subMessage( 'api-help-param-internal' ) .
113 '</span>' .
114 $this->subMessage( 'word-separator' );
115 }
116
117 if ( $this->getLanguage()->getCode() === 'qqx' ) {
118 # Insert a list of alternative message keys for &uselang=qqx.
119 $keylist = implode( ' / ', $this->keysToTry );
120 if ( $this->overriddenKey !== null ) {
121 $keylist .= ' = ' . $this->overriddenKey;
122 }
123 $this->message = $prefix . "($keylist$*)";
124 } else {
125 $this->message = $prefix . parent::fetchMessage();
126 }
127 }
128 return $this->message;
129 }
130
131 private function subMessage( $key ) {
132 $msg = new Message( $key );
133 $msg->isInterface = $this->isInterface;
134 $msg->language = $this->language;
135 $msg->useDatabase = $this->useDatabase;
136 $msg->contextPage = $this->contextPage;
137 return $msg->plain();
138 }
139
140}
141
143class_alias( ApiHelpParamValueMessage::class, 'ApiHelpParamValueMessage' );
array $params
The job parameters.
Message subclass that prepends wikitext for API help.
__construct( $paramValue, $text, $params=[], $deprecated=false, $internal=false)
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:155
string $key
The message key.
Definition Message.php:204
PageReference $contextPage
page object to use as context.
Definition Message.php:233
Language string null $language
In which language to get this message.
Definition Message.php:192
bool $useDatabase
If messages in the local MediaWiki namespace should be loaded; false to use only the compiled Localis...
Definition Message.php:228
string $overriddenKey
The message key that the message was fetched from, if different from all of the requested $keysToTry ...
Definition Message.php:216
getLanguage()
Returns the Language of the Message.
Definition Message.php:423
bool $isInterface
In which language to get this message.
Definition Message.php:184
string null false $message
Definition Message.php:243