* Fixed a typo that caused warnings
[lhc/web/wiklou.git] / includes / Linker.php
index 47a66dc..3f35d9c 100644 (file)
@@ -20,7 +20,7 @@ class Linker {
        function Linker() {}
 
        /**
-        * OBSOLETE
+        * @deprecated
         */
        function postParseLinkColour( $s = NULL ) {
                return NULL;
@@ -130,7 +130,7 @@ class Linker {
        /**
         * Pass a title object, not a title string
         */
-       function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
+       function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
                global $wgOut, $wgUser;
                $fname = 'Linker::makeLinkObj';
                wfProfileIn( $fname );
@@ -368,7 +368,7 @@ class Linker {
        }
 
        /** @todo document */
-       function makeImageLinkObj( &$nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, 
+       function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, 
          $thumb = false, $manual_thumb = '' ) 
        {
                global $wgContLang, $wgUser, $wgThumbLimits;
@@ -377,6 +377,8 @@ class Linker {
                $url   = $img->getViewURL();
                $prefix = $postfix = '';
                
+               wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
+               
                if ( 'center' == $align )
                {
                        $prefix  = '<div class="center">';
@@ -421,13 +423,24 @@ class Linker {
                        if ( $manual_thumb == '') {
                                $thumb = $img->getThumbnail( $width );
                                if ( $thumb ) {
-                                       // $height = $thumb->height;
-                                       $height = floor($thumb->height * $width / $img->width);
-                                       $url = $thumb->getUrl( );
+                                       if( $width > $thumb->width ) {
+                                               // Requested a display size larger than the actual image;
+                                               // fake it up!
+                                               $height = floor($thumb->height * $width / $thumb->width);
+                                               wfDebug( "makeImageLinkObj: client-size height set to '$height'\n" );
+                                       } else {
+                                               $height = $thumb->height;
+                                               wfDebug( "makeImageLinkObj: thumb height set to '$height'\n" );
+                                       }
+                                       $url = $thumb->getUrl();
                                }
                        }
+               } else {
+                       $width = $img->width;
+                       $height = $img->height;
                }
 
+               wfDebug( "makeImageLinkObj2: '$width'x'$height'\n" );
                $u = $nt->escapeLocalURL();
                if ( $url == '' ) {
                        $s = $this->makeBrokenImageLinkObj( $img->getTitle() );
@@ -476,7 +489,7 @@ class Linker {
                        $boxheight = $height;
                        $thumbUrl  = $url;
                } else {
-                       $h  = intval( $height/($width/$boxwidth) );
+                       $h  = round( $height/($width/$boxwidth) );
                        $oboxwidth = $boxwidth + 2;
                        if ( ( ! $boxheight === false ) &&  ( $h > $boxheight ) )
                        {
@@ -510,7 +523,7 @@ class Linker {
 
                $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
                if ( $thumbUrl == '' ) {
-                       $s .= $this->makeBrokenImageLinkObj( $img->getTitle );
+                       $s .= $this->makeBrokenImageLinkObj( $img->getTitle() );
                        $zoomicon = '';
                } else {
                        $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
@@ -533,7 +546,7 @@ class Linker {
        /**
         * Pass a title object, not a title string
         */
-       function makeBrokenImageLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+       function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                # Fail gracefully
                if ( ! isset($nt) ) {
                        # wfDebugDieBacktrace();