66 parent::__construct( $query, $moduleName,
'am' );
76 if ( $params[
'lang'] ===
null ) {
78 } elseif ( !$this->languageNameUtils->isValidCode( $params[
'lang'] ) ) {
80 [
'apierror-invalidlang', $this->
encodeParamName(
'lang' ) ],
'invalidlang'
83 $langObj = $this->languageFactory->getLanguage( $params[
'lang'] );
86 if ( $params[
'enableparser'] ) {
87 if ( $params[
'title'] !==
null ) {
97 $prop = array_fill_keys( (array)$params[
'prop'],
true );
100 if ( in_array(
'*', $params[
'messages'] ) ) {
101 $message_names = $this->localisationCache->getSubitemList( $langObj->getCode(),
'messages' ) ?? [];
102 if ( $params[
'includelocal'] ) {
103 $message_names = array_unique( array_merge(
109 $this->messageCache->getAllMessageKeys( $this->contentLanguage->getCode() )
112 sort( $message_names );
113 $messages_target = $message_names;
115 $messages_target = $params[
'messages'];
120 if ( isset( $params[
'prefix'] ) ) {
122 $messages_filtered = [];
123 foreach ( $messages_target as $message ) {
125 if ( strpos( $message, $params[
'prefix'] ) === 0 ) {
129 $messages_filtered[] = $message;
134 $messages_target = $messages_filtered;
138 if ( isset( $params[
'filter'] ) ) {
139 $messages_filtered = [];
140 foreach ( $messages_target as $message ) {
142 if ( strpos( $message, $params[
'filter'] ) !==
false ) {
143 $messages_filtered[] = $message;
146 $messages_target = $messages_filtered;
150 $customiseFilterEnabled = $params[
'customised'] !==
'all';
151 if ( $customiseFilterEnabled ) {
154 [ $langObj,
'ucfirst' ],
158 !$langObj->equals( $this->contentLanguage ),
162 $customised = $params[
'customised'] ===
'modified';
166 $skip = $params[
'from'] !==
null;
167 $useto = $params[
'to'] !==
null;
169 foreach ( $messages_target as $message ) {
171 if ( $skip && $message === $params[
'from'] ) {
175 if ( $useto && $message > $params[
'to'] ) {
186 if ( isset( $params[
'args'] ) && count( $params[
'args'] ) != 0 ) {
187 $args = $params[
'args'];
190 if ( $customiseFilterEnabled ) {
191 $messageIsCustomised = isset( $customisedMessages[
'pages'][$langObj->ucfirst( $message )] );
193 if ( $customised === $messageIsCustomised ) {
196 $a[
'customised'] =
true;
205 if ( !$msg->exists() ) {
206 $a[
'missing'] =
true;
209 if ( $params[
'enableparser'] ) {
211 $msgString = $msg->page(
$title )->text();
213 $msgString = $msg->plain();
215 if ( !$params[
'nocontent'] ) {
218 if ( isset( $prop[
'default'] ) ) {
219 $default =
wfMessage( $message )->inLanguage( $langObj )->useDatabase(
false );
220 if ( !$default->exists() ) {
221 $a[
'defaultmissing'] =
true;
222 } elseif ( $default->plain() != $msgString ) {
223 $a[
'default'] = $default->plain();
227 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $a );
234 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'message' );
238 if ( $params[
'lang'] ===
null ) {
240 return 'anon-public-user-private';
241 } elseif ( $params[
'enableparser'] ) {
243 return 'anon-public-user-private';
262 'enableparser' =>
false,
263 'nocontent' =>
false,
264 'includelocal' =>
false,
288 'action=query&meta=allmessages&refix=ipb-'
289 =>
'apihelp-query+allmessages-example-ipb',
290 'action=query&meta=allmessages&ammessages=august|mainpage&amlang=de'
291 =>
'apihelp-query+allmessages-example-de',
296 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allmessages';
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_ALLOW_DUPLICATES
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
A query action to return messages from site message cache.
LanguageNameUtils $languageNameUtils
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
LanguageFactory $languageFactory
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
LocalisationCache $localisationCache
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getHelpUrls()
Return links to more detailed help pages about the module.
Language $contentLanguage
__construct(ApiQuery $query, $moduleName, Language $contentLanguage, LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, LocalisationCache $localisationCache, MessageCache $messageCache)
getExamplesMessages()
Returns usage examples for this module.
MessageCache $messageCache
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
This is the main query class.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
static normalizeKey( $key)
Normalize message key input.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.