From 47f60e1f8d42273c42a2597f506b1f81dcce9193 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 13 Feb 2016 07:53:50 +0100 Subject: [PATCH] Add function img_weather --- htdocs/admin/delais.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 21 +++++++++++++++++++++ htdocs/index.php | 10 +++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 0a744a047a5..82a56a60f11 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -261,24 +261,24 @@ $text=''; $options='height="60px"'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 534b4f31d86..ce566e6f9eb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2170,6 +2170,27 @@ function img_object($titlealt, $picto, $options = '', $pictoisfullpath = false) return img_picto($titlealt, 'object_'.$picto, $options, $pictoisfullpath); } +/** + * Show weather picto + * + * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. + * @param string $picto Name of image file to show (If no extension provided, we use '.png'). Image must be stored into htdocs/theme/common directory. + * @param string $options Add more attribute on img tag + * @param int $pictoisfullpath If 1, image path is a full path + * @return string Return img tag + * @see #img_object, #img_picto + */ +function img_weather($titlealt, $picto, $options = '', $pictoisfullpath = 0) +{ + global $conf; + + if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + + $path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto; + + return img_picto($titlealt, $path, $options, 1); +} + /** * Show picto (generic function) * diff --git a/htdocs/index.php b/htdocs/index.php index 0bb3b41ffb2..af3636f2b99 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -618,10 +618,10 @@ function showWeather($totallate,$text,$options) $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; - if ($totallate <= $level0) $out.=img_picto_common($text,'weather/weather-clear.png',$options); - if ($totallate > $level0 && $totallate <= $level1) $out.=img_picto_common($text,'weather/weather-few-clouds.png',$options); - if ($totallate > $level1 && $totallate <= $level2) $out.=img_picto_common($text,'weather/weather-clouds.png',$options); - if ($totallate > $level2 && $totallate <= $level3) $out.=img_picto_common($text,'weather/weather-many-clouds.png',$options); - if ($totallate > $level3) $out.=img_picto_common($text,'weather/weather-storm.png',$options); + if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); + if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); + if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); + if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); + if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); return $out; }
'; -print img_picto_common($text,'weather/weather-clear.png',$options); +print img_weather($text,'weather-clear.png',$options); print '= '.$level0.'         '; -print img_picto_common($text,'weather/weather-few-clouds.png',$options); +print img_weather($text,'weather-few-clouds.png',$options); print '<= '.$level1.'         '; -print img_picto_common($text,'weather/weather-clouds.png',$options); +print img_weather($text,'weather-clouds.png',$options); print '<= '.$level2.'
'; -print img_picto_common($text,'weather/weather-many-clouds.png',$options); +print img_weather($text,'weather-many-clouds.png',$options); print '<= '.$level3.'         '; -print img_picto_common($text,'weather/weather-storm.png',$options); +print img_weather($text,'weather-storm.png',$options); print '> '.$level3.'