feature 2626: manage inline errors on form submission

git-svn-id: http://piwigo.org/svn/trunk@14513 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall
2012-04-29 11:41:34 +00:00
parent 5884b956f8
commit d04e389411
4 changed files with 58 additions and 55 deletions

View File

@@ -221,7 +221,7 @@ if (isset($_POST['submit']))
}
// updating configuration if no error found
if ('sizes' != $page['section'] and count($page['errors']) == 0)
if (!in_array($page['section'], array('sizes', 'watermark')) and count($page['errors']) == 0)
{
//echo '<pre>'; print_r($_POST); echo '</pre>';
$result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
@@ -520,54 +520,52 @@ switch ($page['section'])
}
$template->assign('watermark_files', $watermark_filemap);
$wm = ImageStdParams::get_watermark();
if ($template->get_template_vars('watermark') === null)
{
$wm = ImageStdParams::get_watermark();
$position = 'custom';
if ($wm->xpos == 0 and $wm->ypos == 0)
{
$position = 'topleft';
}
if ($wm->xpos == 100 and $wm->ypos == 0)
{
$position = 'topright';
}
if ($wm->xpos == 50 and $wm->ypos == 50)
{
$position = 'middle';
}
if ($wm->xpos == 0 and $wm->ypos == 100)
{
$position = 'bottomleft';
}
if ($wm->xpos == 100 and $wm->ypos == 100)
{
$position = 'bottomright';
}
if ($wm->xrepeat != 0)
{
$position = 'custom';
if ($wm->xpos == 0 and $wm->ypos == 0)
{
$position = 'topleft';
}
if ($wm->xpos == 100 and $wm->ypos == 0)
{
$position = 'topright';
}
if ($wm->xpos == 50 and $wm->ypos == 50)
{
$position = 'middle';
}
if ($wm->xpos == 0 and $wm->ypos == 100)
{
$position = 'bottomleft';
}
if ($wm->xpos == 100 and $wm->ypos == 100)
{
$position = 'bottomright';
}
if ($wm->xrepeat != 0)
{
$position = 'custom';
}
$template->assign(
'watermark',
array(
'file' => $wm->file,
'minw' => $wm->min_size[0],
'minh' => $wm->min_size[1],
'xpos' => $wm->xpos,
'ypos' => $wm->ypos,
'xrepeat' => $wm->xrepeat,
'opacity' => $wm->opacity,
'position' => $position,
)
);
}
$template->assign(
'watermark',
array(
'file' => $wm->file,
'minw' => $wm->min_size[0],
'minh' => $wm->min_size[1],
'xpos' => $wm->xpos,
'ypos' => $wm->ypos,
'xrepeat' => $wm->xrepeat,
'opacity' => $wm->opacity,
'position' => $position,
)
);
$template->append(
'watermark',
array(),
true
);
break;
}
}

View File

@@ -84,7 +84,7 @@ if ($v <= 0 or $v > 100)
}
// step 3 - save data
if (count($errors)==0)
if (count($errors) == 0)
{
$watermark = new WatermarkParams();
$watermark->file = $pwatermark['file'];

View File

@@ -319,8 +319,6 @@ jQuery(document).ready(function(){
{/literal}{/footer_script}
{html_style}{literal}
input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
.dErrorDesc {background-color:red; color:white; padding:0 5px;border-radius:10px; font-weight:bold;cursor:help;}
.sizeEnable {width:50px;}
.sizeEditForm {margin:0 0 10px 20px;}
.sizeEdit {display:none;}
@@ -489,7 +487,7 @@ jQuery(document).ready(function() {
<li>
<label>
{'Apply watermark if width is bigger than'|@translate}
<input size="4" maxlength="4" type="text" name="w[minw]" value="{$watermark.minw}"{if isset($ferrors.watermark.minw)}class="dError"{/if}>
<input size="4" maxlength="4" type="text" name="w[minw]" value="{$watermark.minw}"{if isset($ferrors.watermark.minw)} class="dError"{/if}>
</label>
{'pixels'|@translate}
</li>
@@ -497,7 +495,7 @@ jQuery(document).ready(function() {
<li>
<label>
{'Apply watermark if height is bigger than'|@translate}
<input size="4" maxlength="4" type="text" name="w[minh]" value="{$watermark.minh}"{if isset($ferrors.watermark.minh)}class="dError"{/if}>
<input size="4" maxlength="4" type="text" name="w[minh]" value="{$watermark.minh}"{if isset($ferrors.watermark.minh)} class="dError"{/if}>
</label>
{'pixels'|@translate}
</li>
@@ -515,24 +513,28 @@ jQuery(document).ready(function() {
<label style="display:block;margin-top:10px;font-weight:normal;"><input name="w[position]" type="radio" value="custom"{if $watermark.position eq 'custom'} checked="checked"{/if}> {'custom'|@translate}</label>
<div id="positionCustomDetails">
<label>{'X Position'|@translate}
<input size="3" maxlength="3" type="text" name="w[xpos]" value="{$watermark.xpos}"{if isset($ferrors.watermark.xpos)}class="dError"{/if}>%
<input size="3" maxlength="3" type="text" name="w[xpos]" value="{$watermark.xpos}"{if isset($ferrors.watermark.xpos)} class="dError"{/if}>%
{if isset($ferrors.watermark.xpos)}<span class="dErrorDesc" title="{$ferrors.watermark.xpos}">!</span>{/if}
</label>
<br>
<label>{'Y Position'|@translate}
<input size="3" maxlength="3" type="text" name="w[ypos]" value="{$watermark.ypos}"{if isset($ferrors.watermark.ypos)}class="dError"{/if}>%
<input size="3" maxlength="3" type="text" name="w[ypos]" value="{$watermark.ypos}"{if isset($ferrors.watermark.ypos)} class="dError"{/if}>%
{if isset($ferrors.watermark.ypos)}<span class="dErrorDesc" title="{$ferrors.watermark.ypos}">!</span>{/if}
</label>
<br>
<label>{'X Repeat'|@translate}
<input size="3" maxlength="3" type="text" name="w[xrepeat]" value="{$watermark.xrepeat}"{if isset($ferrors.watermark.xrepeat)}class="dError"{/if}>
<input size="3" maxlength="3" type="text" name="w[xrepeat]" value="{$watermark.xrepeat}"{if isset($ferrors.watermark.xrepeat)} class="dError"{/if}>
{if isset($ferrors.watermark.xrepeat)}<span class="dErrorDesc" title="{$ferrors.watermark.xrepeat}">!</span>{/if}
</label>
</div>
</li>
<li>
<label>{'Opacity'|@translate}</label>
<input size="3" maxlength="3" type="text" name="w[opacity]" value="{$watermark.opacity}"{if isset($ferrors.watermark.opacity)}class="dError"{/if}> %
<input size="3" maxlength="3" type="text" name="w[opacity]" value="{$watermark.opacity}"{if isset($ferrors.watermark.opacity)} class="dError"{/if}> %
{if isset($ferrors.watermark.opacity)}<span class="dErrorDesc" title="{$ferrors.watermark.opacity}">!</span>{/if}
</li>
</ul>
</fieldset>

View File

@@ -1107,4 +1107,7 @@ FORM#categoryOrdering .categoryLi:hover p.albumActions {visibility:visible;}
#positionCustomDetails label {
font-weight:normal;
}
}
input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
.dErrorDesc {background-color:red; color:white; padding:0 5px;border-radius:10px; font-weight:bold;cursor:help;}