39 private $loadBalancer;
42 private $languageNameUtils;
56 parent::__construct( $mainModule, $moduleName );
57 $this->loadBalancer = $loadBalancer;
58 $this->languageNameUtils = $languageNameUtils;
63 if ( !$this->
getConfig()->
get( MainConfigNames::PageLanguageUseDB ) ) {
64 return 'apihelp-setpagelanguage-extended-description-disabled';
66 return parent::getExtendedDescription();
78 if ( !$this->
getConfig()->
get( MainConfigNames::PageLanguageUseDB ) ) {
90 $titleObj = $pageObj->getTitle();
92 if ( !$pageObj->exists() ) {
101 if ( $params[
'tags'] ) {
103 if ( !$tagStatus->isOK() ) {
112 $params[
'reason'] ??
'',
113 $params[
'tags'] ?: [],
114 $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_PRIMARY )
117 if ( !$status->isOK() ) {
122 'title' => $titleObj->getPrefixedText(),
123 'oldlanguage' => $status->value->oldLanguage,
124 'newlanguage' => $status->value->newLanguage,
125 'logid' => $status->value->logId
142 ParamValidator::PARAM_TYPE =>
'integer'
145 ParamValidator::PARAM_TYPE => array_merge(
147 array_keys( $this->languageNameUtils->getLanguageNames(
148 LanguageNameUtils::AUTONYMS,
149 LanguageNameUtils::SUPPORTED
152 ParamValidator::PARAM_REQUIRED =>
true,
156 ParamValidator::PARAM_TYPE =>
'tags',
157 ParamValidator::PARAM_ISMULTI =>
true,
167 $title = Title::newMainPage()->getPrefixedText();
168 $mp = rawurlencode(
$title );
171 "action=setpagelanguage&title={$mp}&lang=eu&token=123ABC"
172 =>
'apihelp-setpagelanguage-example-language',
173 'action=setpagelanguage&pageid=123&lang=default&token=123ABC'
174 =>
'apihelp-setpagelanguage-example-default',
179 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)