feature #379 multiple format, step 1: add formats

* new table piwigo_image_format (each photo can have 0 to many formats)
* only compatible with synchronization for now. Formats must be in sub-directory pwg_format
* formats are visible on edition page only for now
This commit is contained in:
plegall
2015-12-03 16:04:02 +01:00
parent 27389102d1
commit 8e098d502a
10 changed files with 191 additions and 0 deletions
+35
View File
@@ -180,6 +180,25 @@ function delete_element_files($ids)
}
$new_ids = array();
$formats_of = array();
$query = '
SELECT
image_id,
ext
FROM '.IMAGE_FORMAT_TABLE.'
WHERE image_id IN ('.implode(',', $ids).')
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
if (!isset($formats_of[ $row['image_id'] ]))
{
$formats_of[ $row['image_id'] ] = array();
}
$formats_of[ $row['image_id'] ][] = $row['ext'];
}
$query = '
SELECT
@@ -205,6 +224,14 @@ SELECT
$files[] = original_to_representative( $files[0], $row['representative_ext']);
}
if (isset($formats_of[ $row['id'] ]))
{
foreach ($formats_of[ $row['id'] ] as $format_ext)
{
$files[] = original_to_format($files[0], $format_ext);
}
}
$ok = true;
if (!isset($conf['never_delete_originals']))
{
@@ -277,6 +304,13 @@ DELETE FROM '.IMAGE_CATEGORY_TABLE.'
;';
pwg_query($query);
// destruction of the formats
$query = '
DELETE FROM '.IMAGE_FORMAT_TABLE.'
WHERE image_id IN ('. $ids_str .')
;';
pwg_query($query);
// destruction of the links between images and tags
$query = '
DELETE FROM '.IMAGE_TAG_TABLE.'
@@ -540,6 +574,7 @@ function get_fs_directories($path, $recursive = true)
'.', '..', '.svn',
'thumbnail', 'pwg_high',
'pwg_representative',
'pwg_format',
)
);
$exclude_folders = array_flip($exclude_folders);