From 6ec3a4059a006d3ccac798e4d41b91a2f712799c Mon Sep 17 00:00:00 2001 From: tony baldwin Date: Mon, 11 Feb 2013 12:49:19 -0500 Subject: [PATCH] added more weather data, change curtemp to curweather --- curtemp/curtemp.php | 102 ----------------- curtemp.tgz => curweather.tgz | Bin 30720 -> 30720 bytes .../curtemp.css => curweather/curweather.css | 0 curweather/curweather.php | 106 ++++++++++++++++++ {curtemp => curweather}/getweather.php | 0 {curtemp => curweather}/test.php | 0 6 files changed, 106 insertions(+), 102 deletions(-) delete mode 100644 curtemp/curtemp.php rename curtemp.tgz => curweather.tgz (85%) rename curtemp/curtemp.css => curweather/curweather.css (100%) create mode 100644 curweather/curweather.php rename {curtemp => curweather}/getweather.php (100%) rename {curtemp => curweather}/test.php (100%) diff --git a/curtemp/curtemp.php b/curtemp/curtemp.php deleted file mode 100644 index 36d5fdd61..000000000 --- a/curtemp/curtemp.php +++ /dev/null @@ -1,102 +0,0 @@ - Find the location code for the station or airport nearest you here. - * Version: 1.0 - * Author: Tony Baldwin - * Author: Fabio Comuni - * - */ -require_once('addon/curtemp/getweather.php'); - -function curtemp_install() { - register_hook('network_mod_init', 'addon/curtemp/curtemp.php', 'curtemp_network_mod_init'); - register_hook('plugin_settings', 'addon/curtemp/curtemp.php', 'curtemp_plugin_settings'); - register_hook('plugin_settings_post', 'addon/curtemp/curtemp.php', 'curtemp_plugin_settings_post'); - -} - -function curtemp_uninstall() { - unregister_hook('network_mod_init', 'addon/curtemp/curtemp.php', 'curtemp_network_mod_init'); - unregister_hook('plugin_settings', 'addon/curtemp/curtemp.php', 'curtemp_plugin_settings'); - unregister_hook('plugin_settings_post', 'addon/curtemp/curtemp.php', 'curtemp_plugin_settings_post'); - -} - - -function curtemp_network_mod_init(&$fk_app,&$b) { - - if(! intval(get_pconfig(local_user(),'curtemp','curtemp_enable'))) - return; - - $fk_app->page['htmlhead'] .= '' . "\r\n"; - - // the getweather file does all the work here - // the $rpt value is needed for location - // which getweather uses to fetch the weather data for weather and temp - $rpt = get_pconfig(local_user(), 'curtemp', 'curtemp_loc'); - $wxdata = GetWeather::get($rpt); - $temp = $wxdata['TEMPERATURE_STRING']; - $weather = $wxdata['WEATHER']; - $curtemp = '
-
-

'.t("Current Temp").'

'; - - $curtemp .= "Weather: $weather
- Temperature: $temp "; - - $curtemp .= '
'; - - $fk_app->page['aside'] = $curtemp.$fk_app->page['aside']; - -} - - -function curtemp_plugin_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'curtemp-settings-submit'))) - return; - set_pconfig(local_user(),'curtemp','curtemp_loc',trim($_POST['curtemp_loc'])); - set_pconfig(local_user(),'curtemp','curtemp_enable',intval($_POST['curtemp_enable'])); - - info( t('Current Temp settings updated.') . EOL); -} - - -function curtemp_plugin_settings(&$a,&$s) { - - if(! local_user()) - return; - - /* Add our stylesheet to the curtemp so we can make our settings look nice */ - - $a->page['htmlhead'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ - - $curtemp_loc = get_pconfig(local_user(), 'curtemp', 'curtemp_loc'); - $enable = intval(get_pconfig(local_user(),'curtemp','curtemp_enable')); - $enable_checked = (($enable) ? ' checked="checked" ' : ''); - - - /* Add some HTML to the existing form */ - - $s .= '
'; - $s .= '

' . t('Current Temp Settings') . '

'; - $s .= '
'; - $s .= '

Find the location code for the airport/weather station nearest you here.

'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; - -} - - diff --git a/curtemp.tgz b/curweather.tgz similarity index 85% rename from curtemp.tgz rename to curweather.tgz index d254640b1ab1e6ea01f0ba80789244a56f1c06eb..ce8b12be28365b92e7f8a0b2825bd9d0fb8e7c32 100644 GIT binary patch delta 1715 zcma)5OK%cU7zIiS3|OGFR4I)&6XNt;pghtCO`1wtd=-I~K2l){({vKbkm1sYCR*1< zW4*D7u4)(VjEUWKReym|S1wH4xHG0J7cPu@|%-P|wVJ#)VEodcVP>diy7F;n8# z7#c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VK^Toum%xn0QPE6@5`+nF3Bn}H sW@t*d0AXRa5db+^ADW!>l8cKc3I>YdDwtek*oi4O7P&Dkz7Q<~0N!)O!2kdN diff --git a/curtemp/curtemp.css b/curweather/curweather.css similarity index 100% rename from curtemp/curtemp.css rename to curweather/curweather.css diff --git a/curweather/curweather.php b/curweather/curweather.php new file mode 100644 index 000000000..77f3bf800 --- /dev/null +++ b/curweather/curweather.php @@ -0,0 +1,106 @@ + Find the location code for the station or airport nearest you here. + * Version: 1.0 + * Author: Tony Baldwin + * Author: Fabio Comuni + * + */ +require_once('addon/curweather/getweather.php'); + +function curweather_install() { + register_hook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); + register_hook('plugin_settings', 'addon/curweather/curweather.php', 'curweather_plugin_settings'); + register_hook('plugin_settings_post', 'addon/curweather/curweather.php', 'curweather_plugin_settings_post'); + +} + +function curweather_uninstall() { + unregister_hook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); + unregister_hook('plugin_settings', 'addon/curweather/curweather.php', 'curweather_plugin_settings'); + unregister_hook('plugin_settings_post', 'addon/curweather/curweather.php', 'curweather_plugin_settings_post'); + +} + + +function curweather_network_mod_init(&$fk_app,&$b) { + + if(! intval(get_pconfig(local_user(),'curweather','curweather_enable'))) + return; + + $fk_app->page['htmlhead'] .= '' . "\r\n"; + + // the getweather file does all the work here + // the $rpt value is needed for location + // which getweather uses to fetch the weather data for weather and temp + $rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc'); + $wxdata = GetWeather::get($rpt); + $temp = $wxdata['TEMPERATURE_STRING']; + $weather = $wxdata['WEATHER']; + $rhumid = $wxdata['RELATIVE_HUMIDITY']; + $pressure = $wxdata['PRESSURE_STRING']; + $curweather = '
+
+

'.t("Current Weather").'

'; + + $curweather .= "Weather: $weather
+ Temperature: $temp
+ Relative Humidity: $rhumid
+ Pressure: $pressure"; + + $curweather .= '
'; + + $fk_app->page['aside'] = $curweather.$fk_app->page['aside']; + +} + + +function curweather_plugin_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'curweather-settings-submit'))) + return; + set_pconfig(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); + set_pconfig(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); + + info( t('Current Weather settings updated.') . EOL); +} + + +function curweather_plugin_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the curweather so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $curweather_loc = get_pconfig(local_user(), 'curweather', 'curweather_loc'); + $enable = intval(get_pconfig(local_user(),'curweather','curweather_enable')); + $enable_checked = (($enable) ? ' checked="checked" ' : ''); + + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Current Weather Settings') . '

'; + $s .= '
'; + $s .= '

Find the location code for the airport/weather station nearest you here.

'; + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + + diff --git a/curtemp/getweather.php b/curweather/getweather.php similarity index 100% rename from curtemp/getweather.php rename to curweather/getweather.php diff --git a/curtemp/test.php b/curweather/test.php similarity index 100% rename from curtemp/test.php rename to curweather/test.php