From 4b5b85ab38c52e813c1399a6eaf4f369be91fafc Mon Sep 17 00:00:00 2001 From: Sophivorus Date: Fri, 10 Sep 2021 13:24:21 -0700 Subject: [PATCH] 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 --- i18n/en.json | 1 + i18n/qqq.json | 1 + includes/SpecialInterwiki.php | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/i18n/en.json b/i18n/en.json index 5096eaab..700667cc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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 pagename in [[prefix:pagename]].", + "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.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 16679716..536f1cf7 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -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}}", diff --git a/includes/SpecialInterwiki.php b/includes/SpecialInterwiki.php index 01144d71..76c6ec4e 100644 --- a/includes/SpecialInterwiki.php +++ b/includes/SpecialInterwiki.php @@ -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 ];