forked from Wavyzz/dolibarr
Debug v19
This commit is contained in:
@@ -1594,6 +1594,21 @@ function dol_escape_json($stringtoescape)
|
||||
return str_replace('"', '\"', $stringtoescape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns text escaped for inclusion into a php string, build with double quotes "
|
||||
*
|
||||
* @param string $stringtoescape String to escape
|
||||
* @return string Escaped string for json content.
|
||||
*/
|
||||
function dol_escape_php($stringtoescape)
|
||||
{
|
||||
if (is_null($stringtoescape)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return str_replace('"', "'", $stringtoescape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string label ready to be output on HTML content
|
||||
* To use text inside an attribute, use can use only dol_escape_htmltag()
|
||||
|
||||
@@ -126,10 +126,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
|
||||
if (!empty($val['picto'])) {
|
||||
$texttoinsert .= " 'picto'=>'".$val['picto']."',";
|
||||
}
|
||||
$texttoinsert .= " 'enabled'=>'".($val['enabled'] !== '' ? $val['enabled'] : 1)."',";
|
||||
$texttoinsert .= ' "enabled"=>"'.($val['enabled'] !== '' ? dol_escape_php($val['enabled']) : 1).'",';
|
||||
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
|
||||
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
|
||||
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
|
||||
$texttoinsert .= ' "visible"=>"'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",';
|
||||
if (!empty($val['noteditable'])) {
|
||||
$texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ CSSListClass=CSS for list
|
||||
NotEditable=Not editable
|
||||
ForeignKey=Foreign key
|
||||
ForeignKeyDesc=If the value of this field must be guaranted to exists into another table. Enter here a value matching syntax: tablename.parentfieldtocheck
|
||||
TypeOfFieldsHelp=Example:<br>varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]]<br>'1' means we add a + button after the combo to create the record<br>'filter' is a sql condition, example: 'status=1 AND fk_user=__USER_ID__ AND entity IN (__SHARED_ENTITIES__)'
|
||||
TypeOfFieldsHelp=Example:<br>varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]]<br><br>'1' means we add a + button after the combo to create the record<br>'filter' is an Universal Filter syntax condition, example: '((status:=:1) AND (fk_user:=:__USER_ID__) AND (entity:IN:(__SHARED_ENTITIES__))'
|
||||
TypeOfFieldsHelpIntro=This is the type of the field/attribute.
|
||||
AsciiToHtmlConverter=Ascii to HTML converter
|
||||
AsciiToPdfConverter=Ascii to PDF converter
|
||||
|
||||
@@ -1681,10 +1681,10 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') &&
|
||||
}
|
||||
}
|
||||
|
||||
if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && !empty(GETPOST('obj')) && $tabobj == "createproperty") {
|
||||
if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(GETPOST('obj')))) {
|
||||
$error = 0;
|
||||
|
||||
$objectname = GETPOST('obj');
|
||||
$objectname = (GETPOST('obj') ? GETPOST('obj') : $tabobj);
|
||||
|
||||
$dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
|
||||
$moduletype = $listofmodules[strtolower($module)]['moduletype'];
|
||||
@@ -1719,8 +1719,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
|
||||
'label'=>GETPOST('proplabel', 'alpha'),
|
||||
'type'=>strtolower(GETPOST('proptype', 'alpha')),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible', 'int'),
|
||||
'enabled'=>GETPOST('propenabled', 'int'),
|
||||
'visible'=>GETPOST('propvisible', 'alphanohtml'),
|
||||
'enabled'=>GETPOST('propenabled', 'alphanohtml'),
|
||||
'position'=>GETPOST('propposition', 'int'),
|
||||
'notnull'=>GETPOST('propnotnull', 'int'),
|
||||
'index'=>GETPOST('propindex', 'int'),
|
||||
@@ -1733,7 +1733,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
|
||||
'csslist'=>GETPOST('propcsslist', 'alpha'),
|
||||
'default'=>GETPOST('propdefault', 'restricthtml'),
|
||||
'noteditable'=>intval(GETPOST('propnoteditable', 'int')),
|
||||
'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')),
|
||||
//'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')),
|
||||
'validate' => GETPOST('propvalidate', 'int')
|
||||
);
|
||||
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) {
|
||||
@@ -1743,7 +1743,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
|
||||
} else {
|
||||
$addfieldentry = array();
|
||||
}
|
||||
|
||||
var_dump($addfieldentry);
|
||||
/*if (GETPOST('regeneratemissing'))
|
||||
{
|
||||
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings');
|
||||
@@ -3838,8 +3838,8 @@ if ($module == 'initmodule') {
|
||||
print '</form>';
|
||||
} elseif ($tabobj == 'createproperty') {
|
||||
$attributesUnique = array (
|
||||
'propname' => $form->textwithpicto($langs->trans("Code"), $langs->trans("PropertyDesc"), 1, 'help', 'extracss', 0, 3, 'propertyhelp'),
|
||||
'proplabel' => $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")),
|
||||
'propname' => $form->textwithpicto($langs->trans("Code"), $langs->trans("PropertyDesc"), 1, 'help', 'extracss', 0, 3, 'propertyhelp'),
|
||||
'proptype' => $form->textwithpicto($langs->trans("Type"), $langs->trans("TypeOfFieldsHelpIntro").'<br><br>'.$langs->trans("TypeOfFieldsHelp"), 1, 'help', 'extracss', 0, 3, 'typehelp'),
|
||||
'proparrayofkeyval' => $form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")),
|
||||
'propnotnull' => $form->textwithpicto($langs->trans("NotNull"), $langs->trans("NotNullDesc")),
|
||||
@@ -3850,7 +3850,7 @@ if ($module == 'initmodule') {
|
||||
'propenabled' => $form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc"), 1, 'help', 'extracss', 0, 3, 'enabledhelp'),
|
||||
'propvisible' => $form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc").'<br><br>'.$langs->trans("ItCanBeAnExpression"), 1, 'help', 'extracss', 0, 3, 'visiblehelp'),
|
||||
'propnoteditable' => $langs->trans("NotEditable"),
|
||||
'propalwayseditable' => $langs->trans("AlwaysEditable"),
|
||||
//'propalwayseditable' => $langs->trans("AlwaysEditable"),
|
||||
'propsearchall' => $form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")),
|
||||
'propisameasure' => $form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")),
|
||||
'propcss' => $langs->trans("CSSClass"),
|
||||
@@ -3858,7 +3858,7 @@ if ($module == 'initmodule') {
|
||||
'propcsslist' => $langs->trans("CSSListClass"),
|
||||
'prophelp' => $langs->trans("KeyForTooltip"),
|
||||
'propshowoncombobox' => $langs->trans("ShowOnCombobox"),
|
||||
'propvalidate' => $form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")),
|
||||
//'propvalidate' => $form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")),
|
||||
'propcomment' => $langs->trans("Comment"),
|
||||
);
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?tab=objects&module='.urlencode($module).'&tabobj=createproperty&obj='.urlencode(GETPOST('obj')).'" method="POST">';
|
||||
@@ -3878,10 +3878,16 @@ if ($module == 'initmodule') {
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><input class="maxwidth200" id="'.$key.'" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
} elseif ($key == 'proptype') {
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><div style="position: relative;"><input class="maxwidth200" id="'.$key.'" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"><div id="suggestions"></div><div></td>';
|
||||
} elseif ($key == 'propvalidate') {
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><input type="number" step="1" min="0" max="1" class="text maxwidth100" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
//} elseif ($key == 'propvalidate') {
|
||||
// print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><input type="number" step="1" min="0" max="1" class="text maxwidth100" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
} elseif ($key == 'propvisible') {
|
||||
print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alpha') : "1").'"></td>';
|
||||
} elseif ($key == 'propenabled') {
|
||||
print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alpha') : "isModEnabled('".strtolower($module)."')").'"></td>';
|
||||
} elseif ($key == 'proparrayofkeyval') {
|
||||
print '<td class="titlefieldcreate tdproparrayofkeyval">'.$attribute.'</td><td class="valuefieldcreate"><textarea class="maxwidth200" name="'.$key.'">'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alpha') : "").'</textarea></td>';
|
||||
} else {
|
||||
print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alpha') : '').'"></td>';
|
||||
}
|
||||
$counter++;
|
||||
if ($counter % 2 === 0) {
|
||||
@@ -3954,14 +3960,41 @@ if ($module == 'initmodule') {
|
||||
$("#suggestions").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("#proplabel").on("keyup", function() {
|
||||
console.log("key up on label");
|
||||
s = cleanString($("#proplabel").val());
|
||||
$("#propname").val(s);
|
||||
});
|
||||
|
||||
// when hover in suggestion
|
||||
$("#suggestions").on("mouseenter", "div", function() {
|
||||
console.log("enter suggestion");
|
||||
$(this).css("background-color", "#e0e0e0");
|
||||
});
|
||||
|
||||
$("#suggestions").on("mouseleave", "div", function() {
|
||||
console.log("leave suggestion");
|
||||
$(this).css("background-color", "#fff");
|
||||
});
|
||||
|
||||
function cleanString( stringtoclean )
|
||||
{
|
||||
// allow "a-z", "A-Z", "0-9" and "_"
|
||||
stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
|
||||
stringtoclean = stringtoclean.toLowerCase();
|
||||
if (!isNaN(stringtoclean)) {
|
||||
return ""
|
||||
}
|
||||
while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
|
||||
stringtoclean = stringtoclean.substr(1)
|
||||
}
|
||||
if (stringtoclean.length > 28) {
|
||||
stringtoclean = stringtoclean.substring(0, 27);
|
||||
}
|
||||
return stringtoclean
|
||||
}
|
||||
|
||||
});';
|
||||
print '</script>';
|
||||
} elseif ($tabobj == 'deleteobject') {
|
||||
@@ -4294,7 +4327,7 @@ if ($module == 'initmodule') {
|
||||
print '<th class="center">'.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc"), 1, 'help', 'extracss', 0, 3, 'enabledhelp').'</th>';
|
||||
print '<th class="center">'.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc").'<br><br>'.$langs->trans("ItCanBeAnExpression"), 1, 'help', 'extracss', 0, 3, 'visiblehelp').'</th>';
|
||||
print '<th class="center">'.$langs->trans("NotEditable").'</th>';
|
||||
print '<th class="center">'.$langs->trans("AlwaysEditable").'</th>';
|
||||
//print '<th class="center">'.$langs->trans("AlwaysEditable").'</th>';
|
||||
print '<th class="center">'.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).'</th>';
|
||||
print '<th class="center">'.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).'</th>';
|
||||
print '<th class="center">'.$langs->trans("CSSClass").'</th>';
|
||||
@@ -4341,7 +4374,7 @@ if ($module == 'initmodule') {
|
||||
$propenabled = $propval['enabled'];
|
||||
$propvisible = $propval['visible'];
|
||||
$propnoteditable = !empty($propval['noteditable'])?$propval['noteditable']:0;
|
||||
$propalwayseditable = !empty($propval['alwayseditable'])?$propval['alwayseditable']:0;
|
||||
//$propalwayseditable = !empty($propval['alwayseditable'])?$propval['alwayseditable']:0;
|
||||
$propsearchall = !empty($propval['searchall'])?$propval['searchall']:0;
|
||||
$propisameasure = !empty($propval['isameasure'])?$propval['isameasure']:0;
|
||||
$propcss = !empty($propval['css'])?$propval['css']:'';
|
||||
@@ -4353,6 +4386,7 @@ if ($module == 'initmodule') {
|
||||
$propvalidate = !empty($propval['validate'])?$propval['validate']:0;
|
||||
$propcomment = !empty($propval['comment'])?$propval['comment']:'';
|
||||
|
||||
print '<!-- line for object property -->'."\n";
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td class="tdsticky tdstickygray">';
|
||||
@@ -4368,14 +4402,13 @@ if ($module == 'initmodule') {
|
||||
print '<input name="proptype" value="'.dol_escape_htmltag($proptype).'"></input>';
|
||||
print '</td>';
|
||||
print '<td class="tdoverflowmax200">';
|
||||
print '<input name="proparrayofkeyval" value="';
|
||||
print '<textarea name="proparrayofkeyval">';
|
||||
if (isset($proparrayofkeyval)) {
|
||||
if (is_array($proparrayofkeyval) || $proparrayofkeyval != '') {
|
||||
print dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
print '">';
|
||||
print '</input>';
|
||||
print '</textarea>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).'">';
|
||||
@@ -4393,22 +4426,22 @@ if ($module == 'initmodule') {
|
||||
print '<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center" name="propenabled" size="2" value="'.dol_escape_htmltag($propenabled).'">';
|
||||
print '<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center" name="propvisible" size="2" value="'.dol_escape_htmltag($propvisible).'">';
|
||||
print '<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).'">';
|
||||
print '<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
/*print '<td>';
|
||||
print '<input class="center" name="propalwayseditable" size="2" value="'.dol_escape_htmltag($propalwayseditable).'">';
|
||||
print '</td>';*/
|
||||
print '<td>';
|
||||
print '<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center" name="propsearchall" size="2" value="'.dol_escape_htmltag($propsearchall).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center" name="propisameasure" size="2" value="'.dol_escape_htmltag($propisameasure).'">';
|
||||
print '<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).'">';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).'">';
|
||||
@@ -4485,9 +4518,9 @@ if ($module == 'initmodule') {
|
||||
print '<td class="center tdoverflowmax100" title="'.($propnoteditable ? dol_escape_htmltag($propnoteditable) : '').'">';
|
||||
print $propnoteditable ? dol_escape_htmltag($propnoteditable) : '';
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
/*print '<td class="center">';
|
||||
print $propalwayseditable ? dol_escape_htmltag($propalwayseditable) : '';
|
||||
print '</td>';
|
||||
print '</td>';*/
|
||||
print '<td class="center">';
|
||||
print $propsearchall ? '1' : '';
|
||||
print '</td>';
|
||||
@@ -5188,7 +5221,7 @@ if ($module == 'initmodule') {
|
||||
print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu['position']).'" readonly></td>';
|
||||
// Enabled
|
||||
print '<td class="nowraponall">';
|
||||
print '<input type="text" class="maxwidth125" named="enabled" value="'.dol_escape_htmltag($propEnabled).'">';
|
||||
print '<input type="text" class="maxwidth125" named="enabled" value="'.dol_escape_htmltag($propEnabled != '' ? $propEnabled : "isModEnabled('".dol_escape_htmltag($module)."')").'">';
|
||||
$htmltext = '<u>'.$langs->trans("Examples").':</u><br>';
|
||||
$htmltext .= '1 <span class="opacitymedium">(always enabled)</span><br>';
|
||||
$htmltext .= '0 <span class="opacitymedium">(always disabled)</span><br>';
|
||||
|
||||
Reference in New Issue
Block a user