38 private $loadBalancer;
41 private $languageNameUtils;
55 parent::__construct( $mainModule, $moduleName );
56 $this->loadBalancer = $loadBalancer;
57 $this->languageNameUtils = $languageNameUtils;
62 if ( !$this->
getConfig()->
get( MainConfigNames::PageLanguageUseDB ) ) {
63 return 'apihelp-setpagelanguage-extended-description-disabled';
65 return parent::getExtendedDescription();
77 if ( !$this->
getConfig()->
get( MainConfigNames::PageLanguageUseDB ) ) {
89 $titleObj = $pageObj->getTitle();
91 if ( !$pageObj->exists() ) {
100 if ( $params[
'tags'] ) {
102 if ( !$tagStatus->isOK() ) {
111 $params[
'reason'] ??
'',
112 $params[
'tags'] ?: [],
113 $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_PRIMARY )
116 if ( !$status->isOK() ) {
121 'title' => $titleObj->getPrefixedText(),
122 'oldlanguage' => $status->value->oldLanguage,
123 'newlanguage' => $status->value->newLanguage,
124 'logid' => $status->value->logId
141 ParamValidator::PARAM_TYPE =>
'integer'
144 ParamValidator::PARAM_TYPE => array_merge(
146 array_keys( $this->languageNameUtils->getLanguageNames(
147 LanguageNameUtils::AUTONYMS,
148 LanguageNameUtils::SUPPORTED
151 ParamValidator::PARAM_REQUIRED =>
true,
155 ParamValidator::PARAM_TYPE =>
'tags',
156 ParamValidator::PARAM_ISMULTI =>
true,
166 $title = Title::newMainPage()->getPrefixedText();
167 $mp = rawurlencode(
$title );
170 "action=setpagelanguage&title={$mp}&lang=eu&token=123ABC"
171 =>
'apihelp-setpagelanguage-example-language',
172 'action=setpagelanguage&pageid=123&lang=default&token=123ABC'
173 =>
'apihelp-setpagelanguage-example-default',
178 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:SetPageLanguage';
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
checkTitleUserPermissions( $pageIdentity, $actions, array $options=[])
Helper function for permission-denied errors.
getModuleName()
Get the name of the module being executed by this instance.
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
This is the main API class, used for both external and internal processing.
API module that facilitates changing the language of a page.
needsToken()
Returns the token type this module requires in order to execute.
getExtendedDescription()
Return the extended help text message.
isWriteMode()
Indicates whether this module requires write mode.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
__construct(ApiMain $mainModule, $moduleName, ILoadBalancer $loadBalancer, LanguageNameUtils $languageNameUtils)
execute()
Extracts the title and language from the request parameters and invokes the static SpecialPageLanguag...
getExamplesMessages()
Returns usage examples for this module.
mustBePosted()
Indicates whether this module must be called with a POST request.
A class containing constants representing the names of configuration variables.
static changePageLanguage(IContextSource $context, Title $title, $newLanguage, $reason="", array $tags=[], IDatabase $dbw=null)