Always check links color when background color is set onto category
This commit is contained in:
parent
134c9d13bc
commit
841145678d
@ -1353,16 +1353,22 @@ class Categorie extends CommonObject
|
|||||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||||
* @param string $option Sur quoi pointe le lien ('', 'xyz')
|
* @param string $option Sur quoi pointe le lien ('', 'xyz')
|
||||||
* @param int $maxlength Max length of text
|
* @param int $maxlength Max length of text
|
||||||
* @param string $forced_color Hexadecimal code to force link color
|
|
||||||
* @return string Chaine avec URL
|
* @return string Chaine avec URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$option='',$maxlength=0, $forced_color='')
|
function getNomUrl($withpicto=0,$option='',$maxlength=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
|
$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.'"' : '' ) .'>';
|
$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>';
|
$linkend='</a>';
|
||||||
|
|
||||||
|
|||||||
@ -148,13 +148,7 @@ foreach($fulltree as $key => $val)
|
|||||||
$categstatic->ref=$val['label'];
|
$categstatic->ref=$val['label'];
|
||||||
$categstatic->color=$val['color'];
|
$categstatic->color=$val['color'];
|
||||||
$categstatic->type=$type;
|
$categstatic->type=$type;
|
||||||
// Check contrast with background and correct text color
|
$li=$categstatic->getNomUrl(1,'',60);
|
||||||
$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);
|
|
||||||
$desc=dol_htmlcleanlastbr($val['description']);
|
$desc=dol_htmlcleanlastbr($val['description']);
|
||||||
|
|
||||||
$data[] = array(
|
$data[] = array(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user