on a page * - Linker.php override userToolLinks() so that extra 'chat' item for each line on recent changes * put chat history on discussion page */ $wgExtensionFunctions[] = "wfExtensionWikiChat"; $wgExtensionCredits['specialpage'][] = array( 'name' => 'Chat', 'version' => '2007/03/21', 'author' => 'Austin Che', 'url' => 'http://openwetware.org/wiki/User:Austin_J._Che/Extensions/WikiChat', 'description' => 'Enables chatting on pages using www.phpfreechat.net', ); class WikiChat // not extending SpecialPage to avoid unnecessarily loading SpecialPage.php { var $phpfreechat; // path to phpfreechat.class.php var $params; // phpfreechat params var $defaultrooms; // array of default rooms, default array("Lounge") function WikiChat() { global $wgSitename, $wgScript, $wgUploadDirectory, $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword; $this->phpfreechat = "phpfreechat/src/phpfreechat.class.php"; $this->defaultrooms = array("Lounge"); $this->params = array("serverid" => $wgSitename, "title" => "Wiki Chat", "frozen_nick" => true, // don't allow changing nickname "max_nick_len" => 128, // these are set later when the chat is started //"nick", "channels", "privmsg" "isadmin" => false, // ** maybe make admin if sysop on wiki or use $wgUser->isAllowed("..."), // use same database parameters as wiki "container_type" => "mysql", "container_cfg_mysql_host" => $wgDBserver, // default value is "localhost" //"container_cfg_mysql_port" => 3306, // default value is 3306 // MediaWiki has no port specification for mysql, $wgDbport is only used for postgres "container_cfg_mysql_database" => $wgDBname, "container_cfg_mysql_table" => "phpfreechat", // default value is "phpfreechat" "container_cfg_mysql_username" => $wgDBuser, "container_cfg_mysql_password" => $wgDBpassword, "container_cfg_mysql_fieldtype_subgroup" => 'varchar(128)', //fix for bug in phpfreechat mysql container // paths "server_script_url" => "${wgScript}/Special:Chat", "data_private_path" => "${wgUploadDirectory}/freechat", // these may need to be overwritten "theme_url" => "/freechat/themes", "theme_default_url" => "/freechat/themes", "data_public_url" => "/freechat/data/public", // general prefs "quit_on_closedwindow" => true, "skip_proxies" => array("censor"), // no censoring of words "shownotice" => 0, // show: 0 = nothing, 1 = just nickname changes, 2 = join/quit, 3 = 1+2 "showsmileys" => false, "nickmarker" => true, "btn_sh_smileys" => true, "max_msg" => 100, "openlinknewwindow" => true, ); } function addChatTab(&$skin_template, &$content_actions) { global $wgRequest, $wgTitle, $wgUser; if ($wgUser->isAnon()) return true; $curaction = $wgRequest->getText('action'); $i = 0; foreach ($content_actions as $key => $tab) { if ($key == "talk") { // add chat tab after talk tab $title = Title::makeTitle(NS_SPECIAL, "Chat/" . $wgTitle->getSubjectPage()->getPrefixedDBkey()); $chat["chat"] = array('class' => $curaction == "chat" ? 'selected' : false, 'text' => wfMsg("chat"), 'href' => $title->getLocalUrl(), ); array_splice($content_actions, $i, 0, $chat); break; } $i++; } return true; } function chat($room) { global $wgOut, $wgUser, $wgCachePages; $wgCachePages = false; $wgOut->setHTMLTitle(wfMsg('chat')); $wgOut->setPageTitle(wfMsg('chat')); if ($wgUser->isAnon()) { $wgOut->addHTML(wfMsg("wikichat-anon")); return true; } require_once $this->phpfreechat; $this->params["nick"] = $wgUser->getName(); $this->params["channels"] = $this->defaultrooms; if ($room) { $title = Title::newFromText($room); if ($title && $title->getNamespace() == NS_USER) $this->params["privmsg"] = $title->getText(); else $this->params["channels"] = array_merge($this->defaultrooms, array($room)); } $chat = new phpFreeChat($this->params); $wgOut->addHTML($chat->printChat(true)); $wgOut->addHTML(wfMsg('wikichat-text')); } } function wfExtensionWikiChat() { global $wgMessageCache, $wgSpecialPages, $wgHooks, $wgWikiChat; $wgMessageCache->addMessages(array('chat' => 'Chat', 'wikichat-text' => "Type /help to list chat commands.", 'wikichat-anon' => 'You must log in to chat.')); $wgSpecialPages["Chat"] = array('SpecialPage', 'Chat'); // $wgHooks['SkinTemplateTabs'][] = array(&$wgWikiChat, "addChatTab"); } function wfSpecialChat($par) { // entry point for special page global $wgWikiChat; return $wgWikiChat->chat($par); } $wgWikiChat = new WikiChat(); ?>