1014 fix from REL1_4
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 6 Dec 2004 14:51:18 +0000 (14:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 6 Dec 2004 14:51:18 +0000 (14:51 +0000)
includes/Image.php
includes/ImagePage.php
includes/User.php

index 52bca6e..654048e 100644 (file)
@@ -191,7 +191,11 @@ class Image
        function getSize()
        {
                $st = stat( $this->getImagePath() );
-               return $st['size'];
+               if( $st ) {
+                       return $st['size'];
+               } else {
+                       return false;
+               }
        }
 
        /**
@@ -554,7 +558,8 @@ class Image
        function getFullPath( $fromSharedRepository = false )
        {
                global $wgUploadDirectory, $wgSharedUploadDirectory;
-       
+               global $wgHashedUploadDirectory, $wgHashedSharedUploadDirectory;
+               
                $dir      = $fromSharedRepository ? $wgSharedUploadDirectory :
                                                    $wgUploadDirectory;
                $ishashed = $fromSharedRepository ? $wgHashedSharedUploadDirectory : 
index 0a28e55..6b52070 100644 (file)
@@ -46,8 +46,16 @@ class ImagePage extends Article {
                $url  = $this->img->getViewURL();
                $anchoropen = '';
                $anchorclose = '';
-               if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) {
-                       $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ];
+               if ( $wgUseImageResize ) {
+                       if( $wgUser->getOption( 'imagesize' ) == '' ) {
+                               $sizeSel = User::getDefaultOption( 'imagesize' );
+                       } else {
+                               $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
+                       }
+                       if( !isset( $wgImageLimits[$sizeSel] ) ) {
+                               $sizeSel = User::getDefaultOption( 'imagesize' );
+                       }
+                       $max = $wgImageLimits[$sizeSel];
                        $maxWidth = $max[0];
                        $maxHeight = $max[1];
                }
index d9aa940..90b2dfe 100644 (file)
@@ -177,9 +177,18 @@ class User {
         * a language object.
         */     
        function loadDefaultFromLanguage(){
-               $fname = 'User::loadDefaultFromLanguage';
-               wfProfileIn( $fname );
-               
+               $this->mOptions = User::getDefaultOptions();
+       }
+       
+       /**
+        * Combine the language default options with any site-specific options
+        * and add the default language variants.
+        *
+        * @return array
+        * @static
+        * @access private
+        */
+       function getDefaultOptions() {
                /**
                 * Site defaults will override the global/language defaults
                 */
@@ -193,9 +202,24 @@ class User {
                $defOpt['variant'] = $variant;
                $defOpt['language'] = $variant;
                
-               $this->mOptions = $defOpt;
-               
-               wfProfileOut();
+               return $defOpt;
+       }
+       
+       /**
+        * Get a given default option value.
+        *
+        * @param string $opt
+        * @return string
+        * @static
+        * @access public
+        */
+       function getDefaultOption( $opt ) {
+               $defOpts = User::getDefaultOptions();
+               if( isset( $defOpts[$opt] ) ) {
+                       return $defOpts[$opt];
+               } else {
+                       return '';
+               }
        }
 
        /**