예제 #1
0
function WeatherIconBanner($arguments = '')
{
    global $WI, $wp_version, $l10n;
    // Check to see if display_errors are on, if so, disable them
    $WI->disableDisplayErrors();
    // We're using the 'var1=foo&var2=bar' input format now, so let's take care of it -Viper
    // Removed support for old style WeatherIcon call
    // Really doesn't work anymore
    // $WI->bool is required to translate from 'false' to FALSE and 'true' to TRUE.
    // -Garett
    parse_str($arguments, $new_args);
    // This function f'ing owns
    if (isset($new_args['location'])) {
        if (in_array($new_args['location'], array_keys($WI->settings['locations']))) {
            $location = $WI->settings['locations'][$new_args['location']];
            $location_name = $new_args['location'];
        }
    }
    if (empty($location)) {
        $location = $WI->settings['locations'][$WI->settings['default_location']];
        $location_name = $WI->settings['default_location'];
    }
    $station = $new_args['station'] ? $new_args['station'] : $location['station'];
    $latitude = isset($new_args['latitude']) && $new_args['latitude'] != '' ? $new_args['latitude'] : $location['latitude'];
    $longitude = isset($new_args['longitude']) && $new_args['longitude'] != '' ? $new_args['longitude'] : $location['longitude'];
    $gmt_offset = isset($new_args['gmt_offset']) && $new_args['gmt_offset'] != '' ? $new_args['gmt_offset'] : $location['gmt_offset'];
    $dst = isset($new_args['dst']) && $new_args['dst'] != '' ? $WI->bool($new_args['dst']) : $location['dst'];
    // Fetch the Metar Data for this Station
    $raw = $WI->fetch_metar($station);
    // default output
    $output = get_bloginfo('template_directory') . '/banners/random.php';
    // If no metar ...
    if ($raw) {
        $metar = new WeatherIconMetar($raw, $latitude, $longitude, $gmt_offset, $dst, $before, $after);
        if ($metar->icon_name_translation()) {
            $output = WIicondirWeb . $metar->decoded_metar['icon'];
        }
    }
    // restore the error displaying
    $WI->restoreDisplayErrors();
    echo $output;
}