feature 2548 multisize - implement delete_element_derivatives

git-svn-id: http://piwigo.org/svn/trunk@12917 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2012-01-17 21:02:16 +00:00
parent 89933672f2
commit c6265c515d
3 changed files with 61 additions and 61 deletions

View file

@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@ -175,16 +175,12 @@ function delete_element_files($ids)
return 0;
}
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
$new_ids = array();
$query = '
SELECT
id,
path,
tn_ext,
has_high,
representative_ext
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $ids).')
@ -218,6 +214,7 @@ SELECT
if ($ok)
{
delete_element_derivatives($row);
$new_ids[] += $row['id'];
}
else
@ -2308,16 +2305,22 @@ function clear_derivative_cache_rec($path, $pattern)
}
}
function delete_element_derivatives($ids)
function delete_element_derivatives($infos)
{
// todo
if (!is_array($ids))
$path = $infos['path'];
if (!empty($infos['representative_ext']))
{
$ids = array($ids);
$path = original_to_representative( $path, $infos['representative_ext']);
}
if (substr_compare($path, '../', 0, 3)==0)
{
$path = substr($path, 3);
}
$dot = strpos($path, '.');
$path = substr_replace($path, '-*', $dot, 0);
foreach( glob(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$path) as $file)
{
@unlink($file);
}
// for now I do a massive clear, to be removed once the function is
// properly implemented
clear_derivative_cache();
}
?>

View file

@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@ -292,8 +292,6 @@ SELECT
$update,
array('id' => $image_id)
);
delete_element_derivatives($image_id);
}
else
{

View file

@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@ -458,11 +458,10 @@ SELECT date_available,
if ($max_elements>0)
{ // get some thumbnails ...
$query = '
SELECT DISTINCT id, path, name, representative_ext, file
SELECT DISTINCT i.*
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
'.$where_sql.'
AND date_available=\''.$dates[$i]['date_available'].'\'
AND tn_ext IS NOT NULL
ORDER BY '.DB_RANDOM_FUNCTION.'()
LIMIT '.$max_elements.'
;';