Go to the documentation of this file.
40 protected $limits = [ 20, 50, 100, 250, 500 ];
43 parent::__construct(
'Whatlinkshere' );
70 if ( $par !==
null ) {
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' => [
'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" ] ]
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() )
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;
261 if ( $numRows > $limit ) {
264 $nextId =
$rows[$limit]->page_id;
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 );
305 if ( $row->rd_from && $level < 2 ) {
310 $this->
getConfig()->
get(
'MaxRedirectLinksRetrieved' )
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'];
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'] );
379 $this->
msg(
'parentheses' )->rawParams( $wlhLink )->escaped(),
380 'mw-whatlinkshere-tools'
385 Xml::tags(
'li',
null,
"$link $propsText $dirmark $wlh" ) .
"\n";
400 if ( $text !==
null ) {
417 $this->
getUser()->isAllowed(
'edit' ) &&
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' ) ];
460 $prev = $this->
makeSelfLink( $prev, array_merge( $changed, $overrides ) );
462 if ( $nextId != 0 ) {
463 $overrides = [
'from' => $nextId,
'back' => $prevId ];
464 $next = $this->
makeSelfLink( $next, array_merge( $changed, $overrides ) );
469 foreach ( $this->limits
as $limit ) {
470 $prettyLimit = htmlspecialchars(
$lang->formatNum( $limit ) );
471 $overrides = [
'limit' => $limit ];
472 $limitLinks[] = $this->
makeSelfLink( $prettyLimit, array_merge( $changed, $overrides ) );
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' );
493 # Values that should not be forgotten
494 $f .= Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() );
501 # Target input (.mw-searchInput enables suggestions)
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() ]
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';
563 $chosen = $this->
opts->getValue( $type );
564 $msg = $chosen ? $show : $hide;
565 $overrides = [
$type => !$chosen ];
566 $links[] = $this->
msg(
"whatlinkshere-{$type}" )->rawParams(
567 $this->
makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped();
571 $this->
msg(
'whatlinkshere-filters' )->
text(),
getPageTitle( $subpage=false)
Get a self-referential title object.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Marks HTML that shouldn't be escaped.
msg( $key)
Wrapper around wfMessage that sets the current context.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
getOutput()
Get the OutputPage being used for this instance.
if(!isset( $args[0])) $lang
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
getPrefixedText()
Get the prefixed title with spaces.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
getSkin()
Shortcut to get the skin being used for this instance.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Shortcut to construct an includable special page.
getLanguage()
Shortcut to get user's language.
static openElement( $element, $attribs=null)
This opens an XML element.
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
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
null for the 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
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
static wrapClass( $text, $class, $tag='span', $attribs=[])
Shortcut to make a specific element with a class attribute.
getDBkey()
Get the main part with underscores.
getConfig()
Shortcut to get main config object.
namespace and then decline to actually register it file or subcat img or subcat $title
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
getNamespace()
Get the namespace index, i.e.
getPrevNext( $prevId, $nextId)
wlhLink(Title $target, $text, $editText)
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
showIndirectLinks( $level, $target, $limit, $from=0, $back=0)
Implements Special:Whatlinkshere.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Allows to change the fields on the form that will be generated $name
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
execute( $par)
Default execute method Checks user permissions.
getRequest()
Get the WebRequest being used for this instance.
makeSelfLink( $text, $query)
listItem( $row, $nt, $target, $notClose=false)
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
Represents a title within MediaWiki.
static closeElement( $element)
Shortcut to close an XML element.
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 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
getFilterPanel()
Create filter panel.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
MediaWiki Linker LinkRenderer null $linkRenderer
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
including( $x=null)
Whether the special page is being evaluated via transclusion.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.