summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialWhatlinkshere.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialWhatlinkshere.php')
-rw-r--r--includes/specials/SpecialWhatlinkshere.php69
1 files changed, 39 insertions, 30 deletions
diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php
index cb3e985c..05c7dd5f 100644
--- a/includes/specials/SpecialWhatlinkshere.php
+++ b/includes/specials/SpecialWhatlinkshere.php
@@ -77,7 +77,7 @@ class SpecialWhatLinksHere extends SpecialPage {
$this->opts = $opts;
$this->target = Title::newFromURL( $opts->getValue( 'target' ) );
- if( !$this->target ) {
+ if ( !$this->target ) {
$out->addHTML( $this->whatlinkshereForm() );
return;
}
@@ -94,11 +94,11 @@ class SpecialWhatLinksHere extends SpecialPage {
}
/**
- * @param int $level Recursion level
- * @param $target Title Target title
- * @param int $limit Number of entries to display
- * @param $from Title Display from this article ID
- * @param $back Title Display from this article ID at backwards scrolling
+ * @param int $level Recursion level
+ * @param Title $target Target title
+ * @param int $limit Number of entries to display
+ * @param int $from Display from this article ID (default: 0)
+ * @param int $back Display from this article ID at backwards scrolling (default: 0)
*/
function showIndirectLinks( $level, $target, $limit, $from = 0, $back = 0 ) {
global $wgMaxRedirectLinksRetrieved;
@@ -111,7 +111,7 @@ class SpecialWhatLinksHere extends SpecialPage {
$hidetrans = $this->opts->getValue( 'hidetrans' );
$hideimages = $target->getNamespace() != NS_FILE || $this->opts->getValue( 'hideimages' );
- $fetchlinks = (!$hidelinks || !$hideredirs);
+ $fetchlinks = ( !$hidelinks || !$hideredirs );
// Make the query
$plConds = array(
@@ -119,9 +119,9 @@ class SpecialWhatLinksHere extends SpecialPage {
'pl_namespace' => $target->getNamespace(),
'pl_title' => $target->getDBkey(),
);
- if( $hideredirs ) {
+ if ( $hideredirs ) {
$plConds['rd_from'] = null;
- } elseif( $hidelinks ) {
+ } elseif ( $hidelinks ) {
$plConds[] = 'rd_from is NOT NULL';
}
@@ -166,34 +166,38 @@ class SpecialWhatLinksHere extends SpecialPage {
'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL'
)));
- if( $fetchlinks ) {
+ if ( $fetchlinks ) {
$options['ORDER BY'] = 'pl_from';
$plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
$plConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
- if( !$hidetrans ) {
+ if ( !$hidetrans ) {
$options['ORDER BY'] = 'tl_from';
$tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
$tlConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
- if( !$hideimages ) {
+ if ( !$hideimages ) {
$options['ORDER BY'] = 'il_from';
$ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
$ilConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
- if( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
+ if ( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
if ( 0 == $level ) {
$out->addHTML( $this->whatlinkshereForm() );
// Show filters only if there are links
- if( $hidelinks || $hidetrans || $hideredirs || $hideimages )
+ if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
$out->addHTML( $this->getFilterPanel() );
+ }
$errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
$out->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
@@ -204,21 +208,21 @@ class SpecialWhatLinksHere extends SpecialPage {
// Read the rows into an array and remove duplicates
// templatelinks comes second so that the templatelinks row overwrites the
// pagelinks row, so we get (inclusion) rather than nothing
- if( $fetchlinks ) {
+ if ( $fetchlinks ) {
foreach ( $plRes as $row ) {
$row->is_template = 0;
$row->is_image = 0;
$rows[$row->page_id] = $row;
}
}
- if( !$hidetrans ) {
+ if ( !$hidetrans ) {
foreach ( $tlRes as $row ) {
$row->is_template = 1;
$row->is_image = 0;
$rows[$row->page_id] = $row;
}
}
- if( !$hideimages ) {
+ if ( !$hideimages ) {
foreach ( $ilRes as $row ) {
$row->is_template = 0;
$row->is_image = 1;
@@ -269,7 +273,7 @@ class SpecialWhatLinksHere extends SpecialPage {
$out->addHTML( $this->listEnd() );
- if( $level == 0 ) {
+ if ( $level == 0 ) {
$out->addHTML( $prevnext );
}
}
@@ -292,7 +296,7 @@ class SpecialWhatLinksHere extends SpecialPage {
}
}
- if( $row->rd_from ) {
+ if ( $row->rd_from ) {
$query = array( 'redirect' => 'no' );
} else {
$query = array();
@@ -308,12 +312,15 @@ class SpecialWhatLinksHere extends SpecialPage {
// Display properties (redirect or template)
$propsText = '';
$props = array();
- if ( $row->rd_from )
+ if ( $row->rd_from ) {
$props[] = $msgcache['isredirect'];
- if ( $row->is_template )
+ }
+ if ( $row->is_template ) {
$props[] = $msgcache['istemplate'];
- if( $row->is_image )
+ }
+ if ( $row->is_image ) {
$props[] = $msgcache['isimage'];
+ }
if ( count( $props ) ) {
$propsText = $this->msg( 'parentheses' )->rawParams( implode( $msgcache['semicolon-separator'], $props ) )->escaped();
@@ -334,8 +341,9 @@ class SpecialWhatLinksHere extends SpecialPage {
protected function wlhLink( Title $target, $text ) {
static $title = null;
- if ( $title === null )
+ if ( $title === null ) {
$title = $this->getTitle();
+ }
return Linker::linkKnown(
$title,
@@ -419,8 +427,8 @@ class SpecialWhatLinksHere extends SpecialPage {
'all' => '',
'label' => $this->msg( 'namespace' )->text()
), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
'class' => 'namespaceselector',
)
);
@@ -450,12 +458,13 @@ class SpecialWhatLinksHere extends SpecialPage {
$links = array();
$types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
- if( $this->target->getNamespace() == NS_FILE )
+ if ( $this->target->getNamespace() == NS_FILE ) {
$types[] = 'hideimages';
+ }
// Combined message keys: 'whatlinkshere-hideredirs', 'whatlinkshere-hidetrans', 'whatlinkshere-hidelinks', 'whatlinkshere-hideimages'
// To be sure they will be found by grep
- foreach( $types as $type ) {
+ foreach ( $types as $type ) {
$chosen = $this->opts->getValue( $type );
$msg = $chosen ? $show : $hide;
$overrides = array( $type => !$chosen );