Index: /extensions/AMetaData/admin/amd_metadata_database_database.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_database_database.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_database_database.tpl	(revision 6950)
@@ -296,5 +296,5 @@
 
         {if $amdConfig.amd_DisplayWarningsMessageUpdate=='y'}
-          <div style="padding-left: 60px;" class="warnings">
+          <div class="warnings">
             <p style="font-size: 120%;">{'g003_warning_on_analyze_0'|@translate}</p>
             <p>{'g003_warning_on_analyze_1'|@translate}</p>
Index: /extensions/AMetaData/admin/amd_metadata_database_status.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_database_status.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_database_status.tpl	(revision 6950)
@@ -2,5 +2,5 @@
 
 {if $amdConfig.amd_DisplayWarningsMessageStatus=='y'}
-<div style="padding-left: 60px;" class="warnings">
+<div class="warnings">
 <p style="font-size: 120%;">{'g003_databaseInformation'|@translate}</p>
 {$datas.warning1}
Index: /extensions/AMetaData/admin/amd_metadata_display.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_display.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_display.tpl	(revision 6950)
@@ -351,4 +351,8 @@
 <h2>{'g003_display_management'|@translate}</h2>
 
+<div class='helps'>
+  <p>{'g003_display_page_help'|@translate}</p>
+</div>
+
 <div class="addGroup">
   <a onclick="editGroup('');">{'g003_add_a_group'|@translate}</a>
Index: /extensions/AMetaData/admin/amd_metadata_display_groupListTagOrder.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_display_groupListTagOrder.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_display_groupListTagOrder.tpl	(revision 6950)
@@ -6,7 +6,9 @@
       <td style="width:30%;">{$data.tagId}</td>
       <td>{$data.name}</td>
-      <td style="width:35px;text-align:right;">{$data.nbItems}</td>
-      <td style="width:50px;text-align:right;">{$data.pct}%</td>
-      <td style="width:104px;"><span class="pctBar{$themeconf.name}" style="display:inline-block;width:{$data.pct}px;"></td>
+      {if $data.pct!=''}
+        <td style="width:35px;text-align:right;">{$data.nbItems}</td>
+        <td style="width:50px;text-align:right;">{$data.pct}%</td>
+        <td style="width:104px;"><span class="pctBar{$themeconf.name}" style="display:inline-block;width:{$data.pct}px;"></td>
+      {/if}
     </tr>
   </table>
Index: /extensions/AMetaData/admin/amd_metadata_personnal.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_personnal.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_personnal.tpl	(revision 6950)
@@ -604,4 +604,8 @@
 <h2>{'g003_personnal_metadata'|@translate}</h2>
 
+<div class='helps'>
+  <p>{'g003_personnal_page_help'|@translate}</p>
+</div>
+
 <div class='addMetadata'>
   <a onclick="udm.editMetadata('');">{'g003_add_a_new_md'|@translate}</a>
@@ -612,5 +616,4 @@
     <th style="width:35%;min-width:340px;">{'g003_TagId'|@translate}</th>
     <th>{'g003_TagLabel'|@translate}</th>
-    <th style="width:15%;">{'g003_fill_database'|@translate}</th>
     <th style="width:15%;">{'g003_num_of_rules'|@translate}</th>
     <th width="40px">&nbsp;</th>
Index: /extensions/AMetaData/admin/amd_metadata_personnal_iListTags.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_personnal_iListTags.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_personnal_iListTags.tpl	(revision 6950)
@@ -4,5 +4,4 @@
     <td style="width:35%;min-width:340px;">{$data.tagId}</td>
     <td>{$data.label}</td>
-    <th style="width:15%;">{$data.fillDatabase}</th>
     <th style="width:15%;">{$data.numOfRules}</th>
     <td width="40px">
Index: /extensions/AMetaData/admin/amd_metadata_search.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_search.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_search.tpl	(revision 6950)
@@ -2,3 +2,7 @@
 <h2>{'g003_search'|@translate}</h2>
 
+<div class='helps'>
+  <p>{'g003_search_page_help'|@translate}</p>
+</div>
+
 {$amd_search_page}
Index: /extensions/AMetaData/admin/amd_metadata_select.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 6949)
+++ /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 6950)
@@ -195,4 +195,8 @@
 <h2>{'g003_select_metadata'|@translate}</h2>
 
+<div class='helps'>
+  <p>{'g003_select_page_help'|@translate}</p>
+</div>
+
 <form>
   <input type="hidden" id="iSelectOrderTagList" value="{$datas.config_GetListTags_OrderType}"/>
Index: /extensions/AMetaData/admin/amd_metadata_tags.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_tags.tpl	(revision 6950)
+++ /extensions/AMetaData/admin/amd_metadata_tags.tpl	(revision 6950)
@@ -0,0 +1,89 @@
+
+{literal}
+<script type="text/javascript">
+
+  function displayWait()
+  {
+    $('#iListTags').html("<br>{/literal}{'g003_loading'|@translate}{literal}<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
+  }
+
+  function loadKeywordsList()
+  {
+    $.ajax(
+      {
+        type: "POST",
+        url: "{/literal}{$datas.urlRequest}{literal}",
+        async: true,
+        data: { ajaxfct:"admin.tags.getKeywords" },
+        success: function (msg)
+          {
+            $('#iListTags').html(msg);
+
+            $("#iListTagsNb").html(
+              "{/literal}{'g003_number_of_keywords'|@translate}{literal} "+$("#iListTags table tr").length
+            );
+          }
+      }
+    );
+  }
+
+  function convertKeywordsList()
+  {
+    keywords=new Array();
+
+    $('#iListTags input:checked').each(function (i,e)
+     {
+       re=/(\d+)$/i;
+       num=$(e).attr('id').match(re);
+       keywords.push($('#iTagValue'+num[1]).val());
+     }
+    );
+
+    displayWait();
+
+    $.ajax(
+      {
+        type: "POST",
+        url: "{/literal}{$datas.urlRequest}{literal}",
+        async: true,
+        data: { ajaxfct:"admin.tags.convertKeywords", keywords:keywords },
+        success: function (msg)
+          {
+            loadKeywordsList();
+            if(msg=='ok')
+            {
+              alert("{/literal}{'g003_convert_ok'|@translate}{literal}");
+            }
+          }
+      }
+    );
+  }
+
+</script>
+{/literal}
+
+<h2>{'g003_tags'|@translate}</h2>
+
+<div class='helps'>
+  <p>{'g003_tags_page_help'|@translate}</p>
+</div>
+
+<table id='iHeaderListTags' class="littlefont">
+  <tr>
+    <th style="min-width:340px;">{'g003_keyword'|@translate}</th>
+    <th style="width:120px;">{'g003_num_of_pictures'|@translate}</th>
+    <th style="width:120px;">{'g003_tag_in_piwigo'|@translate}</th>
+    <th style="width:120px;">{'g003_num_of_pictures_already_tagged'|@translate}</th>
+    <th style="width:10px"></th>
+  </tr>
+</table>
+<div id='iListTags' class="{$themeconf.name}">
+</div>
+<div id="iListTagsNb"></div>
+
+<input type="button" value="{'g003_convert_keywords_and_apply'|@translate}" id='iApply' onclick='convertKeywordsList();'>
+
+<script type='text/javascript'>
+  displayWait();
+  loadKeywordsList();
+</script>
Index: /extensions/AMetaData/admin/amd_metadata_tags_iKeywordsList.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_tags_iKeywordsList.tpl	(revision 6950)
+++ /extensions/AMetaData/admin/amd_metadata_tags_iKeywordsList.tpl	(revision 6950)
@@ -0,0 +1,24 @@
+{literal}
+<script type="text/javascript">
+  function switchState(tagId)
+  {
+    $("#"+tagId).get(0).checked=!$("#"+tagId).get(0).checked;
+  }
+</script>
+{/literal}
+
+
+<table class="littlefont listTags {$themeconf.name}" style="width:100%;">
+  {foreach from=$datas key=name item=data}
+  <tr>
+    <td width="15px">
+      <input type="checkbox" id="iTagId{$data.id}">
+      <input type="hidden" id="iTagValue{$data.id}" value="{$data.value}">
+    </td>
+    <td style="min-width:325px;" onclick="switchState('iTagId{$data.id}');">{$data.value}</td>
+    <td style="width:120px;" onclick="switchState('iTagId{$data.id}');">{$data.nbPictures}</td>
+    <td style="width:120px;" onclick="switchState('iTagId{$data.id}');">{'g003_'|cat:$data.tagExists|@translate}</td>
+    <td style="width:120px;" onclick="switchState('iTagId{$data.id}');">{if $data.nbPicturesTagged!='0'}{$data.nbPicturesTagged}{/if}</td>
+  </tr>
+  {/foreach}
+</table>
Index: /extensions/AMetaData/amd.css
===================================================================
--- /extensions/AMetaData/amd.css	(revision 6949)
+++ /extensions/AMetaData/amd.css	(revision 6950)
@@ -105,19 +105,4 @@
 }
 
-.warnings {
-  -moz-border-radius:4px;
-  -webkit-border-radius:4px;
-  -khtml-border-radius:4px;
-  border-radius:4px;
-}
-.warnings p {
-  margin:0;
-  padding:0 0 6px;
-  text-align: justify;
-}
-.warnings ul {
-  margin:-6px 0;
-  padding:0 40px 6px;
-}
 table.mdInfo {
   width:100%;
Index: /extensions/AMetaData/amd_aip.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_aip.class.inc.php	(revision 6949)
+++ /extensions/AMetaData/amd_aip.class.inc.php	(revision 6950)
@@ -49,5 +49,5 @@
     $this->tabsheet = new tabsheet();
 
-    if($this->config['amd_interfaceMode']=='basic')
+    if($this->config['amd_InterfaceMode']=='basic')
     {
       $this->tabsheet->add('metadata',
@@ -69,4 +69,7 @@
                             l10n('g003_search'),
                             $this->getAdminLink().'&amp;fAMD_tabsheet=search');
+      $this->tabsheet->add('tags',
+                            l10n('g003_tags'),
+                            $this->getAdminLink().'&amp;fAMD_tabsheet=tags');
       $this->tabsheet->add('help',
                             l10n('g003_help'),
@@ -128,4 +131,7 @@
         $this->displaySearch($_REQUEST['fAMD_page']);
         break;
+      case 'tags':
+        $this->displayTags();
+        break;
     }
 
@@ -168,5 +174,5 @@
     if(!isset($_REQUEST['fAMD_tabsheet']))
     {
-      if($this->getNumOfPictures()==0 and $this->config['amd_interfaceMode']=='advanced')
+      if($this->getNumOfPictures()==0 and $this->config['amd_InterfaceMode']=='advanced')
       {
         $_REQUEST['fAMD_tabsheet']="database";
@@ -183,10 +189,12 @@
          $_REQUEST['fAMD_tabsheet']=="help" or
          $_REQUEST['fAMD_tabsheet']=="database" or
-         $_REQUEST['fAMD_tabsheet']=="search")
+         $_REQUEST['fAMD_tabsheet']=="search" or
+         $_REQUEST['fAMD_tabsheet']=="tags")
          or
-         $this->config['amd_interfaceMode']=='basic' and
+         $this->config['amd_InterfaceMode']=='basic' and
          (
            $_REQUEST['fAMD_tabsheet']=="database" or
-           $_REQUEST['fAMD_tabsheet']=="search"
+           $_REQUEST['fAMD_tabsheet']=="search" or
+           $_REQUEST['fAMD_tabsheet']=="tags"
          )
       )
@@ -202,5 +210,5 @@
       if(!isset($_REQUEST['fAMD_page']))
       {
-        if($this->config['amd_interfaceMode']=='basic')
+        if($this->config['amd_InterfaceMode']=='basic')
         {
           $_REQUEST['fAMD_page']="display";
@@ -216,5 +224,5 @@
            $_REQUEST['fAMD_page']=="display")
            or
-           $this->config['amd_interfaceMode']=='basic' and
+           $this->config['amd_InterfaceMode']=='basic' and
            (
              $_REQUEST['fAMD_page']=="select"
@@ -222,5 +230,5 @@
         )
       {
-        if($this->config['amd_interfaceMode']=='basic')
+        if($this->config['amd_InterfaceMode']=='basic')
         {
           $_REQUEST['fAMD_page']="display";
@@ -268,4 +276,5 @@
     }
 
+
   } //init_request
 
@@ -327,5 +336,5 @@
                           l10n('g003_personnal'),
                           $this->getAdminLink().'&amp;fAMD_tabsheet=metadata&amp;fAMD_page=personnal');
-    if($this->config['amd_interfaceMode']=='advanced')
+    if($this->config['amd_InterfaceMode']=='advanced')
     {
       $statTabsheet->add('select',
@@ -362,5 +371,5 @@
   protected function displayMetaDataPersonnal()
   {
-    global $template, $theme, $themes, $themeconf;
+    global $template, $theme, $themes, $themeconf, $lang;
 
     $template->set_filename('sheet_page',
@@ -392,4 +401,6 @@
     }
 
+    $lang['g003_personnal_page_help']=GPCCore::BBtoHTML($lang['g003_personnal_page_help']);
+
     $template->assign('datas', $datas);
     return($template->parse('sheet_page', true));
@@ -404,5 +415,5 @@
   protected function displayMetaDataSelect()
   {
-    global $template, $theme, $themes, $themeconf;
+    global $template, $theme, $themes, $themeconf, $lang;
 
     $template->set_filename('sheet_page',
@@ -418,4 +429,6 @@
     );
 
+    $lang['g003_select_page_help']=GPCCore::BBtoHTML($lang['g003_select_page_help']);
+
     $template->assign('datas', $datas);
     return($template->parse('sheet_page', true));
@@ -430,5 +443,5 @@
   protected function displayMetaDataDisplay()
   {
-    global $user, $template;
+    global $user, $template, $lang;
 
     //$local_tpl = new Template(AMD_PATH."admin/", "");
@@ -490,4 +503,5 @@
     }
 
+    $lang['g003_display_page_help']=GPCCore::BBtoHTML($lang['g003_display_page_help']);
     $template->assign('datas', $datas);
     return($template->parse('sheet_page', true));
@@ -745,4 +759,26 @@
   }
 
+
+  /**
+   * display and manage the tags page
+   *
+   */
+  protected function displayTags()
+  {
+    global $template, $user, $lang;
+    $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_metadata_tags.tpl');
+
+    $datas=array(
+      'urlRequest' => $this->getAdminLink('ajax')
+    );
+
+    $lang['g003_tags_page_help']=GPCCore::BBtoHTML($lang['g003_tags_page_help']);
+
+    $template->assign('datas', $datas);
+
+    $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');
+  }
+
+
 } // AMD_AIP class
 
Index: /extensions/AMetaData/amd_aip_install.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_aip_install.class.inc.php	(revision 6949)
+++ /extensions/AMetaData/amd_aip_install.class.inc.php	(revision 6950)
@@ -421,5 +421,5 @@
 
     $this->config['newInstall']='n';
-    $this->config['amd_interfaceMode']=$interfaceMode;
+    $this->config['amd_InterfaceMode']=$interfaceMode;
     $this->saveConfig();
 
Index: /extensions/AMetaData/amd_ajax.php
===================================================================
--- /extensions/AMetaData/amd_ajax.php	(revision 6949)
+++ /extensions/AMetaData/amd_ajax.php	(revision 6950)
@@ -84,4 +84,6 @@
            $_REQUEST['ajaxfct']=='admin.userDefined.deleteTag' or
            $_REQUEST['ajaxfct']=='admin.tag.getValues' or
+           $_REQUEST['ajaxfct']=='admin.tags.getKeywords' or
+           $_REQUEST['ajaxfct']=='admin.tags.convertKeywords' or
 
            $_REQUEST['ajaxfct']=='public.makeStats.doPictureAnalyze')) $_REQUEST['ajaxfct']='';
@@ -317,4 +319,15 @@
         }
 
+        /*
+         * check admin.tags.convertKeywords values
+         */
+        if($_REQUEST['ajaxfct']=="admin.tags.convertKeywords")
+        {
+          if(!isset($_REQUEST['keywords'])) $_REQUEST['keywords']=array();
+          if(!is_array($_REQUEST['keywords'])) $_REQUEST['keywords']=array();
+          if(count($_REQUEST['keywords'])==0) $_REQUEST['ajaxfct']='';
+        }
+
+
 
 
@@ -401,4 +414,10 @@
         case 'admin.tag.getValues':
           $result=$this->ajax_amd_admin_tagGetValues($_REQUEST['id']);
+          break;
+        case 'admin.tags.getKeywords':
+          $result=$this->ajax_amd_admin_tagsGetKeywords();
+          break;
+        case 'admin.tags.convertKeywords':
+          $result=$this->ajax_amd_admin_tagsConvertKeywords($_REQUEST['keywords']);
           break;
 
@@ -942,6 +961,6 @@
               'name'  => L10n::get($row['name']),
               'numId' => $row['numId'],
-              'nbItems' => $row['numOfImg'],
-              'pct'   => ($numOfPictures==0)?"0":sprintf("%.2f", 100*$row['numOfImg']/$numOfPictures)
+              'nbItems' => ($this->config['amd_InterfaceMode']=='advanced')?$row['numOfImg']:'',
+              'pct'   => ($this->config['amd_InterfaceMode']=='advanced')?(($numOfPictures==0)?"0":sprintf("%.2f", 100*$row['numOfImg']/$numOfPictures)):''
             );
           }
@@ -1340,4 +1359,10 @@
         $result=pwg_query($sql);
         */
+
+        if($this->config['amd_InterfaceMode']=='basic')
+        {
+          $sql="INSERT INTO ".$this->tables['selected_tags']." VALUES ('".$properties['tagId']."', 0, -1);";
+          pwg_query($sql);
+        }
       }
       else
@@ -1371,5 +1396,5 @@
       foreach($properties['rules'] as $rule)
       {
-        print_r($rule['value']);
+        //print_r($rule['value']);
         $inserts[]="('$id', '".$rule['defId']."', '".$rule['parentId']."', '".$rule['order']."', '".$rule['type']."', '".$rule['value']."', '".$rule['conditionType']."', '".$rule['conditionValue']."')";
       }
@@ -1378,5 +1403,12 @@
       $result=pwg_query($sql);
 
-      $nbImg=$this->buildUserDefinedTags($id);
+      if($this->config['amd_InterfaceMode']=='advanced')
+      {
+        $nbImg=$this->buildUserDefinedTags($id);
+      }
+      else
+      {
+        $nbImg=0;
+      }
 
       $this->makeStatsConsolidation();
@@ -1463,4 +1495,186 @@
 
     /**
+     * return an html list of found keywords in the images_tags table
+     *
+     * @return String : html formatted list
+     */
+    private function ajax_amd_admin_tagsGetKeywords()
+    {
+      global $template;
+
+      $returned=array();
+      $keywordsList=array();
+      $sql="SELECT pait.value, pait.imageId, paut.numId
+            FROM (".$this->tables['images_tags']." pait
+              JOIN ".$this->tables['used_tags']." paut ON pait.numId = paut.numId)
+
+            WHERE (paut.tagId = 'xmp.dc:subject' OR
+                   paut.tagId = 'xmp.digiKam:tagsList' OR
+                   paut.tagId = 'iptc.Keywords');";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          if(preg_match('/^a:\d+:{/', $row['value']))
+          {
+            /*
+             *  if value is a serialized string, unserialize and process it
+             */
+            $tmp=unserialize($row['value']);
+            foreach($tmp['values'] as $val)
+            {
+              $keywordsList[]="('".mysql_escape_string($val)."', ".$row['imageId'].")";
+            }
+          }
+          else
+          {
+            $keywordsList[]="('".mysql_escape_string($row['value'])."', ".$row['imageId'].")";
+          }
+        }
+        $sql="CREATE TEMPORARY TABLE amd_temp_tags (
+                `value` CHAR(255) default '',
+                `imageId` mediumint(8) unsigned NOT NULL default '0',
+                PRIMARY KEY  USING BTREE (`value`,`imageId`)
+              ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
+        if(pwg_query($sql))
+        {
+          $sql="INSERT IGNORE INTO amd_temp_tags
+            VALUES ".implode(',', $keywordsList);
+          if(pwg_query($sql))
+          {
+            $sql="SELECT att.value AS value,
+                    COUNT(DISTINCT att.imageId) AS nbPictures,
+                    IF(ptt.name IS NULL, 'n', 'y') AS tagExists,
+                    COUNT(DISTINCT pit.image_id) AS nbPicturesTagged
+                  FROM (amd_temp_tags att LEFT JOIN ".TAGS_TABLE."  ptt ON att.value = ptt.name)
+                    LEFT JOIN ".IMAGE_TAG_TABLE." pit ON pit.tag_id = ptt.id
+                  GROUP BY att.value
+                  HAVING nbPicturesTagged < nbPictures";
+            $result=pwg_query($sql);
+            if($result)
+            {
+              $i=0;
+              while($row=pwg_db_fetch_assoc($result))
+              {
+                $row['id']=$i;
+                $returned[]=$row;
+                $i++;
+              }
+            }
+          }
+        }
+      }
+
+      $template->set_filename('keywordsList',
+                    dirname($this->getFileLocation()).'/admin/amd_metadata_tags_iKeywordsList.tpl');
+
+      $template->assign('datas', $returned);
+      return($template->parse('keywordsList', true));
+    }
+
+
+    /**
+     * convert given keywords into tags, and associate them to pictures
+     *
+     * @param Array $keywords : an array of strings
+     * @return String : ok or ko
+     */
+    private function ajax_amd_admin_tagsConvertKeywords($keywords)
+    {
+      global $template;
+
+      $returned='ko';
+
+      /*
+       * 1/ build a temp table with all couple of keywords/imageId
+       */
+      $keywordsList=array();
+      $sql="SELECT pait.value, pait.imageId, paut.numId
+            FROM (".$this->tables['images_tags']." pait
+              JOIN ".$this->tables['used_tags']." paut ON pait.numId = paut.numId)
+
+            WHERE (paut.tagId = 'xmp.dc:subject' OR
+                   paut.tagId = 'xmp.digiKam:tagsList' OR
+                   paut.tagId = 'iptc.Keywords');";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          if(preg_match('/^a:\d+:{/', $row['value']))
+          {
+            /*
+             *  if value is a serialized string, unserialize and process it
+             */
+            $tmp=unserialize($row['value']);
+            foreach($tmp['values'] as $val)
+            {
+              $keywordsList[]="('".mysql_escape_string($val)."', ".$row['imageId'].")";
+            }
+          }
+          else
+          {
+            $keywordsList[]="('".mysql_escape_string($row['value'])."', ".$row['imageId'].")";
+          }
+        }
+        $sql="CREATE TEMPORARY TABLE amd_temp_tags (
+                `value` CHAR(255) default '',
+                `imageId` mediumint(8) unsigned NOT NULL default '0',
+                PRIMARY KEY  USING BTREE (`value`,`imageId`)
+              ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
+        if(pwg_query($sql))
+        {
+          $sql="INSERT IGNORE INTO amd_temp_tags
+            VALUES ".implode(',', $keywordsList);
+          if(pwg_query($sql))
+          {
+            foreach($keywords as $key => $val)
+            {
+              $keywords[$key]="(att.value LIKE '".mysql_escape_string($val)."')";
+            }
+            /*
+             * 2/ join temp table with piwigo tags table, found the keywords
+             *    that don't have a corresponding keyword
+             */
+            $sql="SELECT DISTINCT att.value
+                  FROM amd_temp_tags att LEFT JOIN ".TAGS_TABLE." ptt ON att.value = ptt.name
+                  WHERE ptt.id IS NULL
+                    AND".implode(' OR ', $keywords);
+            $result=pwg_query($sql);
+            if($result)
+            {
+              $sql=array();
+              while($row=pwg_db_fetch_assoc($result))
+              {
+                $sql[]="('', '".mysql_escape_string($row['value'])."', '".mysql_escape_string(str2url($row['value']))."')";
+              }
+              if(count($sql)>0)
+              {
+                $sql="INSERT INTO ".TAGS_TABLE." VALUES ".implode(',', $sql);
+                pwg_query($sql);
+              }
+            }
+
+            /*
+             * 3/ join temp table with piwigo tags table, associate piwigo tagId
+             *    to the keywords (at this step, all keyword can be associated
+             *    with a piwigo tagId)
+             */
+            $sql="INSERT IGNORE INTO ".IMAGE_TAG_TABLE."
+                    SELECT DISTINCT att.imageId, ptt.id
+                    FROM amd_temp_tags att LEFT JOIN ".TAGS_TABLE." ptt ON att.value = ptt.name
+                    WHERE ".implode(' OR ', $keywords);
+            $result=pwg_query($sql);
+            $returned='ok';
+          }
+        }
+      }
+
+      return($returned);
+    }
+
+
+    /**
      * set value(s) for option(s)
      *
Index: /extensions/AMetaData/amd_root.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_root.class.inc.php	(revision 6949)
+++ /extensions/AMetaData/amd_root.class.inc.php	(revision 6950)
@@ -284,5 +284,5 @@
           //if($sqlInsert!="") $sqlInsert.=", ";
           //$sqlInsert.="($imageId, '$numId', '".addslashes($value)."')";
-          $massInsert[]="('$imageId', '$numId', '".addslashes($value)."') ";
+          $massInsert[]="('$imageId', '$numId', '".mysql_escape_string($value)."') ";
         }
       }
Index: /extensions/AMetaData/amd_version.inc.php
===================================================================
--- /extensions/AMetaData/amd_version.inc.php	(revision 6949)
+++ /extensions/AMetaData/amd_version.inc.php	(revision 6950)
@@ -17,5 +17,5 @@
   if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-  define('AMD_VERSION',  '0.5.0');
-  define('AMD_VERSION2', '00.05.00');
+  define('AMD_VERSION',  '0.5.1');
+  define('AMD_VERSION2', '00.05.01');
 ?>
Index: /extensions/AMetaData/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/AMetaData/language/fr_FR/plugin.lang.php	(revision 6949)
+++ /extensions/AMetaData/language/fr_FR/plugin.lang.php	(revision 6950)
@@ -286,4 +286,41 @@
 
 
+$lang['g003_tags']="Tags";
+$lang['g003_number_of_keywords']="Nombre de mots-clefs :";
+$lang['g003_keyword']="Mot-clef";
+$lang['g003_tag_in_piwigo']="Présent dans Piwigo";
+$lang['g003_num_of_pictures']="Nombre de photos";
+$lang['g003_num_of_pictures_already_tagged']="Nombre de photos déjà taggées";
+$lang['g003_convert_ok']="La conversion s'est correctement effectuée";
+$lang['g003_convert_keywords_and_apply']="Convertir";
+
+
+$lang['g003_tags_page_help']="Cette fonctionnalité effectue une extraction des mots-clefs présents dans les métadonnées de vos photos et vous permet de les convertir en [i]Tags[/i].
+Les photos pour lesquelles les mots-clefs ont déjà été convertis et associés n'apparaissent pas : seuls les mots-clefs des photos pour lesquelles une conversion et une association sont possibles sont proposés.";
+
+$lang['g003_search_page_help']="Il est possible d'effectuer diverses recherches sur le contenu des métadonnées, des plus simples au plus complexes : ajoutez des critères, et combinez-les par glisser/déposer.";
+
+$lang['g003_personnal_page_help']="Il est possible de construire très facilement vos propres métadonnées à partir des métadonnées existantes.
+[ul]
+[li]Ajoutez une nouvelles métadonnée[/li]
+[li]Renseignez ses propriétés[/li]
+[li]Ajoutez des règles de gestion et combinez-les au besoin par glisser/déposer[/li]
+[/ul]";
+
+$lang['g003_select_page_help']="Seules les métadonnées sélectionnées ici sont disponibles dans les autres interfaces de paramétrage : ceci permet de réduire la liste des métadonnées à celles qui vous semblent les plus pertinentes pour votre usage.
+La sélection est prise en compte immédiatement (il n'est pas nécessaire de la valider).";
+
+
+$lang['g003_display_page_help']="Les métadonnées affichées avec la photo peuvent être triées et regroupées.
+Par défaut, seul le groupe [i]".$lang['g003_default_group_name']."[/i] est disponible, mais il est possible d'en créer autant que nécessaire ([i]IPTC[/i], [i]Géolocalisation[/i], ...).
+[ul]
+[li]Créez les groupes de métadonnées selon vos besoins[/li]
+[li]Ajoutez-y les métadonnées à afficher[/li]
+[li]Au sein d'un groupe, triez l'ordre d'affichage des métadonnées par glisser/déposer[/li]
+[li]Triez l'ordre d'affichage des groupes par glisser/déposer[/li]
+[/ul]
+Sélections&tris sont pris en compte immédiatement (il n'est pas nécessaire de les valider).";
+
+
 /** ----------------------------------------------------------------------------
  * removed keys from releases 0.5.0/0.5.1
Index: /extensions/AMetaData/main.inc.php
===================================================================
--- /extensions/AMetaData/main.inc.php	(revision 6949)
+++ /extensions/AMetaData/main.inc.php	(revision 6950)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: Advanced MetaData
-Version: 0.5.0
+Version: 0.5.1
 Description: An advanced metadata manager
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=364
@@ -24,27 +24,40 @@
 | 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.4.0   | 2010/04/24 | * 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
 |         |            |
-| 0.5.0   | 2010/07/24 | * release 0.5.0 not published, features are reported in
-|         |            |   the release 0.5.1
+|         |            |
+| 0.5.0   | 2010/07/24 | * release 0.5.0 was not published, implemented features
+|         |            |   are reported in the release 0.5.1
+|         |            |
 |         |            |
 | 0.5.1   | 2010/09/12 | * update to the JpegMetadata class 1.0.1 to fix the
 |         |            |   mantis bugs&features 1686, 1718 and 1719
+|         |            |
 |         |            | * mantis : bug 1686
 |         |            |   . Picture analysis finish with an Error 500 or with a
 |         |            |     problem of memory limit
+|         |            |
 |         |            | * mantis : feature 1719
 |         |            |   . Coding a DateTime class
+|         |            |
 |         |            | * mantis : feature 1718
 |         |            |   . Make test images lighter
@@ -52,27 +65,54 @@
 |         |            |     JpegMetadata class was to heavy ; the file size has
 |         |            |     been reduced from 9Mb to 230Kb
+|         |            |
 |         |            | * mantis : feature 1688
 |         |            |   . Improve performance when the database is filled
 |         |            |     each time a page is displayed (now using an ajax
 |         |            |     call)
+|         |            |
 |         |            | * mantis : feature 1692
 |         |            |   . Add possibility for user to build their own "magic"
 |         |            |     tags
+|         |            |
 |         |            | * mantis : feature 1777
 |         |            |   . Weight of the metadata database can becomes very
 |         |            |     heavy
+|         |            |
 |         |            | * mantis : feature 1691
 |         |            |   . Add possibility to search picture by metadata
 |         |            |     properties
+|         |            |
+|         |            | * mantis bug:1826
+|         |            |   . digiKam XMP tags are not recognized
+|         |            |
 |         |            | * mantis : feature 1846
 |         |            |   . Read the metadata in the HD picture
+|         |            |
 |         |            | * mantis : feature 1857
 |         |            |   . Implement a basic and an advanced interface mode
+|         |            |
+|         |            | * mantis : feature 1858
+|         |            |   . Ability to import tags from picture to piwigo tags
+|         |            |
+|         |            | * mantis bug:1859
+|         |            |   . JpegMetadata class can't manage multiple IPTC keywords
+|         |            |     keywords
+|         |            |
+|         |            | * mantis bug:1861
+|         |            |   . Accentued chars from ISO-8859-1 charset are not
+|         |            |     recognized
+|         |            |
 |         |            | * ajax management entirely rewritted
+|         |            |
 |         |            | * user interface reviewed
+|         |            |
 |         |            | * add some triggers events when picture metadata are
 |         |            |   loaded in the picture.php page
 |         |            |   . amd_jpegMD_loaded
 |         |            |   . amd_jpegMD_userDefinedValues_built
+|         |            |
+|         |            | * mantis : feature 1858
+|         |            |   . Ability to import tags from picture to piwigo tags
+|         |            |
 |         |            |
 |         |            |
