[Phphtmllib-devel] SF.net SVN: phphtmllib:[3261] trunk/open2300/lib/modules
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2009-10-14 07:33:25
|
Revision: 3261 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3261&view=rev Author: hemna Date: 2009-10-14 07:33:16 +0000 (Wed, 14 Oct 2009) Log Message: ----------- added rain gauges Modified Paths: -------------- trunk/open2300/lib/modules/graphs/gauge/myHumidityFlashGauge.php trunk/open2300/lib/modules/graphs/gauge/myTemperatureFlashGauge.php trunk/open2300/lib/modules/home/page/HomePage.inc Added Paths: ----------- trunk/open2300/lib/modules/graphs/gauge/myRainFlashGauge.php Modified: trunk/open2300/lib/modules/graphs/gauge/myHumidityFlashGauge.php =================================================================== --- trunk/open2300/lib/modules/graphs/gauge/myHumidityFlashGauge.php 2009-10-14 02:14:47 UTC (rev 3260) +++ trunk/open2300/lib/modules/graphs/gauge/myHumidityFlashGauge.php 2009-10-14 07:33:16 UTC (rev 3261) @@ -10,8 +10,8 @@ protected $data_object; public function __construct() { - parent::__construct(); - $this->xml = <<<EOL + parent::__construct(); + $this->xml = <<<EOL <gauge> <!-- humidity design --> @@ -51,7 +51,7 @@ //var_dump($today); //$today = "2009-02-15"; $this->date = $today; - $this->do = weatherDataObject::find("1=1 order by datetime desc"); + $this->do = weatherDataObject::find("1=1 order by datetime desc limit 0,1"); $this->getMinMaxHumidity($today); } Added: trunk/open2300/lib/modules/graphs/gauge/myRainFlashGauge.php =================================================================== --- trunk/open2300/lib/modules/graphs/gauge/myRainFlashGauge.php (rev 0) +++ trunk/open2300/lib/modules/graphs/gauge/myRainFlashGauge.php 2009-10-14 07:33:16 UTC (rev 3261) @@ -0,0 +1,83 @@ +<?php + +class myRainFlashGauge extends myFlashGauge { + + + protected $xml = ""; + + protected $date; + + protected $data_object; + + protected $mode = ""; + protected $rain_amount = 0; + + public function __construct() { + parent::__construct(); + + $this->xml = <<<EOL +<gauge> + + <!-- rain gauge design --> + <rect x='40' y='46' width='56' height='208' fill_color='000066' line_thickness='8' line_color='333333' /> + <text x='0' y='0' width='136' size='14' align='center' color='999999'>XX_DESC_XX</text> + <text x='12' y='26' width='200' size='14' color='cccccc'>in in</text> + +<line x1='100' y1='250' x2='104' y2='250' thickness='2' color='666666' /><text x='105' y='242' width='30' align='left' size='12' color='999999'>0</text><line x1='100' y1='230' x2='104' y2='230' thickness='2' color='666666' /><text x='105' y='222' width='30' align='left' size='12' color='999999'>1</text><line x1='100' y1='210' x2='104' y2='210' thickness='2' color='666666' /><text x='105' y='202' width='30' align='left' size='12' color='999999'>2</text><line x1='100' y1='190' x2='104' y2='190' thickness='2' color='666666' /><text x='105' y='182' width='30' align='left' size='12' color='999999'>3</text><line x1='100' y1='170' x2='104' y2='170' thickness='2' color='666666' /><text x='105' y='162' width='30' align='left' size='12' color='999999'>4</text><line x1='100' y1='150' x2='104' y2='150' thickness='2' color='666666' /><text x='105' y='142' width='30' align='left' size='12' color='999999'>5</text><line x1='100' y1='130' x2='104' y2='130' thickness='2' color='666666' /><text x='105' y='122' width='30' align='left' size='12' color='999999'>6</text><line x1='100' y1='110' x2='104' y2='110' thickness='2' color='666666' /><text x='105' y='102' width='30' align='left' size='12' color='999999'>7</text><line x1='100' y1='90' x2='104' y2='90' thickness='2' color='666666' /><text x='105' y='82' width='30' align='left' size='12' color='999999'>8</text><line x1='100' y1='70' x2='104' y2='70' thickness='2' color='666666' /><text x='105' y='62' width='30' align='left' size='12' color='999999'>9</text><line x1='100' y1='50' x2='104' y2='50' thickness='2' color='666666' /><text x='105' y='42' width='30' align='left' size='12' color='999999'>10</text><line x1='32' y1='250' x2='36' y2='250' thickness='2' color='666666' /><text x='0' y='242' width='30' align='right' size='12' color='999999'>0</text><line x1='32' y1='230' x2='36' y2='230' thickness='2' color='666666' /><text x='0' y='222' width='30' align='right' size='12' color='999999'>1</text><line x1='32' y1='210' x2='36' y2='210' thickness='2' color='666666' /><text x='0' y='202' width='30' align='right' size='12' color='999999'>2</text><line x1='32' y1='190' x2='36' y2='190' thickness='2' color='666666' /><text x='0' y='182' width='30' align='right' size='12' color='999999'>3</text><line x1='32' y1='170' x2='36' y2='170' thickness='2' color='666666' /><text x='0' y='162' width='30' align='right' size='12' color='999999'>4</text><line x1='32' y1='150' x2='36' y2='150' thickness='2' color='666666' /><text x='0' y='142' width='30' align='right' size='12' color='999999'>5</text><line x1='32' y1='130' x2='36' y2='130' thickness='2' color='666666' /><text x='0' y='122' width='30' align='right' size='12' color='999999'>6</text><line x1='32' y1='110' x2='36' y2='110' thickness='2' color='666666' /><text x='0' y='102' width='30' align='right' size='12' color='999999'>7</text><line x1='32' y1='90' x2='36' y2='90' thickness='2' color='666666' /><text x='0' y='82' width='30' align='right' size='12' color='999999'>8</text><line x1='32' y1='70' x2='36' y2='70' thickness='2' color='666666' /><text x='0' y='62' width='30' align='right' size='12' color='999999'>9</text><line x1='32' y1='50' x2='36' y2='50' thickness='2' color='666666' /><text x='0' y='42' width='30' align='right' size='12' color='999999'>10</text> + + <!-- rain gauge pointer animated only if rainfall has changed--> + <scale x='44' y='250' start_scale='0' end_scale='XX_VAL_XX' direction='vertical' step='1' shake_span='0' shake_frequency='0' shadow_alpha='0'> + <rect x='44' y='50' width='48' height='200' fill_color='0000ff' /> + </scale> + + <!-- current rainfall text --> + <text x='40' y='260' width='56' size='14' align='center' color='cccccc'>XX_CURR_XXin</text> + + <update url='/index.php?target=my-rain-flash-gauge&mode=XX_MODE_XX' delay='10' delay_type='1' /> + +</gauge> +EOL; + + } + + protected function load_data() { + $this->mode = Request::singleton()->get("mode"); + + $today = date("Y-m-d"); + $current_do = weatherDataObject::find("1=1 order by datetime desc limit 0,1"); + + switch ($this->mode) { + case "1hr": + $this->rain_amount = $current_do->get_rain_1h(); + $this->desc = "1 H R R A I N"; + break; + + case "24hr": + $this->rain_amount = $current_do->get_rain_24h(); + $this->desc = "24 H R R A I N"; + break; + + case "total": + $this->rain_amount = $current_do->get_rain_total(); + $this->desc = "Y E A R R A I N"; + break; + } + } + + + protected function translate_num($num) { + $absolute_low = -1; + $absolute_high = -200; + return (-10*$num); + } + + public function render() { + $search_arr = array("XX_CURR_XX", "XX_VAL_XX", "XX_MODE_XX", "XX_DESC_XX"); + $replace_arr = array($this->rain_amount, $this->translate_num($this->rain_amount), + $this->mode, $this->desc); + + $output = str_replace($search_arr, $replace_arr, $this->xml); + echo $output; + } +} +?> \ No newline at end of file Modified: trunk/open2300/lib/modules/graphs/gauge/myTemperatureFlashGauge.php =================================================================== --- trunk/open2300/lib/modules/graphs/gauge/myTemperatureFlashGauge.php 2009-10-14 02:14:47 UTC (rev 3260) +++ trunk/open2300/lib/modules/graphs/gauge/myTemperatureFlashGauge.php 2009-10-14 07:33:16 UTC (rev 3261) @@ -71,7 +71,7 @@ //var_dump($today); //$today = "2009-02-15"; $this->date = $today; - $this->do = weatherDataObject::find("1=1 order by datetime desc"); + $this->do = weatherDataObject::find("1=1 order by datetime desc limit 0,1"); $this->getMinMaxTemps($today); } Modified: trunk/open2300/lib/modules/home/page/HomePage.inc =================================================================== --- trunk/open2300/lib/modules/home/page/HomePage.inc 2009-10-14 02:14:47 UTC (rev 3260) +++ trunk/open2300/lib/modules/home/page/HomePage.inc 2009-10-14 07:33:16 UTC (rev 3261) @@ -88,8 +88,81 @@ return $container; } + + protected function get_rain_div() { + $rain_div = new DIVtag(array('id'=> 'idRain','style'=> 'padding-top:5px;')); + + $rain_div->add('<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-rain-flash-gauge%26mode%3D1hr" /> +<PARAM NAME="quality" VALUE="high" /> +<PARAM NAME="bgcolor" VALUE="#000000" /> +<param name="allowScriptAccess" value="sameDomain" /> +<EMBED src="/flash/gauge.swf?xml_source=index.php?target=my-rain-flash-gauge%26mode%3D1hr" + quality="high" + bgcolor="#000000" + 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" + HEIGHT="300" + id="gauge" /> +<PARAM NAME="movie" VALUE="/flash/gauge.swf?xml_source=index.php?target=my-rain-flash-gauge%26mode%3D24hr" /> +<PARAM NAME="quality" VALUE="high" /> +<PARAM NAME="bgcolor" VALUE="#000000" /> +<param name="allowScriptAccess" value="sameDomain" /> +<EMBED src="/flash/gauge.swf?xml_source=index.php?target=my-rain-flash-gauge%26mode%3D24hr" + quality="high" + bgcolor="#000000" + 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" + HEIGHT="300" + id="gauge" /> +<PARAM NAME="movie" VALUE="/flash/gauge.swf?xml_source=index.php?target=my-rain-flash-gauge%26mode%3Dtotal" /> +<PARAM NAME="quality" VALUE="high" /> +<PARAM NAME="bgcolor" VALUE="#000000" /> +<param name="allowScriptAccess" value="sameDomain" /> +<EMBED src="/flash/gauge.swf?xml_source=index.php?target=my-rain-flash-gauge%26mode%3Dtotal" + quality="high" + bgcolor="#000000" + WIDTH="140" + HEIGHT="300" + NAME="gauge" + allowScriptAccess="sameDomain" + swLiveConnect="true" + TYPE="application/x-shockwave-flash" + PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> +</EMBED> +</OBJECT> + '); + + return $rain_div; + } + + /** * build the main content for the page * and return it all inside a container object @@ -121,11 +194,13 @@ $radar_img->set_id('idRadarImg'); $radar_div = new DIVtag(array('id' => 'idRadardiv'),$radar_img); + + $rain_div = $this->get_rain_div(); $table = TABLEtag::factory("100%",0,0,0); $table->add_row(new TDtag(array('style' => 'vertical-align:top;width:510px;'),$right_div), - new TDtag(array('style' => 'vertical-align:top;padding-left:8px;'),$radar_div)); + new TDtag(array('style' => 'vertical-align:top;padding-left:8px;'),$radar_div, $rain_div)); return $table; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |