Extension:AccuWeather

From MediaWiki.org

Jump to: navigation, search

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
AccuWeather Extension

Release status: beta

Implementation  Skin
Description Displays Weather Forecast from AccuWeather.com
Author(s)  QuotesTalk
Last Version  1.0 (2009-02-17)
MediaWiki  1.13.2+
License No license specified
Download see below
Example  see below

check usage (experimental)

Contents

[edit] What can this extension do?

This extension adds a weather forecast for a specified location using data supplied by AccuWeather.com

[edit] Usage

<accuweather zipcode="EUR|UK|UK001|LONDON"></accuweather>

[edit] Download instructions

Please cut and paste the code found below and place it in $IP/extensions/AccuWeather/accuweather.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/AccuWeather/accuweather.php");

[edit] Configuration parameters

The zipcode parameter is used to determine the location for the forecast. The four-part format is determined by AccuWeather.com and examples are given in the code found below.

When you have worked out the zipcode for the country you need (i.e. the first three parts; EUR|UK|UK001| ) it is usually a simple matter of adding a CITY NAME ( i.e. the fourth part; LONDON ). Weather forecasts for more than 3 million locations are currently available.

If you need to confirm a zipcode use the code generator at http://netweather.accuweather.com/adcbin/netweather_v2/signup-page2.asp?partner=netweather and run through the configuration options. You will then find your location's zipcode embedded in the final source code.

[edit] Code

<?php
# AccuWeather Extension
# by Quotes
# http://www.quotes.uk.com/
 
# Usage:
# <accuweather zipcode="EUR|UK|UK001|LONDON"></accuweather>

# Source and Zipcodes from:
# http://netweather.accuweather.com/

# Example Zipcodes:
# EUR|UK|UK001|LONDON
# ASI|JP|JA041|TOKYO
# EUR|FR|FR012|PARIS
# NAM|US|NY|NEW YORK
# NAM|CA|ON|TORONTO
# SAM|BR|BR017|RIO DE JANEIRO
# ASI|RU|RS052|MOSCOW
# OCN|AU|NSW|SYDNEY
# MEA|AE|AE005|DUBAI
# ASI|CN|CH002|BEIJING
# AFR|ZA|SF011|CAPE TOWN
# NAM|US|CA|LOS ANGELES
# EUR|DE|GM003|BERLIN
# EUR|ES|SP013|MADRID

# Put this file in the AccuWeather directory in Extensions
# To activate the extension, include it from your LocalSettings.php
# with: require_once("extensions/AccuWeather/accuweather.php");
 
$wgExtensionFunctions[] = "wfAccuweather";
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'AccuWeather Extension',
	'description' => 'Displays Weather Forecast from AccuWeather.com',
	'author' => 'Quotes - http://www.quotes.uk.com/',
	'url' => 'http://www.mediawiki.org/wiki/Extension:AccuWeather',
	'version' => '1.0 (17/Feb/2009)'
 
);
function wfAccuweather() {
    global $wgParser;
    # registers the <accuweather> extension with the WikiText parser
    $wgParser->setHook( "accuweather", "renderAccuweather" );
}
 
# The callback function for converting the input text to HTML output
function renderAccuweather( $input, $argv ) {
 
// escape $input to prevent XSS
	$input = htmlspecialchars($input) ;
 
	$output = '<div style="width: 300px; height: 250px; background-image: url( http://vortex.accuweather.com/adcbin/netweather_v2/backgrounds/lhtblue_300x250_bg.jpg ); background-repeat: no-repeat; background-color: #3BA6C9;" ><div style="height: 238px;" ><script src="http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2.asp?partner=netweather&tStyle=whteYell&logo=1&zipcode=';
	$output .= $argv["zipcode"];
	$output .= '|&lang=uke&size=9&theme=lhtblue&metric=1&target=_self"></script></div><div style="text-align: center; font-family: arial, helvetica, verdana, sans-serif; font-size: 11px; line-height: 12px; color: #FFFFFF;" ><a style="color: #FFFFFF" href="http://www.accuweather.com/world-index-forecast.asp?partner=netweather&locCode=';
	$output .= $argv["zipcode"];
	$output .= '|&metric=1" >Weather Forecast</a> | <a style="color: #FFFFFF" href="http://www.accuweather.com/maps-satellite.asp" >Weather Maps</a> | <a style="color: #FFFFFF" href="http://www.accuweather.com/index-radar.asp" >Weather Radar</a></div></div>';
 
    return $output;
}

[edit] Alternate Sizes and Styles

To enable easy implementation the functionality of this extension has been limited to just one size (300w x 250h) and one colour scheme (Light Blue), so that the only variable is the location (zipcode). Additional options for temperature scale, language, background image, colour scheme and box dimensions (including popular banner sizes) are also available through the code generator at http://netweather.accuweather.com/. If you want to use an alternate style you should find it relatively straightforward to run through the code found below and substitute parameters where required. If you swap out sections of code it may help you if you start by searching and replacing single quotes in the supplied code with double quotes.

[edit] Examples

After installing the AccuWeather Extension please add your wiki to the top of this list:

  • Debatrix - an experimental wiki that I am working on --Jake4d
  • Wiki Sussex - a unique guide to every village and town in Sussex, England.

[edit] See also