Thread: [Phphtmllib-devel] SF.net SVN: phphtmllib:[3342] trunk/open2300/lib/modules/wxdate
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-02-22 04:12:28
|
Revision: 3342 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3342&view=rev Author: hemna Date: 2010-02-22 04:12:22 +0000 (Mon, 22 Feb 2010) Log Message: ----------- new dates Modified Paths: -------------- trunk/open2300/lib/modules/wxdate/page/WxDate.inc Added Paths: ----------- trunk/open2300/lib/modules/wxdate/widgets/ trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc Modified: trunk/open2300/lib/modules/wxdate/page/WxDate.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/page/WxDate.inc 2010-02-21 22:23:15 UTC (rev 3341) +++ trunk/open2300/lib/modules/wxdate/page/WxDate.inc 2010-02-22 04:12:22 UTC (rev 3342) @@ -30,21 +30,26 @@ * * @param TABLEtag object. */ - protected function main_block() { +// 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; +// } - $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 left_block() { + $div = new DIVtag(array("style" => "margin-top:20px"), new WxDateCalendar()); + return $div; } /** @@ -78,7 +83,8 @@ $this->add_css_link('/css/lightview/lightview.css'); $c = new Container(); - $c->add( H3tag::factory("Weather on ".date("l M d, Y", strtotime($this->wxdate))), + + $c->add( H3tag::factory("Weather on ".date("l M d, Y", strtotime($this->wxdate))), Brtag::factory(1), $right_div ); return $c; Added: trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc (rev 0) +++ trunk/open2300/lib/modules/wxdate/widgets/WxDateCalendar.inc 2010-02-22 04:12:22 UTC (rev 3342) @@ -0,0 +1,118 @@ +<?php + +class WxDateCalendar extends AjaxableHTMLWidget { + + protected $date = null; + protected $year = null; + protected $month = null; + protected $day = null; + + protected $current_date; + + private $cur_month = null; + + public function __construct($date = null) { + $this->current_date = date("Y-m-d"); + 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("n", $ts); + $this->day = date('j',$ts); + 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')); + + $days = $this->get_days(); + + $pn = array('«'=>'/weblog/archive/2004/Jul', '»'=>'/weblog/archive/2004/Sep'); + $pn = $this->get_prev_next_urls(); + + $div->add(Calendar::factory($this->year, $this->month, $days, 3, null, 0, $pn)); + + return $div; + } + + + protected function get_prev_next_urls() { + + $next_month_ts = strtotime("+1 month", strtotime($this->date)); + $prev_month_ts = strtotime("-1 month", strtotime($this->date)); + + $prev = RequestBuilder::build_url("WxDate", array("date" => date("Y-m-d", $prev_month_ts))); + $next = RequestBuilder::build_url("WxDate", array("date" => date("Y-m-d", $next_month_ts))); + + Log::singleton()->debug("date = ".$this->date." prev = ".$prev." next=".$next); + + if (!$this->is_current_month()) { + return $pn = array("«" => $prev, "»" => $next ); + } else { + return $pn = array("«" => $prev); + } + } + + protected function get_days() { + $dt = new DateTime(); + $days = array(); + + $cur_ts = strtotime($this->current_date); + $ts = strtotime($this->date); + + $cur_month = $this->is_current_month(); + $cur_day = date("d"); + + $num_days = $this->get_days_in_month($this->month, $this->year); + + if ($cur_month) { + $num_days = $cur_day; + } + + for ($x=1; $x<=$num_days; $x++) { + + if ($x == $this->day) { + $days[$x] = array(null, "selected-day"); + } else { + $date = $this->year."-".$this->month."-".$x; + $url = RequestBuilder::build_url("WxDate", array("date" => $date)); + $days[$x] = array($url, "linked-day"); + } + } + return $days; + } + + private function is_current_month() { + if (!is_null($this->cur_month)) { + return $this->cur_month; + } + + $date = date("Y-m"); + $cur_ts = strtotime($date."-01"); + $ts = strtotime($this->year."-".$this->month."-01"); + + if ($cur_ts == $ts) { + $this->cur_month = true; + } else { + $this->cur_month = false; + } + + return $this->cur_month; + } + + private function get_days_in_month($month, $year) { + $ts = strtotime("-1 day", strtotime($year."-".$month."-01")); + return date("d", $ts); + } + + +} +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <he...@us...> - 2010-02-22 06:46:22
|
Revision: 3352 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3352&view=rev Author: hemna Date: 2010-02-22 06:46:13 +0000 (Mon, 22 Feb 2010) Log Message: ----------- updates Modified Paths: -------------- trunk/open2300/lib/modules/wxdate/page/WxDate.inc 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 06:18:53 UTC (rev 3351) +++ trunk/open2300/lib/modules/wxdate/page/WxDate.inc 2010-02-22 06:46:13 UTC (rev 3352) @@ -44,10 +44,32 @@ } protected function left_block() { + global $config; + $div = new DIVtag(array("style" => "margin-top:0px; width: 320px;"), new WxDateCalendar(), BRtag::factory(2), new WxMonthData()); + + //only show the flash overlay if we + //have today's video file on disk + $curdate = date("ymd", strtotime($this->date)); + $filename = $config->get('videodir')."/".$curdate."/timelapse.flv"; + //$cam_title_div->add($filename); + if (file_exists($filename)) { + $url = '/video/player.swf?file=/video/'.$curdate.'/timelapse.flv&autostart=1'; + $obj = new ObjectTag(array("data" => $url, + "type" => "application/x-shockwave-flash", "quality" => "high", + "wmode" => "transparent", "pluginspage" => "http://www.adobe.com/go/getflashplayer", + "width" => "320", "height" => "240"), + '<param name="movie" value="'.$url.'"><param name="allowFullScreen" value="true">'); + + $cam_href = new Atag(array('href' => '/video/player.swf?file=/video/'.$curdate.'/timelapse.flv&autostart=1', 'class' => 'lightview', + 'rel' => 'flash', 'title' => 'TimeLapse :: '.$curdate.' :: width:640, height:480'), + "View Timelapse Video"); + + } + return $div; } Modified: trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc =================================================================== --- trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc 2010-02-22 06:18:53 UTC (rev 3351) +++ trunk/open2300/lib/modules/wxdate/widgets/WxMonthData.inc 2010-02-22 06:46:13 UTC (rev 3352) @@ -14,11 +14,11 @@ $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; + $this->ts = strtotime($this->date); + $this->year = date("Y", $this->ts); + $this->month = date("m", $this->ts); + $this->day = date('j', $this->ts); + $this->year_month = $this->year."-".$this->month; Log::Singleton()->debug("date=".$this->date." year = ".$this->year." month = ".$this->month." day = ".$this->day); } @@ -32,7 +32,7 @@ $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); + $title = DIVtag::factory('cctitle', "Wx conditions for ".date("F Y", $this->ts)); $div->add($title); $table = TABLEtag::factory("100%",0,2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |