aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryLangLinks.php
diff options
context:
space:
mode:
authorumherirrender <umherirrender_de.wp@web.de>2014-02-11 20:04:32 +0100
committerAnomie <bjorsch@wikimedia.org>2014-02-12 15:18:50 +0000
commit4ba3a9aea96ee21c035c69999be23580e23f4e0a (patch)
treea9c09b03d4b612f9272faafcaba65efbe8f21402 /includes/api/ApiQueryLangLinks.php
parent4265d8f23f205079a48dbb03a32347b5f3a9a396 (diff)
downloadmediawikicore-4ba3a9aea96ee21c035c69999be23580e23f4e0a.tar.gz
mediawikicore-4ba3a9aea96ee21c035c69999be23580e23f4e0a.zip
Add llprop=langname and llprop=autonym for action=query&prop=langlinks
This can helps the client to build a language html. Change-Id: I54c66c8935b0dbbf3bf8e292236119597f1cbe41
Diffstat (limited to 'includes/api/ApiQueryLangLinks.php')
-rw-r--r--includes/api/ApiQueryLangLinks.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php
index 506bd2e06df2..5a45a28fa86f 100644
--- a/includes/api/ApiQueryLangLinks.php
+++ b/includes/api/ApiQueryLangLinks.php
@@ -117,6 +117,12 @@ class ApiQueryLangLinks extends ApiQueryBase {
$entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
}
}
+ if ( isset( $prop['langname'] ) ) {
+ $entry['langname'] = Language::fetchLanguageName( $row->ll_lang, $params['inlanguagecode'] );
+ }
+ if ( isset( $prop['autonym'] ) ) {
+ $entry['autonym'] = Language::fetchLanguageName( $row->ll_lang );
+ }
ApiResult::setContent( $entry, $row->ll_title );
$fit = $this->addPageSubItem( $row->ll_from, $entry );
if ( !$fit ) {
@@ -131,6 +137,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
}
public function getAllowedParams() {
+ global $wgContLang;
return array(
'limit' => array(
ApiBase::PARAM_DFLT => 10,
@@ -148,6 +155,8 @@ class ApiQueryLangLinks extends ApiQueryBase {
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => array(
'url',
+ 'langname',
+ 'autonym',
)
),
'lang' => null,
@@ -159,6 +168,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
'descending'
)
),
+ 'inlanguagecode' => $wgContLang->getCode(),
);
}
@@ -169,11 +179,15 @@ class ApiQueryLangLinks extends ApiQueryBase {
'url' => "Whether to get the full URL (Cannot be used with {$this->getModulePrefix()}prop)",
'prop' => array(
'Which additional properties to get for each interlanguage link',
- ' url - Adds the full URL',
+ ' url - Adds the full URL',
+ ' langname - Adds the localised language name (best effort, use CLDR extension)',
+ " Use {$this->getModulePrefix()}inlanguagecode to control the language",
+ ' autonym - Adds the native language name',
),
'lang' => 'Language code',
'title' => "Link to search for. Must be used with {$this->getModulePrefix()}lang",
'dir' => 'The direction in which to list',
+ 'inlanguagecode' => 'Language code for localised language names',
);
}
@@ -185,6 +199,14 @@ class ApiQueryLangLinks extends ApiQueryBase {
ApiBase::PROP_TYPE => 'string',
ApiBase::PROP_NULLABLE => true
),
+ 'langname' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ ),
+ 'autonym' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ ),
'*' => 'string'
)
);