Changeset 1204


Ignore:
Timestamp:
Apr 19, 2006, 1:46:53 AM (18 years ago)
Author:
rvelices
Message:

merge r1203 from branch-1_6 into trunk

bug 335: tn_ext, has_high and representative_ext are updated during file
synchronization and not metadata synchronization

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/site_reader_local.php

    r1064 r1204  
    4545{
    4646  global $errors;
    47  
     47
    4848  if (!is_dir($this->site_url))
    4949  {
     
    5555        )
    5656      );
    57    
     57
    5858    return false;
    5959  }
    60  
     60
    6161  return true;
    6262}
     
    7878{
    7979  global $conf;
    80   if (!isset($conf['flip_picture_ext']))
    81   {
    82     $conf['flip_picture_ext'] = array_flip($conf['picture_ext']);
    83   }
    8480  if (!isset($conf['flip_file_ext']))
    8581  {
     
    9894        $filename_wo_ext = get_filename_wo_extension($node);
    9995
    100         // searching the thumbnail
    101         $tn_ext = $this->get_tn_ext($path, $filename_wo_ext);
    102 
    103         if (isset($conf['flip_picture_ext'][$extension]))
     96        if ( isset($conf['flip_file_ext'][$extension]) )
    10497        {
     98          $tn_ext = $this->get_tn_ext($path, $filename_wo_ext);
    10599          $fs[ $path.'/'.$node ] = array(
    106100            'tn_ext' => $tn_ext,
    107             'has_high' => $this->get_has_high($path, $node)
    108101            );
    109102        }
    110         else if (isset($conf['flip_file_ext'][$extension]))
    111         { // file not a picture
    112           $representative_ext = $this->get_representative_ext($path, $filename_wo_ext);
    113 
    114           $fs[ $path.'/'.$node ] = array(
    115             'tn_ext' => $tn_ext,
    116             'representative_ext' => $representative_ext
    117             );
    118         }
    119 
    120103      }
    121104      elseif (is_dir($path.'/'.$node)
     
    141124
    142125// returns the name of the attributes that are supported for
    143 // update/synchronization according to configuration
     126// files update/synchronization
    144127function get_update_attributes()
    145128{
    146   global $conf;
    147  
    148   $update_fields = array(
    149     'has_high', 'representative_ext', 'filesize', 'width', 'height'
    150     );
    151  
     129  return array('tn_ext', 'has_high', 'representative_ext');
     130}
     131
     132function get_element_update_attributes($file)
     133{
     134  global $conf;
     135  $data = array();
     136
     137  $filename = basename($file);
     138  $dirname = dirname($file);
     139  $filename_wo_ext = get_filename_wo_extension($filename);
     140  $extension = get_extension($filename);
     141
     142  $data['tn_ext'] = $this->get_tn_ext($dirname, $filename_wo_ext);
     143  $data['has_high'] = $this->get_has_high($dirname, $filename);
     144
     145  if ( !isset($conf['flip_picture_ext'][$extension]) )
     146  {
     147    $data['representative_ext'] = $this->get_representative_ext(
     148        $dirname, $filename_wo_ext
     149      );
     150  }
     151  return $data;
     152}
     153
     154// returns the name of the attributes that are supported for
     155// metadata update/synchronization according to configuration
     156function get_metadata_attributes()
     157{
     158  global $conf;
     159
     160  $update_fields = array('filesize', 'width', 'height');
     161
    152162  if ($conf['use_exif'])
    153163  {
     
    167177        );
    168178  }
    169  
     179
    170180  return $update_fields;
    171181}
    172182
    173183// returns a hash of attributes (metadata+filesize+width,...) for file
    174 function get_element_update_attributes($file)
     184function get_element_metadata($file)
    175185{
    176186  global $conf;
     
    182192  $data = array();
    183193
    184   $filename = basename($file);
    185  
    186   $data['has_high'] = $this->get_has_high(dirname($file), $filename);
    187  
    188   $data['representative_ext'] = $this->get_representative_ext(
    189     dirname($file),
    190     get_filename_wo_extension($filename)
    191     );
    192 
    193194  $data['filesize'] = floor(filesize($file)/1024);
     195
    194196  if ($image_size = @getimagesize($file))
    195197  {
     
    222224    }
    223225  }
    224  
     226
    225227  return $data;
    226228}
     
    246248{
    247249  global $conf;
    248  
     250
    249251  $base_test =
    250252    $path.'/thumbnail/'.$conf['prefix_thumbnail'].$filename_wo_ext.'.';
    251  
     253
    252254  foreach ($conf['picture_ext'] as $ext)
    253255  {
     
    258260    }
    259261  }
    260  
     262
    261263  return null;
    262264}
     
    268270    return 'true';
    269271  }
    270  
     272
    271273  return null;
    272274}
  • trunk/admin/site_reader_remote.php

    r1107 r1204  
    3636var $site_files;
    3737var $insert_attributes;
    38 var $update_attributes;
     38var $metadata_attributes;
    3939
    4040function RemoteSiteReader($url, $listing_url)
     
    4242  $this->site_url = $url;
    4343  $this->insert_attributes = array(
    44     'tn_ext', 'representative_ext', 'has_high'
     44    'tn_ext',
    4545    );
    4646  $this->update_attributes = array(
    47     'representative_ext', 'has_high', 'filesize', 'width', 'height'
     47    'tn_ext', 'representative_ext', 'has_high',
     48    );
     49  $this->metadata_attributes = array(
     50    'filesize', 'width', 'height'
    4851    );
    4952
     
    8689    }
    8790
    88     $this->update_attributes = array_merge(
    89       $this->update_attributes,
     91    $this->metadata_attributes = array_merge(
     92      $this->metadata_attributes,
    9093      explode(',', getAttribute($info_xml_element, 'metadata'))
    9194      );
     
    155158
    156159// returns the name of the attributes that are supported for
    157 // update/synchronization according to listing.xml
     160// files update/synchronization
    158161function get_update_attributes()
    159162{
     
    161164}
    162165
    163 // returns a hash of attributes (metadata+filesize+width,...) for file
    164166function get_element_update_attributes($file)
    165167{
     
    167169    $file,
    168170    $this->update_attributes
     171    );
     172}
     173
     174// returns the name of the attributes that are supported for
     175// metadata update/synchronization according to listing.xml
     176function get_metadata_attributes()
     177{
     178  return $this->metadata_attributes;
     179}
     180
     181// returns a hash of attributes (metadata+width,...) for file
     182function get_element_metadata($file)
     183{
     184  return $this->get_element_attributes(
     185    $file,
     186    $this->metadata_attributes
    169187    );
    170188}
  • trunk/admin/site_update.php

    r1122 r1204  
    104104if (isset($_POST['submit']))
    105105{
     106  if (!isset($conf['flip_picture_ext']))
     107  {
     108    $conf['flip_picture_ext'] = array_flip($conf['picture_ext']);
     109  }
    106110  if ($site_reader->open())
    107111  {
     
    130134  $counts['del_elements'] = 0;
    131135  $counts['new_elements'] = 0;
     136  $counts['upd_elements'] = 0;
    132137
    133138  $start = get_moment();
     
    442447    // thumbnail is mandatory and for non picture element, thumbnail and
    443448    // representative are optionnal
    444     if (in_array(get_extension($filename), $conf['picture_ext']))
     449    if ( isset( $conf['flip_picture_ext'][get_extension($filename)] ) )
    445450    {
    446451      // if we found a thumnbnail corresponding to our picture...
     
    452457          'date_available' => CURRENT_DATE,
    453458          'tn_ext'         => $fs[$path]['tn_ext'],
    454           'has_high'       => isset($fs[$path]['has_high'])
    455             ? $fs[$path]['has_high']
    456             : null,
    457459          'path'           => $path,
    458460          'storage_category_id' => $db_fulldirs[$dirname],
     
    497499        'date_available' => CURRENT_DATE,
    498500        'path'           => $path,
    499         'has_high'       => isset($fs[$path]['has_high'])
    500           ? $fs[$path]['has_high']
    501           : null,
    502501        'tn_ext'         => isset($fs[$path]['tn_ext'])
    503502          ? $fs[$path]['tn_ext']
    504           : null,
    505         'representative_ext' => isset($fs[$path]['representative_ext'])
    506           ? $fs[$path]['representative_ext']
    507503          : null,
    508504        'storage_category_id' => $db_fulldirs[$dirname],
     
    635631// +-----------------------------------------------------------------------+
    636632if (isset($_POST['submit'])
    637     and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
    638 {
    639   $template->assign_block_vars(
    640     'update_result',
    641     array(
    642       'NB_NEW_CATEGORIES'=>$counts['new_categories'],
    643       'NB_DEL_CATEGORIES'=>$counts['del_categories'],
    644       'NB_NEW_ELEMENTS'=>$counts['new_elements'],
    645       'NB_DEL_ELEMENTS'=>$counts['del_elements'],
    646       'NB_ERRORS'=>count($errors),
    647       ));
    648 
     633    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
     634    and !$general_failure )
     635{
    649636  if (!$simulate)
    650637  {
     
    661648    echo ' -->'."\n";
    662649  }
     650
     651  if ($_POST['sync'] == 'files')
     652  {
     653    $start = get_moment();
     654    $opts['category_id'] = '';
     655    $opts['recursive'] = true;
     656    if (isset($_POST['cat']))
     657    {
     658      $opts['category_id'] = $_POST['cat'];
     659      if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
     660      {
     661        $opts['recursive'] = false;
     662      }
     663    }
     664    $files = get_filelist($opts['category_id'], $site_id,
     665                          $opts['recursive'],
     666                          false);
     667    echo '<!-- get_filelist : ';
     668    echo get_elapsed_time($start, get_moment());
     669    echo ' -->'."\n";
     670    $start = get_moment();
     671
     672    $datas = array();
     673    foreach ( $files as $id=>$file )
     674    {
     675      $data = $site_reader->get_element_update_attributes($file);
     676      if ( !is_array($data) )
     677      {
     678        continue;
     679      }
     680      $extension = get_extension($file);
     681      if ( isset($conf['flip_picture_ext'][$extension]) )
     682      {
     683        if ( !isset($data['tn_ext']) )
     684        {
     685          array_push(
     686            $errors,
     687            array(
     688              'path' => $file,
     689              'type' => 'PWG-UPDATE-2'
     690              )
     691            );
     692          continue;
     693        }
     694      }
     695
     696      $data['id']=$id;
     697      array_push($datas, $data);
     698    } // end foreach file
     699
     700    $counts['upd_elements'] = count($datas);
     701    if (!$simulate and count($datas)>0 )
     702    {
     703      mass_updates(
     704        IMAGES_TABLE,
     705        // fields
     706        array(
     707          'primary' => array('id'),
     708          'update'  => $site_reader->get_update_attributes(),
     709          ),
     710        $datas
     711        );
     712    }
     713    echo '<!-- update files : ';
     714    echo get_elapsed_time($start,get_moment());
     715    echo ' -->'."\n";
     716  }// end if sync files
     717}
     718
     719// +-----------------------------------------------------------------------+
     720// |                          synchronize files                            |
     721// +-----------------------------------------------------------------------+
     722if (isset($_POST['submit'])
     723    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
     724{
     725  $template->assign_block_vars(
     726    'update_result',
     727    array(
     728      'NB_NEW_CATEGORIES'=>$counts['new_categories'],
     729      'NB_DEL_CATEGORIES'=>$counts['del_categories'],
     730      'NB_NEW_ELEMENTS'=>$counts['new_elements'],
     731      'NB_DEL_ELEMENTS'=>$counts['del_elements'],
     732      'NB_UPD_ELEMENTS'=>$counts['upd_elements'],
     733      'NB_ERRORS'=>count($errors),
     734      ));
    663735}
    664736
     
    704776  foreach ( $files as $id=>$file )
    705777  {
    706     $data = $site_reader->get_element_update_attributes($file);
     778    $data = $site_reader->get_element_metadata($file);
    707779    if ( is_array($data) )
    708780    {
     
    719791            $tags_of[$id] = array();
    720792          }
    721        
     793
    722794          foreach (explode(',', $data[$key]) as $tag_name)
    723795          {
     
    748820            array_merge(
    749821              array_diff(
    750                 $site_reader->get_update_attributes(),
     822                $site_reader->get_metadata_attributes(),
    751823                // keywords and tags fields are managed separately
    752824                array('keywords', 'tags')
     
    786858// used_metadata string is displayed to inform admin which metadata will be
    787859// used from files for synchronization
    788 $used_metadata = implode( ', ', $site_reader->get_update_attributes());
     860$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
    789861if ($site_is_remote and !isset($_POST['submit']) )
    790862{
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1177 r1204  
    438438$lang['update_nb_new_categories'] = 'categories added in the database';
    439439$lang['update_nb_new_elements'] = 'elements added in the database';
     440$lang['update_nb_upd_elements'] = 'elements updated in the database';
    440441$lang['update_part_research'] = 'Search for new images in the directories';
    441442$lang['update_research_added'] = 'added';
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1177 r1204  
    441441$lang['update_nb_new_categories'] = 'catégories ajoutées dans la base de données';
    442442$lang['update_nb_new_elements'] = 'éléments ajoutés dans la base de données';
     443$lang['update_nb_upd_elements'] = 'éléments mis à jour dans la base de données';
    443444$lang['update_part_research'] = 'Chercher les nouvelles images dans les répertoires';
    444445$lang['update_research_added'] = 'ajouté';
  • trunk/template/yoga/admin/site_update.tpl

    r1085 r1204  
    1515  <li class="update_summary_del">{update_result.NB_DEL_CATEGORIES} {lang:update_nb_del_categories}</li>
    1616  <li class="update_summary_del">{update_result.NB_DEL_ELEMENTS} {lang:update_nb_del_elements}</li>
     17  <li>{update_result.NB_UPD_ELEMENTS} {lang:update_nb_upd_elements}</li>
    1718  <li class="update_summary_err">{update_result.NB_ERRORS} {lang:update_nb_errors}</li>
    1819</ul>
     
    8384    <ul><li><label><input type="checkbox" name="simulate" value="1" checked="checked" {TAG_INPUT_ENABLED} /> {lang:update_simulate}</label></li></ul>
    8485  </fieldset>
    85  
     86
    8687  <fieldset>
    8788    <legend>{lang:update_cats_subset}</legend>
    8889    <ul>
    89     <li> 
     90    <li>
    9091    <select style="width:500px" name="cat" size="10">
    9192      <!-- BEGIN category_option -->
     
    9495    </select>
    9596    </li>
    96  
     97
    9798    <li><label><input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {lang:search_subcats_included}</label></li>
    9899    </ul>
Note: See TracChangeset for help on using the changeset viewer.