From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Implementation Special page
Description Adds an PJIRC Applet to your wiki
Author(s) Jamasi
Latest version 0.9.1 (2009-04-02)
MediaWiki 1.10,1.12,1.13,1.14 (tested) 1.7+ (supposed)
License GNU Affero General Public License 3.0
Download see below
Check usage and version matrix.

This extension allows users to chat in an IRC chat, using PJIRC through the MediaWiki interface. It is loosely based on the IRC Chat extension by Quentin Sheets.


  1. OPTIONAL -- Download the PJIRC binary, which can be found at www.pjirc.com, and save it into the /irc directory of your website.
  2. Save the source code below into its respective files in "/extensions/PJIRC/".
  3. OPTIONAL -- Configure your applet using MediaWiki:IrcXyz pages
  4. Enjoy your new IRC client.

Changes to LocalSettings.php[edit]




# Not a valid entry point, skip unless MEDIAWIKI is defined
if (!defined('MEDIAWIKI')) {
        echo <<<EOT
To install my extension, put the following line in LocalSettings.php:
require_once( "$IP/extensions/PJIRC/SpecialIRC.php" );
        exit( 1 );
 * A Special Page extension to offer an PJIRC java-applet to visitors
 * @addtogroup Extensions
 * @author Jan M. Simons <jamasi at piratenpartei.de>
 * @copyright Copyright © 2007, Jan M. Simons
 * inspired by http://www.mediawiki.org/wiki/Extension:IRC_Chat from Quentin Sheets
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later

$wgExtensionCredits['specialpage'][] = array(
    'name' => 'PJIRC',
    'author' => 'Jan M. Simons',
    'version' => '0.9.1',
    'description' => 'Allows users to engage in an IRC chat, using PJIRC through the MediaWiki interface.',
    'url' => 'http://www.mediawiki.org/wiki/Extension:PJIRC',

$wgAutoloadClasses['PJIRC'] = dirname(__FILE__) . '/SpecialIRC_body.php';
$wgSpecialPages['PJIRC'] = 'PJIRC';
$wgHooks['LoadAllMessages'][] = 'PJIRC::loadMessages';


class PJIRC extends SpecialPage {

        function PJIRC() {
        function execute( $par ) {
	        global $wgOut, $wgUser, $wfMsgHtml, $wgTitle, $wgParser;


		// Get IrcNickname of the user use MediaWiki username otherwise
		If ($wgUser->IsLoggedIn()) {
			$ircNick = $wgUser->getName();
		} else {
			$ircNick = "Guest";

        	if ($wgUser->mId<1) {
			// sysop uses MediaWiki:IrcNick
                	if (wfMsg('ircNick')) $ircNick = wfMsg('ircNick');
        	} else {
			// get nickname from userpage
			$userpage = $wgUser->getUserPage();
			$tmpArticle = new Article(Title::newFromText($userpage->getPrefixedText().'/IrcNick'));
			$content = $tmpArticle->fetchContent(0,false,false);
			if (trim($content," ")) $ircNick = $content;

		//make nickname irc-safe
		$illegalChars = array(".", "_", "/", "\\", "#", "*", "+", "~", "!");
		$ircNick = str_replace($illegalChars, "", $ircNick);

		// if nickname is still empty use default
		if ($ircNick == "") $ircNick = "Guest???";

		// load settings (can be overridden with Mediawiki:IrcXyz pages)
		$ircCodebase = wfMsg('ircCodebase');		// http://yourdomain/IRC
		$ircArchive = wfMsg('ircArchive');		// irc.jar,pixx.jar
		$ircCabinets = wfMsg('ircCabinets');		// irc.cab,securedirc.cab,pixx.cab
		$ircLangExt = wfMsg('ircLangExt');		// txt
		$ircServer = wfMsg('ircServer');		// irc.yourfavourite.net
		$ircServerPort = wfMsg('ircServerPort');	// 6667
		$ircJoinChannel = wfMsg('ircJoinChannel');	// #yourChannel
		$ircWidth = wfMsg('ircWidth');			// 640
		$ircHeight = wfMsg('ircHeight');		// 400
		$ircAltNick = wfMsg('ircAltNick');		// Guest???

		// If page was called with a parameter join that channel
		if ($par) $ircJoinChannel = "#".$par;

        	$ircApplet = '<applet codebase="'.$ircCodebase.'" code="IRCApplet.class" archive="'.$ircArchive.'" width="'.$ircWidth.'" height="'.$ircHeight.'">'."\n";
		if ($ircCabinets) $ircApplett .= '<param name="CABINETS" value="'.$ircCabinets.'">'."\n";
		$ircApplet .= '<param name="nick" value="'.$ircNick.'">
			<param name="alternatenick" value="'.$ircAltNick.'">
			<param name="userid" value="wikichat">
			<param name="name" value="Wiki User">
			<param name="host" value="'.$ircServer.'">
			<param name="port" value="'.$ircServerPort.'">
			<param name="gui" value="pixx">
			<param name="quitmessage" value="PJIRC forever!">
			<param name="asl" value="true">
			<param name="useinfo" value="true">'."\n";
		if ($ircJoinChannel) $ircApplet .= '<param name="Command1" value="/join '.$ircJoinChannel.'">'."\n";
		if ($ircLangExt) {
			$ircApplet .= '<param name="pixx:lngextension" value="'.$ircLangExt.'">
			<param name="lngextension" value="'.$ircLangExt.'">'."\n";
		$ircApplet .= '<param name="languageencoding" value="UnicodeLittle">'."\n";
		$ircApplet .= '<param name="style:bitmapsmileys" value="true">
			<param name="style:smiley1" value=":) img/sourire.gif">
			<param name="style:smiley2" value=":-) img/sourire.gif">
			<param name="style:smiley3" value=":-D img/content.gif">
			<param name="style:smiley4" value=":d img/content.gif">
			<param name="style:smiley5" value=":-O img/OH-2.gif">
			<param name="style:smiley6" value=":o img/OH-1.gif">
			<param name="style:smiley7" value=":-P img/langue.gif">
			<param name="style:smiley8" value=":p img/langue.gif">
			<param name="style:smiley9" value=";-) img/clin-oeuil.gif">
			<param name="style:smiley10" value=";) img/clin-oeuil.gif">
			<param name="style:smiley11" value=":-( img/triste.gif">
			<param name="style:smiley12" value=":( img/triste.gif">
			<param name="style:smiley13" value=":-| img/OH-3.gif">
			<param name="style:smiley14" value=":| img/OH-3.gif">
			<param name="style:smiley15" value=":\'( img/pleure.gif">
			<param name="style:smiley16" value=":$ img/rouge.gif">
			<param name="style:smiley17" value=":-$ img/rouge.gif">
			<param name="style:smiley18" value="(H) img/cool.gif">
			<param name="style:smiley19" value="(h) img/cool.gif">
			<param name="style:smiley20" value=":-@ img/enerve1.gif">
			<param name="style:smiley21" value=":@ img/enerve2.gif">
			<param name="style:smiley22" value=":-S img/roll-eyes.gif">
			<param name="style:smiley23" value=":s img/roll-eyes.gif">
			<param name="style:floatingasl" value="true">
			<param name="pixx:timestamp" value="true">
			<param name="pixx:highlight" value="true">
			<param name="pixx:highlightnick" value="true">
			<param name="pixx:nickfield" value="true">
			<param name="pixx:styleselector" value="true">
			<param name="pixx:setfontonstyle" value="true">
			<h1>No java support</h1>
			<p><font color="green">Sorry, but you need a Java 1.4.x enabled browser to use PJIRC.</font></p>
        	//$wgOut->addHTML("<!--".$ircApplet."-->"); // for debugging
        function loadMessages() {
                static $messagesLoaded = false;
                global $wgMessageCache;
                if ( $messagesLoaded ) return true;
                $messagesLoaded = true;

		// freenode settings (default)
		$defaultsettings = array (
			'ircCodebase'	=> 'http://java.freenode.net/freenode/pjirc/',
			'ircArchive'	=> 'irc.jar,pixx.jar',
			'ircCabinets'	=> '',
			'ircLangExt'	=> '',
			'ircServer'	=> 'irc.freenode.net',
			'ircServerPort'	=> '6667',
			'ircJoinChannel'=> '',
			'ircWidth' 	=> '640',
			'ircHeight'	=> '400',
			'ircAltNick'	=> 'Anon???',
			'ircNick'	=> ''

			// an alternative configuration (if you installed pjirc locally)
			// all settings can also  be overridden with Mediawiki:IrcXxxx pages
			'ircCodebase'	=> 'http://yourdomain/IRC',
			'ircArchive'	=> 'irc.jar,pixx.jar',
			'ircCabinets'	=> 'irc.cab,securedirc.cab,pixx.cab',
			'ircLangExt'	=> 'txt',
			'ircServer'	=> 'irc.yourfavourite.net',
			'ircServerPort'	=> '6667',
			'ircJoinChannel'=> '#yourChannel',
			'ircWidth' 	=> '640',
			'ircHeight'	=> '400',
			'ircAltNick'	=> 'Guest???',
			'ircNick'	=> ''

		// internationalisation
                require( dirname( __FILE__ ) . '/SpecialIRC.i18n.php' );
                foreach ( $allMessages as $lang => $langMessages ) {
                        $wgMessageCache->addMessages( $langMessages, $lang );
                return true;


// localisation file

$allMessages = array(
        'en' => array( 
                'pjirc' => 'IRC Chat'
        'de' => array( 
                'pjirc' => 'IRC-Chat'


After you've installed the extension you should be able to spot it on Special:Version on your Wiki additionally there should be a new specialpage called "IRC Chat".

You can change any defaultvalue (have a look at the code) by creating a page called MediaWiki:IrcNameofTheSetting, eg. MediaWiki:IrcServer and puting the desired value into this page.

By default the applet will use the username of anybody logged in to the wiki as the nickname for IRC. If a user wants to specify another nickname he can create a subpage of his userpage named User:Username/IrcNick which should contain only the desired username.

If you call the specialpage with Special:PJIRC/flood then it will automatically join the channel #flood on load.

You can specify a default channel to join by editing MediaWiki:IrcJoinChannel and placing "#ChannelName" into it.

Known Issues[edit]

  • None at this current time.

Future Developments[edit]

This is a list of confirmed future holdings for this extension (besides the caveats). Please list all requests on the discussion page.

  1. Support for configuring the colors of the applet.

See also[edit]