diff --git a/i18n/ve-mw/api/en.json b/i18n/ve-mw/api/en.json index b060555125..99fc8b67d7 100644 --- a/i18n/ve-mw/api/en.json +++ b/i18n/ve-mw/api/en.json @@ -21,7 +21,6 @@ "Yuki Shira" ] }, - "apierror-visualeditor-api-langlinks-error": "Error querying MediaWiki API", "apierror-visualeditor-badcachekey": "No cached serialization found with that key", "apierror-visualeditor-difffailed": "Diff failed", "apierror-visualeditor-docserver-http-error": "$1", diff --git a/i18n/ve-mw/api/qqq.json b/i18n/ve-mw/api/qqq.json index 8aa4a6cf8f..9cb80aef96 100644 --- a/i18n/ve-mw/api/qqq.json +++ b/i18n/ve-mw/api/qqq.json @@ -30,7 +30,6 @@ "Woytecr" ] }, - "apierror-visualeditor-api-langlinks-error": "{{doc-apierror}}", "apierror-visualeditor-badcachekey": "{{doc-apierror}}", "apierror-visualeditor-difffailed": "{{doc-apierror}}", "apierror-visualeditor-docserver-http-error": "{{Ignored}}\n{{doc-apierror}}\n\nParameters:\n* $1 - Error message, probably in English", diff --git a/includes/ApiVisualEditor.php b/includes/ApiVisualEditor.php index bade61710b..5bab0650e7 100644 --- a/includes/ApiVisualEditor.php +++ b/includes/ApiVisualEditor.php @@ -208,48 +208,6 @@ class ApiVisualEditor extends ApiBase { return $content; } - /** - * Provide the current language links for a given page title - * - * @param Title $title The page title for which to get the current language links - * @return string[]|false The language links - */ - protected function getLangLinks( Title $title ) { - $apiParams = [ - 'action' => 'query', - 'prop' => 'langlinks', - 'lllimit' => 500, - 'titles' => $title->getPrefixedDBkey(), - ]; - $api = new ApiMain( - new DerivativeRequest( - $this->getRequest(), - $apiParams, - /* was posted? */ false - ), - /* enable write? */ true - ); - - $api->execute(); - $result = $api->getResult()->getResultData(); - if ( !isset( $result['query']['pages'][$title->getArticleID()] ) ) { - return false; - } - $page = $result['query']['pages'][$title->getArticleID()]; - if ( !isset( $page['langlinks'] ) ) { - return []; - } - $langlinks = $page['langlinks']; - $langnames = Language::fetchLanguageNames(); - foreach ( $langlinks as $i => $lang ) { - // Check is_array() to filter out API metadata (T218464) - if ( is_array( $lang ) && isset( $langnames[$lang['lang']] ) ) { - $langlinks[$i]['langname'] = $langnames[$lang['lang']]; - } - } - return $langlinks; - } - /** * @inheritDoc */ @@ -660,15 +618,6 @@ class ApiVisualEditor extends ApiBase { ]; } break; - - case 'getlanglinks': - $langlinks = $this->getLangLinks( $title ); - if ( $langlinks === false ) { - $this->dieWithError( 'apierror-visualeditor-api-langlinks-error', 'api-langlinks-error' ); - } else { - $result = [ 'result' => 'success', 'langlinks' => $langlinks ]; - } - break; } $this->getResult()->addValue( null, $this->getModuleName(), $result ); @@ -772,7 +721,6 @@ class ApiVisualEditor extends ApiBase { 'wikitext', 'parsefragment', 'parsedoc', - 'getlanglinks', ], ], 'wikitext' => null, diff --git a/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js b/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js index b7eca03ed2..b5dd6fac7a 100644 --- a/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js +++ b/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js @@ -110,13 +110,13 @@ ve.ui.MWLanguagesPage.prototype.onLoadLanguageData = function ( languages ) { */ ve.ui.MWLanguagesPage.prototype.onAllLanguageItemsSuccess = function ( deferred, response ) { var i, iLen, languages = [], - langlinks = response && response.visualeditor && response.visualeditor.langlinks; + langlinks = OO.getProp( response, 'query', 'pages', 0, 'langlinks' ); if ( langlinks ) { for ( i = 0, iLen = langlinks.length; i < iLen; i++ ) { languages.push( { lang: langlinks[ i ].lang, - langname: langlinks[ i ].langname, - title: langlinks[ i ][ '*' ], + langname: langlinks[ i ].autonym, + title: langlinks[ i ].title, metaItem: null } ); } @@ -168,9 +168,13 @@ ve.ui.MWLanguagesPage.prototype.getAllLanguageItems = function () { var deferred = $.Deferred(); // TODO: Detect paging token if results exceed limit ve.init.target.getContentApi().get( { - action: 'visualeditor', - paction: 'getlanglinks', - page: ve.init.target.getPageName() + format: 'json', + formatversion: 2, + action: 'query', + prop: 'langlinks', + llprop: 'autonym', + lllimit: 500, + titles: ve.init.target.getPageName() } ) .done( this.onAllLanguageItemsSuccess.bind( this, deferred ) ) .fail( this.onAllLanguageItemsError.bind( this, deferred ) );