Index: includes/ImageGallery.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/ImageGallery.php,v
retrieving revision 1.19
diff -u -r1.19 ImageGallery.php
--- includes/ImageGallery.php	16 Apr 2005 04:33:34 -0000	1.19
+++ includes/ImageGallery.php	24 May 2005 15:01:16 -0000
@@ -88,11 +88,49 @@
 	 *
 	 */
 	function toHTML() {
-		global $wgLang, $wgContLang, $wgUser;
+		global $wgLang, $wgContLang, $wgUser, $wgThumbLimits;
 
 		$sk = $wgUser->getSkin();
 
-		$s = '<table class="gallery" cellspacing="0" cellpadding="0">';
+		# The result string
+		$s = "";
+
+		# Use a <table> tag or some <div> 
+		$galleryUseTable = ($wgUser->getOption( 'gallerytableless' )) == false;
+
+		# Get some user options
+		$galleryCols = 4;
+		$thumbSize = 120;
+
+		# Number of columns
+		if( $wgUser->getOption( 'gallerycols' ) == '' ) {
+			$galleryCols = 4;
+		} else {
+			$galleryCols = IntVal( $wgUser->getOption( 'gallerycols' ) );
+		}
+
+		# Size of thumbnail inside the gallery
+		if( $wgUser->getOption( 'gallerythumbsize' ) == '' ) {
+			$thumbSize = 120;
+		} else {
+			$thumbSize = $wgThumbLimits[IntVal( $wgUser->getOption( 'gallerythumbsize' ) )];
+		}
+		$thumbBox = $thumbSize + 32;
+
+		# This is not displayed by default (accessibility)
+		$s .= '<span class="gallerylabel">' . wfMsg( 'gallery' ) . '</span>' . "\n";
+
+		# This prevent overlapping from other floating thumb and is not visible by default
+		$s .= '<hr class="galleryspacer" />' . "\n";
+
+		if($galleryUseTable) {
+			$s .= '<table class="gallery" cellspacing="0" cellpadding="0">' . "\n";
+		} else {
+			# compute the width of the parent div
+			$tabWidth = floor((8.5 * $galleryCols ) + ($galleryCols * ($thumbBox)));
+			$s .= '<div class="gallery" style="width:'.$tabWidth.'px;">' . "\n";
+		}
+
 		$i = 0;
 		foreach ( $this->mImages as $pair ) {
 			$img =& $pair[0];
@@ -103,8 +141,16 @@
 
 			// Not an image. Just print the name and skip.
 			if ( $nt->getNamespace() != NS_IMAGE ) {
-				$s .= '<td><div class="gallerybox" style="height: 152px;">' .
-					htmlspecialchars( $nt->getText() ) . '</div></td>' .  (($i%4==3) ? "</tr>\n" : '');
+
+				$s .= ($galleryUseTable) ? '<td>' : '';
+				$s .= "<div class=\"gallerybox\" " .
+					"style=\"height: {$thumbSize}px; width: {$thumbSize}px;\" >".
+					htmlspecialchars( $nt->getText() ) . '</div>';
+				$s .= ($galleryUseTable) ? '</td>' : '';
+
+				if ($i % $galleryCols == $galleryCols - 1) {
+					$s .= (($galleryUseTable) ? "</tr>" : '<br clear="all" />');
+				}
 				$i++;
 
 				continue;
@@ -123,38 +169,61 @@
 			} else {
 				$nb = '';
 			}
-				
+
 			$textlink = $this->mShowFilename ?
-				$sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "<br />\n" :
+				$sk->makeKnownLinkObj( $nt, htmlspecialchars( 
+					$wgLang->truncate( $nt->getText(), 20, '...' ) ) ) 
+					. "<br />\n" :
 				'' ;
 
-			$s .= ($i%4==0) ? '<tr>' : '';
-			$thumb = $img->getThumbnail( 120, 120 );
-			$vpad = floor( ( 150 - $thumb->height ) /2 ) - 2;
-			$s .= '<td><div class="gallerybox">' . '<div class="thumb" style="padding: ' . $vpad . 'px 0;">';
-			
+			if ($galleryUseTable && ($i % $galleryCols == 0))
+				$s .= '<tr>';
+			$thumb = $img->getThumbnail( $thumbSize, $thumbSize );
+			$tpad = floor( ( ($thumbSize + 30) - $thumb->height ) /2 ) - 2;
+			$rpad = floor( ( ($thumbSize + 30) - $thumb->width ) /2 ) - 2;
+			# add the missing pixel if dimensions are odd 
+			$bpad = ($thumb->height % 2 == 1) ? $tpad + 1 : $tpad;
+			$lpad = ($thumb->height % 2 == 1) ? $rpad + 1 : $rpad;
+
+			$s .= ($galleryUseTable) ? "<td>" : "";
+			$s .= "<div class=\"gallerybox\" style=\"width: {$thumbBox}px; \">" .
+					'<div class="thumb" style="padding: ' . 
+					$tpad . 'px '. $rpad . 'px ' . $bpad .'px ' . $lpad . 'px;">' ;
+
 			# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
 			# in version 4.8.6 generated crackpot html in its absence, see:
 			# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765
 			$s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '</div><div class="gallerytext">' . "\n" .
-				$textlink . $text . $nb .
-				'</div>';
-			$s .= "</div></td>\n";
-			$s .= ($i%4==3) ? '</tr>' : '';
+				$textlink . $text . $nb . '</div>';
+			$s .= "</div>";
+			$s .= ($galleryUseTable ? "</td>" : "");
+
+			if ($i % $galleryCols == $galleryCols -1)
+				{
+					if ($galleryUseTable)
+						$s .= '</tr>' ;
+					else
+						$s .= '<div class="galleryspacer">&nbsp;</div>';
+				}
 			$i++;
 		}
-		if( $i %4 != 0 ) {
-			$s .= "</tr>\n";
+
+		if ($galleryUseTable) {
+			if( $i % $galleryCols != 0 ) {
+				$s .= "</tr>";
+			}
+			$s .= '</table>';
+		}
+		else {
+			# This adjust the parent box arround the boxes
+			$s .= "\n" . '<hr class="galleryspacer" />'; 
+			$s .= "\n" . '</div>';
 		}
-		$s .= '</table>';
 
 		return $s;
 	}
 
 } //class
 
-
-
-
 } // defined( 'MEDIAWIKI' )
-?>
+?>
\ No newline at end of file
Index: includes/SpecialPreferences.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/SpecialPreferences.php,v
retrieving revision 1.112
diff -u -r1.112 SpecialPreferences.php
--- includes/SpecialPreferences.php	14 May 2005 17:55:04 -0000	1.112
+++ includes/SpecialPreferences.php	24 May 2005 15:01:17 -0000
@@ -32,7 +32,8 @@
 	var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
 	var $mUserLanguage, $mUserVariant;
 	var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
-	var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
+	var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
+	var $mImageSize, $mThumbSize, $mGalleryThumbSize, $mGalleryCols, $mGalleryTableless;
 
 	/**
 	 * Constructor
@@ -64,6 +65,9 @@
 		$this->mSearchChars = $request->getVal( 'wpSearchChars' );
 		$this->mImageSize = $request->getVal( 'wpImageSize' );
 		$this->mThumbSize = $request->getInt( 'wpThumbSize' );
+		$this->mGalleryThumbSize = $request->getInt( 'wpGalleryThumbSize' );
+		$this->mGalleryCols = $request->getInt( 'wpGalleryCols' ) ;
+		$this->mGalleryTableless = $request->getInt( 'wpGalleryTableless' ) ;
 		$this->mAction = $request->getVal( 'action' );
 		$this->mReset = $request->getCheck( 'wpReset' );
 		$this->mPosted = $request->wasPosted();
@@ -219,6 +223,9 @@
 		$wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
 		$wgUser->setOption( 'imagesize', $this->mImageSize );
 		$wgUser->setOption( 'thumbsize', $this->mThumbSize );
+		$wgUser->setOption( 'gallerythumbsize', $this->mGalleryThumbSize );
+		$wgUser->setOption( 'gallerycols', $this->validateIntOrNull( $this->mGalleryCols, 1, 20 ) );
+		$wgUser->setOption( 'gallerytableless', $this->validateIntOrNull( $this->mGalleryTableless, 0, 1 ) );
 
 		# Set search namespace options
 		foreach( $this->mSearchNs as $i => $value ) {
@@ -304,6 +311,9 @@
 		$this->mSearchChars = $wgUser->getOption( 'contextchars' );
 		$this->mImageSize = $wgUser->getOption( 'imagesize' );
 		$this->mThumbSize = $wgUser->getOption( 'thumbsize' );
+		$this->mGalleryCols = $wgUser->getOption( 'gallerycols' );
+		$this->mGalleryThumbSize = $wgUser->getOption( 'gallerythumbsize' );
+		$this->mGalleryTableless = $wgUser->getOption( 'gallerytableless' );
 		$this->mRecent = $wgUser->getOption( 'rclimit' );
 
 		$togs = $wgLang->getUserToggles();
@@ -627,7 +637,41 @@
 				$selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
 				$imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
 			}
-			$wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
+			$wgOut->addHTML( "{$imageThumbOptions}</select></label></div>");
+
+			# Size of the gallery thumbs
+			$imageGalleryThumbOptions = null;
+			$wgOut->addHTML( "<div><label>" . wfMsg('gallerythumbsize') . 
+					 " <select name=\"wpGalleryThumbSize\">");
+			foreach ( $wgThumbLimits as $index => $size ) {
+				$selected = ($index == $this->mGalleryThumbSize) ? 'selected="selected"' : '';
+				$imageGalleryThumbOptions .= 	"<option value=\"{$index}\" " .
+								"{$selected}>{$size}px</option>\n";
+			}
+			$wgOut->addHTML( "{$imageGalleryThumbOptions}</select></label></div>");
+
+			# Should gallery use a <table> tag or some <div> tags (tableless)
+			$galleryTablelessChecked = ($this->mGalleryTableless) ? "CHECKED " : '';
+			$wgOut->addHTML( "<div>	<label>" .
+					 "<input type='checkbox'  name='wpGalleryTableless' ".
+					 "value=\"1\" {$galleryTablelessChecked} /> " . 
+					 wfMsg( 'gallerytableless' ) .
+					 "</label>
+			</div>" );
+
+			# how many columns should we display ? between 1 and 20
+			$colnumber = ( $this->mGalleryCols == "") ? 4 : $this->mGalleryCols;
+			$wgOut->addHTML( "<div>	<label>" .
+					 "<input type='text' name='wpGalleryCols' ".
+					 "value=\"$colnumber\" size='3' /> ". 
+					 wfMsg( 'gallerycols' ) .
+					 "</label>
+			</div>" );
+			
+			# Close fieldset
+			$wgOut->addHTML("</fieldset>\n\n");
+
+
 
                 # Date format
                 #
Index: includes/User.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/User.php,v
retrieving revision 1.147
diff -u -r1.147 User.php
--- includes/User.php	24 May 2005 04:28:00 -0000	1.147
+++ includes/User.php	24 May 2005 15:01:20 -0000
@@ -1220,6 +1220,9 @@
 		$confstr .= '!' . $this->getOption( 'numberheadings' );
 		$confstr .= '!' . $this->getOption( 'language' );
 		$confstr .= '!' . $this->getOption( 'thumbsize' );
+		$confstr .= '!' . $this->getOption( 'gallerycols' );
+		$confstr .= '!' . $this->getOption( 'gallerythumbsize' );
+		$confstr .= '!' . $this->getOption( 'gallerytableless' );
 		// add in language specific options, if any
 		$extra = $wgContLang->getExtraHashOptions();
 		$confstr .= $extra;
Index: skins/monobook/main.css
===================================================================
RCS file: /cvsroot/wikipedia/phase3/skins/monobook/main.css,v
retrieving revision 1.38
diff -u -r1.38 main.css
--- skins/monobook/main.css	8 May 2005 16:18:16 -0000	1.38
+++ skins/monobook/main.css	24 May 2005 15:01:21 -0000
@@ -1020,7 +1020,7 @@
     background-color: #c5ffe6;
 }
 
-table.gallery {
+table.gallery, div.gallery {
     border: 1px solid #ccc;
     margin: 2px;
     padding: 2px;
@@ -1037,6 +1037,27 @@
     border: solid 2px white;
 }
 
+div.gallery {
+    vertical-align: top;
+}
+
+.gallerylabel {
+    display: none;
+}
+
+.galleryspacer {
+    clear: both; 
+    font-size: xx-small; 
+    visibility: hidden;
+}
+
+div.gallery div.gallerybox {
+    float: left;
+    vertical-align: top;
+    background-color: #f9f9f9;
+    border: solid 2px white;
+}
+
 div.gallerybox {
     margin: 2px;
     width:  150px;
Index: languages/Language.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/languages/Language.php,v
retrieving revision 1.552
diff -u -r1.552 Language.php
--- languages/Language.php	23 May 2005 23:25:43 -0000	1.552
+++ languages/Language.php	24 May 2005 15:01:28 -0000
@@ -1775,6 +1775,12 @@
 'thumbsize'	=> 'Thumbnail size : ',
 'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)',
 
+# gallery options
+'gallerythumbsize' => 'Gallery thumbnail size :',
+'gallerytableless' => 'Gallery tableless layout',
+'gallerycols' => 'column(s) in the gallery (between 1 and 20)',
+'gallery' => 'Gallery',
+
 'newimages' => 'New images gallery',
 'noimages'  => 'Nothing to see.',
 
