|
[MediaWiki-CVS] SVN: [54055] trunk/extensions: msg#01433mediawiki-cvs
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54055 Revision: 54055 Author: roberthl Date: 2009-07-30 22:38:28 +0000 (Thu, 30 Jul 2009) Log Message: ----------- WebChat, freenodeChat, Mibbit: * Create WebChat extension, a widget-agnostic version of the freenodeChat and Mibbit extensions. * Mark the freenodeChat and Mibbit extensions as obsolete. Added Paths: ----------- trunk/extensions/Mibbit/OBSOLETE trunk/extensions/WebChat/ trunk/extensions/WebChat/WebChat.alias.php trunk/extensions/WebChat/WebChat.i18n.php trunk/extensions/WebChat/WebChat.php trunk/extensions/WebChat/WebChat_body.php trunk/extensions/freenodeChat/OBSOLETE Added: trunk/extensions/Mibbit/OBSOLETE =================================================================== --- trunk/extensions/Mibbit/OBSOLETE (rev 0) +++ trunk/extensions/Mibbit/OBSOLETE 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,4 @@ +As of MediaWiki 1.16.0 this extension is obsoleted by the WebChat extension. It +will be deleted from Subversion on the 1.16.0 release, you are advised to +migrate to the WebChat extension - the Mibbit extension will no longer be +updated or supported except for critical security issues. Added: trunk/extensions/WebChat/WebChat.alias.php =================================================================== --- trunk/extensions/WebChat/WebChat.alias.php (rev 0) +++ trunk/extensions/WebChat/WebChat.alias.php 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,14 @@ +<?php +/** + * Aliases for special pages + * + * @file + * @ingroup Extensions + */ + +$aliases = array(); + +/** English */ +$aliases['en'] = array( + 'WebChat' => array( 'WebChat' ), +); Added: trunk/extensions/WebChat/WebChat.i18n.php =================================================================== --- trunk/extensions/WebChat/WebChat.i18n.php (rev 0) +++ trunk/extensions/WebChat/WebChat.i18n.php 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,22 @@ +<?php + +/** + * Internationalisation file for Mibbit extension. + * + * @addtogroup Extensions + */ + +$messages = array(); + +/** English + * @author Robert Leverington <robert@xxxxxxxxx> + */ +$messages['en'] = array( + 'webchat' => 'Web chat', + 'webchat-desc' => 'Adds a [[Special:WebChat|special page]] used to chat in real time with other wiki users', + 'webchat-header' => 'This special page allows you to collaborate in real time with other users of the wiki. +To connect simply press the "Connect" button. +If you are logged in your nickname will have been prefilled. +Anonymous users are given an automatically generated one, but it can be changed.', + 'right-webchat' => 'Allowed to use web chat', +); Added: trunk/extensions/WebChat/WebChat.php =================================================================== --- trunk/extensions/WebChat/WebChat.php (rev 0) +++ trunk/extensions/WebChat/WebChat.php 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,69 @@ +<?php +/** + * WebChat + * + * Integrates a web chat client in to a special page, for example Mibbit. + * + * @addtogroup Extensions + * + * @link http://www.mediawiki.org/wiki/Extension:WebChat + * + * @author Robert Leverington <robert@xxxxxxxxx> + * @copyright Copyright  2008 - 2009 Robert Leverington. + * @copyright Copyright  2009 Marco 27. + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +// If this is run directly from the web die as this is not a valid entry point. +if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); + +// Extension credits. +$wgExtensionCredits[ 'specialpage' ][] = array( + 'path' => __FILE__, + 'name' => 'WebChat', + 'description' => 'Adds a special page used to chat in real time with other wiki users.', + 'descriptionmsg' => 'webchat-desc', + 'author' => array( 'Robert Leverington', 'Marco 27' ), + 'url' => 'http://www.mediawiki.org/wiki/Extension:WebChat', + 'version' => '1.0.0', +); + +$dir = dirname( __FILE__ ) . '/'; + +// Register special page. +$wgSpecialPages['WebChat'] = 'WebChat'; +$wgSpecialPageGroups['WebChat'] = 'wiki'; +$wgAutoloadClasses['WebChat'] = $dir . 'WebChat_body.php'; + +// Extension messages. +$wgExtensionMessagesFiles['WebChat'] = $dir . 'WebChat.i18n.php'; +$wgExtensionAliasesFiles['WebChat'] = $dir . 'WebChat.alias.php'; + +// Default configuration. +$wgWebChatServer = ''; +$wgWebChatChannel = ''; +$wgWebChatClient = ''; +$wgWebChatClients = array( + 'Mibbit' => array( + 'url' => 'http://embed.mibbit.com/index.html', + 'parameters' => array( + 'noServerMotd' => 'true', + 'server' => '$$$server$$$', + 'channel' => '$$$channel$$$', + 'nick' => '$$$nick$$$', + ), + ), + 'freenodeChat' => array( + 'url' => 'http://webchat.freenode.net/', + 'parameters' => array( + 'channels' => '$$$channel$$$', + 'nick' => '$$$nick$$$', + ), + ) +); + +// Default permissions. +$wgAvailableRights[] = 'webchat'; +$wgGroupPermissions['*' ]['webchat'] = false; +$wgGroupPermissions['user' ]['webchat'] = true; +$wgGroupPermissions['sysop']['webchat'] = true; Added: trunk/extensions/WebChat/WebChat_body.php =================================================================== --- trunk/extensions/WebChat/WebChat_body.php (rev 0) +++ trunk/extensions/WebChat/WebChat_body.php 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,64 @@ +<?php + +/** + * WebChat extension special page class. + */ + +class WebChat extends SpecialPage { + + function __construct() { + SpecialPage::SpecialPage( 'WebChat', 'webchat' ); + } + + function execute( $par ) { + global $wgOut, $wgUser, $wgWebChatServer, $wgWebChatChannel, + $wgWebChatClient, $wgWebChatClients; + wfLoadExtensionMessages( 'WebChat' ); + $this->setHeaders(); + $wgOut->addWikiMsg( 'webchat-header' ); + + if ( !array_key_exists( $wgWebChatClient, $wgWebChatClients ) ) { + throw new MwException( 'Unknown web chat client specified.' ); + } + + foreach ( $wgWebChatClients[$wgWebChatClient]['parameters'] as $parameter => $value ) { + switch ( $value ) { + case '$$$nick$$$': + if ( $wgUser->isLoggedIn() ) $value = str_replace( ' ', '_', $wgUser->getName() ); + break; + case '$$$channel$$$': + $value = $wgWebChatChannel; + break; + case '$$$server$$$': + $value = $wgWebChatServer; + break; + } + $query[] = $parameter . '=' . urlencode( $value ); + } + $query = implode( $query, '&' ); + + $wgOut->addHTML( Xml::openElement( 'iframe', array( + 'width' => '600', + 'height' => '500', + 'scrolling' => 'no', + 'border' => '0', + 'onLoad' => 'webChatExpand( this )', + 'src' => $wgWebChatClients[$wgWebChatClient]['url'] . '?' . $query + ) ) . Xml::closeElement( 'iframe' ) ); + + // Hack to make the chat area a reasonable size. + $wgOut->addHTML( Xml::tags( 'script', + array( 'type' => 'text/javascript' ), +'/* <![CDATA[ */ +function webChatExpand( elem ) { + height = elem.height; + width = elem.width; + elem.height = screen.height - 500; + elem.width = screen.width - 250; +} +/* ]]> */' + ) ); + + } + +} Added: trunk/extensions/freenodeChat/OBSOLETE =================================================================== --- trunk/extensions/freenodeChat/OBSOLETE (rev 0) +++ trunk/extensions/freenodeChat/OBSOLETE 2009-07-30 22:38:28 UTC (rev 54055) @@ -0,0 +1,4 @@ +As of MediaWiki 1.16.0 this extension is obsoleted by the WebChat extension. It +will be deleted from Subversion on the 1.16.0 release, you are advised to +migrate to the WebChat extension - the freenodeChat extension will no longer be +updated or supported except for critical security issues. _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@xxxxxxxxxxxxxxxxxxx https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|
|
||||||||||||||||||||||||||
|
|
|
| News | Mail Home | sitemap | FAQ | advertise |