Wikia code/includes/ImagePage.php
< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.42.3. |
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\ImagePage.php 2011-07-18 22:31:28.059570300 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\ImagePage.php 2011-08-17 15:28:46.421875000 +0100
@@ -10,6 +10,8 @@
*/
class ImagePage extends Article {
+ const FILE_LINKS_SECTION_ID = 'File_links';
+
/* private */ var $img; // Image object
/* private */ var $displayImg;
/* private */ var $repo;
@@ -124,6 +126,7 @@
$this->imageHistory();
// TODO: Cleanup the following
+ $wgOut->addHTML('<a id="'.self::FILE_LINKS_SECTION_ID.'" name="'.self::FILE_LINKS_SECTION_ID.'" rel="nofollow"></a>'."\n");
$wgOut->addHTML( Xml::element( 'h2',
array( 'id' => 'filelinks' ),
wfMsg( 'imagelinks' ) ) . "\n" );
@@ -146,8 +149,7 @@
$wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
$wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
$wgOut->addScriptFile( 'metadata.js' );
- $wgOut->addHTML(
- "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
+ $wgOut->addInlineScript( "attachMetadataToggle('mw_metadata', '$expand', '$collapse');" );
}
}
@@ -292,7 +294,7 @@
$this->loadFile();
- $full_url = $this->displayImg->getURL();
+ $full_url = wfReplaceImageServer( $this->displayImg->getURL(), $this->displayImg->getTimestamp() );
$linkAttribs = false;
$sizeSel = intval( $wgUser->getOption( 'imagesize') );
if( !isset( $wgImageLimits[$sizeSel] ) ) {
@@ -352,25 +354,52 @@
# because of rounding.
}
$msgbig = wfMsgHtml( 'show-big-image' );
- $msgsmall = wfMsgExt( 'show-big-image-thumb', 'parseinline',
- $wgLang->formatNum( $width ),
- $wgLang->formatNum( $height )
- );
+// //RT#55755 $msgsmall = wfMsgExt( 'show-big-image-thumb', 'parseinline',
+// $wgLang->formatNum( $width ),
+// $wgLang->formatNum( $height )
+// );
} else {
# Image is small enough to show full size on image page
$msgbig = htmlspecialchars( $this->displayImg->getName() );
- $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
+ //RT#55755 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
}
$params['width'] = $width;
$thumbnail = $this->displayImg->transform( $params );
+ # Image links. RT #55755
+ $limit = 5;
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $this->getImageLinksRes($dbr, $limit);
+ $num_imagelinks = $dbr->numRows( $res );
+ $links = array();
+ $count = 0;
+ while ( $s = $res->fetchObject() ) {
+ $count++;
+ if( $count <= $limit ) {
+ // We have not yet reached the extra one that tells us there is more to fetch
+ $name = Title::makeTitle( $s->page_namespace, $s->page_title );
+ $link = $sk->makeKnownLinkObj( $name, "" );
+ $links[] = $link;
+ }
+ }
+ # "more" link
+ if ($num_imagelinks > $limit) {
+ $links[] = '<a href="#'.self::FILE_LINKS_SECTION_ID.'">' . wfMsg( 'imageseo-featured-more' ) . '</a>';
+ }
+
$anchorclose = "<br />";
if( $this->displayImg->mustRender() ) {
$showLink = true;
} else {
+ $imagelinks_str = '';
+ if ($num_imagelinks) {
+ $imagelinks_str = wfMsg( 'imageseo-featured-on' );
+ $imagelinks_str .= implode(', ', $links);
+ }
$anchorclose .=
- $msgsmall .
+ $imagelinks_str .
+ //RT#55755 '<br />' . $msgsmall .
'<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
}
@@ -611,13 +640,7 @@
}
}
- protected function imageLinks() {
- global $wgUser, $wgOut, $wgLang;
-
- $limit = 100;
-
- $dbr = wfGetDB( DB_SLAVE );
-
+ private function getImageLinksRes($dbr, $limit) {
$res = $dbr->select(
array( 'imagelinks', 'page' ),
array( 'page_namespace', 'page_title' ),
@@ -625,6 +648,17 @@
__METHOD__,
array( 'LIMIT' => $limit + 1)
);
+
+ return $res;
+ }
+
+ protected function imageLinks() {
+ global $wgUser, $wgOut, $wgLang;
+
+ $limit = 100;
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $this->getImageLinksRes($dbr, $limit);
$count = $dbr->numRows( $res );
if( $count == 0 ) {
$wgOut->addHTML( "<div id='mw-imagepage-nolinkstoimage'>\n" );
@@ -948,7 +982,7 @@
$row .= '<span class="history-deleted">'.$url.'</span>';
} else {
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
- $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) );
+ $row .= Xml::element( 'a', array( 'href' => wfReplaceImageServer( $url, $timestamp ) ), $wgLang->timeAndDate( $timestamp, true ) );
}
$row .= "</td>";