From a6df8fad0b5d7ee4f3d39a009d4a076e4cb062c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Jun 2023 23:42:57 +0200 Subject: [PATCH] Debug v18 --- htdocs/core/lib/functions.lib.php | 7 ++++--- htdocs/modulebuilder/index.php | 33 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 83f2c779f32..787b09899a2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2084,7 +2084,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab } } elseif (!empty($links[$i][1])) { $outmore .= ''; - $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 .= ''."\n"; } $outmore .= ''; @@ -4202,7 +4202,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', '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', - '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', 'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile', 'knowledgemanagement', @@ -4442,7 +4442,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if ($srconly) { return $fullpathpicto; } - // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people + + // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 714c67a18c7..7bc11931860 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -89,7 +89,6 @@ if (!$user->hasRight("modulebuilder", "run")) { accessforbidden('ModuleBuilderNotAllowed'); } - // Dir for custom dirs $tmp = explode(',', $dolibarr_main_document_root_alt); $dirins = $tmp[0]; @@ -2923,8 +2922,8 @@ if ($module == 'initmodule') { print '
'; print ''.$langs->trans("Picto").''; print '
'; - print ''; - print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.
Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); + print ''; + print $form->textwithpicto('', $langs->trans("Example").': fa-file-o, fa-globe, ... any font awesome code.
Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); print '
'; print '
'; @@ -3331,9 +3330,13 @@ if ($module == 'initmodule') { if (empty($firstobjectname)) { $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][1] = $objectname; + $head3[$h][1] = img_picto('', $pictoname, 'class="pictofixedwidth"').$objectname; $head3[$h][2] = $objectname; $h++; } @@ -3341,7 +3344,7 @@ if ($module == 'initmodule') { if ($h > 1) { $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'; $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') { // New object tab @@ -3378,8 +3381,8 @@ if ($module == 'initmodule') { print '
'; print ''.$langs->trans("Picto").'   '; print '
'; - print ''; - print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.
Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); + print ''; + print $form->textwithpicto('', $langs->trans("Example").': fa-file-o, fa-globe, ... any font awesome code.
Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]'); print '
'; print '
'; @@ -3514,7 +3517,14 @@ if ($module == 'initmodule') { $pathtolib = strtolower($module).'/lib/'.strtolower($module).'.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($dirread); @@ -3533,7 +3543,6 @@ if ($module == 'initmodule') { $realpathtosqlextrakey = $dirread.'/'.$pathtosqlextrakey; $realpathtolib = $dirread.'/'.$pathtolib; $realpathtoobjlib = $dirread.'/'.$pathtoobjlib; - $realpathtopicto = $dirread.'/'.$pathtopicto; if (empty($realpathtoapi)) { // For compatibility with some old modules $pathtoapi = strtolower($module).'/class/api_'.strtolower($module).'s.class.php'; @@ -3552,12 +3561,12 @@ if ($module == 'initmodule') { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; // Image - if (dol_is_file($realpathtopicto)) { + if ($realpathtopicto && dol_is_file($realpathtopicto)) { print ' '.$langs->trans("Image").' : '.(dol_is_file($realpathtopicto) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '').''; //print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } elseif (!empty($tmpobject)) { - print ' '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"'); + print ' '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"').$tmpobject->picto; print '
'; }