31 private readonly
Language $contentLanguage,
34 parent::__construct( $query, $moduleName,
'll' );
39 if ( $pages === [] ) {
44 $prop = array_fill_keys( (array)$params[
'prop'],
true );
46 if ( isset( $params[
'title'] ) && !isset( $params[
'lang'] ) ) {
49 'apierror-invalidparammix-mustusewith',
59 if ( $params[
'url'] ) {
60 $prop = [
'url' => 1 ];
70 $this->
addWhereFld(
'll_from', array_keys( $pages ) );
71 if ( $params[
'continue'] !==
null ) {
74 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
75 $this->
addWhere( $db->buildComparison( $op, [
76 'll_from' => $cont[0],
77 'll_lang' => $cont[1],
87 $sort = ( $params[
'dir'] ==
'descending' ?
' DESC' :
'' );
88 if ( isset( $params[
'lang'] ) ) {
90 if ( isset( $params[
'title'] ) ) {
93 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
96 if ( count( $pages ) === 1 ) {
97 $this->
addOption(
'ORDER BY',
'll_lang' . $sort );
106 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
109 $res = $this->
select( __METHOD__ );
112 foreach ( $res as $row ) {
113 if ( ++$count > $params[
'limit'] ) {
121 $displayLanguageCode = $languageNameMap[ $row->ll_lang ] ?? $row->ll_lang;
124 $entry = [
'lang' => $displayLanguageCode ];
125 if ( isset( $prop[
'url'] ) ) {
126 $title = Title::newFromText(
"{$row->ll_lang}:{$row->ll_title}" );
128 $entry[
'url'] = (string)$this->urlUtils->expand( $title->getFullURL(),
PROTO_CURRENT );
132 if ( isset( $prop[
'langname'] ) ) {
133 $entry[
'langname'] = $this->languageNameUtils
134 ->getLanguageName( $displayLanguageCode, $params[
'inlanguagecode'] );
136 if ( isset( $prop[
'autonym'] ) ) {
137 $entry[
'autonym'] = $this->languageNameUtils->getLanguageName( $displayLanguageCode );
157 ParamValidator::PARAM_ISMULTI =>
true,
158 ParamValidator::PARAM_TYPE => [
168 ParamValidator::PARAM_DEFAULT =>
'ascending',
169 ParamValidator::PARAM_TYPE => [
174 'inlanguagecode' => $this->contentLanguage->getCode(),
176 ParamValidator::PARAM_DEFAULT => 10,
177 ParamValidator::PARAM_TYPE =>
'limit',
178 IntegerDef::PARAM_MIN => 1,
186 ParamValidator::PARAM_DEFAULT =>
false,
187 ParamValidator::PARAM_DEPRECATED =>
true,
194 $title = Title::newMainPage()->getPrefixedText();
195 $mp = rawurlencode( $title );
198 "action=query&prop=langlinks&titles={$mp}&redirects="
199 =>
'apihelp-query+langlinks-example-simple',
205 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langlinks';
210class_alias( ApiQueryLangLinks::class,
'ApiQueryLangLinks' );
A class containing constants representing the names of configuration variables.
const InterlanguageLinkCodeMap
Name constant for the InterlanguageLinkCodeMap setting, for use with Config::get()