46 parent::__construct( $query, $moduleName,
'iw' );
48 $this->urlUtils = $urlUtils;
53 if ( $pages === [] ) {
58 $prop = array_fill_keys( (array)
$params[
'prop'],
true );
63 'apierror-invalidparammix-mustusewith',
74 $prop = [
'url' => 1 ];
84 $this->
addWhereFld(
'iwl_from', array_keys( $pages ) );
86 if (
$params[
'continue'] !==
null ) {
88 $op =
$params[
'dir'] ==
'descending' ?
'<=' :
'>=';
90 $this->
addWhere( $db->buildComparison( $op, [
91 'iwl_from' => $cont[0],
92 'iwl_prefix' => $cont[1],
93 'iwl_title' => $cont[2],
97 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
98 if ( isset(
$params[
'prefix'] ) ) {
99 $this->
addWhereFld(
'iwl_prefix', $params[
'prefix'] );
100 if ( isset(
$params[
'title'] ) ) {
101 $this->
addWhereFld(
'iwl_title', $params[
'title'] );
102 $this->
addOption(
'ORDER BY',
'iwl_from' . $sort );
111 if ( count( $pages ) === 1 ) {
112 $this->
addOption(
'ORDER BY',
'iwl_prefix' . $sort );
116 'iwl_prefix' . $sort,
122 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
123 $res = $this->
select( __METHOD__ );
126 foreach ( $res as $row ) {
127 if ( ++$count >
$params[
'limit'] ) {
132 "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}"
136 $entry = [
'prefix' => $row->iwl_prefix ];
138 if ( isset( $prop[
'url'] ) ) {
139 $title = Title::newFromText(
"{$row->iwl_prefix}:{$row->iwl_title}" );
141 $entry[
'url'] = (string)$this->urlUtils->expand( $title->getFullURL(),
PROTO_CURRENT );
145 ApiResult::setContentValue( $entry,
'title', $row->iwl_title );
150 "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}"
164 ParamValidator::PARAM_ISMULTI =>
true,
165 ParamValidator::PARAM_TYPE => [
173 ParamValidator::PARAM_DEFAULT =>
'ascending',
174 ParamValidator::PARAM_TYPE => [
180 ParamValidator::PARAM_DEFAULT => 10,
181 ParamValidator::PARAM_TYPE =>
'limit',
182 IntegerDef::PARAM_MIN => 1,
190 ParamValidator::PARAM_DEFAULT =>
false,
191 ParamValidator::PARAM_DEPRECATED =>
true,
197 $title = Title::newMainPage()->getPrefixedText();
198 $mp = rawurlencode( $title );
201 "action=query&prop=iwlinks&titles={$mp}"
202 =>
'apihelp-query+iwlinks-example-simple',
207 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Iwlinks';
array $params
The job parameters.
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.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
requireMaxOneParameter( $params,... $required)
Dies if more than one parameter from a certain set of parameters are 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 interwiki links on a page.
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, $moduleName, UrlUtils $urlUtils)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
This is the main query class.