Index: /extensions/regenerateWebsize/element_set_global_action.php
===================================================================
--- /extensions/regenerateWebsize/element_set_global_action.php	(revision 10358)
+++ /extensions/regenerateWebsize/element_set_global_action.php	(revision 10358)
@@ -0,0 +1,97 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+check_status(ACCESS_ADMINISTRATOR);
+
+global $template, $conf, $page, $pwg_loaded_plugins;
+
+load_language('plugin.lang', REGENERATE_WEBSIZE_PATH);
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+prepare_upload_configuration();
+$upload_form_config = get_upload_form_config();
+
+$template->set_filename('regenerateWebsize', realpath(REGENERATE_WEBSIZE_PATH.'element_set_global_action.tpl'));
+
+if (isset($_POST['submit']) and $_POST['selectAction'] == 'regenerateWebsize')
+{
+  if ($_POST['regenerateWebsizeSuccess'] != '0')
+    array_push($page['infos'], sprintf(l10n('%s photos have been regenerated'), $_POST['regenerateWebsizeSuccess']));
+
+  if ($_POST['regenerateWebsizeError'] != '0')
+    array_push($page['warnings'], sprintf(l10n('%s photos can not be regenerated'), $_POST['regenerateWebsizeError']));
+
+  // Update configuration
+  $fields = array('websize_maxwidth', 'websize_maxheight', 'websize_quality');
+  foreach ($fields as $field)
+  {
+    if (!isset($upload_form_config[$field]))
+    {
+      continue;
+    }
+    $value = null;
+    if (!empty($_POST[$field]))
+    {
+      $value = $_POST[$field];
+    }
+
+    $min = $upload_form_config[$field]['min'];
+    $max = $upload_form_config[$field]['max'];
+    $pattern = $upload_form_config[$field]['pattern'];
+
+    if (preg_match($pattern, $value) and $value >= $min and $value <= $max)
+    {
+      $conf['upload_form_'.$field] = $value;
+       $updates[] = array(
+        'param' => 'upload_form_'.$field,
+        'value' => $value
+        );
+    }
+    else
+    {
+      array_push(
+        $page['errors'],
+        sprintf(
+          $upload_form_config[$field]['error_message'],
+          $min,
+          $max
+          )
+        );
+    }
+    $form_values[$field] = $value;
+  }
+  if (count($page['errors']) == 0)
+  {
+    mass_updates(
+      CONFIG_TABLE,
+      array(
+        'primary' => array('param'),
+        'update' => array('value')
+        ),
+      $updates
+      );
+  }
+
+  $template->delete_compiled_templates();
+}
+
+foreach ($upload_form_config as $param_shortname => $param)
+{
+  $param_name = 'upload_form_'.$param_shortname;
+  $form_values[$param_shortname] = $conf[$param_name];
+}
+
+$template->assign(array(
+  'upload_form_websize_settings' => $form_values,
+  'all_elements' => $page['cat_elements_id'],
+  'redirect_url' => get_root_url().'admin.php?page='.$_GET['page'],
+  )
+);
+
+$template->append('element_set_global_plugins_actions', array(
+  'ID' => 'regenerateWebsize',
+  'NAME' => l10n('Regenerate Websize Photos'),
+  'CONTENT' => $template->parse('regenerateWebsize', true),
+  )
+);
+
+?>
Index: /extensions/regenerateWebsize/element_set_global_action.tpl
===================================================================
--- /extensions/regenerateWebsize/element_set_global_action.tpl	(revision 10358)
+++ /extensions/regenerateWebsize/element_set_global_action.tpl	(revision 10358)
@@ -0,0 +1,109 @@
+{combine_script id='jquery.progressBar' path='plugins/regenerateWebsize/js/jquery.progressbar.min.js' load='footer'}
+{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'}
+
+{footer_script require='jquery.progressBar,jquery.ajaxmanager'}
+var elements = new Array();
+var all_elements = [{','|@implode:$all_elements}];
+var redirect = '{$redirect_url}';
+
+{literal}
+var queuedManagerWebsize = $.manageAjax.create('queued', { 
+	queue: true,  
+	cacheResponse: false,
+	maxRequests: 1
+});
+
+function progressWebsize(val, max, success) {
+  jQuery('#progressBarWebsize').progressBar(val, {
+    max: max,
+    textFormat: 'fraction',
+    boxImage: 'plugins/regenerateWebsize/images/progressbar.gif',
+    barImage: 'plugins/regenerateWebsize/images/progressbg_orange.gif'
+  });
+  type = success ? 'regenerateWebsizeSuccess': 'regenerateWebsizeError'
+  s = jQuery('[name="'+type+'"]').val();
+  jQuery('[name="'+type+'"]').val(++s);
+
+  if (val == max)
+    jQuery('#applyAction').click();
+}
+
+jQuery(document).ready(function() {
+  jQuery('#applyAction').click(function() {
+    if (jQuery('[name="selectAction"]').val() == 'regenerateWebsize') {
+      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="websize_maxwidth"]').val();
+      maxheight = jQuery('input[name="websize_maxheight"]').val();
+      progressBar_max = elements.length;
+      todo = 0;
+
+      jQuery('.websize_config').hide();
+      jQuery('#applyActionBlock').hide();
+      jQuery('select[name="selectAction"]').hide();
+      jQuery('#regenerationMsgWebsize').show();
+      jQuery('#progressBarWebsize').progressBar(0, {
+        max: progressBar_max,
+        textFormat: 'fraction',
+        boxImage: 'plugins/regenerateWebsize/images/progressbar.gif',
+        barImage: 'plugins/regenerateWebsize/images/progressbg_orange.gif'
+      });
+
+      for (i=0;i<elements.length;i++) {
+        queuedManagerWebsize.add({
+          type: 'GET', 
+          url: 'ws.php', 
+          data: {
+            method: 'pwg.images.regenerateWebsize',
+            maxwidth: maxwidth,
+            maxheight: maxheight,
+            image_id: elements[i],
+            format: 'json'
+          },
+          dataType: 'json',
+          success: ( function(data) { progressWebsize(++todo, progressBar_max, data['result']) }),
+          error: ( function(data) { progressWebsize(++todo, progressBar_max, false) })
+        });
+      }
+      return false;
+    }
+  });
+});
+{/literal}{/footer_script}
+
+<p class="websize_config">
+  <img src="plugins/regenerateWebsize/images/warning.png" alt="!" style="vertical-align:middle;">
+  {'Only photos with HD can be regenerated!'|@translate}
+</p>
+
+<table style="margin:10px 20px;" class="websize_config">
+  <tr>
+    <th>{'Maximum Width'|@translate}</th>
+    <td><input type="text" name="websize_maxwidth" value="{$upload_form_websize_settings.websize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+  </tr>
+  <tr>
+    <th>{'Maximum Height'|@translate}</th>
+    <td><input type="text" name="websize_maxheight" value="{$upload_form_websize_settings.websize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+  </tr>
+  <tr>
+    <th>{'Image Quality'|@translate}</th>
+    <td><input type="text" name="websize_quality" value="{$upload_form_websize_settings.websize_quality}" size="3" maxlength="3"> %</td>
+  </tr>
+</table>
+
+<div id="regenerationMsgWebsize" style="display:none;">{'Websize photos generation in progress...'|@translate}<br><br>
+<span class="progressBarWebsize" id="progressBarWebsize"></span>
+</div>
+
+<input type="hidden" name="regenerateWebsizeSuccess" value="0">
+<input type="hidden" name="regenerateWebsizeError" value="0">
Index: /extensions/regenerateWebsize/index.php
===================================================================
--- /extensions/regenerateWebsize/index.php	(revision 10358)
+++ /extensions/regenerateWebsize/index.php	(revision 10358)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 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/regenerateWebsize/js/jquery.progressbar.js
===================================================================
--- /extensions/regenerateWebsize/js/jquery.progressbar.js	(revision 10358)
+++ /extensions/regenerateWebsize/js/jquery.progressbar.js	(revision 10358)
@@ -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: /extensions/regenerateWebsize/js/jquery.progressbar.min.js
===================================================================
--- /extensions/regenerateWebsize/js/jquery.progressbar.min.js	(revision 10358)
+++ /extensions/regenerateWebsize/js/jquery.progressbar.min.js	(revision 10358)
@@ -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);
Index: /extensions/regenerateWebsize/language/en_UK/description.txt
===================================================================
--- /extensions/regenerateWebsize/language/en_UK/description.txt	(revision 10358)
+++ /extensions/regenerateWebsize/language/en_UK/description.txt	(revision 10358)
@@ -0,0 +1,1 @@
+Regenerate "websize" photos if HD is exists.
Index: /extensions/regenerateWebsize/language/en_UK/index.php
===================================================================
--- /extensions/regenerateWebsize/language/en_UK/index.php	(revision 10358)
+++ /extensions/regenerateWebsize/language/en_UK/index.php	(revision 10358)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 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/regenerateWebsize/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/regenerateWebsize/language/en_UK/plugin.lang.php	(revision 10358)
+++ /extensions/regenerateWebsize/language/en_UK/plugin.lang.php	(revision 10358)
@@ -0,0 +1,9 @@
+<?php
+
+$lang['Regenerate Websize Photos'] = 'Regenerate Websize Photos';
+$lang['Photos generation in progress...'] = 'Photos generation in progress...';
+$lang['%s photos have been regenerated'] = '%s photos have been regenerated';
+$lang['%s photos can not be regenerated'] = '%s photos can not be regenerated';
+$lang['Only photos with HD can be regenerated!' = 'Only photos with HD can be regenerated!';
+
+?>
Index: /extensions/regenerateWebsize/language/fr_FR/description.txt
===================================================================
--- /extensions/regenerateWebsize/language/fr_FR/description.txt	(revision 10358)
+++ /extensions/regenerateWebsize/language/fr_FR/description.txt	(revision 10358)
@@ -0,0 +1,1 @@
+Rénégération les photos "taille web" si la HD est présente.
Index: /extensions/regenerateWebsize/language/fr_FR/index.php
===================================================================
--- /extensions/regenerateWebsize/language/fr_FR/index.php	(revision 10358)
+++ /extensions/regenerateWebsize/language/fr_FR/index.php	(revision 10358)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 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/regenerateWebsize/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/regenerateWebsize/language/fr_FR/plugin.lang.php	(revision 10358)
+++ /extensions/regenerateWebsize/language/fr_FR/plugin.lang.php	(revision 10358)
@@ -0,0 +1,9 @@
+<?php
+
+$lang['Regenerate Websize Photos'] = 'Régénérer les photos taille web';
+$lang['Photos generation in progress...'] = 'Génération des photos en cours...';
+$lang['%s photos have been regenerated'] = '%s photos ont été régénérées.';
+$lang['%s photos can not be regenerated'] = '%s photos ne peuvent pas être régénérées';
+$lang['Only photos with HD can be regenerated!'] = 'Seules les photos avec HD peuvent être régénérées';
+
+?>
Index: /extensions/regenerateWebsize/language/index.php
===================================================================
--- /extensions/regenerateWebsize/language/index.php	(revision 10358)
+++ /extensions/regenerateWebsize/language/index.php	(revision 10358)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 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/regenerateWebsize/main.inc.php
===================================================================
--- /extensions/regenerateWebsize/main.inc.php	(revision 10358)
+++ /extensions/regenerateWebsize/main.inc.php	(revision 10358)
@@ -0,0 +1,27 @@
+<?php
+/*
+Plugin Name: Websize Regeneration
+Version: auto
+Description: Regenerate "websize" photos if HD is exists.
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=529
+Author: P@t
+Author URI: http://www.gauchon.com
+*/
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+define('REGENERATE_WEBSIZE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
+
+add_event_handler('loc_begin_element_set_global', 'rgws_element_set_global_add_action');
+add_event_handler('ws_add_methods', 'add_regenerate_websize_method');
+
+function rgws_element_set_global_add_action()
+{
+  include(REGENERATE_WEBSIZE_PATH.'element_set_global_action.php');
+}
+
+function add_regenerate_websize_method($arr)
+{
+  include_once(REGENERATE_WEBSIZE_PATH.'ws_functions.inc.php');
+}
+
+?>
Index: /extensions/regenerateWebsize/ws_functions.inc.php
===================================================================
--- /extensions/regenerateWebsize/ws_functions.inc.php	(revision 10358)
+++ /extensions/regenerateWebsize/ws_functions.inc.php	(revision 10358)
@@ -0,0 +1,75 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+global $conf;
+
+$service = &$arr[0];
+$service->addMethod(
+  'pwg.images.regenerateWebsize',
+  'ws_images_regenerateWebsize',
+  array(
+    'image_id'  => array(),
+    'maxwidth'  => array('default'=>$conf['upload_form_websize_maxwidth']),
+    'maxheight' => array('default'=>$conf['upload_form_websize_maxheight']),
+    'quality'   => array('default'=>$conf['upload_form_websize_quality']),
+  ),
+  'Regenerate websize images from HD with given arguments.'
+);
+
+function ws_images_regenerateWebsize($params, &$service)
+{
+  global $conf;
+
+  if (!is_admin())
+    return new PwgError(401, 'Access denied');
+
+  $query='
+SELECT id, path, has_high, width, height
+FROM '.IMAGES_TABLE.'
+WHERE id = '.(int)$params['image_id'].'
+;';
+
+  $image = pwg_db_fetch_assoc(pwg_query($query));
+  if ($image == null)
+    return new PwgError(404, "image_id not found");
+
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+
+  if (!empty( $image['has_high'] ))
+  {
+    trigger_event(
+      'upload_image_resize',
+      false,
+      file_path_for_type($image['path'], 'high'),
+      $image['path'],
+      $params['maxwidth'],
+      $params['maxheight'],
+      $params['quality'],
+      true
+      );
+
+    return true;
+  }
+  /*
+  elseif (!empty($image['width']) and !empty($image['height'])
+    and ($image['width'] > $params['maxwidth'] or $image['height'] > $params['maxheight']))
+  {
+    trigger_event(
+      'upload_image_resize',
+      false,
+      $image['path'],
+      $image['path'],
+      min($params['maxwidth'], $image['width']),
+      min($params['maxheight'], $image['height']),
+      $params['quality'],
+      true
+      );
+
+    return true;
+  }
+  */
+  return false;
+}
+
+?>
