Changeset 6729 for extensions/AMetaData


Ignore:
Timestamp:
Jul 29, 2010, 10:12:25 AM (14 years ago)
Author:
grum
Message:

feature:1777

  • Weight of the metadata database can becomes very heavy
Location:
extensions/AMetaData
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/JpegMetaData/Common/Const.class.php

    r4686 r6729  
    142142  }
    143143
     144  class Schemas {
     145    const EXIF  = "exif";
     146    const IPTC  = "iptc";
     147    const XMP   = "xmp";
     148    const MAGIC = "magic";
     149
     150    const EXIF_TIFF = "exif.tiff";
     151    const EXIF_EXIF = "exif.exif";
     152    const EXIF_GPS  = "exif.gps";
     153    const EXIF_MAKER  = "exif.maker";
     154  }
     155
    144156?>
  • extensions/AMetaData/JpegMetaData/Common/Tag.class.php

    r4904 r6729  
    4545 *  - tagValue          : the 'raw' value of the tag, not interpreted ; can be
    4646 *                        of any type
    47  *  - valuelabel        : the interpreted value of the tag ; in most case it's a
     47 *  - valueLabel        : the interpreted value of the tag ; in most case it's a
    4848 *                        String, but can be an Integer, a Float or an Array
    4949 *  - tagIsKnown        : indicates if the tag is a known tag or not
     
    5252 *  - tagIsTranslatable : indicates if the interpreted value for the tag is
    5353 *                        translatable
     54 *  - schema            : the schema associated with the tag ('exif', 'iptc', 'xmp', 'magic')
    5455 *
    5556 * This class provides theses public functions :
     
    5960 *  - getLabel
    6061 *  - getNote
     62 *  - getSchema
    6163 *  - isKnown
    6264 *  - isImplemented
     
    6769 *  - setLabel
    6870 *  - setNote
     71 *  - setSchema
    6972 *  - setKnown
    7073 *  - setImplemented
     
    8487    private $tagIsImplemented = false;
    8588    private $tagIsTranslatable = false;
     89    private $tagSchema = "";
    8690
    8791    /**
     
    104108     * @param Boolean $tagIstranslatable (optional) : determine if the tag value
    105109     *                                                can be translated or not
    106      *
    107      */
    108     function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false)
     110     * @param String $schema (optional)             : schema associated with to
     111     *                                                the tag
     112     */
     113    function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false, $schema="")
    109114    {
    110115      $this->tagId = $tagId;
     
    116121      $this->tagIsImplemented=$tagIsImplemented;
    117122      $this->tagIsTranslatable=$tagIsTranslatable;
     123      $this->tagSchema = $schema;
    118124    }
    119125
     
    128134      unset($this->tagIsImplemented);
    129135      unset($this->tagIsTranslatable);
     136      unset($this->tagSchema);
    130137    }
    131138
     
    202209
    203210    /**
     211     * returns the schema associated to the tag
     212     *
     213     * @return String
     214     */
     215    public function getSchema()
     216    {
     217      return($this->tagSchema);
     218    }
     219
     220    /**
    204221     * returns true if the tag value can be translated
    205222     *
     
    296313
    297314    /**
     315     * set a schema to the tag
     316     *
     317     * @param String $value
     318     * @return String
     319     */
     320    public function setSchema($value)
     321    {
     322      $this->tagSchema=$value;
     323      return($this->tagSchema);
     324    }
     325
     326
     327    /**
    298328     * set if the tag value is translatable
    299329     *
     
    313343      if($mode=="all")
    314344        if(is_string($this->tagId))
    315           $returned.="tag: ".str_replace(" ", " ", sprintf("%-34s", $this->tagId))." ; ";
     345          $returned.="tag: ".str_replace(" ", " ", sprintf("%-34s", $this->tagId))." ;
     346                      schema: ".str_replace(" ", " ", sprintf("%-5s", $this->tagSchema))." ; ";
    316347        else
    317348          $returned.="tag: 0x".sprintf("%04x", $this->tagId)." ; ";
  • extensions/AMetaData/JpegMetaData/JpegMetaData.class.php

    r6722 r6729  
    44 *
    55 * Version : 1.0.1
    6  * Date    : 2010-07-24
     6 * Date    : 2010-07-29
    77 *
    88 *  Author    : Grum
     
    4141 * | 1.0.0   |            | * first public release
    4242 * |         |            |
    43  * | 1.0.1   | 2010-07-24 | * mantis bug:1686
     43 * | 1.0.1   | 2010-07-29 | * mantis bug:1686
    4444 * |         |            |   . bug reported on IfdReader
    4545 * |         |            |     When sub IFD (0x8769) refers to a sub IFD with
     
    5050 * |         |            |     (right solution: to be able to read negative
    5151 * |         |            |     offset)
     52 * |         |            |
    5253 * |         |            | * mantis feature : 1719
    5354 * |         |            |   . Coding a DateTime class ; used only if there is
    5455 * |         |            |     no PHP built-in DateTime class
     56 * |         |            |
     57 * |         |            | * add the "schema" property to Tag class
     58 * |         |            |
     59 * |         |            | * fixed bug about filtering schema
     60 * |         |            |   . when loading metadata, filter on schema are now
     61 * |         |            |     applied ; 'magic' metadata are computed even if
     62 * |         |            |     the other schema are filtered
     63 * |         |            |
     64 * |         |            |
     65 * |         |            |
     66 * |         |            |
    5567 * |         |            |
    5668 * |         |            |
     
    133145    const TAGFILTER_IMPLEMENTED = 0x02;
    134146    const TAGFILTER_ALL         = 0x03;
    135 
    136     const KEY_EXIF_TIFF = "exif.tiff";
    137     const KEY_EXIF_EXIF = "exif.exif";
    138     const KEY_EXIF_GPS  = "exif.gps";
    139     const KEY_EXIF  = "exif";
    140     const KEY_IPTC  = "iptc";
    141     const KEY_XMP   = "xmp";
    142     const KEY_MAGIC = "magic";
    143147
    144148    private $jpeg = null;
     
    238242          case "exif":
    239243            $tmp=new IfdTags();
    240             $schema="exif";
     244            $schema=Schemas::EXIF;
    241245            break;
    242246          case "gps":
    243247            $tmp=new GpsTags();
    244             $schema="exif.gps";
     248            $schema=Schemas::EXIF_GPS;
    245249            break;
    246250          case "iptc":
    247251            $tmp=new IptcTags();
    248             $schema="iptc";
     252            $schema=Schemas::IPTC;
    249253            break;
    250254          case "xmp":
    251255            $tmp=new XmpTags();
    252             $schema="xmp";
     256            $schema=Schemas::XMP;
    253257            break;
    254258          case "magic":
    255259            $tmp=new MagicTags();
    256             $schema="magic";
     260            $schema=Schemas::MAGIC;
    257261            break;
    258262          case MAKER_PENTAX:
    259263            include_once(JPEG_METADATA_DIR."TagDefinitions/PentaxTags.class.php");
    260264            $tmp=new PentaxTags();
    261             $schema="exif.".MAKER_PENTAX;
     265            $schema=Schemas::EXIF_MAKER.'.'.MAKER_PENTAX;
    262266            break;
    263267          case MAKER_NIKON:
    264268            include_once(JPEG_METADATA_DIR."TagDefinitions/NikonTags.class.php");
    265269            $tmp=new NikonTags();
    266             $schema="exif.".MAKER_NIKON;
     270            $schema=Schemas::EXIF_MAKER.'.'.MAKER_NIKON;
    267271            break;
    268272          case MAKER_CANON:
    269273            include_once(JPEG_METADATA_DIR."TagDefinitions/CanonTags.class.php");
    270274            $tmp=new CanonTags();
    271             $schema="exif.".MAKER_CANON;
     275            $schema=Schemas::EXIF_MAKER.'.'.MAKER_CANON;
    272276            break;
    273277          default:
     
    287291                $name=$key;
    288292
    289               if(array_key_exists('schema', $tag) and $val=="exif")
     293              if(array_key_exists('schema', $tag) and $val==Schemas::EXIF)
    290294                $subSchema=".".$tag['schema'];
    291295              else
    292296                $subSchema="";
    293297
    294               if($val=='xmp')
     298              if($val==Schemas::XMP)
    295299                $keyName=$schema.$subSchema.".".$key;
    296300              else
     
    405409               * Load Exifs tags from Tiff block
    406410               */
    407               if($data->getNbIFDs()>0)
     411              if($data->getNbIFDs()>0 and
     412                 ($this->options['magic'] or $this->options['exif'] or $this->options['maker']))
    408413              {
    409                 $this->loadIfdTags($data->getIFD(0), self::KEY_EXIF_TIFF);
     414                $this->loadIfdTags($data->getIFD(0), Schemas::EXIF_TIFF);
    410415              }
    411416            }
     
    415420               * Load Xmp tags from Xmp block
    416421               */
    417               $this->loadTags($data->getTags(), self::KEY_XMP);
     422              if($this->options['magic'] or $this->options['xmp'])
     423              {
     424                $this->loadTags($data->getTags(), Schemas::XMP);
     425              }
    418426            }
    419427            elseif($data instanceof IptcReader)
     
    425433                $data->optimizeDateTime();
    426434
    427               $this->loadTags($data->getTags(), self::KEY_IPTC);
     435              if($this->options['magic'] or $this->options['iptc'])
     436              {
     437                $this->loadTags($data->getTags(), Schemas::IPTC);
     438              }
    428439            }
    429440          }
     
    433444        {
    434445          $this->processMagicTags();
     446        }
     447
     448        // clean all unwanted metadata
     449        foreach($this->tags as $key => $tag)
     450        {
     451          if(!$this->options[$tag->getSchema()]) unset($this->tags[$key]);
    435452        }
    436453
     
    543560            {
    544561              case 'Exif IFD Pointer':
    545                 $exifKey2=self::KEY_EXIF_EXIF;
     562                $exifKey2=Schemas::EXIF_EXIF;
    546563                break;
    547564              case 'MakerNote':
    548                 $exifKey2=self::KEY_EXIF.".".$tag->getTag()->getLabel()->getMaker();
     565                $exifKey2=Schemas::EXIF_MAKER.".".$tag->getTag()->getLabel()->getMaker();
    549566                break;
    550567              case 'GPS IFD Pointer':
    551                 $exifKey2=self::KEY_EXIF_GPS;
     568                $exifKey2=Schemas::EXIF_GPS;
    552569                break;
    553570              default:
     
    621638            $tag->setImplemented($val['implemented']);
    622639            $tag->setTranslatable($val['translatable']);
     640            $tag->setSchema(Schemas::MAGIC);
    623641
    624642            $i=count($val['tagValues']);
  • extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php

    r5222 r6729  
    5656  class CanonReader extends MakerNotesReader
    5757  {
     58    protected $schema = Schemas::EXIF;
     59
    5860    /**
    5961     * The constructor needs, like the ancestor, the datas to be parsed
     
    187189          $entry->getTag()->setImplemented($tagDef['implemented']);
    188190          $entry->getTag()->setTranslatable($tagDef['translatable']);
     191          $entry->getTag()->setSchema($this->schema);
    189192
    190193          if(array_key_exists('tagValues', $tagDef))
     
    333336          $entry->getTag()->setImplemented($tagDef['implemented']);
    334337          $entry->getTag()->setTranslatable($tagDef['translatable']);
     338          $entry->getTag()->setSchema($this->schema);
    335339
    336340          if(array_key_exists('tagValues', $tagDef))
     
    509513          $entry->getTag()->setImplemented($subTagDef['implemented']);
    510514          $entry->getTag()->setTranslatable($subTagDef['translatable']);
     515          $entry->getTag()->setSchema($this->schema);
    511516
    512517          if(array_key_exists('tagValues', $subTagDef))
     
    598603          $entry->getTag()->setImplemented($subTagDef['implemented']);
    599604          $entry->getTag()->setTranslatable($subTagDef['translatable']);
     605          $entry->getTag()->setSchema($this->schema);
    600606
    601607          if(array_key_exists('tagValues', $subTagDef))
  • extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php

    r5222 r6729  
    5454  class GpsReader extends IfdReader
    5555  {
     56    protected $schema = Schemas::EXIF;
     57
    5658    function __destruct()
    5759    {
  • extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php

    r6722 r6729  
    8181  {
    8282    protected $byteOrder = BYTE_ORDER_LITTLE_ENDIAN;
     83    protected $schema = Schemas::EXIF;
     84
    8385
    8486    private $nextIFDOffset = 0;
    8587
    8688    private $dataOffset = 0;
     89
    8790
    8891    /**
     
    233236        $entry->getTag()->setImplemented($tag['implemented']);
    234237        $entry->getTag()->setTranslatable($tag['translatable']);
     238        $entry->getTag()->setSchema($this->schema);
    235239
    236240        /*
  • extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php

    r5237 r6729  
    6565    const HEADER_1 = "Photoshop 3.0\x00";
    6666    const HEADER_2 = "Adobe_Photoshop2.5:\x00";
     67    protected $schema = Schemas::IPTC;
    6768
    6869    private $header = "";
     
    237238        $tag->setImplemented($tagProperties['implemented']);
    238239        $tag->setTranslatable($tagProperties['translatable']);
     240        $tag->setSchema($this->schema);
    239241
    240242        /*
  • extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php

    r5228 r6729  
    5959  class NikonReader extends MakerNotesReader
    6060  {
     61    protected $schema = Schemas::EXIF;
     62
    6163    /* these 2 specific metadata are used to decrypt some information, like the
    6264     * data lens
  • extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php

    r5222 r6729  
    6060  class PentaxReader extends MakerNotesReader
    6161  {
     62    protected $schema = Schemas::EXIF;
     63
    6264    /**
    6365     * The constructor needs, like the ancestor, the datas to be parsed
  • extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php

    r5237 r6729  
    5353  class XmpReader extends GenericReader
    5454  {
     55    protected $schema = Schemas::XMP;
     56
    5557    private $xmlData = NULL;
    5658
     
    300302        $tag->setImplemented($tagProperties['implemented']);
    301303        $tag->setTranslatable($tagProperties['translatable']);
    302 
     304        $tag->setSchema($this->schema);
    303305
    304306        if(array_key_exists('name', $tagProperties))
  • extensions/AMetaData/admin/amd_metadata_select.tpl

    r6722 r6729  
    201201    <select id="iSelectFilterTagList" onchange="loadTagList();">
    202202      <option value="" {if $datas.config_GetListTags_FilterType==""}selected{/if}>{'g003_no_filter'|@translate}</option>
     203      {if !in_array('magic', $amdConfig.amd_FillDataBaseExcludeFilters)}
    203204      <option value="magic" {if $datas.config_GetListTags_FilterType=="magic"}selected{/if}>{'g003_magic_filter'|@translate}</option>
     205      {/if}
    204206      <option value="userDefined" {if $datas.config_GetListTags_FilterType=="userDefined"}selected{/if}>{'g003_userDefined_filter'|@translate}</option>
     207
     208      {if !in_array('exif', $amdConfig.amd_FillDataBaseExcludeFilters)}
    205209      <option value="exif" {if $datas.config_GetListTags_FilterType=="exif"}selected{/if}>Exif</option>
    206       <option value="exif.Canon" {if $datas.config_GetListTags_FilterType=="exif.Canon"}selected{/if}>Exif [Canon]</option>
    207       <option value="exif.Nikon" {if $datas.config_GetListTags_FilterType=="exif.Nikon"}selected{/if}>Exif [Nikon]</option>
    208       <option value="exif.Pentax" {if $datas.config_GetListTags_FilterType=="exif.Pentax"}selected{/if}>Exif [Pentax]</option>
     210      {/if}
     211      {if !in_array('exif.maker', $amdConfig.amd_FillDataBaseExcludeFilters)}
     212      <option value="exif.maker.Canon" {if $datas.config_GetListTags_FilterType=="exif.maker.Canon"}selected{/if}>Exif [Canon]</option>
     213      <option value="exif.maker.Nikon" {if $datas.config_GetListTags_FilterType=="exif.maker.Nikon"}selected{/if}>Exif [Nikon]</option>
     214      <option value="exif.maker.Pentax" {if $datas.config_GetListTags_FilterType=="exif.maker.Pentax"}selected{/if}>Exif [Pentax]</option>
     215      {/if}
     216      {if !in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters)}
    209217      <option value="xmp" {if $datas.config_GetListTags_FilterType=="xmp"}selected{/if}>Xmp</option>
     218      {/if}
     219      {if !in_array('iptc', $amdConfig.amd_FillDataBaseExcludeFilters)}
    210220      <option value="iptc" {if $datas.config_GetListTags_FilterType=="iptc"}selected{/if}>Iptc</option>
     221      {/if}
    211222    </select>
    212223  </label>
  • extensions/AMetaData/amd.css

    r6722 r6729  
    5656}
    5757.helper {
    58   -moz-border-radius:8px;
    59   -webkit-border-radius:8px;
    60   -khtml-border-radius:8px;
    61   border-radius:8px;
     58  -moz-border-radius:4px;
     59  -webkit-border-radius:4px;
     60  -khtml-border-radius:4px;
     61  border-radius:4px;
    6262  border:2px dashed #777777;
    6363  margin:4px 4px 4px 12px;
     
    104104  border-radius:8px;
    105105}
     106
     107.warnings {
     108  -moz-border-radius:4px;
     109  -webkit-border-radius:4px;
     110  -khtml-border-radius:4px;
     111  border-radius:4px;
     112}
     113.warnings p {
     114  margin:0;
     115  padding:0 0 6px;
     116  text-align: justify;
     117}
     118.warnings ul {
     119  margin:-6px 0;
     120  padding:0 40px 6px;
     121}
     122table.mdInfo {
     123  width:100%;
     124  text-align:left;
     125}
     126table.mdInfo tr {
     127  vertical-align:top;
     128}
     129table.mdInfo tr td ul {
     130  margin:0px;
     131}
     132span.mdInfo {
     133  width:100px;
     134  display:inline-block;
     135  font-weight:bold;
     136}
  • extensions/AMetaData/amd_aip.class.inc.php

    r6722 r6729  
    4545
    4646    $this->loadConfig();
     47    $this->configForTemplate();
    4748    $this->initEvents();
    4849
     
    446447    {
    447448      case 'state':
     449        $template->assign('sheetContent', $this->displayDatabaseStatus());
    448450        break;
    449451      case 'update':
     
    454456    $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');
    455457  }
     458
     459
     460
     461  /**
     462   * display the database status
     463   *
     464   * @return String : the content of the page
     465   */
     466  private function displayDatabaseStatus()
     467  {
     468    global $template, $page;
     469
     470    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_status.tpl');
     471
     472    $datas=array(
     473      'urlRequest' => $this->getAdminLink('ajax'),
     474      'warning1' => GPCCore::BBtoHTML(l10n('g003_databaseWarning1')),
     475      'nfoMetadata' => Array(
     476          'exif' => 0,
     477          'iptc' => 0,
     478          'magic' => 0,
     479          'xmp' => 0,
     480          'userDefined' => 0,
     481          'numOfPictures' => 0,
     482          'numOfNotAnalyzedPictures' => 0,
     483          'numOfPicturesWithoutTag' => 0,
     484          'nfoSize' => 0,
     485          'nfoRows' => 0,
     486          'nfoSizeAndRows' => '',
     487        )
     488    );
     489
     490    $sql="SELECT SUM(numOfImg) AS nb, 'exif' AS `type`
     491          FROM ".$this->tables['used_tags']."
     492          WHERE tagId LIKE 'exif.%'
     493          UNION
     494          SELECT SUM(numOfImg), 'iptc'
     495          FROM ".$this->tables['used_tags']."
     496          WHERE tagId LIKE 'iptc.%'
     497          UNION
     498          SELECT SUM(numOfImg), 'magic'
     499          FROM ".$this->tables['used_tags']."
     500          WHERE tagId LIKE 'magic.%'
     501          UNION
     502          SELECT SUM(numOfImg), 'xmp'
     503          FROM ".$this->tables['used_tags']."
     504          WHERE tagId LIKE 'xmp.%'
     505          UNION
     506          SELECT SUM(numOfImg), 'userDefined'
     507          FROM ".$this->tables['used_tags']."
     508          WHERE tagId LIKE 'userDefined.%'
     509          UNION
     510          SELECT COUNT(imageId), 'numOfPictures'
     511          FROM ".$this->tables['images']."
     512          WHERE analyzed='y'
     513          UNION
     514          SELECT COUNT(imageId), 'numOfNotAnalyzedPictures'
     515          FROM ".$this->tables['images']."
     516          WHERE analyzed='n'
     517          UNION
     518          SELECT COUNT(imageId), 'numOfPicturesWithoutTag'
     519          FROM ".$this->tables['images']."
     520          WHERE nbTags=0";
     521    $result=pwg_query($sql);
     522    if($result)
     523    {
     524      while($row=pwg_db_fetch_assoc($result))
     525      {
     526        if(!is_null($row['nb']))
     527        {
     528          $datas['nfoMetadata'][$row['type']]=$row['nb'];
     529          if($row['type']=='exif' or
     530             $row['type']=='iptc' or
     531             $row['type']=='magic' or
     532             $row['type']=='xmp' or
     533             $row['type']=='userDefined') $datas['nfoMetadata']['nfoRows']+=$row['nb'];
     534        }
     535      }
     536    }
     537
     538    $sql="SHOW TABLE STATUS WHERE name LIKE '".$this->tables['images_tags']."'";
     539    $result=pwg_query($sql);
     540    if($result)
     541    {
     542      while($row=pwg_db_fetch_assoc($result))
     543      {
     544        $datas['nfoMetadata']['nfoSize']=$row['Data_length']+$row['Index_length'];
     545      }
     546    }
     547
     548    if($datas['nfoMetadata']['nfoSize']<1048576)
     549    {
     550      $datas['nfoMetadata']['nfoSize']=sprintf('%.2fKio', $datas['nfoMetadata']['nfoSize']/1024);
     551    }
     552    else
     553    {
     554      $datas['nfoMetadata']['nfoSize']=sprintf('%.2fMio', $datas['nfoMetadata']['nfoSize']/1048576);
     555    }
     556    $datas['nfoMetadata']['nfoSizeAndRows']=sprintf(l10n('g003_sizeAndRows'), $datas['nfoMetadata']['nfoSize'], $datas['nfoMetadata']['nfoRows']);
     557    $datas['nfoMetadata']['numOfPictures']=sprintf(l10n('g003_numberOfAnalyzedPictures'), $datas['nfoMetadata']['numOfPictures']);
     558    $datas['nfoMetadata']['numOfNotAnalyzedPictures']=sprintf(l10n('g003_numberOfNotAnalyzedPictures'), $datas['nfoMetadata']['numOfNotAnalyzedPictures']);
     559    $datas['nfoMetadata']['numOfPicturesWithoutTag']=sprintf(l10n('g003_numberOfPicturesWithoutTags'), $datas['nfoMetadata']['numOfPicturesWithoutTag']);
     560
     561    $template->assign("datas", $datas);
     562
     563    return($template->parse('sheet_page', true));
     564  } // displayDatabaseStatus
     565
     566
    456567
    457568
     
    491602
    492603    /*
    493      * delete metdata for images that are not in the AMD image table
    494      */
    495     $sql="DELETE FROM ".$this->tables['images_tags']."
    496             WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
     604     * delete metadata for images that are not in the AMD image table
     605     */
     606    $sql="DELETE ait
     607          FROM ".$this->tables['images_tags']." ait
     608            JOIN (SELECT DISTINCT imageId FROM ".$this->tables['images_tags']." ) aitd
     609              ON ait.imageId=aitd.imageId
     610          WHERE aitd.imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.") ";
    497611    pwg_query($sql);
    498612
    499613
    500     $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database.tpl');
     614
     615
     616    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_database.tpl');
    501617
    502618    $datas=array(
  • extensions/AMetaData/amd_ajax.php

    r6723 r6729  
    6666           $_REQUEST['ajaxfct']=='admin.makeStats.doAnalyze' or
    6767           $_REQUEST['ajaxfct']=='admin.makeStats.consolidate' or
    68            $_REQUEST['ajaxfct']=='admin.makeStats.getStatus' or
    6968           $_REQUEST['ajaxfct']=='admin.showStats.getListTags' or
    7069           $_REQUEST['ajaxfct']=='admin.showStats.getListImages' or
    7170           $_REQUEST['ajaxfct']=='admin.updateTag.select' or
     71           $_REQUEST['ajaxfct']=='admin.config.setOption' or
    7272           $_REQUEST['ajaxfct']=='admin.group.getList' or
    7373           $_REQUEST['ajaxfct']=='admin.group.delete' or
     
    100100               $_REQUEST['selectMode']=="caddieAdd" or
    101101               $_REQUEST['selectMode']=="caddieReplace" or
     102               $_REQUEST['selectMode']=="analyzed" or
    102103               $_REQUEST['selectMode']=="all")) $_REQUEST['selectMode']="caddieAdd";
    103104
    104105          if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=25;
     106
     107          if(!isset($_REQUEST['ignoreOptions'])) $_REQUEST['ignoreOptions']=array();
    105108        }
    106109
     
    135138
    136139          if(!($_REQUEST['filterType']=="" or
    137                $_REQUEST['filterType']=="magic" or
     140               ($_REQUEST['filterType']=="magic" and !in_array('magic', $this->config['amd_FillDataBaseExcludeFilters'])) or
    138141               $_REQUEST['filterType']=="userDefined" or
    139                $_REQUEST['filterType']=="exif" or
    140                $_REQUEST['filterType']=="exif.Canon" or
    141                $_REQUEST['filterType']=="exif.Nikon" or
    142                $_REQUEST['filterType']=="exif.Pentax" or
    143                $_REQUEST['filterType']=="xmp" or
    144                $_REQUEST['filterType']=="iptc")) $_REQUEST['filterType']="";
     142               ($_REQUEST['filterType']=="exif" and !in_array('exif', $this->config['amd_FillDataBaseExcludeFilters'])) or
     143               ($_REQUEST['filterType']=="exif.maker.Canon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
     144               ($_REQUEST['filterType']=="exif.maker.Nikon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
     145               ($_REQUEST['filterType']=="exif.maker.Pentax" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
     146               ($_REQUEST['filterType']=="xmp" and !in_array('xmp', $this->config['amd_FillDataBaseExcludeFilters'])) or
     147               ($_REQUEST['filterType']=="iptc"  and !in_array('iptc', $this->config['amd_FillDataBaseExcludeFilters']))
     148               )) $_REQUEST['filterType']="";
    145149
    146150          if(!isset($_REQUEST['excludeUnusedTag'])) $_REQUEST['excludeUnusedTag']="n";
     
    176180
    177181          if(!isset($_REQUEST['tagSelected'])) $_REQUEST['tagSelected']="";
     182        }
     183
     184        /*
     185         * check admin.config.setOption values
     186         */
     187        if($_REQUEST['ajaxfct']=="admin.config.setOption")
     188        {
     189          if(!isset($_REQUEST['id'])) $_REQUEST['ajaxfct']='';
     190          if(!isset($_REQUEST['value'])) $_REQUEST['ajaxfct']='';
    178191        }
    179192
     
    315328      {
    316329        case 'admin.makeStats.getList':
    317           $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems']);
     330          $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems'], $_REQUEST['ignoreOptions']);
    318331          break;
    319332        case 'admin.makeStats.doAnalyze':
     
    323336          $result=$this->ajax_amd_admin_makeStatsConsolidate();
    324337          break;
    325         case 'admin.makeStats.getStatus':
    326           $result=$this->ajax_amd_admin_makeStatsGetStatus();
    327           break;
    328338        case 'admin.showStats.getListTags':
    329339          $result=$this->ajax_amd_admin_showStatsGetListTags($_REQUEST['orderType'], $_REQUEST['filterType'], $_REQUEST['excludeUnusedTag'], $_REQUEST['selectedTagOnly']);
     
    334344        case 'admin.updateTag.select':
    335345          $result=$this->ajax_amd_admin_updateTagSelect($_REQUEST['numId'], $_REQUEST['tagSelected']);
     346          break;
     347        case 'admin.config.setOption':
     348          $result=$this->ajax_amd_admin_configSetOption($_REQUEST['id'], $_REQUEST['value']);
    336349          break;
    337350        case 'admin.group.getList':
     
    452465     *                      "23 78 4523 5670"
    453466     */
    454     private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems)
     467    private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems, $ignoreSchemas)
    455468    {
    456469      global $user;
    457470
    458471      $returned="";
     472      $this->config['amd_FillDataBaseIgnoreSchemas']=$ignoreSchemas;
    459473      $this->config['amd_NumberOfItemsPerRequest']=$nbOfItems;
    460474      $this->saveConfig();
    461475
    462476      $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait";
    463       if($mode=="notAnalyzed")
     477      if($mode=='notAnalyzed')
    464478      {
    465479        $sql.=" WHERE ait.analyzed='n'";
    466480      }
    467       elseif($mode=="caddieAdd" or $mode=="caddieReplace")
    468       {
    469 
     481      elseif($mode=='caddieAdd' or $mode=='caddieReplace')
     482      {
    470483        $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id
    471484              WHERE ct.user_id = ".$user['id']." ";
    472485
    473         if($mode=="caddieAdd") $sql.=" AND ait.analyzed='n'";
    474       }
    475 
    476       if($mode=="all" or $mode=="caddieReplace")
     486        if($mode=='caddieAdd') $sql.=" AND ait.analyzed='n'";
     487      }
     488      elseif($mode=='analyzed')
     489      {
     490        $sql.=" WHERE ait.analyzed='y'";
     491
     492        pwg_query("UPDATE ".$this->tables['images']." SET nbTags=0 WHERE analyzed='y';");
     493        pwg_query("UPDATE ".$this->tables['used_tags']." SET numOfImg=0");
     494        pwg_query("DELETE FROM ".$this->tables['images_tags']);
     495      }
     496
     497      if($mode=='all' or $mode=='caddieReplace')
    477498      {
    478499        pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0");
     
    563584
    564585    /**
    565      * returns a list of formated string, separated with a semi-colon :
    566      *  - number of current analyzed pictures + number of current analyzed tags
    567      *    for the analyzed pictures
    568      *  - number of pictures not analyzed
    569      *  - number of pictures without tag
    570      *
    571      * @return String
    572      */
    573     private function ajax_amd_admin_makeStatsGetStatus()
    574     {
    575       $numOfMetaData=0;
    576       $numOfPictures=0;
    577       $numOfPicturesNotAnalyzed=0;
    578 
    579       $sql="SELECT COUNT(imageId), SUM(nbTags) FROM ".$this->tables['images']."
    580               WHERE analyzed='y';";
    581       $result=pwg_query($sql);
    582       if($result)
    583       {
    584         while($row=pwg_db_fetch_row($result))
    585         {
    586           $numOfPictures=$row[0];
    587           $numOfMetaData=$row[1];
    588         }
    589       }
    590 
    591 
    592       $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
    593               WHERE analyzed='n';";
    594       $result=pwg_query($sql);
    595       if($result)
    596       {
    597         while($row=pwg_db_fetch_row($result))
    598         {
    599           $numOfPicturesNotAnalyzed=$row[0];
    600         }
    601       }
    602 
    603       $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
    604               WHERE nbTags=0;";
    605       $result=pwg_query($sql);
    606       if($result)
    607       {
    608         while($row=pwg_db_fetch_row($result))
    609         {
    610           $numOfPicturesWithoutTags=$row[0];
    611         }
    612       }
    613 
    614       return(sprintf(l10n("g003_numberOfAnalyzedPictures"), $numOfPictures, $numOfMetaData).";".
    615                 sprintf(l10n("g003_numberOfNotAnalyzedPictures"), $numOfPicturesNotAnalyzed).";".
    616                 sprintf(l10n("g003_numberOfPicturesWithoutTags"), $numOfPicturesWithoutTags));
    617     }
    618 
    619 
    620     /**
    621586     * return a formatted <table> (using the template "amd_stat_show_iListTags")
    622587     * of used tag with, for each tag, the number and the percentage of pictures
     
    13851350      $nbImg=$this->buildUserDefinedTags($id);
    13861351
    1387       $sql="UPDATE ".$this->tables['used_tags']."
    1388               SET numOfImg='$nbImg';";
    1389       $result=pwg_query($sql);
     1352      $this->makeStatsConsolidation();
    13901353
    13911354      return($id.','.$nbImg);
     
    14381401    }
    14391402
    1440 
    1441   }
     1403    /**
     1404     * set value(s) for option(s)
     1405     *
     1406     * @param Array or String $ids : a string or an array of string (id)
     1407     * @param Array or String $values : a string or an array of string
     1408     * @return String : ok or ko
     1409     */
     1410    private function ajax_amd_admin_configSetOption($ids, $values)
     1411    {
     1412      if(is_array($ids) and is_array($values) and count($ids)==count($values))
     1413      {
     1414        foreach($ids as $key=>$id)
     1415        {
     1416          if(isset($id, $this->config))
     1417          {
     1418            $this->config[$id]=$values[$key];
     1419          }
     1420        }
     1421        $this->saveConfig();
     1422        return('ok');
     1423      }
     1424      elseif(is_string($ids) and is_string($values))
     1425      {
     1426        if(isset($ids, $this->config))
     1427        {
     1428          $this->config[$ids]=$values;
     1429        }
     1430        $this->saveConfig();
     1431        return('ok');
     1432      }
     1433
     1434      return('ko');
     1435    }
     1436
     1437
     1438
     1439  } //class
    14421440
    14431441
  • extensions/AMetaData/amd_install.class.inc.php

    r6722 r6729  
    156156      $this->initConfig();
    157157      $this->loadConfig();
     158      $this->loadConfigFromFile(dirname($this->getFileLocation()).'/activatePlugin.conf.php');
    158159
    159160      /*
     
    177178      }
    178179
     180      $this->config['amd_FillDataBaseExcludeTags']=array();
    179181      $this->config['installed']=AMD_VERSION2; //update the installed release number
    180182      $this->saveConfig();
     
    234236    private function initializeDatabase()
    235237    {
     238      global $user;
     239
    236240      L10n::setLanguage('en_UK');
    237241
     
    249253      {
    250254        $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0, '".addslashes(L10n::get($val['name']))."');";
     255        pwg_query($sql);
     256      }
     257
     258      /*
     259       * exclude unauthorized tag with the 'amd_FillDataBaseExcludeTags' option
     260       */
     261      if(count($this->config['amd_FillDataBaseExcludeTags']))
     262      {
     263        $sql="";
     264        foreach($this->config['amd_FillDataBaseExcludeTags'] as $key => $tag)
     265        {
     266          if($sql!="") $sql.=" OR ";
     267          $sql.=" tagId LIKE '$tag' ";
     268        }
     269        $sql="DELETE FROM ".$this->tables['used_tags']."
     270              WHERE ".$sql;
    251271        pwg_query($sql);
    252272      }
  • extensions/AMetaData/amd_root.class.inc.php

    r6722 r6729  
    7676  {
    7777    $this->config=array(
    78       'amd_NumberOfItemsPerRequest' => 25,
     78      // options set by the plugin interface - don't modify them manually
    7979      'amd_GetListTags_OrderType' => "tag",
    8080      'amd_GetListTags_FilterType' => "magic",
     
    8282      'amd_GetListTags_SelectedTagOnly' => "n",
    8383      'amd_GetListImages_OrderType' => "value",
     84      'amd_AllPicturesAreAnalyzed' => "n",
    8485      'amd_FillDataBaseContinuously' => "y",
    85       'amd_AllPicturesAreAnalyzed' => "n",
     86      'amd_FillDataBaseIgnoreSchemas' => array(),
     87
     88      // theses options can be set manually
     89      'amd_NumberOfItemsPerRequest' => 25,
     90      'amd_DisplayWarningsMessageStatus' => "y",
     91      'amd_DisplayWarningsMessageUpdate' => "y",
     92      'amd_FillDataBaseExcludeTags' => array(),
     93      'amd_FillDataBaseExcludeFilters' => array(),
    8694    );
     95    /*
     96     * ==> amd_FillDataBaseExcludeTags : array of tagId
     97     *     the listed tag are completely excluded by the plugin, as they don't
     98     *     exist
     99     *     for each tagId you can use generic char as the LIKE sql operator
     100     *      array('xmp.%', 'exif.maker.%')
     101     *        -> exclude all XMP and EXIF MAKER tags
     102     *
     103     * ==> amd_FillDataBaseExcludeFilters : array of filterValue
     104     *     if you exclude all the xmp tag you probably want to exclude everything
     105     *     displaying 'xmp'
     106     *     array('exif.maker',
     107     *           'exif',
     108     *           'iptc',
     109     *           'xmp',
     110     *           'magic')
     111     *
     112     * ==> amd_DisplayWarningsMessageStatus : 'y' or 'n'
     113     *     amd_DisplayWarningsMessageUpdate
     114     *     you can disable warnings messages displayed on the database status&update
     115     *     page
     116     */
    87117  }
    88118
     
    107137      return(parent::getAdminLink());
    108138    }
     139  }
     140
     141  /**
     142   *
     143   */
     144  protected function configForTemplate()
     145  {
     146    global $template;
     147
     148    $template->assign('amdConfig', $this->config);
    109149  }
    110150
     
    175215  protected function analyzeImageFile($fileName, $imageId, $loaded=false)
    176216  {
     217    $schemas=array_flip($this->config['amd_FillDataBaseIgnoreSchemas']);
    177218    /*
    178219     * the JpegMetaData object is instancied in the constructor
     
    185226          'filter' => AMD_JpegMetaData::TAGFILTER_IMPLEMENTED,
    186227          'optimizeIptcDateTime' => true,
    187           'exif' => true,
    188           'iptc' => true,
    189           'xmp' => true
     228          'exif' => !isset($schemas['exif']),
     229          'iptc' => !isset($schemas['iptc']),
     230          'xmp' => !isset($schemas['xmp']),
     231          'magic' => !isset($schemas['magic']),
    190232        )
    191233      );
     
    469511  protected function makeStatsConsolidation()
    470512  {
     513    // reset numbers
     514    $sql="UPDATE ".$this->tables['used_tags']." ut
     515          SET ut.numOfImg = 0;";
     516    pwg_query($sql);
     517
     518    $sql="UPDATE ".$this->tables['images']." pai
     519          SET pai.nbTags = 0;";
     520    pwg_query($sql);
     521
     522
     523    // count number of images per tag
    471524    $sql="UPDATE ".$this->tables['used_tags']." ut,
    472             (SELECT COUNT(imageId) AS nb, numId
     525            (SELECT COUNT(DISTINCT imageId) AS nb, numId
    473526              FROM ".$this->tables['images_tags']."
    474527              GROUP BY numId) nb
    475528          SET ut.numOfImg = nb.nb
    476529          WHERE ut.numId = nb.numId;";
     530    pwg_query($sql);
     531
     532    //count number of tags per images
     533    $sql="UPDATE ".$this->tables['images']." pai,
     534            (SELECT COUNT(DISTINCT numId) AS nb, imageId
     535              FROM ".$this->tables['images_tags']."
     536              GROUP BY imageId) nb
     537          SET pai.nbTags = nb.nb
     538          WHERE pai.imageId = nb.imageId;";
    477539    pwg_query($sql);
    478540
  • extensions/AMetaData/language/fr_FR/plugin.lang.php

    r6722 r6729  
    1313$lang['g003_show'] = "Consulter";
    1414
    15 $lang['g003_numberOfAnalyzedPictures'] = "%d images ont fait l'objet d'une analyse et représentent %d métadonnées";
    1615$lang['g003_numberOfNotAnalyzedPictures'] = "%d images n'ont pas fait l'objet d'une analyse";
    1716$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";
     
    7877$lang['g003_warning_on_analyze_3a'] = "du nombre de photos dans la galerie";
    7978$lang['g003_warning_on_analyze_3b'] = "du nombre de pages visualisées quotidiennement";
    80 $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";
    81 $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";
     79
    8280$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 :";
    8381$lang['g003_warning_on_analyze_0'] = "Attention !";
     
    165163[/ul]";
    166164
    167 
    168 // release 0.5.0
     165/*
     166 * release 0.5.0
     167 */
    169168
    170169$lang['g003_y'] = "Oui";
     
    211210$lang['g003_userDefined_filter'] = "Métadonnées personnalisées";
    212211
     212$lang['g003_informations'] = "Informations";
     213$lang['g003_databaseInformation'] = "Informations importantes à propos du référentiel";
     214$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.
     215Avant 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.
     216[/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.
     217[/p][p]L'alimentation du référentiel est nécessaire si vous souhaitez :[/p]
     218[ul]
     219[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]
     220[li]Disposer du moteur de recherche[/li]
     221[/ul]
     222";
     223$lang['g003_sizeAndRows'] = "Le référentiel fait %s et est constitué de %s métadonnées";
     224$lang['g003_numberOfAnalyzedPictures'] = "%d images ont fait l'objet d'une analyse";
     225
     226$lang['g003_options'] = "Options";
     227$lang['g003_fillDatabaseContinuously'] = "Alimenter le référentiel au fil de l'eau";
     228$lang['g003_ignoreMetadata'] = "Ignorer les métadonnées suivantes :";
     229
     230$lang['g003_analyze_analyzed_pictures'] = "L'analyse ne porte que sur les images ayant déjà fait l'objet d'une analyse";
     231$lang['g003_fillDatabaseIgnoreWarning'] = "Pour être prise en compte, la modification des paramètres de cette option nécessite d'effectuer une analyse";
     232
     233/*
     234 * removed keys
     235 */
     236//$lang['g003_warning_on_analyze_4a']
     237//$lang['g003_warning_on_analyze_4b']
     238
     239
    213240?>
  • extensions/AMetaData/main.inc.php

    r6722 r6729  
    5656|         |            |   . Add possibility for user to build their own "magic"
    5757|         |            |     tags
     58|         |            | * mantis : feature 1777
     59|         |            |   . Weight of the metadata database can becomes very
     60|         |            |     heavy
    5861|         |            | * ajax management was entirely rewritted
    5962|         |            | * user interface reviewed
    60 |         |            |
    61 |         |            |
    6263|         |            |
    6364|         |            |
  • extensions/AMetaData/maintain.inc.php

    r6722 r6729  
    8383function plugin_activate($plugin_id, $plugin_version, &$errors)
    8484{
    85   global $prefixeTable;
     85  global $prefixeTable, $gpcNeeded;
    8686
    8787  $amd=new AMD_install($prefixeTable, __FILE__);
Note: See TracChangeset for help on using the changeset viewer.