diff --git a/file/js/TimWolla.WCF.Chat.js b/file/js/TimWolla.WCF.Chat.js index 7a8e9f6..83a1176 100644 --- a/file/js/TimWolla.WCF.Chat.js +++ b/file/js/TimWolla.WCF.Chat.js @@ -35,6 +35,16 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; window.history.replaceState({}, '', target.attr('href')); $('.activeMenuItem .chatRoom').parent().removeClass('activeMenuItem'); target.parent().addClass('activeMenuItem'); + $.ajax(target.attr('href'), { + dataType: 'json', + data: { ajax: 1 }, + type: 'POST', + success: function (data, textStatus, jqXHR) { + $('#topic').text(data.topic); + if (data.topic == '') $('#topic').hide(); + else $('#topic').show(); + } + }); } }; })(jQuery, document); \ No newline at end of file diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index 13e3e84..d1c77ff 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -77,6 +77,15 @@ 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(); @@ -96,7 +105,10 @@ public function readDefaultSmileys() { public function readParameters() { parent::readParameters(); - if (isset($_GET['id'])) $this->roomID = (int) $_GET['id']; + if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id']; + if (isset($_REQUEST['ajax'])) { + $this->useTemplate = false; + } } /** @@ -162,5 +174,11 @@ public function show() { // remove index breadcrumb WCF::getBreadcrumbs()->remove(0); parent::show(); + + @header('Content-type: application/json'); + echo \wcf\util\JSON::encode(array( + 'topic' => WCF::getLanguage()->get($this->room->topic) + )); + exit; } } diff --git a/template/chat.tpl b/template/chat.tpl index 5ac0cfe..9c8d007 100644 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -46,7 +46,7 @@ padding: 0px 15px 25px; } - .topic, #smileyList { + #topic, #smileyList { padding: 5px; } @@ -183,7 +183,7 @@
-
topic|language} style="display: none;"{/if}> +
topic|language} style="display: none;"{/if}> {$room->topic|language}