Skip to content

Commit dd1f034

Browse files
author
rvelices
committed
added a button to restore multiple size default sizes ...
git-svn-id: http://piwigo.org/svn/trunk@14228 68402e56-0260-453c-a942-63ccdbb3a9ee
1 parent b4e0a9a commit dd1f034

3 files changed

Lines changed: 35 additions & 22 deletions

File tree

admin/configuration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@
248248
//------------------------------------------------------ $conf reinitialization
249249
load_conf_from_db();
250250
}
251+
elseif (isset($_POST['restore_settings']))
252+
{
253+
ImageStdParams::set_and_save( ImageStdParams::get_default_sizes() );
254+
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = \'disabled_derivatives\'');
255+
clear_derivative_cache();
256+
}
251257

252258
//----------------------------------------------------- template initialization
253259
$template->set_filename('config', 'configuration.tpl');

admin/themes/default/template/configuration.tpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ jQuery(document).ready(function(){
3030
});
3131
{/literal}{/footer_script}
3232

33-
<div class="titrePage">
34-
<h2>{'Piwigo configuration'|@translate} {$TABSHEET_TITLE}</h2>
35-
</div>
33+
<h2>{'Piwigo configuration'|@translate} {$TABSHEET_TITLE}</h2>
3634

3735
{if !isset($default)}
3836
<form method="post" action="{$F_ACTION}" class="properties">
@@ -314,13 +312,13 @@ jQuery(document).ready(function(){
314312
jQuery("#showDetails").click(function() {
315313
jQuery(".sizeDetails").show();
316314
jQuery(this).css("visibility", "hidden");
315+
return false;
317316
});
318317

319318
});
320319
{/literal}{/footer_script}
321320

322-
{html_head}{literal}
323-
<style type="text/css">
321+
{html_style}{literal}
324322
input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
325323
.dErrorDesc {background-color:red; color:white; padding:0 5px;border-radius:10px; font-weight:bold;cursor:help;}
326324
.sizeEnable {width:50px;}
@@ -330,8 +328,7 @@ input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
330328
.showDetails {padding:0;}
331329
.sizeDetails {display:none;margin-left:10px;}
332330
.sizeEditOpen {margin-left:10px;}
333-
</style>
334-
{/literal}{/html_head}
331+
{/literal}{/html_style}
335332

336333
<fieldset id="sizesConf">
337334
<legend>{'Original Size'|@translate}</legend>
@@ -643,9 +640,12 @@ input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
643640
{/if}
644641

645642
{if !isset($default)}
646-
<p class="formButtons">
647-
<input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}">
648-
</p>
643+
<p class="formButtons">
644+
<input type="submit" name="submit" value="{'Save Settings'|@translate}">
645+
{if isset($sizes)}
646+
<input type="submit" name="restore_settings" value="{'Restore'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');">
647+
{/if}
648+
</p>
649649
</form>
650650
{/if}
651651

include/derivative_std_params.inc.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ static function load_from_db()
112112
}
113113
else
114114
{
115-
self::make_default();
115+
self::$watermark = new WatermarkParams();
116+
self::$type_map = self::get_default_sizes();
116117
}
117118
self::build_maps();
118119
}
@@ -141,18 +142,24 @@ static function save()
141142
conf_update_param('derivatives', addslashes($ser) );
142143
}
143144

144-
private static function make_default()
145+
static function get_default_sizes()
145146
{
146-
self::$watermark = new WatermarkParams();
147-
self::$type_map[IMG_SQUARE] = new DerivativeParams( SizingParams::square(120,120) );
148-
self::$type_map[IMG_THUMB] = new DerivativeParams( SizingParams::classic(144,144) );
149-
self::$type_map[IMG_XXSMALL] = new DerivativeParams( SizingParams::classic(240,240) );
150-
self::$type_map[IMG_XSMALL] = new DerivativeParams( SizingParams::classic(432,324) );
151-
self::$type_map[IMG_SMALL] = new DerivativeParams( SizingParams::classic(576,432) );
152-
self::$type_map[IMG_MEDIUM] = new DerivativeParams( SizingParams::classic(792,594) );
153-
self::$type_map[IMG_LARGE] = new DerivativeParams( SizingParams::classic(1008,756) );
154-
self::$type_map[IMG_XLARGE] = new DerivativeParams( SizingParams::classic(1224,918) );
155-
self::$type_map[IMG_XXLARGE] = new DerivativeParams( SizingParams::classic(1656,1242) );
147+
$arr = array(
148+
IMG_SQUARE => new DerivativeParams( SizingParams::square(120,120) ),
149+
IMG_THUMB => new DerivativeParams( SizingParams::classic(144,144) ),
150+
IMG_XXSMALL => new DerivativeParams( SizingParams::classic(240,240) ),
151+
IMG_XSMALL => new DerivativeParams( SizingParams::classic(432,324) ),
152+
IMG_SMALL => new DerivativeParams( SizingParams::classic(576,432) ),
153+
IMG_MEDIUM => new DerivativeParams( SizingParams::classic(792,594) ),
154+
IMG_LARGE => new DerivativeParams( SizingParams::classic(1008,756) ),
155+
IMG_XLARGE => new DerivativeParams( SizingParams::classic(1224,918) ),
156+
IMG_XXLARGE => new DerivativeParams( SizingParams::classic(1656,1242) ),
157+
);
158+
foreach($arr as $params)
159+
{
160+
$params->last_mod_time = time();
161+
}
162+
return $arr;
156163
}
157164

158165
static function apply_global($params)

0 commit comments

Comments
 (0)