Index: /extensions/BatchDownloader/admin.php
===================================================================
--- /extensions/BatchDownloader/admin.php	(revision 25931)
+++ /extensions/BatchDownloader/admin.php	(revision 25932)
@@ -8,5 +8,5 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'sets';
-  
+
 $tabsheet = new tabsheet();
 $tabsheet->add('sets', l10n('Download history'), BATCH_DOWNLOAD_ADMIN . '-sets');
@@ -17,5 +17,5 @@
 if (!class_exists('ZipArchive'))
 {
-  array_push($page['warnings'], l10n('Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'));
+  $page['warnings'][] = l10n('Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.');
 }
 
@@ -28,6 +28,4 @@
   'BATCH_DOWNLOAD_ADMIN' => BATCH_DOWNLOAD_ADMIN,
   ));
-  
+
 $template->assign_var_from_handle('ADMIN_CONTENT', 'batch_download');
-
-?>
Index: /extensions/BatchDownloader/admin/config.php
===================================================================
--- /extensions/BatchDownloader/admin/config.php	(revision 25931)
+++ /extensions/BatchDownloader/admin/config.php	(revision 25932)
@@ -1,9 +1,9 @@
 <?php
-if (!defined('BATCH_DOWNLOAD_PATH')) die('Hacking attempt!');
+defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!');
 
 if (isset($_POST['save_config']))
 {
   if (!defined('USER_COLLEC_ID')) $_POST['what']['collections'] = 'on';
-  
+
   $conf['batch_download'] = array(
     'groups'          => isset($_POST['groups']) ? $_POST['groups'] : array(),
@@ -22,9 +22,9 @@
     );
   $conf['batch_download_comment'] = trim($_POST['archive_comment']);
-  
+
   conf_update_param('batch_download', serialize($conf['batch_download']));
   conf_update_param('batch_download_comment', $conf['batch_download_comment']);
-  
-  array_push($page['infos'], l10n('Information data registered in database'));
+
+  $page['infos'][] = l10n('Information data registered in database');
 }
 
@@ -67,5 +67,3 @@
 
 
-$template->set_filename('batch_download', dirname(__FILE__) . '/template/config.tpl');
-
-?>
+$template->set_filename('batch_download', realpath(BATCH_DOWNLOAD_PATH . 'admin/template/config.tpl'));
Index: /extensions/BatchDownloader/admin/sets.php
===================================================================
--- /extensions/BatchDownloader/admin/sets.php	(revision 25931)
+++ /extensions/BatchDownloader/admin/sets.php	(revision 25932)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('BATCH_DOWNLOAD_PATH')) die('Hacking attempt!');
+defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!');
 
 // actions
@@ -11,5 +11,5 @@
 if (isset($_GET['cancel']))
 {
-  $set = new BatchDownloader($_GET['cancel']);  
+  $set = new BatchDownloader($_GET['cancel']);
   $set->updateParam('total_size', $set->getEstimatedTotalSize());
   $set->updateParam('nb_zip', $set->getEstimatedArchiveNumber());
@@ -28,7 +28,7 @@
     date_creation < DATE_SUB(NOW(), INTERVAL 1 HOUR)
 ;';
-  
+
   $sets = array_from_query($query, 'id');
-  
+
   foreach ($sets as $set_id)
   {
@@ -48,25 +48,25 @@
   if (!empty($_POST['username']))
   {
-    array_push($where_clauses, 'username LIKE "%'.$_POST['username'].'%"');
+    $where_clauses[] = 'username LIKE "%'.$_POST['username'].'%"';
   }
-  
+
   if ($_POST['type'] != -1)
   {
-    array_push($where_clauses, 'type = "'.$_POST['type'].'"');
+    $where_clauses[] = 'type = "'.$_POST['type'].'"';
   }
-  
+
   if ($_POST['status'] != -1)
   {
     if ($_POST['status'] == 'new')
-      array_push($where_clauses, '(status = "new" OR status = "ready")');
+      $where_clauses[] = '(status = "new" OR status = "ready")';
     else
-      array_push($where_clauses, 'status = "'.$_POST['status'].'"');
+      $where_clauses[] = 'status = "'.$_POST['status'].'"';
   }
-  
+
   if ($_POST['size'] != -1)
   {
-    array_push($where_clauses, 'size = "'.$_POST['size'].'"');
+    $where_clauses[] = 'size = "'.$_POST['size'].'"';
   }
-  
+
   if ($_POST['order_by'] == 'size')
   {
@@ -82,5 +82,5 @@
 // get sets
 $query = '
-SELECT 
+SELECT
     s.id,
     u.'.$conf['user_fields']['username'].' AS username
@@ -97,5 +97,5 @@
 {
   $set = new BatchDownloader($set_id);
-  
+
   $template->append('sets', array_merge(
     $set->getSetInfo(),
@@ -106,5 +106,5 @@
     )
     ));
-  
+
   unset($set);
 }
@@ -173,5 +173,3 @@
 
 
-$template->set_filename('batch_download', dirname(__FILE__) . '/template/sets.tpl');
-
-?>
+$template->set_filename('batch_download', realpath(BATCH_DOWNLOAD_PATH . 'admin/template/sets.tpl'));
Index: /extensions/BatchDownloader/admin/template/config.tpl
===================================================================
--- /extensions/BatchDownloader/admin/template/config.tpl	(revision 25931)
+++ /extensions/BatchDownloader/admin/template/config.tpl	(revision 25932)
@@ -1,3 +1,3 @@
-{combine_css path=$BATCH_DOWNLOAD_PATH|@cat:"admin/template/style.css"}
+{combine_css path=$BATCH_DOWNLOAD_PATH|cat:"admin/template/style.css"}
 
 {combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/jquery.ui.slider.js'}
@@ -51,8 +51,8 @@
 $('input[name="multisize"]').on('change', function() {
   if ($(this).val() == 'true') {
-    $('#multisize_title').text('{'Maximum photo size'|@translate|escape:javascript}');
+    $('#multisize_title').text('{'Maximum photo size'|translate|escape:javascript}');
   }
   else {
-    $('#multisize_title').text('{'Photo size'|@translate|escape:javascript}');
+    $('#multisize_title').text('{'Photo size'|translate|escape:javascript}');
   }
 })
@@ -67,19 +67,19 @@
 <form method="post" action="" class="properties">
 <fieldset>
-  <legend>{'Download permissions'|@translate}</legend>
-  
+  <legend>{'Download permissions'|translate}</legend>
+
   <ul>
     <li>
-      <i>{'Warning: Only registered users can use Batch Downloader.'|@translate}</i>
+      <i>{'Warning: Only registered users can use Batch Downloader.'|translate}</i>
     </li>
     <li>
       <label>
       {if $group_options}
-        <b>{'User groups'|@translate}</b>
-        <select name="groups[]" data-placeholder="{'Everybody'|@translate}" class="chzn-select" multiple="multiple" style="width:370px;">
+        <b>{'User groups'|translate}</b>
+        <select name="groups[]" data-placeholder="{'Everybody'|translate}" class="chzn-select" multiple="multiple" style="width:370px;">
           {html_options options=$group_options selected=$batch_download.groups}
         </select>
       {else}
-        {'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list">{'Group management'|@translate}</a>
+        {'There is no group in this gallery.'|translate} <a href="admin.php?page=group_list">{'Group management'|translate}</a>
       {/if}
       </label>
@@ -87,5 +87,5 @@
     <li>
       <label>
-        <b>{'Privacy level'|@translate}</b>
+        <b>{'Privacy level'|translate}</b>
         <select name="level">
           {html_options options=$level_options selected=$batch_download.level}
@@ -94,9 +94,9 @@
     </li>
     <li>
-      <b>{'What can be downloaded?'|@translate}</b>
-      <label><input type="checkbox" name="what[categories]" {if in_array('categories',$batch_download.what)}checked="checked"{/if}/> {'Albums'|@translate}</label>
-      {if $USER_COLLEC_LOADED}<label><input type="checkbox" name="what[collections]" {if in_array('collections',$batch_download.what)}checked="checked"{/if}/> {'Collections'|@translate}</label>{/if}
-      <label><input type="checkbox" name="what[specials]" {if in_array('specials',$batch_download.what)}checked="checked"{/if}/> {'Specials'|@translate}</label>
-      <a class="icon-info-circled-1 showInfo" title="{'Most visited'|@translate}, {'Random photos'|@translate}, {'Best rated'|@translate}..."></a>
+      <b>{'What can be downloaded?'|translate}</b>
+      <label><input type="checkbox" name="what[categories]" {if in_array('categories',$batch_download.what)}checked="checked"{/if}/> {'Albums'|translate}</label>
+      {if $USER_COLLEC_LOADED}<label><input type="checkbox" name="what[collections]" {if in_array('collections',$batch_download.what)}checked="checked"{/if}/> {'Collections'|translate}</label>{/if}
+      <label><input type="checkbox" name="what[specials]" {if in_array('specials',$batch_download.what)}checked="checked"{/if}/> {'Specials'|translate}</label>
+      <a class="icon-info-circled-1 showInfo" title="{'Most visited'|translate}, {'Random photos'|translate}, {'Best rated'|translate}..."></a>
     </li>
     <li>
@@ -106,5 +106,5 @@
 
       <label>
-        <b id="multisize_title">{'Maximum photo size'|@translate}</b>
+        <b id="multisize_title">{'Maximum photo size'|translate}</b>
         <select name="photo_size">
           {html_options options=$sizes_options selected=$batch_download.photo_size}
@@ -116,16 +116,16 @@
 
 <fieldset>
-  <legend>{'Archives'|@translate}</legend>
-  
+  <legend>{'Archives'|translate}</legend>
+
   <ul>
     <li>
       <label>
-        <b>{'Delete downloads after'|@translate}</b>
-        <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3"> {'hours'|@translate}
-      </label>
-    </li>
-    <li>
-      <label>
-        <b>{'Maximum number of photos per download set'|@translate}</b>
+        <b>{'Delete downloads after'|translate}</b>
+        <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3"> {'hours'|translate}
+      </label>
+    </li>
+    <li>
+      <label>
+        <b>{'Maximum number of photos per download set'|translate}</b>
         <div id="max_elements"></div>
         <input type="text" name="max_elements" value="{$batch_download.max_elements}" size="5">
@@ -134,5 +134,5 @@
     <li>
       <label>
-        <b>{'Maximum size of each archive (in Megabytes)'|@translate}</b>
+        <b>{'Maximum size of each archive (in Megabytes)'|translate}</b>
         <div id="max_size"></div>
         <input type="text" name="max_size" value="{$batch_download.max_size}" size="5">
@@ -141,5 +141,5 @@
     <li>
       <label>
-        <b>{'Archive prefix'|@translate}</b>
+        <b>{'Archive prefix'|translate}</b>
         <input type="text" name="archive_prefix" value="{$batch_download.archive_prefix}">
       </label>
@@ -148,30 +148,30 @@
       <label>
         <input type="checkbox" name="one_archive" {if $batch_download.one_archive}checked{/if}>
-        <b>{'Delete previous archive when starting to download another one'|@translate}</b>
-      </label>
-      <a class="icon-info-circled-1 showInfo" title="{'It saves space on the server but doesn\'t allow to restart failed downloads.'|@translate}"></a>
+        <b>{'Delete previous archive when starting to download another one'|translate}</b>
+      </label>
+      <a class="icon-info-circled-1 showInfo" title="{'It saves space on the server but doesn\'t allow to restart failed downloads.'|translate}"></a>
     </li>
     <li>
       <label>
         <input type="checkbox" name="force_pclzip" {if $batch_download.force_pclzip}checked{/if}>
-        <b>{'Force the usage of PclZip instead of ZipArchive as ZIP library'|@translate}</b>
-      </label>
-      <a class="icon-info-circled-1 showInfo" title="{'Only check if you are experiencing corrupted archives with ZipArchive.'|@translate}"></a>
+        <b>{'Force the usage of PclZip instead of ZipArchive as ZIP library'|translate}</b>
+      </label>
+      <a class="icon-info-circled-1 showInfo" title="{'Only check if you are experiencing corrupted archives with ZipArchive.'|translate}"></a>
     </li>
     <li>
       <label>
         <input type="checkbox" name="direct" {if $batch_download.direct}checked{/if}>
-        <b>{'Don\'t download archives through PHP'|@translate}</b>
-      </label>
-      <a class="icon-info-circled-1 showInfo" title="{'Only check if your host complains about high PHP usage.'|@translate}"></a>
+        <b>{'Don\'t download archives through PHP'|translate}</b>
+      </label>
+      <a class="icon-info-circled-1 showInfo" title="{'Only check if your host complains about high PHP usage.'|translate}"></a>
     </li>
   {if $use_ziparchive}
     <li>
       <label>
-        <b>{'Archive comment'|@translate} :</b><br>
+        <b>{'Archive comment'|translate} :</b><br>
         <textarea name="archive_comment" rows="5" style="width:450px;">{$batch_download_comment}</textarea>
       </label>
       <br>
-      <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'|@translate}</i>
+      <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'|translate}</i>
     </li>
   {else}
@@ -181,9 +181,9 @@
 </fieldset>
 
-<p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>  
-
-<fieldset>
-  <legend>{'Environment'|@translate}</legend>
-  
+<p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p>
+
+<fieldset>
+  <legend>{'Environment'|translate}</legend>
+
   <b>PHP</b> {$PHP_VERSION}<br>
 {if $use_ziparchive}
@@ -195,11 +195,11 @@
 
 <fieldset>
-  <legend>{'Advanced features'|@translate}</legend>
-  
+  <legend>{'Advanced features'|translate}</legend>
+
   <dl class="advanced" style="display:none;">
     {$ADVANCED_CONF}
   </dl>
-  
-  <span class="show_advanced buttonLike">{'Display'|@translate}</span>
+
+  <span class="show_advanced buttonLike">{'Display'|translate}</span>
 </fieldset>
 
Index: /extensions/BatchDownloader/admin/template/sets.tpl
===================================================================
--- /extensions/BatchDownloader/admin/template/sets.tpl	(revision 25931)
+++ /extensions/BatchDownloader/admin/template/sets.tpl	(revision 25932)
@@ -1,3 +1,3 @@
-{combine_css path=$BATCH_DOWNLOAD_PATH|@cat:"admin/template/style.css"}
+{combine_css path=$BATCH_DOWNLOAD_PATH|cat:"admin/template/style.css"}
 
 <div class="titrePage">
@@ -7,33 +7,33 @@
 <form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}">
 <fieldset>
-  <legend>{'Filter'|@translate}</legend>
+  <legend>{'Filter'|translate}</legend>
 
   <label>
-    {'Username'|@translate}
+    {'Username'|translate}
     <input type="text" name="username" value="{$F_USERNAME}">
   </label>
 
   <label>
-    {'Set type'|@translate}
+    {'Set type'|translate}
     {html_options name=type options=$type_options selected=$type_selected}
   </label>
-  
+
   <label>
-    {'Photo sizes'|@translate}
+    {'Photo sizes'|translate}
     {html_options name=size options=$size_options selected=$size_selected}
   </label>
-  
+
   <label>
-    {'Status'|@translate}
+    {'Status'|translate}
     {html_options name=status options=$status_options selected=$status_selected}
   </label>
 
   <label>
-    {'Sort by'|@translate}
+    {'Sort by'|translate}
     {html_options name=order_by options=$order_options selected=$order_selected}
   </label>
 
   <label>
-    {'Sort order'|@translate}
+    {'Sort order'|translate}
     {html_options name=direction options=$direction_options selected=$direction_selected}
   </label>
@@ -41,5 +41,5 @@
   <label>
     &nbsp;
-    <span><input class="submit" type="submit" name="filter" value="{'Submit'|@translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span>
+    <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span>
   </label>
 
@@ -51,13 +51,13 @@
   <thead>
     <tr class="throw">
-      <td class="user">{'Username'|@translate}</td>
-      <td class="type">{'Set type'|@translate}</td>
-      <td class="date">{'Creation date'|@translate}</td>
-      <td class="img_size">{'Photo sizes'|@translate}</td>
-      <td class="images">{'Number of images'|@translate}</td>
-      <td class="archives">{'Number of archives'|@translate}</td>
-      <td class="size">{'Total size'|@translate}</td>
-      <td class="status">{'Status'|@translate}</td>
-      <td class="action">{'Actions'|@translate}</td>
+      <td class="user">{'Username'|translate}</td>
+      <td class="type">{'Set type'|translate}</td>
+      <td class="date">{'Creation date'|translate}</td>
+      <td class="img_size">{'Photo sizes'|translate}</td>
+      <td class="images">{'Number of images'|translate}</td>
+      <td class="archives">{'Number of archives'|translate}</td>
+      <td class="size">{'Total size'|translate}</td>
+      <td class="status">{'Status'|translate}</td>
+      <td class="action">{'Actions'|translate}</td>
     </tr>
   </thead>
@@ -68,22 +68,22 @@
     <td>{$set.NAME}</td>
     <td style="text-align:center;">{$set.DATE_CREATION}</td>
-    <td>{if $set.SIZE=='original'}{'Original'|@translate}{else}{$set.SIZE|@translate}{/if}</td>
+    <td>{if $set.SIZE=='original'}{'Original'|translate}{else}{$set.SIZE|translate}{/if}</td>
     <td>{$set.NB_IMAGES}</td>
     <td>{$set.NB_ARCHIVES}</td>
     <td>{$set.TOTAL_SIZE}</td>
     <td>
-      {$set.STATUS|@translate}
+      {$set.STATUS|translate}
       {if $set.STATUS == 'download'}<i style="font-size:0.8em;">({$set.LAST_ZIP}/{$set.NB_ARCHIVES})</i>{/if}
     </td>
     <td style="padding-left:25px;">
-      <a href="{$set.U_DELETE}" title="{'Delete this set'|@translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>
-      {if $set.STATUS != 'done'}<a href="{$set.U_CANCEL}" title="{'Cancel this set'|@translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/permissions.png"></a>{/if}
+      <a href="{$set.U_DELETE}" title="{'Delete this set'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>
+      {if $set.STATUS != 'done'}<a href="{$set.U_CANCEL}" title="{'Cancel this set'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/permissions.png"></a>{/if}
     </td>
   </tr>
   {/foreach}
-  
+
   {if not $sets}
   <tr class="row2">
-    <td colspan="8" style="text-align:center;font-style:italic;">{'No result'|@translate}</td>
+    <td colspan="8" style="text-align:center;font-style:italic;">{'No result'|translate}</td>
   </tr>
   {/if}
@@ -91,5 +91,5 @@
 
 <form action="{$F_FILTER_ACTION}" method="post">
-<p><label><input type="checkbox" name="delete_done" value="1"> {'Remove all finished downloads'|@translate}</label>
-<input type="submit" value="{'Submit'|@translate}"></p>
+  <p><label><input type="checkbox" name="delete_done" value="1"> {'Remove all finished downloads'|translate}</label>
+  <input type="submit" value="{'Submit'|translate}"></p>
 </form>
Index: /extensions/BatchDownloader/download.php
===================================================================
--- /extensions/BatchDownloader/download.php	(revision 25931)
+++ /extensions/BatchDownloader/download.php	(revision 25932)
@@ -7,5 +7,5 @@
 try {
   $BatchDownloader = new BatchDownloader($_GET['set_id']);
-  
+
   if ($conf['batch_download']['one_archive'] and $_GET['zip'] == $BatchDownloader->getParam('last_zip'))
   {
@@ -16,10 +16,10 @@
     $file = $BatchDownloader->getArchivePath($_GET['zip']);
   }
-  
+
   if (empty($file) || !file_exists($file))
   {
     throw new Exception('Unable to locate file.');
   }
-  
+
   if ($conf['batch_download']['direct'])
   {
@@ -47,4 +47,2 @@
 
 exit(0);
-
-?>
Index: /extensions/BatchDownloader/include/BatchDownloader.class.php
===================================================================
--- /extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 25931)
+++ /extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 25932)
@@ -7,5 +7,5 @@
   private $data;
   private $images;
-  
+
   /**
    * __construct
@@ -19,5 +19,5 @@
   {
     global $user, $conf;
-    
+
     $this->conf = $conf['batch_download'];
     $this->data = array(
@@ -36,5 +36,5 @@
       );
     $this->images = array();
-    
+
     // load specific set
     if (preg_match('#^[0-9]+$#', $set_id))
@@ -47,5 +47,5 @@
 ;';
       $result = pwg_query($query);
-      
+
       if (pwg_db_num_rows($result))
       {
@@ -54,5 +54,5 @@
           pwg_db_fetch_assoc($result)
           );
-        
+
         // make sure all pictures of the set exist
         $query = '
@@ -63,5 +63,5 @@
 ;';
         pwg_query($query);
-      
+
         $query = '
 SELECT *
@@ -70,5 +70,5 @@
 ;';
         $this->images = simple_hash_from_query($query, 'image_id', 'zip');
-        
+
         if ( $this->data['status'] != 'done' and count($this->images) != $this->data['nb_images'] )
         {
@@ -78,5 +78,5 @@
       else
       {
-        throw new Exception(l10n('Invalid dowload set'));
+        throw new Exception(l10n('Invalid download set'));
       }
     }
@@ -89,12 +89,12 @@
         if (!in_array($size, $types))
         {
-          throw new Exception(sprintf(l10n('Invalid size %s'), $size));
-        }
-      }
-  
+          throw new Exception(l10n('Invalid size %s', $size));
+        }
+      }
+
       $this->data['type'] = $type;
       $this->data['type_id'] = $type_id;
       $this->data['size'] = $size;
-      
+
       $query = '
 INSERT INTO '.BATCH_DOWNLOAD_TSETS.'(
@@ -109,5 +109,5 @@
     total_size,
     status
-  ) 
+  )
   VALUES(
     '.$this->data['user_id'].',
@@ -125,8 +125,8 @@
       pwg_query($query);
       $this->data['id'] = pwg_db_insert_id();
-      
+
       $date = pwg_query('SELECT FROM_UNIXTIME(NOW());');
       list($this->data['date_creation']) = pwg_db_fetch_row($date);
-      
+
       if (!empty($images))
       {
@@ -139,5 +139,5 @@
     }
   }
-  
+
   /**
    * updateParam
@@ -150,5 +150,5 @@
     pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['id'].';');
   }
-  
+
   /**
    * getParam
@@ -160,5 +160,5 @@
     return $this->data[$name];
   }
-  
+
   /**
    * getImages
@@ -169,5 +169,5 @@
     return $this->images;
   }
-  
+
   /**
    * isInSet
@@ -179,5 +179,5 @@
     return array_key_exists($image_id, $this->images);
   }
-  
+
   /**
    * removeImages
@@ -187,21 +187,21 @@
   {
     if (empty($image_ids) or !is_array($image_ids)) return;
-    
+
     foreach ($image_ids as $image_id)
     {
       unset($this->images[ $image_id ]);
     }
-    
+
     $query = '
 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
-  WHERE 
+  WHERE
     set_id = '.$this->data['id'].'
     AND image_id IN('.implode(',', $image_ids).')
 ;';
     pwg_query($query);
-    
+
     $this->updateParam('nb_images', count($this->images));
   }
-  
+
   /**
    * addImages
@@ -211,5 +211,5 @@
   {
     if (empty($image_ids) or !is_array($image_ids)) return;
-    
+
     $query = '
 SELECT id, file
@@ -218,12 +218,12 @@
 ;';
     $images = simple_hash_from_query($query, 'id', 'file');
-    
+
     $inserts = array();
-    
+
     foreach ($images as $image_id => $file)
     {
       if ($this->isInSet($image_id)) continue;
       if (!in_array(get_extension($file), $this->conf['allowed_ext'])) continue;
-      
+
       $this->images[ $image_id ] = 0;
       $inserts[] = array(
@@ -233,5 +233,5 @@
         );
     }
-    
+
     if (count($inserts))
     {
@@ -242,8 +242,8 @@
         );
     }
-      
+
     $this->updateParam('nb_images', count($this->images));
   }
-  
+
   /**
    * clearImages
@@ -252,5 +252,5 @@
   {
     $this->images = array();
-    
+
     $query = '
 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
@@ -259,5 +259,5 @@
     pwg_query($query);
   }
-  
+
   /**
    * getMissingDerivatives
@@ -271,13 +271,13 @@
       return array();
     }
-    
+
     $uid = '&b='.time();
-    
+
     $params = ImageStdParams::get_by_type($this->data['size']);
     $last_mod_time = $params->last_mod_time;
-    
+
     $image_ids = array_keys($this->images);
     $to_update = $urls = $inserts = array();
-    
+
     global $conf;
     $conf['old_question_mark_in_urls'] = $conf['question_mark_in_urls'];
@@ -286,5 +286,5 @@
     $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true;
     $conf['derivative_url_style'] = 2;
-    
+
     // images which we need to update stats
     if ($update)
@@ -297,9 +297,9 @@
 ;';
       $registered = array_from_query($query, 'image_id', 'filemtime');
-      
+
       $to_update = array_filter($registered, create_function('$t', 'return $t<'.$last_mod_time.';'));
       $to_update = array_merge($to_update, array_diff($image_ids, $registered));
     }
-    
+
     $query = '
 SELECT id, path, width, height, rotation
@@ -313,10 +313,10 @@
     {
       $src_image = new SrcImage($row); // don't give representive_ext
-      
+
       // no-image files
       if ($src_image->is_mimetype())
       {
         if ($update && in_array($row['id'], $to_update))
-        {          
+        {
           $inserts[ $row['id'] ] = array(
             'image_id' => $row['id'],
@@ -333,9 +333,9 @@
       {
         $derivative = new DerivativeImage($this->data['size'], $src_image);
-        
+
         $filemtime = @filemtime($derivative->get_path());
         $src_mtime = @filemtime(PHPWG_ROOT_PATH.$row['path']);
         if ($src_mtime===false) continue;
-        
+
         if ($filemtime===false || $filemtime<$last_mod_time || $filemtime<$src_mtime)
         {
@@ -345,5 +345,5 @@
         {
           $imagesize = getimagesize($derivative->get_path());
-          
+
           $inserts[ $row['id'] ] = array(
             'image_id' => $row['id'],
@@ -357,5 +357,5 @@
       }
     }
-    
+
     if (!empty($inserts))
     {
@@ -365,5 +365,5 @@
 ;';
       pwg_query($query);
-      
+
       mass_inserts(
         IMAGE_SIZES_TABLE,
@@ -372,12 +372,12 @@
         );
     }
-    
+
     $conf['question_mark_in_urls'] = $conf['old_question_mark_in_urls'];
     $conf['php_extension_in_urls'] = $conf['old_php_extension_in_urls'];
     $conf['derivative_url_style'] = $conf['old_derivative_url_style'];
-    
+
     return $urls;
   }
-  
+
   /**
    * deleteArchives
@@ -386,5 +386,5 @@
   {
     $zip_path = glob($this->getArchivePath('*'));
-    
+
     if (is_array($zip_path))
     {
@@ -395,5 +395,5 @@
     }
   }
-  
+
   /**
    * getFilename
@@ -402,14 +402,14 @@
   {
     $row['filename'] = stripslashes(get_filename_wo_extension($row['file']));
-    
+
     // datas
     $search = array('%id%', '%filename%', '%author%', '%dimensions%');
     $replace = array($row['id'], $row['filename']);
-    
+
     $replace[2] = empty($row['author']) ? null : $row['author'];
     $replace[3] = empty($filesize) ? null : $filesize['width'].'x'.$filesize['height'];
-    
+
     $filename = str_replace($search, $replace, $this->conf['file_pattern']);
-    
+
     // functions
     $filename = preg_replace_callback('#\$escape\((.*?)\)#', create_function('$m', 'return str2url($m[1]);'),   $filename);
@@ -417,5 +417,5 @@
     $filename = preg_replace_callback('#\$lower\((.*?)\)#',  create_function('$m', 'return str2lower($m[1]);'), $filename);
     $filename = preg_replace_callback('#\$strpad\((.*?),(.*?),(.*?)\)#', create_function('$m', 'return str_pad($m[1],$m[2],$m[3],STR_PAD_LEFT);'), $filename);
-    
+
     // cleanup
     $filename = preg_replace(
@@ -424,15 +424,15 @@
       $filename
       );
-    
+
     if (empty($filename) || $filename == $this->conf['file_pattern'])
     {
       $filename = $row['id'].'_'.$row['filename'];
     }
-    
+
     $filename.= '.'.get_extension($row['path']);
-    
+
     return $filename;
   }
-  
+
   /**
    * createNextArchive
@@ -447,12 +447,12 @@
       trigger_error('BatchDownloader::createNextArchive, the set is empty', E_USER_ERROR);
     }
-    
+
     global $conf;
-    
+
     // first zip
     if ($this->data['last_zip'] == 0)
     {
       $this->updateParam('status', 'download');
-      
+
       // limit number of elements
       if ($this->data['nb_images'] > $this->conf['max_elements'])
@@ -462,12 +462,12 @@
         $this->addImages($images_ids);
       }
-      
+
       $this->getEstimatedArchiveNumber(true);
-      
+
       $this->updateParam('date_creation', date('Y-m-d H:i:s'));
-      
+
       trigger_action('batchdownload_init_zip', $this->data, array_keys($this->images)); // triggered once for all
     }
-    
+
     // get next images of the set
     $images_to_add = array();
@@ -475,7 +475,7 @@
     {
       if ($zip_id != 0) continue; // here are already added images
-      array_push($images_to_add, $image_id);
-    }
-    
+      $images_to_add[] = $image_id;
+    }
+
     if (count($images_to_add))
     {
@@ -489,5 +489,5 @@
 ;';
       $images_to_add = hash_from_query($query, 'id');
-      
+
       if ($this->data['size'] != 'original')
       {
@@ -500,10 +500,10 @@
         $filesizes = hash_from_query($query, 'image_id');
       }
-      
+
       // open zip
       $this->updateParam('last_zip', $this->data['last_zip']+1);
       $zip_path = $this->getArchivePath();
       $zip = new myZip($zip_path, $this->conf['force_pclzip']);
-      
+
       // add images until size limit is reach, or all images are added
       $images_added = array();
@@ -516,5 +516,5 @@
           continue;
         }
-        
+
         if ($this->data['size'] == 'original')
         {
@@ -525,5 +525,5 @@
         {
           $src_image = new SrcImage($row); // don't give representive_ext
-          
+
           // no-image files
           if ($src_image->is_mimetype())
@@ -536,18 +536,18 @@
           {
             $derivative = new DerivativeImage($this->data['size'], $src_image);
-            
+
             $zip->addFile($derivative->get_path(), $this->getFilename($row, $filesizes[ $row['id'] ]));
             $total_size+= $filesizes[ $row['id'] ]['filesize'];
           }
         }
-        
-        array_push($images_added, $row['id']);
+
+        $images_added[] = $row['id'];
         $this->images[ $row['id'] ] = $this->data['last_zip'];
-        
+
         if ($total_size >= $this->conf['max_size']*1024 and !$force_one_archive) break;
       }
-      
+
       $this->updateParam('total_size', $this->data['total_size'] + $total_size);
-      
+
       // archive comment
       $comment = 'Generated on '.date('r').' with PHP '.PHP_VERSION.' by Piwigo Batch Downloader.';
@@ -558,7 +558,7 @@
       }
       $zip->setArchiveComment($comment);
-      
+
       $zip->close();
-      
+
       // update database
       $query = '
@@ -570,7 +570,7 @@
 ;';
       pwg_query($query);
-      
+
       trigger_action('batchdownload_end_zip', $this->data, $images_added); // triggered for each zip
-      
+
       // all images added ?
       if (count($images_to_add) == count($images_added))
@@ -578,9 +578,9 @@
         if ($this->conf['one_archive']) $this->updateParam('status', 'done');
         $done = true;
-        
+
         // over estimed
         $this->updateParam('nb_zip', $this->data['last_zip']);
       }
-      
+
       // under estimed
       if (!isset($done) && $this->data['status'] != 'done' && $this->data['last_zip'] == $this->data['nb_zip'])
@@ -588,5 +588,5 @@
         $this->updateParam('nb_zip', $this->data['last_zip']+1);
       }
-      
+
       return $zip_path;
     }
@@ -596,5 +596,5 @@
     }
   }
-  
+
   /**
    * getEstimatedTotalSize
@@ -606,7 +606,7 @@
     if ($this->data['nb_images'] == 0) return 0;
     if ( !empty($this->data['estimated_total_size']) and !$force ) return $this->data['estimated_total_size'];
-    
+
     $image_ids = array_slice(array_keys($this->images), 0, $this->conf['max_elements']);
-    
+
     if ($this->data['size'] == 'original')
     {
@@ -625,9 +625,9 @@
 ;';
     }
-    
+
     list($this->data['estimated_total_size']) = pwg_db_fetch_row(pwg_query($query));
     return $this->data['estimated_total_size'];
   }
-  
+
   /**
    * getEstimatedArchiveNumber
@@ -638,9 +638,9 @@
     if ($this->data['status'] == 'done') return $this->data['nb_zip'];
     if ( !empty($this->data['nb_zip']) and !$force ) return $this->data['nb_zip'];
-    
+
     $this->updateParam('nb_zip', ceil( $this->getEstimatedTotalSize($force) / ($this->conf['max_size']*1024) ));
     return $this->data['nb_zip'];
   }
-  
+
   /**
    * getDownloadList
@@ -653,33 +653,33 @@
       return '<b>'.l10n('No archive').'</b>';
     }
-    
+
     $root_url = get_root_url();
-    
+
     $out = '';
     for ($i=1; $i<=$this->getEstimatedArchiveNumber(); $i++)
     {
       $out.= '<li id="zip-'.$i.'">';
-      
+
       if ($this->data['status']=='done' or ($this->conf['one_archive'] and $i<$this->data['last_zip']+1))
       {
-        $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_error.png"> '.sprintf(l10n('Archive #%d (already downloaded)'), $i);
+        $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_error.png"> '.l10n('Archive #%d (already downloaded)', $i);
       }
       else if ($i==$this->data['last_zip']+1 or (!$this->conf['one_archive'] and $i<$this->data['last_zip']+1))
       {
-          $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"' 
-            .(($i!=1 and $this->conf['one_archive']) ? ' onClick="return confirm(\''.addslashes(sprintf(l10n('Starting download Archive #%d will destroy Archive #%d, be sure you finish the download. Continue ?'), $i, $i-1)).'\');"' : null).
-            '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_go.png"> '.sprintf(l10n('Archive #%d (ready)'), $i).'</a>';
+          $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'
+            .(($i!=1 and $this->conf['one_archive']) ? ' onClick="return confirm(\''.addslashes(l10n('Starting download Archive #%d will destroy Archive #%d, be sure you finish the download. Continue ?', $i, $i-1)).'\');"' : null).
+            '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_go.png"> '.l10n('Archive #%d (ready)', $i).'</a>';
       }
       else
       {
-        $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive.png"> '.sprintf(l10n('Archive #%d (pending)'), $i);
-      }
-      
+        $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive.png"> '.l10n('Archive #%d (pending)', $i);
+      }
+
       $out.= '</li>';
     }
-    
+
     return $out;
   }
-  
+
   /**
    * getArchivePath
@@ -693,8 +693,8 @@
       mkgetdir(BATCH_DOWNLOAD_LOCAL . 'u-' .$this->data['user_id']. '/');
     }
-    
+
     if ($i === null) $i = $this->data['last_zip'];
     $set = $this->getNames();
-    
+
     $path = BATCH_DOWNLOAD_LOCAL . 'u-'. $this->data['user_id'] . '/';
     $path.= !empty($this->conf['archive_prefix']) ? $this->conf['archive_prefix'] . '_' : null;
@@ -702,11 +702,11 @@
     $path.= $this->data['user_id'] . $this->data['id'];
     $path.= '_part' . $i . '.zip';
-    
+
     return $path;
   }
-  
+
   /**
    * getNames
-   * @return: array 
+   * @return: array
    *    NAME, set name with HTML
    *    sNAME, set name without HTML
@@ -715,5 +715,5 @@
    */
   function getNames()
-  {    
+  {
     switch ($this->data['type'])
     {
@@ -723,10 +723,10 @@
         global $conf, $page;
         $old_page = $page;
-        
+
         $fields = array(
           'created' => l10n('Creation date'),
           'posted' => l10n('Post date'),
           );
-        
+
         $chronology = explode('-', $this->data['type_id']);
         $page['chronology_field'] = $chronology[0];
@@ -734,5 +734,5 @@
         $page['chronology_view'] = $chronology[2];
         $page['chronology_date'] = array_splice($chronology, 3);
-        
+
         if (!class_exists('Calendar'))
         {
@@ -742,13 +742,13 @@
         $calendar->initialize('');
         $display_name = strip_tags($calendar->get_display_name());
-        
+
         $set['NAME'] = l10n('Calendar').': '.$fields[$page['chronology_field']].$display_name;
         $set['sNAME'] = l10n('Calendar').': '.ltrim($display_name, $conf['level_separator']);
         $set['BASENAME'] = 'calendar-'.$page['chronology_field'].'-'.implode('-',$page['chronology_date']);
-        
+
         $page = $old_page;
         break;
       }
-      
+
       // category
       case 'category':
@@ -765,5 +765,5 @@
           $set['sNAME'] = l10n('Album').': '.trigger_event('render_category_name', $category['name']);
           $set['COMMENT'] = trigger_event('render_category_description', $category['comment']);
-          
+
           if (!empty($category['permalink']))
           {
@@ -781,5 +781,5 @@
         break;
       }
-      
+
       // flat
       case 'flat':
@@ -789,5 +789,5 @@
         break;
       }
-      
+
       // tags
       case 'tags':
@@ -796,5 +796,5 @@
         $set['NAME'] = l10n('Tags').': ';
         $set['BASENAME'] = 'tags';
-        
+
         $first = true;
         foreach ($tags as $tag)
@@ -810,5 +810,5 @@
         break;
       }
-      
+
       // search
       case 'search':
@@ -818,5 +818,5 @@
         break;
       }
-      
+
       // favorites
       case 'favorites':
@@ -826,5 +826,5 @@
         break;
       }
-      
+
       // most_visited
       case 'most_visited':
@@ -834,5 +834,5 @@
         break;
       }
-      
+
       // best_rated
       case 'best_rated':
@@ -842,5 +842,5 @@
         break;
       }
-      
+
       // list
       case 'list':
@@ -850,5 +850,5 @@
         break;
       }
-      
+
       // recent_pics
       case 'recent_pics':
@@ -858,5 +858,5 @@
         break;
       }
-      
+
       // collection
       case 'collection':
@@ -868,5 +868,5 @@
           $infos = $UserCollection->getCollectionInfo();
           $set['NAME'] = l10n('Collection').': <a href="'.$infos['U_PUBLIC'].'">'.$UserCollection->getParam('name').'</a>';
-          
+
           if ( ($name = str2url($UserCollection->getParam('name'))) != null)
           {
@@ -886,12 +886,12 @@
       }
     }
-    
+
     if (!isset($set['sNAME']))    $set['sNAME'] = strip_tags($set['NAME']);
     if (!isset($set['COMMENT']))  $set['COMMENT'] = null;
     if (!isset($set['BASENAME'])) $set['BASENAME'] = $this->data['type'] . $this->data['type_id'];
-    
+
     return $set;
   }
-  
+
   /**
    * getSetInfo
@@ -899,5 +899,5 @@
    */
   function getSetInfo()
-  {    
+  {
     $set = array(
       'NB_IMAGES' =>     $this->data['nb_images'],
@@ -905,9 +905,9 @@
       'STATUS' =>        $this->data['status']=='ready' ? 'new' : $this->data['status'],
       'LAST_ZIP' =>      $this->data['last_zip'],
-      'TOTAL_SIZE' =>    $this->data['status']=='new' ? l10n('Unknown') : sprintf(l10n('%d MB'), ceil($this->getEstimatedTotalSize()/1024)),
+      'TOTAL_SIZE' =>    $this->data['status']=='new' ? l10n('Unknown') : l10n('%d MB', ceil($this->getEstimatedTotalSize()/1024)),
       'DATE_CREATION' => format_date($this->data['date_creation'], true),
       'SIZE' =>          $this->data['size'],
       );
-      
+
     if ($this->data['size'] != 'original')
     {
@@ -915,8 +915,8 @@
       $set['SIZE_INFO'] = $params->sizing->ideal_size[0].' x '.$params->sizing->ideal_size[1];
     }
-    
+
     return array_merge($set, $this->getNames());
   }
-  
+
   /**
    * delete
@@ -939,5 +939,5 @@
   private $lib;
   private $zip;
-  
+
   function __construct($zip_path, $pclzip=false)
   {
@@ -945,5 +945,5 @@
     {
       $this->lib = 'zipa';
-      
+
       $this->zip = new ZipArchive;
       if ($this->zip->open($zip_path, ZipArchive::CREATE) !== true)
@@ -955,21 +955,21 @@
     {
       $this->lib = 'pcl';
-      
+
       require_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
       $this->zip = new PclZip($zip_path);
-      
+
       // create a temporary file for archive creation
       touch(BATCH_DOWNLOAD_LOCAL.'temp.txt');
-      
+
       if ($this->zip->create(BATCH_DOWNLOAD_LOCAL.'temp.txt', PCLZIP_OPT_REMOVE_ALL_PATH) == 0)
       {
         trigger_error('BatchDownloader::createNextArchive, unable to open ZIP archive (PclZip)', E_USER_ERROR);
       }
-      
+
       unlink(BATCH_DOWNLOAD_LOCAL.'temp.txt');
       $this->zip->delete(PCLZIP_OPT_BY_NAME, 'temp.txt');
     }
   }
-  
+
   function addFile($path, $filename)
   {
@@ -983,5 +983,5 @@
     }
   }
-  
+
   function setArchiveComment($comment)
   {
@@ -991,5 +991,5 @@
     }
   }
-  
+
   function close()
   {
@@ -1000,4 +1000,2 @@
   }
 }
-
-?>
Index: /extensions/BatchDownloader/include/download.inc.php
===================================================================
--- /extensions/BatchDownloader/include/download.inc.php	(revision 25931)
+++ /extensions/BatchDownloader/include/download.inc.php	(revision 25932)
@@ -1,6 +1,4 @@
 <?php
 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!');
-
-# this file is called on public page #
 
 global $page, $template, $conf, $user;
@@ -11,10 +9,10 @@
   case 'init_zip':
   {
-    $template->set_filename('index', realpath(BATCH_DOWNLOAD_PATH . 'template/init_zip.tpl'));
-    
+    $template->set_filename('batchdwn', realpath(BATCH_DOWNLOAD_PATH . 'template/init_zip.tpl'));
+
     try
     {
       $BatchDownloader = new BatchDownloader($_GET['set_id']);
-      
+
       // delete set
       if ( isset($_GET['cancel']) )
@@ -26,5 +24,5 @@
         redirect(get_absolute_root_url());
       }
-      
+
       // prepare next zip
       if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'new' and $BatchDownloader->getParam('status') != 'done' )
@@ -35,5 +33,5 @@
           $BatchDownloader->createNextArchive();
         }
-        
+
         if ($conf['batch_download']['one_archive'])
         {
@@ -45,10 +43,10 @@
         }
       }
-      
+
       // alert limit overflow
       if ($BatchDownloader->getParam('nb_images') > $conf['batch_download']['max_elements'])
       {
-        $template->assign('elements_error', sprintf(
-          l10n('You choose to download %d pictures, but the system is limited to %d. You can edit the set, or the last %d pictures will not be downloaded.'),
+        $template->assign('elements_error', l10n(
+          'You choose to download %d pictures, but the system is limited to %d. You can edit the set, or the last %d pictures will not be downloaded.',
           $BatchDownloader->getParam('nb_images'),
           $conf['batch_download']['max_elements'],
@@ -61,5 +59,5 @@
         {
           $missing_derivatives = $BatchDownloader->getMissingDerivatives(true);
-        
+
           // generate missing files
           if (count($missing_derivatives))
@@ -73,5 +71,5 @@
           }
         }
-        
+
         // display download links
         if ($BatchDownloader->getParam('status') != 'new')
@@ -80,14 +78,14 @@
         }
       }
-      
+
       $set = $BatchDownloader->getSetInfo();
-      
+
       // link to the zip
       if (isset($next_file))
       {
         $set['U_DOWNLOAD'] = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&zip='.$_GET['zip'];
-        $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $set['U_DOWNLOAD']);
+        $page['infos'][] = l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>', $set['U_DOWNLOAD']);
       }
-      
+
       // link to edit page
       if ($BatchDownloader->getParam('status') != 'download' and $BatchDownloader->getParam('status') != 'done' and $BatchDownloader->getParam('nb_images') > 0)
@@ -95,11 +93,13 @@
         $set['U_EDIT_SET'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id']));
       }
-      
+
       // cancel link
-      if ($BatchDownloader->getParam('last_zip') != $BatchDownloader->getParam('nb_zip'))
+      if ($BatchDownloader->getParam('last_zip') != $BatchDownloader->getParam('nb_zip')
+        or (isset($missing_derivatives) and count($missing_derivatives))
+        )
       {
         $set['U_CANCEL'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$_GET['set_id'], 'cancel'=>'true'));
       }
-      
+
       $template->assign(array(
         'set' => $set,
@@ -109,16 +109,16 @@
     catch (Exception $e)
     {
-      array_push($page['errors'], $e->getMessage());
+      $page['errors'][] = $e->getMessage();
     }
-    
+
     break;
   }
-  
+
   /* edition page */
   case 'view':
   {
     $self_url = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id']));
-    
-    $template->set_filename('index', realpath(BATCH_DOWNLOAD_PATH . 'template/view.tpl'));
+
+    $template->set_filename('batchdwn', realpath(BATCH_DOWNLOAD_PATH . 'template/view.tpl'));
     $template->assign(array(
       'BATCH_DOWNLOAD_PATH' => BATCH_DOWNLOAD_PATH,
@@ -127,27 +127,27 @@
       'SET_ID' => $_GET['set_id'],
       ));
-    
+
     try
     {
       $BatchDownloader = new BatchDownloader($_GET['set_id']);
-      
+
       if ($BatchDownloader->getParam('status') != 'new' && $BatchDownloader->getParam('status') != 'ready')
       {
-        array_push($page['errors'], l10n('You can not edit this set'));
+        $page['errors'][] = l10n('You can not edit this set');
         break;
       }
-      
+
       if ( isset($_GET['remove']) and preg_match('#^[0-9]+$#', $_GET['remove']) )
       {
         $BatchDownloader->removeImages(array($_GET['remove']));
       }
-      
+
       $template->assign('set', $BatchDownloader->getSetInfo());
-      
+
       $template->set_prefilter('index_thumbnails', 'batch_download_thumbnails_list_prefilter');
-      
+
       $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0;
       $page['items'] = array_keys($BatchDownloader->getImages());
-      
+
       if (count($page['items']) > $page['nb_image_page'])
       {
@@ -161,12 +161,12 @@
         $template->assign('navbar', $page['navigation_bar']);
       }
-      
+
       include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
     }
     catch (Exception $e)
     {
-      array_push($page['errors'], $e->getMessage());
+      $page['errors'][] = $e->getMessage();
     }
-    
+
     break;
   }
@@ -178,4 +178,6 @@
   ));
 
+$template->assign_var_from_handle('CONTENT', 'batchdwn');
+
 
 function batch_download_thumbnails_list_prefilter($content, &$smarty)
@@ -185,5 +187,5 @@
   $replace = '$1
 {strip}<a class="removeSet" href="{$U_VIEW}&amp;remove={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow">
-{\'Remove from download set\'|@translate}&nbsp;<img src="{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/image_delete.png" title="{\'Remove from download set\'|@translate}">
+{\'Remove from download set\'|translate}&nbsp;<img src="{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/image_delete.png" title="{\'Remove from download set\'|translate}">
 </a>{/strip}';
 
@@ -193,4 +195,2 @@
   return preg_replace($search, $replace, $content);
 }
-
-?>
Index: /extensions/BatchDownloader/include/events.inc.php
===================================================================
--- /extensions/BatchDownloader/include/events.inc.php	(revision 25931)
+++ /extensions/BatchDownloader/include/events.inc.php	(revision 25932)
@@ -2,21 +2,21 @@
 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!');
 
-# this file contains all functions directly called by the triggers #
-
 /* define page section from url */
 function batch_download_section_init()
 {
   global $tokens, $page, $conf;
-  
+
   if ($tokens[0] == 'download')
   {
     if (check_download_access() === false) access_denied();
-    
-    add_event_handler('loc_begin_page_header', 'batch_download_page_header');
-    
+
+    $page['body_id'] = 'theBatchDownloader';
+    $page['is_external'] = true;
+    $page['is_homepage'] = false;
     $page['section'] = 'download';
+
     $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('Batch Downloader').$conf['level_separator'];
     $page['title'] = l10n('Batch Downloader');
-    
+
     switch (@$tokens[1])
     {
@@ -39,12 +39,6 @@
 }
 
-function batch_download_page_header()
-{
-  global $page;
-  $page['body_id'] = 'theBatchDownloader';
-}
-
 /* download section */
-function batch_download_page() 
+function batch_download_page()
 {
   global $page;
@@ -61,36 +55,36 @@
 {
   global $page, $template, $user, $conf;
-  
+
   // check accesses
   if ( !count($page['items']) or !isset($page['section']) ) return;
-  
+
   if (check_download_access() === false) return;
-  
+
   switch ($page['section'])
   {
   case 'categories':
     if (!isset($page['category']) && !isset($page['chronology_field'])) return; // don't download the full gallery in flat mode !
-    
+
     if (!in_array('categories', $conf['batch_download']['what'])) return;
     break;
-    
+
   case 'collections':
     if (!in_array('collections', $conf['batch_download']['what'])) return;
     break;
-    
+
   default:
     if (!in_array('specials', $conf['batch_download']['what'])) return;
   }
-  
-  
+
+
   // download the set
   if ( isset($_GET['action']) and $_GET['action']=='advdown_set' )
   {
     $set = get_set_info_from_page();
-    
+
     if ($set !== false && count($set['items']))
     {
       $BatchDownloader = new BatchDownloader('new', $set['items'], $set['type'], $set['id'], $set['size']);
-      
+
       if ($BatchDownloader->getParam('nb_images') != 0)
       {
@@ -103,11 +97,11 @@
         {
           $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
-          
+
           $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&zip=1';
-          
+
           $null = null;
           $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null);
-          
-          $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download);
+
+          $page['infos'][] = l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>', $u_download);
         }
         // otherwise we go to summary page
@@ -121,10 +115,10 @@
         $BatchDownloader->delete();
         unset($BatchDownloader);
-        
-        $page['errors'][] = sprintf(l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'), implode(', ', $conf['batch_download']['allowed_ext']));
+
+        $page['errors'][] = l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.', implode(', ', $conf['batch_download']['allowed_ext']));
       }
     }
   }
-  
+
   if ($page['section'] == 'collections')
   {
@@ -135,7 +129,7 @@
     $url = duplicate_index_url(array(), array('action'));
   }
-  
+
   $url = add_url_params($url, array('action'=>'advdown_set', 'down_size'=>''));
-  
+
   // toolbar button
   $template->assign(array(
@@ -144,5 +138,5 @@
     'BATCH_DWN_URL' => $url,
     ));
-  
+
   if ($conf['batch_download']['multisize'])
   {
@@ -175,5 +169,5 @@
     $template->assign('BATCH_DWN_SIZE', $conf['batch_download']['photo_size']);
   }
-    
+
   $template->set_filename('batchdwn_button', realpath(BATCH_DOWNLOAD_PATH.'template/download_button.tpl'));
   $button = $template->parse('batchdwn_button', true);
@@ -187,10 +181,10 @@
 {
   global $user;
-  
+
   $menu = &$menu_ref_arr[0];
   if ($menu->get_id() != 'menubar') return;
-  
+
   if (check_download_access() === false) return;
-  
+
   $query = '
 SELECT id
@@ -203,5 +197,5 @@
   $result = pwg_query($query);
   if (!pwg_db_num_rows($result)) return;
-  
+
   $menu->register_block(new RegisteredBlock('mbBatchDownloader', l10n('Batch Downloader'), 'BatchDownloader'));
 }
@@ -210,12 +204,12 @@
 {
   global $template, $conf, $user;
-  
+
   $menu = &$menu_ref_arr[0];
   $block = $menu->get_block('mbBatchDownloader');
-  
+
   if ($block != null)
   {
     $query = '
-SELECT id 
+SELECT id
   FROM '.BATCH_DOWNLOAD_TSETS.'
   WHERE
@@ -224,5 +218,5 @@
 ;';
     $sets = array_from_query($query, 'id');
-    
+
     $data = array();
     foreach ($sets as $set_id)
@@ -230,13 +224,13 @@
       $BatchDownloader = new BatchDownloader($set_id);
       $set = $BatchDownloader->getSetInfo();
-      
-      array_push($data, array(
+
+      $data[] = array(
         'URL' => add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))),
         'TITLE' => str_replace('"', "'", strip_tags($set['COMMENT'])),
         'NAME' => $set['sNAME'],
         'COUNT' => $set['NB_IMAGES'],
-        ));
-    }
-    
+        );
+    }
+
     $template->set_template_dir(BATCH_DOWNLOAD_PATH . 'template/');
     $block->set_title(l10n('Downloads'));
@@ -251,13 +245,13 @@
 {
   global $conf;
-  
+
   $time = time();
-  
+
   // we only search for old downloads every hour, nevermind which user is connected
   if ($conf['batch_download']['last_clean'] > $time - 3600) return;
-  
+
   $conf['batch_download']['last_clean'] = $time;
   conf_update_param('batch_download', serialize($conf['batch_download']));
-  
+
   // set old sets as done and clean images table
   $query = '
@@ -271,17 +265,17 @@
 ;';
   pwg_query($query);
-  
+
   $query = '
 UPDATE '.BATCH_DOWNLOAD_TSETS.'
   SET status = "done"
-  WHERE 
+  WHERE
     status != "done" AND
     date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR)
 ;';
   pwg_query($query);
-  
+
   // remove old archives
   $zips = glob(BATCH_DOWNLOAD_LOCAL . 'u-*/*.zip');
-  
+
   if (is_array($zips))
   {
@@ -300,5 +294,5 @@
 {
   if (!isset($_POST['action']) || $_POST['action']!='bd_remove_image') return;
-  
+
   check_status(ACCESS_CLASSIC);
 
@@ -320,7 +314,5 @@
     echo 'error';
   }
-  
+
   exit(0);
 }
-
-?>
Index: /extensions/BatchDownloader/include/functions.inc.php
===================================================================
--- /extensions/BatchDownloader/include/functions.inc.php	(revision 25931)
+++ /extensions/BatchDownloader/include/functions.inc.php	(revision 25932)
@@ -9,5 +9,5 @@
 {
   global $page, $conf;
-  
+
   switch ($page['section'])
   {
@@ -16,6 +16,6 @@
       {
         $batch_type = 'calendar';
-        $batch_id = add_well_known_params_in_url('', 
-          array_intersect_key($page, 
+        $batch_id = add_well_known_params_in_url('',
+          array_intersect_key($page,
             array(
               'chronology_field'=>0,
@@ -62,5 +62,5 @@
       return false;
   }
-  
+
   $set = array(
     'type' => $batch_type,
@@ -69,5 +69,5 @@
     'items' => $page['items'],
     );
-    
+
   // check size
   if (!$conf['batch_download']['multisize'])
@@ -87,5 +87,5 @@
       $avail_sizes[] = 'original';
     }
-    
+
     if (!in_array($set['size'], $avail_sizes))
     {
@@ -104,10 +104,10 @@
 {
   global $user, $conf;
-  
+
   if (is_a_guest()) return false;
   if (is_admin()) return true;
-  
+
   if ($user['level'] < $conf['batch_download']['level']) return false;
-  
+
   if (!empty($conf['batch_download']['groups']))
   {
@@ -119,8 +119,8 @@
 ;';
     $result = pwg_query($query);
-    
+
     if (!pwg_db_num_rows($result)) return false;
   }
-  
+
   return true;
 }
@@ -167,4 +167,2 @@
   }
 }
-
-?>
Index: tensions/BatchDownloader/include/install.inc.php
===================================================================
--- /extensions/BatchDownloader/include/install.inc.php	(revision 25931)
+++ 	(revision )
@@ -1,115 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-function batch_download_install() 
-{
-  global $conf, $prefixeTable;
-  
-  // configuration
-  if (empty($conf['batch_download']))
-  {
-    $batch_download_default_config = array(
-      'groups'          => array(),
-      'level'           => 0,
-      'what'            => array('categories','specials','collections'),
-      'photo_size'      => 'original',
-      'multisize'       => true,
-      'archive_prefix'  => 'piwigo',
-      'archive_timeout' => 48, /* hours */
-      'max_elements'    => 500,
-      'max_size'        => 100, /* MB */
-      'last_clean'      => time(),
-      'one_archive'     => false,
-      'force_pclzip'    => false,
-      'direct'          => false,
-      );
-      
-    $conf['batch_download'] = serialize($batch_download_default_config);
-    $conf['batch_download_comment'] = null;
-    
-    conf_update_param('batch_download', $conf['batch_download']);
-    conf_update_param('batch_download_comment', $conf['batch_download_comment']);
-  }
-  else
-  {
-    $new_conf = is_string($conf['batch_download']) ? unserialize($conf['batch_download']) : $conf['batch_download'];
-    
-    if (!isset($new_conf['what']))
-    {
-      $new_conf['what'] = array('categories','specials','collections');
-    }
-    if (!isset($new_conf['one_archive']))
-    {
-      $new_conf['one_archive'] = false;
-      $new_conf['force_pclzip'] = isset($conf['batch_download_force_pclzip']) && $conf['batch_download_force_pclzip'];
-      $new_conf['direct'] = isset($conf['batch_download_direct']) && $conf['batch_download_direct'];
-    }
-    if (!isset($new_conf['multisize']))
-    {
-      $new_conf['multisize'] = true;
-    }
-    
-    $conf['batch_download'] = serialize($new_conf);
-    conf_update_param('batch_download', $conf['batch_download']);
-  }
-
-  // archives directory
-  if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'))
-  {
-    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
-  }
-
-  // create tables
-  $query = '
-CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets` (
-  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
-  `user_id` smallint(5) NOT NULL,
-  `date_creation` datetime NOT NULL,
-  `type` varchar(16) NOT NULL,
-  `type_id` varchar(64) NOT NULL,
-  `size` varchar(16) NOT NULL DEFAULT "original",
-  `nb_zip` smallint(3) NOT NULL DEFAULT 0,
-  `last_zip` smallint(3) NOT NULL DEFAULT 0,
-  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
-  `total_size` int(10) NOT NULL DEFAULT 0,
-  `status` enum("new","ready","download","done") NOT NULL DEFAULT "new",
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
-;';
-  pwg_query($query);
-  
-  $query = '
-CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets_images` (
-  `set_id` mediumint(8) NOT NULL,
-  `image_id` mediumint(8) NOT NULL,
-  `zip` smallint(5) NOT NULL DEFAULT 0,
-  UNIQUE KEY `UNIQUE` (`set_id`,`image_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8
-;';
-  pwg_query($query);
-  
-  $query = '
-CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'image_sizes` (
-  `image_id` mediumint(8) NOT NULL,
-  `type` varchar(16) NOT NULL,
-  `width` smallint(9) NOT NULL,
-  `height` smallint(9) NOT NULL,
-  `filesize` mediumint(9) NOT NULL,
-  `filemtime` int(16) NOT NULL,
-  PRIMARY KEY (`image_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8
-;';
-  pwg_query($query);
-  
-  // add a "size" column to download_sets
-  $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'download_sets` LIKE "size";');
-  if (!pwg_db_num_rows($result))
-  {      
-    pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` ADD `size` varchar(16) NOT NULL DEFAULT "original";');
-  }
-  
-  // add "ready" status
-  pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` CHANGE `status` `status` enum("new","ready","download","done") NOT NULL DEFAULT "new";');
-}
-
-?>
Index: /extensions/BatchDownloader/main.inc.php
===================================================================
--- /extensions/BatchDownloader/main.inc.php	(revision 25931)
+++ /extensions/BatchDownloader/main.inc.php	(revision 25932)
@@ -1,3 +1,3 @@
-<?php 
+<?php
 /*
 Plugin Name: Batch Downloader
@@ -33,5 +33,5 @@
 {
   add_event_handler('init', 'batch_downloader_remove_image');
-  
+
   add_event_handler('loc_end_section_init', 'batch_download_section_init');
   add_event_handler('loc_end_index', 'batch_download_page');
@@ -40,8 +40,8 @@
 
   add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
+}
 
-  add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
-  add_event_handler('blockmanager_apply', 'batch_download_applymenu');
-}
+add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
+add_event_handler('blockmanager_apply', 'batch_download_applymenu');
 
 
@@ -57,32 +57,10 @@
 function batch_download_init()
 {
-  global $conf, $pwg_loaded_plugins;
-  
-  if (
-    BATCH_DOWNLOAD_VERSION == 'auto' or
-    $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'], BATCH_DOWNLOAD_VERSION, '<')
-  )
-  {
-    include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php');
-    batch_download_install();
-    
-    if ( $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] != 'auto' and BATCH_DOWNLOAD_VERSION != 'auto' )
-    {
-      $query = '
-UPDATE '. PLUGINS_TABLE .'
-SET version = "'. BATCH_DOWNLOAD_VERSION .'"
-WHERE id = "'. BATCH_DOWNLOAD_ID .'"';
-      pwg_query($query);
-      
-      $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] = BATCH_DOWNLOAD_VERSION;
-      
-      if (defined('IN_ADMIN'))
-      {
-        $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION;
-      }
-    }
-  }
-  
+  global $conf;
+
+  include_once(BATCH_DOWNLOAD_PATH . 'maintain.inc.php');
+  $maintain = new BatchDownloader_maintain(BATCH_DOWNLOAD_ID);
+  $maintain->autoUpdate(BATCH_DOWNLOAD_VERSION, 'install');
+
   $conf['batch_download'] = unserialize($conf['batch_download']);
   $conf['batch_download']['file_pattern'] = isset($conf['batch_download_file_pattern']) ? $conf['batch_download_file_pattern'] : '%id%_%filename%_%dimensions%';
@@ -92,5 +70,5 @@
     $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']);
   }
-  
+
   load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
 }
@@ -99,12 +77,10 @@
  * admin plugins menu
  */
-function batch_download_admin_menu($menu) 
+function batch_download_admin_menu($menu)
 {
-  array_push($menu, array(
+  $menu[] = array(
     'NAME' => 'Batch Downloader',
     'URL' => BATCH_DOWNLOAD_ADMIN,
-  ));
+  );
   return $menu;
 }
-
-?>
Index: /extensions/BatchDownloader/maintain.inc.php
===================================================================
--- /extensions/BatchDownloader/maintain.inc.php	(revision 25931)
+++ /extensions/BatchDownloader/maintain.inc.php	(revision 25932)
@@ -2,37 +2,144 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
-include_once(PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/include/install.inc.php');
+class BatchDownloader_maintain extends PluginMaintain
+{
+  private $installed = false;
 
-function plugin_install() 
-{
-  batch_download_install();
-  
-  define('batch_download_installed', true);
-}
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf, $prefixeTable;
 
-function plugin_activate()
-{
-  if (!defined('batch_download_installed'))
+    // configuration
+    if (empty($conf['batch_download']))
+    {
+      $batch_download_default_config = array(
+        'groups'          => array(),
+        'level'           => 0,
+        'what'            => array('categories','specials','collections'),
+        'photo_size'      => 'original',
+        'multisize'       => true,
+        'archive_prefix'  => 'piwigo',
+        'archive_timeout' => 48, /* hours */
+        'max_elements'    => 500,
+        'max_size'        => 100, /* MB */
+        'last_clean'      => time(),
+        'one_archive'     => false,
+        'force_pclzip'    => false,
+        'direct'          => false,
+        );
+
+      $conf['batch_download'] = serialize($batch_download_default_config);
+      $conf['batch_download_comment'] = null;
+
+      conf_update_param('batch_download', $conf['batch_download']);
+      conf_update_param('batch_download_comment', $conf['batch_download_comment']);
+    }
+    else
+    {
+      $new_conf = is_string($conf['batch_download']) ? unserialize($conf['batch_download']) : $conf['batch_download'];
+
+      if (!isset($new_conf['what']))
+      {
+        $new_conf['what'] = array('categories','specials','collections');
+      }
+      if (!isset($new_conf['one_archive']))
+      {
+        $new_conf['one_archive'] = false;
+        $new_conf['force_pclzip'] = isset($conf['batch_download_force_pclzip']) && $conf['batch_download_force_pclzip'];
+        $new_conf['direct'] = isset($conf['batch_download_direct']) && $conf['batch_download_direct'];
+      }
+      if (!isset($new_conf['multisize']))
+      {
+        $new_conf['multisize'] = true;
+      }
+
+      $conf['batch_download'] = serialize($new_conf);
+      conf_update_param('batch_download', $conf['batch_download']);
+    }
+
+    // archives directory
+    if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'))
+    {
+      mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+    }
+
+    // create tables
+    $query = '
+CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets` (
+  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
+  `user_id` smallint(5) NOT NULL,
+  `date_creation` datetime NOT NULL,
+  `type` varchar(16) NOT NULL,
+  `type_id` varchar(64) NOT NULL,
+  `size` varchar(16) NOT NULL DEFAULT "original",
+  `nb_zip` smallint(3) NOT NULL DEFAULT 0,
+  `last_zip` smallint(3) NOT NULL DEFAULT 0,
+  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
+  `total_size` int(10) NOT NULL DEFAULT 0,
+  `status` enum("new","ready","download","done") NOT NULL DEFAULT "new",
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
+;';
+    pwg_query($query);
+
+    $query = '
+CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets_images` (
+  `set_id` mediumint(8) NOT NULL,
+  `image_id` mediumint(8) NOT NULL,
+  `zip` smallint(5) NOT NULL DEFAULT 0,
+  UNIQUE KEY `UNIQUE` (`set_id`,`image_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+;';
+    pwg_query($query);
+
+    $query = '
+CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'image_sizes` (
+  `image_id` mediumint(8) NOT NULL,
+  `type` varchar(16) NOT NULL,
+  `width` smallint(9) NOT NULL,
+  `height` smallint(9) NOT NULL,
+  `filesize` mediumint(9) NOT NULL,
+  `filemtime` int(16) NOT NULL,
+  PRIMARY KEY (`image_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+;';
+    pwg_query($query);
+
+    // add a "size" column to download_sets
+    $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'download_sets` LIKE "size";');
+    if (!pwg_db_num_rows($result))
+    {
+      pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` ADD `size` varchar(16) NOT NULL DEFAULT "original";');
+    }
+
+    // add "ready" status
+    pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` CHANGE `status` `status` enum("new","ready","download","done") NOT NULL DEFAULT "new";');
+  }
+
+  function activate($plugin_version, &$errors=array())
   {
-    batch_download_install();
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
   }
-}
 
-function plugin_uninstall() 
-{
-  global $prefixeTable, $conf;
-  
-  pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = "batch_download" LIMIT 1;');
-  pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets`;');
-  pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets_images`;');
-  
-  rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
-}
+  function deactivate()
+  {
+  }
 
+  function uninstall()
+  {
+    global $prefixeTable, $conf;
 
-if (!function_exists('rrmdir'))
-{
-  function rrmdir($dir)
+    conf_delete_param('batch_download');
+
+    pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets`;');
+    pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets_images`;');
+
+    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
+  }
+
+  static function rrmdir($dir)
   {
     if (!is_dir($dir))
@@ -43,5 +150,5 @@
     $objects = scandir($dir);
     $return = true;
-    
+
     foreach ($objects as $object)
     {
@@ -49,9 +156,9 @@
       {
         $path = $dir.'/'.$object;
-        if (filetype($path) == 'dir') 
+        if (filetype($path) == 'dir')
         {
-          $return = $return && rrmdir($path); 
+          $return = $return && self::rrmdir($path);
         }
-        else 
+        else
         {
           $return = $return && @unlink($path);
@@ -59,8 +166,6 @@
       }
     }
-    
+
     return $return && @rmdir($dir);
   }
 }
-
-?>
Index: /extensions/BatchDownloader/template/download_button.tpl
===================================================================
--- /extensions/BatchDownloader/template/download_button.tpl	(revision 25931)
+++ /extensions/BatchDownloader/template/download_button.tpl	(revision 25932)
@@ -1,4 +1,4 @@
-<a href="{$BATCH_DWN_URL}{$BATCH_DWN_SIZE}" id="batchDownloadLink" title="{'Download all pictures of this selection'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
-  <span class="pwg-icon batch-downloader-icon" style="background:url('{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/zip.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Download'|@translate}</span>
+<a href="{$BATCH_DWN_URL}{$BATCH_DWN_SIZE}" id="batchDownloadLink" title="{'Download all pictures of this selection'|translate}" class="pwg-state-default pwg-button" rel="nofollow">
+  <span class="pwg-icon batch-downloader-icon" style="background:url('{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/zip.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Download'|translate}</span>
 </a>
 
@@ -7,5 +7,5 @@
 
 <div id="batchDownloadBox" class="switchBox" style="display:none">
-  <div class="switchBoxTitle">{'Download'|@translate} - {'Photo sizes'|@translate}</div>
+  <div class="switchBoxTitle">{'Download'|translate} - {'Photo sizes'|translate}</div>
   {foreach from=$BATCH_DWN_SIZES item=size name=loop}{if !$smarty.foreach.loop.first}<br>{/if}
   <a href="{$BATCH_DWN_URL}{$size.TYPE}" rel="nofollow">
@@ -18,9 +18,9 @@
 {footer_script require='jquery'}
 var batchdown_count = {$BATCH_DWN_COUNT};
-var batchdown_string = "{'Confirm the download of %d pictures?'|@translate}";
+var batchdown_string = "{'Confirm the download of %d pictures?'|translate}";
 
 {if isset($BATCH_DWN_SIZES)}
   (SwitchBox=window.SwitchBox||[]).push("#batchDownloadLink", "#batchDownloadBox");
-  
+
   jQuery("#batchDownloadBox a").click(function() {
     return confirm(batchdown_string.replace('%d', batchdown_count));
Index: /extensions/BatchDownloader/template/init_zip.tpl
===================================================================
--- /extensions/BatchDownloader/template/init_zip.tpl	(revision 25931)
+++ /extensions/BatchDownloader/template/init_zip.tpl	(revision 25932)
@@ -1,7 +1,9 @@
-{combine_css path=$BATCH_DOWNLOAD_PATH|@cat:"template/style.css"}
+{combine_css path=$BATCH_DOWNLOAD_PATH|cat:"template/style.css"}
 
 {if $set.U_DOWNLOAD}
 {footer_script}
-setTimeout("document.location.href = '{$set.U_DOWNLOAD}';", 1000);
+setTimeout(function() {
+  document.location.href = '{$set.U_DOWNLOAD}';
+}, 1000);
 {/footer_script}
 {/if}
@@ -12,16 +14,16 @@
 
 {footer_script}
-var derivatives = {ldelim}
+var derivatives = {
   elements: ["{'","'|@implode:$missing_derivatives}"],
   done: 0,
   total: {$missing_derivatives|@count},
-  
-  finished: function() {ldelim}
+
+  finished: function() {
     return derivatives.done == derivatives.total;
   }
 };
 
-function progress() {ldelim}
-  jQuery('#progressBar').progressBar(derivatives.done/derivatives.total*100, {ldelim}
+function progress() {
+  jQuery('#progressBar').progressBar(derivatives.done/derivatives.total*100, {
     width: 300,
     height: 24,
@@ -31,7 +33,6 @@
 }
 
-{literal}
-var queuedManager = jQuery.manageAjax.create('queued', { 
-  queue: true,  
+var queuedManager = jQuery.manageAjax.create('queued', {
+  queue: true,
   cacheResponse: false,
   maxRequests: 1
@@ -40,13 +41,17 @@
 function next_derivative() {
   if (derivatives.finished()) {
-    setTimeout("location.reload(true)", 1000);
+    setTimeout(function() {
+      location.reload(true);
+    }, 1000);
     return;
   }
-  
+
   queuedManager.add({
-    type: 'GET', 
-    url: derivatives.elements[ derivatives.done ], 
+    type: 'GET',
+    url: derivatives.elements[ derivatives.done ],
     dataType: 'json',
-    data: { ajaxload: 'true' },
+    data: {
+      ajaxload: 'true'
+    },
     success: function() {
       derivatives.done++;
@@ -63,23 +68,7 @@
 
 progress();
-setTimeout("next_derivative()", 1000);
-{/literal}{/footer_script}
+setTimeout(next_derivative, 1000);
+{/footer_script}
 
-{/if}
-
-
-{* <!-- Menubar & titrePage --> *}
-{if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/stripped.tpl'}
-  {assign var="clear" value="true"}
-{elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/simple.tpl'}
-  {assign var="clear" value="true"}
-{else}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/default.tpl'}
-{/if}
-
-{if isset($errors) or not empty($infos)}
-{include file='infos_errors.tpl'}
 {/if}
 
@@ -87,15 +76,15 @@
 {if $set}
 <fieldset>
-  <legend>{'Download info'|@translate}</legend>
+  <legend>{'Download info'|translate}</legend>
   <h2>{$set.NAME}</h2>
   {if $set.COMMENT}<blockquote class="comment">{$set.COMMENT}</blockquote>{/if}
-  
+
   <ul class="set-infos">
     <li class="error">{$elements_error}</li>
-    <li><b>{'%d photos'|@translate|@sprintf:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|@translate}</a>{/if}</li>
-    <li><b>{'Photo sizes'|@translate}:</b> {if $set.SIZE=='original'}{'Original'|@translate}{else}{$set.SIZE|@translate}{/if} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>
-    <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE}</li>
-    <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li>
-    <li><b>{'Created on'|@translate}:</b> {$set.DATE_CREATION}</li>
+    <li><b>{'%d photos'|translate:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|translate}</a>{/if}</li>
+    <li><b>{'Photo sizes'|translate}:</b> {if $set.SIZE=='original'}{'Original'|translate}{else}{$set.SIZE|translate}{/if} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>
+    <li><b>{'Estimated size'|translate}:</b> {$set.TOTAL_SIZE}</li>
+    <li><b>{'Estimated number of archives'|translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|translate})</i></li>
+    <li><b>{'Created on'|translate}:</b> {$set.DATE_CREATION}</li>
   </ul>
 </fieldset>
@@ -103,28 +92,24 @@
 {if $missing_derivatives}
 <fieldset>
-  <legend>{'Preparation'|@translate}</legend>
-  
-  <p>{'Please wait, your download is being prepared. This page will automatically refresh when it is ready.'|@translate}</p>
-  
+  <legend>{'Preparation'|translate}</legend>
+
+  <p>{'Please wait, your download is being prepared. This page will automatically refresh when it is ready.'|translate}</p>
+
   <div id="progressBar"></div>
-  
-  <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>
+
+  <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|translate}');">{'Cancel this download'|translate}</a>
 </fieldset>
 
 {elseif $zip_links}
 <fieldset>
-  <legend>{'Download links'|@translate}</legend>
-  
+  <legend>{'Download links'|translate}</legend>
+
   <ul class="download-links">
     {$zip_links}
-    <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|@translate|@sprintf:$archive_timeout}</li>
+    <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|translate:$archive_timeout}</li>
   </ul>
-  
-  {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>{/if}
+
+  {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|translate}');">{'Cancel this download'|translate}</a>{/if}
 </fieldset>
 {/if}
 {/if}
-
-{if $clear}<div style="clear: both;"></div>
-</div>{/if}
-</div>{* <!-- content --> *}
Index: /extensions/BatchDownloader/template/style.css
===================================================================
--- /extensions/BatchDownloader/template/style.css	(revision 25931)
+++ /extensions/BatchDownloader/template/style.css	(revision 25932)
@@ -38,5 +38,5 @@
     border-color:#f00;
   }
-  
+
 .downloadSizeDetails {
   font-style:italic;
Index: /extensions/BatchDownloader/template/thumbnails_css_js.tpl
===================================================================
--- /extensions/BatchDownloader/template/thumbnails_css_js.tpl	(revision 25931)
+++ /extensions/BatchDownloader/template/thumbnails_css_js.tpl	(revision 25932)
@@ -1,38 +1,39 @@
-{html_style}
-#thumbnails li {ldelim} position:relative !important;display:inline-block; }
-li .removeSet {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; }
-li:hover .removeSet {ldelim} display:block !important; }
-{/html_style}
+{html_style}{literal}
+#thumbnails li { position:relative !important;display:inline-block; }
+li .removeSet { width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; }
+li:hover .removeSet { display:block !important; }
+{/literal}{/html_style}
 
 {footer_script require='jquery'}
-jQuery(".removeSet").click(function() {ldelim}
+jQuery(".removeSet").click(function() {
   var toggle_id = jQuery(this).data("id");
   var $trigger = jQuery(this);
-  
-  jQuery.ajax({ldelim}
+
+  jQuery.ajax({
     type: "POST",
     url: "{$ROOT_URL}index.php",
-    data: {ldelim}
+    data: {
       action: "bd_remove_image",
       set_id: "{$SET_ID}",
       toggle_id: toggle_id
     },
-    success: function(msg) {ldelim}
-      if (msg == "ok") {ldelim}
-        $trigger.parent("li").hide("fast", function() {ldelim}
+    success: function(msg) {
+      if (msg == "ok") {
+        $trigger.parent("li").hide("fast", function() {
           jQuery(this).remove();
           if (typeof GThumb != "undefined") GThumb.build();
         });
-        
+
         jQuery(".nbImagesSet").html(parseInt(jQuery(".nbImagesSet").html()) -1);
-      } else {ldelim}
-        $trigger.html('{'Un unknown error occured'|@translate}');
+      }
+      else {
+        $trigger.html('{'Un unknown error occured'|translate}');
       }
     },
-    error: function() {ldelim}
-      $trigger.html('{'Un unknown error occured'|@translate}');
+    error: function() {
+      $trigger.html('{'Un unknown error occured'|translate}');
     }
   });
-  
+
   return false;
 });
Index: /extensions/BatchDownloader/template/view.tpl
===================================================================
--- /extensions/BatchDownloader/template/view.tpl	(revision 25931)
+++ /extensions/BatchDownloader/template/view.tpl	(revision 25932)
@@ -1,17 +1,2 @@
-{* <!-- Menubar & titrePage --> *}
-{if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/stripped.tpl'}
-  {assign var="clear" value="true"}
-{elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/simple.tpl'}
-  {assign var="clear" value="true"}
-{else}
-  {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/default.tpl'}
-{/if}
-
-{if isset($errors) or not empty($infos)}
-{include file='infos_errors.tpl'}
-{/if}
-
 {if $set}
 <fieldset>
@@ -19,7 +4,7 @@
   {if $set.COMMENT}<blockquote>{$set.COMMENT}</blockquote>{/if}
   {assign var="nb_images" value='<span class="nbImagesSet">'|@cat:$set.NB_IMAGES|@cat:'</span>'}
-  {'%d photos'|@translate|replace:'%d':'%s'|sprintf:$nb_images}
+  {'%d photos'|translate|replace:'%d':'%s'|sprintf:$nb_images}
   <br>
-  <b><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'|@translate} →</a></b>
+  <b><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'|translate} →</a></b>
 </fieldset>
 
@@ -30,11 +15,7 @@
 </ul>
 {else}
-{'This download set is empty'|@translate}
+{'This download set is empty'|translate}
 {/if}
 
 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
 {/if}
-
-{if $clear}<div style="clear: both;"></div>
-</div>{/if}
-</div>{* <!-- content --> *}
