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']; $wind = $wxdata['WIND_STRING']; $curweather = '

'.t("Current Weather").'

'; $curweather .= "Weather: $weather
Temperature: $temp
Relative Humidity: $rhumid
Pressure: $pressure
Wind: $wind"; $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 .= '
'; }