Changeset 17302


Ignore:
Timestamp:
08/01/12 21:03:17 (7 years ago)
Author:
rvelices
Message:

merge-r17295 from branch 2.4 feature 2708: in admin, display allowed custom derivatives and ability to delete them

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r16928 r17302  
    107107    'privacy_level', 
    108108  ); 
    109    
     109 
    110110// image order management 
    111111$sort_fields = array( 
     
    127127  'rank ASC'            => l10n('Manual sort order'), 
    128128  ); 
    129    
     129 
    130130$comments_order = array( 
    131131  'ASC' => l10n('Show oldest comments first'), 
     
    142142  { 
    143143    case 'main' : 
    144     {       
     144    { 
    145145      if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) ) 
    146146      { 
     
    159159            // limit to the number of available parameters 
    160160            $order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2)); 
    161              
     161 
    162162            // there is no rank outside categories 
    163163            if ( ($i = array_search('rank ASC', $order_by)) !== false) 
     
    165165              unset($order_by[$i]); 
    166166            } 
    167              
     167 
    168168            // must define a default order_by if user want to order by rank only 
    169169            if ( count($order_by) == 0 ) 
     
    171171              $order_by = array('id ASC'); 
    172172            } 
    173              
     173 
    174174            $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by); 
    175175            $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category); 
     
    181181        } 
    182182      } 
    183        
     183 
    184184      foreach( $main_checkboxes as $checkbox) 
    185185      { 
     
    190190    case 'watermark' : 
    191191    { 
    192       include(PHPWG_ROOT_PATH.'admin/include/configuration_watermark_process.inc.php');         
     192      include(PHPWG_ROOT_PATH.'admin/include/configuration_watermark_process.inc.php'); 
    193193      break; 
    194194    } 
    195195    case 'sizes' : 
    196196    { 
    197       include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php');         
     197      include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php'); 
    198198      break; 
    199199    } 
     
    303303{ 
    304304  case 'main' : 
    305   {    
    306      
     305  { 
     306 
    307307    function order_by_is_local() 
    308308    { 
     
    312312        @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php'); 
    313313      } 
    314        
     314 
    315315      return isset($conf['order_by']) or isset($conf['order_by_inside_category']); 
    316316    } 
    317      
     317 
    318318    if (order_by_is_local()) 
    319319    { 
    320320      array_push($page['warnings'], l10n('You have specified <i>$conf[\'order_by\']</i> in your local configuration file, this parameter in deprecated, please remove it or rename it into <i>$conf[\'order_by_custom\']</i> !')); 
    321321    } 
    322      
     322 
    323323    if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) ) 
    324324    { 
     
    333333      $order_by = explode(', ', $order_by); 
    334334    } 
    335    
     335 
    336336    $template->assign( 
    337337      'main', 
     
    441441          ) 
    442442        ); 
    443        
     443 
    444444      foreach ($sizes_checkboxes as $checkbox) 
    445445      { 
     
    452452          ); 
    453453      } 
    454        
     454 
    455455      // derivatives = multiple size 
    456456      $enabled = ImageStdParams::get_defined_type_map(); 
     
    465465      { 
    466466        $tpl_var = array(); 
    467          
     467 
    468468        $tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false); 
    469469        $tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false; 
    470          
     470 
    471471        if ($params = @$enabled[$type]) 
    472472        { 
     
    478478          $params=@$disabled[$type]; 
    479479        } 
    480          
     480 
    481481        if ($params) 
    482482        { 
     
    496496      $template->assign('derivatives', $tpl_vars); 
    497497      $template->assign('resize_quality', ImageStdParams::$quality); 
     498 
     499      $tpl_vars = array(); 
     500      $now = time(); 
     501      foreach(ImageStdParams::$custom as $custom=>$time) 
     502      { 
     503        $tpl_vars[$custom] = ($now-$time<=24*3600) ? l10n('today') : time_since($time, 'day'); 
     504      } 
     505      $template->assign('custom_derivatives', $tpl_vars); 
    498506    } 
    499507 
     
    547555        $position = 'bottomright'; 
    548556      } 
    549        
     557 
    550558      if ($wm->xrepeat != 0) 
    551559      { 
    552560        $position = 'custom'; 
    553561      } 
    554      
     562 
    555563      $template->assign( 
    556564        'watermark', 
     
    567575        ); 
    568576    } 
    569      
     577 
    570578    break; 
    571579  } 
  • trunk/admin/include/configuration_sizes_process.inc.php

    r14649 r17302  
    229229  } 
    230230 
     231  foreach( array_keys(ImageStdParams::$custom) as $custom) 
     232  { 
     233    if (isset($_POST['delete_custom_derivative_'.$custom])) 
     234    { 
     235      $changed_types[] = $custom; 
     236      unset(ImageStdParams::$custom[$custom]); 
     237    } 
     238  } 
     239 
    231240  ImageStdParams::set_and_save($enabled_by); 
    232241  if (count($disabled) == 0) 
  • trunk/admin/include/configuration_watermark_process.inc.php

    r14584 r17302  
    4949 
    5050    $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png'; 
    51     $file_path = $upload_dir.'/'.$new_name;  
    52    
     51    $file_path = $upload_dir.'/'.$new_name; 
     52 
    5353    move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path); 
    54      
     54 
    5555    $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH)); 
    5656  } 
     
    135135  // do we have to regenerate the derivatives (and which types)? 
    136136  $changed_types = array(); 
    137    
     137 
    138138  foreach (ImageStdParams::get_defined_type_map() as $type => $params) 
    139139  { 
     
    141141    ImageStdParams::apply_global($params); 
    142142 
    143     if ($params->use_watermark != $old_use_watermark 
    144         or $params->use_watermark and $watermark_changed) 
     143    $changed = $params->use_watermark != $old_use_watermark; 
     144    if (!$changed and $params->use_watermark) 
     145    { 
     146      $changed = $watermark_changed; 
     147    } 
     148    if (!$changed and $params->use_watermark) 
     149    { 
     150      // if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark 
     151      $changed |= $watermark->min_size[0]!=$old_watermark->min_size[0] and ($watermark->min_size[0]<$params->max_width() or $old_watermark->min_size[0]<$params->max_width()); 
     152      $changed |= $watermark->min_size[1]!=$old_watermark->min_size[1] and ($watermark->min_size[1]<$params->max_height() or $old_watermark->min_size[1]<$params->max_height()); 
     153    } 
     154 
     155    if ($changed) 
    145156    { 
    146157      $params->last_mod_time = time(); 
  • trunk/admin/include/functions.php

    r17210 r17302  
    15701570    return false; 
    15711571  } 
    1572    
     1572 
    15731573  // let's first break links with all albums but their "storage album" 
    15741574  $query = ' 
     
    15801580;'; 
    15811581  pwg_query($query); 
    1582      
     1582 
    15831583  if (is_array($categories) and count($categories) > 0) 
    15841584  { 
     
    22772277function clear_derivative_cache($types='all') 
    22782278{ 
    2279   $pattern='#.*-'; 
    2280   if ($types == 'all') 
     2279  if ($types === 'all') 
    22812280  { 
    22822281    $types = ImageStdParams::get_all_types(); 
     
    22882287  } 
    22892288 
     2289  for ($i=0; $i<count($types); $i++) 
     2290  { 
     2291    $type = $types[$i]; 
     2292    if ($type == IMG_CUSTOM) 
     2293    { 
     2294      $type = derivative_to_url($type).'[a-zA-Z0-9]+'; 
     2295    } 
     2296    elseif (in_array($type, ImageStdParams::get_all_types())) 
     2297    { 
     2298      $type = derivative_to_url($type); 
     2299    } 
     2300    else 
     2301    {//assume a custom type 
     2302      $type = derivative_to_url(IMG_CUSTOM).'_'.$type; 
     2303    } 
     2304    $types[$i] = $type; 
     2305  } 
     2306 
     2307  $pattern='#.*-'; 
    22902308  if (count($types)>1) 
    22912309  { 
    2292     $type_urls = array(); 
    2293     foreach($types as $dtype) 
    2294     { 
    2295       $type_urls[] = derivative_to_url($dtype); 
    2296     } 
    2297     $pattern .= '(' . implode('|',$type_urls) . ')'; 
     2310    $pattern .= '(' . implode('|',$types) . ')'; 
    22982311  } 
    22992312  else 
    23002313  { 
    2301     $pattern .= derivative_to_url($types[0]); 
    2302   } 
    2303  
    2304   $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; 
     2314    $pattern .= $types[0]; 
     2315  } 
     2316  $pattern.='\.[a-zA-Z0-9]{3,4}$#'; 
     2317 
    23052318  if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) 
    23062319  { 
  • trunk/admin/themes/default/template/configuration.tpl

    r15551 r17302  
    455455  <a href="{$F_ACTION}&action=restore_settings" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');">{'Reset to default values'|@translate}</a> 
    456456</p> 
     457 
     458{if !empty($custom_derivatives)} 
     459<fieldset class="sizeDetails"><legend>{'custom'|@translate}</legend><table style="margin:0"> 
     460{foreach from=$custom_derivatives item=time key=custom} 
     461<tr><td><label><input type="checkbox" name="delete_custom_derivative_{$custom}"> {'Delete'|@translate} {$custom} ({'Last hit'|@translate}: {$time})</label></td></tr> 
     462{/foreach} 
     463</table></fieldset> 
     464{/if} 
     465 
    457466</fieldset> 
    458467{/if} 
  • trunk/themes/default/template/picture.tpl

    r15570 r17302  
    1919{include file='picture_nav_buttons.tpl'|@get_extent:'picture_nav_buttons'} 
    2020<div class="actionButtons"> 
    21 {if count($current.unique_derivatives)>1} 
     21{if isset($current.unique_derivatives) && count($current.unique_derivatives)>1} 
    2222{footer_script require='jquery'}{literal} 
    2323function changeImgSrc(url,typeSave,typeMap) 
Note: See TracChangeset for help on using the changeset viewer.