From 5bc53c4d746391fcfe4fb0ea82ad88b4794e185e Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 1 Aug 2012 19:00:54 +0000 Subject: feature 2708: in admin, display allowed custom derivatives and ability to delete them git-svn-id: http://piwigo.org/svn/branches/2.4@17295 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/configuration_sizes_process.inc.php | 9 ++++++ .../configuration_watermark_process.inc.php | 23 ++++++++++---- admin/include/functions.php | 35 +++++++++++++++------- 3 files changed, 50 insertions(+), 17 deletions(-) (limited to 'admin/include') diff --git a/admin/include/configuration_sizes_process.inc.php b/admin/include/configuration_sizes_process.inc.php index 31153f16b..d748a61e4 100644 --- a/admin/include/configuration_sizes_process.inc.php +++ b/admin/include/configuration_sizes_process.inc.php @@ -228,6 +228,15 @@ if (count($errors) == 0) } } + foreach( array_keys(ImageStdParams::$custom) as $custom) + { + if (isset($_POST['delete_custom_derivative_'.$custom])) + { + $changed_types[] = $custom; + unset(ImageStdParams::$custom[$custom]); + } + } + ImageStdParams::set_and_save($enabled_by); if (count($disabled) == 0) { diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php index 71f8c9f29..6efabac06 100644 --- a/admin/include/configuration_watermark_process.inc.php +++ b/admin/include/configuration_watermark_process.inc.php @@ -48,10 +48,10 @@ if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_n prepare_directory($upload_dir); $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png'; - $file_path = $upload_dir.'/'.$new_name; - + $file_path = $upload_dir.'/'.$new_name; + move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path); - + $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH)); } } @@ -134,14 +134,25 @@ if (count($errors) == 0) // do we have to regenerate the derivatives (and which types)? $changed_types = array(); - + foreach (ImageStdParams::get_defined_type_map() as $type => $params) { $old_use_watermark = $params->use_watermark; ImageStdParams::apply_global($params); - if ($params->use_watermark != $old_use_watermark - or $params->use_watermark and $watermark_changed) + $changed = $params->use_watermark != $old_use_watermark; + if (!$changed and $params->use_watermark) + { + $changed = $watermark_changed; + } + if (!$changed and $params->use_watermark) + { + // if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark + $changed |= $watermark->min_size[0]!=$old_watermark->min_size[0] and ($watermark->min_size[0]<$params->max_width() or $old_watermark->min_size[0]<$params->max_width()); + $changed |= $watermark->min_size[1]!=$old_watermark->min_size[1] and ($watermark->min_size[1]<$params->max_height() or $old_watermark->min_size[1]<$params->max_height()); + } + + if ($changed) { $params->last_mod_time = time(); $changed_types[] = $type; diff --git a/admin/include/functions.php b/admin/include/functions.php index 30e178553..cb735d70f 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1569,7 +1569,7 @@ function move_images_to_categories($images, $categories) { return false; } - + // let's first break links with all albums but their "storage album" $query = ' DELETE '.IMAGE_CATEGORY_TABLE.'.* @@ -1579,7 +1579,7 @@ DELETE '.IMAGE_CATEGORY_TABLE.'.* AND (storage_category_id IS NULL OR storage_category_id != category_id) ;'; pwg_query($query); - + if (is_array($categories) and count($categories) > 0) { associate_images_to_categories($images, $categories); @@ -2276,8 +2276,7 @@ SELECT /** delete all derivative files for one or several types */ function clear_derivative_cache($types='all') { - $pattern='#.*-'; - if ($types == 'all') + if ($types === 'all') { $types = ImageStdParams::get_all_types(); $types[] = IMG_CUSTOM; @@ -2287,21 +2286,35 @@ function clear_derivative_cache($types='all') $types = array($types); } - if (count($types)>1) + for ($i=0; $i1) + { + $pattern .= '(' . implode('|',$types) . ')'; } else { - $pattern .= derivative_to_url($types[0]); + $pattern .= $types[0]; } + $pattern.='\.[a-zA-Z0-9]{3,4}$#'; - $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) { while (($node = readdir($contents)) !== false) -- cgit v1.2.3