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 .= '
'; }