[Phphtmllib-devel] SF.net SVN: phphtmllib:[3349] trunk/open2300/lib/modules/wxdate
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-02-22 06:18:02
|
Revision: 3349 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3349&view=rev Author: hemna Date: 2010-02-22 06:17:56 +0000 (Mon, 22 Feb 2010) Log Message: ----------- month data Modified Paths: -------------- trunk/open2300/lib/modules/wxdate/page/WxDate.inc trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc Added Paths: ----------- trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc Modified: trunk/open2300/lib/modules/wxdate/page/WxDate.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/page/WxDate.inc 2010-02-22 04:33:50 UTC (rev 3348) +++ trunk/open2300/lib/modules/wxdate/page/WxDate.inc 2010-02-22 06:17:56 UTC (rev 3349) @@ -23,32 +23,31 @@ } - /** - * We override this method to automatically - * break up the main block into a - * left block and a right block - * - * @param TABLEtag object. - */ -// protected function main_block() { -// -// $main = new DIVtag(array("id" => "centercontent", -// "style" => "width: 510px; margin-left: auto; margin-right:auto;")); -// -// -// $table = TABLEtag::factory("100%", 0); -// -// $table->add_row( TDtag::factory("rightblock", "", $this->content_block() )); -// -// $table->add_row(new TDtag(array("colspan"=> 2), -// $this->footer_block())); -// $main->add( $table ); -// -// return $main; -// } + + protected function main_block() { + + $main = new DIVtag(array("id" => "maincontent", + "style" => "width: 810px; margin-left: auto; margin-right:auto;")); + $main->set_id("maincontent"); + + $table = TABLEtag::factory("100%", 0); + + $table->add_row( TDtag::factory("leftblock", "", $this->left_block() ), + TDtag::factory("rightblock", "", $this->content_block() )); + + $table->add_row(new TDtag(array("colspan"=> 2), + $this->footer_block())); + $main->add( $table ); + + return $main; + } + protected function left_block() { - $div = new DIVtag(array("style" => "margin-top:0px"), new WxDateCalendar()); + $div = new DIVtag(array("style" => "margin-top:0px; width: 320px;"), + new WxDateCalendar(), + BRtag::factory(2), + new WxMonthData()); return $div; } Modified: trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc 2010-02-22 04:33:50 UTC (rev 3348) +++ trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc 2010-02-22 06:17:56 UTC (rev 3349) @@ -12,6 +12,7 @@ private $cur_month = null; public function __construct($date = null) { + parent::__construct(); $this->current_date = date("Y-m-d"); if ($date == null) { $this->date = Request::singleton()->get("date", date("Y-m-d")); Added: trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc (rev 0) +++ trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc 2010-02-22 06:17:56 UTC (rev 3349) @@ -0,0 +1,80 @@ +<?php + + +class WxMonthData extends AjaxableHTMLWidget { + + public function __construct($date = null) { + parent::__construct(); + if ($date == null) { + $this->date = Request::singleton()->get("date", date("Y-m-d")); + if (empty($this->date) || is_null($this->date)) { + $this->date = date("Y-m-d"); + } + } else { + $this->date = $date; + } + + $ts = strtotime($this->date); + $this->year = date("Y", $ts); + $this->month = date("m", $ts); + $this->day = date('j',$ts); + $this->year_month = $this->year."-".$this->month; + + Log::Singleton()->debug("date=".$this->date." year = ".$this->year." month = ".$this->month." day = ".$this->day); + } + + + public function get_content() { + $div = new DIVtag(array('id'=>$this->get_ajax_replacement_divid().'contents')); + + $db = open2300DB::singleton(); + + $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, max(temp_out) as high from weather where datetime like :date", + array(":date" => $this->year_month.'%')); + + $title = DIVtag::factory('cctitle', "Wx conditions on ".$this->year_month); + $div->add($title); + + $table = TABLEtag::factory("100%",0,2); + + $table->add_row("Temp Month", "High/Low : ".$stmt->high." F /".$stmt->low." F" ); + + $stmt = $db->queryBindOneRowCache("Select min(temp_out) as low, max(temp_out) as high from weather where datetime like :date", + array(":date" => $this->date.'%')); + + $table->add_row("Temp Day", "High/Low : ".$stmt->high." F /".$stmt->low." F" ); + + + $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->queryBindOneRowCache($sql, array(":date" => $this->year_month.'%', ":date2" => $this->year_month.'%')); + + //var_dump($stmt); + $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,8); + + $table->add_row("Peak Wind Month", $this->peak_wind['direction']." ".$this->peak_wind['speed'].'mph@'.$this->peak_wind['angle']." ".$this->peak_wind['time']); + + $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->queryBindOneRowCache($sql, array(":date" => $this->date.'%', ":date2" => $this->date.'%')); + + //var_dump($stmt); + $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); + + $table->add_row("Peak Wind Day", $this->peak_wind['direction']." ".$this->peak_wind['speed'].'mph@'.$this->peak_wind['angle']." ".$this->peak_wind['time']); + + $div->add($table); + return $div; + } + +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |