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 );
66 !$this->getUser()->matchEditToken(
$request->getVal(
'wpEditToken' ) )
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' ) {
157 $formContent = Html::rawElement(
'tr',
null,
158 Html::element(
'td', $label, $this->
msg(
'interwiki-prefix-label' )->
text() ) .
159 Html::rawElement(
'td',
null,
'<code>' . $prefixElement .
'</code>' )
160 ) . Html::rawElement(
166 Xml::label( $this->
msg(
'interwiki-local-label' )->
text(),
'mw-interwiki-local' )
171 Xml::check(
'wpInterwikiLocal', $local, [
'id' =>
'mw-interwiki-local' ] )
173 ) . Html::rawElement(
'tr',
null,
177 Xml::label( $this->
msg(
'interwiki-trans-label' )->
text(),
'mw-interwiki-trans' )
181 $input, Xml::check(
'wpInterwikiTrans', $trans, [
'id' =>
'mw-interwiki-trans' ] ) )
182 ) . Html::rawElement(
'tr',
null,
186 Xml::label( $this->
msg(
'interwiki-url-label' )->
text(),
'mw-interwiki-url' )
188 Html::rawElement(
'td',
$input, Xml::input(
'wpInterwikiURL', 60, $defaulturl,
189 [
'tabindex' => 1,
'maxlength' => 200,
'id' =>
'mw-interwiki-url' ] ) )
193 $form = Xml::fieldset( $topmessage, Html::rawElement(
196 'id' =>
"mw-interwiki-{$action}form",
199 'action' =>
'submit',
203 Html::rawElement(
'p',
null, $intromessage ) .
204 Html::rawElement(
'table', [
'id' =>
"mw-interwiki-{$action}" ],
205 $formContent . Html::rawElement(
'tr',
null,
206 Html::rawElement(
'td', $label, Xml::label( $this->
msg(
'interwiki_reasonfield' )->
text(),
207 "mw-interwiki-{$action}reason" ) ) .
208 Html::rawElement(
'td',
$input, Xml::input(
'wpInterwikiReason', 60,
'',
209 [
'tabindex' => 1,
'id' =>
"mw-interwiki-{$action}reason",
'maxlength' => 200 ] ) )
210 ) . Html::rawElement(
'tr',
null,
211 Html::rawElement(
'td',
null,
'' ) .
212 Html::rawElement(
'td', [
'class' =>
'mw-submit' ],
213 Xml::submitButton( $this->
msg( $button )->
text(), [
'id' =>
'mw-interwiki-submit' ] ) )
215 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken() ) .
216 Html::hidden(
'wpInterwikiAction', $action )
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 ) {
321 if ( !Language::fetchLanguageName( $row[
'iw_prefix'] ) ) {
329 $iwLocalPrefixes = [];
330 $iwLanguagePrefixes = [];
331 foreach ( $iwPrefixes as $iwPrefix ) {
332 if ( Language::fetchLanguageName( $iwPrefix[
'iw_prefix'] ) ) {
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 ) {
423 $out .= Html::openElement(
425 [
'class' =>
'mw-interwikitable wikitable sortable body' ]
427 $out .= Html::openElement(
'tr', [
'class' =>
'interwikitable-header' ] ) .
428 Html::element(
'th',
null, $this->
msg(
'interwiki_prefix' )->
text() ) .
429 Html::element(
'th',
null, $this->
msg(
'interwiki_url' )->
text() ) .
430 Html::element(
'th',
null, $this->
msg(
'interwiki_local' )->
text() ) .
431 Html::element(
'th',
null, $this->
msg(
'interwiki_trans' )->
text() ) .
435 [
'class' =>
'unsortable' ],
436 $this->
msg(
'interwiki_edit' )->
text()
440 $out .= Html::closeElement(
'tr' ) .
"\n";
445 foreach ( $iwPrefixes as $iwPrefix ) {
446 $out .= Html::openElement(
'tr', [
'class' =>
'mw-interwikitable-row' ] );
447 $out .= Html::element(
'td', [
'class' =>
'mw-interwikitable-prefix' ],
448 $iwPrefix[
'iw_prefix'] );
449 $out .= Html::element(
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() :
477 $out .= Html::rawElement(
'td', [
'class' =>
'mw-interwikitable-modify' ],
482 [
'action' =>
'edit',
'prefix' => $iwPrefix[
'iw_prefix'] ]
484 $this->
msg(
'comma-separator' ) .
487 $this->
msg(
'delete' )->
text(),
489 [
'action' =>
'delete',
'prefix' => $iwPrefix[
'iw_prefix'] ]
493 $out .= Html::closeElement(
'tr' ) .
"\n";
495 $out .= Html::closeElement(
'table' );
501 $args = func_get_args();
502 $this->
getOutput()->wrapWikiMsg(
"<p class='error'>$1</p>",
$args );
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
$wgLegalTitleChars
Allowed title characters – regex character class Don't change this unless you know what you're doing.
bool array string $wgInterwikiCache
Interwiki cache, either as an associative array or a path to a constant database (....
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Class to simplify the use of log pages.
Show an error when a user tries to do something they do not have the necessary permissions for.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
Implements Special:Interwiki.
canModify( $out=false)
Returns boolean whether the user can modify the data.
getDescription()
Different description will be shown on Special:SpecialPage depending on whether the user can modify t...
__construct()
Constructor - sets up the new special page.
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept for prefix searches.
doesWrites()
Indicates whether this special page may perform database writes.
execute( $par)
Show the special page.
makeTable( $canModify, $iwPrefixes)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
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,...
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
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
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 local account incomplete not yet checked for validity & $retval
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
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
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))
if(is_array($mode)) switch( $mode) $input