35 private $mungedQuery =
false;
43 private function setParams( array $params ) {
44 $this->mQuery = $params[
'query'];
45 $this->mNs = $params[
'namespace'];
46 $this->mProt = $params[
'protocol'];
54 parent::__construct(
'LinkSearch' );
70 $out->getMetadata()->setPreventClickjacking(
false );
73 $target =
$request->getVal(
'target', $par ??
'' );
74 $namespace =
$request->getIntOrNull(
'namespace' );
78 if ( $prot !==
'//' ) {
79 $protocols_list[] = $prot;
83 $target2 = Parser::normalizeLinkUrl( $target );
85 $bits = $this->urlUtils->parse( $target );
86 if ( isset( $bits[
'scheme'] ) && isset( $bits[
'delimiter'] ) ) {
87 $protocol = $bits[
'scheme'] . $bits[
'delimiter'];
89 if ( str_starts_with( strtolower( $target ), strtolower( $protocol ) ) ) {
90 $target2 = substr( $target, strlen( $protocol ) );
99 '<nowiki>' . $this->
getLanguage()->commaList( $protocols_list ) .
'</nowiki>',
100 count( $protocols_list )
108 'label-message' =>
'linksearch-pat',
109 'default' => $target,
116 'type' =>
'namespaceselect',
117 'name' =>
'namespace',
118 'label-message' =>
'linksearch-ns',
119 'default' => $namespace,
122 'cssclass' =>
'namespaceselector',
126 $htmlForm = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
127 $htmlForm->setSubmitTextMsg(
'linksearch-ok' );
128 $htmlForm->setWrapperLegendMsg(
'linksearch' );
130 $htmlForm->setMethod(
'get' );
131 $htmlForm->prepareForm()->displayForm(
false );
134 if ( $target !=
'' ) {
137 'namespace' => $namespace,
138 'protocol' => $protocol ] );
139 parent::execute( $par );
140 if ( $this->mungedQuery ===
false ) {
141 $out->addWikiMsg(
'linksearch-error' );
145 if ( $ignoredDomains ) {
147 'linksearch-text-ignored-domains',
149 array_map(
static fn ( $domain ) =>
"<code>$domain</code>", $ignoredDomains )
151 count( $ignoredDomains )
167 $params[
'target'] = $this->mProt . $this->mQuery;
169 $params[
'namespace'] = $this->mNs;
177 $dbr = $this->
getDatabaseProvider()->getReplicaDatabase( ExternalLinksTable::VIRTUAL_DOMAIN );
179 $field =
'el_to_domain_index';
181 'urldomain' =>
'el_to_domain_index',
182 'urlpath' =>
'el_to_path'
184 if ( $this->mQuery ===
'*' && $this->mProt !==
'' ) {
185 if ( $this->mProt !==
null ) {
186 $this->mungedQuery = [
187 $dbr->expr( $field, IExpression::LIKE,
new LikeValue( $this->mProt, $dbr->anyString() ) ),
190 $this->mungedQuery = [
191 $dbr->expr( $field, IExpression::LIKE,
new LikeValue(
'http://', $dbr->anyString() ) )
192 ->or( $field, IExpression::LIKE,
new LikeValue(
'https://', $dbr->anyString() ) ),
196 $this->mungedQuery = LinkFilter::getQueryConditions( $this->mQuery, [
197 'protocol' => $this->mProt,
198 'oneWildcard' =>
true,
201 if ( $this->mungedQuery ===
false ) {
203 return [
'tables' =>
'page',
'fields' =>
'page_id',
'conds' =>
'0=1' ];
206 $orderBy = [
'el_id' ];
209 'tables' => [
'page',
'externallinks' ],
211 'namespace' =>
'page_namespace',
212 'title' =>
'page_title',
217 ...$this->mungedQuery,
219 'options' => [
'ORDER BY' => $orderBy ]
223 $retval[
'conds'][
'page_namespace'] = $this->mNs;
245 $title =
new TitleValue( (
int)$result->namespace, $result->title );
247 $url = LinkFilter::reverseIndexes( $result->urldomain ) . $result->urlpath;
251 return $this->
msg(
'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped();
276 return max( parent::getMaxResults(), 60000 );
282 ExternalLinksTable::VIRTUAL_DOMAIN,
289class_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.