Skip to content

Weather module source to WeatherAPI.com #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/libraries/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5709,7 +5709,8 @@ public function get_weather($lat, $lng, $datetime)
))) $locale = 'en';

// Dark Sky Provider
$JSON = $this->get_web_page('https://api.darksky.net/forecast/'.$settings['weather_module_api_key'].'/'.$lat.','.$lng.','.strtotime($datetime).'?exclude=minutely,hourly,daily,alerts&units=ca&lang='.$locale);
// $JSON = $this->get_web_page('https://api.darksky.net/forecast/'.$settings['weather_module_api_key'].'/'.$lat.','.$lng.','.strtotime($datetime).'?exclude=minutely,hourly,daily,alerts&units=ca&lang='.$locale);
$JSON = $this->get_web_page('https://api.weatherapi.com/v1/forecast.json?key='.$settings['weather_module_api_key'].'&q='.$lat.','.$lng);
$data = json_decode($JSON, true);

return (isset($data['currently']) ? $data['currently'] : false);
Expand Down
28 changes: 15 additions & 13 deletions app/modules/weather/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,25 @@

<div class="mec-weather-head">
<div class="mec-weather-icon-box">
<span class="mec-weather-icon <?php echo $weather['icon']; ?>"></span>
<?php $url= str_replace('//', '', $weather['condition']['icon']); $icon = 'style="background-size: 100%; background-image: url(http://'.$url.')"'; ?>
<span class="mec-weather-icon" <?php echo $icon ?>></span>
</div>
<div class="mec-weather-summary">

<?php if(isset($weather['summary'])): ?>
<div class="mec-weather-summary-report"><?php echo $weather['summary']; ?></div>
<?php if(isset($weather['condition']['text'])): ?>
<div class="mec-weather-summary-report"><?php echo $weather['condition']['text']; ?></div>
<?php endif; ?>

<?php if(isset($weather['temperature'])): ?>
<?php if(isset($weather['temp_c'])): ?>
<div class="mec-weather-summary-temp" data-c="<?php _e( ' °C', 'modern-events-calendar-lite' ); ?>" data-f="<?php _e( ' °F', 'modern-events-calendar-lite' ); ?>">
<?php if(!$imperial): echo round($weather['temperature']); ?>
<var><?php _e(' °C', 'modern-events-calendar-lite'); ?></var>
<?php else: echo $this->weather_unit_convert($weather['temperature'], 'C_TO_F'); ?>
<var><?php _e(' °F', 'modern-events-calendar-lite'); ?></var>
<?php endif; ?>
<?php if(!$imperial): echo round($weather['temp_c']); ?>
<var><?php _e(' °C', 'modern-events-calendar-lite'); ?></var>
<?php else: echo $this->weather_unit_convert($weather['temp_c'], 'C_TO_F'); ?>
<var><?php _e(' °F', 'modern-events-calendar-lite'); ?></var>
<?php endif; ?>
</div>
<?php endif; ?>


</div>

Expand All @@ -67,16 +69,16 @@

<div class="mec-weather-extras">

<?php if(isset($weather['windSpeed'])): ?>
<div class="mec-weather-wind" data-kph="<?php _e(' KPH', 'modern-events-calendar-lite'); ?>" data-mph="<?php _e(' MPH', 'modern-events-calendar-lite'); ?>"><span><?php _e('Wind', 'modern-events-calendar-lite'); ?>: </span><?php if(!$imperial) echo round($weather['windSpeed']); else echo $this->weather_unit_convert($weather['windSpeed'], 'KM_TO_M');?><var><?php if(!$imperial) _e(' KPH', 'modern-events-calendar-lite'); else _e(' MPH', 'modern-events-calendar-lite'); ?></var></div>
<?php if(isset($weather['wind_kph'])): ?>
<div class="mec-weather-wind" data-kph="<?php _e(' KPH', 'modern-events-calendar-lite'); ?>" data-mph="<?php _e(' MPH', 'modern-events-calendar-lite'); ?>"><span><?php _e('Wind', 'modern-events-calendar-lite'); ?>: </span><?php if(!$imperial) echo round($weather['wind_kph']); else echo $this->weather_unit_convert($weather['wind_kph'], 'KM_TO_M');?><var><?php if(!$imperial) _e(' KPH', 'modern-events-calendar-lite'); else _e(' MPH', 'modern-events-calendar-lite'); ?></var></div>
<?php endif; ?>

<?php if(isset($weather['humidity'])): ?>
<div class="mec-weather-humidity"><span><?php _e('Humidity', 'modern-events-calendar-lite'); ?>:</span> <?php echo round($weather['humidity']); ?><var><?php _e(' %','modern-events-calendar-lite'); ?></var></div>
<?php endif; ?>

<?php if(isset($weather['visibility'])): ?>
<div class="mec-weather-visibility" data-kph="<?php _e(' KM', 'modern-events-calendar-lite'); ?>" data-mph="<?php _e(' Miles', 'modern-events-calendar-lite'); ?>"><span><?php _e('Visibility', 'modern-events-calendar-lite'); ?>: </span><?php if(!$imperial) echo round($weather['visibility']); else echo $this->weather_unit_convert($weather['visibility'], 'KM_TO_M');?><var><?php if(!$imperial) _e(' KM','modern-events-calendar-lite'); else _e(' Miles','modern-events-calendar-lite'); ?></var></div>
<?php if(isset($weather['vis_km'])): ?>
<div class="mec-weather-visibility" data-kph="<?php _e(' KM', 'modern-events-calendar-lite'); ?>" data-mph="<?php _e(' Miles', 'modern-events-calendar-lite'); ?>"><span><?php _e('Visibility', 'modern-events-calendar-lite'); ?>: </span><?php if(!$imperial) echo round($weather['vis_km']); else echo $this->weather_unit_convert($weather['vis_km'], 'KM_TO_M');?><var><?php if(!$imperial) _e(' KM','modern-events-calendar-lite'); else _e(' Miles','modern-events-calendar-lite'); ?></var></div>
<?php endif; ?>

</div>
Expand Down