From 841145678d13a24ac0f3e01aa4375109948f5b0c Mon Sep 17 00:00:00 2001 From: jfefe Date: Tue, 16 Feb 2016 12:56:57 +0100 Subject: [PATCH] Always check links color when background color is set onto category --- htdocs/categories/class/categorie.class.php | 10 ++++++++-- htdocs/categories/index.php | 8 +------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 50a1a8d0e06..fb74a29a9f5 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1353,16 +1353,22 @@ class Categorie extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option Sur quoi pointe le lien ('', 'xyz') * @param int $maxlength Max length of text - * @param string $forced_color Hexadecimal code to force link color * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='',$maxlength=0, $forced_color='') + function getNomUrl($withpicto=0,$option='',$maxlength=0) { global $langs; $result=''; $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); + // Check contrast with background and correct text color + $color = colorArrayToHex(colorStringToArray($this->color,array()),''); + $forced_color='000'; + $tmpcolorweight=0; + foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x; + if ($tmpcolorweight < 400) $forced_color='FFF'; + $link = ''; $linkend=''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index a01ea17e969..e57cd22d5fd 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -148,13 +148,7 @@ foreach($fulltree as $key => $val) $categstatic->ref=$val['label']; $categstatic->color=$val['color']; $categstatic->type=$type; - // Check contrast with background and correct text color - $color = colorArrayToHex(colorStringToArray($categstatic->color,array()),''); - $textcolor='000'; - $tmpcolorweight=0; - foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x; - if ($tmpcolorweight < 400) $textcolor='FFF'; - $li=$categstatic->getNomUrl(1,'',60, $textcolor); + $li=$categstatic->getNomUrl(1,'',60); $desc=dol_htmlcleanlastbr($val['description']); $data[] = array(