47 private $mungedQuery =
false;
57 private function setParams(
$params ) {
58 $this->mQuery =
$params[
'query'];
59 $this->mNs =
$params[
'namespace'];
60 $this->mProt =
$params[
'protocol'];
73 parent::__construct(
'LinkSearch' );
76 $this->urlUtils = $urlUtils;
88 $out->getMetadata()->setPreventClickjacking(
false );
91 $target = $request->getVal(
'target', $par ??
'' );
92 $namespace = $request->getIntOrNull(
'namespace' );
96 if ( $prot !==
'//' ) {
97 $protocols_list[] = $prot;
101 $target2 = Parser::normalizeLinkUrl( $target );
103 $bits = $this->urlUtils->parse( $target );
104 if ( isset( $bits[
'scheme'] ) && isset( $bits[
'delimiter'] ) ) {
105 $protocol = $bits[
'scheme'] . $bits[
'delimiter'];
107 if ( str_starts_with( strtolower( $target ), strtolower( $protocol ) ) ) {
108 $target2 = substr( $target, strlen( $protocol ) );
117 '<nowiki>' . $this->
getLanguage()->commaList( $protocols_list ) .
'</nowiki>',
118 count( $protocols_list )
126 'label-message' =>
'linksearch-pat',
127 'default' => $target,
134 'type' =>
'namespaceselect',
135 'name' =>
'namespace',
136 'label-message' =>
'linksearch-ns',
137 'default' => $namespace,
140 'cssclass' =>
'namespaceselector',
144 $htmlForm = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
145 $htmlForm->setSubmitTextMsg(
'linksearch-ok' );
146 $htmlForm->setWrapperLegendMsg(
'linksearch' );
148 $htmlForm->setMethod(
'get' );
149 $htmlForm->prepareForm()->displayForm(
false );
152 if ( $target !=
'' ) {
155 'namespace' => $namespace,
156 'protocol' => $protocol ] );
157 parent::execute( $par );
158 if ( $this->mungedQuery ===
false ) {
159 $out->addWikiMsg(
'linksearch-error' );
174 $params[
'target'] = $this->mProt . $this->mQuery;
176 $params[
'namespace'] = $this->mNs;
185 $field =
'el_to_domain_index';
187 'urldomain' =>
'el_to_domain_index',
188 'urlpath' =>
'el_to_path'
190 if ( $this->mQuery ===
'*' && $this->mProt !==
'' ) {
191 if ( $this->mProt !==
null ) {
192 $this->mungedQuery = [
193 $dbr->expr( $field, IExpression::LIKE,
new LikeValue( $this->mProt, $dbr->anyString() ) ),
196 $this->mungedQuery = [
197 $dbr->expr( $field, IExpression::LIKE,
new LikeValue(
'http://', $dbr->anyString() ) )
198 ->or( $field, IExpression::LIKE,
new LikeValue(
'https://', $dbr->anyString() ) ),
202 $this->mungedQuery = LinkFilter::getQueryConditions( $this->mQuery, [
203 'protocol' => $this->mProt,
204 'oneWildcard' =>
true,
207 if ( $this->mungedQuery ===
false ) {
209 return [
'tables' =>
'page',
'fields' =>
'page_id',
'conds' =>
'0=1' ];
212 $orderBy = [
'el_id' ];
215 'tables' => [
'page',
'externallinks' ],
216 'fields' => array_merge( [
217 'namespace' =>
'page_namespace',
218 'title' =>
'page_title',
220 'conds' => array_merge(
226 'options' => [
'ORDER BY' => $orderBy ]
230 $retval[
'conds'][
'page_namespace'] = $this->mNs;
252 $title =
new TitleValue( (
int)$result->namespace, $result->title );
254 $url = LinkFilter::reverseIndexes( $result->urldomain ) . $result->urlpath;
258 return $this->
msg(
'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped();
282 return max( parent::getMaxResults(), 60000 );
287class_alias( SpecialLinkSearch::class,
'SpecialLinkSearch' );
array $params
The job parameters.
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.
The base class for all skins.