mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Merge branch 'master' of github.com:wbbaddons/Tims-Chat
This commit is contained in:
commit
08c8e8b44b
12
eventListener.xml
Normal file
12
eventListener.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/eventListener.xsd">
|
||||
<import>
|
||||
<eventlistener>
|
||||
<eventclassname>wcf\system\request\RouteHandler</eventclassname>
|
||||
<eventname>didInit</eventname>
|
||||
<environment>user</environment>
|
||||
<inherit>0</inherit>
|
||||
<listenerclassname>wcf\system\event\listener\ChatRouteListener</listenerclassname>
|
||||
</eventlistener>
|
||||
</import>
|
||||
</data>
|
@ -20,6 +20,7 @@ class ChatPage extends AbstractPage {
|
||||
public $neededModules = array('CHAT_ACTIVE');
|
||||
//public $neededPermissions = array('user.chat.canEnter');
|
||||
public $joinMessage = null;
|
||||
public $newestMessages = array();
|
||||
public $room = null;
|
||||
public $roomID = 0;
|
||||
public $rooms = array();
|
||||
@ -35,6 +36,7 @@ public function assignVariables() {
|
||||
WCF::getTPL()->assign(array(
|
||||
'chatVersion' => $this->chatVersion,
|
||||
'joinMessage' => $this->joinMessage,
|
||||
'newestMessages' => $this->newestMessages,
|
||||
'room' => $this->room,
|
||||
'roomID' => $this->roomID,
|
||||
'rooms' => $this->rooms,
|
||||
@ -77,18 +79,11 @@ public function readData() {
|
||||
'color1' => $this->userData['color'][1],
|
||||
'color2' => $this->userData['color'][2]
|
||||
));
|
||||
if ($this->room->topic != '') {
|
||||
chat\message\ChatMessageEditor::create(array(
|
||||
'roomID' => $this->room->roomID,
|
||||
'sender' => WCF::getUser()->userID,
|
||||
'time' => TIME_NOW,
|
||||
'type' => chat\message\ChatMessage::TYPE_INFORMATION,
|
||||
'message' => WCF::getLanguage()->getDynamicVariable($this->room->topic)
|
||||
));
|
||||
}
|
||||
|
||||
$this->readDefaultSmileys();
|
||||
$this->readChatVersion();
|
||||
|
||||
$this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +100,19 @@ public function readDefaultSmileys() {
|
||||
public function readParameters() {
|
||||
parent::readParameters();
|
||||
|
||||
if (isset($_GET['id'])) $this->roomID = (int) $_GET['id'];
|
||||
if ($this->action == 'Log') {
|
||||
//TODO: Initialise LogPage
|
||||
exit;
|
||||
}
|
||||
elseif($this->action == 'Send') {
|
||||
//TODO: Safe message in database
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id'];
|
||||
if (isset($_REQUEST['ajax'])) {
|
||||
$this->useTemplate = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,5 +178,12 @@ public function show() {
|
||||
// remove index breadcrumb
|
||||
WCF::getBreadcrumbs()->remove(0);
|
||||
parent::show();
|
||||
if ($this->useTemplate) exit;
|
||||
@header('Content-type: application/json');
|
||||
echo \wcf\util\JSON::encode(array(
|
||||
'title' => WCF::getLanguage()->get($this->room->title),
|
||||
'topic' => WCF::getLanguage()->get($this->room->topic)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
17
file/lib/system/event/listener/ChatRouteListener.class.php
Normal file
17
file/lib/system/event/listener/ChatRouteListener.class.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace wcf\system\event\listener;
|
||||
use wcf\system\event\IEventListener;
|
||||
use wcf\system\request\Route;
|
||||
|
||||
class ChatRouteListener implements IEventListener {
|
||||
/**
|
||||
* @see wcf\system\event\IEventListener::execute()
|
||||
*/
|
||||
public function execute($eventObj, $className, $eventName) {
|
||||
$route = new Route('chatAction');
|
||||
$route->setSchema('/{controller}/{action}');
|
||||
$route->setParameterOption('controller', null, 'Chat');
|
||||
$route->setParameterOption('action', null, '(Log|Send)');
|
||||
$eventObj->addRoute($route);
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
<instruction type="objectType">objectType.xml</instruction>
|
||||
<instruction type="option">option.xml</instruction>
|
||||
<instruction type="pagemenu">pagemenu.xml</instruction>
|
||||
<instruction type="eventListener">eventListener.xml</instruction>
|
||||
<instruction type="templatelistener">templatelistener.xml</instruction>
|
||||
<instruction type="aclOption">acloptions.xml</instruction>
|
||||
</instructions>
|
||||
@ -41,6 +42,7 @@
|
||||
<instruction type="objectType">objectType.xml</instruction>
|
||||
<instruction type="option">option.xml</instruction>
|
||||
<instruction type="pagemenu">pagemenu.xml</instruction>
|
||||
<instruction type="eventListener">eventListener.xml</instruction>
|
||||
<instruction type="templatelistener">templatelistener.xml</instruction>
|
||||
<instruction type="aclOption">acloptions.xml</instruction>
|
||||
</instructions>
|
||||
|
Loading…
Reference in New Issue
Block a user