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';
153 $queryFunc =
function (
IDatabase $dbr, $table, $fromCol ) use (
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 $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;
249 $numRows = count(
$rows );
252 if ( $numRows > $limit ) {
255 $nextId =
$rows[$limit]->page_id;
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 ) {
284 $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
286 if ( $row->rd_from && $level < 2 ) {
291 $this->
getConfig()->
get(
'MaxRedirectLinksRetrieved' )
293 $out->addHTML( Xml::closeElement(
'li' ) );
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'];
352 Hooks::run(
'WhatLinksHereProps', [ $row, $nt,
$target, &$props ] );
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'] );
361 $wlh = Xml::wrapClass(
362 $this->
msg(
'parentheses' )->rawParams( $wlhLink )->escaped(),
363 'mw-whatlinkshere-tools'
367 Xml::openElement(
'li' ) .
"$link $propsText $dirmark $wlh\n" :
368 Xml::tags(
'li',
null,
"$link $propsText $dirmark $wlh" ) .
"\n";
372 return Xml::closeElement(
'ul' );
376 static $title =
null;
377 if ( $title ===
null ) {
383 if ( $text !==
null ) {
400 $this->
getUser()->isAllowed(
'edit' ) &&
402 ContentHandler::getForTitle(
$target )->supportsDirectEditing()
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' );
474 $f = Xml::openElement(
'form', [
'action' =>
wfScript() ] );
476 # Values that should not be forgotten
477 $f .= Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() );
478 foreach ( $this->opts->getUnconsumedValues() as $name =>
$value ) {
479 $f .= Html::hidden( $name,
$value );
482 $f .= Xml::fieldset( $this->
msg(
'whatlinkshere' )->
text() );
484 # Target input (.mw-searchInput enables suggestions)
485 $f .= Xml::inputLabel( $this->
msg(
'whatlinkshere-page' )->
text(),
'target',
486 'mw-whatlinkshere-target', 40,
$target, [
'class' =>
'mw-searchInput' ] );
491 $f .= Html::namespaceSelector(
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() ]
515 $f .= Xml::submitButton( $this->
msg(
'whatlinkshere-submit' )->
text() );
518 $f .= Xml::closeElement(
'fieldset' ) . Xml::closeElement(
'form' ) .
"\n";
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';
544 foreach ( $types as
$type ) {
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();
552 return Xml::fieldset(
553 $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
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.
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
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 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
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