100) { $errors['watermark']['xpos'] = '[0..100]'; } $v = intval($pwatermark['ypos']); if ($v < 0 or $v > 100) { $errors['watermark']['ypos'] = '[0..100]'; } $v = intval($pwatermark['opacity']); if ($v <= 0 or $v > 100) { $errors['watermark']['opacity'] = '(0..100]'; } // step 3 - save data if (count($errors) == 0) { $watermark = new WatermarkParams(); $watermark->file = $pwatermark['file']; $watermark->xpos = intval($pwatermark['xpos']); $watermark->ypos = intval($pwatermark['ypos']); $watermark->xrepeat = intval($pwatermark['xrepeat']); $watermark->opacity = intval($pwatermark['opacity']); $watermark->min_size = array(intval($pwatermark['minw']),intval($pwatermark['minh'])); $old_watermark = ImageStdParams::get_watermark(); $watermark_changed = $watermark->file != $old_watermark->file || $watermark->xpos != $old_watermark->xpos || $watermark->ypos != $old_watermark->ypos || $watermark->xrepeat != $old_watermark->xrepeat || $watermark->opacity != $old_watermark->opacity; // do we have to regenerate the derivatives? $old_enabled = ImageStdParams::get_defined_type_map(); // $disabled = @unserialize( @$conf['disabled_derivatives'] ); // if ($disabled===false) // { // $disabled = array(); // } // save the new watermark configuration ImageStdParams::set_watermark($watermark); $new_enabled = ImageStdParams::get_defined_type_map(); $changed_types = array(); foreach(ImageStdParams::get_all_types() as $type) { if (isset($old_enabled[$type])) { $old_params = $old_enabled[$type]; // echo '
old '.$type."\n"; print_r($old_params); echo ''; $new_params = $new_enabled[$type]; ImageStdParams::apply_global($new_params); // echo '
new '.$type."\n"; print_r($old_params); echo ''; $same = true; if ($new_params->use_watermark != $old_params->use_watermark or $new_params->use_watermark and $watermark_changed) { $same = false; } if (!$same) { $new_params->last_mod_time = time(); $changed_types[] = $type; } else { $new_params->last_mod_time = $old_params->last_mod_time; } $new_enabled[$type] = $new_params; } } $enabled_by = array(); // keys ordered by all types foreach(ImageStdParams::get_all_types() as $type) { if (isset($new_enabled[$type])) { $enabled_by[$type] = $new_enabled[$type]; } } ImageStdParams::set_and_save($enabled_by); if (count($changed_types)) { clear_derivative_cache($changed_types); } } else { $template->assign('watermark', $pwatermark); $template->assign('ferrors', $errors); } ?>