diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index e1bab9af0ab..483e8d5007e 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -274,7 +274,7 @@ if ($action == 'edit') { if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text $toprint = array(); foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index a2b18ea1dbf..57b1a2dbf48 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -629,7 +629,7 @@ if ($action != 'editxxx') { if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text $toprint = array(); foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index ae459e9b8c0..c54e5cb0dfa 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -319,7 +319,7 @@ if ($action == 'edit') { if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text $toprint = array(); foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 0dc37661fad..1d6013325f6 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -622,7 +622,7 @@ if ($action == 'edit') { if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0) { - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text $toprint = array(); foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 49b41a10597..2a75e7d67a2 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1533,17 +1533,22 @@ class Categorie extends CommonObject * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) * - * @param string $sep Separator - * @param string $url Url ('', 'none' or 'urltouse') - * @param int $nocolor 0 - * @param int $addpicto Add picto into link + * @param string $sep Separator + * @param string $url Url ('', 'none' or 'urltouse') + * @param int $nocolor 0 + * @param int $addpicto Add picto into link + * @param int $notrunc Do not truncate names of parent categories * @return string[] */ - public function print_all_ways($sep = '>>', $url = '', $nocolor = 0, $addpicto = 0) + public function print_all_ways($sep = 'auto', $url = '', $nocolor = 0, $addpicto = 0, $notrunc = 0) { // phpcs:enable $ways = array(); + if ($sep == 'auto') { + $sep = '>'; + } + $all_ways = $this->get_all_ways(); // Load array of categories to reach this->id foreach ($all_ways as $way) { // It seems we always have 1 entry in this array. @@ -1567,13 +1572,21 @@ class Categorie extends CommonObject } if ($url == '') { - $link = ''; - $linkend = ''; - $w[] = $link.(($addpicto && $i == 1) ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; + if (($i < count($way) && empty($notrunc)) && $i > 1) { + $link = ''; + $linkend = ''; + } else { + $link = ''; + $linkend = ''; + } + $s = $link.(($addpicto && $i == 1) ? img_object('', 'category', 'class="paddingright"') : ''); + $s .= (($i < count($way) && empty($notrunc)) ? ($i == 1 ? dol_trunc($cat->label, 3) : '') : $cat->label); + $s .= $linkend; + $w[] = $s; } elseif ($url == 'none') { $link = ''; $linkend = ''; - $w[] = $link.(($addpicto && $i == 1) ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; + $w[] = $link.(($addpicto && $i == 1) ? img_object('', 'category', 'class="paddingright"') : '').($i < count($way) ? $cat->label : $cat->label).$linkend; } else { $w[] = ''.($addpicto ? img_object('', 'category') : '').$cat->label.''; } diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index d8b3824dec9..ebbf2b61b25 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -89,7 +89,7 @@ $linkback = ''.$langs->trans("BackToL $object->next_prev_filter = 'type:=:'.((int) $object->type); $object->ref = $object->label; $morehtmlref = '
    '.$langs->trans("Root").' >> '; -$ways = $object->print_all_ways(" >> ", '', 1); +$ways = $object->print_all_ways("auto", '', 1); foreach ($ways as $way) { $morehtmlref .= $way."
    \n"; } diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 9aa9d18af52..4ba5a812267 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -140,7 +140,7 @@ if ($object->id) { $object->next_prev_filter = 'type:=:'.((int) $object->type); $object->ref = $object->label; $morehtmlref = '
    '.$langs->trans("Root").' >> '; - $ways = $object->print_all_ways(" >> ", '', 1); + $ways = $object->print_all_ways("auto", '', 1); foreach ($ways as $way) { $morehtmlref .= $way."
    \n"; } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index f7c24c92ba1..983f9f6a83c 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -216,7 +216,7 @@ $linkback = ''.$langs->trans("BackToL $object->next_prev_filter = 'type:=:'.((int) $object->type); $object->ref = $object->label; $morehtmlref = '
    '.$langs->trans("Root").' >> '; -$ways = $object->print_all_ways(" >> ", '', 1); +$ways = $object->print_all_ways("auto", '', 1); foreach ($ways as $way) { $morehtmlref .= $way."
    \n"; } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 9a45f78a956..8944b4318f5 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -324,8 +324,9 @@ $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/ca $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = 'type:=:'.((int) $object->type); $object->ref = $object->label; -$morehtmlref = '
    '.$langs->trans("Root").' >> '; -$ways = $object->print_all_ways(" >> ", '', 1); +$morehtmlref = '
    '.$langs->trans("Root").''; +$morehtmlref .= ' > '; +$ways = $object->print_all_ways("auto", '', 1, 0, 1); foreach ($ways as $way) { $morehtmlref .= $way."
    \n"; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88f43815ed7..3765e6b17b3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -10134,7 +10134,7 @@ class Form * Render list of categories linked to object with id $id and type $type * * @param int $id Id of object - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode using number (0, 1, 2, ...) is deprecated. * @param int<0,1> $rendermode 0=Default, use multiselect (deprecated). 1=Emulate multiselect (recommended) * @param int<0,1> $nolink 1=Do not add html links * @return string String with categories @@ -10149,7 +10149,7 @@ class Form if ($rendermode == 1) { $toprint = array(); foreach ($categories as $c) { - $ways = $c->print_all_ways(' >> ', ($nolink ? 'none' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', ($nolink ? 'none' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text foreach ($ways as $way) { $color = $c->color; $sfortag = '
  • '; diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index ec2653bdcfc..15f75e3f126 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1326,7 +1326,7 @@ class FormSetupItem if ($result < 0) { $this->setErrors($c->errors); } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text $toprint = array(); foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 696489ac1ed..602837329d1 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -280,7 +280,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort if (!empty($catid)) { print "
    "; $c = new Categorie($db); - $ways = $c->print_all_ways(' > ', 'fourn/product/list.php'); + $ways = $c->print_all_ways('auto', 'fourn/product/list.php'); print " > ".$ways[0]."
    \n"; print "

    "; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 10216a428cc..268d6e17031 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -984,7 +984,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if (!empty($catid)) { print "
    "; $c = new Categorie($db); - $ways = $c->print_all_ways(' > ', 'product/list.php'); + $ways = $c->print_all_ways('auto', 'product/list.php'); print " > ".$ways[0]."
    \n"; print "

    "; } diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index d4fcd04805a..08de6af6bc5 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -414,7 +414,7 @@ if ($resql) { print "
    "; $c = new Categorie($db); $c->fetch($search_categ); - $ways = $c->print_all_ways(' > ', 'product/reassort.php'); + $ways = $c->print_all_ways('auto', 'product/reassort.php'); print " > ".$ways[0]."
    \n"; print "

    "; } diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 294f5ac78e0..df8fea7de82 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -564,7 +564,7 @@ if ($search_categ > 0) { print "
    "; $c = new Categorie($db); $c->fetch($search_categ); - $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); + $ways = $c->print_all_ways('auto', 'product/reassortlot.php'); print " > ".$ways[0]."
    \n"; print "

    "; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index aac87a42cd5..aee9f4371f6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1301,7 +1301,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if (!empty($search_categ_cus) || !empty($search_categ_sup)) { print "
    "; $c = new Categorie($db); - $ways = $c->print_all_ways(' > ', 'societe/list.php'); + $ways = $c->print_all_ways('auto', 'societe/list.php'); print " > ".$ways[0]."
    \n"; print "

    "; } diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d207e6c27ef..01d36cbcd41 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -708,7 +708,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if (!empty($catid)) { print "
    "; $c = new Categorie($db); - $ways = $c->print_all_ways(' > ', 'user/list.php'); + $ways = $c->print_all_ways('auto', 'user/list.php'); print " > ".$ways[0]."
    \n"; print "

    "; }