38 parent::__construct(
'PageLanguage',
'pagelang' );
46 $this->
getOutput()->addModules(
'mediawiki.special.pageLanguage' );
52 $title = $defaultName ? Title::newFromText( $defaultName ) :
null;
54 $defaultPageLanguage =
55 ContentHandler::getForTitle(
$title )->getPageLanguage(
$title );
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' );
91 'id' =>
'mw-pl-languageselector',
92 'cssclass' =>
'mw-languageselector',
95 'label-message' =>
'pagelang-language',
97 $title->getPageLanguage()->getCode() :
98 $this->
getConfig()->get(
'LanguageCode' ),
104 'label-message' =>
'pagelang-reason'
122 Hooks::run(
'LanguageSelector', [ $this->
getOutput(),
'mw-languageselector' ] );
132 $pageName = $data[
'pagename'];
135 if ( $data[
'selectoptions'] == 1 ) {
136 $newLanguage =
'default';
138 $newLanguage = $data[
'language'];
142 $title = Title::newFromTextThrow( $pageName );
148 $errors =
$title->getUserPermissionsErrors(
'edit', $this->
getUser() );
152 $wikitext =
$out->formatPermissionsErrorMessage( $errors );
154 return Status::newFatal(
new RawMessage(
'$1', [ $wikitext ] ) );
158 $this->goToUrl =
$title->getFullUrlForRedirect(
159 $title->isRedirect() ? [
'redirect' =>
'no' ] : []
166 $data[
'reason'] ??
''
179 $newLanguage, $reason,
array $tags = [] ) {
181 $defLang =
$context->getConfig()->get(
'LanguageCode' );
183 $pageId =
$title->getArticleID();
187 return Status::newFatal(
188 'pagelang-nonexistent-page',
195 $oldLanguage = $dbw->selectField(
198 [
'page_id' => $pageId ],
203 if ( $newLanguage ===
'default' ) {
208 if ( $newLanguage === $oldLanguage ) {
210 if ( !$oldLanguage ) {
213 'pagelang-unchanged-language-default',
216 'pagelang-unchanged-language'
219 return Status::newFatal(
220 'pagelang-unchanged-language',
227 $logOld = $oldLanguage ?: $defLang .
'[def]';
228 $logNew = $newLanguage ?: $defLang .
'[def]';
233 [
'page_lang' => $newLanguage ],
235 'page_id' => $pageId,
236 'page_lang' => $oldLanguage
241 if ( !$dbw->affectedRows() ) {
242 return Status::newFatal(
'pagelang-db-failed' );
247 '4::oldlanguage' => $logOld,
248 '5::newlanguage' => $logNew
251 $entry->setPerformer(
$context->getUser() );
252 $entry->setTarget(
$title );
253 $entry->setParameters( $logParams );
254 $entry->setComment( $reason );
255 $entry->setTags( $tags );
257 $logid = $entry->insert();
258 $entry->publish( $logid );
261 $title->invalidateCache();
263 return Status::newGood( (
object)[
264 'oldLanguage' => $logOld,
265 'newLanguage' => $logNew,
272 $this->
getOutput()->redirect( $this->goToUrl );
276 $moveLogPage =
new LogPage(
'pagelang' );
277 $out1 = Xml::element(
'h2',
null, $moveLogPage->getName()->text() );
280 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.
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 new log entries and inserting 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 document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
Allows to change the fields on the form that will be generated $name
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
switch( $options['output']) $languages