51 parent::__construct( $query, $moduleName,
'll' );
52 $this->languageNameUtils = $languageNameUtils;
53 $this->contentLanguage = $contentLanguage;
54 $this->urlUtils = $urlUtils;
59 if ( $pages === [] ) {
64 $prop = array_fill_keys( (array)
$params[
'prop'],
true );
69 'apierror-invalidparammix-mustusewith',
80 $prop = [
'url' => 1 ];
90 $this->
addWhereFld(
'll_from', array_keys( $pages ) );
91 if (
$params[
'continue'] !==
null ) {
94 $op =
$params[
'dir'] ==
'descending' ?
'<=' :
'>=';
95 $this->
addWhere( $db->buildComparison( $op, [
96 'll_from' => $cont[0],
97 'll_lang' => $cont[1],
107 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
108 if ( isset(
$params[
'lang'] ) ) {
110 if ( isset(
$params[
'title'] ) ) {
111 $this->
addWhereFld(
'll_title', $params[
'title'] );
113 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
116 if ( count( $pages ) === 1 ) {
117 $this->
addOption(
'ORDER BY',
'll_lang' . $sort );
126 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
127 $res = $this->
select( __METHOD__ );
130 foreach ( $res as $row ) {
131 if ( ++$count >
$params[
'limit'] ) {
139 $displayLanguageCode = $languageNameMap[ $row->ll_lang ] ?? $row->ll_lang;
142 $entry = [
'lang' => $displayLanguageCode ];
143 if ( isset( $prop[
'url'] ) ) {
144 $title = Title::newFromText(
"{$row->ll_lang}:{$row->ll_title}" );
146 $entry[
'url'] = (string)$this->urlUtils->expand( $title->getFullURL(),
PROTO_CURRENT );
150 if ( isset( $prop[
'langname'] ) ) {
151 $entry[
'langname'] = $this->languageNameUtils
152 ->getLanguageName( $displayLanguageCode,
$params[
'inlanguagecode'] );
154 if ( isset( $prop[
'autonym'] ) ) {
155 $entry[
'autonym'] = $this->languageNameUtils->getLanguageName( $displayLanguageCode );
173 ParamValidator::PARAM_ISMULTI =>
true,
174 ParamValidator::PARAM_TYPE => [
184 ParamValidator::PARAM_DEFAULT =>
'ascending',
185 ParamValidator::PARAM_TYPE => [
190 'inlanguagecode' => $this->contentLanguage->getCode(),
192 ParamValidator::PARAM_DEFAULT => 10,
193 ParamValidator::PARAM_TYPE =>
'limit',
194 IntegerDef::PARAM_MIN => 1,
202 ParamValidator::PARAM_DEFAULT =>
false,
203 ParamValidator::PARAM_DEPRECATED =>
true,
209 $title = Title::newMainPage()->getPrefixedText();
210 $mp = rawurlencode( $title );
213 "action=query&prop=langlinks&titles={$mp}&redirects="
214 =>
'apihelp-query+langlinks-example-simple',
219 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langlinks';
224class_alias( ApiQueryLangLinks::class,
'ApiQueryLangLinks' );
array $params
The job parameters.
A class containing constants representing the names of configuration variables.
const InterlanguageLinkCodeMap
Name constant for the InterlanguageLinkCodeMap setting, for use with Config::get()