47 private $mungedQuery =
false;
57 private function setParams( array $params ) {
58 $this->mQuery = $params[
'query'];
59 $this->mNs = $params[
'namespace'];
60 $this->mProt = $params[
'protocol'];
68 parent::__construct(
'LinkSearch' );
71 $this->urlUtils = $urlUtils;
83 $out->getMetadata()->setPreventClickjacking(
false );
86 $target = $request->getVal(
'target', $par ??
'' );
87 $namespace = $request->getIntOrNull(
'namespace' );
91 if ( $prot !==
'//' ) {
92 $protocols_list[] = $prot;
96 $target2 = Parser::normalizeLinkUrl( $target );
98 $bits = $this->urlUtils->parse( $target );
99 if ( isset( $bits[
'scheme'] ) && isset( $bits[
'delimiter'] ) ) {
100 $protocol = $bits[
'scheme'] . $bits[
'delimiter'];
102 if ( str_starts_with( strtolower( $target ), strtolower( $protocol ) ) ) {
103 $target2 = substr( $target, strlen( $protocol ) );
112 '<nowiki>' . $this->
getLanguage()->commaList( $protocols_list ) .
'</nowiki>',
113 count( $protocols_list )
121 'label-message' =>
'linksearch-pat',
122 'default' => $target,
129 'type' =>
'namespaceselect',
130 'name' =>
'namespace',
131 'label-message' =>
'linksearch-ns',
132 'default' => $namespace,
135 'cssclass' =>
'namespaceselector',
139 $htmlForm = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
140 $htmlForm->setSubmitTextMsg(
'linksearch-ok' );
141 $htmlForm->setWrapperLegendMsg(
'linksearch' );
143 $htmlForm->setMethod(
'get' );
144 $htmlForm->prepareForm()->displayForm(
false );
147 if ( $target !=
'' ) {
150 'namespace' => $namespace,
151 'protocol' => $protocol ] );
152 parent::execute( $par );
153 if ( $this->mungedQuery ===
false ) {
154 $out->addWikiMsg(
'linksearch-error' );
169 $params[
'target'] = $this->mProt . $this->mQuery;
171 $params[
'namespace'] = $this->mNs;
180 $field =
'el_to_domain_index';
182 'urldomain' =>
'el_to_domain_index',
183 'urlpath' =>
'el_to_path'
185 if ( $this->mQuery ===
'*' && $this->mProt !==
'' ) {
186 if ( $this->mProt !==
null ) {
187 $this->mungedQuery = [
188 $dbr->expr( $field, IExpression::LIKE,
new LikeValue( $this->mProt, $dbr->anyString() ) ),
191 $this->mungedQuery = [
192 $dbr->expr( $field, IExpression::LIKE,
new LikeValue(
'http://', $dbr->anyString() ) )
193 ->or( $field, IExpression::LIKE,
new LikeValue(
'https://', $dbr->anyString() ) ),
197 $this->mungedQuery = LinkFilter::getQueryConditions( $this->mQuery, [
198 'protocol' => $this->mProt,
199 'oneWildcard' =>
true,
202 if ( $this->mungedQuery ===
false ) {
204 return [
'tables' =>
'page',
'fields' =>
'page_id',
'conds' =>
'0=1' ];
207 $orderBy = [
'el_id' ];
210 'tables' => [
'page',
'externallinks' ],
211 'fields' => array_merge( [
212 'namespace' =>
'page_namespace',
213 'title' =>
'page_title',
215 'conds' => array_merge(
221 'options' => [
'ORDER BY' => $orderBy ]
225 $retval[
'conds'][
'page_namespace'] = $this->mNs;
247 $title =
new TitleValue( (
int)$result->namespace, $result->title );
249 $url = LinkFilter::reverseIndexes( $result->urldomain ) . $result->urlpath;
253 return $this->
msg(
'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped();
277 return max( parent::getMaxResults(), 60000 );
282class_alias( SpecialLinkSearch::class,
'SpecialLinkSearch' );
A class containing constants representing the names of configuration variables.
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()
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.