Go to the documentation of this file.
38 parent::__construct(
'PageLanguage',
'pagelang' );
46 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
47 return parent::preText();
55 $defaultPageLanguage =
57 $hasCustomLanguageSet = !$defaultPageLanguage->equals(
$title->getPageLanguage() );
59 $hasCustomLanguageSet =
false;
65 'label-message' =>
'pagelang-name',
66 'default' =>
$title ?
$title->getPrefixedText() : $defaultName,
67 'autofocus' => $defaultName ===
null,
73 (string)$this->
msg(
'pagelang-use-default' )->escaped() => 1,
74 (string)$this->
msg(
'pagelang-select-lang' )->escaped() => 2,
76 $page[
'selectoptions'] = [
77 'id' =>
'mw-pl-options',
79 'options' => $selectoptions,
80 'default' => $hasCustomLanguageSet ? 2 : 1
88 $options[
"$code - $name"] = $code;
92 'id' =>
'mw-pl-languageselector',
93 'cssclass' =>
'mw-languageselector',
95 'options' => $options,
96 'label-message' =>
'pagelang-language',
98 $title->getPageLanguage()->getCode() :
99 $this->
getConfig()->get(
'LanguageCode' ),
105 'label-message' =>
'pagelang-reason'
133 $pageName = $data[
'pagename'];
136 if ( $data[
'selectoptions'] == 1 ) {
137 $newLanguage =
'default';
139 $newLanguage = $data[
'language'];
149 $errors =
$title->getUserPermissionsErrors(
'edit', $this->
getUser() );
153 $wikitext = $out->formatPermissionsErrorMessage( $errors );
159 $this->goToUrl =
$title->getFullUrlForRedirect(
160 $title->isRedirect() ? [
'redirect' =>
'no' ] : []
167 $data[
'reason'] ??
''
180 $newLanguage, $reason, array $tags = [] ) {
182 $defLang =
$context->getConfig()->get(
'LanguageCode' );
184 $pageId =
$title->getArticleID();
189 'pagelang-nonexistent-page',
196 $oldLanguage = $dbw->selectField(
199 [
'page_id' => $pageId ],
204 if ( $newLanguage ===
'default' ) {
209 if ( $newLanguage === $oldLanguage ) {
211 if ( !$oldLanguage ) {
214 'pagelang-unchanged-language-default',
217 'pagelang-unchanged-language'
221 'pagelang-unchanged-language',
228 $logOld = $oldLanguage ?: $defLang .
'[def]';
229 $logNew = $newLanguage ?: $defLang .
'[def]';
234 [
'page_lang' => $newLanguage ],
236 'page_id' => $pageId,
237 'page_lang' => $oldLanguage
242 if ( !$dbw->affectedRows() ) {
248 '4::oldlanguage' => $logOld,
249 '5::newlanguage' => $logNew
252 $entry->setPerformer(
$context->getUser() );
253 $entry->setTarget(
$title );
254 $entry->setParameters( $logParams );
255 $entry->setComment( $reason );
256 $entry->addTags( $tags );
258 $logid = $entry->insert();
259 $entry->publish( $logid );
262 $title->invalidateCache();
265 'oldLanguage' => $logOld,
266 'newLanguage' => $logNew,
273 $this->
getOutput()->redirect( $this->goToUrl );
277 $moveLogPage =
new LogPage(
'pagelang' );
278 $out1 =
Xml::element(
'h2',
null, $moveLogPage->getName()->text() );
281 return $out1 . $out2;
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
postText()
Add post-text to the form.
getOutput()
Get the OutputPage being used for this instance.
switch( $options['output']) $languages
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Special page which uses an HTMLForm to handle processing.
doesWrites()
Indicates whether this special page may perform database writes.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
getLanguage()
Shortcut to get user's language.
preText()
Add pre-text to the form.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
getDisplayFormat()
Get display format for the form.
getConfig()
Shortcut to get main config object.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
getUser()
Shortcut to get the User executing this instance.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
getContext()
Gets the context this SpecialPage is executed in.
string null $par
The sub-page of the special page.
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
string $goToUrl
URL to go to if language change successful.
static newGood( $value=null)
Factory function for good results.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
Interface for objects which can provide a MediaWiki context on request.
static changePageLanguage(IContextSource $context, Title $title, $newLanguage, $reason, array $tags=[])
Represents a title within MediaWiki.
Special page for changing the content language of a page.
getFormFields()
Get an HTMLForm descriptor array.
Class for creating new log entries and inserting them into the database.
Variant of the Message class.
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.