fixed: WeatherData asset is broken

This commit is contained in:
Graham Knop 2008-05-13 20:53:11 +00:00
parent 45ae63d122
commit dffd70073c
3 changed files with 36 additions and 15 deletions

View file

@ -58,6 +58,7 @@
- removed legacy wgFieldUserData table - removed legacy wgFieldUserData table
- fixed: Thingy: Importing data can fail with some internal field Ids - fixed: Thingy: Importing data can fail with some internal field Ids
- fixed: Thingy: Problem with add_url tmpl_var permissions - fixed: Thingy: Problem with add_url tmpl_var permissions
- fixed: WeatherData asset is broken
7.5.10 7.5.10
- fix: Syntax error in GetCsMail - fix: Syntax error in GetCsMail

View file

@ -16,6 +16,16 @@ package WebGUI::Asset::Wobject::WeatherData;
use strict; use strict;
use Weather::Com::Finder; use Weather::Com::Finder;
BEGIN {
# This is horrible, and needs to be removed when Weather::Com > 0.5.3 is released.
my $old_get_weather = \&Weather::Com::Base::get_weather;
*Weather::Com::Base::get_weather = sub {
my $self = shift;
$self->{LINKS} = 1;
return $self->$old_get_weather(@_);
};
}
use WebGUI::International; use WebGUI::International;
use base 'WebGUI::Asset::Wobject'; use base 'WebGUI::Asset::Wobject';
use WebGUI::Utility; use WebGUI::Utility;
@ -116,12 +126,13 @@ sub view {
next unless defined $weather; next unless defined $weather;
foreach my $foundLocation(@{$weather->find($location)}) { foreach my $foundLocation(@{$weather->find($location)}) {
my $conditions = $foundLocation->current_conditions->description; my $current_conditions = $foundLocation->current_conditions;
my $conditions = $current_conditions->description;
$conditions =~ s/\b(\w)/uc($1)/eg; $conditions =~ s/\b(\w)/uc($1)/eg;
my $tempC = $foundLocation->current_conditions->temperature; my $tempC = $current_conditions->temperature;
my $tempF; my $tempF;
$tempF = sprintf("%.0f",(((9/5)*$tempC) + 32)) if($tempC); $tempF = sprintf("%.0f",(((9/5)*$tempC) + 32)) if($tempC);
my $icon = $foundLocation->current_conditions->icon || "na"; my $icon = $current_conditions->icon || "na";
push(@{$var{'ourLocations.loop'}}, { push(@{$var{'ourLocations.loop'}}, {
query => $location, query => $location,
@ -135,6 +146,15 @@ sub view {
iconUrl => $url->extras("wobject/WeatherData/medium_icons/".$icon.".png"), iconUrl => $url->extras("wobject/WeatherData/medium_icons/".$icon.".png"),
iconAlt => $conditions, iconAlt => $conditions,
}); });
if (!$var{links_loop}) {
$var{links_loop} = [];
for my $lnk (@{$foundLocation->current_conditions->{WEATHER}{lnks}{link}} ) {
push @{$var{links_loop}}, {
link_url => $lnk->{l},
link_title => $lnk->{t},
};
}
}
} }
} }
} }