Index: extensions/TweetThis/admin.tpl
===================================================================
--- extensions/TweetThis/admin.tpl	(revision 11504)
+++ extensions/TweetThis/admin.tpl	(revision 11514)
@@ -6,79 +6,92 @@
 
 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 
-	<fieldset>
-		<legend>{'Configuration'|@translate}</legend>	  
-    
-    <ul>
-      <li>
+
+    <table class="twitter_buttons">
+      <tr>
+        <td><label>
+          <img src="{$TWEET_PATH}images/tweeth.png"/>
+          <input type="radio" name="button_style" value="horizontal" {if $button_style == 'horizontal'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="{$TWEET_PATH}images/tweetv.png"/>
+          <input type="radio" name="button_style" value="vertical" {if $button_style == 'vertical'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="{$TWEET_PATH}images/tweetn.png"/>
+          <input type="radio" name="button_style" value="none" {if $button_style == 'none'}checked="checked"{/if}/>
+        </label></td>
+        <td>&nbsp;</td>
+      </tr>
+      <tr>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/twitter-a.png"/>
+          <input type="radio" name="button_style" value="twitter-a" {if $button_style == 'twitter-a'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_logo-a.png"/>
+          <input type="radio" name="button_style" value="t_logo-a" {if $button_style == 't_logo-a'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_small-a.png"/>
+          <input type="radio" name="button_style" value="t_small-a" {if $button_style == 't_small-a'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_mini-a.png"/>
+          <input type="radio" name="button_style" value="t_mini-a" {if $button_style == 't_mini-a'}checked="checked"{/if}/>
+        </label></td>
+      </tr>
+      <tr>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/twitter-b.png"/>
+          <input type="radio" name="button_style" value="twitter-b" {if $button_style == 'twitter-b'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_logo-b.png"/>
+          <input type="radio" name="button_style" value="t_logo-b" {if $button_style == 't_logo-b'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_small-b.png"/>
+          <input type="radio" name="button_style" value="t_small-b" {if $button_style == 't_small-b'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_mini-b.png"/>
+          <input type="radio" name="button_style" value="t_mini-b" {if $button_style == 't_mini-b'}checked="checked"{/if}/>
+        </label></td>
+      </tr>
+      <tr>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/twitter-c.png"/>
+          <input type="radio" name="button_style" value="twitter-c" {if $button_style == 'twitter-c'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_logo-c.png"/>
+          <input type="radio" name="button_style" value="t_logo-c" {if $button_style == 't_logo-c'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_small-c.png"/>
+          <input type="radio" name="button_style" value="t_small-c" {if $button_style == 't_small-c'}checked="checked"{/if}/>
+        </label></td>
+        <td><label>
+          <img src="http://twitter-badges.s3.amazonaws.com/t_mini-c.png"/>
+          <input type="radio" name="button_style" value="t_mini-c" {if $button_style == 't_mini-c'}checked="checked"{/if}/>
+        </label></td>
+      </tr>
       
-      <table class="twitter_buttons">
-        <tr>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/twitter-a.png"/>
-            <input type="radio" name="button_style" value="twitter-a" {if $button_style == 'twitter-a'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_logo-a.png"/>
-            <input type="radio" name="button_style" value="t_logo-a" {if $button_style == 't_logo-a'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_small-a.png"/>
-            <input type="radio" name="button_style" value="t_small-a" {if $button_style == 't_small-a'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_mini-a.png"/>
-            <input type="radio" name="button_style" value="t_mini-a" {if $button_style == 't_mini-a'}checked="checked"{/if}/>
-          </label></td>
-        </tr>
-        <tr>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/twitter-b.png"/>
-            <input type="radio" name="button_style" value="twitter-b" {if $button_style == 'twitter-b'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_logo-b.png"/>
-            <input type="radio" name="button_style" value="t_logo-b" {if $button_style == 't_logo-b'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_small-b.png"/>
-            <input type="radio" name="button_style" value="t_small-b" {if $button_style == 't_small-b'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_mini-b.png"/>
-            <input type="radio" name="button_style" value="t_mini-b" {if $button_style == 't_mini-b'}checked="checked"{/if}/>
-          </label></td>
-        </tr>
-        <tr>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/twitter-c.png"/>
-            <input type="radio" name="button_style" value="twitter-c" {if $button_style == 'twitter-c'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_logo-c.png"/>
-            <input type="radio" name="button_style" value="t_logo-c" {if $button_style == 't_logo-c'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_small-c.png"/>
-            <input type="radio" name="button_style" value="t_small-c" {if $button_style == 't_small-c'}checked="checked"{/if}/>
-          </label></td>
-          <td><label>
-            <img src="http://twitter-badges.s3.amazonaws.com/t_mini-c.png"/>
-            <input type="radio" name="button_style" value="t_mini-c" {if $button_style == 't_mini-c'}checked="checked"{/if}/>
-          </label></td>
-        </tr>
-      </table>
-      
-    </li>
-    
-    <li>
-      <span class="property">{'Button position on picture page'|@translate}</span>
-      <label><input type="radio" name="position" value="top" {if $position == 'top'}checked="checked"{/if}/> {'Top'|@translate}</label>
-      <label><input type="radio" name="position" value="bottom" {if $position == 'bottom'}checked="checked"{/if}/> {'Bottom'|@translate}</label>
-      <label><input type="radio" name="position" value="toolbar" {if $position == 'toolbar'}checked="checked"{/if}/> {'Toolbar'|@translate}</label>
-    </li>
-  </ul>
-  
-	</fieldset>
-		
-	<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
+      <tr class="property">
+        <td colspan="2">
+          {'Button position on picture page'|@translate}
+        </td>
+        <td colspan="2">
+          <label><input type="radio" name="position" value="top" {if $position == 'top'}checked="checked"{/if}/> {'Top'|@translate}</label>
+          <label><input type="radio" name="position" value="bottom" {if $position == 'bottom'}checked="checked"{/if}/> {'Bottom'|@translate}</label>
+          <label><input type="radio" name="position" value="toolbar" {if $position == 'toolbar'}checked="checked"{/if}/> {'Toolbar'|@translate}</label>
+        </td>
+      </tr>
+      <tr class="submit">
+        <td colspan="4">
+          <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" />
+        </td>
+      </tr>
+    </table>
+
 </form>
Index: extensions/TweetThis/images/index.php
===================================================================
--- extensions/TweetThis/images/index.php	(revision 11514)
+++ extensions/TweetThis/images/index.php	(revision 11514)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery                                    |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: extensions/TweetThis/main.inc.php
===================================================================
--- extensions/TweetThis/main.inc.php	(revision 11504)
+++ extensions/TweetThis/main.inc.php	(revision 11514)
@@ -41,4 +41,32 @@
     $template->set_prefilter('index', 'tweet_add_button_prefilter');
   }
+  
+  // html change a bit if we use custom button, or official with counter
+  if ( in_array( $conf['TweetThis'][0], array('none','horizontal','vertical') ) )
+  {
+    $template->assign('TWEET_IFRAME', true);
+    $template->assign('TWEET_COUNTER', $conf['TweetThis'][0]);
+  }
+  else
+  {
+    $template->assign('TWEET_IFRAME', false);
+    $template->assign('TWEET_COUNTER', 'none');
+  }
+  
+  // if the link is in the toolbar, we must use smallest buttons
+  if ( script_basename() == 'index' OR  $conf['TweetThis'][1] == 'toolbar')
+  {
+    switch ($conf['TweetThis'][0])
+    {
+      case 'vertical':
+        $template->assign('TWEET_COUNTER', 'horizontal'); break;
+      case 't_logo-a':
+        $template->assign('TWEET_IMAGE', 't_small-a'); break; 
+      case 't_logo-b':
+        $template->assign('TWEET_IMAGE', 't_small-b'); break; 
+      case 't_logo-c':
+        $template->assign('TWEET_IMAGE', 't_small-c'); break;
+    }
+  }
 }
 
@@ -52,7 +80,8 @@
       $search = '<div id="theImage">';
       $replace = '
-<a href="http://twitter.com/share" class="twitter-share-button" title="{\'Share on Twitter\'|@translate}" style="display:block;">
-  <img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>
-</a>
+<div><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 
+        class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}">
+  {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
+</a></div>
 ';
       break;
@@ -61,6 +90,7 @@
       $search = '{$ELEMENT_CONTENT}';
       $replace = '
-<a href="http://twitter.com/share" class="twitter-share-button" title="{\'Share on Twitter\'|@translate}" style="display:block;">
-  <img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>
+<a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 
+    class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}">
+  {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
 </a>
 ';
@@ -68,17 +98,19 @@
       
     case 'toolbar':
-      $search = '{/if}{/strip}{*caddie management END*}';
+      $search = '{*caddie management END*}';
       $replace = '
-<a href="http://twitter.com/share" class="twitter-share-button pwg-button" title="{\'Share on Twitter\'|@translate}">
-  <img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>
+<a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 
+    class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}">
+  {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
 </a>
 ';
       break;
       
-    case 'index':
+    case 'index':  
       $search = '<ul class="categoryActions">';
       $replace = '
-<li><a href="http://twitter.com/share" class="twitter-share-button pwg-button" title="{\'Share on Twitter\'|@translate}">
-  <img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>
+<li><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 
+        class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}">
+  {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
 </a></li>
 ';
@@ -86,5 +118,5 @@
   }
   
-  $replace = $search . $replace . '{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js\'}';
+  $replace = $search . $replace . '{if $TWEET_IFRAME}{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js}{/if}';
 
   return str_replace($search, $replace, $content);
Index: extensions/TweetThis/style.css
===================================================================
--- extensions/TweetThis/style.css	(revision 11504)
+++ extensions/TweetThis/style.css	(revision 11514)
@@ -3,4 +3,5 @@
   border:10px solid #f9f9f9;
   border-radius:10px;
+  margin-bottom:20px;
 }
 
@@ -11,9 +12,11 @@
   border-right-color:#CDE8F4;
   border-bottom-color:#CDE8F4;
+  text-align:center;
+  vertical-align:center;
 }
 .twitter_buttons td:hover {
   background-color:#D0E7F2;
 }
-tr td:last-child {
+.twitter_buttons tr td:last-child {
   border-right:none;
 }
@@ -21,2 +24,29 @@
   border-bottom:none;
 }
+tr.property td, tr.submit td {
+  padding:10px 5px;
+}
+tr.property td:hover, tr.submit td:hover {
+  background-color:#ECF6FA;
+}
+tr.property td:first-child {
+  text-align:right;
+  font-weight:bold;
+}
+tr.property td:last-child {
+  text-align:left;
+}
+tr.submit input {
+    background: url("http://a0.twimg.com/a/1308875119/phoenix/img/buttons/bg-btn-blue.gif") repeat-x 0 -202px #DDDDDD;
+    border-color: #3399DD #3399DD #2288CC;
+    color: #FFFFFF !important;
+    text-shadow: -1px -1px 0 #3399DD;
+    border-radius: 4px 4px 4px 4px;
+    border-style: solid;
+    border-width: 1px;
+    padding: 5px 9px !important;
+}
+tr.submit input:hover {
+  box-shadow: 0 0 5px #2288CC;
+  border-color: #3399DD #3399DD #2288CC;
+}
