|
175 | 175 | } |
176 | 176 | case 'sizes' : |
177 | 177 | { |
178 | | - $fields = array( |
179 | | - 'original_resize', |
180 | | - 'original_resize_maxwidth', |
181 | | - 'original_resize_maxheight', |
182 | | - 'original_resize_quality', |
183 | | - ); |
184 | | - |
185 | | - $updates = array(); |
186 | | - |
187 | | - foreach ($fields as $field) |
188 | | - { |
189 | | - $value = !empty($_POST[$field]) ? $_POST[$field] : null; |
190 | | - $form_values[$field] = $value; |
191 | | - $updates[$field] = $value; |
192 | | - } |
193 | | - |
194 | | - save_upload_form_config($updates, $page['errors']); |
195 | | - |
196 | | - if (count($page['errors']) == 0) |
197 | | - { |
198 | | - array_push( |
199 | | - $page['infos'], |
200 | | - l10n('Your configuration settings are saved') |
201 | | - ); |
202 | | - } |
203 | | - |
| 178 | + include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php'); |
204 | 179 | break; |
205 | 180 | } |
206 | 181 | case 'comments' : |
@@ -428,69 +403,82 @@ function order_by_is_local() |
428 | 403 | } |
429 | 404 | case 'sizes' : |
430 | 405 | { |
431 | | - $template->assign( |
432 | | - 'sizes', |
433 | | - array( |
434 | | - 'original_resize_maxwidth' => $conf['original_resize_maxwidth'], |
435 | | - 'original_resize_maxheight' => $conf['original_resize_maxheight'], |
436 | | - 'original_resize_quality' => $conf['original_resize_quality'], |
437 | | - ) |
438 | | - ); |
439 | | - |
440 | | - foreach ($sizes_checkboxes as $checkbox) |
| 406 | + // we only load the derivatives if it was not already loaded: it occurs |
| 407 | + // when submitting the form and an error remains |
| 408 | + if (!isset($page['sizes_loaded_in_tpl'])) |
441 | 409 | { |
442 | | - $template->append( |
| 410 | + $template->assign( |
443 | 411 | 'sizes', |
444 | 412 | array( |
445 | | - $checkbox => $conf[$checkbox] |
446 | | - ), |
447 | | - true |
| 413 | + 'original_resize_maxwidth' => $conf['original_resize_maxwidth'], |
| 414 | + 'original_resize_maxheight' => $conf['original_resize_maxheight'], |
| 415 | + 'original_resize_quality' => $conf['original_resize_quality'], |
| 416 | + ) |
448 | 417 | ); |
449 | | - } |
450 | | - |
451 | | - // derivaties = multiple size |
452 | | - $enabled = ImageStdParams::get_defined_type_map(); |
453 | | - $disabled = @unserialize(@$conf['disabled_derivatives']); |
454 | | - if ($disabled === false) |
455 | | - { |
456 | | - $disabled = array(); |
457 | | - } |
458 | | - |
459 | | - $tpl_vars = array(); |
460 | | - foreach(ImageStdParams::get_all_types() as $type) |
461 | | - { |
462 | | - $tpl_var = array(); |
463 | 418 |
|
464 | | - $tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false); |
465 | | - $tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false; |
466 | | - |
467 | | - if ($params=@$enabled[$type]) |
| 419 | + foreach ($sizes_checkboxes as $checkbox) |
468 | 420 | { |
469 | | - $tpl_var['enabled']=true; |
| 421 | + $template->append( |
| 422 | + 'sizes', |
| 423 | + array( |
| 424 | + $checkbox => $conf[$checkbox] |
| 425 | + ), |
| 426 | + true |
| 427 | + ); |
470 | 428 | } |
471 | | - else |
| 429 | + |
| 430 | + // derivatives = multiple size |
| 431 | + $enabled = ImageStdParams::get_defined_type_map(); |
| 432 | + $disabled = @unserialize(@$conf['disabled_derivatives']); |
| 433 | + if ($disabled === false) |
472 | 434 | { |
473 | | - $tpl_var['enabled']=false; |
474 | | - $params=@$disabled[$type]; |
| 435 | + $disabled = array(); |
475 | 436 | } |
476 | | - |
477 | | - if ($params) |
| 437 | + |
| 438 | + $common_quality = 50; |
| 439 | + |
| 440 | + $tpl_vars = array(); |
| 441 | + foreach(ImageStdParams::get_all_types() as $type) |
478 | 442 | { |
479 | | - list($tpl_var['w'],$tpl_var['h']) = $params->sizing->ideal_size; |
480 | | - if ( ($tpl_var['crop'] = round(100*$params->sizing->max_crop)) > 0) |
| 443 | + $tpl_var = array(); |
| 444 | + |
| 445 | + $tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false); |
| 446 | + $tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false; |
| 447 | + |
| 448 | + if ($params = @$enabled[$type]) |
481 | 449 | { |
482 | | - list($tpl_var['minw'],$tpl_var['minh']) = $params->sizing->min_size; |
| 450 | + $tpl_var['enabled'] = true; |
483 | 451 | } |
484 | 452 | else |
485 | 453 | { |
486 | | - $tpl_var['minw'] = $tpl_var['minh'] = ""; |
| 454 | + $tpl_var['enabled']=false; |
| 455 | + $params=@$disabled[$type]; |
| 456 | + } |
| 457 | + |
| 458 | + if ($params) |
| 459 | + { |
| 460 | + list($tpl_var['w'],$tpl_var['h']) = $params->sizing->ideal_size; |
| 461 | + if ( ($tpl_var['crop'] = round(100*$params->sizing->max_crop)) > 0) |
| 462 | + { |
| 463 | + list($tpl_var['minw'],$tpl_var['minh']) = $params->sizing->min_size; |
| 464 | + } |
| 465 | + else |
| 466 | + { |
| 467 | + $tpl_var['minw'] = $tpl_var['minh'] = ""; |
| 468 | + } |
| 469 | + $tpl_var['sharpen'] = $params->sharpen; |
| 470 | + $tpl_var['quality'] = $params->quality; |
| 471 | + |
| 472 | + if ($params->quality > $common_quality and $tpl_var['enabled']) |
| 473 | + { |
| 474 | + $common_quality = $params->quality; |
| 475 | + } |
487 | 476 | } |
488 | | - $tpl_var['sharpen'] = $params->sharpen; |
489 | | - $tpl_var['quality'] = $params->quality; |
| 477 | + $tpl_vars[$type]=$tpl_var; |
490 | 478 | } |
491 | | - $tpl_vars[$type]=$tpl_var; |
| 479 | + $template->assign('derivatives', $tpl_vars); |
| 480 | + $template->assign('resize_quality', $common_quality); |
492 | 481 | } |
493 | | - $template->assign('derivatives', $tpl_vars); |
494 | 482 |
|
495 | 483 | break; |
496 | 484 | } |
|
0 commit comments