Changeset 14221


Ignore:
Timestamp:
Apr 19, 2012, 4:43:30 PM (9 years ago)
Author:
plg
Message:

feature 2606: second step on multiple size configuration screen redesign.

Configuration settings are saved on form submission.

The old screen is still available for tests.

Default resize quality set to 95 instead of 85.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r13958 r14221  
    176176    case 'sizes' :
    177177    {
    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');       
    204179      break;
    205180    }
     
    429404  case 'sizes' :
    430405  {
    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)
    441     {
    442       $template->append(
     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']))
     409    {
     410      $template->assign(
    443411        'sizes',
    444412        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          )
    448417        );
    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();
    463418     
    464       $tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false);
    465       $tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false;
     419      foreach ($sizes_checkboxes as $checkbox)
     420      {
     421        $template->append(
     422          'sizes',
     423          array(
     424            $checkbox => $conf[$checkbox]
     425            ),
     426          true
     427          );
     428      }
    466429     
    467       if ($params=@$enabled[$type])
    468       {
    469         $tpl_var['enabled']=true;
    470       }
    471       else
    472       {
    473         $tpl_var['enabled']=false;
    474         $params=@$disabled[$type];
    475       }
    476      
    477       if ($params)
    478       {
    479         list($tpl_var['w'],$tpl_var['h']) = $params->sizing->ideal_size;
    480         if ( ($tpl_var['crop'] = round(100*$params->sizing->max_crop)) > 0)
     430      // derivatives = multiple size
     431      $enabled = ImageStdParams::get_defined_type_map();
     432      $disabled = @unserialize(@$conf['disabled_derivatives']);
     433      if ($disabled === false)
     434      {
     435        $disabled = array();
     436      }
     437
     438      $common_quality = 50;
     439
     440      $tpl_vars = array();
     441      foreach(ImageStdParams::get_all_types() as $type)
     442      {
     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])
    481449        {
    482           list($tpl_var['minw'],$tpl_var['minh']) = $params->sizing->min_size;
     450          $tpl_var['enabled'] = true;
    483451        }
    484452        else
    485453        {
    486           $tpl_var['minw'] = $tpl_var['minh'] = "";
    487         }
    488         $tpl_var['sharpen'] = $params->sharpen;
    489         $tpl_var['quality'] = $params->quality;
    490       }
    491       $tpl_vars[$type]=$tpl_var;
    492     }
    493     $template->assign('derivatives', $tpl_vars);
     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          }
     476        }
     477        $tpl_vars[$type]=$tpl_var;
     478      }
     479      $template->assign('derivatives', $tpl_vars);
     480      $template->assign('resize_quality', $common_quality);
     481    }
    494482
    495483    break;
  • trunk/admin/include/functions_upload.inc.php

    r13843 r14221  
    6969}
    7070
    71 function save_upload_form_config($data, &$errors=array())
     71function save_upload_form_config($data, &$errors=array(), &$form_errors=array())
    7272{
    7373  if (!is_array($data) or empty($data))
     
    131131            )
    132132          );
     133       
     134        $form_errors[$field] = '['.$min.' .. '.$max.']';
    133135      }
    134136    }
  • trunk/admin/themes/default/template/configuration.tpl

    r13883 r14221  
    320320{/literal}{/footer_script}
    321321
    322 {literal}
    323 <style>
     322{html_head}{literal}
     323<style type="text/css">
     324input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
     325.dErrorDesc {background-color:red; color:white; padding:0 5px;border-radius:10px; font-weight:bold;cursor:help;}
    324326.sizeEnable {width:50px;}
    325327.sizeEditForm {margin:0 0 10px 20px;}
     
    330332.sizeEditOpen {margin-left:10px;}
    331333</style>
    332 {/literal}
     334{/literal}{/html_head}
    333335
    334336<fieldset id="sizesConf">
     
    345347    <tr>
    346348      <th>{'Maximum Width'|@translate}</th>
    347       <td><input type="text" name="original_resize_maxwidth" value="{$sizes.original_resize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     349      <td>
     350        <input type="text" name="original_resize_maxwidth" value="{$sizes.original_resize_maxwidth}" size="4" maxlength="4"{if isset($ferrors.original_resize_maxwidth)} class="dError"{/if}> {'pixels'|@translate}
     351        {if isset($ferrors.original_resize_maxwidth)}<span class="dErrorDesc" title="{$ferrors.original_resize_maxwidth}">!</span>{/if}
     352      </td>
    348353    </tr>
    349354    <tr>
    350355      <th>{'Maximum Height'|@translate}</th>
    351       <td><input type="text" name="original_resize_maxheight" value="{$sizes.original_resize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     356      <td>
     357        <input type="text" name="original_resize_maxheight" value="{$sizes.original_resize_maxheight}" size="4" maxlength="4"{if isset($ferrors.original_resize_maxheight)} class="dError"{/if}> {'pixels'|@translate}
     358        {if isset($ferrors.original_resize_maxheight)}<span class="dErrorDesc" title="{$ferrors.original_resize_maxheight}">!</span>{/if}
     359      </td>
    352360    </tr>
    353361    <tr>
    354362      <th>{'Image Quality'|@translate}</th>
    355       <td><input type="text" name="original_resize_quality" value="{$sizes.original_resize_quality}" size="3" maxlength="3"> %</td>
     363      <td>
     364        <input type="text" name="original_resize_quality" value="{$sizes.original_resize_quality}" size="3" maxlength="3"{if isset($ferrors.original_resize_quality)} class="dError"{/if}> %
     365        {if isset($ferrors.original_resize_quality)}<span class="dErrorDesc" title="{$ferrors.original_resize_quality}">!</span>{/if}
     366      </td>
    356367    </tr>
    357368  </table>
     
    359370</fieldset>
    360371
    361 <div class="warnings">Warning: the following fields are for test "user interface" test only. Any change won't be saved.<br>See screen [Administration > Configuration > Multiple Size] to configure sizes.</div>
    362 
    363372<fieldset id="multiSizesConf">
    364373  <legend>{'Multiple Size'|@translate}</legend>
    365374
    366375<div class="showDetails">
    367   <a href="#" id="showDetails"{if $show_details} style="display:none"{/if}>{'show details'|@translate}</a>
     376  <a href="#" id="showDetails"{if $show_details or isset($ferrors)} style="display:none"{/if}>{'show details'|@translate}</a>
    368377</div>
    369378
     
    385394
    386395    <td>
    387       <span class="sizeDetails">{$d.w} x {$d.h} {'pixels'|@translate}{if $d.crop}, {'Crop'|@translate|lower}{/if}</span>
     396      <span class="sizeDetails"{if isset($ferrors)} style="display:inline"{/if}>{$d.w} x {$d.h} {'pixels'|@translate}{if $d.crop}, {'Crop'|@translate|lower}{/if}</span>
    388397    </td>
    389398
    390399    <td>
    391       <span class="sizeDetails">
     400      <span class="sizeDetails"{if isset($ferrors) and !isset($ferrors.$type)} style="display:inline"{/if}>
    392401        <a href="#" id="sizeEditOpen-{$type}" class="sizeEditOpen">{'edit'|@translate}</a>
    393402      </span>
     
    395404  </tr>
    396405
    397   <tr id="sizeEdit-{$type}" class="sizeEdit">
     406  <tr id="sizeEdit-{$type}" class="sizeEdit" {if isset($ferrors.$type)} style="display:block"{/if}>
    398407    <td colspan="3">
    399408      <table class="sizeEditForm">
     
    412421          <td class="sizeEditWidth">{if $d.must_square or $d.crop}{'Width'|@translate}{else}{'Maximum Width'|@translate}{/if}</td>
    413422          <td>
    414             <input type="text" name="d[{$type}][w]" maxlength="4" size="4" value="{$d.w}"{if isset($ferrors.$type.w)}class="dError"{/if}>
     423            <input type="text" name="d[{$type}][w]" maxlength="4" size="4" value="{$d.w}"{if isset($ferrors.$type.w)} class="dError"{/if}>
    415424            {'pixels'|@translate}
    416425            {if isset($ferrors.$type.w)}<span class="dErrorDesc" title="{$ferrors.$type.w}">!</span>{/if}
     
    422431          <td class="sizeEditHeight">{if $d.crop}{'Height'|@translate}{else}{'Maximum Height'|@translate}{/if}</td>
    423432          <td>
    424             <input type="text" name="d[{$type}][h]" maxlength="4" size="4"  value="{$d.h}"{if isset($ferrors.$type.h)}class="dError"{/if}>
     433            <input type="text" name="d[{$type}][h]" maxlength="4" size="4"  value="{$d.h}"{if isset($ferrors.$type.h)} class="dError"{/if}>
    425434            {'pixels'|@translate}
    426435            {if isset($ferrors.$type.h)}<span class="dErrorDesc" title="{$ferrors.$type.h}">!</span>{/if}
     
    434443</table>
    435444
    436 <p style="margin:20px 0 0 0" class="sizeDetails">
     445<p style="margin:20px 0 0 0;{if isset($ferrors)} display:block;{/if}" class="sizeDetails">
    437446  {'Image Quality'|@translate}
    438   <input type="text" name="original_resize_quality" value="{$sizes.original_resize_quality}" size="3" maxlength="3"> %
     447  <input type="text" name="resize_quality" value="{$resize_quality}" size="3" maxlength="3"{if isset($ferrors.resize_quality)} class="dError"{/if}> %
     448  {if isset($ferrors.resize_quality)}<span class="dErrorDesc" title="{$ferrors.resize_quality}">!</span>{/if}
    439449</p>
    440450</fieldset>
  • trunk/include/derivative_params.inc.php

    r13426 r14221  
    241241  public $sizing;
    242242  public $sharpen = 0;
    243   public $quality = 85;
     243  public $quality = 95;
    244244
    245245  function __construct($sizing)
Note: See TracChangeset for help on using the changeset viewer.