Index: /trunk/admin/batch_manager_global.php
===================================================================
--- /trunk/admin/batch_manager_global.php	(revision 10388)
+++ /trunk/admin/batch_manager_global.php	(revision 10389)
@@ -34,4 +34,13 @@
 
 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+prepare_upload_configuration();
+
+$upload_form_config = get_upload_form_config();
+foreach ($upload_form_config as $param_shortname => $param)
+{
+  $param_name = 'upload_form_'.$param_shortname;
+  $form_values[$param_shortname] = $conf[$param_name];
+}
 
 // +-----------------------------------------------------------------------+
@@ -395,4 +404,59 @@
   }
 
+  if ('regenerateThumbnails' == $action)
+  {
+    if ($_POST['regenerateSuccess'] != '0')
+      array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess']));
+
+    if ($_POST['regenerateError'] != '0')
+      array_push($page['warnings'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateError']));
+
+    // Update configuration
+    $fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality');
+    $updates = array();
+    foreach ($fields as $field)
+    {
+      $value = null;
+      if (!empty($_POST[$field]))
+      {
+        $value = $_POST[$field];
+      }
+
+      if (preg_match($upload_form_config[$field]['pattern'], $value)
+        and $value >= $upload_form_config[$field]['min']
+        and $value <= $upload_form_config[$field]['max'])
+      {
+        $conf['upload_form_'.$field] = $value;
+         $updates[] = array(
+          'param' => 'upload_form_'.$field,
+          'value' => $value
+          );
+      }
+      else
+      {
+        $updates = null;
+        break;
+      }
+      $form_values[$field] = $value;
+    }
+    if (!empty($updates))
+    {
+      mass_updates(
+        CONFIG_TABLE,
+        array(
+          'primary' => array('param'),
+          'update' => array('value')
+          ),
+        $updates
+        );
+    }
+    function regenerateThumbnails_prefilter($content, $smarty)
+    {
+      return str_replace('{$thumbnail.TN_SRC}', '{$thumbnail.TN_SRC}?rand='.md5(uniqid(rand(), true)), $content);
+    }
+    $template->set_prefilter('batch_manager_global', 'regenerateThumbnails_prefilter');
+    $template->delete_compiled_templates();
+  }
+
   trigger_action('element_set_global_action', $action, $collection);
 }
@@ -431,4 +495,6 @@
     'filter' => $_SESSION['bulk_manager_filter'],
     'selection' => $collection,
+    'all_elements' => $page['cat_elements_id'],
+    'upload_form_settings' => $form_values,
     'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
     'F_ACTION'=>$base_url.get_query_string_diff(array('cat')),
Index: /trunk/admin/themes/default/template/batch_manager_global.tpl
===================================================================
--- /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 10388)
+++ /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 10389)
@@ -7,4 +7,6 @@
 
 {combine_script id='jquery.fcbkcomplete' load='footer' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'}
+{combine_script id='jquery.progressBar' load='footer' path='plugins/regenerateThumbnails/js/jquery.progressbar.min.js'}
+{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
 
 {footer_script require='jquery.fcbkcomplete'}{literal}
@@ -27,9 +29,18 @@
 var nb_thumbs_set = {$nb_thumbs_set};
 var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
+var elements = new Array();
+var all_elements = [{','|@implode:$all_elements}];
 
 var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
 var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
 var selectedMessage_all = "{'All %d photos are selected'|@translate}";
+var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
 {literal}
+var queuedManagerThumbnails = $.manageAjax.create('queued', { 
+	queue: true,  
+	cacheResponse: false,
+	maxRequests: 3
+});
+
 function str_repeat(i, m) {
         for (var o = []; m > 0; o[--m] = i);
@@ -79,4 +90,19 @@
 }
 
+function progress(val, max, success) {
+  jQuery('#progressBar').progressBar(val, {
+    max: max,
+    textFormat: 'fraction',
+    boxImage: 'themes/default/images/progressbar.gif',
+    barImage: 'themes/default/images/progressbg_orange.gif'
+  });
+  type = success ? 'regenerateSuccess': 'regenerateError'
+  s = jQuery('[name="'+type+'"]').val();
+  jQuery('[name="'+type+'"]').val(++s);
+
+  if (val == max)
+    jQuery('#applyAction').click();
+}
+
 $(document).ready(function() {
   function checkPermitAction() {
@@ -299,4 +325,56 @@
     });
     return false;
+  });
+
+  jQuery('#applyAction').click(function() {
+    if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') {
+      if (elements.length != 0)
+        return true;
+
+      if (jQuery('input[name="setSelected"]').attr('checked'))
+        elements = all_elements;
+      else
+        jQuery('input[name="selection[]"]').each(function() {
+          if (jQuery(this).attr('checked')) {
+            elements.push(jQuery(this).val());
+          }
+        });
+
+      maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
+      maxheight = jQuery('input[name="thumb_maxheight"]').val();
+      progressBar_max = elements.length;
+      todo = 0;
+
+      jQuery('#thumb_config').hide();
+      jQuery('#applyActionBlock').hide();
+      jQuery('select[name="selectAction"]').hide();
+      jQuery('#regenerationMsg').show();
+      jQuery('#regenerationText').html(regenerateThumbnailsMessage);
+      jQuery('#progressBar').progressBar(0, {
+        max: progressBar_max,
+        textFormat: 'fraction',
+        boxImage: 'themes/default/images/progressbar.gif',
+        barImage: 'themes/default/images/progressbg_orange.gif'
+      });
+
+      for (i=0;i<elements.length;i++) {
+        queuedManagerThumbnails.add({
+          type: 'GET', 
+          url: 'ws.php', 
+          data: {
+            method: 'pwg.images.resize',
+            type: 'thumbnail',
+            maxwidth: maxwidth,
+            maxheight: maxheight,
+            image_id: elements[i],
+            format: 'json'
+          },
+          dataType: 'json',
+          success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
+          error: ( function(data) { progress(++todo, progressBar_max, false) })
+        });
+      }
+      return false;
+    }
   });
 
@@ -474,4 +552,5 @@
       <option value="add_to_caddie">{'add to caddie'|@translate}</option>
   {/if}
+      <option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>
   {if !empty($element_set_global_plugins_actions)}
     {foreach from=$element_set_global_plugins_actions item=action}
@@ -560,4 +639,30 @@
     </div>
 
+    <!-- regenerate thumbnails -->
+    <div id="action_regenerateThumbnails" class="bulkAction">
+      <table style="margin-left:20px;" id="thumb_config">
+        <tr>
+          <th>{'Maximum Width'|@translate}</th>
+          <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+        </tr>
+        <tr>
+          <th>{'Maximum Height'|@translate}</th>
+          <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+        </tr>
+        <tr>
+          <th>{'Image Quality'|@translate}</th>
+          <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td>
+        </tr>
+      </table>
+    </div>
+
+    <!-- progress bar -->
+    <div id="regenerationMsg" style="display:none;">
+      <p id="regenerationText" style="margin-bottom:10px;"></p>
+      <span class="progressBar" id="progressBar"></span>
+      <input type="hidden" name="regenerateSuccess" value="0">
+      <input type="hidden" name="regenerateError" value="0">
+    </div>
+
     <!-- plugins -->
 {if !empty($element_set_global_plugins_actions)}
Index: /trunk/themes/default/js/plugins/jquery.progressbar.js
===================================================================
--- /trunk/themes/default/js/plugins/jquery.progressbar.js	(revision 10389)
+++ /trunk/themes/default/js/plugins/jquery.progressbar.js	(revision 10389)
@@ -0,0 +1,186 @@
+/*
+ * jQuery Progress Bar plugin
+ * Version 2.0 (06/22/2009)
+ * @requires jQuery v1.2.1 or later
+ *
+ * Copyright (c) 2008 Gary Teo
+ * http://t.wits.sg
+
+USAGE:
+	$(".someclass").progressBar();
+	$("#progressbar").progressBar();
+	$("#progressbar").progressBar(45);							// percentage
+	$("#progressbar").progressBar({showText: false });			// percentage with config
+	$("#progressbar").progressBar(45, {showText: false });		// percentage with config
+*/
+(function($) {
+	$.extend({
+		progressBar: new function() {
+
+			this.defaults = {
+				steps			: 20,											// steps taken to reach target
+				stepDuration	: 20,											
+				max				: 100,											// Upon 100% i'd assume, but configurable
+				showText		: true,											// show text with percentage in next to the progressbar? - default : true
+				textFormat		: 'percentage',									// Or otherwise, set to 'fraction'
+				width			: 120,											// Width of the progressbar - don't forget to adjust your image too!!!												// Image to use in the progressbar. Can be a single image too: 'images/progressbg_green.gif'
+				height			: 12,											// Height of the progressbar - don't forget to adjust your image too!!!
+				callback		: null,											// Calls back with the config object that has the current percentage, target percentage, current image, etc
+				boxImage		: 'images/progressbar.gif',						// boxImage : image around the progress bar
+				barImage		: {
+									0:	'images/progressbg_red.gif',
+									30: 'images/progressbg_orange.gif',
+									70: 'images/progressbg_green.gif'
+								},
+				
+				
+				// Internal use
+				running_value	: 0,
+				value			: 0,
+				image			: null
+			};
+			
+			/* public methods */
+			this.construct = function(arg1, arg2) {
+				var argvalue	= null;
+				var argconfig	= null;
+				
+				if (arg1 != null) {
+					if (!isNaN(arg1)) {
+						argvalue = arg1;
+						if (arg2 != null) {
+							argconfig = arg2;
+						}
+					} else {
+						argconfig = arg1; 
+					}
+				}
+				
+				return this.each(function(child) {
+					var pb		= this;
+					var config	= this.config;
+					
+					if (argvalue != null && this.bar != null && this.config != null) {
+						this.config.value 		= parseInt(argvalue)
+						if (argconfig != null)
+							pb.config			= $.extend(this.config, argconfig);
+						config	= pb.config;
+					} else {
+						var $this				= $(this);
+						var config				= $.extend({}, $.progressBar.defaults, argconfig);
+						config.id				= $this.attr('id') ? $this.attr('id') : Math.ceil(Math.random() * 100000);	// random id, if none provided
+						
+						if (argvalue == null)
+							argvalue	= $this.html().replace("%","")	// parse percentage
+						
+						config.value			= parseInt(argvalue);
+						config.running_value	= 0;
+						config.image			= getBarImage(config);
+						
+						var numeric = ['steps', 'stepDuration', 'max', 'width', 'height', 'running_value', 'value'];
+						for (var i=0; i<numeric.length; i++) 
+							config[numeric[i]] = parseInt(config[numeric[i]]);
+						
+						$this.html("");
+						var bar					= document.createElement('img');
+						var text				= document.createElement('span');
+						var $bar				= $(bar);
+						var $text				= $(text);
+						pb.bar					= $bar;
+						
+						$bar.attr('id', config.id + "_pbImage");
+						$text.attr('id', config.id + "_pbText");
+						$text.html(getText(config));
+						$bar.attr('title', getText(config));
+						$bar.attr('alt', getText(config));
+						$bar.attr('src', config.boxImage);
+						$bar.attr('width', config.width);
+						$bar.css("width", config.width + "px");
+						$bar.css("height", config.height + "px");
+						$bar.css("background-image", "url(" + config.image + ")");
+						$bar.css("background-position", ((config.width * -1)) + 'px 50%');
+						$bar.css("padding", "0");
+						$bar.css("margin", "0");
+						$this.append($bar);
+						$this.append($text);
+					}
+
+					function getPercentage(config) {
+						return config.running_value * 100 / config.max;
+					}
+
+					function getBarImage(config) {
+						var image = config.barImage;
+						if (typeof(config.barImage) == 'object') {
+							for (var i in config.barImage) {
+								if (config.running_value >= parseInt(i)) {
+									image = config.barImage[i];
+								} else { break; }
+							}
+						}
+						return image;
+					}
+					
+					function getText(config) {
+						if (config.showText) {
+							if (config.textFormat == 'percentage') {
+								return " " + Math.round(config.running_value) + "%";
+							} else if (config.textFormat == 'fraction') {
+								return " " + config.running_value + '/' + config.max;
+							}
+						}
+					}
+					
+					config.increment = Math.round((config.value - config.running_value)/config.steps);
+					if (config.increment < 0)
+						config.increment *= -1;
+					if (config.increment < 1)
+						config.increment = 1;
+					
+					var t = setInterval(function() {
+						var pixels	= config.width / 100;			// Define how many pixels go into 1%
+						
+						if (config.running_value > config.value) {
+							if (config.running_value - config.increment  < config.value) {
+								config.running_value = config.value;
+							} else {
+								config.running_value -= config.increment;
+							}
+						}
+						else if (config.running_value < config.value) {
+							if (config.running_value + config.increment  > config.value) {
+								config.running_value = config.value;
+							} else {
+								config.running_value += config.increment;
+							}
+						}
+						
+						if (config.running_value == config.value)
+							clearInterval(t);
+						
+						var $bar	= $("#" + config.id + "_pbImage");
+						var $text	= $("#" + config.id + "_pbText");
+						var image	= getBarImage(config);
+						if (image != config.image) {
+							$bar.css("background-image", "url(" + image + ")");
+							config.image = image;
+						}
+						$bar.css("background-position", (((config.width * -1)) + (getPercentage(config) * pixels)) + 'px 50%');
+						$bar.attr('title', getText(config));
+						$text.html(getText(config));
+						
+						if (config.callback != null && typeof(config.callback) == 'function')
+							config.callback(config);
+						
+						pb.config = config;
+					}, config.stepDuration); 
+				});
+			};
+		}
+	});
+		
+	$.fn.extend({
+        progressBar: $.progressBar.construct
+	});
+	
+})(jQuery);
Index: /trunk/themes/default/js/plugins/jquery.progressbar.min.js
===================================================================
--- /trunk/themes/default/js/plugins/jquery.progressbar.min.js	(revision 10389)
+++ /trunk/themes/default/js/plugins/jquery.progressbar.min.js	(revision 10389)
@@ -0,0 +1,20 @@
+
+(function($){$.extend({progressBar:new function(){this.defaults={steps:20,stepDuration:20,max:100,showText:true,textFormat:'percentage',width:120,height:12,callback:null,boxImage:'images/progressbar.gif',barImage:{0:'images/progressbg_red.gif',30:'images/progressbg_orange.gif',70:'images/progressbg_green.gif'},running_value:0,value:0,image:null};this.construct=function(arg1,arg2){var argvalue=null;var argconfig=null;if(arg1!=null){if(!isNaN(arg1)){argvalue=arg1;if(arg2!=null){argconfig=arg2;}}else{argconfig=arg1;}}
+return this.each(function(child){var pb=this;var config=this.config;if(argvalue!=null&&this.bar!=null&&this.config!=null){this.config.value=parseInt(argvalue)
+if(argconfig!=null)
+pb.config=$.extend(this.config,argconfig);config=pb.config;}else{var $this=$(this);var config=$.extend({},$.progressBar.defaults,argconfig);config.id=$this.attr('id')?$this.attr('id'):Math.ceil(Math.random()*100000);if(argvalue==null)
+argvalue=$this.html().replace("%","")
+config.value=parseInt(argvalue);config.running_value=0;config.image=getBarImage(config);var numeric=['steps','stepDuration','max','width','height','running_value','value'];for(var i=0;i<numeric.length;i++)
+config[numeric[i]]=parseInt(config[numeric[i]]);$this.html("");var bar=document.createElement('img');var text=document.createElement('span');var $bar=$(bar);var $text=$(text);pb.bar=$bar;$bar.attr('id',config.id+"_pbImage");$text.attr('id',config.id+"_pbText");$text.html(getText(config));$bar.attr('title',getText(config));$bar.attr('alt',getText(config));$bar.attr('src',config.boxImage);$bar.attr('width',config.width);$bar.css("width",config.width+"px");$bar.css("height",config.height+"px");$bar.css("background-image","url("+config.image+")");$bar.css("background-position",((config.width*-1))+'px 50%');$bar.css("padding","0");$bar.css("margin","0");$this.append($bar);$this.append($text);}
+function getPercentage(config){return config.running_value*100/config.max;}
+function getBarImage(config){var image=config.barImage;if(typeof(config.barImage)=='object'){for(var i in config.barImage){if(config.running_value>=parseInt(i)){image=config.barImage[i];}else{break;}}}
+return image;}
+function getText(config){if(config.showText){if(config.textFormat=='percentage'){return" "+Math.round(config.running_value)+"%";}else if(config.textFormat=='fraction'){return" "+config.running_value+'/'+config.max;}}}
+config.increment=Math.round((config.value-config.running_value)/config.steps);if(config.increment<0)
+config.increment*=-1;if(config.increment<1)
+config.increment=1;var t=setInterval(function(){var pixels=config.width/100;if(config.running_value>config.value){if(config.running_value-config.increment<config.value){config.running_value=config.value;}else{config.running_value-=config.increment;}}
+else if(config.running_value<config.value){if(config.running_value+config.increment>config.value){config.running_value=config.value;}else{config.running_value+=config.increment;}}
+if(config.running_value==config.value)
+clearInterval(t);var $bar=$("#"+config.id+"_pbImage");var $text=$("#"+config.id+"_pbText");var image=getBarImage(config);if(image!=config.image){$bar.css("background-image","url("+image+")");config.image=image;}
+$bar.css("background-position",(((config.width*-1))+(getPercentage(config)*pixels))+'px 50%');$bar.attr('title',getText(config));$text.html(getText(config));if(config.callback!=null&&typeof(config.callback)=='function')
+config.callback(config);pb.config=config;},config.stepDuration);});};}});$.fn.extend({progressBar:$.progressBar.construct});})(jQuery);
