Browse Source
- Split the Chats widget in two (and create Rooms widget out of it)
- Split the Chats widget in two (and create Rooms widget out of it)
- Continue MUC implementation with join/disconnect - Fix MovimWebsocket initialisation - Change some icons - Add a empty view in Chatpull/16/head
24 changed files with 330 additions and 222 deletions
-
13app/assets/js/movim_websocket.js
-
3app/models/conference/ConferenceDAO.php
-
5app/views/chat.tpl
-
47app/widgets/Chat/Chat.php
-
4app/widgets/Chat/_chat_empty.tpl
-
2app/widgets/Chat/_chat_header.tpl
-
9app/widgets/Chat/_chat_header_room.tpl
-
3app/widgets/Chat/chat.tpl
-
2app/widgets/Chat/locales.ini
-
154app/widgets/Chats/Chats.php
-
9app/widgets/Chats/_chats.tpl
-
11app/widgets/Chats/chats.js
-
13app/widgets/Chats/chats.tpl
-
15app/widgets/Chats/locales.ini
-
2app/widgets/Header/_header_chat.tpl
-
2app/widgets/Navigation/navigation.tpl
-
179app/widgets/Rooms/Rooms.php
-
17app/widgets/Rooms/_rooms.tpl
-
4app/widgets/Rooms/_rooms_add.tpl
-
2app/widgets/Rooms/_rooms_remove.tpl
-
17app/widgets/Rooms/locales.ini
-
33app/widgets/Rooms/rooms.js
-
1app/widgets/Rooms/rooms.tpl
-
5themes/material/css/style.css
@ -0,0 +1,4 @@ |
|||
<div class="placeholder icon forum"> |
|||
<h1>{$c->__('chat.empty_title')}</h1> |
|||
<h4>{$c->__('chat.empty_text')}</h4> |
|||
</div> |
@ -1,10 +1,15 @@ |
|||
<span id="back" class="icon" onclick="MovimTpl.hidePanel()"><i class="md md-arrow-back"></i></span> |
|||
<span id="back" class="icon" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();"><i class="md md-arrow-back"></i></span> |
|||
|
|||
<ul class="active"> |
|||
<li onclick="Chats_ajaxRemoveRoomConfirmation('{$room}')"> |
|||
<li onclick="Rooms_ajaxRemoveConfirm('{$room}')"> |
|||
<span class="icon"> |
|||
<i class="md md-delete"></i> |
|||
</span> |
|||
</li> |
|||
<li onclick="Rooms_ajaxExit('{$room}'); MovimTpl.hidePanel();"> |
|||
<span class="icon"> |
|||
<i class="md md-close"></i> |
|||
</span> |
|||
</li> |
|||
</ul> |
|||
<h2>{$room}</h2> |
@ -1,2 +1 @@ |
|||
<div id="chat_widget"> |
|||
</div> |
|||
<div id="chat_widget">{$c->prepareEmpty()}</div> |
@ -1,10 +1,3 @@ |
|||
<div id="chats_widget"> |
|||
<ul id="chats_widget_list" class="thick active divided"> |
|||
{$list} |
|||
</ul> |
|||
<!-- |
|||
<a class="button action color"> |
|||
<i class="md md-playlist-add"></i> |
|||
</a> |
|||
--> |
|||
</div> |
|||
<ul id="chats_widget_list" class="thick active divided"> |
|||
{$list} |
|||
</ul> |
@ -1,24 +1,9 @@ |
|||
[chats] |
|||
chats.empty = 'Open a new conversation here by clicking on the plus button bellow' |
|||
chats.add = 'Chat with a contact' |
|||
chats.add_room = 'Add a chatroom' |
|||
|
|||
[message] |
|||
message.encrypted = 'Encrypted message' |
|||
|
|||
[chatrooms] |
|||
chatrooms.title = 'Chatrooms' |
|||
chatrooms.id = 'Chat Room ID' |
|||
chatrooms.name = 'Name' |
|||
chatrooms.name_placeholder = 'My Favorite Room' |
|||
chatrooms.nickname = 'Nickname' |
|||
chatrooms.bad_id = 'Bad Chatroom ID' |
|||
chatrooms.empty_name = 'Empty name' |
|||
chatrooms.remove_title = 'Remove a chatroom' |
|||
chatrooms.remove_text = 'You are going to remove the following chatroom. Please confirm your action.' |
|||
|
|||
[add] |
|||
button.chat = 'Chat' |
|||
|
|||
[bookmarks] |
|||
bookmarks.updated = 'Bookmarks updated' |
@ -0,0 +1,179 @@ |
|||
<?php |
|||
|
|||
use Moxl\Xec\Action\Presence\Muc; |
|||
use Moxl\Xec\Action\Bookmark\Get; |
|||
use Moxl\Xec\Action\Bookmark\Set; |
|||
use Moxl\Xec\Action\Presence\Unavailable; |
|||
|
|||
class Rooms extends WidgetCommon |
|||
{ |
|||
function load() |
|||
{ |
|||
$this->addjs('rooms.js'); |
|||
$this->registerEvent('bookmark_set_handle', 'onBookmark'); |
|||
$this->registerEvent('presence_muc_handle', 'onConnected'); |
|||
$this->registerEvent('presence_unavailable_handle', 'onDisconnected'); |
|||
} |
|||
|
|||
function onBookmark() |
|||
{ |
|||
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms()); |
|||
Notification::append(null, $this->__('bookmarks.updated')); |
|||
RPC::call('Rooms.refresh'); |
|||
RPC::call('MovimTpl.hidePanel'); |
|||
} |
|||
|
|||
function onConnected() |
|||
{ |
|||
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms()); |
|||
Notification::append(null, $this->__('chatrooms.connected')); |
|||
RPC::call('Rooms.refresh'); |
|||
} |
|||
|
|||
function onDisconnected() |
|||
{ |
|||
// We reset the Chat view
|
|||
$c = new Chat(); |
|||
$c->ajaxGet(); |
|||
|
|||
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms()); |
|||
Notification::append(null, $this->__('chatrooms.disconnected')); |
|||
RPC::call('Rooms.refresh'); |
|||
} |
|||
|
|||
/** |
|||
* @brief Display the add room form |
|||
*/ |
|||
function ajaxAdd() |
|||
{ |
|||
$view = $this->tpl(); |
|||
|
|||
$cd = new \Modl\ContactDAO; |
|||
$view->assign('me', $cd->get()); |
|||
|
|||
Dialog::fill($view->draw('_rooms_add', true)); |
|||
} |
|||
|
|||
/** |
|||
* @brief Display the remove room confirmation |
|||
*/ |
|||
function ajaxRemoveConfirm($room) |
|||
{ |
|||
$view = $this->tpl(); |
|||
|
|||
$view->assign('room', $room); |
|||
|
|||
Dialog::fill($view->draw('_rooms_remove', true)); |
|||
} |
|||
|
|||
/** |
|||
* @brief Remove a room |
|||
*/ |
|||
function ajaxRemove($room) |
|||
{ |
|||
$cd = new \modl\ConferenceDAO(); |
|||
$cd->deleteNode($room); |
|||
|
|||
$this->setBookmark(); |
|||
} |
|||
|
|||
/** |
|||
* @brief Join a chatroom |
|||
*/ |
|||
function ajaxJoin($jid, $nickname) |
|||
{ |
|||
$p = new Muc; |
|||
$p->setTo($jid) |
|||
->setNickname($nickname) |
|||
->request(); |
|||
} |
|||
|
|||
/** |
|||
* @brief Exit a room |
|||
* |
|||
* @param string $room |
|||
*/ |
|||
function ajaxExit($room) |
|||
{ |
|||
$session = \Sessionx::start(); |
|||
|
|||
$pu = new Unavailable; |
|||
$pu->setTo($room) |
|||
->setResource($session->username) |
|||
->request(); |
|||
} |
|||
|
|||
/** |
|||
* @brief Display the add room form |
|||
*/ |
|||
function ajaxChatroomAdd($form) |
|||
{ |
|||
if(!filter_var($form['jid'], FILTER_VALIDATE_EMAIL)) { |
|||
Notification::append(null, $this->__('chatrooms.bad_id')); |
|||
} elseif(trim($form['name']) == '') { |
|||
Notification::append(null, $this->__('chatrooms.empty_name')); |
|||
} else { |
|||
$item = array( |
|||
'type' => 'conference', |
|||
'name' => $form['name'], |
|||
'autojoin' => $form['autojoin'], |
|||
'nick' => $form['nick'], |
|||
'jid' => $form['jid']); |
|||
$this->setBookmark($item); |
|||
RPC::call('Dialog.clear'); |
|||
} |
|||
} |
|||
|
|||
private function setBookmark($item = false) |
|||
{ |
|||
$arr = array(); |
|||
|
|||
if($item) { |
|||
array_push($arr, $item); |
|||
} |
|||
|
|||
$sd = new \modl\SubscriptionDAO(); |
|||
$cd = new \modl\ConferenceDAO(); |
|||
|
|||
foreach($sd->getSubscribed() as $s) { |
|||
array_push($arr, |
|||
array( |
|||
'type' => 'subscription', |
|||
'server' => $s->server, |
|||
'title' => $s->title, |
|||
'subid' => $s->subid, |
|||
'tags' => unserialize($s->tags), |
|||
'node' => $s->node)); |
|||
} |
|||
|
|||
foreach($cd->getAll() as $c) { |
|||
array_push($arr, |
|||
array( |
|||
'type' => 'conference', |
|||
'name' => $c->name, |
|||
'autojoin' => $c->autojoin, |
|||
'nick' => $c->nick, |
|||
'jid' => $c->conference)); |
|||
} |
|||
|
|||
|
|||
$b = new Set; |
|||
$b->setArr($arr) |
|||
->setTo($this->user->getLogin()) |
|||
->request(); |
|||
} |
|||
|
|||
function prepareRooms() |
|||
{ |
|||
$view = $this->tpl(); |
|||
$cod = new \modl\ConferenceDAO(); |
|||
$view->assign('conferences', $cod->getAll()); |
|||
|
|||
return $view->draw('_rooms', true); |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
$this->view->assign('list', $this->prepareRooms()); |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
<ul class="thick divided active"> |
|||
<li class="subheader"> |
|||
{$c->__('chatrooms.title')} |
|||
</li> |
|||
{loop="$conferences"} |
|||
<li data-jid="{$value->conference}" |
|||
data-nick="{$value->nick}" |
|||
class="room {if="$value->status == 1"}online{/if}"> |
|||
{if="$value->status == 1"} |
|||
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people"></i></span> |
|||
{else} |
|||
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people-outline"></i></span> |
|||
{/if} |
|||
<span>{$value->name}</span> |
|||
</li> |
|||
{/loop} |
|||
</ul> |
@ -0,0 +1,17 @@ |
|||
rooms.add = 'Add a chatroom' |
|||
|
|||
[chatrooms] |
|||
chatrooms.title = 'Chatrooms' |
|||
chatrooms.id = 'Chat Room ID' |
|||
chatrooms.name = 'Name' |
|||
chatrooms.name_placeholder = 'My Favorite Room' |
|||
chatrooms.nickname = 'Nickname' |
|||
chatrooms.bad_id = 'Bad Chatroom ID' |
|||
chatrooms.empty_name = 'Empty name' |
|||
chatrooms.remove_title = 'Remove a chatroom' |
|||
chatrooms.remove_text = 'You are going to remove the following chatroom. Please confirm your action.' |
|||
chatrooms.connected = 'Connected to the chatroom' |
|||
chatrooms.disconnected = 'Disconnected from the chatroom' |
|||
|
|||
[bookmarks] |
|||
bookmarks.updated = 'Bookmarks updated' |
@ -0,0 +1,33 @@ |
|||
var Rooms = { |
|||
refresh: function() { |
|||
var items = document.querySelectorAll('#rooms_widget ul li:not(.subheader)'); |
|||
var i = 0; |
|||
while(i < items.length) |
|||
{ |
|||
if(items[i].dataset.jid != null) { |
|||
items[i].onclick = function(e) { |
|||
console.log(this); |
|||
if(!movim_has_class(this, 'online')) { |
|||
Rooms_ajaxJoin(this.dataset.jid, this.dataset.nick); |
|||
} |
|||
|
|||
Chat_ajaxGetRoom(this.dataset.jid); |
|||
Chats.reset(items); |
|||
movim_add_class(this, 'active'); |
|||
} |
|||
} |
|||
|
|||
i++; |
|||
} |
|||
}, |
|||
|
|||
reset: function(list) { |
|||
for(i = 0; i < list.length; i++) { |
|||
movim_remove_class(list[i], 'active'); |
|||
} |
|||
} |
|||
} |
|||
|
|||
MovimWebsocket.attach(function() { |
|||
Rooms.refresh(); |
|||
}); |
@ -0,0 +1 @@ |
|||
<div id="rooms_widget">{$list}</div> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue