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';
159 "rd_from = $fromCol",
161 'rd_interwiki = ' .
$dbr->addQuotes(
'' ) .
' OR rd_interwiki IS NULL'
165 $subQuery =
$dbr->selectSQLText(
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 $errMsg = is_int( $namespace ) ?
'nolinkshere-ns' :
'nolinkshere';
212 $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
213 $out->setStatusCode( 404 );
224 foreach ( $plRes
as $row ) {
225 $row->is_template = 0;
227 $rows[$row->page_id] = $row;
231 foreach ( $tlRes
as $row ) {
232 $row->is_template = 1;
234 $rows[$row->page_id] = $row;
237 if ( !$hideimages ) {
238 foreach ( $ilRes
as $row ) {
239 $row->is_template = 0;
241 $rows[$row->page_id] = $row;
247 $rows = array_values( $rows );
249 $numRows =
count( $rows );
252 if ( $numRows >
$limit ) {
255 $nextId = $rows[
$limit]->page_id;
257 $rows = array_slice( $rows, 0,
$limit );
267 foreach ( $rows
as $row ) {
268 $lb->add( $row->page_namespace, $row->page_title );
276 $out->addWikiMsg(
'linkshere', $this->target->getPrefixedText() );
278 $prevnext = $this->
getPrevNext( $prevId, $nextId );
279 $out->addHTML( $prevnext );
283 foreach ( $rows
as $row ) {
286 if ( $row->rd_from && $level < 2 ) {
291 $this->
getConfig()->
get(
'MaxRedirectLinksRetrieved' )
303 $out->addHTML( $prevnext );
309 return Xml::openElement(
'ul', ( $level ? [] : [
'id' =>
'mw-whatlinkshere-list' ] ) );
315 # local message cache
316 static $msgcache =
null;
317 if ( $msgcache ===
null ) {
318 static $msgs = [
'isredirect',
'istemplate',
'semicolon-separator',
319 'whatlinkshere-links',
'isimage',
'editlink' ];
321 foreach ( $msgs
as $msg ) {
322 $msgcache[$msg] = $this->
msg( $msg )->escaped();
326 if ( $row->rd_from ) {
327 $query = [
'redirect' =>
'no' ];
335 $row->page_is_redirect ? [
'class' =>
'mw-redirect' ] : [],
342 if ( $row->rd_from ) {
343 $props[] = $msgcache[
'isredirect'];
345 if ( $row->is_template ) {
346 $props[] = $msgcache[
'istemplate'];
348 if ( $row->is_image ) {
349 $props[] = $msgcache[
'isimage'];
354 if (
count( $props ) ) {
355 $propsText = $this->
msg(
'parentheses' )
356 ->rawParams( implode( $msgcache[
'semicolon-separator'], $props ) )->escaped();
359 # Space for utilities links, with a what-links-here link provided
360 $wlhLink = $this->
wlhLink( $nt, $msgcache[
'whatlinkshere-links'], $msgcache[
'editlink'] );
362 $this->
msg(
'parentheses' )->rawParams( $wlhLink )->escaped(),
363 'mw-whatlinkshere-tools'
368 Xml::tags(
'li',
null,
"$link $propsText $dirmark $wlh" ) .
"\n";
383 if ( $text !==
null ) {
400 $this->
getUser()->isAllowed(
'edit' ) &&
404 if ( $editText !==
null ) {
412 [
'action' =>
'edit' ]
421 if ( $text !==
null ) {
434 $currentLimit = $this->
opts->getValue(
'limit' );
435 $prev = $this->
msg(
'whatlinkshere-prev' )->numParams( $currentLimit )->escaped();
436 $next = $this->
msg(
'whatlinkshere-next' )->numParams( $currentLimit )->escaped();
438 $changed = $this->
opts->getChangedValues();
439 unset( $changed[
'target'] );
441 if ( 0 != $prevId ) {
442 $overrides = [
'from' => $this->
opts->getValue(
'back' ) ];
443 $prev = $this->
makeSelfLink( $prev, array_merge( $changed, $overrides ) );
445 if ( 0 != $nextId ) {
446 $overrides = [
'from' => $nextId,
'back' => $prevId ];
447 $next = $this->
makeSelfLink( $next, array_merge( $changed, $overrides ) );
452 foreach ( $this->limits
as $limit ) {
453 $prettyLimit = htmlspecialchars(
$lang->formatNum(
$limit ) );
454 $overrides = [
'limit' =>
$limit ];
455 $limitLinks[] = $this->
makeSelfLink( $prettyLimit, array_merge( $changed, $overrides ) );
458 $nums =
$lang->pipeList( $limitLinks );
460 return $this->
msg(
'viewprevnext' )->rawParams( $prev, $next, $nums )->escaped();
465 $this->
opts->consumeValue(
'target' );
467 $this->
opts->consumeValues( [
'back',
'from' ] );
470 $namespace = $this->
opts->consumeValue(
'namespace' );
471 $nsinvert = $this->
opts->consumeValue(
'invert' );
476 # Values that should not be forgotten
484 # Target input (.mw-searchInput enables suggestions)
486 'mw-whatlinkshere-target', 40,
$target, [
'class' =>
'mw-searchInput' ] );
493 'selected' => $namespace,
495 'label' => $this->
msg(
'namespace' )->
text()
497 'name' =>
'namespace',
499 'class' =>
'namespaceselector',
505 $this->
msg(
'invert' )->
text(),
509 [
'title' => $this->
msg(
'tooltip-whatlinkshere-invert' )->
text() ]
529 $show = $this->
msg(
'show' )->escaped();
530 $hide = $this->
msg(
'hide' )->escaped();
532 $changed = $this->
opts->getChangedValues();
533 unset( $changed[
'target'] );
536 $types = [
'hidetrans',
'hidelinks',
'hideredirs' ];
537 if ( $this->target->getNamespace() ==
NS_FILE ) {
538 $types[] =
'hideimages';
545 $chosen = $this->
opts->getValue( $type );
546 $msg = $chosen ? $show : $hide;
547 $overrides = [
$type => !$chosen ];
548 $links[] = $this->
msg(
"whatlinkshere-{$type}" )->rawParams(
549 $this->
makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped();
553 $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.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
getOutput()
Get the OutputPage being used for this instance.
if(!isset( $args[0])) $lang
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
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
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.
Allows to change the fields on the form that will be generated $name
getLanguage()
Shortcut to get user's language.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
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.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
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.
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
msg()
Wrapper around wfMessage that sets the current context.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
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)
Represents a title within MediaWiki.
static closeElement( $element)
Shortcut to close an XML element.
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.
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