From: Bryan Tong Minh Date: Fri, 9 May 2008 11:31:00 +0000 (+0000) Subject: * Show a link to [[Special:Whatlinkshere]] in case there are more imagelinks on ImagePage X-Git-Tag: 1.31.0-rc.0~47786 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=66dcc672ad519d6d2e3c2872e90d29272f820148;p=lhc%2Fweb%2Fwiklou.git * Show a link to [[Special:Whatlinkshere]] in case there are more imagelinks on ImagePage * Cleanup ImagePage code --- diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 0ba21985ea..c77c0776cf 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -521,31 +521,45 @@ EOT function imageLinks() { global $wgUser, $wgOut; + + $limit = 100; $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" ); + $res = $dbr->select( + array( 'imagelinks', 'page' ), + array( 'page_namespace', 'page_title' ), + array( 'il_to' => $this->mTitle->getDBkey(), 'il_from = page_id' ), + __METHOD__, + array( 'LIMIT' => $limit + 1) + ); if ( 0 == $dbr->numRows( $res ) ) { - $wgOut->addHtml( '

' . wfMsg( "nolinkstoimage" ) . "

\n" ); + $wgOut->addHtml( Xml::element('p', null ,wfMsg( "nolinkstoimage" ) )."\n" ); return; } - $wgOut->addHTML( '

' . wfMsg( 'linkstoimage' ) . "

\n\n" ); + $res->free(); + + // Add a links to [[Special:Whatlinkshere]] + if ( $count > $limit ) + $wgOut->addWikiText( wfMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() ) ); } function imageRedirects() @@ -561,7 +575,8 @@ EOT 'rd_title' => $this->mTitle->getDBkey(), 'page_namespace' => NS_IMAGE, 'rd_from = page_id' - ) + ), + __METHOD__ ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 8198f81314..cd75dec49d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1710,6 +1710,7 @@ A click on a column header changes the sorting.', 'imagelinks' => 'Links', 'linkstoimage' => 'The following pages link to this file:', 'nolinkstoimage' => 'There are no pages that link to this file.', +'morelinkstoimage' => 'View [[Special:Whatlinkshere/$1|more links]] to this file.', 'redirectstofile' => 'The following files redirect to this file:', 'sharedupload' => 'This file is a shared upload and may be used by other projects.', 'shareduploadwiki' => 'Please see the $1 for further information.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index fbfae95456..a301439c0f 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1050,6 +1050,7 @@ $wgMessageStructure = array( 'imagelinks', 'linkstoimage', 'nolinkstoimage', + 'morelinkstoimage', 'redirectstofile', 'sharedupload', 'shareduploadwiki',