Changeset 5080


Ignore:
Timestamp:
Mar 7, 2010, 10:24:29 PM (14 years ago)
Author:
grum
Message:

Add caddie as source to build database

Location:
extensions/AMetaData
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/amd_aip.class.inc.php

    r5040 r5080  
    5353                          l10n('g003_metadata'),
    5454                          $this->page_link.'&fAMD_tabsheet=metadata');
    55     $this->tabsheet->add('database',
    56                           l10n('g003_database'),
    57                           $this->page_link.'&fAMD_tabsheet=database');
     55    $this->tabsheet->add('help',
     56                          l10n('g003_help'),
     57                          $this->page_link.'&fAMD_tabsheet=help');
    5858    $this->ajax = new Ajax();
    5959    $this->jpegMD=new JpegMetaData();
     
    9999    $template->assign('plugin', $template_plugin);
    100100
    101     if($_REQUEST['fAMD_tabsheet']=='database')
    102     {
    103       $this->displayDatabase();
     101    if($_REQUEST['fAMD_tabsheet']=='help')
     102    {
     103      //$this->displayHelp();
    104104    }
    105105    elseif($_REQUEST['fAMD_tabsheet']=='metadata')
     
    213213    else
    214214    {
    215       $defautTabsheet="metadata";
     215      $defautTabsheet="select";
    216216    }
    217217
     
    222222
    223223    if($_REQUEST['fAMD_tabsheet']!="metadata" and
    224        $_REQUEST['fAMD_tabsheet']!="database")
    225     {
    226       $_REQUEST['fAMD_tabsheet']=$defautTabsheet;
     224       $_REQUEST['fAMD_tabsheet']!="help")
     225    {
     226      $_REQUEST['fAMD_tabsheet']="metadata";
    227227    }
    228228
    229229    if($_REQUEST['fAMD_tabsheet']=="metadata" and !isset($_REQUEST['fAMD_page']))
    230230    {
    231       $_REQUEST['fAMD_page']="select";
     231      $_REQUEST['fAMD_page']=$defautTabsheet;
    232232    }
    233233
    234234    if($_REQUEST['fAMD_tabsheet']=="metadata" and
    235235       !($_REQUEST['fAMD_page']=="select" or
     236         $_REQUEST['fAMD_page']=="database" or
    236237         $_REQUEST['fAMD_page']=="display"))
    237238    {
    238       $_REQUEST['fAMD_page']="select";
     239      $_REQUEST['fAMD_page']=$defautTabsheet;
    239240    }
    240241
     
    249250      if($_REQUEST['ajaxfct']=="makeStatsGetList" and !isset($_REQUEST['selectMode']))
    250251      {
    251         $_REQUEST['selectMode']="notAnalyzed";
     252        $_REQUEST['selectMode']="caddieAdd";
    252253      }
    253254
    254255      if($_REQUEST['ajaxfct']=="makeStatsGetList" and
    255256         !($_REQUEST['selectMode']=="notAnalyzed" or
     257           $_REQUEST['selectMode']=="caddieAdd" or
     258           $_REQUEST['selectMode']=="caddieReplace" or
    256259           $_REQUEST['selectMode']=="all"))
    257260      {
    258         $_REQUEST['selectMode']="notAnalyzed";
     261        $_REQUEST['selectMode']="caddieAdd";
    259262      }
    260263
     
    477480
    478481  /**
    479    * display and manage the database page
    480    *
    481    * the function automatically update the AMD tables :
    482    *  - add new pictures in the AMD image table (assuming image is not analyzed
    483    *    yet)
    484    *  - remove deleted pictures in the AMD image & image_tags table
    485    *
    486    * @return String : the content of the page
    487    */
    488   private function displayDatabase()
    489   {
    490     global $template, $page;
    491 
    492     /*
    493      * insert new image (from piwigo images table) in the AMD images table, with
    494      * statut 'not analyzed'
    495      */
    496     $sql="INSERT INTO ".$this->tables['images']."
    497             SELECT id, 'n', 0
    498               FROM ".IMAGES_TABLE."
    499               WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
    500     pwg_query($sql);
    501 
    502 
    503     /*
    504      * delete image who are in the AMD images table and not in the piwigo image
    505      * table
    506      */
    507     $sql="DELETE FROM ".$this->tables['images']."
    508             WHERE imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.")";
    509     pwg_query($sql);
    510 
    511 
    512     /*
    513      * delete metdata for images that are not in the AMD image table
    514      */
    515     $sql="DELETE FROM ".$this->tables['images_tags']."
    516             WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
    517     pwg_query($sql);
    518 
    519 
    520     $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_database.tpl');
    521 
    522     $datas=array(
    523       'urlRequest' => $this->page_link,
    524       'NumberOfItemsPerRequest' => $this->my_config['amd_NumberOfItemsPerRequest'],
    525     );
    526 
    527     $template->assign("datas", $datas);
    528 
    529     $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');
    530   } // displayDatabase
    531 
    532 
    533 
    534   /**
    535482   * display and manage the metadata page
    536483   * the page have two tabsheet :
     
    547494    $statTabsheet = new tabsheet('statTabsheet', $this->tabsheet->get_titlename());
    548495    $statTabsheet->select($tab);
     496    $statTabsheet->add('database',
     497                          l10n('g003_database'),
     498                          $this->page_link.'&fAMD_tabsheet=metadata&fAMD_page=database');
    549499    $statTabsheet->add('select',
    550500                          l10n('g003_select'),
     
    561511      $template->assign('sheetContent', $this->displayMetaDataSelect());
    562512    }
     513    elseif($tab=="display")
     514    {
     515      $template->assign('sheetContent', $this->displayMetaDataDisplay());
     516    }
    563517    else
    564518    {
    565       $template->assign('sheetContent', $this->displayMetaDataDisplay());
     519      $template->assign('sheetContent', $this->displayDatabase());
    566520    }
    567521
     
    670624
    671625
     626  /**
     627   * display and manage the database page
     628   *
     629   * the function automatically update the AMD tables :
     630   *  - add new pictures in the AMD image table (assuming image is not analyzed
     631   *    yet)
     632   *  - remove deleted pictures in the AMD image & image_tags table
     633   *
     634   * @return String : the content of the page
     635   */
     636  private function displayDatabase()
     637  {
     638    global $template, $page;
     639
     640    /*
     641     * insert new image (from piwigo images table) in the AMD images table, with
     642     * statut 'not analyzed'
     643     */
     644    $sql="INSERT INTO ".$this->tables['images']."
     645            SELECT id, 'n', 0
     646              FROM ".IMAGES_TABLE."
     647              WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
     648    pwg_query($sql);
     649
     650
     651    /*
     652     * delete image who are in the AMD images table and not in the piwigo image
     653     * table
     654     */
     655    $sql="DELETE FROM ".$this->tables['images']."
     656            WHERE imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.")";
     657    pwg_query($sql);
     658
     659
     660    /*
     661     * delete metdata for images that are not in the AMD image table
     662     */
     663    $sql="DELETE FROM ".$this->tables['images_tags']."
     664            WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")";
     665    pwg_query($sql);
     666
     667
     668    $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database.tpl');
     669
     670    $datas=array(
     671      'urlRequest' => $this->page_link,
     672      'NumberOfItemsPerRequest' => $this->my_config['amd_NumberOfItemsPerRequest'],
     673    );
     674
     675    $template->assign("datas", $datas);
     676
     677    return($template->parse('sheet_page', true));
     678  } // displayDatabase
     679
     680
     681
    672682
    673683  /**
     
    729739          if($sqlInsert!="") $sqlInsert.=", ";
    730740          $sqlInsert.="($imageId, '$numId', '".addslashes($value)."')";
    731           $massInsert[]=array(
    732             'imageId' => $imageId,
    733             'numId' => $numId,
    734             'value' => addslashes($value)
    735           );
     741          $massInsert[]="('$imageId', '$numId', '".addslashes($value)."') ";
    736742        }
    737743      }
    738744    }
    739745
    740     /*if($sqlInsert!="")
    741     {
    742       $sqlInsert="INSERT INTO ".$this->tables['images_tags']." VALUES ".$sqlInsert;
    743       pwg_query($sqlInsert);
    744     }*/
    745     mass_inserts($this->tables['images_tags'], array('imageId', 'numId', 'value'), $massInsert);
     746    $sql="REPLACE INTO ".$this->tables['images_tags']." (imageId, numId, value)
     747          VALUES ".implode(", ", $massInsert);
     748    //mass_inserts($this->tables['images_tags'], array('imageId', 'numId', 'value'), $massInsert);
    746749
    747750    $sql="UPDATE ".$this->tables['images']."
     
    803806  private function ajax_amd_makeStatsGetList($mode, $nbOfItems)
    804807  {
     808    global $user;
     809
    805810    $returned="";
    806811    $this->my_config['amd_NumberOfItemsPerRequest']=$nbOfItems;
    807812    $this->save_config();
    808813
    809     $sql="SELECT imageId FROM ".$this->tables['images'];
     814    $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait";
    810815    if($mode=="notAnalyzed")
    811816    {
    812       $sql.=" WHERE analyzed='n'";
    813     }
    814     else
     817      $sql.=" WHERE ait.analyzed='n'";
     818    }
     819    elseif($mode=="caddieAdd" or $mode=="caddieReplace")
     820    {
     821
     822      $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id
     823            WHERE ct.user_id = ".$user['id'].";";
     824    }
     825
     826    if($mode=="all" or $mode=="caddieReplace")
    815827    {
    816828      pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0");
  • extensions/AMetaData/language/fr_FR/plugin.lang.php

    r5040 r5080  
    2020$lang['g003_numberOfAnalyzedPictures'] = "%d images ont fait l'objet d'une analyse et représentent %d métadonnées";
    2121$lang['g003_numberOfNotAnalyzedPictures'] = "%d images n'ont pas fait l'objet d'une analyse";
    22 $lang['g003_analyze_not_analyzed_pictures'] = "Analyser les images manquantes";
    23 $lang['g003_analyze_all_pictures'] = "Analyser toutes les images";
     22$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";
     23$lang['g003_analyze_all_pictures'] = "L'analyse porte sur toutes les images de la galerie et vient remplacer le référentiel actuel";
     24$lang['g003_analyze_caddie_add_pictures'] = "L'analyse porte sur les images du panier et vient s'ajouter au référentiel actuel";
     25$lang['g003_analyze_caddie_replace_pictures'] = "L'analyse porte sur les images du panier et vient remplacer le référentiel actuel";
    2426$lang['g003_analyze'] = "Analyser";
    2527$lang['g003_update_metadata'] = "Mettre à jour le référentiel de métadonnées";
     
    7880
    7981$lang['g003_warning_on_analyze_0'] = "Attention !";
    80 $lang['g003_warning_on_analyze_1'] = "En fonction du nombre de photos dans votre galerie, l'alimentation du référentiel est un processus qui peut s'avérer être long (jusqu'à plusieurs minutes de traitement), et gourmand en ressources sur le serveur.";
     82$lang['g003_warning_on_analyze_1'] = "L'alimentation du référentiel est un processus qui peut s'avérer être long (jusqu'à plusieurs minutes de traitement) et gourmand en ressources sur le serveur en fonction du nombre de photos sélectionnées pour l'analyse.";
    8183$lang['g003_warning_on_analyze_2'] = "Certains hébergeurs peuvent sanctionner ce type d'usage.";
    82 $lang['g003_warning_on_analyze_3'] = "L'alimentation du référentiel n'est pas nécessaire pour que le plugin puisse exploiter les métadonnées de vos photos : il n'est nécessaire que pour les analyses statistiques";
     84$lang['g003_warning_on_analyze_3'] = "Il est fortement recommandé de remplir le panier avec une cinquantaine de photos représentatives de la galerie pour procéder au traitement.";
    8385
    8486
Note: See TracChangeset for help on using the changeset viewer.