Index: extensions/rotateImage/language/fr_FR/description.txt
===================================================================
--- extensions/rotateImage/language/fr_FR/description.txt	(revision 12409)
+++ extensions/rotateImage/language/fr_FR/description.txt	(revision 12409)
@@ -0,0 +1,1 @@
+Rotation des images en masse.
Index: extensions/rotateImage/language/fr_FR/index.php
===================================================================
--- extensions/rotateImage/language/fr_FR/index.php	(revision 12409)
+++ extensions/rotateImage/language/fr_FR/index.php	(revision 12409)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 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/rotateImage/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/rotateImage/language/fr_FR/plugin.lang.php	(revision 12409)
+++ extensions/rotateImage/language/fr_FR/plugin.lang.php	(revision 12409)
@@ -0,0 +1,8 @@
+<?php
+$lang['Images rotation in progress...'] = 'Rotation des images en cours...';
+$lang['Rotate images'] = 'Pivoter les images';
+$lang['Rotate 90° right'] = 'Rotation de 90° à droite';
+$lang['Rotate 90° left'] = 'Rotation de 90° à gauche';
+$lang['Rotate 180°'] = 'Rotation de 180°';
+
+?>
Index: extensions/rotateImage/main.inc.php
===================================================================
--- extensions/rotateImage/main.inc.php	(revision 12409)
+++ extensions/rotateImage/main.inc.php	(revision 12409)
@@ -0,0 +1,32 @@
+<?php
+/*
+Plugin Name: Rotate Image
+Version: 0.1
+Description: enables to rotate images in batch processing
+Plugin URI: http://www.phpwebgallery.net
+*/
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+add_event_handler('loc_begin_element_set_global', 'rotate_image_set_template_data');
+add_event_handler('ws_add_methods', 'add_image_rotate_method');
+
+function add_image_rotate_method($arr)
+{
+  include_once('ws_functions.inc.php');
+}
+
+function rotate_image_set_template_data() {
+	global $template,$lang;
+    load_language('plugin.lang', dirname(__FILE__).'/');
+	$template->set_filename('rotate_image', realpath(dirname(__FILE__).'/rotate_image.tpl'));
+	$template->append('element_set_global_plugins_actions', array(
+    'ID' => 'rotateImg',
+    'NAME' => l10n('Rotate images'),
+    'CONTENT' => $template->parse('rotate_image', true),
+    )
+  );
+}
+
+
+
+?>
Index: extensions/rotateImage/rotate_image.tpl
===================================================================
--- extensions/rotateImage/rotate_image.tpl	(revision 12409)
+++ extensions/rotateImage/rotate_image.tpl	(revision 12409)
@@ -0,0 +1,74 @@
+﻿{footer_script}
+var rotateImagesMessage = "{'Images rotation in progress...'|@translate}";
+
+{literal}
+  jQuery('#applyAction').click(function(e) {
+    if (elements.length != 0)
+    {
+      return true;
+    }
+    else if (jQuery('[name="selectAction"]').val() == 'rotateImg')
+    {
+      angle = jQuery('input[name="rotate_angle"]:checked').val();
+      e.stopPropagation();
+    }
+    else
+    {
+      return true;
+    }
+    jQuery('.bulkAction').hide();
+    jQuery('#regenerationText').html(rotateImagesMessage);
+    var maxRequests=1;
+
+    var queuedManager = jQuery.manageAjax.create('queued', { 
+      queue: true,  
+      cacheResponse: false,
+      maxRequests: maxRequests
+    });
+    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());
+        }
+      });
+    progressBar_max = elements.length;
+    todo = 0;
+
+    jQuery('#applyActionBlock').hide();
+    jQuery('select[name="selectAction"]').hide();
+    jQuery('#regenerationMsg').show();
+    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++) {
+      queuedManager.add({
+        type: 'GET', 
+        url: 'ws.php', 
+        data: {
+          method: "pwg.image.rotate",
+          format: 'json',
+          angle: angle,
+          image_id: elements[i]
+        },
+        dataType: 'json',
+        success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
+        error: ( function(data) { progress(++todo, progressBar_max, false) })
+      });
+    }
+    return false;
+  });
+
+{/literal}{/footer_script}
+
+<div id="rotate_image" class="bulkAction">
+  <p>{'Select angle :'|@translate}</p>
+  <label><input type="radio" name="rotate_angle" value="90" checked="checked"> {'Rotate 90° left'|@translate}</label>
+  <label><input type="radio" name="rotate_angle" value="270"> {'Rotate 90° right'|@translate}</label>
+  <label><input type="radio" name="rotate_angle" value="180"> {'Rotate 180°'|@translate}</label>
+</div>
Index: extensions/rotateImage/ws_functions.inc.php
===================================================================
--- extensions/rotateImage/ws_functions.inc.php	(revision 12409)
+++ extensions/rotateImage/ws_functions.inc.php	(revision 12409)
@@ -0,0 +1,64 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+$service = &$arr[0];
+$service->addMethod('pwg.image.rotate', 'ws_image_rotate',
+  array(
+  'image_id'=>array(),
+  'angle'=>array('default'=>"90"),
+  ),
+  'Rotates a given image'
+);
+
+function ws_image_rotate($params, &$service)
+{
+  if (!is_admin())
+  {
+    return new PwgError(401, 'Access denied');
+  }
+
+  if (empty($params['image_id']))
+  {
+    return new PwgError(403, "image_id or image_path is missing");
+  }
+
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+  include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
+  $image_id=(int)$params['image_id'];
+  $angle=(int)$params['angle'];
+  $query='
+SELECT id, path, tn_ext, has_high
+  FROM '.IMAGES_TABLE.'
+  WHERE id = '.$image_id.'
+;';
+  $image = pwg_db_fetch_assoc(pwg_query($query));
+  if ($image == null)
+  {
+    return new PwgError(403, "image_id not found");
+  }
+
+  $image_path = $image['path'];
+
+    
+  $thumb_path = get_thumbnail_path($image);
+
+  $img = new pwg_image($image_path);
+  $img->rotate($angle);
+  $img->write($image_path);
+  update_metadata(array($image_id=>$image_path));
+  
+  foreach (array('thumb','high') as $size) {
+    $resized_path = file_path_for_type($image_path,$size);
+    if (file_exists($resized_path)) {
+      $resized = new pwg_image($resized_path);
+      $resized->rotate($angle);
+      $resized->write($resized_path);
+    }
+  }
+  return true;
+  
+}
+
+?>
