mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 18:58:42 +00:00
Merge "Show full language names in the MW language dialog"
This commit is contained in:
commit
9bf0f5b93e
|
@ -240,6 +240,36 @@ class ApiVisualEditor extends ApiBase {
|
|||
}
|
||||
}
|
||||
|
||||
protected function getLangLinks( $title ) {
|
||||
$apiParams = array(
|
||||
'action' => 'query',
|
||||
'prop' => 'langlinks',
|
||||
'lllimit' => 500,
|
||||
'titles' => $title->getPrefixedDBkey(),
|
||||
'indexpageids' => 1,
|
||||
);
|
||||
$api = new ApiMain(
|
||||
new DerivativeRequest(
|
||||
$this->getRequest(),
|
||||
$apiParams,
|
||||
false // was posted?
|
||||
),
|
||||
true // enable write?
|
||||
);
|
||||
|
||||
$api->execute();
|
||||
$result = $api->getResultData();
|
||||
if ( !isset( $result['query']['pages'][$title->getArticleID()]['langlinks'] ) ) {
|
||||
return false;
|
||||
}
|
||||
$langlinks = $result['query']['pages'][$title->getArticleID()]['langlinks'];
|
||||
$langnames = Language::fetchLanguageNames();
|
||||
foreach ( $langlinks as $i => $lang ) {
|
||||
$langlinks[$i]['langname'] = $langnames[$langlinks[$i]['lang']];
|
||||
}
|
||||
return $langlinks;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgVisualEditorNamespaces, $wgVisualEditorEditNotices;
|
||||
|
||||
|
@ -318,6 +348,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'parsefragment':
|
||||
$content = $this->parseWikitextFragment( $params['wikitext'], $page->getText() );
|
||||
if ( $content === false ) {
|
||||
|
@ -329,6 +360,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'serialize':
|
||||
if ( $params['cachekey'] !== null ) {
|
||||
$content = $this->trySerializationCache( $params['cachekey'] );
|
||||
|
@ -347,6 +379,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
}
|
||||
$result = array( 'result' => 'success', 'content' => $content );
|
||||
break;
|
||||
|
||||
case 'diff':
|
||||
if ( $params['cachekey'] !== null ) {
|
||||
$wikitext = $this->trySerializationCache( $params['cachekey'] );
|
||||
|
@ -367,10 +400,20 @@ class ApiVisualEditor extends ApiBase {
|
|||
$result = $diff;
|
||||
|
||||
break;
|
||||
|
||||
case 'serializeforcache':
|
||||
$key = $this->storeInSerializationCache( $page, $parserParams['oldid'], $params['html'] );
|
||||
$result = array( 'result' => 'success', 'cachekey' => $key );
|
||||
break;
|
||||
|
||||
case 'getlanglinks':
|
||||
$langlinks = $this->getLangLinks( $page );
|
||||
if ( $langlinks === false ) {
|
||||
$this->dieUsage( 'Error querying MediaWiki API', 'parsoidserver' );
|
||||
} else {
|
||||
$result = array( 'result' => 'success', 'langlinks' => $langlinks );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->getResult()->addValue( null, $this->getModuleName(), $result );
|
||||
|
@ -384,7 +427,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
'paction' => array(
|
||||
ApiBase::PARAM_REQUIRED => true,
|
||||
ApiBase::PARAM_TYPE => array(
|
||||
'parse', 'parsefragment', 'serializeforcache', 'serialize', 'diff'
|
||||
'parse', 'parsefragment', 'serializeforcache', 'serialize', 'diff', 'getlanglinks',
|
||||
),
|
||||
),
|
||||
'wikitext' => null,
|
||||
|
@ -401,7 +444,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
}
|
||||
|
||||
public function mustBePosted() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isWriteMode() {
|
||||
|
|
|
@ -77,9 +77,9 @@ $messages['en'] = array(
|
|||
'visualeditor-dialog-meta-categories-options' => 'Options',
|
||||
'visualeditor-dialog-meta-categories-section' => 'Categories',
|
||||
'visualeditor-dialog-meta-categories-sortkey-label' => 'Sort this page as',
|
||||
'visualeditor-dialog-meta-languages-code-label' => 'Language code',
|
||||
'visualeditor-dialog-meta-languages-label' => 'Languages',
|
||||
'visualeditor-dialog-meta-languages-link-label' => 'Linked page',
|
||||
'visualeditor-dialog-meta-languages-name-label' => 'Language',
|
||||
'visualeditor-dialog-meta-languages-readonlynote' => 'This is a list of pages in other languages that are linked to this one; for now, it can only be edited in source mode or on Wikidata.',
|
||||
'visualeditor-dialog-meta-languages-section' => 'Languages',
|
||||
'visualeditor-dialog-meta-title' => 'Page settings',
|
||||
|
@ -473,11 +473,10 @@ Parameters:
|
|||
'visualeditor-dialog-meta-categories-section' => 'Label for the categories dialog section.
|
||||
{{Identical|Category}}',
|
||||
'visualeditor-dialog-meta-categories-sortkey-label' => "Label for setting the page's sort key for a given category",
|
||||
'visualeditor-dialog-meta-languages-code-label' => 'Column header for the language links table, giving the language code of the remote wiki
|
||||
{{Identical|Language code}}',
|
||||
'visualeditor-dialog-meta-languages-label' => '{{Identical|Language}}',
|
||||
'visualeditor-dialog-meta-languages-link-label' => 'Column header for the language links table, giving the name of the remote page.
|
||||
{{Identical|Linked page}}',
|
||||
'visualeditor-dialog-meta-languages-name-label' => 'Column header for the language links table, giving the language name of the remote wiki',
|
||||
'visualeditor-dialog-meta-languages-readonlynote' => 'Text of a note informing users that the language links cannot yet be edited.
|
||||
|
||||
See also:
|
||||
|
|
|
@ -579,9 +579,9 @@ $wgResourceModules += array(
|
|||
'visualeditor-dialog-meta-categories-options',
|
||||
'visualeditor-dialog-meta-categories-section',
|
||||
'visualeditor-dialog-meta-categories-sortkey-label',
|
||||
'visualeditor-dialog-meta-languages-code-label',
|
||||
'visualeditor-dialog-meta-languages-label',
|
||||
'visualeditor-dialog-meta-languages-link-label',
|
||||
'visualeditor-dialog-meta-languages-name-label',
|
||||
'visualeditor-dialog-meta-languages-readonlynote',
|
||||
'visualeditor-dialog-meta-languages-section',
|
||||
'visualeditor-dialog-meta-title',
|
||||
|
|
|
@ -56,7 +56,7 @@ ve.ui.MWLanguagesPage.prototype.onLoadLanguageData = function ( languages ) {
|
|||
.append( this.$( '<tr>' )
|
||||
.append(
|
||||
this.$( '<th>' )
|
||||
.append( ve.msg( 'visualeditor-dialog-meta-languages-code-label' ) )
|
||||
.append( ve.msg( 'visualeditor-dialog-meta-languages-name-label' ) )
|
||||
)
|
||||
.append(
|
||||
this.$( '<th>' )
|
||||
|
@ -75,8 +75,8 @@ ve.ui.MWLanguagesPage.prototype.onLoadLanguageData = function ( languages ) {
|
|||
}
|
||||
$languagesTable
|
||||
.append( this.$( '<tr>' )
|
||||
.append( this.$( '<td>' ).append( languages[i].lang ) )
|
||||
.append( this.$( '<td>' ).append( languages[i].title )
|
||||
.append( this.$( '<td>' ).text( languages[i].langname ) )
|
||||
.append( this.$( '<td>' ).text( languages[i].title )
|
||||
.attr( 'lang', languages[i].safelang )
|
||||
.attr( 'dir', languages[i].dir ) )
|
||||
);
|
||||
|
@ -88,12 +88,13 @@ ve.ui.MWLanguagesPage.prototype.onLoadLanguageData = function ( languages ) {
|
|||
/**
|
||||
* Handle language items being loaded.
|
||||
*/
|
||||
ve.ui.MWLanguagesPage.prototype.onAllLanuageItemsSuccess = function ( deferred, response ) {
|
||||
var i, iLen, languages = [], langlinks = response.query.pages[response.query.pageids[0]].langlinks;
|
||||
ve.ui.MWLanguagesPage.prototype.onAllLanguageItemsSuccess = function ( deferred, response ) {
|
||||
var i, iLen, languages = [], langlinks = response.visualeditor.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]['*'],
|
||||
'metaItem': null
|
||||
} );
|
||||
|
@ -112,6 +113,7 @@ ve.ui.MWLanguagesPage.prototype.getLanguageItemFromMetaListItem = function ( met
|
|||
// TODO: get real values from metaItem once Parsoid actually provides them - bug 48970
|
||||
return {
|
||||
'lang': 'lang',
|
||||
'langname': 'langname',
|
||||
'title': 'title',
|
||||
'metaItem': metaItem
|
||||
};
|
||||
|
@ -147,11 +149,9 @@ ve.ui.MWLanguagesPage.prototype.getAllLanguageItems = function () {
|
|||
$.ajax( {
|
||||
'url': mw.util.wikiScript( 'api' ),
|
||||
'data': {
|
||||
'action': 'query',
|
||||
'prop': 'langlinks',
|
||||
'lllimit': 500,
|
||||
'titles': mw.config.get( 'wgTitle' ),
|
||||
'indexpageids': 1,
|
||||
'action': 'visualeditor',
|
||||
'paction': 'getlanglinks',
|
||||
'page': mw.config.get( 'wgTitle' ),
|
||||
'format': 'json'
|
||||
},
|
||||
'dataType': 'json',
|
||||
|
@ -160,8 +160,8 @@ ve.ui.MWLanguagesPage.prototype.getAllLanguageItems = function () {
|
|||
'timeout': 100000,
|
||||
'cache': 'false'
|
||||
} )
|
||||
.done( ve.bind( this.onAllLanuageItemsSuccess, this, deferred ) )
|
||||
.fail( ve.bind( this.onAllLanuageItemsError, this, deferred ) );
|
||||
.done( ve.bind( this.onAllLanguageItemsSuccess, this, deferred ) )
|
||||
.fail( ve.bind( this.onAllLanguageItemsError, this, deferred ) );
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
|
@ -170,4 +170,4 @@ ve.ui.MWLanguagesPage.prototype.getAllLanguageItems = function () {
|
|||
*
|
||||
* TODO: This error function should probably not be empty.
|
||||
*/
|
||||
ve.ui.MWLanguagesPage.prototype.onAllLanuageItemsError = function () {};
|
||||
ve.ui.MWLanguagesPage.prototype.onAllLanguageItemsError = function () {};
|
||||
|
|
Loading…
Reference in a new issue