[Phphtmllib-devel] SF.net SVN: phphtmllib:[3223] trunk/open2300/lib/modules/home/widgets
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2009-02-22 18:37:34
|
Revision: 3223 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3223&view=rev Author: hemna Date: 2009-02-22 18:37:30 +0000 (Sun, 22 Feb 2009) Log Message: ----------- try and get rain totals to be accurate for the year Modified Paths: -------------- trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc Modified: trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc 2009-02-22 17:22:00 UTC (rev 3222) +++ trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc 2009-02-22 18:37:30 UTC (rev 3223) @@ -16,14 +16,18 @@ * @var weatherDataObject */ protected $wx; + + protected $rain_total; + + protected $temp_low_high = array("low" => 0, + "high" => 0); /** * Class Constructor * */ public function __construct(weatherDataObject $wx=null) { - $log = Log::singleton(); - $log->info("Updating CurrentConditions"); + $log = Log::singleton(); parent::__construct(); if ($wx == null) { //we don't have the current conditions. @@ -32,17 +36,25 @@ } else { $this->wx = $wx; } - } - - public function get_content() { - //get today's High, and today's Low so far. + //load min max temps $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.'%')); - $low = $stmt->low; - $high = $stmt->high; + $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, max(temp_out) as high from weather where datetime like :date", + array(":date" => $today.'%')); + $this->temp_low_high["low"] = $stmt->low; + $this->temp_low_high["high"] = $stmt->high; + $year = date("Y"); + $stmt = $db->queryBindOneRowCache("Select rain_total from weather where datetime like :date order by datetime desc limit 0,1", + array(":date" => $year.'%')); + $year_rain_start = $stmt->rain_total; + + $this->rain_total = sprintf("%0.2f", $year_rain_start - $this->wx->get_rain_total()); + } + + public function get_content() { + $div = new DIVtag(array('id'=>$this->get_ajax_replacement_divid().'contents')); //build the title @@ -64,7 +76,7 @@ new SPANtag(array('id' => 'idTempK','style' => 'font-weight:bold;'),WXConversion::fahrenheit_to_kelvin($outside_temp)), " K", BRtag::factory(), $this->wx->get_forecast(), new DIVtag(array('style' => 'padding-top:5px;'), 'Feels like '.$this->wx->get_wind_chill()." F"), - new DIVtag(array('style' => 'padding-top:5px;'), $high.' F / '.$low.' F High/Low'))); + new DIVtag(array('style' => 'padding-top:5px;'), $this->temp_low_high["low"].' F / '.$this->temp_low_high["high"].' F Low/High'))); $table->add_row("Relative Humidity : ", $this->wx->get_rel_hum_out().' %'); @@ -77,7 +89,7 @@ $table->add_row("Pressure : ", $pressure. ' inHG / '.WXConversion::inchmercury_to_millibars($pressure). ' mbar'); - $table->add_row('Rainfall : ',$this->wx->get_rain_1h().' last hour '.$this->wx->get_rain_24h().' in 24 hours '.$this->wx->get_rain_total().' total.'); + $table->add_row('Rainfall : ',$this->wx->get_rain_1h().' last hour '.$this->wx->get_rain_24h().' in 24 hours '.$this->wx->get_rain_total().' : '.$this->rain_total.' total.'); $table->add_row(" ", " "); $inside_temp = $this->wx->get_temp_in(); Modified: trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc 2009-02-22 17:22:00 UTC (rev 3222) +++ trunk/open2300/lib/modules/home/widgets/TextCurrentConditions.inc 2009-02-22 18:37:30 UTC (rev 3223) @@ -6,50 +6,16 @@ -class TextCurrentConditions extends AjaxableHTMLWidget { +class TextCurrentConditions extends CurrentConditions { /** * the object's controller target * */ const ID="text"; - - /** - * 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) { - $log = Log::singleton(); - $log->info("TextCurrentConditions"); - 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() { - //get today's High, and today's Low so far. - $db = open2300DB::singleton(); - $today = date("Y-m-d"); - $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; - //build the title //$title = DIVtag::factory('cctitle', Atag::factory(AjaxRequestBuilder::build_replace_url('CurrentConditions', array(), $this->get_ajax_replacement_divid()), 'Current Conditions', 'linkrefresh')); //now add the update block @@ -72,7 +38,7 @@ $output .= "Pressure : ". $pressure. ' inHG / '.WXConversion::inchmercury_to_millibars($pressure). ' mbar '; //rainfall - $output .= 'Rainfall : '.$this->wx->get_rain_1h().' last hour '.$this->wx->get_rain_24h().' in 24 hours '.$this->wx->get_rain_total().' total. '; + $output .= 'Rainfall : '.$this->wx->get_rain_1h().'" last hour '.$this->wx->get_rain_24h().'" in 24 hours '.$this->rain_total.'" total. '; //inside temp $inside_temp = $this->wx->get_temp_in(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |