From 95a78ca0d3412ffa1d54e13c9caab7bc8b6b0e13 Mon Sep 17 00:00:00 2001 From: rvelices Date: Sun, 1 Jan 2012 21:10:43 +0000 Subject: feature 2541 multisize - admin GUI for choosing derivative parameters + persistence git-svn-id: http://piwigo.org/svn/trunk@12820 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/functions.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'admin/include') diff --git a/admin/include/functions.php b/admin/include/functions.php index 85ee0f4f2..0669c8d6d 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -2054,6 +2054,7 @@ function get_active_menu($menu_page) return 4; case 'configuration': + case 'derivatives': case 'extend_for_templates': case 'menubar': case 'themes': @@ -2247,23 +2248,34 @@ SELECT return array_from_query($query, 'user_id'); } -function clear_derivative_cache($type='all') +/** delete all derivative files for one or several types */ +function clear_derivative_cache($types='all') { $pattern='#.*-'; - if ($type == 'all') + if ($types == 'all') + { + $types = ImageStdParams::get_all_types(); + $types[] = IMG_CUSTOM; + } + elseif (!is_array($types)) + { + $types = array($types); + } + + if (count($types)>1) { $type_urls = array(); - foreach(ImageStdParams::get_all_types() as $dtype) + foreach($types as $dtype) { $type_urls[] = derivative_to_url($dtype); } - $type_urls[] = derivative_to_url(IMG_CUSTOM); $pattern .= '(' . implode('|',$type_urls) . ')'; } else { - $pattern .= derivative_to_url($type); + $pattern .= derivative_to_url($types[0]); } + $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) { @@ -2320,7 +2332,7 @@ function clear_derivative_cache_rec($path, $pattern) unlink($path.'/index.htm'); } clearstatcache(); - rmdir($path); + @rmdir($path); } return $rmdir; } -- cgit v1.2.3