function theme_yr_verdata_forecast in Yr Weatherdata 7
Same name and namespace in other branches
- 6.2 yr_verdata.module \theme_yr_verdata_forecast()
Theme function for displaying the forecast for a location on that location's main forecast page. Caching is done for the whole page, so we don't need to do it here.
Parameters
$forecast: An array with the processed forecast information for this location, each element in the array should be one tabular period from the xml.
Return value
Returns themed output with forecast in boxes for this location.
File
- ./
yr_verdata.module, line 825 - yr_verdata.module This file contains the code for getting the forecast from yr.no and displaying it on a Drupal site.
Code
function theme_yr_verdata_forecast($forecast) {
$output = array();
$prefix = '<div id="yr-longterm-forecast" class="yr-forecast-boxes clearfix">';
if ($forecast['longterm-forecast'][4]['period'] != '0') {
// The first day should have a heading that says "Tomorrow".
$prefix .= '<h4>' . t('Upcoming') . '</h4>';
$period_class = 'yr-period-margin-' . $forecast['longterm-forecast'][4]['period'];
$prefix .= '<div class="yr-longterm-day ' . $period_class . ' clearfix">';
}
$output['longterm-forecast'] = array(
'#prefix' => $prefix,
'#suffix' => '</div><!-- /#yr-longterm-forecast -->',
);
foreach ($forecast['longterm-forecast'] as $key => $item) {
$output['longterm-forecast'][$key] = yr_verdata_forecastbox($item);
// Create a "new line" for each day of the forecast. Also, add a header saying which day this is.
if ($item['period'] == '0' || isset($item['following'])) {
$head = '<h4>' . ucfirst($item['day']) . '</h4>';
// ucfirst() because these are headers.
$output['longterm-forecast'][$key]['#prefix'] = $head . '<div class="yr-longterm-day clearfix"><div class="yr-forecast-box">';
}
// Close the "day-line".
if ($item['period'] == '3' || isset($item['last'])) {
$output['longterm-forecast'][$key]['#suffix'] = '</div></div><!-- /.yr-longterm-day -->';
}
}
return drupal_render($output);
}