You are here

function theme_yr_verdata_information in Yr Weatherdata 6.2

Same name and namespace in other branches
  1. 7 yr_verdata.module \theme_yr_verdata_information()

Theme function for displaying the location information about 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

$vars: An array for the location with basic information about it.

Return value

Returns themed output with basic information for this location.

File

./yr_verdata.module, line 865
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_information($vars) {
  $output = '';
  foreach ($vars as $key => $value) {
    $elem = 'p';
    $class = 'yr-text';
    if ($key === 'timezone') {
      continue;
    }
    elseif ($key === 'links') {
      $output .= theme('item_list', $value);
    }
    elseif ($key === 'upcoming-forecast') {
      $output .= '<div id="yr-upcoming-forecast" class="yr-forecast-boxes clear-block">';
      foreach ($value as $item) {
        $output .= yr_verdata_forecastbox($item);
      }
      $output .= '</div>';
    }
    else {
      if ($key === 'sun' && isset($value['never_rise'])) {
        $class .= ' yr-polarnight';
        $value = $value['never_rise'];
      }
      elseif ($key === 'sun' && isset($value['never_set'])) {
        $class .= ' yr-midnightsun';
        $value = $value['never_set'];
      }
      elseif ($key === 'sun') {
        $class .= ' yr-sun';
        $value = $value['rise'] . '<br />' . $value['set'];
      }
      $output .= "<{$elem} class=\"{$class}\">{$value}</{$elem}>";
    }
  }

  // Add a note about time.
  $output .= '<p class="yr-timezone-note">' . t('All times are in local time, %timezone.', array(
    '%timezone' => $vars['timezone'],
  )) . '</p>';
  return $output;
}