60 parent::__construct( $query, $moduleName,
'am' );
61 $this->contentLanguage = $contentLanguage;
62 $this->languageFactory = $languageFactory;
63 $this->languageNameUtils = $languageNameUtils;
64 $this->localisationCache = $localisationCache;
65 $this->messageCache = $messageCache;
70 if ( $params[
'lang'] ===
null ) {
72 } elseif ( !$this->languageNameUtils->isValidCode( $params[
'lang'] ) ) {
74 [
'apierror-invalidlang', $this->
encodeParamName(
'lang' ) ],
'invalidlang'
77 $langObj = $this->languageFactory->getLanguage( $params[
'lang'] );
80 if ( $params[
'enableparser'] ) {
81 if ( $params[
'title'] !==
null ) {
82 $title = Title::newFromText( $params[
'title'] );
83 if ( !$title || $title->isExternal() ) {
87 $title = Title::newFromText(
'API' );
91 $prop = array_fill_keys( (array)$params[
'prop'],
true );
94 if ( in_array(
'*', $params[
'messages'] ) ) {
95 $message_names = $this->localisationCache->getSubitemList( $langObj->getCode(),
'messages' ) ?? [];
96 if ( $params[
'includelocal'] ) {
97 $message_names = array_unique( array_merge(
103 $this->messageCache->getAllMessageKeys( $this->contentLanguage->getCode() )
106 sort( $message_names );
107 $messages_target = $message_names;
109 $messages_target = $params[
'messages'];
114 if ( isset( $params[
'prefix'] ) ) {
116 $messages_filtered = [];
117 foreach ( $messages_target as $message ) {
118 if ( str_starts_with( $message, $params[
'prefix'] ) ) {
122 $messages_filtered[] = $message;
127 $messages_target = $messages_filtered;
131 if ( isset( $params[
'filter'] ) ) {
132 $messages_filtered = [];
133 foreach ( $messages_target as $message ) {
134 if ( str_contains( $message, $params[
'filter'] ) ) {
135 $messages_filtered[] = $message;
138 $messages_target = $messages_filtered;
142 $customiseFilterEnabled = $params[
'customised'] !==
'all';
143 if ( $customiseFilterEnabled ) {
144 $customisedMessages = AllMessagesTablePager::getCustomisedStatuses(
146 [ $langObj,
'ucfirst' ],
150 !$langObj->equals( $this->contentLanguage ),
154 $customised = $params[
'customised'] ===
'modified';
158 $skip = $params[
'from'] !==
null;
159 $useto = $params[
'to'] !==
null;
161 foreach ( $messages_target as $message ) {
163 if ( $skip && $message === $params[
'from'] ) {
167 if ( $useto && $message > $params[
'to'] ) {
178 if ( isset( $params[
'args'] ) && count( $params[
'args'] ) != 0 ) {
179 $args = $params[
'args'];
182 if ( $customiseFilterEnabled ) {
183 $messageIsCustomised = isset( $customisedMessages[
'pages'][$langObj->ucfirst( $message )] );
185 if ( $customised === $messageIsCustomised ) {
188 $a[
'customised'] =
true;
195 $msg = $this->
msg( $message, $args )->inLanguage( $langObj );
197 if ( !$msg->exists() ) {
198 $a[
'missing'] =
true;
201 if ( $params[
'enableparser'] ) {
203 $msgString = $msg->page( $title )->text();
205 $msgString = $msg->plain();
207 if ( !$params[
'nocontent'] ) {
210 if ( isset( $prop[
'default'] ) ) {
211 $default = $this->
msg( $message )->inLanguage( $langObj )->useDatabase(
false );
212 if ( !$default->exists() ) {
213 $a[
'defaultmissing'] =
true;
214 } elseif ( $default->plain() != $msgString ) {
215 $a[
'default'] = $default->plain();
219 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $a );
226 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'message' );
230 if ( $params[
'lang'] ===
null ) {
232 return 'anon-public-user-private';
233 } elseif ( $params[
'enableparser'] ) {
235 return 'anon-public-user-private';
245 ParamValidator::PARAM_DEFAULT =>
'*',
246 ParamValidator::PARAM_ISMULTI =>
true,
249 ParamValidator::PARAM_ISMULTI =>
true,
250 ParamValidator::PARAM_TYPE => [
254 'enableparser' =>
false,
255 'nocontent' =>
false,
256 'includelocal' =>
false,
258 ParamValidator::PARAM_ISMULTI =>
true,
259 ParamValidator::PARAM_ALLOW_DUPLICATES =>
true,
263 ParamValidator::PARAM_DEFAULT =>
'all',
264 ParamValidator::PARAM_TYPE => [
280 'action=query&meta=allmessages&refix=ipb-'
281 =>
'apihelp-query+allmessages-example-ipb',
282 'action=query&meta=allmessages&ammessages=august|mainpage&amlang=de'
283 =>
'apihelp-query+allmessages-example-de',
288 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allmessages';
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
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.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName, Language $contentLanguage, LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, LocalisationCache $localisationCache, MessageCache $messageCache)
getExamplesMessages()
Returns usage examples for this module.
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.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Base class for language-specific code.
Caching for the contents of localisation files.
Cache messages that are defined by MediaWiki-namespace pages or by hooks.
static normalizeKey( $key)
Normalize message key input.