';
if (is_array($location)) {
// Several locations returned due to imprecise location parameter.
$html = sprintf(_("Several locations possible with the parameter: %s"), $this->_params['location'])
. '
';
foreach ($location as $real_location) {
$html .= '
' . $real_location->city . ', ' . $real_location->state . '(' . $real_location->code . ")\n";
}
$html .= '';
return $html;
}
try {
$forecast = $weather->getForecast($location->code, $this->_params['days']);
$station = $weather->getStation();
$current = $weather->getCurrentConditions($location->code);
} catch (Horde_Service_Weather_Exception $e) {
return $e->getMessage();
}
// Units to display as
$units = $weather->getUnits($weather->units);
// Location and local time.
$html .= '
'
. '' . $station->name . '';
if ($current->time->timestamp()) {
$html .= ' ' . sprintf(_("Local time: %s %s"), $current->time->strftime($GLOBALS['prefs']->getValue('date_format')), $current->time->strftime($GLOBALS['prefs']->getValue('time_format')));
}
$html .= '
';
$html .= '
';
// Sunrise/sunset.
if ($station->sunrise) {
$html .= '' . _("Sunrise") . ': '
. Horde::img('block/sunrise/sunrise.png', _("Sunrise"))
. sprintf("%s %s", $station->sunrise->strftime($GLOBALS['prefs']->getValue('date_format')), $station->sunrise->strftime($GLOBALS['prefs']->getValue('time_format')));
$html .= ' ' . _("Sunset") . ': '
. Horde::img('block/sunrise/sunset.png', _("Sunset"))
. sprintf("%s %s", $station->sunset->strftime($GLOBALS['prefs']->getValue('date_format')), $station->sunset->strftime($GLOBALS['prefs']->getValue('time_format')));
$html .= '
';
}
// Temperature.
$html .= '' . _("Temperature") . ': ' .
$current->temp . '°' . Horde_String::upper($units['temp']);
// Dew point.
if (is_numeric($current->dewpoint)) {
$html .= ' ' . _("Dew point") . ': ' .
round($current->dewpoint) . '°' . Horde_String::upper($units['temp']);
}
// Feels like temperature.
// @TODO: Need to parse if wind chill/heat index etc..
// $html .= ' ' . _("Feels like: ") . '' .
// round($weather['feltTemperature']) . '°' . Horde_String::upper($units['temp']);
// Pressure and trend.
if ($current->pressure) {
$html .= '
' . _("Pressure") . ': ';
$trend = $current->pressure_trend;
if (empty($trend)) {
$html .= sprintf('%d %s',
round($current->pressure), $units['pres']);
} else {
$html .= sprintf(_("%d %s and %s"),
round($current->pressure), $units['pres'],
_($trend));
}
}
if ($current->wind_direction) {
// Wind.
$html .= '
' . _("Wind") . ': ';
$html .= sprintf(
_("From the %s (%s °) at %s %s"),
$current->wind_direction,
$current->wind_degrees,
$current->wind_speed,
$units['wind']);
if ($current->wind_gust > 0) {
$html .= ', ' . _("gusting") . ' ' . $current->wind_gust . ' ' . $units['wind'];
}
}
// Humidity.
if ($current->humidity) {
$html .= '
' . _("Humidity") . ': ' . $current->humidity;
}
if ($current->visibility) {
// Visibility.
$html .= ' ' . _("Visibility") . ': '
. round($current->visibility) . ' ' . $units['vis'];
}
// Current condition.
$condition = $current->condition;
$html .= '
' . _("Current condition") . ': '
. Horde::img(Horde_Themes::img('weather/32x32/' . $current->icon))
. ' ' . $condition
. '
';
// Forecast
if ($this->_params['days'] > 0) {
$html .= '
' .
sprintf(_("%d-day forecast"), $this->_params['days']) .
'
';
$futureDays = 0;
$html .= '
';
// Headers.
$html .= '';
$html .= '' . _("Day") . ' | ' .
sprintf(_("Temperature%s(%sHi%s/%sLo%s)"),
' ',
'', '',
'', '') .
' | ' . _("Condition") . ' | ';
if (isset($this->_params['detailedForecast'])) {
if (in_array(Horde_Service_Weather::FORECAST_FIELD_PRECIPITATION, $forecast->fields)) {
$html .= '' . sprintf(_("Precipitation%schance"), ' ') . ' | ';
}
if (in_array(Horde_Service_Weather::FORECAST_FIELD_HUMIDITY, $forecast->fields)) {
$html .= '' . _("Humidity") . ' | ';
}
if (in_array(Horde_Service_Weather::FORECAST_FIELD_WIND, $forecast->fields)) {
$html .= '' . _("Wind") . ' | ';
}
}
$html .= '
';
$which = -1;
foreach ($forecast as $day) {
$which++;
if ($which > $this->_params['days']) {
break;
}
$html .= '';
// Day name.
$html .= '';
if ($which == 0) {
$html .= _("Today");
} elseif ($which == 1) {
$html .= _("Tomorrow");
} else {
$html .= strftime('%A', mktime(0, 0, 0, date('m'), date('d') + $futureDays, date('Y')));
}
$html .= ' ' .
strftime('%b %d', mktime(0, 0, 0, date('m'), date('d') + $futureDays, date('Y'))) .
' | ';
// Forecast condition.
$condition = $day->conditions;
// Temperature.
$html .= ''
. '' . $day->high . '°'
. Horde_String::upper($units['temp']) . '/'
. '' . $day->low . '°'
. Horde_String::upper($units['temp']) . ' | ';
// Condition.
$html .= ''
. Horde::img(Horde_Themes::img('weather/32x32/' . $day->icon))
. ' ' . $condition . ' | ';
if (isset($this->_params['detailedForecast'])) {
if (in_array(Horde_Service_Weather::FORECAST_FIELD_PRECIPITATION, $forecast->fields)) {
$html .= ''
. ($day->precipitation_percent >= 0 ? $day->precipitation_percent . '%' : _("N/A")) . ' | ';
}
if (in_array(Horde_Service_Weather::FORECAST_FIELD_HUMIDITY, $forecast->fields)) {
$html .= ''
. ($day->humidity ? $day->humidity . '%': _("N/A")) . ' | ';
}
if (in_array(Horde_Service_Weather::FORECAST_FIELD_WIND, $forecast->fields)) {
// Winds.
if ($day->wind_direction) {
$html .= '' . ' '
. sprintf(_("From the %s at %s %s"),
$day->wind_direction,
$day->wind_speed,
$units['wind']);
if ($day->wind_gust && $day->wind_gust > $day->wind_speed) {
$html .= ', ' . _("gusting") . ' '
. $day->wind_gust . ' ' . $units['wind'];
}
$html .= ' | ';
} else {
$html .= '' . _("N/A") . ' | ';
}
}
}
$html .= '
';
$futureDays++;
}
$html .= '
';
}
if ($weather->logo) {
$html .= '
'
. _("Weather data provided by") . ' '
. Horde::link(
Horde::externalUrl($weather->link),
$weather->title, '', '_blank', '', $weather->title)
. Horde::img(new Horde_Themes_Image($weather->logo))
. '
';
} else {
$html .= '
'
. _("Weather data provided by") . ' '
. Horde::link(
Horde::externalUrl($weather->link),
$weather->title, '', '_blank', '', $weather->title)
. '' . $weather->title . ''
. '
';
}
return $html . '
';
}
}
tmpjWNuGb/horde-5.1.5/lib/Block/Account/ 0000755 0001750 0001750 00000000000 12262230550 017543 5 ustar mathieu mathieu tmpjWNuGb/horde-5.1.5/lib/Block/Account/Finger.php 0000644 0001750 0001750 00000005572 12233761316 021506 0 ustar mathieu mathieu
* @author Jan Schneider