Skip to content

Commit

Permalink
merge r1203 from branch-1_6 into trunk
Browse files Browse the repository at this point in the history
bug 335: tn_ext, has_high and representative_ext are updated during file
synchronization and not metadata synchronization

git-svn-id: http://piwigo.org/svn/trunk@1204 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Apr 18, 2006
1 parent 8e4c71c commit 94c3990
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 79 deletions.
90 changes: 46 additions & 44 deletions admin/site_reader_local.php
Expand Up @@ -44,7 +44,7 @@ function LocalSiteReader($url)
function open()
{
global $errors;

if (!is_dir($this->site_url))
{
array_push(
Expand All @@ -54,10 +54,10 @@ function open()
'type' => 'PWG-ERROR-NO-FS'
)
);

return false;
}

return true;
}

Expand All @@ -77,10 +77,6 @@ function get_full_directories($basedir)
function get_elements($path)
{
global $conf;
if (!isset($conf['flip_picture_ext']))
{
$conf['flip_picture_ext'] = array_flip($conf['picture_ext']);
}
if (!isset($conf['flip_file_ext']))
{
$conf['flip_file_ext'] = array_flip($conf['file_ext']);
Expand All @@ -97,26 +93,13 @@ function get_elements($path)
$extension = get_extension($node);
$filename_wo_ext = get_filename_wo_extension($node);

// searching the thumbnail
$tn_ext = $this->get_tn_ext($path, $filename_wo_ext);

if (isset($conf['flip_picture_ext'][$extension]))
if ( isset($conf['flip_file_ext'][$extension]) )
{
$tn_ext = $this->get_tn_ext($path, $filename_wo_ext);
$fs[ $path.'/'.$node ] = array(
'tn_ext' => $tn_ext,
'has_high' => $this->get_has_high($path, $node)
);
}
else if (isset($conf['flip_file_ext'][$extension]))
{ // file not a picture
$representative_ext = $this->get_representative_ext($path, $filename_wo_ext);

$fs[ $path.'/'.$node ] = array(
'tn_ext' => $tn_ext,
'representative_ext' => $representative_ext
);
}

}
elseif (is_dir($path.'/'.$node)
and $node != '.'
Expand All @@ -140,15 +123,42 @@ function get_elements($path)
}

// returns the name of the attributes that are supported for
// update/synchronization according to configuration
// files update/synchronization
function get_update_attributes()
{
return array('tn_ext', 'has_high', 'representative_ext');
}

function get_element_update_attributes($file)
{
global $conf;
$data = array();

$filename = basename($file);
$dirname = dirname($file);
$filename_wo_ext = get_filename_wo_extension($filename);
$extension = get_extension($filename);

$data['tn_ext'] = $this->get_tn_ext($dirname, $filename_wo_ext);
$data['has_high'] = $this->get_has_high($dirname, $filename);

if ( !isset($conf['flip_picture_ext'][$extension]) )
{
$data['representative_ext'] = $this->get_representative_ext(
$dirname, $filename_wo_ext
);
}
return $data;
}

// returns the name of the attributes that are supported for
// metadata update/synchronization according to configuration
function get_metadata_attributes()
{
global $conf;

$update_fields = array(
'has_high', 'representative_ext', 'filesize', 'width', 'height'
);


$update_fields = array('filesize', 'width', 'height');

if ($conf['use_exif'])
{
$update_fields =
Expand All @@ -166,12 +176,12 @@ function get_update_attributes()
array_keys($conf['use_iptc_mapping'])
);
}

return $update_fields;
}

// returns a hash of attributes (metadata+filesize+width,...) for file
function get_element_update_attributes($file)
function get_element_metadata($file)
{
global $conf;
if (!is_file($file))
Expand All @@ -181,16 +191,8 @@ function get_element_update_attributes($file)

$data = array();

$filename = basename($file);

$data['has_high'] = $this->get_has_high(dirname($file), $filename);

$data['representative_ext'] = $this->get_representative_ext(
dirname($file),
get_filename_wo_extension($filename)
);

$data['filesize'] = floor(filesize($file)/1024);

if ($image_size = @getimagesize($file))
{
$data['width'] = $image_size[0];
Expand Down Expand Up @@ -221,7 +223,7 @@ function get_element_update_attributes($file)
}
}
}

return $data;
}

Expand All @@ -245,10 +247,10 @@ function get_representative_ext($path, $filename_wo_ext)
function get_tn_ext($path, $filename_wo_ext)
{
global $conf;

$base_test =
$path.'/thumbnail/'.$conf['prefix_thumbnail'].$filename_wo_ext.'.';

foreach ($conf['picture_ext'] as $ext)
{
$test = $base_test.$ext;
Expand All @@ -257,7 +259,7 @@ function get_tn_ext($path, $filename_wo_ext)
return $ext;
}
}

return null;
}

Expand All @@ -267,7 +269,7 @@ function get_has_high($path, $filename)
{
return 'true';
}

return null;
}

Expand Down
32 changes: 25 additions & 7 deletions admin/site_reader_remote.php
Expand Up @@ -35,16 +35,19 @@ class RemoteSiteReader
var $site_dirs;
var $site_files;
var $insert_attributes;
var $update_attributes;
var $metadata_attributes;

function RemoteSiteReader($url, $listing_url)
{
$this->site_url = $url;
$this->insert_attributes = array(
'tn_ext', 'representative_ext', 'has_high'
'tn_ext',
);
$this->update_attributes = array(
'representative_ext', 'has_high', 'filesize', 'width', 'height'
'tn_ext', 'representative_ext', 'has_high',
);
$this->metadata_attributes = array(
'filesize', 'width', 'height'
);

if (!isset($listing_url))
Expand Down Expand Up @@ -85,8 +88,8 @@ function open()
return false;
}

$this->update_attributes = array_merge(
$this->update_attributes,
$this->metadata_attributes = array_merge(
$this->metadata_attributes,
explode(',', getAttribute($info_xml_element, 'metadata'))
);

Expand Down Expand Up @@ -154,13 +157,12 @@ function get_elements($path)
}

// returns the name of the attributes that are supported for
// update/synchronization according to listing.xml
// files update/synchronization
function get_update_attributes()
{
return $this->update_attributes;
}

// returns a hash of attributes (metadata+filesize+width,...) for file
function get_element_update_attributes($file)
{
return $this->get_element_attributes(
Expand All @@ -169,6 +171,22 @@ function get_element_update_attributes($file)
);
}

// returns the name of the attributes that are supported for
// metadata update/synchronization according to listing.xml
function get_metadata_attributes()
{
return $this->metadata_attributes;
}

// returns a hash of attributes (metadata+width,...) for file
function get_element_metadata($file)
{
return $this->get_element_attributes(
$file,
$this->metadata_attributes
);
}

//-------------------------------------------------- private functions --------
/**
* Returns a hash of image/file attributes
Expand Down

0 comments on commit 94c3990

Please sign in to comment.