Class WeatherForecast

Description

Weather Forecast widget class

Options:

provider (string):
Name of the weather forecast provider. Can be specified with or without "Weather" at the end: e.g. BBC and BBWeather will both use the BBCWeather provider

params (array):
Contains provider dependant parameters; see the documentation for the provider classes.
While the exact requiremets are provider dependant, there are three common parameters:
dateFormat (string) => Date format for days; Used by CDateFormatter::format(), see Date Format Patterns for a description of formats. Default: "EEE d' 'MMM yyyy"
location (string) => location of the forecast in the providers format. Default location is London, UK
units (string) => Units to provide the forecast in. "C"|"F" C=metric (default), F=imperial

cache (mixed):
integer: number of seconds before the forecast expires</br> array:
0 (integer) => number of seconds before the forecast expires
1 (CCacheDependency) => Cache dependency object
boolean false: Disable cacheing. i.e. every access creates a request to the provider.
null (default): Cache the forecast for one hour

cssFile (mixed):
string: Path to the CSS file to use
boolean false: No CSS file
null (default): Use the default CSS file

symbolsDir (mixed):
string: Path to the directory containing symbols to use
boolen false: Use the providers symbols specified in the data (Google only)
null (default): Use the default symbols

symbolMap (mixed):
array: Associative array that maps a forecast parameter (e.g., description, code, etc.) to the symbol to use for a given value of the parameter. e.g. 'symbolMap' => array( 'Partly Cloudy' => partly_cloudy.gif, 'Sunny' => 'sunn.gif', etc. );
null (default): Use the provider's default symbol map

Example Useage

  1.  $this->widget('application.extensions.widgets.weatherForecast.WeatherForecast'array(
  2.   'provider'=>'BBC',
  3.   'params' => array(
  4.   'location'=>'40'// BBCWeather::Paris
  5.     'units' => 'C'
  6.   ),
  7.   'cache'=>array(
  8.     3600// Cache up to one hour
  9.     new CExpressionDependency("date('H)"// Expire the cache at the top of the hour
  10.   )
  11.  ));

Located in /WeatherForecast.php (line 99)

CWidget
   |
   --WeatherForecast
Method Summary
WFBaseProvider getProvider (string $provider)
void init ()
string renderTable (array $sections, [array $htmlOptions = array()])
void renderTableElement ( $tag,  $content)
void renderTableRow ( $key,  $content)
void renderTableSection ( $tag,  $content)
void run ()
Methods
getProvider (line 192)

Factory method to load the forecast provider

  • return: Forecast provider class
  • throws: CDbException if provider not suppored
WFBaseProvider getProvider (string $provider)
  • string $provider: Forecast provider
init (line 143)

Initialises the widget

Registers the CSS file and sets the required forecast provider, loading it if required

void init ()
renderTable (line 214)

Renders the forecast table

  • return: The rendered table
string renderTable (array $sections, [array $htmlOptions = array()])
  • array $sections: sections of the table
  • array $htmlOptions: HTML options for the table
renderTableElement (line 270)
void renderTableElement ( $tag,  $content)
  • $tag
  • $content
renderTableRow (line 245)
void renderTableRow ( $key,  $content)
  • $key
  • $content
renderTableSection (line 227)
void renderTableSection ( $tag,  $content)
  • $tag
  • $content
run (line 166)

Display the forecast

The cached forecast is used if enabled and not expired

void run ()

Documentation generated on Tue, 13 Oct 2009 14:44:47 +0100 by phpDocumentor 1.4.2