[Phphtmllib-devel] SF.net SVN: phphtmllib:[3331] trunk/open2300/lib/modules/home
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-02-21 19:54:46
|
Revision: 3331 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3331&view=rev Author: hemna Date: 2010-02-21 19:54:38 +0000 (Sun, 21 Feb 2010) Log Message: ----------- made webcam it's own widget Modified Paths: -------------- trunk/open2300/lib/modules/home/page/HomePage.inc trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc Added Paths: ----------- trunk/open2300/lib/modules/home/widgets/WebCam.inc Modified: trunk/open2300/lib/modules/home/page/HomePage.inc =================================================================== --- trunk/open2300/lib/modules/home/page/HomePage.inc 2010-02-21 19:42:59 UTC (rev 3330) +++ trunk/open2300/lib/modules/home/page/HomePage.inc 2010-02-21 19:54:38 UTC (rev 3331) @@ -33,6 +33,7 @@ $script->add("Event.observe(window, 'load', start_updates);"); $container->add($script); + $this->add_js_link("/js/cal.js"); $left_div = new DIVtag(array('id'=> '')); @@ -59,29 +60,6 @@ PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </embed> </object>', -// '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" -// codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" -// WIDTH="140" -// HEIGHT="300" -// id="gauge" /> -// -//<PARAM NAME="movie" VALUE="/flash/gauge.swf?xml_source=index.php?target=my-humidity-flash-gauge" /> -//<PARAM NAME="quality" VALUE="high" /> -//<PARAM NAME="bgcolor" VALUE="#ffffff" /> -//<param name="allowScriptAccess" value="sameDomain" /> -//<EMBED src="/flash/gauge.swf?xml_source=index.php?target=my-humidity-flash-gauge" -// quality="high" -// bgcolor="#ffffff" -// WIDTH="140" -// HEIGHT="300" -// NAME="gauge" -// allowScriptAccess="sameDomain" -// swLiveConnect="true" -// TYPE="application/x-shockwave-flash" -// PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> -//</EMBED> -//</OBJECT> -// ', '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="140" @@ -217,33 +195,11 @@ 480,320); $radar_img->set_id('idRadarImg'); - $this->add_js_link('/js/lightview/lightview.js'); - $this->add_css_link('/css/lightview/lightview.css'); - - $curdate = date("Ymd"); - - $cam_img = new IMGtag(array('id' => 'idCamImg', 'src' => 'cam/cam.jpg', 'width' => '480', height => '320')); - $cam_img_div = new DIVtag(array('id' => 'idCamImgDiv'), $cam_img); - - - $cam_title_div = new DIVtag(array('id' => 'idCamTitle', 'class' => 'camtitle') ); - - //only show the flash overlay if we - //have today's video file on disk - $filename = "/home/waboring/wx.hemna.com/htdocs/video/".$curdate."/timelapse.flv"; - if (file_exists($filename)) { - $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"); - $cam_href->set_collapse(true); - $cam_title_div->add($cam_href); - $filetime = date ("H:i:s", filemtime($filename)); - $cam_title_div->add(" "); - $cam_title_div->add(new SPANtag(array('style' => 'font-size: .7em'), "(Updated ".$filetime." )")); - } - - $cam_div = new DIVtag(array('id' => 'idCamDiv', 'style' => 'padding-bottom:10px;margin-bottom:5px;'), $cam_title_div, $cam_img_div); + $this->add_css_link('/css/lightview/lightview.css'); + + $this->add_js_link('http://yui.yahooapis.com/combo?2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js&2.8.0r4/build/calendar/calendar-min.js'); + $this->add_css_link('http://yui.yahooapis.com/combo?2.8.0r4/build/calendar/assets/skins/sam/calendar.css'); $radar_div = new DIVtag(array('id' => 'idRadardiv'),$radar_img); @@ -251,7 +207,7 @@ $table->add_row(new TDtag(array('style' => 'vertical-align:top;width:510px;'),$right_div), new TDtag(array('style' => 'vertical-align:top;padding-left:8px;'), - $cam_div, $radar_div)); + new WebCam(), $radar_div)); return $table; } Modified: trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc 2010-02-21 19:42:59 UTC (rev 3330) +++ trunk/open2300/lib/modules/home/widgets/CurrentConditions.inc 2010-02-21 19:54:38 UTC (rev 3331) @@ -96,9 +96,9 @@ $table->add_row("Relative Humidity : ", $this->wx->get_rel_hum_out().' %'); //wind - $table->add_row("Wind : ",new TDtag(array(), SPANtag::factory('',"From the ".$this->wx->get_wind_direction()." ".$this->wx->get_wind_angle(). "@".$this->wx->get_wind_speed().'mph'), + $table->add_row("Wind : ",new TDtag(array(), SPANtag::factory('',"From the ".$this->wx->get_wind_direction()." ".$this->wx->get_wind_speed().'mph@'.$this->wx->get_wind_angle()), $this->get_wind_angle_image($this->wx->get_wind_angle()), - SPANtag::factory('',"Peak winds ".$this->peak_wind['direction']." ".$this->peak_wind['angle'].'@'.$this->peak_wind['speed'].'mph '.$this->peak_wind['time']))); + SPANtag::factory('',"Peak winds ".$this->peak_wind['direction']." ".$this->peak_wind['speed'].'mph@'.$this->peak_wind['angle']." ".$this->peak_wind['time']))); $table->add_row(" ", " "); $pressure = $this->wx->get_rel_pressure(); Added: trunk/open2300/lib/modules/home/widgets/WebCam.inc =================================================================== --- trunk/open2300/lib/modules/home/widgets/WebCam.inc (rev 0) +++ trunk/open2300/lib/modules/home/widgets/WebCam.inc 2010-02-21 19:54:38 UTC (rev 3331) @@ -0,0 +1,100 @@ +<?php + + +class WebCam extends AjaxableHTMLWidget { + + const CACHE_KEY = "webcamcaldates"; + + protected $cal_dates; + + public function __construct() { + parent::__construct(); + + $cache = FileCache::singleton(); + + //determine which dates should be enabled + //for the calendar + $this->cal_dates = $cache->get(WebCam::CACHE_KEY); + if (!$this->cal_dates) { + $this->find_valid_calendar_dates(); + $cache->set(WebCam::CACHE_KEY, $this->cal_dates, 3600); + } else { + $log = Log::singleton(); + $log->info("using calendar cache value"); + } + + + } + + + public function get_content() { + global $config; + + $curdate = date("Ymd"); + + $cam_title_div = new DIVtag(array('id' => 'idWebCamTitle')); + + + //only show the flash overlay if we + //have today's video file on disk + $filename = $config->get('videodir')."/".$curdate."/timelapse.flv"; + //$cam_title_div->add($filename); + if (file_exists($filename)) { + $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"); + $cam_href->set_collapse(true); + $cam_title_div->add($cam_href); + $filetime = date("H:i:s", filemtime($filename)); + $cam_title_div->add(" "); + $nowtime = date("H:i:s"); + $cam_title_div->add(new SPANtag(array('id' => 'idWebCamFlasUpdate', 'style' => 'font-size: .7em'), "(Updated ".$filetime." )")); + } + + //$cam_title_div->add($cal_div, $cam_calendar_icon); + + $cam_img = new IMGtag(array('id' => 'idWebCamImg', 'src' => 'cam/cam.jpg', 'width' => '480', height => '320')); + $cam_img_div = new DIVtag(array('id' => 'idCamImgDiv'), $cam_img); + + $cam_div = new DIVtag(array('id' => $this->get_ajax_replacement_divid().'Contents', + 'style' => 'padding-bottom:10px;margin-bottom:5px;', + 'class' => 'yui-skin-sam'), $cam_title_div, $cam_img_div); + + return $cam_div; + } + + + /** + * This walks the video dir and figues out what + * directories that coorespond to dates have + * valid timelapse.flv files. These dirs/dates + * will be enabled in the calendar popup. + * + */ + private function find_valid_calendar_dates() { + global $config; + $dates = array(); + $log = Log::singleton(); + + $videodir = $config->get('videodir'); + if (file_exists($videodir)) { + if ($dir = opendir($videodir)) { + while (($file = readdir($dir)) !== false) { + if ($file != "." && $file != ".." && $file != "player.swf" && $file != ".svn") { + $log->info("::find_valid_calendar_dates() - found file ".$file); + //now check to see if it contains timelapse.flv + if (file_exists($videodir."/".$file."/timelapse.flv")) { + $dates[] = $file; + } + } + } + closedir($dir); + } + } + sort($dates); + $this->cal_dates = $dates; + $log->info(var_export($this->cal_dates, true)); + + } +} +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |