Index: /extensions/AMetaData/admin/amd_help.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_help.tpl	(revision 5958)
+++ /extensions/AMetaData/admin/amd_help.tpl	(revision 5959)
@@ -1,5 +1,5 @@
 {$statTabsheet}
 
-<h3>{'g003_metadata'|@translate}&nbsp;{$data.title}</h3>
+<h2>{'g003_metadata'|@translate}&nbsp;{$data.title}</h2>
 
 <div id="helpBody">
Index: /extensions/AMetaData/admin/amd_metadata_database.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_database.tpl	(revision 5958)
+++ /extensions/AMetaData/admin/amd_metadata_database.tpl	(revision 5959)
@@ -1,9 +1,13 @@
 {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
-{known_script id="jquery.ui.slider" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.slider.packed.js"}
 {known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
-
 
 {literal}
 <script type="text/javascript">
+var processAnalyze = {
+      step:0,
+      lists:new Array(),
+      timeStart:0,
+      timeEnd:0
+    }
 
   function init()
@@ -45,6 +49,4 @@
   function doAnalyze()
   {
-    $("body").css("cursor", "wait");
-
     mode="all";
     modeLabel="";
@@ -72,5 +74,5 @@
 
 
-    doAnalyze="<br><form id='iDialogProgress' class='formtable'>"+
+    doAnalyzeDialog="<br><form id='iDialogProgress' class='formtable'>"+
       "<div id='iprogressbar_contener' class='gcBorderInput'>"+
       "<span id='iprogressbar_bg' class='gcBgInput' style='width:0%;'>&nbsp;</span>"+
@@ -92,5 +94,5 @@
         title: '{/literal}{"g003_updating_metadata"|@translate}{literal}&nbsp;('+modeLabel+')',
       }
-    ).html(doAnalyze);
+    ).html(doAnalyzeDialog);
 
     NumberOfItemsPerRequest=$("#iamd_NumberOfItemsPerRequest").val();
@@ -100,9 +102,12 @@
         type: "POST",
         url: "{/literal}{$datas.urlRequest}{literal}",
-        async: false,
+        async: true,
         data: { ajaxfct:"makeStatsGetList", selectMode:mode, numOfItems:NumberOfItemsPerRequest },
         success: function(msg)
           {
-            doStep_getList(msg);
+            processAnalyze.step=0;
+            processAnalyze.lists=msg.split(";");
+            processAnalyze.timeStart=new Date();
+            doStep_processList();
           },
         error: function()
@@ -124,69 +129,75 @@
   }
 
-  function doStep_getList(data)
-  {
-    timeStart = new Date();
-    list=data.split(";");
-    for(i=0;i<list.length-1;i++)
+  function doStep_processList()
+  {
+    if(processAnalyze.step < processAnalyze.lists.length)
     {
       tmp = $.ajax({
         type: "POST",
         url: "{/literal}{$datas.urlRequest}{literal}",
-        async: false,
-        data: { ajaxfct:"makeStatsDoAnalyze", imagesList:list[i] }
-       }).responseText;
-
-      pct=100*(i+1)/list.length;
+        async: true,
+        data: { ajaxfct:"makeStatsDoAnalyze", imagesList:processAnalyze.lists[processAnalyze.step] },
+        success: function(msg)
+          {
+            processAnalyze.step++;
+            doStep_processList();
+          },
+       });
+
+      pct=100*(processAnalyze.step+1)/processAnalyze.lists.length;
       $("#iprogressbar_bg").css("width", pct+"%");
       $("#iprogressbar_fg").html(Math.round(pct)+"%");
     }
-
-    tmp = $.ajax({
-      type: "POST",
-      url: "{/literal}{$datas.urlRequest}{literal}",
-      async: false,
-      data: { ajaxfct:"makeStatsConsolidation" }
-     }).responseText;
-
-
-    timeEnd = new Date();
-    timeElapsed=timeEnd.getTime()-timeStart.getTime();
-
-
-    $("#dialog")
-    .dialog("destroy")
-    .html("")
-    .get(0).removeAttribute('style');
-
-    $("#dialog")
-    .dialog(
-      {
-        resizable: false,
-        width:480,
-        height:120,
-        modal: true,
-        draggable:true,
-        dialogClass: 'gcBgTabSheet gcBorder',
-        title: '{/literal}{"g003_updating_metadata"|@translate}{literal}',
-        dialogClass: 'gcBgTabSheet gcBorder',
-        open: function(event, ui)
+    else
+    {
+      // list completely processed
+
+      tmp = $.ajax({
+        type: "POST",
+        url: "{/literal}{$datas.urlRequest}{literal}",
+        async: false,
+        data: { ajaxfct:"makeStatsConsolidation" }
+       }).responseText;
+
+
+      processAnalyze.timeEnd = new Date();
+      timeElapsed=processAnalyze.timeEnd.getTime()-processAnalyze.timeStart.getTime();
+
+
+      $("#dialog")
+      .dialog("destroy")
+      .html("")
+      .get(0).removeAttribute('style');
+
+      $("#dialog")
+      .dialog(
         {
-          bH=$("div.ui-dialog-buttonpane").get(0).clientHeight;
-          $("#dialog").css('height', (this.clientHeight-bH)+"px");
-        },
-        buttons:
-        {
-          '{/literal}{"g003_ok"|@translate}{literal}':
-            function()
-            {
-              $(this).dialog('destroy').html("").get(0).removeAttribute('style');
-            }
+          resizable: false,
+          width:480,
+          height:120,
+          modal: true,
+          draggable:true,
+          dialogClass: 'gcBgTabSheet gcBorder',
+          title: '{/literal}{"g003_updating_metadata"|@translate}{literal}',
+          dialogClass: 'gcBgTabSheet gcBorder',
+          open: function(event, ui)
+          {
+            bH=$("div.ui-dialog-buttonpane").get(0).clientHeight;
+            $("#dialog").css('height', (this.clientHeight-bH)+"px");
+          },
+          buttons:
+          {
+            '{/literal}{"g003_ok"|@translate}{literal}':
+              function()
+              {
+                $(this).dialog('destroy').html("").get(0).removeAttribute('style');
+              }
+          }
         }
-      }
-    )
-    .html("<br>{/literal}{'g003_analyze_is_finished'|@translate}{literal}&nbsp;("+displayTime(timeElapsed/1000)+")");
-
-    getStatus();
-    $("body").css("cursor", "default");
+      )
+      .html("<br>{/literal}{'g003_analyze_is_finished'|@translate}{literal}&nbsp;("+displayTime(timeElapsed/1000)+")");
+
+      getStatus();
+    }
   }
 
@@ -196,5 +207,5 @@
 {/literal}
 
-<h3>{'g003_status_of_database'|@translate}</h3>
+<h2>{'g003_status_of_database'|@translate}</h2>
 
 <div id="dialog"></div>
Index: /extensions/AMetaData/admin/amd_metadata_display.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_display.tpl	(revision 5958)
+++ /extensions/AMetaData/admin/amd_metadata_display.tpl	(revision 5959)
@@ -359,5 +359,5 @@
 
 
-<h3>{'g003_display_management'|@translate}</h3>
+<h2>{'g003_display_management'|@translate}</h2>
 
 <div class="addGroup">
Index: /extensions/AMetaData/admin/amd_metadata_select.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 5958)
+++ /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 5959)
@@ -202,5 +202,5 @@
 
 
-<h3>{'g003_select_metadata'|@translate}</h3>
+<h2>{'g003_select_metadata'|@translate}</h2>
 
 <form>
Index: /extensions/AMetaData/amd.css
===================================================================
--- /extensions/AMetaData/amd.css	(revision 5958)
+++ /extensions/AMetaData/amd.css	(revision 5959)
@@ -1,12 +1,2 @@
-
-.formtable, .formtable P { text-align:left; display:block; }
-.formtable tr { vertical-align:top; }
-.littlefont { font-size:90%; }
-.littlefont td { padding:1px; }
-table.littlefont th { padding:3px; text-align:left;}
-table.littlefont td { padding:1px 3px; }
-#iprogressbar_contener { margin:0px; padding:0px; display:block; height:20px; border-width:1px; border-style:solid;}
-#iprogressbar_bg { display:block; z-index:100; position:relative; height:20px; }
-#iprogressbar_fg { width:100%; text-align:center; display: block; z-index:200; position:relative; top:-18px;  }
 #iHeaderListTags { width:100%; border:1px solid; border-collapse: collapse; margin-top:3px; }
 #iListTags { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
@@ -19,25 +9,6 @@
 #iListImages.clear table tr:hover, table.clear tr:hover { color: #D54E21; background:#dbe8f3; cursor:default; }
 #iHeaderListImages { width:100%; border-bottom:1px solid; }
-.nfo ul { margin-top:0em; margin-bottom:1em; }
-.warning { color:#ffffff; background:#dd0000; margin-bottom:8px; margin-top:8px; padding:8px; }
-.warning p, .nfo p { margin-top:0.5em; margin-bottom:0em; }
-.warning ul { margin-top:0em; margin-bottom:0.5em; }
-.pctBarroma { height:6px; background:#FF7700; }
-.pctBarclear { height:6px; background:#005E89; }
-li.groupItems { border:1px solid #666666; margin-bottom:5px; padding:0 5px; width:90%; cursor:move; padding:4px; }
 div.addGroup { padding-left:40px; text-align:left; }
 #iGroups { list-style: none; }
-
-.ui-dialog { border-width:1px; border-style:solid; }
-.ui-dialog-buttonpane { padding:4px; }
-.ui-dialog-buttonpane button { margin-right:8px; }
-.ui-dialog-titlebar { font-weight:bold; }
-.ui-dialog-title-dialog { text-align: left; }
-.ui-dialog-titlebar-close { float: right; }
-.ui-dialog-content { overflow:auto; }
-.ui-dialog-container { }
-.ui-dialog-titlebar-close { display:none; }
-
-.ui-widget-overlay { background:#000000; opacity:0.5; filter:alpha(opacity:50); position:absolute; top:0px; left:0px; }
 
 .tagListOrder { list-style: none; padding:0px; margin-right:8px; margin-left:35px; }
@@ -46,33 +17,11 @@
 .editGroupListButton { margin-left:8px; position:absolute; z-index:1000; }
 table.tagListOrderItem { width:100%; border-collapse:collapse; }
-.dialogForm { text-align:left; margin:8px; }
+
 #ianalyzestatus { margin:8px; padding:8px; }
 #ianalyzestatus ul { margin:0px; padding:0 0 0 20px; }
 #iamd_nb_item_per_request_display { display:inline-block; width:70px; }
 #iamd_nb_item_per_request_slider { display:inline-block; width:350px; }
-#iDialogProgress { margin:16px 8px 8px; }
 #helpBody { text-align: left; padding-top:30px; }
 #helpBody ul { padding:0px; margin:0px; }
 #helpBody li { margin-left:30px; }
-#iDialogProgress p { text-align: center; margin-top: 8px; margin-bottom: 0pt; }
 
-.tabsheet2 {
-display:table;
-font-family:verdana,arial,helvetica,sans-serif; font-size:8px;
-list-style-image:none; padding: 0 0 0 10px; position:relative; text-decoration:none;
-white-space:nowrap; margin: 0 0 0 -6px;top:-21px;border-bottom:1px solid;
-width:100%;
-}
-.tabsheet2 li { float:left; margin:0 0 0 0; overflow:hidden; text-align:right; border-width:1px; position:relative; }
-.tabsheet2 a {
-display:block; font-size:11px; border:0;
-font-weight:bold; overflow:hidden; padding:2px 6px;
-text-align:right; text-decoration:none; margin: 0; }
-.tabsheet2 a:first-letter { text-transform:capitalize; }
-
-.tabsheet2 li:hover, .tabsheet2 li.selected_tab  {
-padding-top:6px; border-bottom:5px solid;
- }
-/* .tabsheet a:hover */
-.tabsheet2 a span { display:block; font-size:10px; margin-right:2px; padding:0 3px 0 1px; }
-
Index: /extensions/AMetaData/amd_aip.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_aip.class.inc.php	(revision 5958)
+++ /extensions/AMetaData/amd_aip.class.inc.php	(revision 5959)
@@ -115,4 +115,5 @@
   {
     add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
+    GPCCss::applyGpcCss();
   }
 
@@ -603,5 +604,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         if($row['groupId']==-1)
@@ -633,5 +634,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $datas['groups'][]=Array(
@@ -732,5 +733,5 @@
 
     $data=Array(
-      'sheetContent' => $this->BBtoHTML($lang['g003_help_'.$tab]),
+      'sheetContent' => GPCCore::BBtoHTML($lang['g003_help_'.$tab]),
       'title' => l10n('g003_help_tab_'.$tab),
     );
@@ -740,48 +741,4 @@
     $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');
   }
-
-
-
-  /**
-   * convert (light) BB tag to HTML tag
-   *
-   * all BB codes are not recognized, only :
-   *  - [ul] [/ul]
-   *  - [li] [/li]
-   *  - [b] [/b]
-   *  - [i] [/i]
-   *  - [url] [/url]
-   *  - carriage return is replaced by a <br>
-   *
-   * @param String $text : text to convert
-   * @return String : BB to HTML text
-   */
-  protected function BBtoHTML($text)
-  {
-    $patterns = Array(
-      '/\[li\](.*?)\[\/li\]\n*/im',
-      '/\[b\](.*?)\[\/b\]/ism',
-      '/\[i\](.*?)\[\/i\]/ism',
-      '/\[url\]([\w]+?:\/\/[^ \"\n\r\t<]*?)\[\/url\]/ism',
-      '/\[url=([\w]+?:\/\/[^ \"\n\r\t<]*?)\](.*?)\[\/url\]/ism',
-      '/\n{0,1}\[ul\]\n{0,1}/im',
-      '/\n{0,1}\[\/ul\]\n{0,1}/im',
-      '/\n/im',
-    );
-    $replacements = Array(
-      '<li>\1</li>',
-      '<b>\1</b>',
-      '<i>\1</i>',
-      '<a href="\1">\1</a>',
-      '<a href="\1">\2</a>',
-      '<ul>',
-      '</ul>',
-      '<br>',
-    );
-
-    return(preg_replace($patterns, $replacements, $text));
-  }
-
-
 
 
@@ -827,5 +784,7 @@
 
       $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id
-            WHERE ct.user_id = ".$user['id'].";";
+            WHERE ct.user_id = ".$user['id']." ";
+
+      if($mode=="caddieAdd") $sql.=" AND ait.analyzed='n'";
     }
 
@@ -841,5 +800,5 @@
     {
       $i=0;
-      while($row=mysql_fetch_row($result))
+      while($row=pwg_db_fetch_row($result))
       {
         $returned.=$row[0];
@@ -876,5 +835,5 @@
     $returned="";
 
-    if(count($list)>0)
+    if(count($list)>0 and trim($imagesList)!='')
     {
       // $path = path of piwigo's on the server filesystem
@@ -885,5 +844,5 @@
       if($result)
       {
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           /*
@@ -938,5 +897,5 @@
     if($result)
     {
-      while($row=mysql_fetch_row($result))
+      while($row=pwg_db_fetch_row($result))
       {
         $numOfPictures=$row[0];
@@ -951,5 +910,5 @@
     if($result)
     {
-      while($row=mysql_fetch_row($result))
+      while($row=pwg_db_fetch_row($result))
       {
         $numOfPicturesNotAnalyzed=$row[0];
@@ -962,5 +921,5 @@
     if($result)
     {
-      while($row=mysql_fetch_row($result))
+      while($row=pwg_db_fetch_row($result))
       {
         $numOfPicturesWithoutTags=$row[0];
@@ -1051,5 +1010,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $datas[]=array(
@@ -1110,5 +1069,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $datas[]=array(
@@ -1148,5 +1107,5 @@
       if($result)
       {
-        if(mysql_num_rows($result)==0)
+        if(pwg_db_num_rows($result)==0)
         {
           $sql="INSERT INTO ".$this->tables['selected_tags']."
@@ -1197,5 +1156,5 @@
       {
         $datas=Array();
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           if($row['groupId']==$id)
@@ -1298,5 +1257,5 @@
       {
         $datas=Array();
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           $datas[]=Array(
@@ -1410,5 +1369,5 @@
       $sql="INSERT INTO ".$this->tables['groups']." VALUES('', 9999)";
       $result=pwg_query($sql);
-      $groupId=mysql_insert_id();
+      $groupId=pwg_db_insert_id();
     }
 
@@ -1470,5 +1429,5 @@
       if($result)
       {
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           if(array_key_exists($row['lang'], $datasLang['language_list']))
@@ -1519,5 +1478,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $datas['groups'][]=Array(
Index: /extensions/AMetaData/amd_install.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_install.class.inc.php	(revision 5958)
+++ /extensions/AMetaData/amd_install.class.inc.php	(revision 5959)
@@ -164,5 +164,5 @@
       if($result)
       {
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           $listToAnalyze[0][]=$row;
@@ -190,5 +190,5 @@
         if($result)
         {
-          while($row=mysql_fetch_assoc($result))
+          while($row=pwg_db_fetch_assoc($result))
           {
             $listToAnalyze[0][]=$row;
Index: /extensions/AMetaData/amd_pip.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_pip.class.inc.php	(revision 5958)
+++ /extensions/AMetaData/amd_pip.class.inc.php	(revision 5959)
@@ -69,5 +69,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $filename=$row['path'];
@@ -105,5 +105,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $tagsList[$row['tagId']]=$row['gName'];
Index: /extensions/AMetaData/amd_root.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_root.class.inc.php	(revision 5958)
+++ /extensions/AMetaData/amd_root.class.inc.php	(revision 5959)
@@ -115,5 +115,5 @@
     if($result)
     {
-      while($row=mysql_fetch_row($result))
+      while($row=pwg_db_fetch_row($result))
       {
         $numOfPictures=$row[0];
@@ -141,5 +141,5 @@
       $path=dirname(dirname(dirname(__FILE__)));
 
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $this->analyzeImageFile($path."/".$row['path'], $row['imageId']);
@@ -215,5 +215,5 @@
       {
         $numId=-1;
-        while($row=mysql_fetch_assoc($result))
+        while($row=pwg_db_fetch_assoc($result))
         {
           $numId=$row['numId'];
@@ -268,5 +268,5 @@
     if($result)
     {
-      while($row=mysql_fetch_assoc($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $this->config['amd_AllPicturesAreAnalyzed']=($row['nb']==0)?'y':'n';
Index: /extensions/AMetaData/main.inc.php
===================================================================
--- /extensions/AMetaData/main.inc.php	(revision 5958)
+++ /extensions/AMetaData/main.inc.php	(revision 5959)
@@ -23,11 +23,17 @@
 | release | date       |
 | 0.0     | 2010/01/21 | * start coding
+|         |            |
 | 0.1b    | 2010/03/21 | * beta release
+|         |            |
 | 0.2b    | 2010/03/23 | * beta release
+|         |            |
 | 0.3b    | 2010/04/11 | * beta release
-| 0.4b    | 2010/04/18 | * beta release for Piwigo 2.1
 |         |            |
-|         |            |
-|         |            |
+| 0.4b    | 2010/04/24 | * beta release for Piwigo 2.1
+|         |            | * uses some GPC 3.1.0 functions
+|         |            | * optimize ajax request to fill the metadata database
+|         |            | * replace all the 'mysql_*' functions with 'pwg_db_*'
+|         |            |   functions
+|         |            | * update some html/css
 |         |            |
 |         |            |
Index: /extensions/AMetaData/maintain.inc.php
===================================================================
--- /extensions/AMetaData/maintain.inc.php	(revision 5958)
+++ /extensions/AMetaData/maintain.inc.php	(revision 5959)
@@ -35,10 +35,10 @@
  * -------------------------------------------------------------------------- */
 $gpc_installed=false;
-$gpcNeeded="3.0.0";
+$gpcNeeded="3.1.0";
 if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
 {
   @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
-  // need GPC release greater or equal than 3.0.0
-  if(CommonPlugin::checkGPCRelease(3,0,0))
+  // need GPC release greater or equal than 3.1.0
+  if(CommonPlugin::checkGPCRelease(3,1,0))
   {
     @include_once("amd_install.class.inc.php");
