Extension:AIM

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
AIM Button

Release status: unmaintained

Implementation Tag, MyWiki
Description Embeds a button showing users online status and providing access to a popup chat window.
Author(s) Jeffrey Phillips Freeman
Latest version 1.0a (2007-05-07)
MediaWiki 1.5+
Database changes No
License Public domain
Download see below
Example Syncleus Technology Wiki
Parameters
  • $wgAimKey
Tags
<aim>

Translate the AIM extension if it is available at translatewiki.net

Check usage and version matrix; code metrics
Please Upgrade to 1.0a or above from all version to prevent an XSS attack

The AIM extension embeds a button showing users online AIM status. When clicked, a popup AIM chat window appears.

Usage[edit | edit source]

To embed an AIM Button inside a MediaWiki article

syntax
"<aim>AIM-Username</aim>"

Use Extension talk:AIM to report issues or ask for help

Installation[edit | edit source]

  1. Copy the code into a file (e.g. aim.php)
  2. Change $wgAimKey to your AIM key (get an AIM key here).
  3. Save the file in the extensions directory of your MediaWiki folder
  4. Add the line require_once('extensions/aim.php'); to the end of your LocalSettings.php file

Now you can use the extension with <aim>AIM-Username</aim> in the wiki


Code[edit | edit source]

<?php
 
/**
 * MediaWiki AIM extension
 *
 * @file
 * @ingroup Extensions
 * @version 1.0a
 * @author Jeffrey Phillips Freeman <freemo@gmail.com> & released to the public domain.
 * @link https://www.mediawiki.org/wiki/Extension:AIM
 */
 
if ( !defined( 'MEDIAWIKI' ) ) {
	die( 'This is not a valid entry point.' );
}
 
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'AIM',
        'version' => '1.0a',
        'author' => 'Jeffrey Phillips Freeman',
        'url' => 'https://www.mediawiki.org/wiki/Extension:AIM',
        'description' => 'Embeds a button showing users online AIM status'
);
 
//setup default varibles
$wgAimKey = 'AIM_KEY_HERE';
 
// set up MediaWiki to react to the "<aim>" tag
$wgExtensionFunctions[] = "wfAIM";
 
function wfAIM() {
        global $wgParser;
        $wgParser->setHook( "aim", "RenderAIM" );
}
 
 
// the function that reacts to "<aim>"
 
function RenderAIM( $input, $argv ) {
 
// set your defaults for the style and action (0 to 26) (add)
 
        $style_default = "0" ;
        $action_default = "sendim" ;
 
// the varibles are: <aim style="$argv['style']" action="$argv['action']">$input</aim>
 
// escape $input to prevent XSS
        $input = htmlspecialchars($input) ;
 
// test to see if the optinal elements of the tags are set and supported. if not set them to the defaults
 
        if( isset( $argv['style'] ) ){
                $style = $argv['style'] ;
                if( !($style >= "0" AND $style <= "0") ){
                        $style = $style_default ;
                }
        } else {
                $style = $style_default ;
        }
 
        if( isset( $argv['action'] ) ){
                $action = $argv['action'] ;
                if( !($action == "sendim") ){
                        $action = $action_default ;
                }
        } else {
                $action = $action_default ;
        }
 
// set the url to the image and the stype of the image
global $wgAimKey;
$image = '<img src="http://api.oscar.aol.com/SOA/key='.$wgAimKey.'/presence/'.$input.'" border="0"/> ' ;
 
// start the rendering the html outupt
     $output  = '<!-- MediaWiki extension http:/www.mediawiki.org/wiki/Extension:AIM -->';
     $output .= '<a href="aim:GoIM?screenname='.$input.'">'.$image.'</a>';
     $output .= '<!-- end of AIM button -->';
 
// send the output to MediaWiki
     return $output;
}