Index: /extensions/AMetaData/JpegMetaData/Common/Const.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Common/Const.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Common/Const.class.php	(revision 6729)
@@ -142,3 +142,15 @@
   }
 
+  class Schemas {
+    const EXIF  = "exif";
+    const IPTC  = "iptc";
+    const XMP   = "xmp";
+    const MAGIC = "magic";
+
+    const EXIF_TIFF = "exif.tiff";
+    const EXIF_EXIF = "exif.exif";
+    const EXIF_GPS  = "exif.gps";
+    const EXIF_MAKER  = "exif.maker";
+  }
+
 ?>
Index: /extensions/AMetaData/JpegMetaData/Common/Tag.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Common/Tag.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Common/Tag.class.php	(revision 6729)
@@ -45,5 +45,5 @@
  *  - tagValue          : the 'raw' value of the tag, not interpreted ; can be
  *                        of any type
- *  - valuelabel        : the interpreted value of the tag ; in most case it's a
+ *  - valueLabel        : the interpreted value of the tag ; in most case it's a
  *                        String, but can be an Integer, a Float or an Array
  *  - tagIsKnown        : indicates if the tag is a known tag or not
@@ -52,4 +52,5 @@
  *  - tagIsTranslatable : indicates if the interpreted value for the tag is
  *                        translatable
+ *  - schema            : the schema associated with the tag ('exif', 'iptc', 'xmp', 'magic')
  *
  * This class provides theses public functions :
@@ -59,4 +60,5 @@
  *  - getLabel
  *  - getNote
+ *  - getSchema
  *  - isKnown
  *  - isImplemented
@@ -67,4 +69,5 @@
  *  - setLabel
  *  - setNote
+ *  - setSchema
  *  - setKnown
  *  - setImplemented
@@ -84,4 +87,5 @@
     private $tagIsImplemented = false;
     private $tagIsTranslatable = false;
+    private $tagSchema = "";
 
     /**
@@ -104,7 +108,8 @@
      * @param Boolean $tagIstranslatable (optional) : determine if the tag value
      *                                                can be translated or not
-     *
-     */
-    function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false)
+     * @param String $schema (optional)             : schema associated with to
+     *                                                the tag
+     */
+    function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false, $schema="")
     {
       $this->tagId = $tagId;
@@ -116,4 +121,5 @@
       $this->tagIsImplemented=$tagIsImplemented;
       $this->tagIsTranslatable=$tagIsTranslatable;
+      $this->tagSchema = $schema;
     }
 
@@ -128,4 +134,5 @@
       unset($this->tagIsImplemented);
       unset($this->tagIsTranslatable);
+      unset($this->tagSchema);
     }
 
@@ -202,4 +209,14 @@
 
     /**
+     * returns the schema associated to the tag
+     *
+     * @return String
+     */
+    public function getSchema()
+    {
+      return($this->tagSchema);
+    }
+
+    /**
      * returns true if the tag value can be translated
      *
@@ -296,4 +313,17 @@
 
     /**
+     * set a schema to the tag
+     *
+     * @param String $value
+     * @return String
+     */
+    public function setSchema($value)
+    {
+      $this->tagSchema=$value;
+      return($this->tagSchema);
+    }
+
+
+    /**
      * set if the tag value is translatable
      *
@@ -313,5 +343,6 @@
       if($mode=="all")
         if(is_string($this->tagId))
-          $returned.="tag: ".str_replace(" ", "&nbsp;", sprintf("%-34s", $this->tagId))." ; ";
+          $returned.="tag: ".str_replace(" ", "&nbsp;", sprintf("%-34s", $this->tagId))." ;
+                      schema: ".str_replace(" ", "&nbsp;", sprintf("%-5s", $this->tagSchema))." ; ";
         else
           $returned.="tag: 0x".sprintf("%04x", $this->tagId)." ; ";
Index: /extensions/AMetaData/JpegMetaData/JpegMetaData.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/JpegMetaData.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/JpegMetaData.class.php	(revision 6729)
@@ -4,5 +4,5 @@
  *
  * Version : 1.0.1
- * Date    : 2010-07-24
+ * Date    : 2010-07-29
  *
  *  Author    : Grum
@@ -41,5 +41,5 @@
  * | 1.0.0   |            | * first public release
  * |         |            |
- * | 1.0.1   | 2010-07-24 | * mantis bug:1686
+ * | 1.0.1   | 2010-07-29 | * mantis bug:1686
  * |         |            |   . bug reported on IfdReader
  * |         |            |     When sub IFD (0x8769) refers to a sub IFD with
@@ -50,7 +50,19 @@
  * |         |            |     (right solution: to be able to read negative
  * |         |            |     offset)
+ * |         |            |
  * |         |            | * mantis feature : 1719
  * |         |            |   . Coding a DateTime class ; used only if there is
  * |         |            |     no PHP built-in DateTime class
+ * |         |            |
+ * |         |            | * add the "schema" property to Tag class
+ * |         |            |
+ * |         |            | * fixed bug about filtering schema
+ * |         |            |   . when loading metadata, filter on schema are now
+ * |         |            |     applied ; 'magic' metadata are computed even if
+ * |         |            |     the other schema are filtered
+ * |         |            |
+ * |         |            |
+ * |         |            |
+ * |         |            |
  * |         |            |
  * |         |            |
@@ -133,12 +145,4 @@
     const TAGFILTER_IMPLEMENTED = 0x02;
     const TAGFILTER_ALL         = 0x03;
-
-    const KEY_EXIF_TIFF = "exif.tiff";
-    const KEY_EXIF_EXIF = "exif.exif";
-    const KEY_EXIF_GPS  = "exif.gps";
-    const KEY_EXIF  = "exif";
-    const KEY_IPTC  = "iptc";
-    const KEY_XMP   = "xmp";
-    const KEY_MAGIC = "magic";
 
     private $jpeg = null;
@@ -238,36 +242,36 @@
           case "exif":
             $tmp=new IfdTags();
-            $schema="exif";
+            $schema=Schemas::EXIF;
             break;
           case "gps":
             $tmp=new GpsTags();
-            $schema="exif.gps";
+            $schema=Schemas::EXIF_GPS;
             break;
           case "iptc":
             $tmp=new IptcTags();
-            $schema="iptc";
+            $schema=Schemas::IPTC;
             break;
           case "xmp":
             $tmp=new XmpTags();
-            $schema="xmp";
+            $schema=Schemas::XMP;
             break;
           case "magic":
             $tmp=new MagicTags();
-            $schema="magic";
+            $schema=Schemas::MAGIC;
             break;
           case MAKER_PENTAX:
             include_once(JPEG_METADATA_DIR."TagDefinitions/PentaxTags.class.php");
             $tmp=new PentaxTags();
-            $schema="exif.".MAKER_PENTAX;
+            $schema=Schemas::EXIF_MAKER.'.'.MAKER_PENTAX;
             break;
           case MAKER_NIKON:
             include_once(JPEG_METADATA_DIR."TagDefinitions/NikonTags.class.php");
             $tmp=new NikonTags();
-            $schema="exif.".MAKER_NIKON;
+            $schema=Schemas::EXIF_MAKER.'.'.MAKER_NIKON;
             break;
           case MAKER_CANON:
             include_once(JPEG_METADATA_DIR."TagDefinitions/CanonTags.class.php");
             $tmp=new CanonTags();
-            $schema="exif.".MAKER_CANON;
+            $schema=Schemas::EXIF_MAKER.'.'.MAKER_CANON;
             break;
           default:
@@ -287,10 +291,10 @@
                 $name=$key;
 
-              if(array_key_exists('schema', $tag) and $val=="exif")
+              if(array_key_exists('schema', $tag) and $val==Schemas::EXIF)
                 $subSchema=".".$tag['schema'];
               else
                 $subSchema="";
 
-              if($val=='xmp')
+              if($val==Schemas::XMP)
                 $keyName=$schema.$subSchema.".".$key;
               else
@@ -405,7 +409,8 @@
                * Load Exifs tags from Tiff block
                */
-              if($data->getNbIFDs()>0)
+              if($data->getNbIFDs()>0 and
+                 ($this->options['magic'] or $this->options['exif'] or $this->options['maker']))
               {
-                $this->loadIfdTags($data->getIFD(0), self::KEY_EXIF_TIFF);
+                $this->loadIfdTags($data->getIFD(0), Schemas::EXIF_TIFF);
               }
             }
@@ -415,5 +420,8 @@
                * Load Xmp tags from Xmp block
                */
-              $this->loadTags($data->getTags(), self::KEY_XMP);
+              if($this->options['magic'] or $this->options['xmp'])
+              {
+                $this->loadTags($data->getTags(), Schemas::XMP);
+              }
             }
             elseif($data instanceof IptcReader)
@@ -425,5 +433,8 @@
                 $data->optimizeDateTime();
 
-              $this->loadTags($data->getTags(), self::KEY_IPTC);
+              if($this->options['magic'] or $this->options['iptc'])
+              {
+                $this->loadTags($data->getTags(), Schemas::IPTC);
+              }
             }
           }
@@ -433,4 +444,10 @@
         {
           $this->processMagicTags();
+        }
+
+        // clean all unwanted metadata
+        foreach($this->tags as $key => $tag)
+        {
+          if(!$this->options[$tag->getSchema()]) unset($this->tags[$key]);
         }
 
@@ -543,11 +560,11 @@
             {
               case 'Exif IFD Pointer':
-                $exifKey2=self::KEY_EXIF_EXIF;
+                $exifKey2=Schemas::EXIF_EXIF;
                 break;
               case 'MakerNote':
-                $exifKey2=self::KEY_EXIF.".".$tag->getTag()->getLabel()->getMaker();
+                $exifKey2=Schemas::EXIF_MAKER.".".$tag->getTag()->getLabel()->getMaker();
                 break;
               case 'GPS IFD Pointer':
-                $exifKey2=self::KEY_EXIF_GPS;
+                $exifKey2=Schemas::EXIF_GPS;
                 break;
               default:
@@ -621,4 +638,5 @@
             $tag->setImplemented($val['implemented']);
             $tag->setTranslatable($val['translatable']);
+            $tag->setSchema(Schemas::MAGIC);
 
             $i=count($val['tagValues']);
Index: /extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php	(revision 6729)
@@ -56,4 +56,6 @@
   class CanonReader extends MakerNotesReader
   {
+    protected $schema = Schemas::EXIF;
+
     /**
      * The constructor needs, like the ancestor, the datas to be parsed
@@ -187,4 +189,5 @@
           $entry->getTag()->setImplemented($tagDef['implemented']);
           $entry->getTag()->setTranslatable($tagDef['translatable']);
+          $entry->getTag()->setSchema($this->schema);
 
           if(array_key_exists('tagValues', $tagDef))
@@ -333,4 +336,5 @@
           $entry->getTag()->setImplemented($tagDef['implemented']);
           $entry->getTag()->setTranslatable($tagDef['translatable']);
+          $entry->getTag()->setSchema($this->schema);
 
           if(array_key_exists('tagValues', $tagDef))
@@ -509,4 +513,5 @@
           $entry->getTag()->setImplemented($subTagDef['implemented']);
           $entry->getTag()->setTranslatable($subTagDef['translatable']);
+          $entry->getTag()->setSchema($this->schema);
 
           if(array_key_exists('tagValues', $subTagDef))
@@ -598,4 +603,5 @@
           $entry->getTag()->setImplemented($subTagDef['implemented']);
           $entry->getTag()->setTranslatable($subTagDef['translatable']);
+          $entry->getTag()->setSchema($this->schema);
 
           if(array_key_exists('tagValues', $subTagDef))
Index: /extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php	(revision 6729)
@@ -54,4 +54,6 @@
   class GpsReader extends IfdReader
   {
+    protected $schema = Schemas::EXIF;
+
     function __destruct()
     {
Index: /extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php	(revision 6729)
@@ -81,8 +81,11 @@
   {
     protected $byteOrder = BYTE_ORDER_LITTLE_ENDIAN;
+    protected $schema = Schemas::EXIF;
+
 
     private $nextIFDOffset = 0;
 
     private $dataOffset = 0;
+
 
     /**
@@ -233,4 +236,5 @@
         $entry->getTag()->setImplemented($tag['implemented']);
         $entry->getTag()->setTranslatable($tag['translatable']);
+        $entry->getTag()->setSchema($this->schema);
 
         /*
Index: /extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php	(revision 6729)
@@ -65,4 +65,5 @@
     const HEADER_1 = "Photoshop 3.0\x00";
     const HEADER_2 = "Adobe_Photoshop2.5:\x00";
+    protected $schema = Schemas::IPTC;
 
     private $header = "";
@@ -237,4 +238,5 @@
         $tag->setImplemented($tagProperties['implemented']);
         $tag->setTranslatable($tagProperties['translatable']);
+        $tag->setSchema($this->schema);
 
         /*
Index: /extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php	(revision 6729)
@@ -59,4 +59,6 @@
   class NikonReader extends MakerNotesReader
   {
+    protected $schema = Schemas::EXIF;
+
     /* these 2 specific metadata are used to decrypt some information, like the
      * data lens
Index: /extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php	(revision 6729)
@@ -60,4 +60,6 @@
   class PentaxReader extends MakerNotesReader
   {
+    protected $schema = Schemas::EXIF;
+
     /**
      * The constructor needs, like the ancestor, the datas to be parsed
Index: /extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php
===================================================================
--- /extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php	(revision 6728)
+++ /extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php	(revision 6729)
@@ -53,4 +53,6 @@
   class XmpReader extends GenericReader
   {
+    protected $schema = Schemas::XMP;
+
     private $xmlData = NULL;
 
@@ -300,5 +302,5 @@
         $tag->setImplemented($tagProperties['implemented']);
         $tag->setTranslatable($tagProperties['translatable']);
-
+        $tag->setSchema($this->schema);
 
         if(array_key_exists('name', $tagProperties))
Index: /extensions/AMetaData/admin/amd_metadata_select.tpl
===================================================================
--- /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 6728)
+++ /extensions/AMetaData/admin/amd_metadata_select.tpl	(revision 6729)
@@ -201,12 +201,23 @@
     <select id="iSelectFilterTagList" onchange="loadTagList();">
       <option value="" {if $datas.config_GetListTags_FilterType==""}selected{/if}>{'g003_no_filter'|@translate}</option>
+      {if !in_array('magic', $amdConfig.amd_FillDataBaseExcludeFilters)}
       <option value="magic" {if $datas.config_GetListTags_FilterType=="magic"}selected{/if}>{'g003_magic_filter'|@translate}</option>
+      {/if}
       <option value="userDefined" {if $datas.config_GetListTags_FilterType=="userDefined"}selected{/if}>{'g003_userDefined_filter'|@translate}</option>
+
+      {if !in_array('exif', $amdConfig.amd_FillDataBaseExcludeFilters)}
       <option value="exif" {if $datas.config_GetListTags_FilterType=="exif"}selected{/if}>Exif</option>
-      <option value="exif.Canon" {if $datas.config_GetListTags_FilterType=="exif.Canon"}selected{/if}>Exif [Canon]</option>
-      <option value="exif.Nikon" {if $datas.config_GetListTags_FilterType=="exif.Nikon"}selected{/if}>Exif [Nikon]</option>
-      <option value="exif.Pentax" {if $datas.config_GetListTags_FilterType=="exif.Pentax"}selected{/if}>Exif [Pentax]</option>
+      {/if}
+      {if !in_array('exif.maker', $amdConfig.amd_FillDataBaseExcludeFilters)}
+      <option value="exif.maker.Canon" {if $datas.config_GetListTags_FilterType=="exif.maker.Canon"}selected{/if}>Exif [Canon]</option>
+      <option value="exif.maker.Nikon" {if $datas.config_GetListTags_FilterType=="exif.maker.Nikon"}selected{/if}>Exif [Nikon]</option>
+      <option value="exif.maker.Pentax" {if $datas.config_GetListTags_FilterType=="exif.maker.Pentax"}selected{/if}>Exif [Pentax]</option>
+      {/if}
+      {if !in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters)}
       <option value="xmp" {if $datas.config_GetListTags_FilterType=="xmp"}selected{/if}>Xmp</option>
+      {/if}
+      {if !in_array('iptc', $amdConfig.amd_FillDataBaseExcludeFilters)}
       <option value="iptc" {if $datas.config_GetListTags_FilterType=="iptc"}selected{/if}>Iptc</option>
+      {/if}
     </select>
   </label>
Index: /extensions/AMetaData/amd.css
===================================================================
--- /extensions/AMetaData/amd.css	(revision 6728)
+++ /extensions/AMetaData/amd.css	(revision 6729)
@@ -56,8 +56,8 @@
 }
 .helper {
-  -moz-border-radius:8px;
-  -webkit-border-radius:8px;
-  -khtml-border-radius:8px;
-  border-radius:8px;
+  -moz-border-radius:4px;
+  -webkit-border-radius:4px;
+  -khtml-border-radius:4px;
+  border-radius:4px;
   border:2px dashed #777777;
   margin:4px 4px 4px 12px;
@@ -104,2 +104,33 @@
   border-radius:8px;
 }
+
+.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%;
+  text-align:left;
+}
+table.mdInfo tr {
+  vertical-align:top;
+}
+table.mdInfo tr td ul {
+  margin:0px;
+}
+span.mdInfo {
+  width:100px;
+  display:inline-block;
+  font-weight:bold;
+}
Index: /extensions/AMetaData/amd_aip.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_aip.class.inc.php	(revision 6728)
+++ /extensions/AMetaData/amd_aip.class.inc.php	(revision 6729)
@@ -45,4 +45,5 @@
 
     $this->loadConfig();
+    $this->configForTemplate();
     $this->initEvents();
 
@@ -446,4 +447,5 @@
     {
       case 'state':
+        $template->assign('sheetContent', $this->displayDatabaseStatus());
         break;
       case 'update':
@@ -454,4 +456,113 @@
     $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');
   }
+
+
+
+  /**
+   * display the database status
+   *
+   * @return String : the content of the page
+   */
+  private function displayDatabaseStatus()
+  {
+    global $template, $page;
+
+    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_status.tpl');
+
+    $datas=array(
+      'urlRequest' => $this->getAdminLink('ajax'),
+      'warning1' => GPCCore::BBtoHTML(l10n('g003_databaseWarning1')),
+      'nfoMetadata' => Array(
+          'exif' => 0,
+          'iptc' => 0,
+          'magic' => 0,
+          'xmp' => 0,
+          'userDefined' => 0,
+          'numOfPictures' => 0,
+          'numOfNotAnalyzedPictures' => 0,
+          'numOfPicturesWithoutTag' => 0,
+          'nfoSize' => 0,
+          'nfoRows' => 0,
+          'nfoSizeAndRows' => '',
+        )
+    );
+
+    $sql="SELECT SUM(numOfImg) AS nb, 'exif' AS `type`
+          FROM ".$this->tables['used_tags']."
+          WHERE tagId LIKE 'exif.%'
+          UNION
+          SELECT SUM(numOfImg), 'iptc'
+          FROM ".$this->tables['used_tags']."
+          WHERE tagId LIKE 'iptc.%'
+          UNION
+          SELECT SUM(numOfImg), 'magic'
+          FROM ".$this->tables['used_tags']."
+          WHERE tagId LIKE 'magic.%'
+          UNION
+          SELECT SUM(numOfImg), 'xmp'
+          FROM ".$this->tables['used_tags']."
+          WHERE tagId LIKE 'xmp.%'
+          UNION
+          SELECT SUM(numOfImg), 'userDefined'
+          FROM ".$this->tables['used_tags']."
+          WHERE tagId LIKE 'userDefined.%'
+          UNION
+          SELECT COUNT(imageId), 'numOfPictures'
+          FROM ".$this->tables['images']."
+          WHERE analyzed='y'
+          UNION
+          SELECT COUNT(imageId), 'numOfNotAnalyzedPictures'
+          FROM ".$this->tables['images']."
+          WHERE analyzed='n'
+          UNION
+          SELECT COUNT(imageId), 'numOfPicturesWithoutTag'
+          FROM ".$this->tables['images']."
+          WHERE nbTags=0";
+    $result=pwg_query($sql);
+    if($result)
+    {
+      while($row=pwg_db_fetch_assoc($result))
+      {
+        if(!is_null($row['nb']))
+        {
+          $datas['nfoMetadata'][$row['type']]=$row['nb'];
+          if($row['type']=='exif' or
+             $row['type']=='iptc' or
+             $row['type']=='magic' or
+             $row['type']=='xmp' or
+             $row['type']=='userDefined') $datas['nfoMetadata']['nfoRows']+=$row['nb'];
+        }
+      }
+    }
+
+    $sql="SHOW TABLE STATUS WHERE name LIKE '".$this->tables['images_tags']."'";
+    $result=pwg_query($sql);
+    if($result)
+    {
+      while($row=pwg_db_fetch_assoc($result))
+      {
+        $datas['nfoMetadata']['nfoSize']=$row['Data_length']+$row['Index_length'];
+      }
+    }
+
+    if($datas['nfoMetadata']['nfoSize']<1048576)
+    {
+      $datas['nfoMetadata']['nfoSize']=sprintf('%.2fKio', $datas['nfoMetadata']['nfoSize']/1024);
+    }
+    else
+    {
+      $datas['nfoMetadata']['nfoSize']=sprintf('%.2fMio', $datas['nfoMetadata']['nfoSize']/1048576);
+    }
+    $datas['nfoMetadata']['nfoSizeAndRows']=sprintf(l10n('g003_sizeAndRows'), $datas['nfoMetadata']['nfoSize'], $datas['nfoMetadata']['nfoRows']);
+    $datas['nfoMetadata']['numOfPictures']=sprintf(l10n('g003_numberOfAnalyzedPictures'), $datas['nfoMetadata']['numOfPictures']);
+    $datas['nfoMetadata']['numOfNotAnalyzedPictures']=sprintf(l10n('g003_numberOfNotAnalyzedPictures'), $datas['nfoMetadata']['numOfNotAnalyzedPictures']);
+    $datas['nfoMetadata']['numOfPicturesWithoutTag']=sprintf(l10n('g003_numberOfPicturesWithoutTags'), $datas['nfoMetadata']['numOfPicturesWithoutTag']);
+
+    $template->assign("datas", $datas);
+
+    return($template->parse('sheet_page', true));
+  } // displayDatabaseStatus
+
+
 
 
@@ -491,12 +602,17 @@
 
     /*
-     * delete metdata for images that are not in the AMD image table
-     */
-    $sql="DELETE FROM ".$this->tables['images_tags']."
-            WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
+     * delete metadata for images that are not in the AMD image table
+     */
+    $sql="DELETE ait
+          FROM ".$this->tables['images_tags']." ait
+            JOIN (SELECT DISTINCT imageId FROM ".$this->tables['images_tags']." ) aitd
+              ON ait.imageId=aitd.imageId
+          WHERE aitd.imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.") ";
     pwg_query($sql);
 
 
-    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database.tpl');
+
+
+    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_database.tpl');
 
     $datas=array(
Index: /extensions/AMetaData/amd_ajax.php
===================================================================
--- /extensions/AMetaData/amd_ajax.php	(revision 6728)
+++ /extensions/AMetaData/amd_ajax.php	(revision 6729)
@@ -66,8 +66,8 @@
            $_REQUEST['ajaxfct']=='admin.makeStats.doAnalyze' or
            $_REQUEST['ajaxfct']=='admin.makeStats.consolidate' or
-           $_REQUEST['ajaxfct']=='admin.makeStats.getStatus' or
            $_REQUEST['ajaxfct']=='admin.showStats.getListTags' or
            $_REQUEST['ajaxfct']=='admin.showStats.getListImages' or
            $_REQUEST['ajaxfct']=='admin.updateTag.select' or
+           $_REQUEST['ajaxfct']=='admin.config.setOption' or
            $_REQUEST['ajaxfct']=='admin.group.getList' or
            $_REQUEST['ajaxfct']=='admin.group.delete' or
@@ -100,7 +100,10 @@
                $_REQUEST['selectMode']=="caddieAdd" or
                $_REQUEST['selectMode']=="caddieReplace" or
+               $_REQUEST['selectMode']=="analyzed" or
                $_REQUEST['selectMode']=="all")) $_REQUEST['selectMode']="caddieAdd";
 
           if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=25;
+
+          if(!isset($_REQUEST['ignoreOptions'])) $_REQUEST['ignoreOptions']=array();
         }
 
@@ -135,12 +138,13 @@
 
           if(!($_REQUEST['filterType']=="" or
-               $_REQUEST['filterType']=="magic" or
+               ($_REQUEST['filterType']=="magic" and !in_array('magic', $this->config['amd_FillDataBaseExcludeFilters'])) or
                $_REQUEST['filterType']=="userDefined" or
-               $_REQUEST['filterType']=="exif" or
-               $_REQUEST['filterType']=="exif.Canon" or
-               $_REQUEST['filterType']=="exif.Nikon" or
-               $_REQUEST['filterType']=="exif.Pentax" or
-               $_REQUEST['filterType']=="xmp" or
-               $_REQUEST['filterType']=="iptc")) $_REQUEST['filterType']="";
+               ($_REQUEST['filterType']=="exif" and !in_array('exif', $this->config['amd_FillDataBaseExcludeFilters'])) or
+               ($_REQUEST['filterType']=="exif.maker.Canon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
+               ($_REQUEST['filterType']=="exif.maker.Nikon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
+               ($_REQUEST['filterType']=="exif.maker.Pentax" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
+               ($_REQUEST['filterType']=="xmp" and !in_array('xmp', $this->config['amd_FillDataBaseExcludeFilters'])) or
+               ($_REQUEST['filterType']=="iptc"  and !in_array('iptc', $this->config['amd_FillDataBaseExcludeFilters']))
+               )) $_REQUEST['filterType']="";
 
           if(!isset($_REQUEST['excludeUnusedTag'])) $_REQUEST['excludeUnusedTag']="n";
@@ -176,4 +180,13 @@
 
           if(!isset($_REQUEST['tagSelected'])) $_REQUEST['tagSelected']="";
+        }
+
+        /*
+         * check admin.config.setOption values
+         */
+        if($_REQUEST['ajaxfct']=="admin.config.setOption")
+        {
+          if(!isset($_REQUEST['id'])) $_REQUEST['ajaxfct']='';
+          if(!isset($_REQUEST['value'])) $_REQUEST['ajaxfct']='';
         }
 
@@ -315,5 +328,5 @@
       {
         case 'admin.makeStats.getList':
-          $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems']);
+          $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems'], $_REQUEST['ignoreOptions']);
           break;
         case 'admin.makeStats.doAnalyze':
@@ -323,7 +336,4 @@
           $result=$this->ajax_amd_admin_makeStatsConsolidate();
           break;
-        case 'admin.makeStats.getStatus':
-          $result=$this->ajax_amd_admin_makeStatsGetStatus();
-          break;
         case 'admin.showStats.getListTags':
           $result=$this->ajax_amd_admin_showStatsGetListTags($_REQUEST['orderType'], $_REQUEST['filterType'], $_REQUEST['excludeUnusedTag'], $_REQUEST['selectedTagOnly']);
@@ -334,4 +344,7 @@
         case 'admin.updateTag.select':
           $result=$this->ajax_amd_admin_updateTagSelect($_REQUEST['numId'], $_REQUEST['tagSelected']);
+          break;
+        case 'admin.config.setOption':
+          $result=$this->ajax_amd_admin_configSetOption($_REQUEST['id'], $_REQUEST['value']);
           break;
         case 'admin.group.getList':
@@ -452,27 +465,35 @@
      *                      "23 78 4523 5670"
      */
-    private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems)
+    private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems, $ignoreSchemas)
     {
       global $user;
 
       $returned="";
+      $this->config['amd_FillDataBaseIgnoreSchemas']=$ignoreSchemas;
       $this->config['amd_NumberOfItemsPerRequest']=$nbOfItems;
       $this->saveConfig();
 
       $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait";
-      if($mode=="notAnalyzed")
+      if($mode=='notAnalyzed')
       {
         $sql.=" WHERE ait.analyzed='n'";
       }
-      elseif($mode=="caddieAdd" or $mode=="caddieReplace")
-      {
-
+      elseif($mode=='caddieAdd' or $mode=='caddieReplace')
+      {
         $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id
               WHERE ct.user_id = ".$user['id']." ";
 
-        if($mode=="caddieAdd") $sql.=" AND ait.analyzed='n'";
-      }
-
-      if($mode=="all" or $mode=="caddieReplace")
+        if($mode=='caddieAdd') $sql.=" AND ait.analyzed='n'";
+      }
+      elseif($mode=='analyzed')
+      {
+        $sql.=" WHERE ait.analyzed='y'";
+
+        pwg_query("UPDATE ".$this->tables['images']." SET nbTags=0 WHERE analyzed='y';");
+        pwg_query("UPDATE ".$this->tables['used_tags']." SET numOfImg=0");
+        pwg_query("DELETE FROM ".$this->tables['images_tags']);
+      }
+
+      if($mode=='all' or $mode=='caddieReplace')
       {
         pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0");
@@ -563,60 +584,4 @@
 
     /**
-     * returns a list of formated string, separated with a semi-colon :
-     *  - number of current analyzed pictures + number of current analyzed tags
-     *    for the analyzed pictures
-     *  - number of pictures not analyzed
-     *  - number of pictures without tag
-     *
-     * @return String
-     */
-    private function ajax_amd_admin_makeStatsGetStatus()
-    {
-      $numOfMetaData=0;
-      $numOfPictures=0;
-      $numOfPicturesNotAnalyzed=0;
-
-      $sql="SELECT COUNT(imageId), SUM(nbTags) FROM ".$this->tables['images']."
-              WHERE analyzed='y';";
-      $result=pwg_query($sql);
-      if($result)
-      {
-        while($row=pwg_db_fetch_row($result))
-        {
-          $numOfPictures=$row[0];
-          $numOfMetaData=$row[1];
-        }
-      }
-
-
-      $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
-              WHERE analyzed='n';";
-      $result=pwg_query($sql);
-      if($result)
-      {
-        while($row=pwg_db_fetch_row($result))
-        {
-          $numOfPicturesNotAnalyzed=$row[0];
-        }
-      }
-
-      $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
-              WHERE nbTags=0;";
-      $result=pwg_query($sql);
-      if($result)
-      {
-        while($row=pwg_db_fetch_row($result))
-        {
-          $numOfPicturesWithoutTags=$row[0];
-        }
-      }
-
-      return(sprintf(l10n("g003_numberOfAnalyzedPictures"), $numOfPictures, $numOfMetaData).";".
-                sprintf(l10n("g003_numberOfNotAnalyzedPictures"), $numOfPicturesNotAnalyzed).";".
-                sprintf(l10n("g003_numberOfPicturesWithoutTags"), $numOfPicturesWithoutTags));
-    }
-
-
-    /**
      * return a formatted <table> (using the template "amd_stat_show_iListTags")
      * of used tag with, for each tag, the number and the percentage of pictures
@@ -1385,7 +1350,5 @@
       $nbImg=$this->buildUserDefinedTags($id);
 
-      $sql="UPDATE ".$this->tables['used_tags']."
-              SET numOfImg='$nbImg';";
-      $result=pwg_query($sql);
+      $this->makeStatsConsolidation();
 
       return($id.','.$nbImg);
@@ -1438,6 +1401,41 @@
     }
 
-
-  }
+    /**
+     * set value(s) for option(s)
+     *
+     * @param Array or String $ids : a string or an array of string (id)
+     * @param Array or String $values : a string or an array of string
+     * @return String : ok or ko
+     */
+    private function ajax_amd_admin_configSetOption($ids, $values)
+    {
+      if(is_array($ids) and is_array($values) and count($ids)==count($values))
+      {
+        foreach($ids as $key=>$id)
+        {
+          if(isset($id, $this->config))
+          {
+            $this->config[$id]=$values[$key];
+          }
+        }
+        $this->saveConfig();
+        return('ok');
+      }
+      elseif(is_string($ids) and is_string($values))
+      {
+        if(isset($ids, $this->config))
+        {
+          $this->config[$ids]=$values;
+        }
+        $this->saveConfig();
+        return('ok');
+      }
+
+      return('ko');
+    }
+
+
+
+  } //class
 
 
Index: /extensions/AMetaData/amd_install.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_install.class.inc.php	(revision 6728)
+++ /extensions/AMetaData/amd_install.class.inc.php	(revision 6729)
@@ -156,4 +156,5 @@
       $this->initConfig();
       $this->loadConfig();
+      $this->loadConfigFromFile(dirname($this->getFileLocation()).'/activatePlugin.conf.php');
 
       /*
@@ -177,4 +178,5 @@
       }
 
+      $this->config['amd_FillDataBaseExcludeTags']=array();
       $this->config['installed']=AMD_VERSION2; //update the installed release number
       $this->saveConfig();
@@ -234,4 +236,6 @@
     private function initializeDatabase()
     {
+      global $user;
+
       L10n::setLanguage('en_UK');
 
@@ -249,4 +253,20 @@
       {
         $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0, '".addslashes(L10n::get($val['name']))."');";
+        pwg_query($sql);
+      }
+
+      /*
+       * exclude unauthorized tag with the 'amd_FillDataBaseExcludeTags' option
+       */
+      if(count($this->config['amd_FillDataBaseExcludeTags']))
+      {
+        $sql="";
+        foreach($this->config['amd_FillDataBaseExcludeTags'] as $key => $tag)
+        {
+          if($sql!="") $sql.=" OR ";
+          $sql.=" tagId LIKE '$tag' ";
+        }
+        $sql="DELETE FROM ".$this->tables['used_tags']."
+              WHERE ".$sql;
         pwg_query($sql);
       }
Index: /extensions/AMetaData/amd_root.class.inc.php
===================================================================
--- /extensions/AMetaData/amd_root.class.inc.php	(revision 6728)
+++ /extensions/AMetaData/amd_root.class.inc.php	(revision 6729)
@@ -76,5 +76,5 @@
   {
     $this->config=array(
-      'amd_NumberOfItemsPerRequest' => 25,
+      // options set by the plugin interface - don't modify them manually
       'amd_GetListTags_OrderType' => "tag",
       'amd_GetListTags_FilterType' => "magic",
@@ -82,7 +82,37 @@
       'amd_GetListTags_SelectedTagOnly' => "n",
       'amd_GetListImages_OrderType' => "value",
+      'amd_AllPicturesAreAnalyzed' => "n",
       'amd_FillDataBaseContinuously' => "y",
-      'amd_AllPicturesAreAnalyzed' => "n",
+      'amd_FillDataBaseIgnoreSchemas' => array(),
+
+      // theses options can be set manually
+      'amd_NumberOfItemsPerRequest' => 25,
+      'amd_DisplayWarningsMessageStatus' => "y",
+      'amd_DisplayWarningsMessageUpdate' => "y",
+      'amd_FillDataBaseExcludeTags' => array(),
+      'amd_FillDataBaseExcludeFilters' => array(),
     );
+    /*
+     * ==> amd_FillDataBaseExcludeTags : array of tagId
+     *     the listed tag are completely excluded by the plugin, as they don't
+     *     exist
+     *     for each tagId you can use generic char as the LIKE sql operator
+     *      array('xmp.%', 'exif.maker.%')
+     *        -> exclude all XMP and EXIF MAKER tags
+     *
+     * ==> amd_FillDataBaseExcludeFilters : array of filterValue
+     *     if you exclude all the xmp tag you probably want to exclude everything
+     *     displaying 'xmp'
+     *     array('exif.maker',
+     *           'exif',
+     *           'iptc',
+     *           'xmp',
+     *           'magic')
+     *
+     * ==> amd_DisplayWarningsMessageStatus : 'y' or 'n'
+     *     amd_DisplayWarningsMessageUpdate
+     *     you can disable warnings messages displayed on the database status&update
+     *     page
+     */
   }
 
@@ -107,4 +137,14 @@
       return(parent::getAdminLink());
     }
+  }
+
+  /**
+   *
+   */
+  protected function configForTemplate()
+  {
+    global $template;
+
+    $template->assign('amdConfig', $this->config);
   }
 
@@ -175,4 +215,5 @@
   protected function analyzeImageFile($fileName, $imageId, $loaded=false)
   {
+    $schemas=array_flip($this->config['amd_FillDataBaseIgnoreSchemas']);
     /*
      * the JpegMetaData object is instancied in the constructor
@@ -185,7 +226,8 @@
           'filter' => AMD_JpegMetaData::TAGFILTER_IMPLEMENTED,
           'optimizeIptcDateTime' => true,
-          'exif' => true,
-          'iptc' => true,
-          'xmp' => true
+          'exif' => !isset($schemas['exif']),
+          'iptc' => !isset($schemas['iptc']),
+          'xmp' => !isset($schemas['xmp']),
+          'magic' => !isset($schemas['magic']),
         )
       );
@@ -469,10 +511,30 @@
   protected function makeStatsConsolidation()
   {
+    // reset numbers
+    $sql="UPDATE ".$this->tables['used_tags']." ut
+          SET ut.numOfImg = 0;";
+    pwg_query($sql);
+
+    $sql="UPDATE ".$this->tables['images']." pai
+          SET pai.nbTags = 0;";
+    pwg_query($sql);
+
+
+    // count number of images per tag
     $sql="UPDATE ".$this->tables['used_tags']." ut,
-            (SELECT COUNT(imageId) AS nb, numId
+            (SELECT COUNT(DISTINCT imageId) AS nb, numId
               FROM ".$this->tables['images_tags']."
               GROUP BY numId) nb
           SET ut.numOfImg = nb.nb
           WHERE ut.numId = nb.numId;";
+    pwg_query($sql);
+
+    //count number of tags per images
+    $sql="UPDATE ".$this->tables['images']." pai,
+            (SELECT COUNT(DISTINCT numId) AS nb, imageId
+              FROM ".$this->tables['images_tags']."
+              GROUP BY imageId) nb
+          SET pai.nbTags = nb.nb
+          WHERE pai.imageId = nb.imageId;";
     pwg_query($sql);
 
Index: /extensions/AMetaData/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/AMetaData/language/fr_FR/plugin.lang.php	(revision 6728)
+++ /extensions/AMetaData/language/fr_FR/plugin.lang.php	(revision 6729)
@@ -13,5 +13,4 @@
 $lang['g003_show'] = "Consulter";
 
-$lang['g003_numberOfAnalyzedPictures'] = "%d images ont fait l'objet d'une analyse et représentent %d métadonnées";
 $lang['g003_numberOfNotAnalyzedPictures'] = "%d images n'ont pas fait l'objet d'une analyse";
 $lang['g003_analyze_not_analyzed_pictures'] = "L'analyse porte sur les images n'ayant jamais été analysées et vient s'ajouter au référentiel actuel";
@@ -78,6 +77,5 @@
 $lang['g003_warning_on_analyze_3a'] = "du nombre de photos dans la galerie";
 $lang['g003_warning_on_analyze_3b'] = "du nombre de pages visualisées quotidiennement";
-$lang['g003_warning_on_analyze_4a'] = "le référentiel n'est exploité qu'à des fins statistiques et facilite le choix des métadonnées sélectionnées pour affichage";
-$lang['g003_warning_on_analyze_4b'] = "une image non prise prise en compte pour l'alimentation du référentiel disposera quand même des métadonnées sur la galerie";
+
 $lang['g003_warning_on_analyze_5'] = "Afin de disposer rapidement d'un référentiel complet, il est possible de procéder à une analyse plus directe de la galerie :";
 $lang['g003_warning_on_analyze_0'] = "Attention !";
@@ -165,6 +163,7 @@
 [/ul]";
 
-
-// release 0.5.0
+/*
+ * release 0.5.0
+ */
 
 $lang['g003_y'] = "Oui";
@@ -211,3 +210,31 @@
 $lang['g003_userDefined_filter'] = "Métadonnées personnalisées";
 
+$lang['g003_informations'] = "Informations";
+$lang['g003_databaseInformation'] = "Informations importantes à propos du référentiel";
+$lang['g003_databaseWarning1']="[p]Le référentiel est constitué des métadonnées contenues dans les images de galerie ainsi que de métadonnées calculées par le plugin. En fonction du nombre d'images et du nombre de métadonnées y étant rattachées, le référentiel peut s'avérer être très volumineux.
+Avant d'alimenter le référentiel, assurez-vous que la base de données proposée par votre hébergeur permet ce type d'usage.
+[/p][p]Il est toutefois à noter que l'usage du référentiel est facultatif, ce dernier n'étant pas exploité pour l'affichage des métadonnées des photos de la galerie.
+[/p][p]L'alimentation du référentiel est nécessaire si vous souhaitez :[/p]
+[ul]
+[li]Disposer de statistiques sur les métadonnées présentes dans vos photos (c'est aussi une aide pour la sélection de métadonnées)[/li]
+[li]Disposer du moteur de recherche[/li]
+[/ul]
+";
+$lang['g003_sizeAndRows'] = "Le référentiel fait %s et est constitué de %s métadonnées";
+$lang['g003_numberOfAnalyzedPictures'] = "%d images ont fait l'objet d'une analyse";
+
+$lang['g003_options'] = "Options";
+$lang['g003_fillDatabaseContinuously'] = "Alimenter le référentiel au fil de l'eau";
+$lang['g003_ignoreMetadata'] = "Ignorer les métadonnées suivantes :";
+
+$lang['g003_analyze_analyzed_pictures'] = "L'analyse ne porte que sur les images ayant déjà fait l'objet d'une analyse";
+$lang['g003_fillDatabaseIgnoreWarning'] = "Pour être prise en compte, la modification des paramètres de cette option nécessite d'effectuer une analyse";
+
+/*
+ * removed keys
+ */
+//$lang['g003_warning_on_analyze_4a']
+//$lang['g003_warning_on_analyze_4b']
+
+
 ?>
Index: /extensions/AMetaData/main.inc.php
===================================================================
--- /extensions/AMetaData/main.inc.php	(revision 6728)
+++ /extensions/AMetaData/main.inc.php	(revision 6729)
@@ -56,8 +56,9 @@
 |         |            |   . Add possibility for user to build their own "magic"
 |         |            |     tags
+|         |            | * mantis : feature 1777
+|         |            |   . Weight of the metadata database can becomes very
+|         |            |     heavy
 |         |            | * ajax management was entirely rewritted
 |         |            | * user interface reviewed
-|         |            |
-|         |            |
 |         |            |
 |         |            |
Index: /extensions/AMetaData/maintain.inc.php
===================================================================
--- /extensions/AMetaData/maintain.inc.php	(revision 6728)
+++ /extensions/AMetaData/maintain.inc.php	(revision 6729)
@@ -83,5 +83,5 @@
 function plugin_activate($plugin_id, $plugin_version, &$errors)
 {
-  global $prefixeTable;
+  global $prefixeTable, $gpcNeeded;
 
   $amd=new AMD_install($prefixeTable, __FILE__);
