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' );
117 $fetchlinks = ( !$hidelinks || !$hideredirs );
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;
149 } elseif ( $hidelinks ) {
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' => [
'INNER 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' => [
'INNER JOIN',
"$fromCol = page_id" ] ]
188 $plRes = $queryFunc(
$dbr,
'pagelinks',
'pl_from' );
192 $tlRes = $queryFunc(
$dbr,
'templatelinks',
'tl_from' );
195 if ( !$hideimages ) {
196 $ilRes = $queryFunc(
$dbr,
'imagelinks',
'il_from' );
199 if ( ( !$fetchlinks || !$plRes->numRows() )
200 && ( $hidetrans || !$tlRes->numRows() )
201 && ( $hideimages || !$ilRes->numRows() )
208 if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
211 $msgKey = is_int( $namespace ) ?
'nolinkshere-ns' :
'nolinkshere';
216 $this->target->isRedirect() ? [
'redirect' =>
'no' ] : []
219 $errMsg = $this->
msg( $msgKey )
220 ->params( $this->target->getPrefixedText() )
223 $out->addHTML( $errMsg );
224 $out->setStatusCode( 404 );
235 foreach ( $plRes
as $row ) {
236 $row->is_template = 0;
238 $rows[$row->page_id] = $row;
242 foreach ( $tlRes
as $row ) {
243 $row->is_template = 1;
245 $rows[$row->page_id] = $row;
248 if ( !$hideimages ) {
249 foreach ( $ilRes
as $row ) {
250 $row->is_template = 0;
252 $rows[$row->page_id] = $row;
260 $numRows = count(
$rows );
263 if ( $numRows > $limit ) {
266 $nextId =
$rows[$limit]->page_id;
279 $lb->add( $row->page_namespace, $row->page_title );
292 $this->target->isRedirect() ? [
'redirect' =>
'no' ] : []
295 $msg = $this->
msg(
'linkshere' )
296 ->params( $this->target->getPrefixedText() )
299 $out->addHTML( $msg );
301 $prevnext = $this->
getPrevNext( $prevId, $nextId );
302 $out->addHTML( $prevnext );
307 $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
309 if ( $row->rd_from && $level < 2 ) {
314 $this->
getConfig()->
get(
'MaxRedirectLinksRetrieved' )
316 $out->addHTML( Xml::closeElement(
'li' ) );
326 $out->addHTML( $prevnext );
332 return Xml::openElement(
'ul', ( $level ? [] : [
'id' =>
'mw-whatlinkshere-list' ] ) );
338 # local message cache
339 static $msgcache =
null;
340 if ( $msgcache ===
null ) {
341 static $msgs = [
'isredirect',
'istemplate',
'semicolon-separator',
342 'whatlinkshere-links',
'isimage',
'editlink' ];
344 foreach ( $msgs
as $msg ) {
345 $msgcache[$msg] = $this->
msg( $msg )->escaped();
349 if ( $row->rd_from ) {
350 $query = [
'redirect' =>
'no' ];
358 $row->page_is_redirect ? [
'class' =>
'mw-redirect' ] : [],
365 if ( $row->rd_from ) {
366 $props[] = $msgcache[
'isredirect'];
368 if ( $row->is_template ) {
369 $props[] = $msgcache[
'istemplate'];
371 if ( $row->is_image ) {
372 $props[] = $msgcache[
'isimage'];
375 Hooks::run(
'WhatLinksHereProps', [ $row, $nt,
$target, &$props ] );
377 if ( count( $props ) ) {
378 $propsText = $this->
msg(
'parentheses' )
379 ->rawParams( implode( $msgcache[
'semicolon-separator'], $props ) )->escaped();
382 # Space for utilities links, with a what-links-here link provided
383 $wlhLink = $this->
wlhLink( $nt, $msgcache[
'whatlinkshere-links'], $msgcache[
'editlink'] );
384 $wlh = Xml::wrapClass(
385 $this->
msg(
'parentheses' )->rawParams( $wlhLink )->escaped(),
386 'mw-whatlinkshere-tools'
390 Xml::openElement(
'li' ) .
"$link $propsText $dirmark $wlh\n" :
391 Xml::tags(
'li',
null,
"$link $propsText $dirmark $wlh" ) .
"\n";
395 return Xml::closeElement(
'ul' );
406 if ( $text !==
null ) {
423 $this->
getUser()->isAllowed(
'edit' ) &&
425 ContentHandler::getForTitle(
$target )->supportsDirectEditing()
427 if ( $editText !==
null ) {
435 [
'action' =>
'edit' ]
444 if ( $text !==
null ) {
457 $currentLimit = $this->opts->getValue(
'limit' );
458 $prev = $this->
msg(
'whatlinkshere-prev' )->numParams( $currentLimit )->escaped();
459 $next = $this->
msg(
'whatlinkshere-next' )->numParams( $currentLimit )->escaped();
461 $changed = $this->opts->getChangedValues();
462 unset( $changed[
'target'] );
464 if ( 0 != $prevId ) {
465 $overrides = [
'from' => $this->opts->getValue(
'back' ) ];
466 $prev = $this->
makeSelfLink( $prev, array_merge( $changed, $overrides ) );
468 if ( 0 != $nextId ) {
469 $overrides = [
'from' => $nextId,
'back' => $prevId ];
470 $next = $this->
makeSelfLink( $next, array_merge( $changed, $overrides ) );
475 foreach ( $this->limits
as $limit ) {
476 $prettyLimit = htmlspecialchars(
$lang->formatNum( $limit ) );
477 $overrides = [
'limit' => $limit ];
478 $limitLinks[] = $this->
makeSelfLink( $prettyLimit, array_merge( $changed, $overrides ) );
481 $nums =
$lang->pipeList( $limitLinks );
483 return $this->
msg(
'viewprevnext' )->rawParams( $prev, $next, $nums )->escaped();
488 $this->opts->consumeValue(
'target' );
490 $this->opts->consumeValues( [
'back',
'from' ] );
493 $namespace = $this->opts->consumeValue(
'namespace' );
494 $nsinvert = $this->opts->consumeValue(
'invert' );
497 $f = Xml::openElement(
'form', [
'action' =>
wfScript() ] );
499 # Values that should not be forgotten
500 $f .= Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() );
501 foreach ( $this->opts->getUnconsumedValues()
as $name =>
$value ) {
505 $f .= Xml::fieldset( $this->
msg(
'whatlinkshere' )->
text() );
507 # Target input (.mw-searchInput enables suggestions)
508 $f .= Xml::inputLabel( $this->
msg(
'whatlinkshere-page' )->
text(),
'target',
509 'mw-whatlinkshere-target', 40,
$target, [
'class' =>
'mw-searchInput' ] );
514 $f .= Html::namespaceSelector(
516 'selected' => $namespace,
518 'label' => $this->
msg(
'namespace' )->
text()
520 'name' =>
'namespace',
522 'class' =>
'namespaceselector',
528 $this->
msg(
'invert' )->
text(),
532 [
'title' => $this->
msg(
'tooltip-whatlinkshere-invert' )->
text() ]
538 $f .= Xml::submitButton( $this->
msg(
'whatlinkshere-submit' )->
text() );
541 $f .= Xml::closeElement(
'fieldset' ) . Xml::closeElement(
'form' ) .
"\n";
552 $show = $this->
msg(
'show' )->escaped();
553 $hide = $this->
msg(
'hide' )->escaped();
555 $changed = $this->opts->getChangedValues();
556 unset( $changed[
'target'] );
559 $types = [
'hidetrans',
'hidelinks',
'hideredirs' ];
560 if ( $this->target->getNamespace() ==
NS_FILE ) {
561 $types[] =
'hideimages';
568 $chosen = $this->opts->getValue(
$type );
569 $msg = $chosen ? $show : $hide;
570 $overrides = [
$type => !$chosen ];
571 $links[] = $this->
msg(
"whatlinkshere-{$type}" )->rawParams(
572 $this->
makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped();
575 return Xml::fieldset(
576 $this->
msg(
'whatlinkshere-filters' )->
text(),
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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
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.
including( $x=null)
Whether the special page is being evaluated via transclusion.
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.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
Allows to change the fields on the form that will be generated $name
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
if(!isset( $args[0])) $lang