$this->closeShowImage();
$this->imageHistory();
- $this->imageLinks();
+
if ( $showmeta ) {
global $wgStylePath, $wgStyleVersion;
*/
function showTOC( $metadata ) {
global $wgLang;
+ $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
+ $backlinksUrl = $wlh->getLocalUrl( 'hidelinks=1&hidetrans=1&target=' . urlencode( $this->mTitle->getFullText() ) );
$r = '<ul id="filetoc">
<li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
- <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
+ <li><a href="' . $backlinksUrl . '">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
($metadata ? ' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
</ul>';
return $r;
}
- function imageLinks()
- {
- global $wgUser, $wgOut;
-
- $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
-
- $dbr = wfGetDB( DB_SLAVE );
- $page = $dbr->tableName( 'page' );
- $imagelinks = $dbr->tableName( 'imagelinks' );
-
- $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
- $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id";
- $sql = $dbr->limitResult($sql, 500, 0);
- $res = $dbr->query( $sql, "ImagePage::imageLinks" );
-
- if ( 0 == $dbr->numRows( $res ) ) {
- $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
- return;
- }
- $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
-
- $sk = $wgUser->getSkin();
- while ( $s = $dbr->fetchObject( $res ) ) {
- $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
- $link = $sk->makeKnownLinkObj( $name, "" );
- $wgOut->addHTML( "<li>{$link}</li>\n" );
- }
- $wgOut->addHTML( "</ul>\n" );
- }
-
/**
* Delete the file, or an earlier version of it
*/
$opts->add( 'hideredirs', false );
$opts->add( 'hidetrans', false );
$opts->add( 'hidelinks', false );
+ $opts->add( 'hideimages', false );
$opts->fetchValuesFromRequest( $this->request );
$opts->validateIntBounds( 'limit', 0, 5000 );
$hidelinks = $this->opts->getValue( 'hidelinks' );
$hideredirs = $this->opts->getValue( 'hideredirs' );
$hidetrans = $this->opts->getValue( 'hidetrans' );
+ $hideimages = $target->getNamespace() != NS_IMAGE || $this->opts->getValue( 'hideimages' );
$fetchlinks = !$hidelinks || !$hideredirs;
'tl_title' => $target->getDBkey(),
);
+ $ilConds = array(
+ 'page_id=il_from',
+ 'il_to' => $target->getDBkey(),
+ );
$namespace = $this->opts->getValue( 'namespace' );
if ( is_int($namespace) ){
$tlConds, __METHOD__, $options );
}
- if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) ) {
+ if( !$hideimages ) {
+ $options['ORDER BY'] = 'il_from';
+ $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
+ $ilConds, __METHOD__, $options );
+ }
+
+ if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) && ( $hideimages || !$dbr->numRows( $ilRes ) ) ) {
if ( 0 == $level ) {
$wgOut->addHTML( $this->whatlinkshereForm() );
$errMsg = is_int($namespace) ? 'nolinkshere-ns' : 'nolinkshere';
$wgOut->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
// Show filters only if there are links
- if( $hidelinks || $hidetrans || $hideredirs )
+ if( $hidelinks || $hidetrans || $hideredirs || $hideimages )
$wgOut->addHTML( $this->getFilterPanel() );
}
return;
if( $fetchlinks ) {
while ( $row = $dbr->fetchObject( $plRes ) ) {
$row->is_template = 0;
+ $row->is_image = 0;
$rows[$row->page_id] = $row;
}
$dbr->freeResult( $plRes );
if( !$hidetrans ) {
while ( $row = $dbr->fetchObject( $tlRes ) ) {
$row->is_template = 1;
+ $row->is_image = 0;
$rows[$row->page_id] = $row;
}
$dbr->freeResult( $tlRes );
}
+ if( !$hideimages ) {
+ while ( $row = $dbr->fetchObject( $ilRes ) ) {
+ $row->is_template = 0;
+ $row->is_image = 1;
+ $rows[$row->page_id] = $row;
+ }
+ $dbr->freeResult( $ilRes );
+ }
// Sort by key and then change the keys to 0-based indices
ksort( $rows );
static $msgcache = null;
if ( $msgcache === null ) {
static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator',
- 'whatlinkshere-links' );
+ 'whatlinkshere-links', 'isimage' );
$msgcache = array();
foreach ( $msgs as $msg ) {
$msgcache[$msg] = wfMsgHtml( $msg );
$props[] = $msgcache['isredirect'];
if ( $row->is_template )
$props[] = $msgcache['istemplate'];
+ if( $row->is_image )
+ $props[] = $msgcache['isimage'];
if ( count( $props ) ) {
$propsText = '(' . implode( $msgcache['semicolon-separator'], $props ) . ')';
unset($changed['target']); // Already in the request title
$links = array();
- foreach( array( 'hidetrans', 'hidelinks', 'hideredirs' ) as $type ) {
+ $types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
+ if( $this->target->getNamespace() == NS_IMAGE )
+ $types[] = 'hideimages';
+ foreach( $types as $type ) {
$chosen = $this->opts->getValue( $type );
$msg = wfMsgHtml( "whatlinkshere-{$type}", $chosen ? $show : $hide );
$overrides = array( $type => !$chosen );