* A new tab in the preferencesc called 'File' for any current and future
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 12 Apr 2005 00:37:45 +0000 (00:37 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 12 Apr 2005 00:37:45 +0000 (00:37 +0000)
  file-related options, moving the images description limit there (from misc)
* (bug 1221) image thumbnail sizes are now a user preference (in the 'Files' tab)

includes/DefaultSettings.php
includes/Linker.php
includes/SpecialPreferences.php
languages/Language.php

index 61a72aa..d7c2d6a 100644 (file)
@@ -1070,6 +1070,19 @@ $wgImageLimits = array (
        array(1280,1024),
        array(10000,10000) );
 
+/**
+ * Adjust thumbnails on image pages according to a user setting. In order to
+ * reduce disk usage, the values can only be selected from a list. This is the
+ * list of settings the user can choose from:
+ */
+$wgThumbLimits = array(
+       120,
+       150,
+       180,
+       200,
+       250,
+       300
+);
 
 /** Navigation links for the user sidebar.
  * 'text' is the name of the MediaWiki message that contains the label of this link
index 84dc09a..a5c7a2b 100644 (file)
@@ -415,6 +415,8 @@ class Linker {
        /** @todo document */
        function makeImageLinkObj( $nt, $alt = '' ) {
                global $wgContLang, $wgUseImageResize;
+               global $wgUser, $wgThumbLimits;
+               
                $img   = new Image( $nt );
                $url   = $img->getViewURL();
 
@@ -495,13 +497,22 @@ class Linker {
                        # for right-to-left-languages ("Semitic languages")
                        #
                        # If  thumbnail width has not been provided, it is set
-                       # here to 180 pixels
+                       # to the default user option as specified in Language*.php
                        if ( $align == '' ) {
                                $align = $wgContLang->isRTL() ? 'left' : 'right';
                        }
+
+                       
                        if ( ! isset($width) ) {
-                               $width = 180;
+                               $wopt = $wgUser->getOption( 'thumbsize' );
+
+                               if( !isset( $wgThumbLimits[$wopt] ) ) {
+                                        $wopt = User::getDefaultOption( 'thumbsize' );
+                               }
+                               
+                               $width = $wgThumbLimits[$wopt];
                        }
+                       
                        return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
 
                } elseif ( isset($width) ) {
index 0c1fd47..d4e6722 100644 (file)
@@ -56,13 +56,14 @@ class PreferencesForm {
                $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
                $this->mNick = $request->getVal( 'wpNick' );
                $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
-        $this->mUserVariant = $request->getVal( 'wpUserVariant' );
+               $this->mUserVariant = $request->getVal( 'wpUserVariant' );
                $this->mSearch = $request->getVal( 'wpSearch' );
                $this->mRecent = $request->getVal( 'wpRecent' );
                $this->mHourDiff = $request->getVal( 'wpHourDiff' );
                $this->mSearchLines = $request->getVal( 'wpSearchLines' );
                $this->mSearchChars = $request->getVal( 'wpSearchChars' );
                $this->mImageSize = $request->getVal( 'wpImageSize' );
+               $this->mThumbSize = $request->getInt( 'wpThumbSize' );
 
                $this->mAction = $request->getVal( 'action' );
                $this->mReset = $request->getCheck( 'wpReset' );
@@ -218,6 +219,7 @@ class PreferencesForm {
                $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
                $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
                $wgUser->setOption( 'imagesize', $this->mImageSize );
+               $wgUser->setOption( 'thumbsize', $this->mThumbSize );
 
                # Set search namespace options
                foreach( $this->mSearchNs as $i => $value ) {
@@ -304,6 +306,7 @@ class PreferencesForm {
                $this->mSearchLines = $wgUser->getOption( 'contextlines' );
                $this->mSearchChars = $wgUser->getOption( 'contextchars' );
                $this->mImageSize = $wgUser->getOption( 'imagesize' );
+               $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
                $this->mRecent = $wgUser->getOption( 'rclimit' );
 
                $togs = $wgLang->getUserToggles();
@@ -375,7 +378,7 @@ class PreferencesForm {
         */
        function mainPrefsForm( $err ) {
                global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
-               global $wgAllowRealName, $wgImageLimits;
+               global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
                global $wgLanguageNames, $wgDisableLangConversion;
                global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
                global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
@@ -408,6 +411,7 @@ class PreferencesForm {
                $cp = wfMsg( 'changepassword' );
                $sk = wfMsg( 'skin' );
                $math = wfMsg( 'math' );
+               $files = wfMsg( 'files' );
                $dateFormat = wfMsg('dateformat');
                $opw = wfMsg( 'oldpassword' );
                $npw = wfMsg( 'newpassword' );
@@ -607,7 +611,28 @@ class PreferencesForm {
        value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
                }
                $wgOut->addHTML( "</fieldset>\n\n" );
-               
+
+               # Files
+               #
+               $wgOut->addHTML("<fieldset>
+                       <legend>$files</legend>
+                       <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
+                       
+                       $imageLimitOptions = null;
+                       foreach ( $wgImageLimits as $index => $limits ) {
+                               $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
+                               $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
+                       }
+                       
+                       $imageThumbOptions = null;
+                       $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
+                               <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
+                       foreach ( $wgThumbLimits as $index => $size ) {
+                               $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
+                               $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
+                       }
+                       $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
+
                 # Date format
                 #
                if ($dateopts) {
@@ -680,16 +705,6 @@ class PreferencesForm {
                #
                $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
 
-               $wgOut->addHTML( '<div><label>' . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
-
-               $imageLimitOptions='';
-               foreach ( $wgImageLimits as $index => $limits ) {
-                       $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
-                       $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
-               }
-               $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>" );
-
-
                foreach ( $togs as $tname ) {
                        if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
                                $wgOut->addHTML( $this->getToggle( $tname ) );
index ffa1990..e80981c 100644 (file)
@@ -76,6 +76,7 @@ if(isset($wgExtraNamespaces)) {
        'showtoolbar'           => 1,
        'date'                  => 0,
        'imagesize'             => 2,
+       'thumbsize'             => 2,
        'rememberpassword'      => 0,
        'enotifwatchlistpages'  => 1,
        'enotifusertalkpages'   => 1,
@@ -853,7 +854,7 @@ See [[Project:User preferences help]] for help deciphering the options.",
 'changepassword' => 'Change password',
 'skin'                 => 'Skin',
 'math'                 => 'Math',
-'dateformat'   => 'Date format',
+'dateformat'           => 'Date format',
 'math_failure'         => 'Failed to parse',
 'math_unknown_error'   => 'unknown error',
 'math_unknown_function'        => 'unknown function ',
@@ -891,6 +892,7 @@ from server time (UTC).',
 'emailflag'            => 'Disable e-mail from other users',
 'defaultns'            => 'Search in these namespaces by default:',
 'default'              => 'default',
+'files'                        => 'Files',
 
 # User levels special page
 #
@@ -1776,6 +1778,7 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');
 'nextdiff' => 'Next diff →',
 
 'imagemaxsize' => 'Limit images on image description pages to: ',
+'thumbsize'    => 'Thumbnail size : ',
 'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)',
 
 'newimages' => 'New images gallery',