You are here

function theme_yr_verdata_symbol in Yr Weatherdata 6.2

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

Function for generating a themed weather symbol for one forecast period.

Parameters

$vars: The symbol property from the loaded xml object. Should have the attributes 'number' and 'name'.

Return value

Returns a themed image for the weather symbol.

2 theme calls to theme_yr_verdata_symbol()
yr_verdata_generate in ./yr_verdata.module
Function for generating a forecast for a location. This function should only be called after having checked if there is an up-to-date cache available, as this will load and parse an xml-file, possibly getting it from a remote host first, which is…
yr_verdata_generate_forecastboxes in ./yr_verdata.module
Function for generating one or more forecast boxes for given periods.

File

./yr_verdata.module, line 698
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_symbol($vars) {
  $nsym = FALSE;
  switch ($vars['symbol']['number']) {
    case '1':
    case '2':
    case '3':
    case '5':
    case '6':
    case '7':
    case '8':
      $nsym = TRUE;
      break;
  }
  $symbol = $vars['symbol']['number'] > 9 ? $vars['symbol']['number'] : '0' . $vars['symbol']['number'];
  $vars['period'] .= '';

  // Convert the object to a string for the next comparison.
  if ($nsym === TRUE) {
    $symbol .= $vars['period'] === '0' ? 'n' : 'd';
  }
  $url = variable_get('yr_verdata_symbol_url', 'http://symbol.yr.no/grafikk/sym/b38/') . $symbol . '.png';
  return theme('image', $url, $vars['name'], $vars['name'], NULL, FALSE);
}