// when submitting the form and an error remains if (!isset($page['sizes_loaded_in_tpl'])) { $is_gd = pwg_image::get_library() == 'gd' ? true : false; $template->assign('is_gd', $is_gd); $template->assign('sizes', array('original_resize_maxwidth' => $conf['original_resize_maxwidth'], 'original_resize_maxheight' => $conf['original_resize_maxheight'], 'original_resize_quality' => $conf['original_resize_quality'])); foreach ($sizes_checkboxes as $checkbox) { $template->append('sizes', array($checkbox => $conf[$checkbox]), true); } // derivatives = multiple size $enabled = ImageStdParams::get_defined_type_map(); $disabled = @unserialize(@$conf['disabled_derivatives']); if ($disabled === false) { $disabled = array(); } $tpl_vars = array(); foreach (ImageStdParams::get_all_types() as $type) { $tpl_var = array(); $tpl_var['must_square'] = $type == IMG_SQUARE ? true : false; $tpl_var['must_enable'] = $type == IMG_SQUARE || $type == IMG_THUMB || $type == $conf['derivative_default_size'] ? true : false; if ($params = @$enabled[$type]) { $tpl_var['enabled'] = true; } else { $tpl_var['enabled'] = false; $params = @$disabled[$type]; } if ($params) { list($tpl_var['w'], $tpl_var['h']) = $params->sizing->ideal_size; if (($tpl_var['crop'] = round(100 * $params->sizing->max_crop)) > 0) { list($tpl_var['minw'], $tpl_var['minh']) = $params->sizing->min_size; } else { $tpl_var['minw'] = $tpl_var['minh'] = "";
/** * Delete all derivative files for one or several types * * @param 'all'|int[] $types */ function clear_derivative_cache($types = 'all') { if ($types === 'all') { $types = ImageStdParams::get_all_types(); $types[] = IMG_CUSTOM; } elseif (!is_array($types)) { $types = array($types); } for ($i = 0; $i < count($types); $i++) { $type = $types[$i]; if ($type == IMG_CUSTOM) { $type = derivative_to_url($type) . '[a-zA-Z0-9]+'; } elseif (in_array($type, ImageStdParams::get_all_types())) { $type = derivative_to_url($type); } else { //assume a custom type $type = derivative_to_url(IMG_CUSTOM) . '_' . $type; } $types[$i] = $type; } $pattern = '#.*-'; if (count($types) > 1) { $pattern .= '(' . implode('|', $types) . ')'; } else { $pattern .= $types[0]; } $pattern .= '\\.[a-zA-Z0-9]{3,4}$#'; if ($contents = @opendir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR)) { while (($node = readdir($contents)) !== false) { if ($node != '.' and $node != '..' and is_dir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node)) { clear_derivative_cache_rec(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node, $pattern); } } closedir($contents); } }