45 parent::__construct( $query, $moduleName,
'll' );
52 if ( $pages === [] ) {
57 $prop = array_fill_keys( (array)$params[
'prop'],
true );
59 if ( isset( $params[
'title'] ) && !isset( $params[
'lang'] ) ) {
62 'apierror-invalidparammix-mustusewith',
72 if ( $params[
'url'] ) {
73 $prop = [
'url' => 1 ];
83 $this->
addWhereFld(
'll_from', array_keys( $pages ) );
84 if ( $params[
'continue'] !==
null ) {
85 $cont = explode(
'|', $params[
'continue'] );
87 $op = $params[
'dir'] ==
'descending' ?
'<' :
'>';
88 $llfrom = (int)$cont[0];
89 $lllang = $this->
getDB()->addQuotes( $cont[1] );
91 "ll_from $op $llfrom OR " .
92 "(ll_from = $llfrom AND " .
93 "ll_lang $op= $lllang)"
103 $sort = ( $params[
'dir'] ==
'descending' ?
' DESC' :
'' );
104 if ( isset( $params[
'lang'] ) ) {
106 if ( isset( $params[
'title'] ) ) {
107 $this->
addWhereFld(
'll_title', $params[
'title'] );
109 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
112 if ( count( $pages ) === 1 ) {
113 $this->
addOption(
'ORDER BY',
'll_lang' . $sort );
122 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
126 foreach (
$res as $row ) {
127 if ( ++$count > $params[
'limit'] ) {
134 $languageNameMap = $this->
getConfig()->get( MainConfigNames::InterlanguageLinkCodeMap );
135 $displayLanguageCode = $languageNameMap[ $row->ll_lang ] ?? $row->ll_lang;
138 $entry = [
'lang' => $displayLanguageCode ];
139 if ( isset( $prop[
'url'] ) ) {
146 if ( isset( $prop[
'langname'] ) ) {
147 $entry[
'langname'] = $this->languageNameUtils
148 ->getLanguageName( $displayLanguageCode, $params[
'inlanguagecode'] );
150 if ( isset( $prop[
'autonym'] ) ) {
151 $entry[
'autonym'] = $this->languageNameUtils->getLanguageName( $displayLanguageCode );
186 'inlanguagecode' => $this->contentLanguage->getCode(),
206 'action=query&prop=langlinks&titles=Main%20Page&redirects='
207 =>
'apihelp-query+langlinks-example-simple',
212 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langlinks';
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const LIMIT_BIG1
Fast query, standard limit.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addFields( $value)
Add a set of fields to select to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
getPageSet()
Get the PageSet object to work on.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
A query module to list all langlinks (links to corresponding foreign language pages).
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
__construct(ApiQuery $query, $moduleName, LanguageNameUtils $languageNameUtils, Language $contentLanguage)
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
LanguageNameUtils $languageNameUtils
Language $contentLanguage
This is the main query class.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
A class containing constants representing the names of configuration variables.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.