Extension:AIM

From MediaWiki.org
Jump to: navigation, search
Translate this page; This page contains changes which are not marked for translation.

Other languages:
العربية • ‎বাংলা • ‎Deutsch • ‎English • ‎日本語 • ‎मराठी • ‎polski • ‎русский • ‎sicilianu • ‎中文
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
AIM Button

Release status:Extension status unmaintained

ImplementationTemplate:Extension#type Tag, MyWiki
DescriptionTemplate:Extension#description Embeds a button showing users online status and providing access to a popup chat window.
Author(s)Template:Extension#username Jeffrey Phillips Freeman
Latest versionTemplate:Extension#version 1.0a (2007-05-07)
MediaWikiTemplate:Extension#mediawiki 1.5+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license Public domain
Download see below
ExampleTemplate:Extension#example Syncleus Technology Wiki
ParametersTemplate:Extension#parameters
  • $wgAimKey
TagsTemplate:Extension#tags
<aim>

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

Check usage and version matrix.

Note Note: 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]

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]

  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.phpManual:LocalSettings.php file

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

Code[edit]

<?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 output
     $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;
}