40 protected $limits = [ 20, 50, 100, 250, 500 ];
43 parent::__construct(
'Whatlinkshere' );
70 if ( $par !==
null ) {
77 $this->target = Title::newFromText(
$opts->
getValue(
'target' ) );
78 if ( !$this->target ) {
86 $this->
getSkin()->setRelevantTitle( $this->target );
88 $this->selfTitle = $this->
getPageTitle( $this->target->getPrefixedDBkey() );
90 $out->setPageTitle( $this->
msg(
'whatlinkshere-title', $this->target->getPrefixedText() ) );
91 $out->addBacklinkSubtitle( $this->target );
112 $hidelinks = $this->opts->getValue(
'hidelinks' );
113 $hideredirs = $this->opts->getValue(
'hideredirs' );
114 $hidetrans = $this->opts->getValue(
'hidetrans' );
120 $conds[
'pagelinks'] = [
124 $conds[
'templatelinks'] = [
128 $conds[
'imagelinks'] = [
132 $namespace = $this->opts->getValue(
'namespace' );
133 $invert = $this->opts->getValue(
'invert' );
134 $nsComparison = ( $invert ?
'!= ' :
'= ' ) .
$dbr->addQuotes( $namespace );
135 if (
is_int( $namespace ) ) {
136 $conds[
'pagelinks'][] =
"pl_from_namespace $nsComparison";
137 $conds[
'templatelinks'][] =
"tl_from_namespace $nsComparison";
138 $conds[
'imagelinks'][] =
"il_from_namespace $nsComparison";
142 $conds[
'templatelinks'][] =
"tl_from >= $from";
143 $conds[
'pagelinks'][] =
"pl_from >= $from";
144 $conds[
'imagelinks'][] =
"il_from >= $from";
148 $conds[
'pagelinks'][
'rd_from'] =
null;
150 $conds[
'pagelinks'][] =
'rd_from is NOT NULL';
157 $queryLimit = $limit + 1;
159 "rd_from = $fromCol",
161 'rd_interwiki = ' .
$dbr->addQuotes(
'' ) .
' OR rd_interwiki IS NULL'
165 $subQuery =
$dbr->buildSelectSubquery(
166 [ $table,
'redirect',
'page' ],
167 [ $fromCol,
'rd_from' ],
169 __CLASS__ .
'::showIndirectLinks',
171 [
'ORDER BY' => $fromCol,
'LIMIT' => 2 * $queryLimit,
'STRAIGHT_JOIN' ],
173 'page' => [
'JOIN',
"$fromCol = page_id" ],
174 'redirect' => [
'LEFT JOIN', $on ]
178 [
'page',
'temp_backlink_range' => $subQuery ],
179 [
'page_id',
'page_namespace',
'page_title',
'rd_from',
'page_is_redirect' ],
181 __CLASS__ .
'::showIndirectLinks',
182 [
'ORDER BY' =>
'page_id',
'LIMIT' => $queryLimit ],
183 [
'page' => [
'JOIN',
"$fromCol = page_id" ] ]
195 if ( !$hideimages ) {
199 if ( ( !$fetchlinks || !$plRes->numRows() )
200 && ( $hidetrans || !$tlRes->numRows() )
201 && ( $hideimages || !$ilRes->numRows() )
203 if ( $level == 0 && !$this->
including() ) {
207 if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
210 $msgKey =
is_int( $namespace ) ?
'nolinkshere-ns' :
'nolinkshere';
215 $this->target->isRedirect() ? [
'redirect' =>
'no' ] : []
218 $errMsg = $this->
msg( $msgKey )
219 ->params( $this->target->getPrefixedText() )
222 $out->addHTML( $errMsg );
223 $out->setStatusCode( 404 );
233 foreach ( $plRes as $row ) {
234 $row->is_template = 0;
236 $rows[$row->page_id] = $row;
240 foreach ( $tlRes as $row ) {
241 $row->is_template = 1;
243 $rows[$row->page_id] = $row;
246 if ( !$hideimages ) {
247 foreach ( $ilRes as $row ) {
248 $row->is_template = 0;
250 $rows[$row->page_id] = $row;
258 $numRows = count(
$rows );
261 if ( $numRows > $limit ) {
264 $nextId =
$rows[$limit]->page_id;
276 foreach (
$rows as $row ) {
277 $lb->add( $row->page_namespace, $row->page_title );
281 if ( $level == 0 && !$this->
including() ) {
289 $this->target->isRedirect() ? [
'redirect' =>
'no' ] : []
292 $msg = $this->
msg(
'linkshere' )
293 ->params( $this->target->getPrefixedText() )
296 $out->addHTML( $msg );
298 $prevnext = $this->
getPrevNext( $prevId, $nextId );
299 $out->addHTML( $prevnext );
302 foreach (
$rows as $row ) {
303 $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
305 if ( $row->rd_from && $level < 2 ) {
310 $this->
getConfig()->
get(
'MaxRedirectLinksRetrieved' )
312 $out->addHTML( Xml::closeElement(
'li' ) );
320 if ( $level == 0 && !$this->
including() ) {
321 $out->addHTML( $prevnext );
326 return Xml::openElement(
'ul', ( $level ? [] : [
'id' =>
'mw-whatlinkshere-list' ] ) );
332 # local message cache
333 static $msgcache =
null;
334 if ( $msgcache ===
null ) {
335 static $msgs = [
'isredirect',
'istemplate',
'semicolon-separator',
336 'whatlinkshere-links',
'isimage',
'editlink' ];
338 foreach ( $msgs as $msg ) {
339 $msgcache[$msg] = $this->
msg( $msg )->escaped();
343 if ( $row->rd_from ) {
344 $query = [
'redirect' =>
'no' ];
352 $row->page_is_redirect ? [
'class' =>
'mw-redirect' ] : [],
359 if ( $row->rd_from ) {
360 $props[] = $msgcache[
'isredirect'];
362 if ( $row->is_template ) {
363 $props[] = $msgcache[
'istemplate'];
365 if ( $row->is_image ) {
366 $props[] = $msgcache[
'isimage'];
369 Hooks::run(
'WhatLinksHereProps', [ $row, $nt,
$target, &$props ] );
371 if ( count( $props ) ) {
372 $propsText = $this->
msg(
'parentheses' )
373 ->rawParams( implode( $msgcache[
'semicolon-separator'], $props ) )->escaped();
376 # Space for utilities links, with a what-links-here link provided
377 $wlhLink = $this->
wlhLink( $nt, $msgcache[
'whatlinkshere-links'], $msgcache[
'editlink'] );
378 $wlh = Xml::wrapClass(
379 $this->
msg(
'parentheses' )->rawParams( $wlhLink )->escaped(),
380 'mw-whatlinkshere-tools'
384 Xml::openElement(
'li' ) .
"$link $propsText $dirmark $wlh\n" :
385 Xml::tags(
'li',
null,
"$link $propsText $dirmark $wlh" ) .
"\n";
389 return Xml::closeElement(
'ul' );
393 static $title =
null;
394 if ( $title ===
null ) {
400 if ( $text !==
null ) {
417 $this->
getUser()->isAllowed(
'edit' ) &&
419 ContentHandler::getForTitle(
$target )->supportsDirectEditing()
421 if ( $editText !==
null ) {
429 [
'action' =>
'edit' ]
438 if ( $text !==
null ) {
451 $currentLimit = $this->opts->getValue(
'limit' );
452 $prev = $this->
msg(
'whatlinkshere-prev' )->numParams( $currentLimit )->escaped();
453 $next = $this->
msg(
'whatlinkshere-next' )->numParams( $currentLimit )->escaped();
455 $changed = $this->opts->getChangedValues();
456 unset( $changed[
'target'] );
458 if ( $prevId != 0 ) {
459 $overrides = [
'from' => $this->opts->getValue(
'back' ) ];
462 if ( $nextId != 0 ) {
463 $overrides = [
'from' =>
$nextId,
'back' => $prevId ];
469 foreach ( $this->limits as $limit ) {
471 $overrides = [
'limit' => $limit ];
475 $nums =
$lang->pipeList( $limitLinks );
477 return $this->
msg(
'viewprevnext' )->rawParams( $prev, $next, $nums )->escaped();
482 $this->opts->consumeValue(
'target' );
484 $this->opts->consumeValues( [
'back',
'from' ] );
487 $namespace = $this->opts->consumeValue(
'namespace' );
488 $nsinvert = $this->opts->consumeValue(
'invert' );
491 $f = Xml::openElement(
'form', [
'action' =>
wfScript() ] );
493 # Values that should not be forgotten
494 $f .= Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() );
495 foreach ( $this->opts->getUnconsumedValues() as $name =>
$value ) {
496 $f .= Html::hidden( $name,
$value );
499 $f .= Xml::fieldset( $this->
msg(
'whatlinkshere' )->
text() );
501 # Target input (.mw-searchInput enables suggestions)
502 $f .= Xml::inputLabel( $this->
msg(
'whatlinkshere-page' )->
text(),
'target',
503 'mw-whatlinkshere-target', 40,
$target, [
'class' =>
'mw-searchInput' ] );
508 $f .= Html::namespaceSelector(
510 'selected' => $namespace,
512 'label' => $this->
msg(
'namespace' )->
text(),
513 'in-user-lang' =>
true,
515 'name' =>
'namespace',
517 'class' =>
'namespaceselector',
523 $this->
msg(
'invert' )->
text(),
527 [
'title' => $this->
msg(
'tooltip-whatlinkshere-invert' )->
text() ]
533 $f .= Xml::submitButton( $this->
msg(
'whatlinkshere-submit' )->
text() );
536 $f .= Xml::closeElement(
'fieldset' ) . Xml::closeElement(
'form' ) .
"\n";
547 $show = $this->
msg(
'show' )->escaped();
548 $hide = $this->
msg(
'hide' )->escaped();
550 $changed = $this->opts->getChangedValues();
551 unset( $changed[
'target'] );
554 $types = [
'hidetrans',
'hidelinks',
'hideredirs' ];
555 if ( $this->target->getNamespace() ==
NS_FILE ) {
556 $types[] =
'hideimages';
562 foreach ( $types as
$type ) {
563 $chosen = $this->opts->getValue(
$type );
566 $links[] = $this->
msg(
"whatlinkshere-{$type}" )->rawParams(
570 return Xml::fieldset(
571 $this->
msg(
'whatlinkshere-filters' )->
text(),
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions Trademarks This License does not grant permission to use the trade service or product names of the except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file Disclaimer of Warranty Unless required by applicable law or agreed to in Licensor provides the WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or including
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Marks HTML that shouldn't be escaped.
Shortcut to construct an includable special page.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
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.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
msg( $key)
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.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
MediaWiki Linker LinkRenderer null $linkRenderer
Implements Special:Whatlinkshere.
execute( $par)
Default execute method Checks user permissions.
wlhLink(Title $target, $text, $editText)
listItem( $row, $nt, $target, $notClose=false)
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getFilterPanel()
Create filter panel.
showIndirectLinks( $level, $target, $limit, $from=0, $back=0)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
makeSelfLink( $text, $query)
getPrevNext( $prevId, $nextId)
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getDBkey()
Get the main part with underscores.
getPrefixedText()
Get the prefixed title with spaces.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
if(!isset( $args[0])) $lang