Go to the documentation of this file.
11 parent::__construct(
'Interwiki' );
25 'interwiki' :
'interwiki-title-norights' )->plain();
45 $out->addModules(
'ext.interwiki.specialpage' );
47 $action = $par ?:
$request->getVal(
'action', $par );
57 $out->returnToMain(
false, $return );
66 $out->addWikiMsg(
'sessionfailure' );
70 $out->returnToMain(
false, $return );
86 if ( !$this->
getUser()->isAllowed(
'interwiki' ) ) {
96 $out->addWikiMsg(
'interwiki-cached' );
113 $prefix =
$request->getVal(
'prefix' );
115 $label = [
'class' =>
'mw-label' ];
116 $input = [
'class' =>
'mw-input' ];
118 if ( $action ===
'delete' ) {
119 $topmessage = $this->
msg(
'interwiki_delquestion', $prefix )->text();
120 $intromessage = $this->
msg(
'interwiki_deleting', $prefix )->escaped();
121 $wpPrefix =
Html::hidden(
'wpInterwikiPrefix', $prefix );
124 } elseif ( $action ===
'edit' ) {
126 $row =
$dbr->selectRow(
'interwiki',
'*', [
'iw_prefix' => $prefix ], __METHOD__ );
129 $this->
error(
'interwiki_editerror', $prefix );
133 $prefix = $prefixElement = $row->iw_prefix;
134 $defaulturl = $row->iw_url;
135 $trans = $row->iw_trans;
136 $local = $row->iw_local;
137 $wpPrefix =
Html::hidden(
'wpInterwikiPrefix', $row->iw_prefix );
138 $topmessage = $this->
msg(
'interwiki_edittext' )->text();
139 $intromessage = $this->
msg(
'interwiki_editintro' )->escaped();
141 } elseif ( $action ===
'add' ) {
142 $prefix =
$request->getVal(
'wpInterwikiPrefix',
$request->getVal(
'prefix' ) );
143 $prefixElement =
Xml::input(
'wpInterwikiPrefix', 20, $prefix,
144 [
'tabindex' => 1,
'id' =>
'mw-interwiki-prefix',
'maxlength' => 20 ] );
145 $local =
$request->getCheck(
'wpInterwikiLocal' );
146 $trans =
$request->getCheck(
'wpInterwikiTrans' );
147 $defaulturl =
$request->getVal(
'wpInterwikiURL', $this->
msg(
'interwiki-defaulturl' )->
text() );
148 $topmessage = $this->
msg(
'interwiki_addtext' )->text();
149 $intromessage = $this->
msg(
'interwiki_addintro' )->escaped();
150 $button =
'interwiki_addbutton';
153 if ( $action ===
'add' || $action ===
'edit' ) {
163 Xml::label( $this->
msg(
'interwiki-local-label' )->
text(),
'mw-interwiki-local' )
168 Xml::check(
'wpInterwikiLocal', $local, [
'id' =>
'mw-interwiki-local' ] )
174 Xml::label( $this->
msg(
'interwiki-trans-label' )->
text(),
'mw-interwiki-trans' )
178 $input,
Xml::check(
'wpInterwikiTrans', $trans, [
'id' =>
'mw-interwiki-trans' ] ) )
186 [
'tabindex' => 1,
'maxlength' => 200,
'id' =>
'mw-interwiki-url' ] ) )
193 'id' =>
"mw-interwiki-{$action}form",
196 'action' =>
'submit',
204 "mw-interwiki-{$action}reason" ) ) .
206 [
'tabindex' => 1,
'id' =>
"mw-interwiki-{$action}reason",
'maxlength' => 200 ] ) )
223 $prefix =
$request->getVal(
'wpInterwikiPrefix' );
224 $do =
$request->getVal(
'wpInterwikiAction' );
231 if ( $do ===
'add' && preg_match(
"/\s|[^$validPrefixChars]/", $prefix ) ) {
232 $this->
error(
'interwiki-badprefix', htmlspecialchars( $prefix ) );
236 $reason =
$request->getText(
'wpInterwikiReason' );
241 $dbw->delete(
'interwiki', [
'iw_prefix' => $prefix ], __METHOD__ );
243 if ( $dbw->affectedRows() === 0 ) {
244 $this->
error(
'interwiki_delfailed', $prefix );
247 $this->
getOutput()->addWikiMsg(
'interwiki_deleted', $prefix );
248 $log =
new LogPage(
'interwiki' );
249 $log->addEntry(
'iw_delete', $selfTitle, $reason, [ $prefix ] );
257 $theurl =
$request->getVal(
'wpInterwikiURL' );
258 $local =
$request->getCheck(
'wpInterwikiLocal' ) ? 1 : 0;
259 $trans =
$request->getCheck(
'wpInterwikiTrans' ) ? 1 : 0;
261 'iw_prefix' => $prefix,
263 'iw_local' => $local,
267 if ( $prefix ===
'' || $theurl ===
'' ) {
268 $this->
error(
'interwiki-submit-empty' );
277 $this->
error(
'interwiki-submit-invalidurl' );
282 if ( $do ===
'add' ) {
283 $dbw->insert(
'interwiki', $data, __METHOD__,
'IGNORE' );
285 $dbw->update(
'interwiki', $data, [
'iw_prefix' => $prefix ], __METHOD__,
'IGNORE' );
289 if ( $dbw->affectedRows() === 0 ) {
290 $this->
error(
"interwiki_{$do}failed", $prefix );
293 $this->
getOutput()->addWikiMsg(
"interwiki_{$do}ed", $prefix );
294 $log =
new LogPage(
'interwiki' );
295 $log->addEntry(
'iw_' . $do, $selfTitle, $reason, [ $prefix, $theurl, $trans, $local ] );
303 global $wgInterwikiCentralDB, $wgInterwikiViewOnly;
307 if ( !method_exists(
'Interwiki',
'getAllPrefixes' ) ) {
309 $this->
error(
'interwiki_error' );
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' )->escaped()
348 $this->
getOutput()->addHTML(
'<p class="mw-interwiki-log">' . $logLink .
'</p>' );
353 if (
count( $iwGlobalPrefixes ) !== 0 ) {
354 $addtext = $this->
msg(
'interwiki-addtext-local' )->escaped();
356 $addtext = $this->
msg(
'interwiki_addtext' )->escaped();
359 $this->
getOutput()->addHTML(
'<p class="mw-interwiki-addlink">' . $addlink .
'</p>' );
362 $this->
getOutput()->addWikiMsg(
'interwiki-legend' );
364 if ( ( !is_array( $iwPrefixes ) ||
count( $iwPrefixes ) === 0 ) &&
365 ( !is_array( $iwGlobalPrefixes ) ||
count( $iwGlobalPrefixes ) === 0 )
368 $this->
error(
'interwiki_error' );
373 if (
count( $iwGlobalPrefixes ) !== 0 ) {
375 '<h2 id="interwikitable-global">' .
376 $this->
msg(
'interwiki-global-links' )->parse() .
379 $this->
getOutput()->addWikiMsg(
'interwiki-global-description' );
382 $this->
makeTable(
false, $iwGlobalPrefixes );
386 if (
count( $iwLocalPrefixes ) !== 0 ) {
387 if (
count( $iwGlobalPrefixes ) !== 0 ) {
389 '<h2 id="interwikitable-local">' .
390 $this->
msg(
'interwiki-local-links' )->parse() .
393 $this->
getOutput()->addWikiMsg(
'interwiki-local-description' );
396 '<h2 id="interwikitable-local">' .
397 $this->
msg(
'interwiki-links' )->parse() .
400 $this->
getOutput()->addWikiMsg(
'interwiki-description' );
402 $this->
makeTable( $canModify, $iwLocalPrefixes );
406 if (
count( $iwLanguagePrefixes ) !== 0 ) {
408 '<h2 id="interwikitable-language">' .
409 $this->
msg(
'interwiki-language-links' )->parse() .
412 $this->
getOutput()->addWikiMsg(
'interwiki-language-description' );
414 $this->
makeTable( $canModify, $iwLanguagePrefixes );
418 protected function makeTable( $canModify, $iwPrefixes ) {
423 [
'class' =>
'mw-interwikitable wikitable sortable body' ]
433 [
'class' =>
'unsortable' ],
434 $this->
msg(
'interwiki_edit' )->
text()
443 foreach ( $iwPrefixes
as $iwPrefix ) {
446 $iwPrefix[
'iw_prefix'] );
449 [
'class' =>
'mw-interwikitable-url' ],
452 $attribs = [
'class' =>
'mw-interwikitable-local' ];
454 if ( isset( $iwPrefix[
'iw_local'] ) && $iwPrefix[
'iw_local'] ) {
455 $attribs[
'class'] .=
' mw-interwikitable-local-yes';
458 $contents = isset( $iwPrefix[
'iw_local'] ) ?
459 $this->
msg(
'interwiki_' . $iwPrefix[
'iw_local'] )->text() :
462 $attribs = [
'class' =>
'mw-interwikitable-trans' ];
464 if ( isset( $iwPrefix[
'iw_trans'] ) && $iwPrefix[
'iw_trans'] ) {
465 $attribs[
'class'] .=
' mw-interwikitable-trans-yes';
468 $contents = isset( $iwPrefix[
'iw_trans'] ) ?
469 $this->
msg(
'interwiki_' . $iwPrefix[
'iw_trans'] )->text() :
477 [
'action' =>
'edit',
'prefix' => $iwPrefix[
'iw_prefix'] ] ) .
478 $this->
msg(
'comma-separator' ) .
480 [
'action' =>
'delete',
'prefix' => $iwPrefix[
'iw_prefix'] ] )
491 $args = func_get_args();
492 $this->
getOutput()->wrapWikiMsg(
"<p class='error'>$1</p>",
$args );
508 $params = parent::getMessageParameters();
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.
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.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static invalidateCache( $prefix)
Purge the cache (local and persistent) for an interwiki prefix.
static getAllPrefixes( $local=null)
Returns all interwiki prefix definitions.
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 linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
when a variable name is used in a it is silently declared as a new masking the global
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.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
getRequest()
Get the WebRequest being used for this instance.
execute( $par)
Show the special page.
static fetchLanguageName( $code, $inLanguage=null, $include='all')
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()).
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.
the array() calling protocol came about after MediaWiki 1.4rc1.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
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