Go to the documentation of this file.
14 parent::__construct(
'Interwiki' );
28 'interwiki' :
'interwiki-title-norights' )->plain();
48 $out->addModuleStyles(
'ext.interwiki.specialpage' );
50 $action = $par ?:
$request->getVal(
'action', $par );
60 $out->returnToMain(
false, $return );
69 $out->addWikiMsg(
'sessionfailure' );
73 $out->returnToMain(
false, $return );
89 if ( !$this->
getUser()->isAllowed(
'interwiki' ) ) {
99 $out->addWikiMsg(
'interwiki-cached' );
116 $prefix =
$request->getVal(
'prefix' );
118 $label = [
'class' =>
'mw-label' ];
119 $input = [
'class' =>
'mw-input' ];
121 if ( $action ===
'delete' ) {
122 $topmessage = $this->
msg(
'interwiki_delquestion', $prefix )->text();
123 $intromessage = $this->
msg(
'interwiki_deleting', $prefix )->escaped();
124 $wpPrefix =
Html::hidden(
'wpInterwikiPrefix', $prefix );
127 } elseif ( $action ===
'edit' ) {
129 $row =
$dbr->selectRow(
'interwiki',
'*', [
'iw_prefix' => $prefix ], __METHOD__ );
132 $this->
error(
'interwiki_editerror', $prefix );
136 $prefix = $prefixElement = $row->iw_prefix;
137 $defaulturl = $row->iw_url;
138 $trans = $row->iw_trans;
139 $local = $row->iw_local;
140 $wpPrefix =
Html::hidden(
'wpInterwikiPrefix', $row->iw_prefix );
141 $topmessage = $this->
msg(
'interwiki_edittext' )->text();
142 $intromessage = $this->
msg(
'interwiki_editintro' )->escaped();
144 } elseif ( $action ===
'add' ) {
145 $prefix =
$request->getVal(
'wpInterwikiPrefix',
$request->getVal(
'prefix' ) );
146 $prefixElement =
Xml::input(
'wpInterwikiPrefix', 20, $prefix,
147 [
'tabindex' => 1,
'id' =>
'mw-interwiki-prefix',
'maxlength' => 20 ] );
148 $local =
$request->getCheck(
'wpInterwikiLocal' );
149 $trans =
$request->getCheck(
'wpInterwikiTrans' );
150 $defaulturl =
$request->getVal(
'wpInterwikiURL', $this->
msg(
'interwiki-defaulturl' )->
text() );
151 $topmessage = $this->
msg(
'interwiki_addtext' )->text();
152 $intromessage = $this->
msg(
'interwiki_addintro' )->escaped();
153 $button =
'interwiki_addbutton';
156 if ( $action ===
'add' || $action ===
'edit' ) {
166 Xml::label( $this->
msg(
'interwiki-local-label' )->
text(),
'mw-interwiki-local' )
171 Xml::check(
'wpInterwikiLocal', $local, [
'id' =>
'mw-interwiki-local' ] )
177 Xml::label( $this->
msg(
'interwiki-trans-label' )->
text(),
'mw-interwiki-trans' )
181 $input,
Xml::check(
'wpInterwikiTrans', $trans, [
'id' =>
'mw-interwiki-trans' ] ) )
189 [
'tabindex' => 1,
'maxlength' => 200,
'id' =>
'mw-interwiki-url' ] ) )
196 'id' =>
"mw-interwiki-{$action}form",
199 'action' =>
'submit',
207 "mw-interwiki-{$action}reason" ) ) .
209 [
'tabindex' => 1,
'id' =>
"mw-interwiki-{$action}reason",
'maxlength' => 200 ] ) )
226 $prefix =
$request->getVal(
'wpInterwikiPrefix' );
227 $do =
$request->getVal(
'wpInterwikiAction' );
234 if ( $do ===
'add' && preg_match(
"/\s|[^$validPrefixChars]/", $prefix ) ) {
235 $this->
error(
'interwiki-badprefix', htmlspecialchars( $prefix ) );
239 $reason =
$request->getText(
'wpInterwikiReason' );
241 $lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
245 $dbw->delete(
'interwiki', [
'iw_prefix' => $prefix ], __METHOD__ );
247 if ( $dbw->affectedRows() === 0 ) {
248 $this->
error(
'interwiki_delfailed', $prefix );
251 $this->
getOutput()->addWikiMsg(
'interwiki_deleted', $prefix );
252 $log =
new LogPage(
'interwiki' );
253 $log->addEntry(
'iw_delete', $selfTitle, $reason, [ $prefix ] );
254 $lookup->invalidateCache( $prefix );
261 $theurl =
$request->getVal(
'wpInterwikiURL' );
262 $local =
$request->getCheck(
'wpInterwikiLocal' ) ? 1 : 0;
263 $trans =
$request->getCheck(
'wpInterwikiTrans' ) ? 1 : 0;
265 'iw_prefix' => $prefix,
267 'iw_local' => $local,
271 if ( $prefix ===
'' || $theurl ===
'' ) {
272 $this->
error(
'interwiki-submit-empty' );
281 $this->
error(
'interwiki-submit-invalidurl' );
286 if ( $do ===
'add' ) {
287 $dbw->insert(
'interwiki', $data, __METHOD__,
'IGNORE' );
289 $dbw->update(
'interwiki', $data, [
'iw_prefix' => $prefix ], __METHOD__,
'IGNORE' );
293 if ( $dbw->affectedRows() === 0 ) {
294 $this->
error(
"interwiki_{$do}failed", $prefix );
297 $this->
getOutput()->addWikiMsg(
"interwiki_{$do}ed", $prefix );
298 $log =
new LogPage(
'interwiki' );
299 $log->addEntry(
'iw_' . $do, $selfTitle, $reason, [ $prefix, $theurl, $trans, $local ] );
300 $lookup->invalidateCache( $prefix );
307 global $wgInterwikiCentralDB, $wgInterwikiViewOnly;
311 $lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
312 $iwPrefixes = $lookup->getAllPrefixes(
null );
313 $iwGlobalPrefixes = [];
314 if ( $wgInterwikiCentralDB !==
null && $wgInterwikiCentralDB !==
wfWikiID() ) {
317 $res = $dbrCentralDB->select(
'interwiki',
'*',
false, __METHOD__ );
319 foreach (
$res as $row ) {
329 $iwLocalPrefixes = [];
330 $iwLanguagePrefixes = [];
331 foreach ( $iwPrefixes
as $iwPrefix ) {
333 $iwLanguagePrefixes[] = $iwPrefix;
335 $iwLocalPrefixes[] = $iwPrefix;
340 $this->
getOutput()->addWikiMsg(
'interwiki_intro' );
343 if ( $wgInterwikiViewOnly ===
false ) {
346 $this->
msg(
'interwiki-logtext' )->
text()
348 $this->
getOutput()->addHTML(
'<p class="mw-interwiki-log">' . $logLink .
'</p>' );
353 if (
count( $iwGlobalPrefixes ) !== 0 ) {
354 $addtext = $this->
msg(
'interwiki-addtext-local' )->text();
356 $addtext = $this->
msg(
'interwiki_addtext' )->text();
361 '<p class="mw-interwiki-addlink">' . $addlink .
'</p>' );
364 $this->
getOutput()->addWikiMsg(
'interwiki-legend' );
366 if ( ( !is_array( $iwPrefixes ) ||
count( $iwPrefixes ) === 0 ) &&
367 ( !is_array( $iwGlobalPrefixes ) ||
count( $iwGlobalPrefixes ) === 0 )
370 $this->
error(
'interwiki_error' );
375 if (
count( $iwGlobalPrefixes ) !== 0 ) {
377 '<h2 id="interwikitable-global">' .
378 $this->
msg(
'interwiki-global-links' )->parse() .
381 $this->
getOutput()->addWikiMsg(
'interwiki-global-description' );
384 $this->
makeTable(
false, $iwGlobalPrefixes );
388 if (
count( $iwLocalPrefixes ) !== 0 ) {
389 if (
count( $iwGlobalPrefixes ) !== 0 ) {
391 '<h2 id="interwikitable-local">' .
392 $this->
msg(
'interwiki-local-links' )->parse() .
395 $this->
getOutput()->addWikiMsg(
'interwiki-local-description' );
398 '<h2 id="interwikitable-local">' .
399 $this->
msg(
'interwiki-links' )->parse() .
402 $this->
getOutput()->addWikiMsg(
'interwiki-description' );
404 $this->
makeTable( $canModify, $iwLocalPrefixes );
408 if (
count( $iwLanguagePrefixes ) !== 0 ) {
410 '<h2 id="interwikitable-language">' .
411 $this->
msg(
'interwiki-language-links' )->parse() .
414 $this->
getOutput()->addWikiMsg(
'interwiki-language-description' );
416 $this->
makeTable( $canModify, $iwLanguagePrefixes );
420 protected function makeTable( $canModify, $iwPrefixes ) {
425 [
'class' =>
'mw-interwikitable wikitable sortable body' ]
435 [
'class' =>
'unsortable' ],
436 $this->
msg(
'interwiki_edit' )->
text()
445 foreach ( $iwPrefixes
as $iwPrefix ) {
448 $iwPrefix[
'iw_prefix'] );
451 [
'class' =>
'mw-interwikitable-url' ],
454 $attribs = [
'class' =>
'mw-interwikitable-local' ];
456 if ( isset( $iwPrefix[
'iw_local'] ) && $iwPrefix[
'iw_local'] ) {
457 $attribs[
'class'] .=
' mw-interwikitable-local-yes';
460 $contents = isset( $iwPrefix[
'iw_local'] ) ?
461 $this->
msg(
'interwiki_' . $iwPrefix[
'iw_local'] )->text() :
464 $attribs = [
'class' =>
'mw-interwikitable-trans' ];
466 if ( isset( $iwPrefix[
'iw_trans'] ) && $iwPrefix[
'iw_trans'] ) {
467 $attribs[
'class'] .=
' mw-interwikitable-trans-yes';
470 $contents = isset( $iwPrefix[
'iw_trans'] ) ?
471 $this->
msg(
'interwiki_' . $iwPrefix[
'iw_trans'] )->text() :
482 [
'action' =>
'edit',
'prefix' => $iwPrefix[
'iw_prefix'] ]
484 $this->
msg(
'comma-separator' ) .
487 $this->
msg(
'delete' )->
text(),
489 [
'action' =>
'delete',
'prefix' => $iwPrefix[
'iw_prefix'] ]
501 $args = func_get_args();
502 $this->
getOutput()->wrapWikiMsg(
"<p class='error'>$1</p>",
$args );
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
getPageTitle( $subpage=false)
Get a self-referential title object.
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
msg( $key)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
$wgLegalTitleChars
Allowed title characters – regex character class Don't change this unless you know what you're doing.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
bool array string $wgInterwikiCache
Interwiki cache, either as an associative array or a path to a constant database (....
wfReadOnly()
Check whether the wiki is in read-only mode.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
__construct()
Constructor - sets up the new special page.
Show an error when a user tries to do something they do not have the necessary permissions for.
makeTable( $canModify, $iwPrefixes)
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
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
static closeElement( $element)
Returns "</$element>".
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
getDescription()
Different description will be shown on Special:SpecialPage depending on whether the user can modify t...
doesWrites()
Indicates whether this special page may perform database writes.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(is_array( $mode)) switch( $mode) $input
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Class to simplify the use of log pages.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
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))
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 $request
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Parent class for all special pages.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
Implements Special:Interwiki.
getRequest()
Get the WebRequest being used for this instance.
execute( $par)
Show the special page.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
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
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
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 MediaWikiServices
canModify( $out=false)
Returns boolean whether the user can modify the data.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept for prefix searches.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
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