Index: /extensions/pbase2piwigo/admin.php
===================================================================
--- /extensions/pbase2piwigo/admin.php	(revision 17313)
+++ /extensions/pbase2piwigo/admin.php	(revision 17314)
@@ -12,16 +12,6 @@
 }
 
-// tabsheet
-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'), PBASE_ADMIN . '-import');
-// $tabsheet->add('config', l10n('Configuration'), PBASE_ADMIN . '-config');
-$tabsheet->select($page['tab']);
-$tabsheet->assign();
-
 // include page
-include(PBASE_PATH . 'admin/' . $page['tab'] . '.php');
+include(PBASE_PATH . 'admin/import.php');
 
 // template
Index: tensions/pbase2piwigo/admin/config.php
===================================================================
--- /extensions/pbase2piwigo/admin/config.php	(revision 17313)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?php
-if (!defined('FLICKR_PATH')) die('Hacking attempt!');
-
-if (isset($_POST['save_config']))
-{
-  $conf['flickr2piwigo'] = array(
-    'api_key' => trim($_POST['api_key']),
-    'secret_key' => trim($_POST['secret_key']),
-    );
-  unset($_SESSION['phpFlickr_auth_token']);
-  conf_update_param('flickr2piwigo', serialize($conf['flickr2piwigo']));
-}
-
-
-$template->assign(array(
-  'flickr2piwigo' => $conf['flickr2piwigo'],
-  'FLICKR_HELP_CONTENT' => load_language('help_api_key.html', FLICKR_PATH, array('return'=>true)),
-  'FLICKR_CALLBACK' => get_absolute_root_url() . FLICKR_ADMIN . '-import',
-  ));
-
-
-$template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/config.tpl');
-
-?>
Index: /extensions/pbase2piwigo/admin/import.php
===================================================================
--- /extensions/pbase2piwigo/admin/import.php	(revision 17313)
+++ /extensions/pbase2piwigo/admin/import.php	(revision 17314)
@@ -50,5 +50,25 @@
   case 'config':
   {
+    if (isset($_SESSION['pbase_empty_error']))
+    {
+      array_push($page['errors'], l10n('Import queue is empty'));
+      unset($_SESSION['pbase_empty_error']);
+    }
+    
+    // counters
+    $nb_categories = $nb_pictures = 0;
+    count_pictures_cats($tree, '/root', $nb_pictures, $nb_categories, true);
+    
+    // get piwigo categories
+    $query = '
+SELECT id, name, uppercats, global_rank
+  FROM '.CATEGORIES_TABLE.'
+;';
+    display_select_cat_wrapper($query, array(), 'associate_options');
+    display_select_cat_wrapper($query, array(), 'category_parent_options');
+    
     $template->assign(array(
+      'nb_categories' => $nb_categories-1, // don't count root
+      'nb_pictures' => $nb_pictures,
       'F_ACTION' => PBASE_ADMIN.'-import&amp;action=init_import',
       'RESET_LINK' => PBASE_ADMIN.'-import&amp;action=reset_tree',
@@ -61,8 +81,18 @@
   {
     $categories = $_POST['categories'];
+    $nb_categories = $nb_pictures = 0;
     
-    // remove duplicate categories (in case of recursive mode)
     if (isset($_POST['recursive']))
     {
+      // we don't add "root", only it's children
+      if (@$categories[0] == '/root')
+      {
+        $temp = &get_current_cat($tree, '/root');
+        $categories = array_merge($categories, array_values(array_unique_deep($temp['categories'], 'path')));
+        $categories = array_unique($categories);
+        unset($categories[0]);
+      }
+      
+      // remove duplicate categories (in case of recursive mode)
       foreach ($categories as &$path)
       {
@@ -77,8 +107,13 @@
     // count pictures and cats
     $temp_cats = $categories;
-    $nb_categories = $nb_pictures = 0;
     foreach ($temp_cats as $path)
     {
       count_pictures_cats($tree, $path, $nb_pictures, $nb_categories, isset($_POST['recursive']));
+    }
+    
+    if ($nb_pictures == 0)
+    {
+      $_SESSION['pbase_empty_error'] = true;
+      redirect(PBASE_ADMIN.'-import');
     }
     
@@ -87,4 +122,5 @@
       'nb_categories' => $nb_categories,
       'categories' => $categories,
+      'PARENT_CATEGORY' => $_POST['parent_category'],
       'RECURSIVE' => boolean_to_string(isset($_POST['recursive'])),
       'FILLS' => implode(',', @$_POST['fills']),
Index: tensions/pbase2piwigo/admin/template/config.tpl
===================================================================
--- /extensions/pbase2piwigo/admin/template/config.tpl	(revision 17313)
+++ 	(revision )
@@ -1,37 +1,0 @@
-{combine_css path=$FLICKR_PATH|@cat:"admin/template/style.css"}
-
-<div class="titrePage">
-	<h2>Flickr2Piwigo</h2>
-</div>
-
-<form method="post" action="" class="properties">
-<fieldset>
-  <legend>{'Flickr logins'|@translate}</legend>
-  
-  <ul>
-    <li>
-      <label>
-        <span class="property">{'API key'|@translate}</span>
-        <input type="text" name="api_key" value="{$flickr2piwigo.api_key}" size="40">
-      </label>
-    </li>
-
-    <li>
-      <label>
-        <span class="property">{'API secret'|@translate}</span>
-        <input type="text" name="secret_key" value="{$flickr2piwigo.secret_key}" size="20">
-      </label>
-    </li>
-  </ul>
-</fieldset>
-
-<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>
-  {$FLICKR_HELP_CONTENT}
-</fieldset>
-  
-</form>
Index: /extensions/pbase2piwigo/admin/template/import.config.tpl
===================================================================
--- /extensions/pbase2piwigo/admin/template/import.config.tpl	(revision 17313)
+++ /extensions/pbase2piwigo/admin/template/import.config.tpl	(revision 17314)
@@ -1,2 +1,5 @@
+{include file='include/colorbox.inc.tpl'}
+{include file='include/add_album.inc.tpl'}
+
 {footer_script require='jquery.ui.resizable'}{literal}
 jQuery(".categoryList").resizable({
@@ -10,5 +13,5 @@
 <form action="{$F_ACTION}" method="post">
 <fieldset>
-  <legend>{'Choose albums to import'|@translate}</legend>
+  <legend>{'Select albums to import'|@translate}</legend>
   
   <select name="categories[]" class="categoryList" multiple="multiple" size="20">
@@ -16,6 +19,9 @@
   </select>
   
+  <b>{'Nb albums'|@translate}</b>: {$nb_categories}<br>
+  <b>{'Nb photos'|@translate}</b>: {$nb_pictures}<br>
+  
   <br>
-  <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'|@translate}');">Reset</a>
+  <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'|@translate}');">{'Reset'|@translate}</a>
 </fieldset>
 
@@ -23,5 +29,15 @@
   <legend>{'Configuration'|@translate}</legend>
   
-  <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>Recursive</b></label></p>
+  <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>{'Recursive'|@translate}</b></label></p>
+  
+  <p id="albumSelectWrapper">
+    <b>{'Import in this album'|@translate}:</b>
+    <select style="width:400px" name="parent_category" id="albumSelect" size="1">
+      <option value="0">------------</option>
+      {html_options options=$associate_options}
+    </select>
+    {'... 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 pBase datas'|@translate}:</b>
@@ -35,5 +51,5 @@
 
   <p class="bottomButtons">
-    <input type="submit" value="Begin Transfer">    
+    <input type="submit" value="{'Begin transfer'|@translate}">    
   </p>
 </form>
Index: /extensions/pbase2piwigo/admin/template/import.init_import.tpl
===================================================================
--- /extensions/pbase2piwigo/admin/template/import.init_import.tpl	(revision 17313)
+++ /extensions/pbase2piwigo/admin/template/import.init_import.tpl	(revision 17314)
@@ -123,5 +123,5 @@
 
 {foreach from=$categories item=cat}
-add_cat_to_add_queue('{$cat}', 0, {$RECURSIVE}, '{$FILLS}');
+add_cat_to_add_queue('{$cat}', {$PARENT_CATEGORY}, {$RECURSIVE}, '{$FILLS}');
 {/foreach}
 
@@ -137,12 +137,12 @@
 <div class="warnings" style="display:none;">
   <ul>
-    <li>hohiho</li>
+    <li>null</li>
   </ul>
 </div>
 
 <p>
-  <b>Nb albums</b>: <span class="nb_categories">0</span>/{$nb_categories}<br>
-  <b>Nb pictures</b>: <span class="nb_pictures">0</span>/{$nb_pictures}<br>
-  <b>Errors</b>: <span class="nb_errors">0</span><br>
+  <b>{'Nb albums'|@translate}</b>: <span class="nb_categories">0</span>/{$nb_categories}<br>
+  <b>{'Nb photos'|@translate}</b>: <span class="nb_pictures">0</span>/{$nb_pictures}<br>
+  <b>{'Errors'|@translate}</b>: <span class="nb_errors">0</span><br>
   <br>
   <img class="loading" src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif">
Index: /extensions/pbase2piwigo/include/functions.inc.php
===================================================================
--- /extensions/pbase2piwigo/include/functions.inc.php	(revision 17313)
+++ /extensions/pbase2piwigo/include/functions.inc.php	(revision 17314)
@@ -309,60 +309,113 @@
  * @return: bool
  */
-function test_remote_download()
-{
-  return function_exists('curl_init') || ini_get('allow_url_fopen');
+if (!function_exists('test_remote_download'))
+{
+  function test_remote_download()
+  {
+    return function_exists('curl_init') || ini_get('allow_url_fopen');
+  }
 }
 
 /**
  * download a remote file
- * @param: string source
- * @param: string destination
- * @return: bool
- */
-function download_remote_file($src, $dest)
-{
-  if (function_exists('curl_init'))
-  {
-    $newf = fopen($dest, "wb");
-    $ch = curl_init();
-    
-    curl_setopt($ch, CURLOPT_URL, $src);
-    curl_setopt($ch, CURLOPT_HEADER, 0);
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en"));
-    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
-    curl_setopt($ch, CURLOPT_FILE, $newf);
-    
-    if (curl_exec($ch) === false)
-    {
-      return 'file_error';
-    }
-    
-    curl_close($ch);
-    fclose($newf);
-    
-    return true;
-  }
-  else if (ini_get('allow_url_fopen'))
-  {
-    $opts = array(
-      'http' => array(
-        'method' => "GET",
-        'user_agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
-        'header' => "Accept-language: en",
-      )
-    );
-
-    $context = stream_context_create($opts);
-    
-    if (($file = file_get_contents($src, false, $context)) === false)
-    {
-      return 'file_error';
-    }
-    file_put_contents($dest, $file);
-    
-    return true;
-  }
-  
-  return false;
+ *  - needs cURL or allow_url_fopen
+ *  - take care of SSL urls
+ *
+ * @param: string source url
+ * @param: mixed destination file (if true, file content is returned)
+ */
+if (!function_exists('download_remote_file'))
+{
+  function download_remote_file($src, $dest)
+  {
+    if (empty($src))
+    {
+      return false;
+    }
+    
+    $return = ($dest === true) ? true : false;
+    
+    /* curl */
+    if (function_exists('curl_init'))
+    {
+      if (!$return)
+      {
+        $newf = fopen($dest, "wb");
+      }
+      $ch = curl_init();
+      
+      curl_setopt($ch, CURLOPT_URL, $src);
+      curl_setopt($ch, CURLOPT_HEADER, 0);
+      curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en"));
+      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
+      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+      curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
+      if (strpos($src, 'https://') !== false)
+      {
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+      }
+      if (!$return)
+      {
+        curl_setopt($ch, CURLOPT_FILE, $newf);
+      }
+      else
+      {
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+      }
+      
+      if (($out = curl_exec($ch)) === false)
+      {
+        return 'file_error';
+      }
+      
+      curl_close($ch);
+      
+      if (!$return)
+      {
+        fclose($newf);
+        return true;
+      }
+      else
+      {
+        return $out;
+      }
+    }
+    /* file get content */
+    else if (ini_get('allow_url_fopen'))
+    {
+      if (strpos($src, 'https://') !== false and !extension_loaded('openssl'))
+      {
+        return false;
+      }
+      
+      $opts = array(
+        'http' => array(
+          'method' => "GET",
+          'user_agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
+          'header' => "Accept-language: en",
+        )
+      );
+
+      $context = stream_context_create($opts);
+      
+      if (($file = file_get_contents($src, false, $context)) === false)
+      {
+        return 'file_error';
+      }
+      
+      if (!$return)
+      {
+        file_put_contents($dest, $file);
+        return true;
+      }
+      else
+      {
+        return $file;
+      }
+    }
+    
+    return false;
+  }
 }
 
@@ -397,19 +450,22 @@
  * @return: array
  */
-function array_unique_deep(&$array, $key)
-{
-  $values = array();
-  foreach ($array as $k1 => $row)
-  {
-    foreach ($row as $k2 => $v)
-    {
-      if ($k2 == $key)
-      {
-        $values[ $k1 ] = $v;
-        continue;
-      }
-    }
-  }
-  return array_unique($values);
+if (!function_exists('array_unique_deep'))
+{
+  function array_unique_deep(&$array, $key)
+  {
+    $values = array();
+    foreach ($array as $k1 => $row)
+    {
+      foreach ($row as $k2 => $v)
+      {
+        if ($k2 == $key)
+        {
+          $values[ $k1 ] = $v;
+          continue;
+        }
+      }
+    }
+    return array_unique($values);
+  }
 }
 
@@ -423,33 +479,36 @@
  * @return key or array of keys
  */
-function array_pos($needle, &$haystack, $match_all=false, $preg_mode=false)
-{
-  if ($match_all) $matches = array();
-  
-  foreach ($haystack as $i => $row)
-  {
-    if (!is_array($row))
-    {
-      if (!$preg_mode)
-      {
-        if (strpos($row, $needle) !== false)
+if (!function_exists('array_pos'))
+{
+  function array_pos($needle, &$haystack, $match_all=false, $preg_mode=false)
+  {
+    if ($match_all) $matches = array();
+    
+    foreach ($haystack as $i => $row)
+    {
+      if (!is_array($row))
+      {
+        if (!$preg_mode)
         {
-          if (!$match_all) return $i;
-          else array_push($matches, $i);
+          if (strpos($row, $needle) !== false)
+          {
+            if (!$match_all) return $i;
+            else array_push($matches, $i);
+          }
         }
-      }
-      else
-      {
-        if (preg_match($needle, $row) === 1)
+        else
         {
-          if (!$match_all) return $i;
-          else array_push($matches, $i);
+          if (preg_match($needle, $row) === 1)
+          {
+            if (!$match_all) return $i;
+            else array_push($matches, $i);
+          }
         }
       }
     }
-  }
-  
-  if ( !$match_all or !count($matches) ) return false;
-  return $matches;
+    
+    if ( !$match_all or !count($matches) ) return false;
+    return $matches;
+  }
 }
 
Index: /extensions/pbase2piwigo/include/ws_functions.inc.php
===================================================================
--- /extensions/pbase2piwigo/include/ws_functions.inc.php	(revision 17313)
+++ /extensions/pbase2piwigo/include/ws_functions.inc.php	(revision 17314)
@@ -111,9 +111,4 @@
   $category = &get_current_cat($tree, $params['path']);
   
-  if ($category['path'] == '/root')
-  {
-    $category['title'] = 'Import PBase';
-  }
-  
   // add category
   $query = '
@@ -143,5 +138,5 @@
     'pictures' => array(),
     'categories' => array(),
-    'message' => sprintf(l10n('Album "%s" added'), $category['title']),
+    'message' => sprintf(l10n('Album "%s" created'), $category['title']),
     );
     
Index: /extensions/pbase2piwigo/language/en_UK/description.txt
===================================================================
--- /extensions/pbase2piwigo/language/en_UK/description.txt	(revision 17313)
+++ /extensions/pbase2piwigo/language/en_UK/description.txt	(revision 17314)
@@ -1,1 +1,1 @@
-Extension for importing pictures from PBase
+Import photos from PBase
Index: /extensions/pbase2piwigo/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/pbase2piwigo/language/en_UK/plugin.lang.php	(revision 17313)
+++ /extensions/pbase2piwigo/language/en_UK/plugin.lang.php	(revision 17314)
@@ -1,5 +1,21 @@
 <?php
 
-
+$lang['No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'] = 'No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true';
+$lang['Import queue is empty'] = 'Import queue is empty';
+$lang['Invalid user id'] = 'Invalid user id';
+$lang['Album "%s" created'] = 'Album "%s" created';
+$lang['Photo "%s" imported'] = 'Photo "%s" imported';
+$lang['PBase login'] = 'PBase login';
+$lang['Begin analyse'] = 'Begin analyse';
+$lang['Select albums to import'] = 'Select albums to import';
+$lang['Nb albums'] = 'Nb albums';
+$lang['Nb photos'] = 'Nb photos';
+$lang['Import in this album'] = 'Import in this album';
+$lang['Fill these fields from pBase datas'] = 'Fill these fields from pBase datas';
+$lang['%1$d errors occured. %2$d albums and %3$d photos added.'] = '%1$d errors occured. %2$d albums and %3$d photos added.';
+$lang['Completed. %1$d albums and %2$d photos added.'] = 'Completed. %1$d albums and %2$d photos added.';
+$lang['Errors'] = 'Errors';
+$lang['Recursive'] = 'Recursive';
+$lang['Begin transfer'] = 'Begin transfer';
 
 ?>
Index: /extensions/pbase2piwigo/language/fr_FR/description.txt
===================================================================
--- /extensions/pbase2piwigo/language/fr_FR/description.txt	(revision 17313)
+++ /extensions/pbase2piwigo/language/fr_FR/description.txt	(revision 17314)
@@ -1,1 +1,1 @@
-Extension pour importer des photos depuis PBase
+Importez des photos depuis PBase
Index: /extensions/pbase2piwigo/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/pbase2piwigo/language/fr_FR/plugin.lang.php	(revision 17313)
+++ /extensions/pbase2piwigo/language/fr_FR/plugin.lang.php	(revision 17314)
@@ -1,4 +1,21 @@
 <?php
 
+$lang['No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'] = 'Aucune fonction de téléchargement disponible. PBase2Piwigo a besoin de l\'extension cURL ou du réglage allow_url_fopen=true';
+$lang['Import queue is empty'] = 'File d\'attente vide';
+$lang['Invalid user id'] = 'Identifiant invdalie';
+$lang['Album "%s" created'] = 'Album "%s" créé';
+$lang['Photo "%s" imported'] = 'Photo "%s" importée';
+$lang['PBase login'] = 'Identifiant PBase';
+$lang['Begin analyse'] = 'Démarre l\'analyse';
+$lang['Select albums to import'] = 'Selectionnez les albums à importer';
+$lang['Nb albums'] = 'Nb d\'albums';
+$lang['Nb photos'] = 'Nb de photos';
+$lang['Import in this album'] = 'Importer dans cet album';
+$lang['Fill these fields from pBase datas'] = 'Remplir ces champs à partir des données de PBase';
+$lang['%1$d errors occured. %2$d albums and %3$d photos added.'] = '%1$d erreurs. %2$d albums et %3$d photos ajoutés.';
+$lang['Completed. %1$d albums and %2$d photos added.'] = 'Terminé. %1$d albums et %2$d photos ajoutés.';
+$lang['Errors'] = 'Erreurs';
+$lang['Recursive'] = 'Recursif';
+$lang['Begin transfer'] = 'Démarrer le transfert';
 
 
Index: /extensions/pbase2piwigo/main.inc.php
===================================================================
--- /extensions/pbase2piwigo/main.inc.php	(revision 17313)
+++ /extensions/pbase2piwigo/main.inc.php	(revision 17314)
@@ -3,6 +3,6 @@
 Plugin Name: PBase2Piwigo
 Version: auto
-Description: Extension for importing pictures from PBase
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
+Description: Import photos from PBase
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=627
 Author: Mistic
 Author URI: http://www.strangeplanet.fr
