Complete work for mutualizing generic substitution system.

This commit is contained in:
Laurent Destailleur
2017-06-01 01:53:55 +02:00
parent 6c7179d281
commit c70beaa56b
19 changed files with 315 additions and 228 deletions

View File

@@ -120,11 +120,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$error++;
}
}
if (! $error)
{
$db->begin();
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
@@ -134,7 +134,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql.= " WHERE rowid = ".$id;
}
$result = $db->query($sql);
if ($result > 0)
{
@@ -223,7 +223,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$head=defaultvalues_prepare_head();
dol_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder')
@@ -249,11 +249,11 @@ $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder);
// Field
$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder')
if ($mode != 'sortorder')
{
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
}
else
else
{
$texthelp='field or alias.field';
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
@@ -264,22 +264,14 @@ if ($mode != 'focus')
{
if ($mode != 'sortorder')
{
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
// See list into GETPOST
$texthelp.='__USERID__<br>';
$texthelp.='__SUPERVISORID__<br>';
$texthelp.='__MYCOUNTRYID__<br>';
$texthelp.='__DAY__<br>';
$texthelp.='__MONTH__<br>';
$texthelp.='__YEAR__<br>';
$texthelp.='__PREVIOUS_DAY__<br>';
$texthelp.='__PREVIOUS_MONTH__<br>';
$texthelp.='__PREVIOUS_YEAR__<br>';
$texthelp.='__NEXT_DAY__<br>';
$texthelp.='__NEXT_MONTH__<br>';
$texthelp.='__NEXT_YEAR__<br>';
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
}
else
{
@@ -351,18 +343,18 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
print "\n";
print '<tr class="oddeven">';
// Page
print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page;
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
print '</td>'."\n";
// Field
print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
@@ -382,7 +374,7 @@ if ($result)
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
print '</td>';
}
// Actions
print '<td align="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
@@ -400,7 +392,7 @@ if ($result)
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
}
print '</td>';
print "</tr>\n";
print "\n";
$i++;