Index: /extensions/instagram2piwigo/admin.php
===================================================================
--- /extensions/instagram2piwigo/admin.php	(revision 26198)
+++ /extensions/instagram2piwigo/admin.php	(revision 26199)
@@ -1,8 +1,7 @@
 <?php
-if (!defined('INSTAG_PATH')) die('Hacking attempt!');
+defined('INSTAG_PATH') or die('Hacking attempt!');
 
 global $template, $page, $conf;
 
-$conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
 load_language('plugin.lang', INSTAG_PATH);
 
@@ -31,5 +30,4 @@
   'INSTAG_ADMIN' => INSTAG_ADMIN,
   ));
+
 $template->assign_var_from_handle('ADMIN_CONTENT', 'Instagram2Piwigo');
-
-?>
Index: /extensions/instagram2piwigo/admin/config.php
===================================================================
--- /extensions/instagram2piwigo/admin/config.php	(revision 26198)
+++ /extensions/instagram2piwigo/admin/config.php	(revision 26199)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('INSTAG_PATH')) die('Hacking attempt!');
+defined('INSTAG_PATH') or die('Hacking attempt!');
 
 if (isset($_POST['save_config']))
@@ -8,4 +8,5 @@
     'secret_key' => trim($_POST['secret_key']),
     );
+
   unset($_SESSION['phpinstagram_auth_token']);
   conf_update_param('Instagram2Piwigo', serialize($conf['Instagram2Piwigo']));
@@ -21,5 +22,3 @@
 
 
-$template->set_filename('Instagram2Piwigo', dirname(__FILE__) . '/template/config.tpl');
-
-?>
+$template->set_filename('Instagram2Piwigo', realpath(INSTAG_PATH . 'admin/template/config.tpl'));
Index: /extensions/instagram2piwigo/admin/import.php
===================================================================
--- /extensions/instagram2piwigo/admin/import.php	(revision 26198)
+++ /extensions/instagram2piwigo/admin/import.php	(revision 26199)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('INSTAG_PATH')) die('Hacking attempt!');
+defined('INSTAG_PATH') or die('Hacking attempt!');
 
 set_time_limit(600);
@@ -7,12 +7,12 @@
 
 // check API parameters and connect to instagram
-if ( empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']) )
-{
-  array_push($page['warnings'], l10n('Please fill your API keys on the configuration tab'));
+if (empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']))
+{
+  $page['warnings'][] = l10n('Please fill your API keys on the configuration tab');
   $_GET['action'] = 'error';
 }
 else if (!function_exists('curl_init'))
 {
-  array_push($page['errors'], l10n('No download method available').' (cURL)');
+  $page['errors'][] = l10n('No download method available').' (cURL)';
   $_GET['action'] = 'error';
 }
@@ -25,8 +25,8 @@
     
     $auth_config = array(
-        'client_id'         => $conf['Instagram2Piwigo']['api_key'],
-        'client_secret'     => $conf['Instagram2Piwigo']['secret_key'],
-        'redirect_uri'      => get_absolute_root_url() . INSTAG_ADMIN . '-import',
-    );
+      'client_id'     => $conf['Instagram2Piwigo']['api_key'],
+      'client_secret' => $conf['Instagram2Piwigo']['secret_key'],
+      'redirect_uri'  => get_absolute_root_url() . INSTAG_ADMIN . '-import',
+      );
     
     $auth = new Instagram_Auth($auth_config);
@@ -57,5 +57,8 @@
 
 
-if (!isset($_GET['action'])) $_GET['action'] = 'main';
+if (!isset($_GET['action']))
+{
+  $_GET['action'] = 'main';
+}
 
 
@@ -142,6 +145,9 @@
     if ($duplicates>0)
     {
-      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;prefilter=instagram">'
-          .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-instagram">'
+          .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>';
     }
@@ -195,5 +201,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(INSTAG_ADMIN . '-import');
@@ -204,5 +210,3 @@
 $template->assign('ACTION', $_GET['action']);
 
-$template->set_filename('Instagram2Piwigo', dirname(__FILE__) . '/template/import.tpl');
-
-?>
+$template->set_filename('Instagram2Piwigo', realpath(INSTAG_PATH . 'admin/template/import.tpl'));
Index: /extensions/instagram2piwigo/admin/template/config.tpl
===================================================================
--- /extensions/instagram2piwigo/admin/template/config.tpl	(revision 26198)
+++ /extensions/instagram2piwigo/admin/template/config.tpl	(revision 26199)
@@ -5,5 +5,5 @@
 <form method="post" action="" class="properties">
 <fieldset>
-  <legend>{'Instagram logins'|@translate}</legend>
+  <legend>{'Instagram logins'|translate}</legend>
   
   <ul>
@@ -24,8 +24,8 @@
 </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 Instagram Client ID ?'|@translate}</legend>
+  <legend>{'How do I get my Instagram Client ID ?'|translate}</legend>
   
   <p><b>OAuth redirect_uri :</b> <span style="font-family:monospace;font-size:14px;">{$INSTAG_CALLBACK}</span></p>
Index: /extensions/instagram2piwigo/admin/template/import.list_photos.tpl
===================================================================
--- /extensions/instagram2piwigo/admin/template/import.list_photos.tpl	(revision 26198)
+++ /extensions/instagram2piwigo/admin/template/import.list_photos.tpl	(revision 26199)
@@ -1,35 +1,25 @@
 {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'}
-{combine_css path="admin/themes/default/uploadify.jGrowl.css"}
+{combine_css path="themes/default/js/plugins/jquery.jGrowl.css"}
 
 {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', {
+    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;
@@ -66,138 +56,108 @@
         return true;
       });
-      $(this).click(function(event) {console.log(event.shiftKey);$(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.addInstagram', 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.addInstagram',
+        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).fadeOut(function(){ $(this).remove(); });
+        }
+        else {
+          $.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) {
+        $.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({
@@ -216,5 +176,5 @@
   /* thumbnail click */
   $(".wrap1 label").click(function (event) {
-    $("input[name=setSelected]").attr('checked', false);
+    $("input[name=setSelected]").prop('checked', false);
 
     var wrap2 = $(this).children(".wrap2");
@@ -235,5 +195,5 @@
   /* select all */
   $("#selectAll").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
+    $("input[name=setSelected]").prop('checked', false);
     
     $(".thumbnails label").each(function() {
@@ -241,5 +201,5 @@
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', true);
+      $(checkbox).prop('checked', true);
       $(wrap2).addClass("thumbSelected"); 
     });
@@ -251,5 +211,5 @@
   /* select none */
   $("#selectNone").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
+    $("input[name=setSelected]").prop('checked', false);
     
     $(".thumbnails label").each(function() {
@@ -257,5 +217,5 @@
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', false);
+      $(checkbox).prop('checked', false);
       $(wrap2).removeClass("thumbSelected"); 
     });
@@ -267,5 +227,5 @@
   /* select invert */
   $("#selectInvert").click(function () {
-    $("input[name=setSelected]").attr('checked', false);
+    $("input[name=setSelected]").prop('checked', false);
     
     $(".thumbnails label").each(function() {
@@ -273,9 +233,10 @@
       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 {
+      }
+      else {
         $(wrap2).removeClass('thumbSelected'); 
       }
@@ -288,5 +249,5 @@
   /* select set */
   $("#selectSet").click(function () {
-    $("input[name=setSelected]").attr('checked', true);
+    $("input[name=setSelected]").prop('checked', true);
     
     $(".thumbnails label").each(function() {
@@ -294,5 +255,5 @@
       var checkbox = $(this).children("input[type=checkbox]");
 
-      $(checkbox).attr('checked', true);
+      $(checkbox).prop('checked', true);
       $(wrap2).addClass("thumbSelected"); 
     });
@@ -303,5 +264,5 @@
  
   /* begin import */
-  jQuery('#beginImport').click(function() {
+  $('#beginImport').click(function() {
     $("#loader_import").fadeIn();
     var album = $("#albumSelect option:selected").val();
@@ -312,5 +273,5 @@
     }); 
     
-    if (jQuery('input[name="setSelected"]').attr('checked')) {
+    if ($('input[name="setSelected"]').prop('checked')) {
       import_selected = all_elements.length;
       $("#progress").html("0/"+ import_selected);
@@ -319,10 +280,11 @@
         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);
+			$("input[name='selection[]']:checked").each(function() {
+        performImport($(this).attr('value'), album, fills);
       });
     }
@@ -332,17 +294,15 @@
   
   /* pagination loader */
-  jQuery('#navigation a').click(function() {
+  $('#navigation a').click(function() {
     $("#loader_display").fadeIn();
   });
-});
-{/literal}
+}(jQuery));
 {/footer_script}
 
-{html_head}
-<style type="text/css">
-.thumbnails .wrap2 {ldelim} width:128px; height:128px; }
-.thumbnail {ldelim} width:100px; }
-</style>
-{/html_head}
+
+{html_style}
+.thumbnails .wrap2 { width:128px; height:128px; }
+.thumbnail { width:100px; }
+{/html_style}
 
 
@@ -351,21 +311,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>
 
@@ -376,5 +336,5 @@
 					<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 Instagram page in a new tab'|@translate}">Open</a></div>
+						<div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|translate}</a> &middot; <a href="{$thumbnail.url}" target="_blank" title="{'Open Instagram page in a new tab'|translate}">Open</a></div>
 							<span>
 								<img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|@escape:'html'}" class="thumbnail">
@@ -396,41 +356,42 @@
     {/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 Instagram 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>
+      <b>{'Fill these fields from Instagram 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_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/instagram2piwigo/admin/template/import.tpl
===================================================================
--- /extensions/instagram2piwigo/admin/template/import.tpl	(revision 26198)
+++ /extensions/instagram2piwigo/admin/template/import.tpl	(revision 26199)
@@ -8,6 +8,6 @@
 
 {* <!-- 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");
@@ -16,5 +16,5 @@
   $("#loader_import").fadeIn();
 });
-{/literal}{/footer_script}
+{/footer_script}
 
 <p>
@@ -30,5 +30,5 @@
 
 {* <!-- PHOTOS LIST --> *}
-{elseif $ACTION == 'list_photos'}
+{else if $ACTION == 'list_photos'}
 {include file=$INSTAG_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'}
 
Index: /extensions/instagram2piwigo/include/functions.inc.php
===================================================================
--- /extensions/instagram2piwigo/include/functions.inc.php	(revision 26198)
+++ /extensions/instagram2piwigo/include/functions.inc.php	(revision 26199)
@@ -1,16 +1,4 @@
 <?php
-if (!defined('INSTAG_PATH')) die('Hacking attempt!');
-
-/**
- * test if a download method is available
- * @return: bool
- */
-if (!function_exists('test_remote_download'))
-{
-  function test_remote_download()
-  {
-    return function_exists('curl_init') || ini_get('allow_url_fopen');
-  }
-}
+defined('INSTAG_PATH') or die('Hacking attempt!');
 
 /**
@@ -120,4 +108,2 @@
   }
 }
-
-?>
Index: /extensions/instagram2piwigo/include/ws_functions.inc.php
===================================================================
--- /extensions/instagram2piwigo/include/ws_functions.inc.php	(revision 26198)
+++ /extensions/instagram2piwigo/include/ws_functions.inc.php	(revision 26199)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('INSTAG_PATH')) die('Hacking attempt!');
+defined('INSTAG_PATH') or die('Hacking attempt!');
 
 function instagram_add_ws_method($arr)
@@ -14,5 +14,7 @@
       'fills' => array('default' =>null),
       ),
-    'Used by Instagram2Piwigo'
+    'Used by Instagram2Piwigo',
+    null,
+    array('hidden'=>true)
     );
 }
@@ -26,7 +28,6 @@
   
   global $conf;
-  $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
   
-  if ( empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']) )
+  if (empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']))
   {
     return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
@@ -65,4 +66,5 @@
     'username' => $photo_f->getUser()->getFullName(true),
     'tags' => $photo_f->getTags()->toArray(),
+    'location' => $photo_f->getLocation(),
     );
   $photo = array_merge($param, $photo);
@@ -95,7 +97,12 @@
   
     $updates = array();
-    if (in_array('fill_name', $photo['fills']))   $updates['name'] = $photo['title'];
+    if (in_array('fill_name', $photo['fills']))   $updates['name'] = pwg_db_real_escape_string($photo['title']);
     if (in_array('fill_taken', $photo['fills']))  $updates['date_creation'] = $photo['date'];
-    if (in_array('fill_author', $photo['fills'])) $updates['author'] = $photo['username'];
+    if (in_array('fill_author', $photo['fills'])) $updates['author'] = pwg_db_real_escape_string($photo['username']);
+    if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location']) )
+    {
+      $updates['latitude'] = pwg_db_real_escape_string($photo['location']->getLat());
+      $updates['longitude'] = pwg_db_real_escape_string($photo['location']->getLng());
+    }
     
     if (count($updates))
@@ -108,5 +115,5 @@
     }
     
-    if ( !empty($photo['tags']) and in_array('fill_tags', $photo['fills']) )
+    if (!empty($photo['tags']) and in_array('fill_tags', $photo['fills']))
     {
       $raw_tags = implode(',', $photo['tags']);
@@ -115,6 +122,4 @@
   }
   
-  return sprintf(l10n('Photo "%s" imported'), $photo['title']);
+  return l10n('Photo "%s" imported', $photo['title']);
 }
-
-?>
Index: /extensions/instagram2piwigo/main.inc.php
===================================================================
--- /extensions/instagram2piwigo/main.inc.php	(revision 26198)
+++ /extensions/instagram2piwigo/main.inc.php	(revision 26199)
@@ -9,26 +9,34 @@
 */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 global $conf;
 
-define('INSTAG_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
-define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
+define('INSTAG_ID',       basename(dirname(__FILE__)));
+define('INSTAG_PATH',     PHPWG_PLUGINS_PATH . INSTAG_ID . '/');
+define('INSTAG_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . INSTAG_ID);
 define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/');
+define('INSTAG_VERSION',  'auto');
 
+
+include_once(INSTAG_PATH . 'include/ws_functions.inc.php');
+
+
+add_event_handler('init', 'instagram_init');
+add_event_handler('ws_add_methods', 'instagram_add_ws_method');
 
 if (defined('IN_ADMIN'))
 {
   add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu');
+
   add_event_handler('get_batch_manager_prefilters', 'instagram_add_batch_manager_prefilters');
   add_event_handler('perform_batch_manager_prefilters', 'instagram_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-  add_event_handler('loc_begin_admin_page', 'instagram_prefilter_from_url');
 
   function instagram_admin_menu($menu) 
   {
-    array_push($menu, array(
+    $menu[] = array(
       'NAME' => 'Instagram2Piwigo',
       'URL' => INSTAG_ADMIN,
-    ));
+      );
     return $menu;
   }
@@ -36,8 +44,8 @@
   function instagram_add_batch_manager_prefilters($prefilters)
   {
-    array_push($prefilters, array(
+    $prefilters[] = array(
       'ID' => 'instagram',
       'NAME' => l10n('Imported from Instagram'),
-    ));
+      );
     return $prefilters;
   }
@@ -57,20 +65,15 @@
     return $filter_sets;
   }
-  
-  function instagram_prefilter_from_url()
-  {
-    global $page;
-    if ($page['page'] == 'batch_manager' && @$_GET['prefilter'] == 'instagram')
-    {
-      $_SESSION['bulk_manager_filter'] = array('prefilter' => 'instagram');
-      unset($_GET['prefilter']);
-    }
-  }
 }
 
 
-include_once(INSTAG_PATH . 'include/ws_functions.inc.php');
+function instagram_init()
+{
+  global $conf;
 
-add_event_handler('ws_add_methods', 'instagram_add_ws_method');
+  include_once(INSTAG_PATH . 'maintain.inc.php');
+  $maintain = new instagram2piwigo_maintain(INSTAG_ID);
+  $maintain->autoUpdate(INSTAG_VERSION, 'install');
 
-?>
+  $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
+}
Index: /extensions/instagram2piwigo/maintain.inc.php
===================================================================
--- /extensions/instagram2piwigo/maintain.inc.php	(revision 26198)
+++ /extensions/instagram2piwigo/maintain.inc.php	(revision 26199)
@@ -1,76 +1,77 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-define(
-  'Instagram2Piwigo_default_config', 
-  serialize(array(
+class instagram2piwigo_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('Instagram2Piwigo', Instagram2Piwigo_default_config);
-  
-  mkdir($conf['data_location'].'instagram_cache/', 0755);
-}
+    if (empty($conf['Instagram2Piwigo']))
+    {
+      $conf['Instagram2Piwigo'] = serialize($this->default_conf);
+      conf_update_param('Instagram2Piwigo', $conf['Instagram2Piwigo']);
+    }
 
-function plugin_activate()
-{
-  global $conf;
+    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
 
-  if (empty($conf['Instagram2Piwigo']))
+    $this->installed = true;
+  }
+
+  function activate($plugin_version, &$errors=array())
   {
-    conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config);
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
   }
-  
-  if (!file_exists($conf['data_location'].'instagram_cache/'))
+
+  function deactivate()
   {
-    mkdir($conf['data_location'].'instagram_cache/', 0755);
+  }
+
+  function uninstall()
+  {
+    global $conf;
+
+    conf_delete_param('Instagram2Piwigo');
+
+    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_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 = "Instagram2Piwigo";');
-  unset($conf['Instagram2Piwigo']);
-  
-  rrmdir($conf['data_location'].'instagram_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);
-} 
-
-?>
