merge-r17295 from branch 2.4 feature 2708: in admin, display allowed custom derivatives and ability to delete them
git-svn-id: http://piwigo.org/svn/trunk@17302 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
56a395e3a4
commit
92049de075
6 changed files with 92 additions and 42 deletions
|
@ -495,6 +495,14 @@ switch ($page['section'])
|
|||
}
|
||||
$template->assign('derivatives', $tpl_vars);
|
||||
$template->assign('resize_quality', ImageStdParams::$quality);
|
||||
|
||||
$tpl_vars = array();
|
||||
$now = time();
|
||||
foreach(ImageStdParams::$custom as $custom=>$time)
|
||||
{
|
||||
$tpl_vars[$custom] = ($now-$time<=24*3600) ? l10n('today') : time_since($time, 'day');
|
||||
}
|
||||
$template->assign('custom_derivatives', $tpl_vars);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -228,6 +228,15 @@ if (count($errors) == 0)
|
|||
}
|
||||
}
|
||||
|
||||
foreach( array_keys(ImageStdParams::$custom) as $custom)
|
||||
{
|
||||
if (isset($_POST['delete_custom_derivative_'.$custom]))
|
||||
{
|
||||
$changed_types[] = $custom;
|
||||
unset(ImageStdParams::$custom[$custom]);
|
||||
}
|
||||
}
|
||||
|
||||
ImageStdParams::set_and_save($enabled_by);
|
||||
if (count($disabled) == 0)
|
||||
{
|
||||
|
|
|
@ -140,8 +140,19 @@ if (count($errors) == 0)
|
|||
$old_use_watermark = $params->use_watermark;
|
||||
ImageStdParams::apply_global($params);
|
||||
|
||||
if ($params->use_watermark != $old_use_watermark
|
||||
or $params->use_watermark and $watermark_changed)
|
||||
$changed = $params->use_watermark != $old_use_watermark;
|
||||
if (!$changed and $params->use_watermark)
|
||||
{
|
||||
$changed = $watermark_changed;
|
||||
}
|
||||
if (!$changed and $params->use_watermark)
|
||||
{
|
||||
// if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark
|
||||
$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());
|
||||
$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());
|
||||
}
|
||||
|
||||
if ($changed)
|
||||
{
|
||||
$params->last_mod_time = time();
|
||||
$changed_types[] = $type;
|
||||
|
|
|
@ -2276,8 +2276,7 @@ SELECT
|
|||
/** delete all derivative files for one or several types */
|
||||
function clear_derivative_cache($types='all')
|
||||
{
|
||||
$pattern='#.*-';
|
||||
if ($types == 'all')
|
||||
if ($types === 'all')
|
||||
{
|
||||
$types = ImageStdParams::get_all_types();
|
||||
$types[] = IMG_CUSTOM;
|
||||
|
@ -2287,21 +2286,35 @@ function clear_derivative_cache($types='all')
|
|||
$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)
|
||||
{
|
||||
$type_urls = array();
|
||||
foreach($types as $dtype)
|
||||
{
|
||||
$type_urls[] = derivative_to_url($dtype);
|
||||
}
|
||||
$pattern .= '(' . implode('|',$type_urls) . ')';
|
||||
$pattern .= '(' . implode('|',$types) . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$pattern .= derivative_to_url($types[0]);
|
||||
$pattern .= $types[0];
|
||||
}
|
||||
$pattern.='\.[a-zA-Z0-9]{3,4}$#';
|
||||
|
||||
$pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#';
|
||||
if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR))
|
||||
{
|
||||
while (($node = readdir($contents)) !== false)
|
||||
|
|
|
@ -454,6 +454,15 @@ jQuery(document).ready(function(){
|
|||
<p style="margin:10px 0 0 0;{if isset($ferrors)} display:block;{/if}" class="sizeDetails">
|
||||
<a href="{$F_ACTION}&action=restore_settings" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');">{'Reset to default values'|@translate}</a>
|
||||
</p>
|
||||
|
||||
{if !empty($custom_derivatives)}
|
||||
<fieldset class="sizeDetails"><legend>{'custom'|@translate}</legend><table style="margin:0">
|
||||
{foreach from=$custom_derivatives item=time key=custom}
|
||||
<tr><td><label><input type="checkbox" name="delete_custom_derivative_{$custom}"> {'Delete'|@translate} {$custom} ({'Last hit'|@translate}: {$time})</label></td></tr>
|
||||
{/foreach}
|
||||
</table></fieldset>
|
||||
{/if}
|
||||
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="imageNumber">{$PHOTO}</div>
|
||||
{include file='picture_nav_buttons.tpl'|@get_extent:'picture_nav_buttons'}
|
||||
<div class="actionButtons">
|
||||
{if count($current.unique_derivatives)>1}
|
||||
{if isset($current.unique_derivatives) && count($current.unique_derivatives)>1}
|
||||
{footer_script require='jquery'}{literal}
|
||||
function changeImgSrc(url,typeSave,typeMap)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue