Changeset 722799
- Timestamp:
- 06/04/2013 09:49:49 PM (13 years ago)
- Location:
- weather-layer/trunk
- Files:
-
- 3 edited
-
admin.php (modified) (4 diffs)
-
config.php (modified) (2 diffs)
-
weather_layer.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
weather-layer/trunk/admin.php
r603517 r722799 29 29 { 30 30 register_setting('wl_options', 'wl_options'); 31 31 32 add_settings_section('main_section', 'General settings', 'weather_layer_settings_main_section', __FILE__); 33 32 34 add_settings_field('plugin_language', 'Language', 'weather_layer_settings_language', __FILE__, 'main_section'); 33 add_settings_field('plugin_degrees', 'Degrees', 'weather_layer_settings_degrees', __FILE__, 'main_section'); 35 add_settings_field('plugin_degrees', 'Degrees unit', 'weather_layer_settings_degrees', __FILE__, 'main_section'); 36 add_settings_field('plugin_windspeed', 'Wind speed unit', 'weather_layer_settings_windspeed', __FILE__, 'main_section'); 34 37 add_settings_field('plugin_titleformat', 'Title format', 'weather_layer_settings_titleformat', __FILE__, 'main_section'); 35 38 add_settings_field('plugin_branding', 'Activate promotional links', 'weather_layer_settings_branding', __FILE__, 'main_section'); … … 60 63 global $WL_languages; 61 64 $options = get_option('wl_options'); 62 $language = isset($options['language']) && !empty($options['language']) && isset($WL_languages[$options['language']]) ? $options['language'] : LANGUAGE;63 65 ?> 64 66 … … 83 85 84 86 $options = get_option('wl_options'); 85 $degrees = isset($options['degrees']) && !empty($options['degrees']) && isset($WL_degrees[$options['degrees']]) ? $options['degrees'] : DEGREES;86 87 ?> 87 88 … … 91 92 $selected = ((!isset($options['degrees']) || empty($options['degrees'])) && $label == DEGREES) 92 93 || (isset($options['degrees']) && !empty($options['degrees']) && $label == $options['degrees']); 94 ?> 95 <option value="<?php echo $label; ?>" <?php echo ($selected ? 'selected="selected"' : ''); ?> /><?php echo $label; ?></option> 96 <?php 97 endforeach; 98 ?> 99 </select> 100 101 <?php 102 } 103 104 function weather_layer_settings_windspeed() 105 { 106 global $WL_windspeed; 107 108 $options = get_option('wl_options'); 109 ?> 110 111 <select id="windspeed" name="wl_options[windspeed]"> 112 <?php 113 foreach ($WL_windspeed as $label => $value) : 114 $selected = ((!isset($options['windspeed']) || empty($options['windspeed'])) && $label == WINDSPEED) 115 || (isset($options['windspeed']) && !empty($options['windspeed']) && $label == $options['windspeed']); 93 116 ?> 94 117 <option value="<?php echo $label; ?>" <?php echo ($selected ? 'selected="selected"' : ''); ?> /><?php echo $label; ?></option> -
weather-layer/trunk/config.php
r722780 r722799 6 6 7 7 define ('LANGUAGE', 'fr'); // Langue par défaut 8 define ('DEGREES', 'c'); // Unités de degrés par défaut 8 define ('DEGREES', 'c'); // Unités par défaut des degrés 9 define ('WINDSPEED', 'km/h'); // Unités par défaut de la vitesse du vent 9 10 define ('LAYER_TITLE_FORMAT', '%city% (%country%)'); // Formatage par défaut du titre du layer 10 11 define ('IMAGES_PATH', get_bloginfo('wpurl') . '/wp-content/plugins/weather-layer/icones/'); // Répertoire des images … … 20 21 'Celsius' => 'c', 21 22 'Fahrenheit' => 'f' 23 ); 24 25 $WL_windspeed = array 26 ( 27 'km/h' => 'km/h', 28 'm/s' => 'm/s', 29 'Knots' => 'knots' 22 30 ); 23 31 -
weather-layer/trunk/weather_layer.php
r722780 r722799 4 4 Plugin URI: http://blogovoyage.fr/weather-layer 5 5 Description: This plugin allows you to display weather data on your blog thanks to Yahoo! Weather. Example of use with shortcode : [weatherlayer country="France" city="Paris"] You can also add the Weather Widget in order to display weather information into your sidebar. 6 Version: 3. 3.26 Version: 3.4 7 7 Author: Morgan Fabre 8 8 Author URI: http://blogovoyage.fr … … 170 170 function weather_layer_getDegreesClass ($value) 171 171 { 172 // Si les degrés sont en Fahrenheit, on les convertit Celsius pour assurer une correspondance des couleurs 173 if (weather_layer_getDegreesUnit() == 'f') 174 $value = ($value - 32) / 1.8; 175 172 176 if ($value < 12) 173 177 $class = COLD_CLASS; 174 else if ($value < 2 6)178 else if ($value < 25) 175 179 $class = TEMPERATE_CLASS; 176 180 else … … 204 208 205 209 return (isset($options['degrees']) && isset($WL_degrees[$options['degrees']]) ? $WL_degrees[$options['degrees']] : DEGREES); 210 } 211 212 /** 213 @Author Morgan Fabre 214 Récupération des unités à utiliser pour la vitesse du vent 215 */ 216 function weather_layer_getWindSpeedUnit () 217 { 218 global $WL_windspeed; 219 220 $options = get_option('wl_options'); 221 222 return (isset($options['windspeed']) && isset($WL_windspeed[$options['windspeed']]) ? $WL_windspeed[$options['windspeed']] : WINDSPEED); 223 } 224 225 /** 226 @Author Morgan Fabre 227 Calcul de la valeur de la vitesse du vent 228 */ 229 function weather_layer_getWindSpeedValue($speed) 230 { 231 switch (weather_layer_getWindSpeedUnit()) 232 { 233 case "m/s" : 234 $speed /= 3.6; 235 break; 236 237 case "knots" : 238 $speed /= 1.852; 239 break; 240 } 241 242 return round($speed, 1); 206 243 } 207 244 … … 358 395 <?php echo weather_layer_getWeatherText($xml->item->condition['code']); ?> 359 396 <br /> 360 <?php echo weather_layer_translate('Wind'); ?> : <?php echo round($xml->wind['speed'], 0); ?> km/h397 <?php echo weather_layer_translate('Wind'); ?> : <?php echo weather_layer_getWindSpeedValue($xml->wind['speed']); ?> <?php echo weather_layer_getWindSpeedUnit(); ?> 361 398 <br /> 362 399 <?php echo weather_layer_translate('Humidity'); ?> : <?php echo $xml->atmosphere['humidity']; ?>%
Note: See TracChangeset
for help on using the changeset viewer.