X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryLangLinks.php;h=53cfba1ec87f8625c17e72ebdb7bdbbe0c97e041;hb=af2c2b6331842bc9e66d5cdda27291de585c8ea5;hp=506bd2e06df2ede3d67d36eb621ff9b232b0424b;hpb=06debf1eb6affacbcdcdf4db5cfafe5e87c734a9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 506bd2e06d..53cfba1ec8 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -31,7 +31,7 @@ */ class ApiQueryLangLinks extends ApiQueryBase { - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'll' ); } @@ -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,13 +199,21 @@ 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' ) ); } public function getDescription() { - return 'Returns all interlanguage links from the given page(s)'; + return 'Returns all interlanguage links from the given page(s).'; } public function getPossibleErrors() {