From 0ea7d51b227c2ef32b25378e4355e1a4479c9b16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 8 Dec 2014 19:05:22 +0100 Subject: [PATCH] Fixed: Several fix in color management (function at wrong place, mark param that are deprecated, convertion of value to get correct format in all situation) --- htdocs/adherents/stats/geo.php | 3 +- htdocs/core/class/html.formother.class.php | 8 ++--- htdocs/core/lib/functions.lib.php | 13 -------- htdocs/core/lib/functions2.lib.php | 39 ++++++++++++++++++++++ htdocs/theme/eldy/style.css.php | 15 +++++---- 5 files changed, 53 insertions(+), 25 deletions(-) diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 736f6ef0140..938e3e172b2 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -23,6 +23,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $graphwidth=DolGraph::getDefaultGraphSizeForStats('width',700); @@ -69,7 +70,7 @@ dol_mkdir($dir); if ($mode) { - // Define sql + // Define sql if ($mode == 'memberbycountry') { $label=$langs->trans("Country"); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1ed76cddd9b..c7f953dbbfc 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -560,13 +560,13 @@ class FormOther * * @param string $set_color Pre-selected color * @param string $prefix Name of HTML field - * @param string $form_name Name of form + * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @return void * @deprecated */ - function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='') + function select_color($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='') { print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors); } @@ -576,13 +576,13 @@ class FormOther * * @param string $set_color Pre-selected color * @param string $prefix Name of HTML field - * @param string $form_name Name of form + * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @param string $morecss Add css style into input field * @return void */ - function selectColor($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='', $morecss='') + function selectColor($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='', $morecss='') { global $langs,$conf; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5c0040a74b9..fb587487aae 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4843,19 +4843,6 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') } -/** - * 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 - * @return string RGB hex value (without # before). For example: FF00FF - */ -function colorArrayToHex($arraycolor,$colorifnotfound='888888') -{ - if (! is_array($arraycolor)) return $colorifnotfound; - return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); -} - /** * Set focus onto field with selector * diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 4702fe69e99..246af863d12 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1836,3 +1836,42 @@ function fetchObjectByElement($element_id,$element_type) { } return 0; } + + +/** + * 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 + * @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; + 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) + * + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @param string $colorifnotfound Color code to return if entry not defined + * @return string RGB hex value (without # before). For example: FF00FF + * @see Make the opposite of colorArrayToHex + */ +function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) +{ + if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is + $tmp=preg_match('/^([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); + if (! $tmp) + { + $tmp=explode(',',$stringcolor); + if (count($tmp) < 3) return $colorifnotfound; + return $tmp; + } + return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); +} + + diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7eed00b74f6..dc159a87607 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -38,6 +38,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); session_cache_limiter(FALSE); require_once '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']); @@ -107,7 +108,7 @@ $colorbacklinepair2='255,255,255'; // line pair $colorbacklinepairhover=(230+round(($isred+$isgreen+$isblue)/9)).','.(230+round(($isred+$isgreen+$isblue)/9)).','.(230+round(($isred+$isgreen+$isblue)/9)); $colorbackbody='#f9f9f9'; $colortext='40,40,40'; -$fontsize='13'; +$fontsize='12'; $fontsizesmaller='11'; // Eldy colors @@ -131,12 +132,8 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_LINEIMPAIR2='255,255,255'; $conf->global->THEME_ELDY_LINEIMPAIRHOVER='238,246,252'; $conf->global->THEME_ELDY_TEXT='50,50,130'; - /*if ($dol_use_jmobile) - { - $conf->global->THEME_ELDY_BACKTABCARD1='245,245,245'; // topmenu - $conf->global->THEME_ELDY_BACKTABCARD2='245,245,245'; - $conf->global->THEME_ELDY_BACKTABACTIVE='245,245,245'; - }*/ + $conf->global->THEME_ELDY_FONT_SIZE1='12'; + $conf->global->THEME_ELDY_FONT_SIZE2='11'; } $colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1) :(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); @@ -167,6 +164,10 @@ if ((! empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) && empty($user->conf-> $colorbacklinepairhover=''; } +// Format color value to match expected format (may be 'FFFFFF' or '255,255,255') +$colorbacktabcard1=join(',',colorStringToArray($colorbacktabcard1)); +$colorbacktabcard2=join(',',colorStringToArray($colorbacktabcard2)); + // Set text color to black or white $tmppart=explode(',',$colorbackhmenu1); $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); -- GitLab