Changeset 7519


Ignore:
Timestamp:
Oct 31, 2010, 7:08:03 PM (13 years ago)
Author:
grum
Message:

Exploit the JpegMetadata class previous evolution
feature:1975, feature:1976, feature:1978

Location:
extensions/AMetaData
Files:
14 edited

Legend:

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

    r7511 r7519  
    107107 * |         |            |   . Implement keywords as magic tag
    108108 * |         |            |
     109 * |         |            | * mantis bug:1978
     110 * |         |            |   . Some meta names are not translated in french
    109111 * |         |            |
    110112 * |         |            |
     
    796798          return($num);
    797799        case "Author.Keywords":
    798           $list=array_flip(array_flip(explode(',', str_replace(array('/', '|', ', '), ',', $value))));
     800          $list=array_flip(array_flip(explode(',', str_replace(array('/', '|', ','), ',', $value))));
    799801          sort($list);
    800           return(implode(',', $list));
     802          $tmp=array();
     803          foreach($list as $key=>$val)
     804          {
     805            if(trim($val)!='') $tmp[]=trim($val);
     806          }
     807          return($tmp);
    801808          break;
    802809        default:
  • extensions/AMetaData/admin/amd_metadata_database_database.tpl

    r7447 r7519  
    9090    {
    9191      ignoreOptions.push('xmp');
     92    }
     93    if($('#iFillDataBaseIgnore_com').get(0).checked)
     94    {
     95      ignoreOptions.push('com');
    9296    }
    9397
     
    254258            in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters) and
    255259            in_array('iptc', $amdConfig.amd_FillDataBaseExcludeFilters) and
    256             in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters)) }
     260            in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters) and
     261            in_array('com', $amdConfig.amd_FillDataBaseExcludeFilters)) }
    257262        <br>
    258263        {'g003_ignoreMetadata'|@translate}<br>
     
    270275              {/if}
    271276              {if !in_array('xmp', $amdConfig.amd_FillDataBaseExcludeFilters)}
    272               <label><input onclick='displayAnalyzedOption();' type="checkbox" id='iFillDataBaseIgnore_xmp' {if in_array('xmp', $amdConfig.amd_FillDataBaseIgnoreSchemas)}checked{/if}>&nbsp;XMP</label>
     277              <label><input onclick='displayAnalyzedOption();' type="checkbox" id='iFillDataBaseIgnore_xmp' {if in_array('xmp', $amdConfig.amd_FillDataBaseIgnoreSchemas)}checked{/if}>&nbsp;XMP</label><br>
     278              {/if}
     279              {if !in_array('com', $amdConfig.amd_FillDataBaseExcludeFilters)}
     280              <label><input onclick='displayAnalyzedOption();' type="checkbox" id='iFillDataBaseIgnore_com' {if in_array('com', $amdConfig.amd_FillDataBaseIgnoreSchemas)}checked{/if}>&nbsp;COM</label>
    273281              {/if}
    274282            </td>
  • extensions/AMetaData/admin/amd_metadata_database_status.tpl

    r6950 r7519  
    11<h2>{'g003_status_of_database'|@translate}</h2>
     2
     3{if $datas.warning2!=''}
     4<div class="warnings">
     5<p style="font-size: 120%;">{'g003_database_is_not_up_to_date'|@translate}</p>
     6{$datas.warning2}
     7</div>
     8{/if}
     9
    210
    311{if $amdConfig.amd_DisplayWarningsMessageStatus=='y'}
     
    614{$datas.warning1}
    715</div>
     16{/if}
    817
    918<fieldset>
     
    2837     <li><span class="mdInfo">XMP</span>{$datas.nfoMetadata.xmp}</li>
    2938     {/if}
     39     {if !in_array('com', $amdConfig.amd_FillDataBaseExcludeFilters)}
     40     <li><span class="mdInfo">COM</span>{$datas.nfoMetadata.com}</li>
     41     {/if}
    3042     <li><span class="mdInfo">{'g003_personnal'|@translate}</span>{$datas.nfoMetadata.userDefined}</li>
    3143    </ul>
     
    4557
    4658
    47 {/if}
    4859
  • extensions/AMetaData/admin/amd_metadata_select.tpl

    r6950 r7519  
    224224      <option value="iptc" {if $datas.config_GetListTags_FilterType=="iptc"}selected{/if}>Iptc</option>
    225225      {/if}
     226      {if !in_array('com', $amdConfig.amd_FillDataBaseExcludeFilters)}
     227      <option value="com" {if $datas.config_GetListTags_FilterType=="com"}selected{/if}>Com</option>
     228      {/if}
    226229    </select>
    227230  </label>
  • extensions/AMetaData/amd_aip.class.inc.php

    r7447 r7519  
    558558    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_status.tpl');
    559559
     560    $warning2='';
     561    $sql="SELECT tagId
     562          FROM ".$this->tables['used_tags']."
     563          WHERE newFromLastUpdate='y'";
     564    $result=pwg_query($sql);
     565    if($result)
     566    {
     567      $tmp=array();
     568      $tagSchema='';
     569      while($row=pwg_db_fetch_assoc($result))
     570      {
     571        if(preg_match('/^([a-z0-9]*)\..*/i', $row['tagId'], $tagSchema))
     572        {
     573          if(!in_array($tagSchema[1],$this->config['amd_FillDataBaseIgnoreSchemas'])) $tmp[]=$row['tagId'];
     574        }
     575      }
     576      if(count($tmp)>0)
     577      {
     578        $ul='';
     579        foreach($tmp as $val)
     580        {
     581          $ul.='<li>'.$val.'</li>';
     582        }
     583        if(count($tmp)>1)
     584        {
     585          $warning2=sprintf(GPCCore::BBtoHTML(l10n('g003_databaseWarning2_n')),$ul);
     586        }
     587        else
     588        {
     589          $warning2=sprintf(GPCCore::BBtoHTML(l10n('g003_databaseWarning2_1')),$ul);
     590        }
     591      }
     592    }
     593
     594
    560595    $datas=array(
    561596      'urlRequest' => $this->getAdminLink('ajax'),
     597      'warning2' => $warning2,
    562598      'warning1' => GPCCore::BBtoHTML(l10n('g003_databaseWarning1')),
    563599      'nfoMetadata' => Array(
     
    566602          'magic' => 0,
    567603          'xmp' => 0,
     604          'com' => 0,
    568605          'userDefined' => 0,
    569606          'numOfPictures' => 0,
     
    591628          FROM ".$this->tables['used_tags']."
    592629          WHERE tagId LIKE 'xmp.%'
     630          UNION
     631          SELECT SUM(numOfImg), 'com'
     632          FROM ".$this->tables['used_tags']."
     633          WHERE tagId LIKE 'com.%'
    593634          UNION
    594635          SELECT SUM(numOfImg), 'userDefined'
     
    619660             $row['type']=='magic' or
    620661             $row['type']=='xmp' or
     662             $row['type']=='com' or
    621663             $row['type']=='userDefined') $datas['nfoMetadata']['nfoRows']+=$row['nb'];
    622664        }
  • extensions/AMetaData/amd_aip_install.class.inc.php

    r7399 r7519  
    174174      'magic.Author.Copyright',
    175175      'magic.Author.ImageTitle',
     176      'magic.Author.Keywords',
    176177      'magic.GPS.Altitude',
    177178      'magic.GPS.Latitude',
  • extensions/AMetaData/amd_ajax.php

    r7447 r7519  
    162162               ($_REQUEST['filterType']=="exif.maker.Pentax" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or
    163163               ($_REQUEST['filterType']=="xmp" and !in_array('xmp', $this->config['amd_FillDataBaseExcludeFilters'])) or
    164                ($_REQUEST['filterType']=="iptc"  and !in_array('iptc', $this->config['amd_FillDataBaseExcludeFilters']))
     164               ($_REQUEST['filterType']=="iptc"  and !in_array('iptc', $this->config['amd_FillDataBaseExcludeFilters'])) or
     165               ($_REQUEST['filterType']=="com"  and !in_array('com', $this->config['amd_FillDataBaseExcludeFilters']))
    165166               )) $_REQUEST['filterType']="";
    166167
     
    659660     * @param String $orderType : order for the list (by tag 'tag' or by number of
    660661     *                            pictures 'num')
    661      * @param String $filterType : filter for the list ('exif', 'xmp', 'iptc' or '')
     662     * @param String $filterType : filter for the list ('exif', 'xmp', 'iptc', 'com' or '')
    662663     * @return String
    663664     */
     
    15331534                   paut.tagId = 'xmp.digiKam:TagsList' OR
    15341535                   paut.tagId = 'xmp.lr:hierarchicalSubject' OR
    1535                    paut.tagId = 'iptc.Keywords');";
     1536                   paut.tagId = 'iptc.Keywords' OR
     1537                   paut.tagId = 'magic.Author.Keywords');";
    15361538      $result=pwg_query($sql);
    15371539      if($result)
     
    15451547             */
    15461548            $tmp=unserialize($row['value']);
     1549            if(!isset($tmp['values'])) $tmp=array('values'=>$tmp);
    15471550            foreach($tmp['values'] as $val)
    15481551            {
     
    16361639                   paut.tagId = 'xmp.digiKam:TagsList' OR
    16371640                   paut.tagId = 'xmp.lr:hierarchicalSubject' OR
    1638                    paut.tagId = 'iptc.Keywords');";
     1641                   paut.tagId = 'iptc.Keywords' OR
     1642                   paut.tagId = 'magic.Author.Keywords');";
    16391643      $result=pwg_query($sql);
    16401644      if($result)
     
    16481652             */
    16491653            $tmp=unserialize($row['value']);
     1654            if(!isset($tmp['values'])) $tmp=array('values'=>$tmp);
    16501655            foreach($tmp['values'] as $val)
    16511656            {
    1652               if($row['tagId']=='xmp.digiKam:TagsList')
     1657              if($row['tagId']=='xmp.digiKam:TagsList' or $row['tagId']=='xmp.lr:hierarchicalSubject')
    16531658              {
    16541659                $list=explode($this->tagSeparators[$row['tagId']], $val);
  • extensions/AMetaData/amd_install.class.inc.php

    r7399 r7519  
    4747      $this->initConfig();
    4848      $this->loadConfig();
     49      $this->config['amd_FillDataBaseIgnoreSchemas']=> array('exif', 'iptc', 'xmp', 'com');
    4950      $this->config['installed']=AMD_VERSION2;
    5051      $this->config['newInstall']='y';
     
    5960  `numOfImg` int(10) unsigned NOT NULL default '0',
    6061  `translatedName` varchar(200) NOT NULL default '',
     62  `newFromLastUpdate` char(1) NOT NULL default 'n',
    6163  PRIMARY KEY  (`numId`),
    6264  KEY `by_tag` (`tagId`)
     
    177179          $this->config['newInstall']='n';
    178180          $this->updateFrom_000400();
    179           break;
     181        case '00.05.01':
     182        case '00.05.02':
     183          $this->config['newInstall']='n';
     184          $this->updateFrom_000502();
    180185        default:
    181186          /*
     
    183188           * database with default values
    184189           */
    185           $this->initializeDatabase();
     190          $this->fillDatabase();
    186191          break;
    187192      }
     
    247252    }
    248253
    249 
     254    /**
     255     * update the database from the release 0.5.2
     256     */
     257    private function updateFrom_000502()
     258    {
     259      /*
     260       * alter existing tables
     261       */
     262      $tablesUpdate=array(
     263        $this->tables['used_tags'] => array(
     264          'newFromLastUpdate' => "ADD COLUMN `newFromLastUpdate` CHAR(1)  NOT NULL DEFAULT 'n' AFTER `translatedName`",
     265        )
     266      );
     267
     268      $tablef=new GPCTables(array($this->tables['used_tags']));
     269
     270      if(count($tablesUpdate)>0) $tablef->updateTablesFields($tablesUpdate);
     271
     272      unset($tablesUpdate);
     273    }
    250274
    251275
     
    253277     * fill the database with some default value
    254278     */
    255     private function initializeDatabase()
     279    private function fillDatabase()
     280    {
     281      if($this->config['newInstall']=='y')
     282      {
     283        $this->initializeDatabaseContent();
     284      }
     285      else
     286      {
     287        $this->updateDatabaseContent();
     288      }
     289    }
     290
     291    /**
     292     * reset and initialize the database content (for a fresh install)
     293     */
     294    private function initializeDatabaseContent()
    256295    {
    257296      global $user;
     
    269308       * fill the 'used_tags' table with default values
    270309       */
    271       foreach(AMD_JpegMetaData::getTagList(Array('filter' => AMD_JpegMetaData::TAGFILTER_IMPLEMENTED, 'xmp' => true, 'maker' => true, 'iptc' => true)) as $key => $val)
    272       {
    273         $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0, '".addslashes(L10n::get($val['name']))."');";
     310      foreach(AMD_JpegMetaData::getTagList(
     311                Array('filter' => AMD_JpegMetaData::TAGFILTER_IMPLEMENTED,
     312                      'xmp' => true,
     313                      'maker' => true,
     314                      'iptc' => true,
     315                      'com' => true)
     316              ) as $key => $val
     317             )
     318      {
     319        $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0, '".addslashes(L10n::get($val['name']))."', 'n');";
    274320        pwg_query($sql);
    275321      }
     
    292338    }
    293339
     340    /**
     341     * update the database content (for an update)
     342     */
     343    private function updateDatabaseContent()
     344    {
     345      global $user;
     346
     347      L10n::setLanguage('en_UK');
     348
     349      pwg_query("INSERT INTO ".$this->tables['images']."
     350                  SELECT id, 'n', 0
     351                    FROM ".IMAGES_TABLE."
     352                    WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")");
     353
     354      $tagList=array();
     355      $sql="SELECT tagId FROM ".$this->tables['used_tags'];
     356      $result=pwg_query($sql);
     357      if($result)
     358      {
     359        while($row=pwg_db_fetch_row($result))
     360        {
     361          $tagList[$row[0]]='';
     362        }
     363      }
     364
     365      /*
     366       * fill the 'used_tags' table with default values
     367       */
     368      foreach(AMD_JpegMetaData::getTagList(
     369                Array('filter' => AMD_JpegMetaData::TAGFILTER_IMPLEMENTED,
     370                      'xmp' => true,
     371                      'maker' => true,
     372                      'iptc' => true,
     373                      'com' => true)
     374              ) as $key => $val
     375             )
     376      {
     377        if(!array_key_exists($key, $tagList))
     378        {
     379          $sql="INSERT IGNORE INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0, '".addslashes(L10n::get($val['name']))."', 'y');";
     380          pwg_query($sql);
     381        }
     382      }
     383
     384      /*
     385       * exclude unauthorized tag with the 'amd_FillDataBaseExcludeTags' option
     386       */
     387      if(count($this->config['amd_FillDataBaseExcludeTags']))
     388      {
     389        $sql="";
     390        foreach($this->config['amd_FillDataBaseExcludeTags'] as $key => $tag)
     391        {
     392          if($sql!="") $sql.=" OR ";
     393          $sql.=" tagId LIKE '$tag' ";
     394        }
     395        $sql="DELETE FROM ".$this->tables['used_tags']."
     396              WHERE ".$sql;
     397        pwg_query($sql);
     398      }
     399    }
     400
     401
    294402    private function buildDefaultGroup()
    295403    {
  • extensions/AMetaData/amd_root.class.inc.php

    r6950 r7519  
    3737  {
    3838    global $user;
    39     $this->setPluginName("AMetaData");
     39    $this->setPluginName("Advanced MetaData");
    4040    $this->setPluginNameFiles("amd");
    4141    parent::__construct($prefixeTable, $filelocation);
     
    111111     *           'iptc',
    112112     *           'xmp',
    113      *           'magic')
     113     *           'magic',
     114     *           'com')
    114115     *
    115116     * ==> amd_DisplayWarningsMessageStatus : 'y' or 'n'
     
    240241          'xmp' => !isset($schemas['xmp']),
    241242          'magic' => !isset($schemas['magic']),
     243          'com' => !isset($schemas['com']),
    242244        )
    243245      );
     
    582584
    583585    }
     586print_r($this->config['amd_FillDataBaseIgnoreSchemas']);
    584587    $this->saveConfig();
    585588  }
  • extensions/AMetaData/amd_version.inc.php

    r7036 r7519  
    1717  if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1818
    19   define('AMD_VERSION',  '0.5.2');
    20   define('AMD_VERSION2', '00.05.02');
     19  define('AMD_VERSION',  '0.5.3');
     20  define('AMD_VERSION2', '00.05.03');
    2121  define('AMD_GPC_NEEDED', '3.2.0');
    2222?>
  • extensions/AMetaData/language/en_UK/plugin.lang.php

    r7447 r7519  
    11<?php
    2 
     2/*
     3 * How to translate metadata names and values ?
     4 *
     5 * Metadata names and values are not translated with a /language/*.lang.php file
     6 * but they are stored in a .po and .mo files, respectively localized into
     7 *  - /JpegMetaData/Locale/xx_XX/Tag.po
     8 *  - /JpegMetaData/Locale/xx_XX/LC_MESSAGES/Tag.mo
     9 *
     10 * More information about GNU gettext l10n system and method to edit the .po & .mo
     11 * files on wikipedia :
     12 *  - http://en.wikipedia.org/wiki/GNU_gettext
     13 *
     14 */
    315
    416$lang['Grum Plugin Classes is not installed'] = '<b>Grum Plugin Classes</b> plugin is not installed';
     
    343355
    344356
    345 
    346 
     357$lang['g003_database_is_not_up_to_date']="The repository is not up do date !";
     358$lang['g003_databaseWarning2_1']="[p]A new metadata is available since the last update of the plugin:[/p][ul]%s[/ul]
     359[p]
     360To be exploited, it is necessary to update the repository.[/p]";
     361$lang['g003_databaseWarning2_n']="[p]Some new metadatas are available since the last update of the plugin:[/p][ul]%s[/ul]
     362[p]
     363To be exploited, it is necessary to update the repository.[/p]";
     364
     365// help for metadata translation is given at the beginning of this file
    347366
    348367?>
  • extensions/AMetaData/language/es_ES/plugin.lang.php

    r7035 r7519  
    11<?php
     2/*
     3 * How to translate metadata names and values ?
     4 *
     5 * Metadata names and values are not translated with a /language/*.lang.php file
     6 * but they are stored in a .po and .mo files, respectively localized into
     7 *  - /JpegMetaData/Locale/xx_XX/Tag.po
     8 *  - /JpegMetaData/Locale/xx_XX/LC_MESSAGES/Tag.mo
     9 *
     10 * More information about GNU gettext l10n system and method to edit the .po & .mo
     11 * files on wikipedia :
     12 *  - http://en.wikipedia.org/wiki/GNU_gettext
     13 *
     14 */
    215
    316$lang['Grum Plugin Classes is not installed'] = 'El plugin <b>Grum Plugin Classes</b> no esta instalado';
     
    1629$lang['g003_performances'] = "Rendimiento";
    1730$lang['g003_setting_nb_items_per_request'] = "Numero de imágenes analizadas por demandas";
    18 $lang['g003_apply'] = "Afficher en écriture latineAplicar";
     31$lang['g003_apply'] = "Aplicar";
    1932
    2033$lang['g003_numberOfAnalyzedPictures'] = "%d imágenes han sido objeto de un análisis y representan %d métadatos";
     
    326339
    327340
     341/** ----------------------------------------------------------------------------
     342 * new keys from releases 0.5.3
     343 *
     344 *
     345 * need to be translated
     346 * thanks :)
     347 */
     348$lang['g003_1_picture_in_caddie']="1 picture in caddie";
     349$lang['g003_n_pictures_in_caddie']="%s pictures in caddie";
     350$lang['g003_analyze_random_pictures'] = "The analysis focuses on %s images selected randomly among images that have never been analyzed, and adds to the existing repository";
     351$lang['g003_invalid_random_number']="The number of images to process is not valid";
     352
     353
     354$lang['g003_database_is_not_up_to_date']="The repository is not up do date !";
     355$lang['g003_databaseWarning2_1']="[p]A new metadata is available since the last update of the plugin:[/p][ul]%s[/ul]
     356[p]
     357To be exploited, it is necessary to update the repository.[/p]";
     358$lang['g003_databaseWarning2_n']="[p]Some new metadatas are available since the last update of the plugin:[/p][ul]%s[/ul]
     359[p]
     360To be exploited, it is necessary to update the repository.[/p]";
     361
     362// help for metadata translation is given at the beginning of this file
    328363
    329364?>
  • extensions/AMetaData/language/fr_FR/plugin.lang.php

    r7448 r7519  
    11<?php
     2
     3/*
     4 * How to translate metadata names and values ?
     5 *
     6 * Metadata names and values are not translated with a /language/*.lang.php file
     7 * but they are stored in a .po and .mo files, respectively localized into
     8 *  - /JpegMetaData/Locale/xx_XX/Tag.po
     9 *  - /JpegMetaData/Locale/xx_XX/LC_MESSAGES/Tag.mo
     10 *
     11 * More information about GNU gettext l10n system and method to edit the .po & .mo
     12 * files on wikipedia :
     13 *  - http://en.wikipedia.org/wiki/GNU_gettext
     14 *
     15 */
    216
    317$lang['Grum Plugin Classes is not installed'] = 'Le plugin <b>Grum Plugin Classes</b> n\'est pas installé';
     
    341355$lang['g003_invalid_random_number']="Le nombre de photos à traiter est invalide";
    342356
     357$lang['g003_database_is_not_up_to_date']="Le référentiel n'est pas à jour !";
     358$lang['g003_databaseWarning2_1']="[p]Une nouvelle métadonnée est accessible suite à la dernière mise à jour du plugin :[/p][ul]%s[/ul]
     359[p]
     360Pour qu'elle puisse être exploitée, il est nécessaire de procéder à la mise à jour du référentiel.[/p]";
     361$lang['g003_databaseWarning2_n']="[p]De nouvelles métadonnées sont accessibles suite à la dernière mise à jour du plugin :[/p][ul]%s[/ul]
     362[p]
     363Pour qu'elles puissent être exploitées, il est nécessaire de procéder à la mise à jour du référentiel.[/p]";
     364
     365// help for metadata translation is given at the beginning of this file
    343366
    344367
  • extensions/AMetaData/main.inc.php

    r7447 r7519  
    22/*
    33Plugin Name: Advanced MetaData
    4 Version: 0.5.2
     4Version: 0.5.3
    55Description: An advanced metadata manager
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=364
     
    126126|         |            |   new package
    127127|         |            |
    128 | 0.x.y   | 2010/09/30 | * mantis bug:1894
     128| 0.5.3   | 2010/09/30 | * mantis bug:1894
    129129|         |            |   . Error when filling the metadata repository
    130130|         |            |
     
    163163|         |            | * mantis bug:1294
    164164|         |            |   . filling database method
     165|         |            |
     166|         |            | * mantis bug:1975
     167|         |            |   . Implement COM segment as a tag
     168|         |            |
     169|         |            | * mantis bug:1976
     170|         |            |   . Implement keywords as magic tag
     171|         |            |
     172|         |            | * mantis bug:1978
     173|         |            |   . Some meta names are not translated in french
     174|         |            |
    165175|         |            |
    166176|         |            |
Note: See TracChangeset for help on using the changeset viewer.