[Phphtmllib-devel] SF.net SVN: phphtmllib:[3169] trunk/open2300/lib/modules/home/widgets
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2008-11-07 04:35:03
|
Revision: 3169 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3169&view=rev Author: hemna Date: 2008-11-07 04:34:59 +0000 (Fri, 07 Nov 2008) Log Message: ----------- added metar Modified Paths: -------------- trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc Added Paths: ----------- trunk/open2300/lib/modules/home/widgets/MetarTextCurrentConditions.inc Added: trunk/open2300/lib/modules/home/widgets/MetarTextCurrentConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/MetarTextCurrentConditions.inc (rev 0) +++ trunk/open2300/lib/modules/home/widgets/MetarTextCurrentConditions.inc 2008-11-07 04:34:59 UTC (rev 3169) @@ -0,0 +1,79 @@ +<?php +/** + * This file contains the CurrentConditions + * widget class. + */ + + + +class MetarTextCurrentConditions extends AjaxableHTMLWidget { + + /** + * This contains the current + * weatherDataObject for + * the conditions that you want to display + * + * @var weatherDataObject + */ + protected $wx; + + /** + * Class Constructor + * + */ + public function __construct(weatherDataObject $wx=null) { + parent::__construct(); + if ($wx == null) { + //we don't have the current conditions. + //we need to get them + $this->wx = weatherDataObject::find("1=1 order by datetime desc"); + } else { + $this->wx = $wx; + } + } + + public function get_content() { + + $metar = $GLOBALS['config']->get('station_name'); + + //get today's High, and today's Low so far. + $db = open2300DB::singleton(); + $today = date("Y-m-d"); + + $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, max(temp_out) as high from weather where datetime like :date", array(":date" => $today.'%')); + + $cur_date = new DateTime($this->wx->get_datetime()); + //$metar .= "<br>".$cur_date->format("dHi")."<br>"; + $cur_date->setTimezone(new DateTimeZone("UTC")); + $metar .= " ".$cur_date->format("dHi")."Z AUTO "; + + $outside_temp = $this->wx->get_temp_out(); + $dewpoint = $this->wx->get_dewpoint(); + $metar .= ""; + + //now do wind + $wind_dir = $this->wx->get_wind_direction(); + $wind_angle = $this->wx->get_wind_angle(); + $wind_speed = WXConversion::mph_to_knots($this->wx->get_wind_speed()); + + $metar .= sprintf("%3.0f",$wind_angle).sprintf("%02.0fKT ",$wind_speed); + + //we don't have sky conditions. + $metar .= "XXX "; + + //temperature and dew point + $metar .= WXConversion::fahrenheit_to_celsius($outside_temp, "%2.0f").'/'. + WXConversion::fahrenheit_to_celsius($dewpoint, "%2.0f"); + + //now pressure + $metar .= "A".$this->wx->get_rel_pressure()*100; + + //remarks section + $metar .= " RMK A02 "; + //rain in the last hour + $metar .= sprintf("P%0004.0f",($this->wx->get_rain_1h()*100)); + Log::singleton()->info($metar); + return $metar; + } +} +?> Modified: trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc 2008-10-06 23:28:29 UTC (rev 3168) +++ trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc 2008-11-07 04:34:59 UTC (rev 3169) @@ -39,7 +39,7 @@ //get today's High, and today's Low so far. $db = open2300DB::singleton(); $today = date("Y-m-d"); - $output = ""; + $output = ""; $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, max(temp_out) as high from weather where datetime like :date", array(":date" => $today.'%')); $low = $stmt->low; $high = $stmt->high; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |