37 private $mungedQuery =
false;
45 private function setParams( $params ) {
46 $this->mQuery = $params[
'query'];
47 $this->mNs = $params[
'namespace'];
48 $this->mProt = $params[
'protocol'];
59 parent::__construct(
'LinkSearch' );
73 $out->setPreventClickjacking(
false );
76 $target = $request->getVal(
'target', $par ??
'' );
77 $namespace = $request->getIntOrNull(
'namespace' );
80 foreach ( $this->
getConfig()->
get( MainConfigNames::UrlProtocols ) as $prot ) {
81 if ( $prot !==
'//' ) {
82 $protocols_list[] = $prot;
88 $protocol =
'http://';
90 if ( isset( $bits[
'scheme'] ) && isset( $bits[
'delimiter'] ) ) {
91 $protocol = $bits[
'scheme'] . $bits[
'delimiter'];
94 if ( str_starts_with( strtolower( $target ), strtolower( $protocol ) ) ) {
95 $target2 = substr( $target, strlen( $protocol ) );
104 '<nowiki>' . $this->
getLanguage()->commaList( $protocols_list ) .
'</nowiki>',
105 count( $protocols_list )
113 'label-message' =>
'linksearch-pat',
114 'default' => $target,
118 if ( !$this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
121 'type' =>
'namespaceselect',
122 'name' =>
'namespace',
123 'label-message' =>
'linksearch-ns',
124 'default' => $namespace,
127 'cssclass' =>
'namespaceselector',
131 $htmlForm = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
132 $htmlForm->setSubmitTextMsg(
'linksearch-ok' );
133 $htmlForm->setWrapperLegendMsg(
'linksearch' );
135 $htmlForm->setMethod(
'get' );
136 $htmlForm->prepareForm()->displayForm(
false );
139 if ( $target !=
'' ) {
142 'namespace' => $namespace,
143 'protocol' => $protocol ] );
144 parent::execute( $par );
145 if ( $this->mungedQuery ===
false ) {
146 $out->addWikiMsg(
'linksearch-error' );
161 $params[
'target'] = $this->mProt . $this->mQuery;
162 if ( $this->mNs !==
null && !$this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
163 $params[
'namespace'] = $this->mNs;
173 if ( $this->mQuery ===
'*' && $this->mProt !==
'' ) {
174 $this->mungedQuery = [
175 'el_index_60' .
$dbr->buildLike( $this->mProt,
$dbr->anyString() ),
178 $this->mungedQuery = LinkFilter::getQueryConditions( $this->mQuery, [
179 'protocol' => $this->mProt,
180 'oneWildcard' =>
true,
183 if ( $this->mungedQuery ===
false ) {
185 return [
'tables' =>
'page',
'fields' =>
'page_id',
'conds' =>
'0=1' ];
187 $orderBy[] =
'el_index_60';
190 $orderBy[] =
'el_id';
193 'tables' => [
'page',
'externallinks' ],
195 'namespace' =>
'page_namespace',
196 'title' =>
'page_title',
197 'value' =>
'el_index',
200 'conds' => array_merge(
206 'options' => [
'ORDER BY' => $orderBy ]
209 if ( $this->mNs !==
null && !$this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
210 $retval[
'conds'][
'page_namespace'] = $this->mNs;
238 return $this->
msg(
'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped();
262 return max( parent::getMaxResults(), 60000 );
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
A class containing constants representing the names of configuration variables.
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Special:LinkSearch to search the external-links table.
execute( $par)
This is the actual workhorse.
isSyndicated()
Disable RSS/Atom feeds.
getOrderFields()
Override to squash the ORDER BY.
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
formatResult( $skin, $result)
getMaxResults()
enwiki complained about low limits on this special page
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
preprocessResults( $db, $res)
Pre-fill the link cache.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Represents a page (or page fragment) title within MediaWiki.