12use MediaWiki\Languages\LanguageNameUtils;
37 parent::__construct( $mainModule, $moduleName );
38 $this->dbProvider = $dbProvider;
39 $this->languageNameUtils = $languageNameUtils;
46 return 'apihelp-setpagelanguage-extended-description-disabled';
48 return parent::getExtendedDescription();
72 $titleObj = $pageObj->getTitle();
74 if ( !$pageObj->exists() ) {
83 if ( $params[
'tags'] ) {
84 $tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
85 if ( !$tagStatus->isOK() ) {
94 $params[
'reason'] ??
'',
95 $params[
'tags'] ?: [],
96 $this->dbProvider->getPrimaryDatabase()
99 if ( !$status->isOK() ) {
104 'title' => $titleObj->getPrefixedText(),
105 'oldlanguage' => $status->value->oldLanguage,
106 'newlanguage' => $status->value->newLanguage,
107 'logid' => $status->value->logId
127 ParamValidator::PARAM_TYPE =>
'integer'
130 ParamValidator::PARAM_TYPE => [
132 ...array_keys( $this->languageNameUtils->getLanguageNames(
133 LanguageNameUtils::AUTONYMS,
134 LanguageNameUtils::SUPPORTED
137 ParamValidator::PARAM_REQUIRED =>
true,
141 ParamValidator::PARAM_TYPE =>
'tags',
142 ParamValidator::PARAM_ISMULTI =>
true,
154 $title = Title::newMainPage()->getPrefixedText();
155 $mp = rawurlencode( $title );
158 "action=setpagelanguage&title={$mp}&lang=eu&token=123ABC"
159 =>
'apihelp-setpagelanguage-example-language',
160 'action=setpagelanguage&pageid=123&lang=default&token=123ABC'
161 =>
'apihelp-setpagelanguage-example-default',
167 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:SetPageLanguage';
172class_alias( ApiSetPageLanguage::class,
'ApiSetPageLanguage' );
This is the main API class, used for both external and internal processing.
API module that facilitates changing the language of a page.
getExtendedDescription()
Return the extended help text message.This is additional text to display at the top of the help secti...
needsToken()
Returns the token type this module requires in order to execute.Modules are strongly encouraged to us...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isWriteMode()
Indicates whether this module requires write access to the wiki.API modules must override this method...
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
execute()
Extracts the title and language from the request parameters and invokes the static SpecialPageLanguag...
__construct(ApiMain $mainModule, string $moduleName, IConnectionProvider $dbProvider, LanguageNameUtils $languageNameUtils)
mustBePosted()
Indicates whether this module must be called with a POST request.Implementations of this method must ...
getHelpUrls()
Return links to more detailed help pages about the module.1.25, returning boolean false is deprecated...
A class containing constants representing the names of configuration variables.
const PageLanguageUseDB
Name constant for the PageLanguageUseDB setting, for use with Config::get()
Special page for changing the content language of a page.
static changePageLanguage(IContextSource $context, Title $title, $newLanguage, $reason="", array $tags=[], ?IDatabase $dbw=null)