Index: /extensions/flickr2piwigo/admin.php
===================================================================
--- /extensions/flickr2piwigo/admin.php	(revision 26179)
+++ /extensions/flickr2piwigo/admin.php	(revision 26180)
@@ -1,8 +1,7 @@
 <?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+defined('FLICKR_PATH') or die('Hacking attempt!');
 
 global $template, $page, $conf;
 
-$conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']);
 load_language('plugin.lang', FLICKR_PATH);
 
@@ -15,5 +14,5 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'import';
-  
+
 $tabsheet = new tabsheet();
 $tabsheet->add('import', l10n('Import'), FLICKR_ADMIN . '-import');
@@ -31,5 +30,4 @@
   'FLICKR_ADMIN' => FLICKR_ADMIN,
   ));
+
 $template->assign_var_from_handle('ADMIN_CONTENT', 'flickr2piwigo');
-
-?>
Index: /extensions/flickr2piwigo/admin/config.php
===================================================================
--- /extensions/flickr2piwigo/admin/config.php	(revision 26179)
+++ /extensions/flickr2piwigo/admin/config.php	(revision 26180)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+defined('FLICKR_PATH') or die('Hacking attempt!');
 
 if (isset($_POST['save_config']))
@@ -21,5 +21,3 @@
 
 
-$template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/config.tpl');
-
-?>
+$template->set_filename('flickr2piwigo', realpath(FLICKR_PATH . 'admin/template/config.tpl'));
Index: /extensions/flickr2piwigo/admin/import.php
===================================================================
--- /extensions/flickr2piwigo/admin/import.php	(revision 26179)
+++ /extensions/flickr2piwigo/admin/import.php	(revision 26180)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+defined('FLICKR_PATH') or die('Hacking attempt!');
 
 set_time_limit(600);
@@ -7,12 +7,12 @@
 
 // check API parameters and connect to flickr
-if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) )
-{
-  array_push($page['warnings'], l10n('Please fill your API keys on the configuration tab'));
+if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']))
+{
+  $page['warnings'][] = l10n('Please fill your API keys on the configuration tab');
   $_GET['action'] = 'error';
 }
-else if ( !test_remote_download() )
-{
-  array_push($page['errors'], l10n('No download method available'));
+else if (!test_remote_download())
+{
+  $page['errors'][] = l10n('No download method available');
   $_GET['action'] = 'error';
 }
@@ -23,5 +23,5 @@
   $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
   $flickr->enableCache('fs', FLICKR_FS_CACHE);
-  
+
   // must authenticate
   $u = $flickr->test_login();
@@ -30,15 +30,18 @@
     $_GET['action'] = 'init_login';
   }
-  
+
   // generate token after authentication
   if (!empty($_GET['frob']))
   {
     $flickr->auth_getToken($_GET['frob']);
-    $_GET['action'] = 'logued';
-  }
-}
-
-
-if (!isset($_GET['action'])) $_GET['action'] = 'main';
+    $_GET['action'] = 'logged';
+  }
+}
+
+
+if (!isset($_GET['action']))
+{
+  $_GET['action'] = 'main';
+}
 
 
@@ -51,5 +54,5 @@
     break;
   }
-  
+
   // call flickr login procedure
   case 'login':
@@ -58,7 +61,7 @@
     break;
   }
-  
+
   // message after login
-  case 'logued':
+  case 'logged':
   {
     $_SESSION['page_infos'][] = l10n('Successfully logged in to you Flickr account');
@@ -66,5 +69,5 @@
     break;
   }
-  
+
   // logout
   case 'logout':
@@ -75,5 +78,5 @@
     break;
   }
-  
+
   // main menu
   case 'main':
@@ -89,5 +92,5 @@
     break;
   }
-  
+
   // list user albums
   case 'list_albums':
@@ -97,5 +100,5 @@
     $total_albums = $albums['total'];
     $albums = $albums['photoset'];
-    
+
     foreach ($albums as &$album)
     {
@@ -103,10 +106,10 @@
     }
     unset($album);
-    
+
     // not classed
     $wo_albums = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 1);
     if ($wo_albums['photos']['total'] > 0)
     {
-      array_push($albums, array(
+      $albums[] = array(
         'id' => 'not_in_set',
         'title' => l10n('Pictures without album'),
@@ -114,7 +117,7 @@
         'photos' => $wo_albums['photos']['total'],
         'U_LIST' => FLICKR_ADMIN . '-import&amp;action=list_photos&amp;album=not_in_set',
-        ));
-    }
-    
+        );
+    }
+
     $template->assign(array(
       'total_albums' => $total_albums,
@@ -123,5 +126,5 @@
     break;
   }
-  
+
   // list photos of an album
   case 'list_photos':
@@ -130,5 +133,5 @@
     $flickr_prefix = 'flickr-'.$u['username'].'-';
     $flickr_root_url = $flickr->urls_getUserPhotos($u['id']);
-    
+
     // pagination
     if (isset($_GET['start']))   $page['start'] = intval($_GET['start']);
@@ -136,5 +139,5 @@
     if (isset($_GET['display'])) $page['display'] = $_GET['display']=='all' ? 500 : intval($_GET['display']);
     else                         $page['display'] = 20;
-    
+
     // get photos
     if ($_GET['album'] == 'not_in_set')
@@ -148,5 +151,5 @@
       $all_photos = $all_photos['photoset']['photo'];
     }
-    
+
     // get existing photos
     $query = '
@@ -157,5 +160,5 @@
     $existing_photos = simple_hash_from_query($query, 'id', 'file');
     $existing_photos = array_map(create_function('$p', 'return preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos);
-    
+
     // remove existing photos
     $duplicates = 0;
@@ -168,16 +171,19 @@
       }
     }
-    
+
     if ($duplicates>0)
     {
-      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;prefilter=flickr">'
-          .l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates)
+      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;filter=prefilter-flickr">'
+          .l10n_dec(
+            'One picture is not displayed because already existing in the database.',
+            '%d pictures are not displayed because already existing in the database.',
+            $duplicates)
         .'</a>';
     }
-    
+
     // displayed photos
     $page_photos = array_slice($all_photos, $page['start'], $page['display']);
     $all_elements = array_map(create_function('$p', 'return  \'"\'.$p["id"].\'"\';'), $all_photos);
-    
+
     foreach ($page_photos as &$photo)
     {
@@ -187,5 +193,5 @@
     }
     unset($photo);
-    
+
     $template->assign(array(
       'nb_thumbs_set' => count($all_photos),
@@ -197,5 +203,5 @@
       'U_DISPLAY' => $self_url,
       ));
-      
+
     // get piwigo categories
     $query = '
@@ -204,5 +210,5 @@
 ;';
     display_select_cat_wrapper($query, array(), 'category_parent_options');
-    
+
     // get navbar
     $nav_bar = create_navigation_bar(
@@ -215,14 +221,14 @@
     break;
   }
-  
+
   // list all photos of the user
   case 'list_all':
   {
     $flickr_prefix = 'flickr-'.$u['username'].'-';
-    
+
     // get all photos in all albums
     $all_albums = $flickr->photosets_getList($u['id']);
     $all_albums = $all_albums['photoset'];
-    
+
     $all_photos = array();
     foreach ($all_albums as $album)
@@ -230,5 +236,5 @@
       $album_photos = $flickr->photosets_getPhotos($album['id'], NULL, NULL, 500, NULL, 'photos');
       $album_photos = $album_photos['photoset']['photo'];
-      
+
       foreach ($album_photos as $photo)
       {
@@ -236,5 +242,5 @@
       }
     }
-    
+
     // get existing photos
     $query = '
@@ -245,5 +251,5 @@
     $existing_photos = simple_hash_from_query($query, 'id', 'file');
     $existing_photos = array_map(create_function('$p', 'return preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos);
-    
+
     // remove existing photos
     $duplicates = 0;
@@ -265,18 +271,21 @@
     unset($photo);
     $all_photos = array_values($all_photos);
-    
+
     if ($duplicates>0)
     {
-      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;prefilter=flickr">'
-          .l10n_dec('%d picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates)
+      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;filter=prefilter-flickr">'
+          .l10n_dec(
+            'One picture is not displayed because already existing in the database.',
+            '%d pictures are not displayed because already existing in the database.',
+            $duplicates)
         .'</a>';
     }
-    
+
     $template->assign(array(
       'nb_elements' => count($all_photos),
-      'all_elements' => json_encode($all_photos),
+      'all_elements' => $all_photos,
       'F_ACTION' => FLICKR_ADMIN . '-import&amp;action=import_set',
       ));
-      
+
     // get piwigo categories
     $query = '
@@ -287,5 +296,5 @@
     break;
   }
-  
+
   // success message after import
   case 'import_set':
@@ -293,5 +302,5 @@
     if (isset($_POST['done']))
     {
-      $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']);
+      $_SESSION['page_infos'][] = l10n('%d pictures imported', $_POST['done']);
     }
     redirect(FLICKR_ADMIN . '-import');
@@ -300,10 +309,5 @@
 
 
-$template->assign(array(
-  'ACTION' => $_GET['action'],
-  'GMAPS_LOADED' => !empty($pwg_loaded_plugins['rv_gmaps']) || !empty($pwg_loaded_plugins['piwigo-openstreetmap']),
-  ));
-
-$template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/import.tpl');
-
-?>
+$template->assign('ACTION', $_GET['action']);
+
+$template->set_filename('flickr2piwigo', realpath(FLICKR_PATH . 'admin/template/import.tpl'));
Index: /extensions/flickr2piwigo/admin/template/config.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/config.tpl	(revision 26179)
+++ /extensions/flickr2piwigo/admin/template/config.tpl	(revision 26180)
@@ -1,3 +1,3 @@
-{combine_css path=$FLICKR_PATH|@cat:"admin/template/style.css"}
+{combine_css path=$FLICKR_PATH|cat:'admin/template/style.css'}
 
 <div class="titrePage">
@@ -7,10 +7,10 @@
 <form method="post" action="" class="properties">
 <fieldset>
-  <legend>{'Flickr logins'|@translate}</legend>
-  
+  <legend>{'Flickr logins'|translate}</legend>
+
   <ul>
     <li>
       <label>
-        <span class="property">{'API key'|@translate}</span>
+        <span class="property">{'API key'|translate}</span>
         <input type="text" name="api_key" value="{$flickr2piwigo.api_key}" size="40">
       </label>
@@ -19,5 +19,5 @@
     <li>
       <label>
-        <span class="property">{'API secret'|@translate}</span>
+        <span class="property">{'API secret'|translate}</span>
         <input type="text" name="secret_key" value="{$flickr2piwigo.secret_key}" size="20">
       </label>
@@ -26,12 +26,12 @@
 </fieldset>
 
-<p><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>
+<p><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p>
 
 <fieldset>
-  <legend>{'How do I get my Flickr API key?'|@translate}</legend>
-  
-  <p><b>{'Callback URL'|@translate} :</b> <span style="font-family:monospace;font-size:14px;">{$FLICKR_CALLBACK}</span></p>
+  <legend>{'How do I get my Flickr API key?'|translate}</legend>
+
+  <p><b>{'Callback URL'|translate} :</b> <span style="font-family:monospace;font-size:14px;">{$FLICKR_CALLBACK}</span></p>
   {$FLICKR_HELP_CONTENT}
 </fieldset>
-  
+
 </form>
Index: /extensions/flickr2piwigo/admin/template/import.list_all.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/import.list_all.tpl	(revision 26179)
+++ /extensions/flickr2piwigo/admin/template/import.list_all.tpl	(revision 26180)
@@ -1,108 +1,118 @@
 {footer_script require='jquery.ajaxmanager,jquery.jgrowl'}
-/* global vars */
-var errorHead   = '{'ERROR'|@translate|@escape:'javascript'}';
-var errorMsg    = '{'an error happened'|@translate|@escape:'javascript'}';
-var successHead = '{'Success'|@translate|@escape:'javascript'}';
+(function($){
+  /* global vars */
+  var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}];
+  var import_done = 0;
+  var import_selected = {$nb_elements};
+  var queuedManager = $.manageAjax.create('queued', {
+    queue: true,
+    maxRequests: 1
+  });
 
-var import_done = 0;
-var import_selected = {$nb_elements};
-var queuedManager = jQuery.manageAjax.create('queued', {ldelim}
-  queue: true,  
-  maxRequests: 1
-});
+  /* import queue */
+  function performImport(photo, album, fills) {
+    queuedManager.add({
+      type: 'GET',
+      dataType: 'json',
+      url: 'ws.php',
+      data: {
+        method: 'pwg.images.addFlickr',
+        id: photo,
+        category: album,
+        fills: fills,
+        format: 'json'
+      },
+      success: function(data) {
+        if (data['stat'] == 'ok') {
+          $.jGrowl(data['result'], {
+            theme: 'success', life: 4000, sticky: false,
+            header: '{'Success'|translate}',
+          });
+          $("#photo-"+photo.id).fadeOut(function(){ $(this).remove(); });
+        }
+        else {
+          $.jGrowl(data['result'], {
+            theme: 'error', sticky: true,
+            header: '{'ERROR'|translate}'
+          });
+        }
 
-{literal}
-/* import queue */
-function performImport(photo, album, fills) {
-  queuedManager.add({
-    type: 'GET',
-    dataType: 'json',
-    url: 'ws.php',
-    data: { method: 'pwg.images.addFlickr', id: photo, category: album, fills: fills, format: 'json' },
-    success: function(data) {
-      if (data['stat'] == 'ok') {
-        jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false });
-        jQuery("#photo-"+photo.id).fadeOut(function(){ $(this).remove(); });
-      } else {
-        jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true });
+        import_done++;
+        $("#progress").html(import_done +"/"+ import_selected);
+
+        if (import_done == import_selected) {
+          $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
+          $("#import_form").submit();
+        }
+      },
+      error: function(data) {
+        $.jGrowl('{'an error happened'|translate|escape:'javascript'}', {
+          theme: 'error', sticky: true,
+          header: '{'ERROR'|translate}'
+        });
       }
-      
-      import_done++;
-      $("#progress").html(import_done +"/"+ import_selected);
-      
-      if (import_done == import_selected) {
-        $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
-        $("#import_form").submit();
-      }
-    },
-    error: function(data) {
-      jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true });
-    }
-  });
-}
+    });
+  }
 
+  /* begin import */
+  $('#beginImport').click(function() {
+    $("#loader_import").fadeIn();
 
-$(document).ready(function() {
-  //var all_elements = jQuery.parseJSON('{/literal}{$all_elements}{literal}');
-  var all_elements = {/literal}{$all_elements}{literal};
-  
-  /* begin import */
-  jQuery('#beginImport').click(function() {
-    $("#loader_import").fadeIn();
-    
     if ($("input[name='album_mode']:checked").val() == 'identical') {
       var album = 0;
-    } else {
+    }
+    else {
       var album = $("#albumSelect option:selected").val();
     }
-    
+
     var fills = '';
     $("input[name^='fill_']:checked").each(function() {
       fills+= $(this).attr("name") +',';
-    }); 
-    
+    });
+
     import_selected = all_elements.length;
     $("#progress").html("0/"+ import_selected);
-    
+
     for (var i in all_elements) {
       if (album == 0) this_album = all_elements[i]['albums'];
       else            this_album = album;
-      
+
       performImport(all_elements[i]['id'], this_album, fills);
     }
-    
+
     return false;
   });
-  
+
   /* album mode */
   $("input[name='album_mode']").change(function() {
     if ($(this).val() == 'one_album') {
       $("#albumSelectWrapper").slideDown();
-    } else {
+    }
+    else {
       $("#albumSelectWrapper").slideUp();
     }
   });
-});
-{/literal}
+}(jQuery));
 {/footer_script}
+
 
 <form action="{$F_ACTION}" method="post" id="import_form">
 
   <fieldset>
-    <legend>{'Selection'|@translate}</legend>
+    <legend>{'Selection'|translate}</legend>
 
   {if $nb_elements}
-    {'%d elements ready for importation'|@translate|@sprintf:$nb_elements}
+    {'%d elements ready for importation'|translate:$nb_elements}
   {else}
-    <div>{'No photo in the current set.'|@translate}</div>
+    <div>{'No photo in the current set.'|translate}</div>
   {/if}
   </fieldset>
-  
+
   <fieldset>
-    <legend>{'Import options'|@translate}</legend>
-    
+    <legend>{'Import options'|translate}</legend>
+
     <p>
-      <label><input type="radio" name="album_mode" value="identical" checked="checked"> {'Reproduce flickr albums'|@translate}</label><br>
-      <label><input type="radio" name="album_mode" value="one_album"> {'Import all photos in this album'|@translate} :</label>
+      <label><input type="radio" name="album_mode" value="identical" checked="checked"> {'Reproduce flickr albums'|translate}</label><br>
+      <label><input type="radio" name="album_mode" value="one_album"> {'Import all photos in this album'|translate} :</label>
     </p>
 
@@ -111,21 +121,21 @@
         {html_options options=$category_parent_options}
       </select>
-      {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
+      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
     </p>
-    
+
     <p>
-      <b>{'Fill these fields from Flickr datas'|@translate}:</b>
-      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|@translate}</label>
-      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|@translate}</label>
-      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|@translate}</label>
-      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|@translate}</label>
-      <label><input type="checkbox" name="fill_posted"> {'Post date'|@translate}</label>
+      <b>{'Fill these fields from Flickr datas'|translate}:</b>
+      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|translate}</label>
+      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|translate}</label>
+      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|translate}</label>
+      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|translate}</label>
+      <label><input type="checkbox" name="fill_posted"> {'Post date'|translate}</label>
       <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label>
-      {if $GMAPS_LOADED}<label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>{/if}
+      <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>
     </p>
-    
+
     <p>
-      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|@translate}" {if not $nb_elements}style="display:none;"{/if}>
-      <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i> <span id="progress"></span></span>
+      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|translate}" {if not $nb_elements}style="display:none;"{/if}>
+      <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i> <span id="progress"></span></span>
     </p>
   </fieldset>
Index: /extensions/flickr2piwigo/admin/template/import.list_photos.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/import.list_photos.tpl	(revision 26179)
+++ /extensions/flickr2piwigo/admin/template/import.list_photos.tpl	(revision 26180)
@@ -1,29 +1,18 @@
 {footer_script require='jquery.ajaxmanager,jquery.jgrowl'}
-/* global vars */
-var nb_thumbs_page = {$nb_thumbs_page};
-var nb_thumbs_set = {$nb_thumbs_set};
-var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}];
-
-var errorHead   = '{'ERROR'|@translate|@escape:'javascript'}';
-var errorMsg    = '{'an error happened'|@translate|@escape:'javascript'}';
-var successHead = '{'Success'|@translate|@escape:'javascript'}';
-var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
-var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
-var selectedMessage_all = "{'All %d photos are selected'|@translate}";
-var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
-
-var import_done = 0;
-var import_selected = 0;
-var queuedManager = jQuery.manageAjax.create('queued', {ldelim}
-  queue: true,  
-  maxRequests: 1
-});
-
-{literal}
-/* Shift-click: select all photos between the click and the shift+click */
-jQuery(document).ready(function() {
+(function($){
+  /* global vars */
+  var nb_thumbs_set = {$nb_thumbs_set};
+  var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}];
+  var import_done = 0;
+  var import_selected = 0;
+  var queuedManager = $.manageAjax.create('queued', {ldelim}
+    queue: true,
+    maxRequests: 1
+  });
+
+  /* Shift-click: select all photos between the click and the shift+click */
   var last_clicked=0;
   var last_clickedstatus=true;
-  jQuery.fn.enableShiftClick = function() {
+  $.fn.enableShiftClick = function() {
     var inputs = [];
     var count=0;
@@ -44,10 +33,8 @@
             input = $(inputs[i]);
             $(input).attr('checked', last_clickedstatus);
-            if (last_clickedstatus)
-            {
+            if (last_clickedstatus) {
               $(input).siblings("span.wrap2").addClass("thumbSelected");
             }
-            else
-            {
+            else {
               $(input).siblings("span.wrap2").removeClass("thumbSelected");
             }
@@ -60,138 +47,108 @@
         return true;
       });
-      $(this).click(function(event) {$(this).triggerHandler("shclick",event)});
+      $(this).click(function(event) { $(this).triggerHandler("shclick",event); });
     });
   }
-});
-
-/* sprintf */
-function str_repeat(i, m) {
-    for (var o = []; m > 0; o[--m] = i);
-    return o.join('');
-}
-
-function sprintf() {
-  var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
-  while (f) {
-    if (m = /^[^\x25]+/.exec(f)) {
-      o.push(m[0]);
-    }
-    else if (m = /^\x25{2}/.exec(f)) {
-      o.push('%');
-    }
-    else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
-      if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
-        throw('Too few arguments.');
-      }
-      if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
-        throw('Expecting number but found ' + typeof(a));
-      }
-      switch (m[7]) {
-        case 'b': a = a.toString(2); break;
-        case 'c': a = String.fromCharCode(a); break;
-        case 'd': a = parseInt(a); break;
-        case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
-        case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
-        case 'o': a = a.toString(8); break;
-        case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
-        case 'u': a = Math.abs(a); break;
-        case 'x': a = a.toString(16); break;
-        case 'X': a = a.toString(16).toUpperCase(); break;
-      }
-      a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
-      c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
-      x = m[5] - String(a).length - s.length;
-      p = m[5] ? str_repeat(c, x) : '';
-      o.push(s + (m[4] ? a + p : p + a));
-    }
-    else {
-      throw('Huh ?!');
-    }
-    f = f.substring(m[0].length);
-  }
-  return o.join('');
-}
-
-/* update displaying */
-function checkPermitAction() {
-  var nbSelected = 0;
-  if ($("input[name=setSelected]").is(':checked')) {
-    nbSelected = nb_thumbs_set;
-  } else {
-    $(".thumbnails input[type=checkbox]").each(function() {
-      if ($(this).is(':checked')) nbSelected++;
-    });
-  }
-
-  if (nbSelected == 0) {
-    $("#beginImport").hide();
-  } else {
-    $("#beginImport").show();
-  }
-
-  $("#applyOnDetails").text(
-    sprintf(
-      applyOnDetails_pattern,
-      nbSelected
-    )
-  );
-
-  // display the number of currently selected photos in the "Selection" fieldset
-  if (nbSelected == 0) {
-    $("#selectedMessage").text(
+
+  /* update displaying */
+  function checkPermitAction() {
+    var nbSelected = 0;
+    if ($("input[name=setSelected]").is(':checked')) {
+      nbSelected = nb_thumbs_set;
+    }
+    else {
+      $(".thumbnails input[type=checkbox]").each(function() {
+        if ($(this).is(':checked')) nbSelected++;
+      });
+    }
+
+    if (nbSelected == 0) {
+      $("#beginImport").hide();
+    }
+    else {
+      $("#beginImport").show();
+    }
+
+    $("#applyOnDetails").text(
       sprintf(
-        selectedMessage_none,
-        nb_thumbs_set
+        '{'on the %d selected photos'|translate|escape:javascript}',
+        nbSelected
       )
     );
-  } else if (nbSelected == nb_thumbs_set) {
-    $("#selectedMessage").text(
-      sprintf(
-        selectedMessage_all,
-        nb_thumbs_set
-      )
-    );
-  } else {
-    $("#selectedMessage").text(
-      sprintf(
-        selectedMessage_pattern,
-        nbSelected,
-        nb_thumbs_set
-      )
-    );
+
+    // display the number of currently selected photos in the "Selection" fieldset
+    if (nbSelected == 0) {
+      $("#selectedMessage").text(
+        sprintf(
+          '{'No photo selected, %d photos in current set'|translate|escape:javascript}',
+          nb_thumbs_set
+        )
+      );
+    }
+    else if (nbSelected == nb_thumbs_set) {
+      $("#selectedMessage").text(
+        sprintf(
+          '{'All %d photos are selected'|translate|escape:javascript}',
+          nb_thumbs_set
+        )
+      );
+    }
+    else {
+      $("#selectedMessage").text(
+        sprintf(
+          '{'%d of %d photos selected'|translate|escape:javascript}',
+          nbSelected,
+          nb_thumbs_set
+        )
+      );
+    }
   }
-}
-
-/* import queue */
-function performImport(photo, album, fills) {
-  queuedManager.add({
-    type: 'GET',
-    dataType: 'json',
-    url: 'ws.php',
-    data: { method: 'pwg.images.addFlickr', id: photo, category: album, fills: fills, format: 'json' },
-    success: function(data) {
-      if (data['stat'] == 'ok') {
-        jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false });
-        jQuery("#photo-"+photo).fadeOut(function(){ $(this).remove(); });
-      } else {
-        jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true });
+
+  /* import queue */
+  function performImport(photo, album, fills) {
+    queuedManager.add({
+      type: 'GET',
+      dataType: 'json',
+      url: 'ws.php',
+      data: {
+        method: 'pwg.images.addFlickr',
+        id: photo,
+        category: album,
+        fills: fills,
+        format: 'json'
+      },
+      success: function(data) {
+        if (data['stat'] == 'ok') {
+          jQuery.jGrowl(data['result'], {
+            theme: 'success', life: 4000, sticky: false,
+            header: '{'Success'|translate}'
+          });
+          jQuery("#photo-"+photo).fadeOut(function(){ $(this).remove(); });
+        }
+        else {
+          jQuery.jGrowl(data['result'], {
+            theme: 'error', sticky: true,
+            header: '{'ERROR'|translate}'
+          });
+        }
+
+        import_done++;
+        $("#progress").html(import_done +"/"+ import_selected);
+
+        if (import_done == import_selected) {
+          $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
+          $("#import_form").submit();
+        }
+      },
+      error: function(data) {
+        jQuery.jGrowl('{'an error happened'|translate|@escape:'javascript'}', {
+          theme: 'error', sticky: true,
+          header: '{'ERROR'|translate}'
+        });
       }
-      
-      import_done++;
-      $("#progress").html(import_done +"/"+ import_selected);
-      
-      if (import_done == import_selected) {
-        $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
-        $("#import_form").submit();
-      }
-    },
-    error: function(data) {
-      jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true });
-    }
-  });
-}
-
-
-$(document).ready(function() {
+    });
+  }
+
+
   checkPermitAction();
   $("a.preview-box").colorbox();
@@ -206,6 +163,6 @@
 
   /* thumbnail click */
-  $(".wrap1 label").click(function (event) {
-    $("input[name=setSelected]").attr('checked', false);
+  $(".wrap1 label").click(function(event) {
+    $("input[name=setSelected]").prop('checked', false);
 
     var wrap2 = $(this).children(".wrap2");
@@ -215,8 +172,8 @@
 
     if ($(checkbox).is(':checked')) {
-      $(wrap2).addClass("thumbSelected"); 
-    }
-    else {
-      $(wrap2).removeClass('thumbSelected'); 
+      $(wrap2).addClass("thumbSelected");
+    }
+    else {
+      $(wrap2).removeClass('thumbSelected');
     }
 
@@ -225,15 +182,15 @@
 
   /* select all */
-  $("#selectAll").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
-    
+  $("#selectAll").click(function() {
+    $("input[name=setSelected]").prop('checked', false);
+
     $(".thumbnails label").each(function() {
       var wrap2 = $(this).children(".wrap2");
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', true);
-      $(wrap2).addClass("thumbSelected"); 
-    });
-    
+      $(checkbox).prop('checked', true);
+      $(wrap2).addClass("thumbSelected");
+    });
+
     checkPermitAction();
     return false;
@@ -241,15 +198,15 @@
 
   /* select none */
-  $("#selectNone").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
-    
+  $("#selectNone").click(function() {
+    $("input[name=setSelected]").prop('checked', false);
+
     $(".thumbnails label").each(function() {
       var wrap2 = $(this).children(".wrap2");
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', false);
-      $(wrap2).removeClass("thumbSelected"); 
-    });
-    
+      $(checkbox).prop('checked', false);
+      $(wrap2).removeClass("thumbSelected");
+    });
+
     checkPermitAction();
     return false;
@@ -257,76 +214,78 @@
 
   /* select invert */
-  $("#selectInvert").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
-    
+  $("#selectInvert").click(function() {
+    $("input[name=setSelected]").prop('checked', false);
+
     $(".thumbnails label").each(function() {
       var wrap2 = $(this).children(".wrap2");
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
+      $(checkbox).prop('checked', !$(checkbox).is(':checked'));
 
       if ($(checkbox).is(':checked')) {
-        $(wrap2).addClass("thumbSelected"); 
-      } else {
-        $(wrap2).removeClass('thumbSelected'); 
+        $(wrap2).addClass("thumbSelected");
       }
-    });
-    
-    checkPermitAction();
-    return false;
-  }); 
-  
+      else {
+        $(wrap2).removeClass('thumbSelected');
+      }
+    });
+
+    checkPermitAction();
+    return false;
+  });
+
   /* select set */
-  $("#selectSet").click(function () {
-    $("input[name=setSelected]").attr('checked', true);
-    
+  $("#selectSet").click(function() {
+    $("input[name=setSelected]").prop('checked', true);
+
     $(".thumbnails label").each(function() {
       var wrap2 = $(this).children(".wrap2");
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', true);
-      $(wrap2).addClass("thumbSelected"); 
-    });
-    
-    checkPermitAction();
-    return false;
-  });
- 
+      $(checkbox).prop('checked', true);
+      $(wrap2).addClass("thumbSelected");
+    });
+
+    checkPermitAction();
+    return false;
+  });
+
   /* begin import */
   jQuery('#beginImport').click(function() {
     $("#loader_import").fadeIn();
     var album = $("#albumSelect option:selected").val();
-    
+
     var fills = '';
     $("input[name^='fill_']:checked").each(function() {
       fills+= $(this).attr("name") +',';
-    }); 
-    
+    });
+
     if (jQuery('input[name="setSelected"]').attr('checked')) {
       import_selected = all_elements.length;
       $("#progress").html("0/"+ import_selected);
-      
+
       for (var i in all_elements) {
         performImport(all_elements[i], album, fills);
       }
-		} else {
+		}
+    else {
       import_selected = $("input[name='selection[]']:checked").length;
       $("#progress").html("0/"+ import_selected);
-      
+
 			jQuery("input[name='selection[]']:checked").each(function() {
         performImport(jQuery(this).attr('value'), album, fills);
       });
     }
-    
-    return false;
-  });
-  
+
+    return false;
+  });
+
   /* pagination loader */
   jQuery('#navigation a').click(function() {
     $("#loader_display").fadeIn();
   });
-});
-{/literal}
+}(jQuery));
 {/footer_script}
+
 
 <div id="batchManagerGlobal">
@@ -334,21 +293,21 @@
 
   <fieldset>
-    <legend>{'Selection'|@translate}</legend>
+    <legend>{'Selection'|translate}</legend>
 
   {if !empty($thumbnails)}
     <p id="checkActions">
-      {'Select:'|@translate}
+      {'Select:'|translate}
     {if $nb_thumbs_set > $nb_thumbs_page}
-      <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
-      <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
+      <a href="#" id="selectAll">{'The whole page'|translate}</a>,
+      <a href="#" id="selectSet">{'The whole set'|translate}</a>,
     {else}
-      <a href="#" id="selectAll">{'All'|@translate}</a>,
+      <a href="#" id="selectAll">{'All'|translate}</a>,
     {/if}
-      <a href="#" id="selectNone">{'None'|@translate}</a>,
-      <a href="#" id="selectInvert">{'Invert'|@translate}</a>
+      <a href="#" id="selectNone">{'None'|translate}</a>,
+      <a href="#" id="selectInvert">{'Invert'|translate}</a>
 
       <span id="selectedMessage"></span>
       <input type="checkbox" name="setSelected" style="display:none">
-      <span id="loader_display" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
+      <span id="loader_display" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i></span>
     </p>
 
@@ -359,7 +318,7 @@
 					<label>
 						<span class="wrap2">
-						<div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|@translate}</a> &middot; <a href="{$thumbnail.url}" target="_blank" title="{'Open Flickr page in a new tab'|@translate}">Flickr</a></div>
+						<div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|translate}</a> &middot; <a href="{$thumbnail.url}" target="_blank" title="{'Open Flickr page in a new tab'|translate}">Flickr</a></div>
 							<span>
-								<img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|@escape:'html'}" class="thumbnail">
+								<img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|escape:'html'}" class="thumbnail">
 							</span>
 						</span>
@@ -370,53 +329,53 @@
       {/foreach}
     </ul>
-    
-    
+
+
     <div style="clear:both;" id="navigation">
     {if !empty($navbar) }
       <div style="float:left">
-      {include file='navigation_bar.tpl'|@get_extent:'navbar'}
+      {include file='navigation_bar.tpl'|get_extent:'navbar'}
       </div>
     {/if}
-    
-      <div style="float:right;margin-top:10px;">{'display'|@translate}
+
+      <div style="float:right;margin-top:10px;">{'display'|translate}
         <a href="{$U_DISPLAY}&amp;display=20">20</a>
         &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
         &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
-        &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
-        {'photos per page'|@translate}
+        &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|translate}</a>
+        {'photos per page'|translate}
       </div>
     </div>
 
   {else}
-    <div>{'No photo in the current set.'|@translate}</div>
+    <div>{'No photo in the current set.'|translate}</div>
   {/if}
   </fieldset>
-  
+
   <fieldset>
-    <legend>{'Import options'|@translate}</legend>
+    <legend>{'Import options'|translate}</legend>
 
     <p>
-      <label for="albumSelect"><b>{'Album'|@translate}:</b></label>
+      <label for="albumSelect"><b>{'Album'|translate}:</b></label>
       <select style="width:400px" name="associate" id="albumSelect" size="1">
         {html_options options=$category_parent_options}
       </select>
-      {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
+      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
     </p>
-    
+
     <p>
-      <b>{'Fill these fields from Flickr datas'|@translate}:</b>
-      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|@translate}</label>
-      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|@translate}</label>
-      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|@translate}</label>
-      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|@translate}</label>
-      <label><input type="checkbox" name="fill_posted"> {'Post date'|@translate}</label>
+      <b>{'Fill these fields from Flickr datas'|translate}:</b>
+      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|translate}</label>
+      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|translate}</label>
+      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|translate}</label>
+      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|translate}</label>
+      <label><input type="checkbox" name="fill_posted"> {'Post date'|translate}</label>
       <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label>
-      {if $GMAPS_LOADED}<label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>{/if}
+      <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>
     </p>
 
     <p>
       <input type="hidden" name="album" value="{$album}">
-      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|@translate}" style="display:none;">
-      <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i> <span id="progress"></span></span>
+      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|translate}" style="display:none;">
+      <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i> <span id="progress"></span></span>
     </p>
   </fieldset>
Index: /extensions/flickr2piwigo/admin/template/import.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/import.tpl	(revision 26179)
+++ /extensions/flickr2piwigo/admin/template/import.tpl	(revision 26180)
@@ -1,6 +1,7 @@
-{combine_css path=$FLICKR_PATH|@cat:"admin/template/style.css"}
+{combine_css path=$FLICKR_PATH|cat:'admin/template/style.css'}
 
 {include file='include/colorbox.inc.tpl'}
 {include file='include/add_album.inc.tpl'}
+{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
 {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
@@ -13,9 +14,10 @@
 {* <!-- LOGIN --> *}
 {if $ACTION == 'init_login'}
-<p><input type="submit" onClick="javascript:window.location.href ='{$flickr_login}';" value="{'Login'|@translate}"></p>
+<p><input type="submit" onclick="javascript:window.location.href ='{$flickr_login}';" value="{'Login'|translate}"></p>
 
 {* <!-- MAIN MENU --> *}
-{elseif $ACTION == 'main'}
-{footer_script}{literal}
+{else if $ACTION == 'main'}
+
+{footer_script}
 jQuery('input[type="submit"]').click(function() {
   window.location.href = $(this).attr("data");
@@ -24,44 +26,45 @@
   $("#loader_import").fadeIn();
 });
-{/literal}{/footer_script}
+{/footer_script}
 
 <p>
-  <b>{'Logged in as'|@translate}</b> : <a href="{$profile_url}" target="_blank">{$username}</a><br><br>
-  <input type="submit" data="{$logout_url}" value="{'Logout'|@translate}">
+  <b>{'Logged in as'|translate}</b> : <a href="{$profile_url}" target="_blank">{$username}</a><br><br>
+  <input type="submit" data="{$logout_url}" value="{'Logout'|translate}">
 </p>
 <br>
 <p>
-  <input type="submit" data="{$list_albums_url}" class="load" value="{'List my albums'|@translate}">
-  <input type="submit" data="{$import_all_url}" class="load" value="{'Import all my pictures'|@translate}">
+  <input type="submit" data="{$list_albums_url}" class="load" value="{'List my albums'|translate}">
+  <input type="submit" data="{$import_all_url}" class="load" value="{'Import all my pictures'|translate}">
   <br>
-  <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
+  <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i></span>
 </p>
 
 {* <!-- ALBUMS LIST --> *}
-{elseif $ACTION == 'list_albums'}
-{footer_script}{literal}
+{else if $ACTION == 'list_albums'}
+
+{footer_script}
 jQuery('.load').click(function() {
   $("#loader_import").fadeIn();
 });
-{/literal}{/footer_script}
+{/footer_script}
 
-<h3>{'%d albums'|@translate|@sprintf:$total_albums}</h3>
+<h3>{'%d albums'|translate:$total_albums}</h3>
 <ul id="albumsList">
 {foreach from=$albums item=album}
   <li {if $album.id == "not_in_set"}class="not_in_set"{/if}>
-    <b><a href="{$album.U_LIST}" class="load">{$album.title}</a></b> <i>{'(%d photos)'|@translate|@sprintf:$album.photos}</i> 
-    {if $album.description}- {$album.description|@truncate:100}{/if}
+    <b><a href="{$album.U_LIST}" class="load">{$album.title}</a></b> <i>{'(%d photos)'|translate:$album.photos}</i>
+    {if $album.description}- {$album.description|truncate:100}{/if}
   </li>
 {/foreach}
 </ul>
-<span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
+<span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i></span>
 
 {* <!-- PHOTOS LIST --> *}
-{elseif $ACTION == 'list_photos'}
-{include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'}
+{else if $ACTION == 'list_photos'}
+{include file=$FLICKR_ABS_PATH|cat:'admin/template/import.list_photos.tpl'}
 
 {* <!-- IMPORT ALL --> *}
-{elseif $ACTION == 'list_all'}
-{include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_all.tpl'}
+{else if $ACTION == 'list_all'}
+{include file=$FLICKR_ABS_PATH|cat:'admin/template/import.list_all.tpl'}
 
 {/if}
Index: /extensions/flickr2piwigo/admin/template/style.css
===================================================================
--- /extensions/flickr2piwigo/admin/template/style.css	(revision 26179)
+++ /extensions/flickr2piwigo/admin/template/style.css	(revision 26180)
Index: /extensions/flickr2piwigo/include/functions.inc.php
===================================================================
--- /extensions/flickr2piwigo/include/functions.inc.php	(revision 26179)
+++ /extensions/flickr2piwigo/include/functions.inc.php	(revision 26180)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+defined('FLICKR_PATH') or die('Hacking attempt!');
 
 /**
@@ -30,7 +30,7 @@
       return false;
     }
-    
+
     $return = ($dest === true) ? true : false;
-    
+
     /* curl */
     if (function_exists('curl_init'))
@@ -41,5 +41,5 @@
       }
       $ch = curl_init();
-      
+
       curl_setopt($ch, CURLOPT_URL, $src);
       curl_setopt($ch, CURLOPT_HEADER, false);
@@ -65,8 +65,8 @@
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       }
-      
+
       $out = curl_exec($ch);
       curl_close($ch);
-      
+
       if ($out === false)
       {
@@ -90,5 +90,5 @@
         return false;
       }
-      
+
       $opts = array(
         'http' => array(
@@ -100,10 +100,10 @@
 
       $context = stream_context_create($opts);
-      
+
       if (($file = file_get_contents($src, false, $context)) === false)
       {
         return 'file_error';
       }
-      
+
       if (!$return)
       {
@@ -116,8 +116,6 @@
       }
     }
-    
+
     return false;
   }
 }
-
-?>
Index: /extensions/flickr2piwigo/include/ws_functions.inc.php
===================================================================
--- /extensions/flickr2piwigo/include/ws_functions.inc.php	(revision 26179)
+++ /extensions/flickr2piwigo/include/ws_functions.inc.php	(revision 26180)
@@ -1,9 +1,9 @@
 <?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+defined('FLICKR_PATH') or die('Hacking attempt!');
 
 function flickr_add_ws_method($arr)
 {
   $service = &$arr[0];
-  
+
   $service->addMethod(
     'pwg.images.addFlickr',
@@ -14,5 +14,7 @@
       'fills' => array('default' =>null),
       ),
-    'Used by Flickr2Piwigo'
+    'Used by Flickr2Piwigo',
+    null,
+    array('hidden'=>true)
     );
 }
@@ -24,34 +26,33 @@
     return new PwgError(403, 'Forbidden');
   }
-  
+
   global $conf;
-  $conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']);
-  
-  if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) )
+
+  if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']))
   {
     return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
   }
-  
+
   include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
   include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
   include_once(FLICKR_PATH . 'include/functions.inc.php');
-  
+
   if (test_remote_download() === false)
   {
     return new PwgError(null, l10n('No download method available'));
   }
-  
+
   // init flickr API
   include_once(FLICKR_PATH . 'include/phpFlickr/phpFlickr.php');
   $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
   $flickr->enableCache('fs', FLICKR_FS_CACHE);
-  
+
   // user
   $u = $flickr->test_login();
-  if ( $u === false or empty($_SESSION['phpFlickr_auth_token']) )
+  if ($u === false or empty($_SESSION['phpFlickr_auth_token']))
   {
     return new PwgError(403, l10n('API not authenticated'));
   }
-  
+
   // photos infos
   $photo_f = $flickr->photos_getInfo($photo['id']);
@@ -59,5 +60,5 @@
   $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original');
   $photo['path'] = FLICKR_FS_CACHE . 'flickr-'.$u['username'].'-'.$photo['id'].'.'.get_extension($photo['url']);
-  
+
   // copy file
   if (download_remote_file($photo['url'], $photo['path']) == false)
@@ -65,10 +66,10 @@
     return new PwgError(null, l10n('Can\'t download file'));
   }
-  
+
   // category
   if (!preg_match('#^[0-9]+$#', $photo['category']))
   {
     $categories_names = explode(',', $photo['category']);
-    
+
     $photo['category'] = array();
     foreach ($categories_names as $category_name)
@@ -79,15 +80,15 @@
 ;';
       $result = pwg_query($query);
-      
+
       if (pwg_db_num_rows($result))
       {
         list($cat_id) = pwg_db_fetch_row($result);
-        array_push($photo['category'], $cat_id);
+        $photo['category'][] = $cat_id;
       }
       else
       {
-        
+
         $cat = create_virtual_category($category_name);
-        array_push($photo['category'], $cat['id']);
+        $photo['category'][] = $cat['id'];
       }
     }
@@ -97,8 +98,8 @@
     $photo['category'] = array($photo['category']);
   }
-  
+
   // add photo
   $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']);
-  
+
   // do some updates
   if (!empty($photo['fills']))
@@ -106,7 +107,7 @@
     $photo['fills'] = rtrim($photo['fills'], ',');
     $photo['fills'] = explode(',', $photo['fills']);
-  
+
     $updates = array();
-    if (in_array('fill_name', $photo['fills']))   $updates['name'] = pwg_db_real_escape_string($photo['title']); 
+    if (in_array('fill_name', $photo['fills']))   $updates['name'] = pwg_db_real_escape_string($photo['title']);
     if (in_array('fill_posted', $photo['fills'])) $updates['date_available'] = date('Y-m-d H:i:s', $photo['dates']['posted']);
     if (in_array('fill_taken', $photo['fills']))  $updates['date_creation'] = $photo['dates']['taken'];
@@ -115,8 +116,8 @@
     if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location']) )
     {
-      $updates['lat'] = pwg_db_real_escape_string($photo['location']['latitude']);
-      $updates['lon'] = pwg_db_real_escape_string($photo['location']['longitude']);
+      $updates['latitude'] = pwg_db_real_escape_string($photo['location']['latitude']);
+      $updates['longitude'] = pwg_db_real_escape_string($photo['location']['longitude']);
     }
-    
+
     if (count($updates))
     {
@@ -127,6 +128,6 @@
         );
     }
-    
-    if ( !empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills']) )
+
+    if (!empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills']))
     {
       $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']);
@@ -135,7 +136,5 @@
     }
   }
-  
-  return sprintf(l10n('Photo "%s" imported'), $photo['title']);
+
+  return l10n('Photo "%s" imported', $photo['title']);
 }
-
-?>
Index: /extensions/flickr2piwigo/main.inc.php
===================================================================
--- /extensions/flickr2piwigo/main.inc.php	(revision 26179)
+++ /extensions/flickr2piwigo/main.inc.php	(revision 26180)
@@ -1,3 +1,3 @@
-<?php 
+<?php
 /*
 Plugin Name: Flickr2Piwigo
@@ -9,35 +9,43 @@
 */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 global $conf;
 
-define('FLICKR_PATH',     PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
-define('FLICKR_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
+define('FLICKR_ID',       basename(dirname(__FILE__)));
+define('FLICKR_PATH',     PHPWG_PLUGINS_PATH . FLICKR_ID . '/');
+define('FLICKR_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . FLICKR_ID);
 define('FLICKR_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
+define('FLICKR_VERSION',  'auto');
 
+
+include_once(FLICKR_PATH . 'include/ws_functions.inc.php');
+
+
+add_event_handler('init', 'flickr_init');
+add_event_handler('ws_add_methods', 'flickr_add_ws_method');
 
 if (defined('IN_ADMIN'))
 {
   add_event_handler('get_admin_plugin_menu_links', 'flickr_admin_menu');
+
   add_event_handler('get_batch_manager_prefilters', 'flickr_add_batch_manager_prefilters');
   add_event_handler('perform_batch_manager_prefilters', 'flickr_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-  add_event_handler('loc_begin_admin_page', 'flickr_prefilter_from_url');
 
-  function flickr_admin_menu($menu) 
+  function flickr_admin_menu($menu)
   {
-    array_push($menu, array(
+    $menu[] = array(
       'NAME' => 'Flickr2Piwigo',
       'URL' => FLICKR_ADMIN,
-    ));
+      );
     return $menu;
   }
-  
+
   function flickr_add_batch_manager_prefilters($prefilters)
   {
-    array_push($prefilters, array(
+    $prefilters[] = array(
       'ID' => 'flickr',
       'NAME' => l10n('Imported from Flickr'),
-    ));
+      );
     return $prefilters;
   }
@@ -54,23 +62,17 @@
       $filter_sets[] = array_from_query($query, 'id');
     }
-    
+
     return $filter_sets;
-  }
-  
-  function flickr_prefilter_from_url()
-  {
-    global $page;
-    if ($page['page'] == 'batch_manager' && @$_GET['prefilter'] == 'flickr')
-    {
-      $_SESSION['bulk_manager_filter'] = array('prefilter' => 'flickr');
-      unset($_GET['prefilter']);
-    }
   }
 }
 
 
-include_once(FLICKR_PATH . 'include/ws_functions.inc.php');
+function flickr_init()
+{
+  global $conf;
+  include_once(FLICKR_PATH . 'maintain.inc.php');
+  $maintain = new flickr2piwigo_maintain(FLICKR_ID);
+  $maintain->autoUpdate(FLICKR_VERSION, 'install');
 
-add_event_handler('ws_add_methods', 'flickr_add_ws_method');
-
-?>
+  $conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']);
+}
Index: /extensions/flickr2piwigo/maintain.inc.php
===================================================================
--- /extensions/flickr2piwigo/maintain.inc.php	(revision 26179)
+++ /extensions/flickr2piwigo/maintain.inc.php	(revision 26180)
@@ -1,76 +1,77 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-define(
-  'flickr2piwigo_default_config', 
-  serialize(array(
+class flickr2piwigo_maintain extends PluginMaintain
+{
+  private $installed = false;
+
+  private $default_conf = array(
     'api_key' => null,
     'secret_key' => null,
-    ))
-  );
+    );
 
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf;
 
-function plugin_install() 
-{
-  global $conf;
-  
-  conf_update_param('flickr2piwigo', flickr2piwigo_default_config);
-  
-  mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
-}
+    if (empty($conf['flickr2piwigo']))
+    {
+      $conf['flickr2piwigo'] = serialize($this->default_conf);
+      conf_update_param('flickr2piwigo', $conf['flickr2piwigo']);
+    }
 
-function plugin_activate()
-{
-  global $conf;
+    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
 
-  if (empty($conf['flickr2piwigo']))
+    $this->installed = true;
+  }
+
+  function activate($plugin_version, &$errors=array())
   {
-    conf_update_param('flickr2piwigo', flickr2piwigo_default_config);
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
   }
-  
-  if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/'))
+
+  function deactivate()
   {
-    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+  }
+
+  function uninstall()
+  {
+    global $conf;
+
+    conf_delete_param('flickr2piwigo');
+
+    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
+  }
+
+  static function rrmdir($dir)
+  {
+    if (!is_dir($dir))
+    {
+      return false;
+    }
+    $dir = rtrim($dir, '/');
+    $objects = scandir($dir);
+    $return = true;
+
+    foreach ($objects as $object)
+    {
+      if ($object !== '.' && $object !== '..')
+      {
+        $path = $dir.'/'.$object;
+        if (filetype($path) == 'dir')
+        {
+          $return = $return && self::rrmdir($path);
+        }
+        else
+        {
+          $return = $return && @unlink($path);
+        }
+      }
+    }
+
+    return $return && @rmdir($dir);
   }
 }
-
-function plugin_uninstall() 
-{
-  global $conf;
-  
-  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "flickr2piwigo";');
-  unset($conf['flickr2piwigo']);
-  
-  rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
-}
-
-function rrmdir($dir)
-{
-  if (!is_dir($dir))
-  {
-    return false;
-  }
-  $dir = rtrim($dir, '/');
-  $objects = scandir($dir);
-  $return = true;
-  
-  foreach ($objects as $object)
-  {
-    if ($object !== '.' && $object !== '..')
-    {
-      $path = $dir.'/'.$object;
-      if (filetype($path) == 'dir') 
-      {
-        $return = $return && rrmdir($path); 
-      }
-      else 
-      {
-        $return = $return && @unlink($path);
-      }
-    }
-  }
-  
-  return $return && @rmdir($dir);
-} 
-
-?>
