38 parent::__construct(
'PageLanguage',
'pagelang' );
46 $this->
getOutput()->addModules(
'mediawiki.special.pageLanguage' );
52 $title = $defaultName ? Title::newFromText( $defaultName ) :
null;
54 $defaultPageLanguage =
56 $hasCustomLanguageSet = !$defaultPageLanguage->equals( $title->getPageLanguage() );
58 $hasCustomLanguageSet =
false;
64 'label-message' =>
'pagelang-name',
65 'default' => $title ? $title->getPrefixedText() : $defaultName,
66 'autofocus' => $defaultName ===
null,
72 (
string)$this->
msg(
'pagelang-use-default' )->escaped() => 1,
73 (
string)$this->
msg(
'pagelang-select-lang' )->escaped() => 2,
75 $page[
'selectoptions'] = [
76 'id' =>
'mw-pl-options',
78 'options' => $selectoptions,
79 'default' => $hasCustomLanguageSet ? 2 : 1
84 $languages = Language::fetchLanguageNames( $userLang,
'mwfile' );
92 'id' =>
'mw-pl-languageselector',
93 'cssclass' =>
'mw-languageselector',
96 'label-message' =>
'pagelang-language',
98 $title->getPageLanguage()->getCode() :
99 $this->
getConfig()->get(
'LanguageCode' ),
105 'label-message' =>
'pagelang-reason'
123 Hooks::run(
'LanguageSelector', [ $this->
getOutput(),
'mw-languageselector' ] );
133 $pageName = $data[
'pagename'];
136 if ( $data[
'selectoptions'] == 1 ) {
137 $newLanguage =
'default';
139 $newLanguage = $data[
'language'];
143 $title = Title::newFromTextThrow( $pageName );
145 return Status::newFatal( $ex->getMessageObject() );
149 $errors = $title->getUserPermissionsErrors(
'edit', $this->
getUser() );
153 $wikitext =
$out->formatPermissionsErrorMessage( $errors );
155 return Status::newFatal(
new RawMessage(
'$1', [ $wikitext ] ) );
159 $this->goToUrl = $title->getFullUrlForRedirect(
160 $title->isRedirect() ? [
'redirect' =>
'no' ] : []
167 $data[
'reason'] ===
null ?
'' : $data[
'reason']
180 $newLanguage, $reason, array $tags = [] ) {
182 $defLang =
$context->getConfig()->get(
'LanguageCode' );
184 $pageId = $title->getArticleID();
188 return Status::newFatal(
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'
220 return Status::newFatal(
221 'pagelang-unchanged-language',
228 $logOld = $oldLanguage ? $oldLanguage : $defLang .
'[def]';
229 $logNew = $newLanguage ? $newLanguage : $defLang .
'[def]';
234 [
'page_lang' => $newLanguage ],
236 'page_id' => $pageId,
237 'page_lang' => $oldLanguage
242 if ( !$dbw->affectedRows() ) {
243 return Status::newFatal(
'pagelang-db-failed' );
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->setTags( $tags );
258 $logid = $entry->insert();
259 $entry->publish( $logid );
262 $title->invalidateCache();
264 return Status::newGood( (
object)[
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;
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Special page which uses an HTMLForm to handle processing.
string $par
The sub-page of the special page.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class to simplify the use of log pages.
Class for creating log entries manually, to inject them into the database.
Variant of the Message class.
Special page for changing the content language of a page.
getFormFields()
Get an HTMLForm descriptor array.
postText()
Add post-text to the form.
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...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static changePageLanguage(IContextSource $context, Title $title, $newLanguage, $reason, array $tags=[])
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
doesWrites()
Indicates whether this special page may perform database writes.
getDisplayFormat()
Get display format for the form.
string $goToUrl
URL to go to if language change successful.
preText()
Add pre-text to the form.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
Represents a title within MediaWiki.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Interface for objects which can provide a MediaWiki context on request.
switch( $options['output']) $languages