33 parent::__construct( $query, $moduleName,
'll' );
37 if ( $this->
getPageSet()->getGoodTitleCount() == 0 ) {
42 $prop = array_flip( (array)$params[
'prop'] );
44 if ( isset( $params[
'title'] ) && !isset( $params[
'lang'] ) ) {
47 'apierror-invalidparammix-mustusewith',
57 if ( $params[
'url'] ) {
58 $prop = [
'url' => 1 ];
69 if ( $params[
'continue'] !==
null ) {
70 $cont = explode(
'|', $params[
'continue'] );
72 $op = $params[
'dir'] ==
'descending' ?
'<' :
'>';
73 $llfrom = (int)$cont[0];
74 $lllang = $this->
getDB()->addQuotes( $cont[1] );
76 "ll_from $op $llfrom OR " .
77 "(ll_from = $llfrom AND " .
78 "ll_lang $op= $lllang)"
88 $sort = ( $params[
'dir'] ==
'descending' ?
' DESC' :
'' );
89 if ( isset( $params[
'lang'] ) ) {
91 if ( isset( $params[
'title'] ) ) {
94 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
97 if ( count( $this->
getPageSet()->getGoodTitles() ) == 1 ) {
98 $this->
addOption(
'ORDER BY',
'll_lang' . $sort );
107 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
111 foreach (
$res as $row ) {
112 if ( ++$count > $params[
'limit'] ) {
118 $entry = [
'lang' => $row->ll_lang ];
119 if ( isset( $prop[
'url'] ) ) {
120 $title = Title::newFromText(
"{$row->ll_lang}:{$row->ll_title}" );
125 $languageNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils();
126 if ( isset( $prop[
'langname'] ) ) {
127 $entry[
'langname'] = $languageNameUtils
128 ->getLanguageName( $row->ll_lang, $params[
'inlanguagecode'] );
130 if ( isset( $prop[
'autonym'] ) ) {
131 $entry[
'autonym'] = $languageNameUtils->getLanguageName( $row->ll_lang );
133 ApiResult::setContentValue( $entry,
'title', $row->ll_title );
166 'inlanguagecode' => MediaWikiServices::getInstance()->getContentLanguage()->getCode(),
186 'action=query&prop=langlinks&titles=Main%20Page&redirects='
187 =>
'apihelp-query+langlinks-example-simple',
192 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.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
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) Stable to override.
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 Stable to override.
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.
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName)
This is the main query class.