2
0
forked from Wavyzz/dolibarr

Debug v18

This commit is contained in:
Laurent Destailleur
2023-06-01 23:42:57 +02:00
parent 7be8ea782d
commit a6df8fad0b
2 changed files with 25 additions and 15 deletions

View File

@@ -2084,7 +2084,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
} }
} elseif (!empty($links[$i][1])) { } elseif (!empty($links[$i][1])) {
$outmore .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="wordwrap inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'; $outmore .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="wordwrap inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
$outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. $outmore .= preg_replace('/([a-z])\|([a-z])/i', '\\1 | \\2', $links[$i][1]); // Replace x|y with x | y to allow wrap on long composed texts.
$outmore .= '</a>'."\n"; $outmore .= '</a>'."\n";
} }
$outmore .= '</div>'; $outmore .= '</div>';
@@ -4202,7 +4202,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice',
'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye', 'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye',
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus',
'gears', 'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'gears', 'generate', 'generic', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group',
'hands-helping', 'help', 'holiday', 'hands-helping', 'help', 'holiday',
'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile', 'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile',
'knowledgemanagement', 'knowledgemanagement',
@@ -4442,7 +4442,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if ($srconly) { if ($srconly) {
return $fullpathpicto; return $fullpathpicto;
} }
// tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for blind people
// tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for blind people
return '<img src="'.$fullpathpicto.'"'.($notitle ? '' : ' alt="'.dol_escape_htmltag($alt).'"').(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt.($morecss ? ' class="'.$morecss.'"' : '') : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup return '<img src="'.$fullpathpicto.'"'.($notitle ? '' : ' alt="'.dol_escape_htmltag($alt).'"').(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt.($morecss ? ' class="'.$morecss.'"' : '') : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup
} }

View File

@@ -89,7 +89,6 @@ if (!$user->hasRight("modulebuilder", "run")) {
accessforbidden('ModuleBuilderNotAllowed'); accessforbidden('ModuleBuilderNotAllowed');
} }
// Dir for custom dirs // Dir for custom dirs
$tmp = explode(',', $dolibarr_main_document_root_alt); $tmp = explode(',', $dolibarr_main_document_root_alt);
$dirins = $tmp[0]; $dirins = $tmp[0];
@@ -2923,8 +2922,8 @@ if ($module == 'initmodule') {
print '<div class="tagtr"><div class="tagtd">'; print '<div class="tagtr"><div class="tagtd">';
print '<span class="opacitymedium">'.$langs->trans("Picto").'</span>'; print '<span class="opacitymedium">'.$langs->trans("Picto").'</span>';
print '</div><div class="tagtd">'; print '</div><div class="tagtd">';
print '<input type="text" name="idpicto" value="'.(GETPOSTISSET('idpicto') ? GETPOST('idpicto') : getDolGlobalString('MODULEBUILDER_DEFAULTPICTO', 'fa-generic')).'" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">'; print '<input type="text" name="idpicto" value="'.(GETPOSTISSET('idpicto') ? GETPOST('idpicto') : getDolGlobalString('MODULEBUILDER_DEFAULTPICTO', 'fa-file-o')).'" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">';
print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); print $form->textwithpicto('', $langs->trans("Example").': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
print '</div></div>'; print '</div></div>';
print '<div class="tagtr"><div class="tagtd">'; print '<div class="tagtr"><div class="tagtd">';
@@ -3331,9 +3330,13 @@ if ($module == 'initmodule') {
if (empty($firstobjectname)) { if (empty($firstobjectname)) {
$firstobjectname = $objectname; $firstobjectname = $objectname;
} }
$pictoname = 'generic';
if (preg_match('/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
$pictoname = $reg[1];
}
$head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname; $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname;
$head3[$h][1] = $objectname; $head3[$h][1] = img_picto('', $pictoname, 'class="pictofixedwidth"').$objectname;
$head3[$h][2] = $objectname; $head3[$h][2] = $objectname;
$h++; $h++;
} }
@@ -3341,7 +3344,7 @@ if ($module == 'initmodule') {
if ($h > 1) { if ($h > 1) {
$head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=deleteobject'; $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=deleteobject';
$head3[$h][1] =img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("DangerZone"); $head3[$h][1] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Dangeddddddd|fffffffffffrZone");
$head3[$h][2] = 'deleteobject'; $head3[$h][2] = 'deleteobject';
$h++; $h++;
} }
@@ -3355,7 +3358,7 @@ if ($module == 'initmodule') {
} }
} }
print dol_get_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 print dol_get_fiche_head($head3, $tabobj, '', -1, '', 0, '', '', 0, 'forobjectsuffix'); // Level 3
if ($tabobj == 'newobject') { if ($tabobj == 'newobject') {
// New object tab // New object tab
@@ -3378,8 +3381,8 @@ if ($module == 'initmodule') {
print '<div class="tagtr"><div class="tagtd">'; print '<div class="tagtr"><div class="tagtd">';
print '<span class="opacitymedium">'.$langs->trans("Picto").'</span> &nbsp; '; print '<span class="opacitymedium">'.$langs->trans("Picto").'</span> &nbsp; ';
print '</div><div class="tagtd">'; print '</div><div class="tagtd">';
print '<input type="text" name="idpicto" value="fa-generic" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">'; print '<input type="text" name="idpicto" value="fa-file-o" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">';
print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); print $form->textwithpicto('', $langs->trans("Example").': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
print '</div></div>'; print '</div></div>';
print '<div class="tagtr"><div class="tagtd">'; print '<div class="tagtr"><div class="tagtd">';
@@ -3514,7 +3517,14 @@ if ($module == 'initmodule') {
$pathtolib = strtolower($module).'/lib/'.strtolower($module).'.lib.php'; $pathtolib = strtolower($module).'/lib/'.strtolower($module).'.lib.php';
$pathtoobjlib = strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($tabobj).'.lib.php'; $pathtoobjlib = strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($tabobj).'.lib.php';
$pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png';
if (is_object($tmpobject) && property_exists($tmpobject, 'picto')) {
$pathtopicto = $tmpobject->picto;
$realpathtopicto = '';
} else {
$pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png';
$realpathtopicto = $dirread.'/'.$pathtopicto;
}
//var_dump($pathtoclass); //var_dump($pathtoclass);
//var_dump($dirread); //var_dump($dirread);
@@ -3533,7 +3543,6 @@ if ($module == 'initmodule') {
$realpathtosqlextrakey = $dirread.'/'.$pathtosqlextrakey; $realpathtosqlextrakey = $dirread.'/'.$pathtosqlextrakey;
$realpathtolib = $dirread.'/'.$pathtolib; $realpathtolib = $dirread.'/'.$pathtolib;
$realpathtoobjlib = $dirread.'/'.$pathtoobjlib; $realpathtoobjlib = $dirread.'/'.$pathtoobjlib;
$realpathtopicto = $dirread.'/'.$pathtopicto;
if (empty($realpathtoapi)) { // For compatibility with some old modules if (empty($realpathtoapi)) { // For compatibility with some old modules
$pathtoapi = strtolower($module).'/class/api_'.strtolower($module).'s.class.php'; $pathtoapi = strtolower($module).'/class/api_'.strtolower($module).'s.class.php';
@@ -3552,12 +3561,12 @@ if ($module == 'initmodule') {
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>'; print '<br>';
// Image // Image
if (dol_is_file($realpathtopicto)) { if ($realpathtopicto && dol_is_file($realpathtopicto)) {
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>'; print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>';
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; //print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>'; print '<br>';
} elseif (!empty($tmpobject)) { } elseif (!empty($tmpobject)) {
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"'); print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"').$tmpobject->picto;
print '<br>'; print '<br>';
} }