From cdc7e22de9289a3c9f0f74d10dd0f150273df23f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 5 May 2008 22:14:55 +0000 Subject: [PATCH] Revert r34267, r34268, r34269, r34270 for now. I don't like the UI chhanges here; the file usage links simply disappear from their current location with no warning or explanation, while the in-page TOC at the top suddenly starts linking to a different page, totally unexpectedly. --- RELEASE-NOTES | 1 - includes/ImagePage.php | 36 +++++++++++++++++++++++++++---- includes/SpecialWhatlinkshere.php | 35 ++++-------------------------- languages/messages/MessagesEn.php | 4 ++-- maintenance/language/messages.inc | 2 -- 5 files changed, 38 insertions(+), 40 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index acb1dd7cfb..cc773771e6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -103,7 +103,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN shared when $wgSharedDB is enabled. * Drop-down AJAX search suggestions (turn on $wgEnableMWSuggest) * More relevant search snippets (turn on $wgAdvancedSearchHighlighting) -* Image links are now displayed using Special:Whatlinkshere === Bug fixes in 1.13 === diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 9c28f2cfa2..3b8a1f5e20 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -87,7 +87,7 @@ class ImagePage extends Article { $this->closeShowImage(); $this->imageHistory(); - + $this->imageLinks(); if ( $showmeta ) { global $wgStylePath, $wgStyleVersion; @@ -111,12 +111,10 @@ class ImagePage extends Article { */ function showTOC( $metadata ) { global $wgLang; - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); - $backlinksUrl = $wlh->getLocalUrl( 'hidelinks=1&hidetrans=1&target=' . urlencode( $this->mTitle->getFullText() ) ); $r = ''; return $r; @@ -494,6 +492,36 @@ EOT } + 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( '

' . wfMsg( "nolinkstoimage" ) . "

\n" ); + return; + } + $wgOut->addHTML( '

' . wfMsg( 'linkstoimage' ) . "

\n\n" ); + } + /** * Delete the file, or an earlier version of it */ diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index d51e13ad82..c1eb4565c4 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -51,7 +51,6 @@ class WhatLinksHerePage { $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 ); @@ -95,7 +94,6 @@ class WhatLinksHerePage { $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; @@ -117,10 +115,6 @@ class WhatLinksHerePage { 'tl_title' => $target->getDBkey(), ); - $ilConds = array( - 'page_id=il_from', - 'il_to' => $target->getDBkey(), - ); $namespace = $this->opts->getValue( 'namespace' ); if ( is_int($namespace) ){ @@ -155,19 +149,13 @@ class WhatLinksHerePage { $tlConds, __METHOD__, $options ); } - 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( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) ) { 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 || $hideimages ) + if( $hidelinks || $hidetrans || $hideredirs ) $wgOut->addHTML( $this->getFilterPanel() ); } return; @@ -179,7 +167,6 @@ class WhatLinksHerePage { if( $fetchlinks ) { while ( $row = $dbr->fetchObject( $plRes ) ) { $row->is_template = 0; - $row->is_image = 0; $rows[$row->page_id] = $row; } $dbr->freeResult( $plRes ); @@ -188,19 +175,10 @@ class WhatLinksHerePage { 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 ); @@ -259,7 +237,7 @@ class WhatLinksHerePage { static $msgcache = null; if ( $msgcache === null ) { static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator', - 'whatlinkshere-links', 'isimage' ); + 'whatlinkshere-links' ); $msgcache = array(); foreach ( $msgs as $msg ) { $msgcache[$msg] = wfMsgHtml( $msg ); @@ -276,8 +254,6 @@ class WhatLinksHerePage { $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 ) . ')'; @@ -390,10 +366,7 @@ class WhatLinksHerePage { unset($changed['target']); // Already in the request title $links = array(); - $types = array( 'hidetrans', 'hidelinks', 'hideredirs' ); - if( $this->target->getNamespace() == NS_IMAGE ) - $types[] = 'hideimages'; - foreach( $types as $type ) { + foreach( array( 'hidetrans', 'hidelinks', 'hideredirs' ) as $type ) { $chosen = $this->opts->getValue( $type ); $msg = wfMsgHtml( "whatlinkshere-{$type}", $chosen ? $show : $hide ); $overrides = array( $type => !$chosen ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 71bd5629c8..4fb40a0fa3 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2422,8 +2422,8 @@ Do you want to delete it to make way for the move?', cannot move a page over itself.', 'immobile_namespace' => 'Source or destination title is of a special type; cannot move pages from and into that namespace.', -'imagenocrossnamespace' => 'Cannot move file to non-file namespace', -'imagetypemismatch' => 'The new file extension does not match its type', +'imagenocrossnamespace' => "Cannot move file to non-file namespace", +'imagetypemismatch' => "The new file extension does not match its type", # Export 'export' => 'Export pages', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 24b214aa72..facc5191ec 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1518,11 +1518,9 @@ $wgMessageStructure = array( 'nolinkshere-ns', 'isredirect', 'istemplate', - 'isimage', 'whatlinkshere-prev', 'whatlinkshere-next', 'whatlinkshere-links', - 'whatlinkshere-hideimages', 'whatlinkshere-hideredirs', 'whatlinkshere-hidetrans', 'whatlinkshere-hidelinks', -- 2.20.1