36 parent::__construct( $query, $moduleName,
'el' );
41 if ( $pages === [] ) {
48 $query = $params[
'query'];
49 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
57 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
62 if ( count( $pages ) !== 1 ) {
63 $orderBy[] =
'el_from';
66 if ( $query !==
null && $query !==
'' ) {
67 $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() ),
100 $this->
addOption(
'ORDER BY', $orderBy );
103 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
105 if ( $params[
'continue'] !==
null ) {
107 array_fill( 0, count( $orderBy ),
'string' ) );
108 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
109 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
115 foreach (
$res as $row ) {
116 if ( ++$count > $params[
'limit'] ) {
119 $this->setContinue( $orderBy, $row );
125 if ( $params[
'expandurl'] ) {
128 ApiResult::setContentValue( $entry,
'url', $to );
131 $this->setContinue( $orderBy, $row );
137 private function setContinue( $orderBy, $row ) {
139 foreach ( $orderBy as $field ) {
140 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
152 ParamValidator::PARAM_DEFAULT => 10,
153 ParamValidator::PARAM_TYPE =>
'limit',
154 IntegerDef::PARAM_MIN => 1,
162 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
163 ParamValidator::PARAM_DEFAULT =>
'',
166 'expandurl' =>
false,
171 $title = Title::newMainPage()->getPrefixedText();
172 $mp = rawurlencode(
$title );
175 "action=query&prop=extlinks&titles={$mp}"
176 =>
'apihelp-query+extlinks-example-simple',
181 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.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
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.
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.