Always check links color when background color is set onto category

This commit is contained in:
jfefe 2016-02-16 12:56:57 +01:00
parent 134c9d13bc
commit 841145678d
2 changed files with 9 additions and 9 deletions

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip"' . ( $forced_color ? ' style="color: #'.$forced_color.'"' : '' ) .'>';
$linkend='</a>';

View File

@ -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(