Fix extra space from r64084
[lhc/web/wiklou.git] / includes / Linker.php
index 27be479..c049f47 100644 (file)
@@ -468,7 +468,7 @@ class Linker {
                if ( $file && !isset( $hp['width'] ) ) {
                        $hp['width'] = $file->getWidth( $page );
 
-                       if( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
+                       if( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) ) {
                                $wopt = $wgUser->getOption( 'thumbsize' );
 
                                if( !isset( $wgThumbLimits[$wopt] ) ) {
@@ -485,7 +485,9 @@ class Linker {
                                        round( $wgThumbLimits[$wopt] * $fp['upright'], -1 ) :
                                        $wgThumbLimits[$wopt];
                                if ( $hp['width'] <= 0 || $prefWidth < $hp['width'] ) {
-                                       $hp['width'] = $prefWidth;
+                                       if( !isset( $hp['height'] ) ) {
+                                               $hp['width'] = $prefWidth;
+                                       }
                                }
                        }
                }
@@ -521,7 +523,7 @@ class Linker {
                }
 
                if ( !$thumb ) {
-                       $s = $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
+                       $s = $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time==true );
                } else {
                        $params = array(
                                'alt' => $fp['alt'],
@@ -629,7 +631,7 @@ class Linker {
 
                $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
                if( !$exists ) {
-                       $s .= $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
+                       $s .= $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time==true );
                        $zoomicon = '';
                } elseif ( !$thumb ) {
                        $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) );
@@ -679,17 +681,9 @@ class Linker {
                                        wfProfileOut( __METHOD__ );
                                        return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
                                }
+                               
+                               $href = $this->getUploadUrl( $title, $query );
 
-                               $q = 'wpDestFile=' . $title->getPartialUrl();
-                               if( $query != '' )
-                                       $q .= '&' . $query;
-
-                               if( $wgUploadNavigationUrl ) {
-                                       $href = wfAppendQuery( $wgUploadNavigationUrl, $q );
-                               } else {
-                                       $upload = SpecialPage::getTitleFor( 'Upload' );
-                                       $href = $upload->getLocalUrl( $q );
-                               }
 
                                list( $inside, $trail ) = self::splitTrail( $trail );
 
@@ -707,6 +701,27 @@ class Linker {
                        return "<!-- ERROR -->{$prefix}{$text}{$trail}";
                }
        }
+       
+       /**
+        * Get the URL to upload a certain file
+        * 
+        * @param $destFile Title Title of the file to upload
+        * @param $query string Urlencoded query string to prepend
+        * @return string Urlencoded URL
+        */
+       protected function getUploadUrl( $destFile, $query = '' ) {
+               global $wgUploadNavigationUrl;
+               $q = 'wpDestFile=' . $destFile->getPartialUrl();
+               if( $query != '' )
+                       $q .= '&' . $query;
+
+               if( $wgUploadNavigationUrl ) {
+                       return wfAppendQuery( $wgUploadNavigationUrl, $q );
+               } else {
+                       $upload = SpecialPage::getTitleFor( 'Upload' );
+                       return $upload->getLocalUrl( $q );
+               }       
+       }
 
        /**
         * Create a direct link to a given uploaded file.
@@ -729,7 +744,8 @@ class Linker {
                                $url  = $img->getURL();
                                $class = 'internal';
                        } else {
-                               return $this->makeBrokenImageLinkObj( $title, $text, '', '', '', '', $time==true );
+                               $url = $this->getUploadUrl( $title );
+                               $class = 'new';
                        }
                        $alt = htmlspecialchars( $title->getText() );
                        if( $text == '' ) {
@@ -954,7 +970,7 @@ class Linker {
                $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
 
                # Render autocomments and make links:
-               $comment = $this->formatAutoComments( $comment, $title, $local );
+               $comment = $this->formatAutocomments( $comment, $title, $local );
                $comment = $this->formatLinksInComment( $comment, $title, $local );
 
                wfProfileOut( __METHOD__ );
@@ -991,11 +1007,11 @@ class Linker {
                $title = $this->autocommentTitle;
                $local = $this->autocommentLocal;
 
-               $pre=$match[1];
-               $auto=$match[2];
-               $post=$match[3];
-               $link='';
-               if( $title ) {
+               $pre = $match[1];
+               $auto = $match[2];
+               $post = $match[3];
+               $link = '';
+               if ( $title ) {
                        $section = $auto;
 
                        # Generate a valid anchor name from the section title.
@@ -2005,7 +2021,7 @@ class Linker {
        public function tooltipAndAccesskeyAttribs( $name ) {
                global $wgEnableTooltipsAndAccesskeys;
                if ( !$wgEnableTooltipsAndAccesskeys )
-                       return '';
+                       return array();
                # FIXME: If Sanitizer::expandAttributes() treated "false" as "output
                # no attribute" instead of "output '' as value for attribute", this
                # would be three lines.