Add a field to Special:Interwiki to add/edit the API URL of interwiki

prefixes

Until now, the only way to add/edit the URL of the API of an interwiki
prefix was to edit the database directly.

The immediate motivation for this change is to make it easier to add new
wikis that can be used by Extension:InterwikiExtracts without requiring
the user to do manual changes to the database, see
https://www.mediawiki.org/wiki/Extension:InterwikiExtracts#New_interwikis

Bug: T244594
Change-Id: Ifd5809aa60eab622d0effc69a39d31cc32d38fef
This commit is contained in:
Sophivorus 2021-09-10 13:24:21 -07:00 committed by Reedy
parent 0f306e5440
commit 4b5b85ab38
3 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,7 @@
"interwiki_url": "URL",
"interwiki-url-label": "URL:",
"interwiki_url_intro": "Template for URLs. The placeholder $1 will be replaced by the <em>pagename</em> in <code>[<nowiki />[prefix:<em>pagename</em>]]</code>.",
"interwiki-api-label": "API:",
"interwiki_local": "Forward",
"interwiki-local-label": "Forward",
"interwiki_local_0_intro": "External HTTP requests to the local wiki using this interwiki prefix in the URL will result in a \"{{int:badtitle}}\" error page.",

View file

@ -29,6 +29,7 @@
"interwiki_url": "{{optional}}\nUsed on [[Special:Interwiki]] as a column header of the table.\n\nSee also:\n*{{msg-mw|Interwiki-url-label}}\n{{Identical|URL}}",
"interwiki-url-label": "{{optional}}\nUsed on [[Special:Interwiki]] as a field label in a form.\n\nSee also:\n* {{msg-mw|interwiki url}}\n{{Identical|URL}}",
"interwiki_url_intro": "Used on [[Special:Interwiki]] so as to explain the data in the {{msg-mw|Interwiki url}} column of the table.\n\nParameters:\n* $1 is being rendered verbatim. It refers to the syntax of the values listed in the \"prefix\" column, and does not mark a substitutable variable of this message.",
"interwiki-api-label": "{{optional}}\nUsed on [[Special:Interwiki]] as a field label in a form.",
"interwiki_local": "Used on [[Special:Interwiki]] as a column header.\n\n{{Identical|Forward}}",
"interwiki-local-label": "Field label for the interwiki property \"local\", to set if an HTTP request to the local wiki with this interwiki prefix in the URL is redirected to the target URL given in the interwiki link definitions.\n{{Identical|Forward}}",
"interwiki_local_0_intro": "Used on [[Special:Interwiki]] so as to describe the meaning of the value 0 in the {{msg-mw|Interwiki local}} column of the table.\n\nRefers to {{msg-mw|Badtitle}}.\n\nSee also:\n* {{msg-mw|Interwiki local 1 intro}}",

View file

@ -144,6 +144,15 @@ class SpecialInterwiki extends SpecialPage {
'size' => 60,
],
'api' => [
'type' => 'url',
'id' => 'mw-interwiki-api',
'label-message' => 'interwiki-api-label',
'maxlength' => 200,
'name' => 'wpInterwikiAPI',
'size' => 60,
],
'reason' => [
'type' => 'text',
'id' => "mw-interwiki-{$action}reason",
@ -191,6 +200,7 @@ class SpecialInterwiki extends SpecialPage {
$status->fatal( 'interwiki_editerror', $prefix );
} else {
$formDescriptor['url']['default'] = $row->iw_url;
$formDescriptor['api']['default'] = $row->iw_api;
$formDescriptor['trans']['default'] = $row->iw_trans;
$formDescriptor['local']['default'] = $row->iw_local;
}
@ -278,11 +288,13 @@ class SpecialInterwiki extends SpecialPage {
$prefix = $contLang->lc( $prefix );
case 'edit':
$theurl = $data['url'];
$api = $data['api'] ?? '';
$local = $data['local'] ? 1 : 0;
$trans = $data['trans'] ? 1 : 0;
$rows = [
'iw_prefix' => $prefix,
'iw_url' => $theurl,
'iw_api' => $api,
'iw_local' => $local,
'iw_trans' => $trans
];