2
0
forked from Wavyzz/dolibarr

FIX Better management error into the color conversion functions

This commit is contained in:
Laurent Destailleur
2015-06-12 14:37:27 +02:00
parent 4a726f6315
commit 1a2bde14fb
3 changed files with 18 additions and 10 deletions

View File

@@ -1844,22 +1844,24 @@ function fetchObjectByElement($element_id,$element_type) {
* Convert an array with RGB value into hex RGB value
*
* @param array $arraycolor Array
* @param string $colorifnotfound Color code to return if entry not defined
* @param string $colorifnotfound Color code to return if entry not defined or not a RGB format
* @return string RGB hex value (without # before). For example: FF00FF
* @see Make the opposite of colorStringToArray
*/
function colorArrayToHex($arraycolor,$colorifnotfound='888888')
{
if (! is_array($arraycolor)) return $colorifnotfound;
if (empty($arraycolor)) return $colorifnotfound;
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
}
/**
* Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255)
* Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255).
* If entry is already an array, return it.
*
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
* @param string $colorifnotfound Color code to return if entry not defined
* @param array $colorifnotfound Color code array to return if entry not defined
* @return string RGB hex value (without # before). For example: FF00FF
* @see Make the opposite of colorArrayToHex
*/