34 parent::__construct( $query, $moduleName,
'el' );
39 if ( $pages === [] ) {
46 $query = $params[
'query'];
55 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
60 if ( count( $pages ) !== 1 ) {
61 $orderBy[] =
'el_from';
64 if ( $query !==
null && $query !==
'' ) {
65 if ( $protocol ===
null ) {
66 $protocol =
'http://';
72 $conds = LinkFilter::getQueryConditions( $query, [
74 'oneWildcard' =>
true,
81 if ( !isset( $conds[
'el_index_60'] ) ) {
82 $orderBy[] =
'el_index_60';
85 $orderBy[] =
'el_index_60';
87 if ( $protocol !==
null ) {
88 $this->
addWhere(
'el_index_60' . $db->buildLike(
"$protocol", $db->anyString() ) );
92 'el_to NOT' . $db->buildLike(
'//', $db->anyString() ),
93 'el_index_60 ' . $db->buildLike(
'http://', $db->anyString() ),
102 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
104 if ( $params[
'continue'] !==
null ) {
105 $cont = explode(
'|', $params[
'continue'] );
107 $i = count( $cont ) - 1;
108 $cond = $orderBy[$i] .
' >= ' . $db->addQuotes( rawurldecode( $cont[$i] ) );
110 $field = $orderBy[$i];
111 $v = $db->addQuotes( rawurldecode( $cont[$i] ) );
112 $cond =
"($field > $v OR ($field = $v AND $cond))";
120 foreach (
$res as $row ) {
121 if ( ++$count > $params[
'limit'] ) {
124 $this->setContinue( $orderBy, $row );
130 if ( $params[
'expandurl'] ) {
133 ApiResult::setContentValue( $entry,
'url', $to );
136 $this->setContinue( $orderBy, $row );
142 private function setContinue( $orderBy, $row ) {
144 foreach ( $orderBy as $field ) {
145 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
157 ParamValidator::PARAM_DEFAULT => 10,
158 ParamValidator::PARAM_TYPE =>
'limit',
159 IntegerDef::PARAM_MIN => 1,
168 ParamValidator::PARAM_DEFAULT =>
'',
171 'expandurl' =>
false,
176 $title = Title::newMainPage()->getPrefixedText();
177 $mp = rawurlencode(
$title );
180 "action=query&prop=extlinks&titles={$mp}"
181 =>
'apihelp-query+extlinks-example-simple',
186 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Extlinks';
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.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const LIMIT_BIG1
Fast query, standard limit.
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.
static prepareProtocols()
static getProtocolPrefix( $protocol)
A query module to list all external URLs found on a given set of pages.
getExamplesMessages()
Returns usage examples for this module.
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.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
__construct(ApiQuery $query, $moduleName)
This is the main query class.
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.