aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/configuration.php54
-rw-r--r--admin/include/configuration_sizes_process.inc.php9
-rw-r--r--admin/include/configuration_watermark_process.inc.php23
-rw-r--r--admin/include/functions.php35
-rw-r--r--admin/themes/default/template/configuration.tpl9
5 files changed, 90 insertions, 40 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index e4e881051..6132c7806 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -106,7 +106,7 @@ $display_info_checkboxes = array(
'rating_score',
'privacy_level',
);
-
+
// image order management
$sort_fields = array(
'' => '',
@@ -126,7 +126,7 @@ $sort_fields = array(
'id DESC' => l10n('Numeric identifier, 9 → 1'),
'rank ASC' => l10n('Manual sort order'),
);
-
+
$comments_order = array(
'ASC' => l10n('Show oldest comments first'),
'DESC' => l10n('Show latest comments first'),
@@ -141,7 +141,7 @@ if (isset($_POST['submit']))
switch ($page['section'])
{
case 'main' :
- {
+ {
if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
{
if ( !empty($_POST['order_by']) )
@@ -158,19 +158,19 @@ if (isset($_POST['submit']))
{
// limit to the number of available parameters
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
-
+
// there is no rank outside categories
if ( ($i = array_search('rank ASC', $order_by)) !== false)
{
unset($order_by[$i]);
}
-
+
// must define a default order_by if user want to order by rank only
if ( count($order_by) == 0 )
{
$order_by = array('id ASC');
}
-
+
$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
}
@@ -180,7 +180,7 @@ if (isset($_POST['submit']))
array_push($page['errors'], l10n('No order field selected'));
}
}
-
+
foreach( $main_checkboxes as $checkbox)
{
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
@@ -189,12 +189,12 @@ if (isset($_POST['submit']))
}
case 'watermark' :
{
- include(PHPWG_ROOT_PATH.'admin/include/configuration_watermark_process.inc.php');
+ include(PHPWG_ROOT_PATH.'admin/include/configuration_watermark_process.inc.php');
break;
}
case 'sizes' :
{
- include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php');
+ include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php');
break;
}
case 'comments' :
@@ -302,8 +302,8 @@ $template->assign(
switch ($page['section'])
{
case 'main' :
- {
-
+ {
+
function order_by_is_local()
{
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
@@ -311,15 +311,15 @@ switch ($page['section'])
{
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
}
-
+
return isset($conf['order_by']) or isset($conf['order_by_inside_category']);
}
-
+
if (order_by_is_local())
{
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> !'));
}
-
+
if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
{
$order_by = array('');
@@ -332,7 +332,7 @@ switch ($page['section'])
$order_by = str_replace('ORDER BY ', null, $order_by);
$order_by = explode(', ', $order_by);
}
-
+
$template->assign(
'main',
array(
@@ -440,7 +440,7 @@ switch ($page['section'])
'original_resize_quality' => $conf['original_resize_quality'],
)
);
-
+
foreach ($sizes_checkboxes as $checkbox)
{
$template->append(
@@ -451,7 +451,7 @@ switch ($page['section'])
true
);
}
-
+
// derivatives = multiple size
$enabled = ImageStdParams::get_defined_type_map();
$disabled = @unserialize(@$conf['disabled_derivatives']);
@@ -464,10 +464,10 @@ switch ($page['section'])
foreach(ImageStdParams::get_all_types() as $type)
{
$tpl_var = array();
-
+
$tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false);
$tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false;
-
+
if ($params = @$enabled[$type])
{
$tpl_var['enabled'] = true;
@@ -477,7 +477,7 @@ switch ($page['section'])
$tpl_var['enabled']=false;
$params=@$disabled[$type];
}
-
+
if ($params)
{
list($tpl_var['w'],$tpl_var['h']) = $params->sizing->ideal_size;
@@ -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;
@@ -546,12 +554,12 @@ switch ($page['section'])
{
$position = 'bottomright';
}
-
+
if ($wm->xrepeat != 0)
{
$position = 'custom';
}
-
+
$template->assign(
'watermark',
array(
@@ -566,7 +574,7 @@ switch ($page['section'])
)
);
}
-
+
break;
}
}
diff --git a/admin/include/configuration_sizes_process.inc.php b/admin/include/configuration_sizes_process.inc.php
index 31153f16b..d748a61e4 100644
--- a/admin/include/configuration_sizes_process.inc.php
+++ b/admin/include/configuration_sizes_process.inc.php
@@ -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)
{
diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php
index 71f8c9f29..6efabac06 100644
--- a/admin/include/configuration_watermark_process.inc.php
+++ b/admin/include/configuration_watermark_process.inc.php
@@ -48,10 +48,10 @@ if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_n
prepare_directory($upload_dir);
$new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
- $file_path = $upload_dir.'/'.$new_name;
-
+ $file_path = $upload_dir.'/'.$new_name;
+
move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path);
-
+
$pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
}
}
@@ -134,14 +134,25 @@ if (count($errors) == 0)
// do we have to regenerate the derivatives (and which types)?
$changed_types = array();
-
+
foreach (ImageStdParams::get_defined_type_map() as $type => $params)
{
$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;
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 30e178553..cb735d70f 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1569,7 +1569,7 @@ function move_images_to_categories($images, $categories)
{
return false;
}
-
+
// let's first break links with all albums but their "storage album"
$query = '
DELETE '.IMAGE_CATEGORY_TABLE.'.*
@@ -1579,7 +1579,7 @@ DELETE '.IMAGE_CATEGORY_TABLE.'.*
AND (storage_category_id IS NULL OR storage_category_id != category_id)
;';
pwg_query($query);
-
+
if (is_array($categories) and count($categories) > 0)
{
associate_images_to_categories($images, $categories);
@@ -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);
}
- if (count($types)>1)
+ for ($i=0; $i<count($types); $i++)
{
- $type_urls = array();
- foreach($types as $dtype)
+ $type = $types[$i];
+ if ($type == IMG_CUSTOM)
{
- $type_urls[] = derivative_to_url($dtype);
+ $type = derivative_to_url($type).'[a-zA-Z0-9]+';
}
- $pattern .= '(' . implode('|',$type_urls) . ')';
+ 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)
+ {
+ $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)
diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl
index 7fbbb26ad..f612c8386 100644
--- a/admin/themes/default/template/configuration.tpl
+++ b/admin/themes/default/template/configuration.tpl
@@ -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}