34 private $mungedQuery =
false;
42 private function setParams( array $params ) {
43 $this->mQuery = $params[
'query'];
44 $this->mNs = $params[
'namespace'];
45 $this->mProt = $params[
'protocol'];
53 parent::__construct(
'LinkSearch' );
69 $out->getMetadata()->setPreventClickjacking(
false );
72 $target = $request->getVal(
'target', $par ??
'' );
73 $namespace = $request->getIntOrNull(
'namespace' );
77 if ( $prot !==
'//' ) {
78 $protocols_list[] = $prot;
82 $target2 = Parser::normalizeLinkUrl( $target );
84 $bits = $this->urlUtils->parse( $target );
85 if ( isset( $bits[
'scheme'] ) && isset( $bits[
'delimiter'] ) ) {
86 $protocol = $bits[
'scheme'] . $bits[
'delimiter'];
88 if ( str_starts_with( strtolower( $target ), strtolower( $protocol ) ) ) {
89 $target2 = substr( $target, strlen( $protocol ) );
98 '<nowiki>' . $this->
getLanguage()->commaList( $protocols_list ) .
'</nowiki>',
99 count( $protocols_list )
107 'label-message' =>
'linksearch-pat',
108 'default' => $target,
115 'type' =>
'namespaceselect',
116 'name' =>
'namespace',
117 'label-message' =>
'linksearch-ns',
118 'default' => $namespace,
121 'cssclass' =>
'namespaceselector',
125 $htmlForm = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
126 $htmlForm->setSubmitTextMsg(
'linksearch-ok' );
127 $htmlForm->setWrapperLegendMsg(
'linksearch' );
129 $htmlForm->setMethod(
'get' );
130 $htmlForm->prepareForm()->displayForm(
false );
133 if ( $target !=
'' ) {
136 'namespace' => $namespace,
137 'protocol' => $protocol ] );
138 parent::execute( $par );
139 if ( $this->mungedQuery ===
false ) {
140 $out->addWikiMsg(
'linksearch-error' );
144 if ( $ignoredDomains ) {
146 'linksearch-text-ignored-domains',
148 array_map(
static fn ( $domain ) =>
"<code>$domain</code>", $ignoredDomains )
150 count( $ignoredDomains )
166 $params[
'target'] = $this->mProt . $this->mQuery;
168 $params[
'namespace'] = $this->mNs;
176 $dbr = $this->
getDatabaseProvider()->getReplicaDatabase( ExternalLinksTable::VIRTUAL_DOMAIN );
178 $field =
'el_to_domain_index';
180 'urldomain' =>
'el_to_domain_index',
181 'urlpath' =>
'el_to_path'
183 if ( $this->mQuery ===
'*' && $this->mProt !==
'' ) {
184 if ( $this->mProt !==
null ) {
185 $this->mungedQuery = [
186 $dbr->expr( $field, IExpression::LIKE,
new LikeValue( $this->mProt, $dbr->anyString() ) ),
189 $this->mungedQuery = [
190 $dbr->expr( $field, IExpression::LIKE,
new LikeValue(
'http://', $dbr->anyString() ) )
191 ->or( $field, IExpression::LIKE,
new LikeValue(
'https://', $dbr->anyString() ) ),
195 $this->mungedQuery = LinkFilter::getQueryConditions( $this->mQuery, [
196 'protocol' => $this->mProt,
197 'oneWildcard' =>
true,
200 if ( $this->mungedQuery ===
false ) {
202 return [
'tables' =>
'page',
'fields' =>
'page_id',
'conds' =>
'0=1' ];
205 $orderBy = [
'el_id' ];
208 'tables' => [
'page',
'externallinks' ],
210 'namespace' =>
'page_namespace',
211 'title' =>
'page_title',
216 ...$this->mungedQuery,
218 'options' => [
'ORDER BY' => $orderBy ]
222 $retval[
'conds'][
'page_namespace'] = $this->mNs;
244 $title =
new TitleValue( (
int)$result->namespace, $result->title );
246 $url = LinkFilter::reverseIndexes( $result->urldomain ) . $result->urlpath;
250 return $this->
msg(
'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped();
275 return max( parent::getMaxResults(), 60000 );
281 ExternalLinksTable::VIRTUAL_DOMAIN,
288class_alias( SpecialLinkSearch::class,
'SpecialLinkSearch' );
A class containing constants representing the names of configuration variables.
const ExternalLinksIgnoreDomains
Name constant for the ExternalLinksIgnoreDomains setting, for use with Config::get()
const UrlProtocols
Name constant for the UrlProtocols setting, for use with Config::get()
const MiserMode
Name constant for the MiserMode setting, for use with Config::get()
Factory for LinkBatch objects to batch query page metadata.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
getFullTitle()
Return the full title, including $par.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.