[Phphtmllib-devel] SF.net SVN: phphtmllib:[3368] trunk/open2300/lib
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-02-26 07:10:19
|
Revision: 3368 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3368&view=rev Author: hemna Date: 2010-02-26 07:10:13 +0000 (Fri, 26 Feb 2010) Log Message: ----------- added new ticker at the top Modified Paths: -------------- trunk/open2300/lib/autoload.inc trunk/open2300/lib/core/page/open2300Page.inc Added Paths: ----------- trunk/open2300/lib/modules/home/widgets/TickerConditions.inc Modified: trunk/open2300/lib/autoload.inc =================================================================== --- trunk/open2300/lib/autoload.inc 2010-02-26 07:09:14 UTC (rev 3367) +++ trunk/open2300/lib/autoload.inc 2010-02-26 07:10:13 UTC (rev 3368) @@ -1,7 +1,7 @@ <?php /** * This is an auto-generated file. Please do not modify! - * Generated on 2010-02-21T20:41:36-08:00 by AutoloadGenerator + * Generated on 2010-02-25T19:54:06-08:00 by AutoloadGenerator * * @package open2300 */ @@ -154,6 +154,7 @@ 'InfoTable'=>'external/phphtmllib/src/widgets/InfoTable.inc', 'InfoTableCSS'=>'external/phphtmllib/src/widgets/css/InfoTableCSS.inc', 'IP'=>'external/phphtmllib/src/misc/IP.inc', +'JSONWidget'=>'external/phphtmllib/src/widgets/JSONWidget.inc', 'Log'=>'external/phphtmllib/src/logging/Log.inc', 'LogEvent'=>'external/phphtmllib/src/logging/LogEvent.inc', 'LogFormatter'=>'external/phphtmllib/src/logging/LogFormatter.inc', @@ -234,6 +235,7 @@ 'TextCurrentConditions'=>'modules/home/widgets/TextCurrentConditions.inc', 'TextNav'=>'external/phphtmllib/src/widgets/TextNav.inc', 'TextNavCSS'=>'external/phphtmllib/src/widgets/css/TextNavCSS.inc', +'TickerConditions'=>'modules/home/widgets/TickerConditions.inc', 'Timer'=>'external/phphtmllib/src/misc/Timer.inc', 'TreeItemWidget'=>'external/phphtmllib/src/widgets/TreeItemWidget.inc', 'Validator'=>'external/phphtmllib/src/validation/Validator.inc', @@ -314,6 +316,7 @@ 'text'=>'TextCurrentConditions', 'text-c-s-s-nav'=>'TextCSSNav', 'text-nav'=>'TextNav', +'ticker'=>'TickerConditions', 'tree-item-w'=>'TreeItemWidget', 'vertical-c-s-s-nav-table'=>'VerticalCSSNavTable', 'weather-dl'=>'WeatherDataListPage', @@ -395,6 +398,7 @@ 'TextCurrentConditions'=>'text', 'TextCSSNav'=>'text-c-s-s-nav', 'TextNav'=>'text-nav', +'TickerConditions'=>'ticker', 'TreeItemWidget'=>'tree-item-w', 'VerticalCSSNavTable'=>'vertical-c-s-s-nav-table', 'WeatherDataListPage'=>'weather-dl', Modified: trunk/open2300/lib/core/page/open2300Page.inc =================================================================== --- trunk/open2300/lib/core/page/open2300Page.inc 2010-02-26 07:09:14 UTC (rev 3367) +++ trunk/open2300/lib/core/page/open2300Page.inc 2010-02-26 07:10:13 UTC (rev 3368) @@ -42,6 +42,9 @@ const ID_NAV = 'leftBlock'; protected $centering_width = "500px"; + + + protected $include_ticker = true; /** * This is the constructor. @@ -122,20 +125,33 @@ $this->add_js_link( 'http://ajax.googleapis.com/ajax/libs/scriptaculous/1/scriptaculous.js' ); $this->add_js_link( '/js/ajax.js' ); $this->add_js_link( '/js/main.js' ); + $this->add_js_link( '/js/ticker.js' ); } protected function header_block() { - $header = new Container(); + $header = new Container(); + + + if ($this->include_ticker) { + $script = SCRIPTtag::factory(); + $script->add("Event.observe(window, 'load', start_ticker);"); + $header->add($script); + } + $header->add( new DIVtag(array('id' => 'idPageHeadText'),"Hemna's Weather Station"), new DIVtag(array('id' => 'idPageSubHeadText'),"Pilot Hill, CA") ); - $table = TABLEtag::factory("1024",0,0,0,"center"); + $table = TABLEtag::factory("1024",0,0,0,"center"); - $table->add_row(new TDtag(array("id" => "pageheader"), + $table->add_row(new TDtag(array("id" => "headtopleft"), "Pilot Hill, CA Weather"), + new TDtag(array("id" => "headtopcenter"), "something"), + new TDtag(array("id" => "headtopright"), "nothing")); + + $table->add_row(new TDtag(array("id" => "pageheader", "colspan" => "3"), $header)); - $table->add_row(new TDtag(array('id' => self::ID_MENU), $this->menu_block())); + $table->add_row(new TDtag(array('id' => self::ID_MENU, "colspan" => "3"), $this->menu_block())); return $table; } Added: trunk/open2300/lib/modules/home/widgets/TickerConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/TickerConditions.inc (rev 0) +++ trunk/open2300/lib/modules/home/widgets/TickerConditions.inc 2010-02-26 07:10:13 UTC (rev 3368) @@ -0,0 +1,140 @@ +<?php +/** + * This file contains the CurrentConditions + * widget class. + */ + + + +class TickerConditions extends JSONWidget { + + const ID = "ticker"; + + /** + * This contains the current + * weatherDataObject for + * the conditions that you want to display + * + * @var weatherDataObject + */ + protected $wx; + + protected $rain_total; + + protected $temp_low_high = array("low" => 0, + "high" => 0); + + /** + * Class Constructor + * + */ + public function init() { + $log = Log::singleton(); + $hots = "<span class=\"hot\">"; + $hote = "</span>"; + $colds = "<span class=\"cold\">"; + $colde = "</span>"; + + + 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 limit 0,1"); + } else { + $this->wx = $wx; + } + + //load min max temps + $db = open2300DB::singleton(); + $today = date("Y-m-d"); + + //TEMPERATURE + $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, datetime from weather where datetime like :date", + array(":date" => $today.'%'), 60*5); + $this->temp_low_high["low"] = $stmt->low; + $this->temp_low_high["low_str"] = $colds.$stmt->low. "°F".$colde." at " . substr($stmt->datetime,10); + + $stmt = $db->queryBindOneRowCache("Select max(temp_out) as high, datetime from weather where datetime like :date", + array(":date" => $today.'%'), 60*5); + + $this->temp_low_high["high"] = $stmt->high; + $this->temp_low_high["high_str"] = $hots.$stmt->high . "°F".$hote." at " . substr($stmt->datetime,10); + + //HUMIDITY + $stmt = $db->queryBindOneRowCache("Select max(rel_hum_out) as high, datetime from weather where datetime like :date", + array(":date" => $today.'%'), 60*5); + + $this->temp_low_high["high_hum"] = $stmt->high; + $this->temp_low_high["high_hum_str"] = $hots.$stmt->high . "%".$hote." at " . substr($stmt->datetime,10); + + $stmt = $db->queryBindOneRowCache("Select min(rel_hum_out) as low, datetime from weather where datetime like :date", + array(":date" => $today.'%'), 60*5); + + $this->temp_low_high["low_hum"] = $stmt->low; + $this->temp_low_high["low_hum_str"] = $colds.$stmt->low . "%".$colde." at " . substr($stmt->datetime,10); + + + $year = date("Y"); + $stmt = $db->queryBindOneRowCache("Select rain_total from weather where datetime like :date order by datetime asc limit 0,1", + array(":date" => $year.'%')); + $year_rain_start = $stmt->rain_total; + + $this->rain_total = sprintf("%0.2f", $this->wx->get_rain_total() - $year_rain_start); + + + + //WIND + $stmt = $db->queryBindOneRowCache("Select avg(wind_speed) as average from weather where datetime like :date", + array(":date" => $today.'%'), 60*5); + $this->wind['average'] = sprintf("%0.2f",$stmt->average); + + //get the peak winds + //$db->set_debug_flag(true); + $sql = "select datetime,wind_speed, wind_angle, wind_direction from weather where ". + "wind_speed = (select max(wind_speed) from weather where datetime like :date) ". + "and datetime like :date2"; + $stmt = $db->queryBindOneRow($sql, + array(":date" => $today.'%', + ":date2" => $today.'%')); + $log->debug(var_export($stmt,true)); + $this->peak_wind['speed'] = $stmt->wind_speed; + $this->peak_wind['angle'] = $stmt->wind_angle; + $this->peak_wind['direction'] = $stmt->wind_direction; + $this->peak_wind['time'] = substr($stmt->datetime,10); + $log->debug("peak wind was ".$stmt->wind_speed); + } + + + + public function build_object() { + + $outside_temp = $this->wx->get_temp_out(); + $outside_tempC = WXConversion::fahrenheit_to_celsius($outside_temp); + + + $data = array(); + //the middle td + $data["middle"] = array("Last Update: ".$this->wx->get_datetime(), + "Low Temp: ".$this->temp_low_high["low_str"], + "High Temp: ".$this->temp_low_high["high_str"], + "Average Wind: ".$this->wind['average']."mph", + "Peak Wind ".$this->peak_wind['direction']." ". + $this->peak_wind['speed'].'mph@'.$this->peak_wind['angle']. + " ".$this->peak_wind['time'], + "Low Humidity: ".$this->temp_low_high["low_hum_str"], + "High Humidity: ".$this->temp_low_high["high_hum_str"]); + + //the right td + $data["right"] = array(date("G:i:s"), + $outside_temp."°F / ".$outside_tempC."°C", + $this->wx->get_wind_direction()." ".$this->wx->get_wind_speed().'mph@'.$this->wx->get_wind_angle(), + $this->wx->get_rel_pressure()." inHG", + "Humidity: ".$this->wx->get_rel_hum_out().'%', + "Rain 1h: ".$this->wx->get_rain_1h(), + "Rain 24h: ".$this->wx->get_rain_24h(), + "Rain Year: ".$this->rain_total); + + return $data; + } +} +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |