]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14651, improved chat module interface"
authordongsheng <dongsheng>
Thu, 8 Oct 2009 06:37:00 +0000 (06:37 +0000)
committerdongsheng <dongsheng>
Thu, 8 Oct 2009 06:37:00 +0000 (06:37 +0000)
15 files changed:
lang/en_utf8/chat.php
mod/chat/chat_ajax.php
mod/chat/gui_ajax/index.php
mod/chat/gui_ajax/script.js
mod/chat/gui_ajax/theme/bubble/bubbles.png [new file with mode: 0755]
mod/chat/gui_ajax/theme/bubble/chat.css [new file with mode: 0755]
mod/chat/gui_ajax/theme/bubble/config.php [new file with mode: 0755]
mod/chat/gui_ajax/theme/bubble/horizontal.png [new file with mode: 0755]
mod/chat/gui_ajax/theme/bubble/input.png [new file with mode: 0755]
mod/chat/gui_ajax/theme/bubble/vertical.png [new file with mode: 0755]
mod/chat/gui_ajax/theme/compact/chat.css [new file with mode: 0755]
mod/chat/gui_ajax/theme/compact/config.php [new file with mode: 0755]
mod/chat/lib.php
mod/chat/view.php
theme/standard/styles_layout.css

index ca5a09a0d738fc858c206a91b47bdbbadafcd851..ea1cf3bc716fa76b393fa5da61d6b9789f2dbdac 100644 (file)
@@ -40,6 +40,7 @@ $string['helpchatting'] = 'Help with chatting';
 $string['idle'] = 'Idle';
 $string['invalidid'] = 'Could not find that chat room!';
 $string['inputarea'] = 'Input area';
+$string['messageyoubeep'] = 'You beeped $a';
 $string['messagebeepseveryone'] = '$a beeps everyone!';
 $string['messagebeepsyou'] = '$a has just beeped you!';
 $string['messageenter'] = '$a has just entered this chat';
index 6af584f6a04f31f296f71ca70af8d667997704d7..bee3580d0b3b0a00dc781a505409e06297ad371c 100644 (file)
@@ -20,6 +20,7 @@ require_once(dirname(__FILE__) . '/lib.php');
 $action = optional_param('action', '', PARAM_ALPHANUM);
 $beep_id      = optional_param('beep', '', PARAM_RAW);
 $chat_sid     = required_param('chat_sid', PARAM_ALPHANUM);
+$theme        = required_param('theme', PARAM_ALPHANUM);
 $chat_message = optional_param('chat_message', '', PARAM_RAW);
 $chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT);
 $chat_lastrow  = optional_param('chat_lastrow', 1, PARAM_INT);
@@ -124,22 +125,15 @@ case 'update':
         foreach ($messages as $n => &$message) {
             $tmp = new stdclass;
             // when somebody enter room, user list will be updated
-            if($message->system == 1){
+            if (!empty($message->system)){
                 $send_user_list = true;
-                $tmp->type = 'system';
                 $users = chat_format_userlist(chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid), $course);
             }
-            if ($html = chat_format_message($message, $chatuser->course, $USER, $chat_lastrow)) {
-                if ($html->beep) {
-                    $tmp->type = 'beep';
-                } elseif (empty($tmp->type)) {
-                    $tmp->type = 'user';
-                }
-                $tmp->mymessage = ($USER->id == $message->userid);
-                $tmp->msg  = $html->html;
-                $message = $tmp;
+            if ($html = chat_format_message_theme($message, $chatuser->course, $USER, $theme)) {
+                $message->mymessage = ($USER->id == $message->userid);
+                $message->message  = $html->html;
             } else {
-                unset($message);
+                unset($messages[$n]);
             }
         }
     }
index 83987ece14a18c0c6ec37232b47a541f5e9cb4ad..7d69560d17c0edd1902d59a48325aad42842dafe 100644 (file)
@@ -1,15 +1,16 @@
 <?php
 require_once('../../../config.php');
 require_once('../lib.php');
+
 $id      = required_param('id', PARAM_INT);
 $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
+$theme   = optional_param('theme', 'compact', PARAM_ALPHANUM);
 
 $url = new moodle_url($CFG->wwwroot.'/mod/chat/gui_ajax/index.php', array('id'=>$id));
 if ($groupid !== 0) {
     $url->param('groupid', $groupid);
 }
 $PAGE->set_url($url);
-
 if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
     print_error('invalidid', 'chat');
 }
@@ -53,6 +54,7 @@ if (!$chat_sid = chat_login_user($chat->id, 'ajax', $groupid, $course)) {
 
 $str_title = format_string($course->shortname) . ": ".format_string($chat->name,true).$groupname;
 $str_send  = get_string('send', 'chat'); 
+$str_themes = get_string('themes'); 
 
 $PAGE->set_generaltype('popup');
 $PAGE->set_title('Chat');
@@ -62,13 +64,19 @@ $PAGE->requires->yui_lib('layout');
 $PAGE->requires->yui_lib('container');
 $PAGE->requires->yui_lib('connection');
 $PAGE->requires->yui_lib('json');
-$PAGE->requires->yui_lib('button');
-$PAGE->requires->yui_lib('selector');
+$PAGE->requires->yui_lib('animation');
+$PAGE->requires->yui_lib('menu');
+
+if (!file_exists(dirname(__FILE__) . '/theme/'.$theme.'/chat.css')) {
+    $theme = 'bubble';
+}
 $PAGE->requires->data_for_js('chat_cfg', array(
     'home'=>$CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id,
+    'chaturl'=>$CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
+    'theme'=>$theme,
     'userid'=>$USER->id,
     'sid'=>$chat_sid,
-    'timer'=>5000,
+    'timer'=>3000,
     'chat_lasttime'=>0,
     'chat_lastrow'=>null,
     'chatroom_name'=>$str_title
@@ -84,38 +92,44 @@ $PAGE->requires->string_for_js('talk', 'chat');
 
 $PAGE->requires->js('mod/chat/gui_ajax/script.js');
 $PAGE->requires->yui_lib('animation')->in_head();
-$PAGE->requires->css('mod/chat/chat.css');
 
+$PAGE->requires->css('mod/chat/gui_ajax/theme/'.$theme.'/chat.css');
 $PAGE->add_body_class('yui-skin-sam');
+$PAGE->set_generaltype('embedded');
 
 echo $OUTPUT->header();
-echo $OUTPUT->heading($str_title, 1);
 $intro = format_text($chat->intro, $chat->introformat);
+$home_url = $CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id;
 
 echo <<<DIVS
+<!--
 <div id="chat-header">
-{$chat->name} {$intro}
+{$chat->name} <p>{$intro}</p>
 </div>
+-->
 <div id="chat-userlist">
     <ul id="users-list">
-        <li></li>
     </ul>
 </div>
-<div id="chat_options">
-</div>
+<div id="chat-options"></div>
 <div id="chat-messages">
-    <div>
-        <ul id="messages-list">
-            <li></li>
-        <ul>
-    </div>
-</div>
-<div id="chat-input">
-    <input type="text" id="input_msgbox" value="" size="70" />
-    <input type="button" id="btn_send" value="$str_send" />
+    <ul id="messages-list"><ul>
 </div>
-<div id="notify">
+<div id="chat-input-area">
+<table width="100%">
+<tr>
+    <td>
+         &raquo;
+        <input type="text" disabled="true" id="input-message" value="Loading..." size="50" />
+        <input type="button" id="button-send" value="$str_send" />
+    </td>
+    <td align="right">
+        <a id="choosetheme" href="###">{$str_themes} ▶</a>
+    </td>
+</tr>
+</table>
 </div>
+<div id="chat-notify"></div>
 DIVS;
 echo $OUTPUT->footer();
 ?>
index 550d83a9eb80b8031c238d3ca2aee0d7c2994046..a0c848e7ec0f96f7e57f1d695e7aac8effba87be 100644 (file)
@@ -1,5 +1,3 @@
-// record msg IDs
-
 YAHOO.namespace('moodle.chat');
 YAHOO.moodle.chat.api = moodle_cfg.wwwroot+'/mod/chat/chat_ajax.php';
 YAHOO.moodle.chat.interval = null;
@@ -7,17 +5,17 @@ YAHOO.moodle.chat.chat_input_element = null;
 YAHOO.moodle.chat.msgs = [];
 YAHOO.moodle.chat.scrollable = true;
 
+
 (function() {
 var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
 // window.onload
 Event.onDOMReady(function() {
-    // build layout
     var layout = new YAHOO.widget.Layout({
         units: [
-        { position: 'top', height: 50, body: 'chat-header', gutter: '5px', resize: false },
+        //{ position: 'top', height: 50, body: 'chat-header', gutter: '5px', resize: false },
         { position: 'right', width: 180, resize: true, gutter: '5px', scroll: true, body: 'chat-userlist', animate: false },
-        { position: 'bottom', height: 42, resize: false, body: 'chat-input', gutter: '5px', collapse: false, resize: false },
-        //{ position: 'left', header: 'Options', width: 200, resize: true, body: 'chat_options', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: false },
+        { position: 'bottom', height: 42, resize: false, body: 'chat-input-area', gutter: '5px', collapse: false, resize: false },
+        //{ position: 'left', header: 'Options', width: 200, resize: true, body: 'chat-options', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: false },
         { position: 'center', body: 'chat-messages', gutter: '5px', scroll: true }
         ]
     });
@@ -27,7 +25,7 @@ Event.onDOMReady(function() {
         });
     });
     layout.render();
-    Event.on('btn_send', 'click', function(ev) {
+    Event.on('button-send', 'click', function(ev) {
         Event.stopEvent(ev);
         YAHOO.moodle.chat.send_message();
     });
@@ -39,7 +37,7 @@ Event.onDOMReady(function() {
         Event.stopEvent(ev);
         YAHOO.moodle.chat.scrollable = true;
     });
-    YAHOO.moodle.chat.chat_input_element = document.getElementById('input_msgbox');
+    YAHOO.moodle.chat.chat_input_element = document.getElementById('input-message');
     YAHOO.moodle.chat.chat_input_element.onkeypress = function(ev) {
         var e = (ev)?ev:event;
         if (e.keyCode == 13) {
@@ -51,6 +49,9 @@ Event.onDOMReady(function() {
     this.cb = {
         success: function(o){
             YAHOO.moodle.chat.chat_input_element.focus();
+            document.getElementById('input-message').disabled = false;
+            document.getElementById('input-message').value = '';
+            document.getElementById('input-message').focus();
             if(o.responseText){
                 var data = YAHOO.lang.JSON.parse(o.responseText);
             } else {
@@ -63,10 +64,22 @@ Event.onDOMReady(function() {
     params.action = 'init';
     params.chat_init = 1;
     params.chat_sid = chat_cfg.sid;
+    params.theme = chat_cfg.theme;
     var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api, this.cb, build_querystring(params));
     YAHOO.moodle.chat.interval = setInterval(function(){
         YAHOO.moodle.chat.update_messages();
     }, chat_cfg.timer);
+    var oMenu = new YAHOO.widget.Menu("basicmenu", { xy:[0,0] });
+    oMenu.addItems([
+            { text: "Bubble", url: chat_cfg.chaturl+'&theme=bubble'},
+            { text: "Compact", url: chat_cfg.chaturl+'&theme=compact'},
+        ]);
+    oMenu.render(document.body);
+    YAHOO.util.Event.addListener('choosetheme', 'click', function(e) {
+        var position = YAHOO.util.Event.getXY(e);
+        oMenu.moveTo(position[0]-120, position[1]-70);
+        oMenu.show();
+        });
 });
 })();
 
@@ -82,7 +95,7 @@ function in_array(f, t){
 }
 
 YAHOO.moodle.chat.talkto = function(name) {
-    var msg = document.getElementById('input_msgbox');
+    var msg = document.getElementById('input-message');
     msg.value = "To "+name+": ";
     msg.focus();
 }
@@ -90,8 +103,8 @@ YAHOO.moodle.chat.talkto = function(name) {
 YAHOO.moodle.chat.send_callback = {
     success: function(o) {
         if(o.responseText == 200){
-            document.getElementById('btn_send').value = mstr.chat.send;
-            document.getElementById('input_msgbox').value = '';
+            document.getElementById('button-send').value = mstr.chat.send;
+            document.getElementById('input-message').value = '';
         }
 
         clearInterval(YAHOO.moodle.chat.interval)
@@ -99,20 +112,20 @@ YAHOO.moodle.chat.send_callback = {
         YAHOO.moodle.chat.interval = setInterval(function(){
             YAHOO.moodle.chat.update_messages();
         }, chat_cfg.timer);
-        //document.getElementById('input_msgbox').focus();
+        //document.getElementById('input-message').focus();
     }
 }
 YAHOO.moodle.chat.send_message = function(ev) {
-    var msg = document.getElementById('input_msgbox').value;
-    var el_send = document.getElementById('btn_send');
+    var msg = document.getElementById('input-message').value;
+    var el_send = document.getElementById('button-send');
     if (!msg) {
-        alert('Empty message not allowed');
         return;
     }
     el_send.value = mstr.chat.sending;
     var params = {};
     params.chat_message=msg;
     params.chat_sid=chat_cfg.sid;
+    params.theme = chat_cfg.theme;
     var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=chat", YAHOO.moodle.chat.send_callback, build_querystring(params));
 }
 
@@ -121,6 +134,7 @@ YAHOO.moodle.chat.send_beep = function(user_id) {
     var params = {};
     params.chat_sid = chat_cfg.sid;
     params.beep=user_id;
+    params.theme = chat_cfg.theme;
     var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=chat", YAHOO.moodle.chat.send_callback, build_querystring(params));
 }
 
@@ -137,9 +151,16 @@ YAHOO.moodle.chat.update_users = function(users) {
         html += '<tr>';
         html += '<td>' + users[i].picture + '</td>';
         html += '<td>';
-        html += ' <a target="_blank" href="'+users[i].url+'">'+ users[i].name+'<br/>';
-        html += ' <a href="###" onclick="YAHOO.moodle.chat.talkto(\''+users[i].name+'\')">'+mstr.chat.talk+'</a> ';
-        html += ' <a href="###" onclick="YAHOO.moodle.chat.send_beep('+users[i].id+')">'+mstr.chat.beep+'</a>';
+        if (users[i].id==chat_cfg.userid) {
+            html += ' <strong><a target="_blank" href="'+users[i].url+'">'+ users[i].name+'</a></strong>';
+        } else {
+            html += ' <a target="_blank" href="'+users[i].url+'">'+ users[i].name+'</a>';
+        }
+        html += '<br />';
+        if (users[i].id!=chat_cfg.userid) {
+            html += ' <a href="###" onclick="YAHOO.moodle.chat.talkto(\''+users[i].name+'\')">'+mstr.chat.talk+'</a> ';
+            html += ' <a href="###" onclick="YAHOO.moodle.chat.send_beep('+users[i].id+')">'+mstr.chat.beep+'</a>';
+        }
         html += '</td>';
         html += '</tr>';
         html += '</table>';
@@ -160,6 +181,7 @@ YAHOO.moodle.chat.update_messages = function() {
     }
     params.chat_lasttime = chat_cfg.chat_lasttime;
     params.chat_sid = chat_cfg.sid;
+    params.theme = chat_cfg.theme;
     var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=update", YAHOO.moodle.chat.update_cb, build_querystring(params));
 }
 
@@ -184,14 +206,14 @@ YAHOO.moodle.chat.append_msg = function(key, msg, row) {
     } else {
         item.className = 'mdl-chat-entry';
     }
-    item.innerHTML = msg.msg;
-    if(msg.type && msg.type == 'beep'){
-        document.getElementById('notify').innerHTML = '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
+    item.innerHTML = msg.message;
+    if(msg.type && msg.type == 'beep') {
+        document.getElementById('chat-notify').innerHTML = '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
     }
     list.appendChild(item);
     if (!row) {
         var anim = new YAHOO.util.ColorAnim(item.id, YAHOO.moodle.chat.oddmsg_cfg);
-        anim.animate(); 
+        //anim.animate(); 
     }
     if (msg.mymessage) {
         //var anim = new YAHOO.util.ColorAnim(item.id, YAHOO.moodle.chat.mymsg_cfg);
diff --git a/mod/chat/gui_ajax/theme/bubble/bubbles.png b/mod/chat/gui_ajax/theme/bubble/bubbles.png
new file mode 100755 (executable)
index 0000000..e81653b
Binary files /dev/null and b/mod/chat/gui_ajax/theme/bubble/bubbles.png differ
diff --git a/mod/chat/gui_ajax/theme/bubble/chat.css b/mod/chat/gui_ajax/theme/bubble/chat.css
new file mode 100755 (executable)
index 0000000..cda0463
--- /dev/null
@@ -0,0 +1,37 @@
+.yui-skin-sam .yui-layout .yui-layout-hd { border:0; }
+.yui-skin-sam  .yui-layout .yui-layout-unit div.yui-layout-bd-nohd { border:0; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-bd { border:0; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-unit-right { background: white; }
+.yui-skin-sam .yui-layout-unit-bottom  { background: #F2F2F2; }
+.yui-skin-sam .yui-layout-unit-right { background: #eef2f8; }
+.yui-skin-sam .yui-layout-unit-center { background: white; }
+.yui-skin-sam .yui-layout-unit-top { background: #FFE39D; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-bd { background: transparent; }
+
+#input-message {
+    background:#FFFFFF url(input.png) repeat-x scroll 0 0;
+    padding:0 9px;
+    border: 1px solid #999;
+    border-radius: 9px;
+    -moz-border-radius: 9px;
+}
+
+.mdl-chat-entry .topleft { background:transparent url(bubbles.png) no-repeat scroll left top; height:9px; width:18px; }
+.mdl-chat-entry .top { background:transparent url(horizontal.png) repeat-x scroll center top; font-size:1px; height:9px; }
+.mdl-chat-entry .topright { background:transparent url(bubbles.png) no-repeat scroll -18px top; height:9px; width:11px; }
+.mdl-chat-entry .left { background:transparent url(vertical.png) repeat-y scroll left center; width:18px; }
+.mdl-chat-entry .conmts { background:#DCDCDC none repeat scroll 0 0; color:#000000; text-shadow:0 1px 0 #EEEEEE; }
+.mdl-chat-entry .right { background:transparent url(vertical.png) repeat-y scroll -18px 0; width:11px; }
+.mdl-chat-entry .bottomleft { background:transparent url(bubbles.png) no-repeat scroll left -9px; height:12px; width:18px; }
+.mdl-chat-entry .bottomright { background:transparent url(bubbles.png) no-repeat scroll right -9px; height:12px; width:11px; }
+.mdl-chat-entry .bottom { background:transparent url(horizontal.png) repeat-x scroll 0 -9px; height:12px; }
+
+.mdl-chat-my-entry .topleft{background:url(bubbles.png) no-repeat 0 -21px;height:9px;width:11px;}
+.mdl-chat-my-entry .topright{background:url(bubbles.png) no-repeat -11px -21px;height:9px;width:18px;}
+.mdl-chat-my-entry .bottomleft{background:url(bubbles.png) no-repeat 0 bottom;width:11px;height:12px;}
+.mdl-chat-my-entry .bottomright{background:url(bubbles.png) no-repeat right bottom;width:18px;height:12px;}
+.mdl-chat-my-entry .top{background:url(horizontal.png) repeat-x 0 -21px;font-size:1px;height:9px;}
+.mdl-chat-my-entry .bottom{background:url(horizontal.png) repeat-x bottom;height:12px;}
+.mdl-chat-my-entry .left{background:url(vertical.png) repeat-y -29px 0;width:11px;}
+.mdl-chat-my-entry .right{background:url(vertical.png) repeat-y right;width:18px;}
+.mdl-chat-my-entry .conmts{background:#C0E668;color:#000;}
diff --git a/mod/chat/gui_ajax/theme/bubble/config.php b/mod/chat/gui_ajax/theme/bubble/config.php
new file mode 100755 (executable)
index 0000000..dbdf3c2
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+$chattheme_cfg = new stdclass;
+$chattheme_cfg->avatar = true;
+$chattheme_cfg->align  = true;
+$chattheme_cfg->event_message = <<<TEMPLATE
+<div class="chat-event">
+<span class="time">___time___</span>
+<a target='_blank' href="___senderprofile___">___sender___</a>
+<span class="event">___event___</span>
+</div>
+TEMPLATE;
+$chattheme_cfg->user_message_left = <<<TEMPLATE
+<table class='chat-message'___tablealign___><tr>
+<td class="picture" valign="middle" width="32px">
+___avatar___
+</td>
+<td class="text">
+    <table cellspacing="0" cellpadding="0" border="0" ___mymessageclass___>
+    <tbody>
+        <tr><td class="topleft"></td><td class="top"></td><td class="topright"></td></tr>
+        <tr>
+            <td class="left"></td>
+            <td class="conmts">
+            ___message___
+            </td>
+            <td class="right"></td>
+        </tr>
+        <tr>
+            <td class="bottomleft"></td>
+            <td class="bottom"></td>
+            <td class="bottomright"></td>
+        </tr>
+    </tbody>
+    </table>
+</td>
+<tr>
+<td colspan="2"___align___>
+    <span class="time">___time___</span>
+    <span class="user">___sender___</span>
+</td>
+</tr>
+TEMPLATE;
+$chattheme_cfg->user_message_right = <<<TEMPLATE
+<table class='chat-message'___tablealign___><tr>
+<td class="text">
+    <table cellspacing="0" cellpadding="0" border="0" ___mymessageclass___>
+    <tbody>
+        <tr><td class="topleft"></td><td class="top"></td><td class="topright"></td></tr>
+        <tr>
+            <td class="left"></td>
+            <td class="conmts">
+            ___message___
+            </td>
+            <td class="right"></td>
+        </tr>
+        <tr>
+            <td class="bottomleft"></td>
+            <td class="bottom"></td>
+            <td class="bottomright"></td>
+        </tr>
+    </tbody>
+    </table>
+</td>
+<td class="picture" valign="middle" width="32px">
+___avatar___
+</td>
+<tr>
+<td colspan="2" ___tablealign___>
+    <span class="time">___time___</span>
+    <span class="user">___sender___</span>
+</td>
+</tr>
+TEMPLATE;
diff --git a/mod/chat/gui_ajax/theme/bubble/horizontal.png b/mod/chat/gui_ajax/theme/bubble/horizontal.png
new file mode 100755 (executable)
index 0000000..2248e4d
Binary files /dev/null and b/mod/chat/gui_ajax/theme/bubble/horizontal.png differ
diff --git a/mod/chat/gui_ajax/theme/bubble/input.png b/mod/chat/gui_ajax/theme/bubble/input.png
new file mode 100755 (executable)
index 0000000..2d7997c
Binary files /dev/null and b/mod/chat/gui_ajax/theme/bubble/input.png differ
diff --git a/mod/chat/gui_ajax/theme/bubble/vertical.png b/mod/chat/gui_ajax/theme/bubble/vertical.png
new file mode 100755 (executable)
index 0000000..f9b145f
Binary files /dev/null and b/mod/chat/gui_ajax/theme/bubble/vertical.png differ
diff --git a/mod/chat/gui_ajax/theme/compact/chat.css b/mod/chat/gui_ajax/theme/compact/chat.css
new file mode 100755 (executable)
index 0000000..6c8e3eb
--- /dev/null
@@ -0,0 +1,51 @@
+.yui-skin-sam .yui-layout .yui-layout-hd { border:0; }
+.yui-skin-sam  .yui-layout .yui-layout-unit div.yui-layout-bd-nohd { border:0; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-bd { border:0; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-unit-right { background: white; }
+.yui-skin-sam .yui-layout-unit-bottom  { background: #F2F2F2; }
+.yui-skin-sam .yui-layout-unit-right { background: #eef2f8; }
+.yui-skin-sam .yui-layout-unit-center { background: white; }
+.yui-skin-sam .yui-layout-unit-top { background: #FFE39D; }
+.yui-skin-sam .yui-layout .yui-layout-unit div.yui-layout-bd { background: transparent; }
+
+#input-message {
+    background:#FFFFFF url(input.png) repeat-x scroll 0 0;
+    border: 1px solid #999;
+}
+.chat-message {
+    margin: 3px;
+}
+.mdl-chat-entry .meta {
+    background: #82b5ee;
+    border-bottom: 1px solid white;
+    -moz-border-radius-topleft: 6px;
+    -moz-border-radius-topright: 6px;
+    border-top-left-radius: 6px;
+    border-top-right-radius: 6px;
+}
+
+.mdl-chat-entry .text{
+    color:white;
+    padding: 3px;
+    background: #82b5ee;
+    -moz-border-radius-bottomleft: 6px;
+    -moz-border-radius-bottomright: 6px;
+    border-bottom-left-radius:6px;
+    border-bottom-right-radius:6px;
+}
+.mdl-chat-my-entry .meta {
+    background: #f3f3f3;
+    border-bottom: 1px solid white;
+    -moz-border-radius-topleft: 6px;
+    -moz-border-radius-topright: 6px;
+    border-top-left-radius: 6px;
+    border-top-right-radius: 6px;
+}
+.mdl-chat-my-entry .text{
+    padding: 3px;
+    background: #f3f3f3;
+    -moz-border-radius-bottomleft: 6px;
+    -moz-border-radius-bottomright: 6px;
+    border-bottom-left-radius:6px;
+    border-bottom-right-radius:6px;
+}
diff --git a/mod/chat/gui_ajax/theme/compact/config.php b/mod/chat/gui_ajax/theme/compact/config.php
new file mode 100755 (executable)
index 0000000..a0337c2
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+$chattheme_cfg = new stdclass;
+$chattheme_cfg->avatar = false;
+$chattheme_cfg->align  = false;
+$chattheme_cfg->event_message = <<<TEMPLATE
+<div class="chat-event">
+<span class="time">___time___</span>
+<a target='_blank' href="___senderprofile___">___sender___</a>
+<span class="event">___event___</span>
+</div>
+TEMPLATE;
+$chattheme_cfg->user_message = <<<TEMPLATE
+<div class='chat-message'>
+    <div class="meta">
+        <span class="time">___time___</span>
+        <span class="user"><a href="___senderprofile___" target="_blank">___sender___</a></span>
+    </div>
+    <div class="text">
+    ___message___
+    </div>
+</div>
+TEMPLATE;
index ae50a2d5839f9bd4f4b8e591737f3727709e14e9..938e054bca2f0ec0e6d99538a81f96261b7ba6eb 100644 (file)
@@ -755,11 +755,11 @@ function chat_update_chat_times($chatid=0) {
  * @return bool|string Returns HTML or false
  */
 function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow=NULL) {
-    global $CFG, $USER, $OUTPUT, $COURSE;
+    global $CFG, $USER;
 
-    $result = new object();
-    $result->beep = false;         // by default
-    $result->refreshusers = false; // by default
+    $output = new object();
+    $output->beep = false;       // by default
+    $output->refreshusers = false; // by default
 
     // Use get_user_timezone() to find the correct timezone for displaying this message:
     // It's either the current user's timezone or else decided by some Moodle config setting
@@ -774,11 +774,10 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
     $USER->timezone = $tz;
     $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
 
-    $message->picture = $OUTPUT->user_picture(moodle_user_picture::make($sender, $courseid));
-    if (empty($courseid)) {
-        $courseid = $COURSE->id;
+    $message->picture = print_user_picture($sender->id, $courseid, $sender->picture, false, true, false);
+    if ($courseid) {
+        $message->picture = "<a onclick=\"window.open('$CFG->wwwroot/user/view.php?id=$sender->id&amp;course=$courseid')\" href=\"$CFG->wwwroot/user/view.php?id=$sender->id&amp;course=$courseid\">$message->picture</a>";
     }
-    $message->picture = "<a target='_blank' href=\"$CFG->wwwroot/user/view.php?id=$sender->id&amp;course=$courseid\">$message->picture</a>";
 
     //Calculate the row class
     if ($chat_lastrow !== NULL) {
@@ -788,35 +787,32 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
     }
 
     // Start processing the message
+
     if(!empty($message->system)) {
         // System event
-        $result->text = $message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender));
-
-        $result->html  = '<div class="chat-event">';
-        $result->html .= '<span class="time">'.$message->strtime.'</span> ';
-        $userlink = "<a target='_blank' href=\"$CFG->wwwroot/user/view.php?id=$sender->id&amp;course=$courseid\">".fullname($sender)."</a>";
-        $result->html .= '<span class="event">'.get_string('message'.$message->message, 'chat', $userlink).'</span> ';
-        $result->html .= '</div>';
-
-        $result->basic = '<dl><dt class="event">'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'</dt></dl>';
+        $output->text = $message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender));
+        $output->html  = '<table class="chat-event"><tr'.$rowclass.'><td class="picture">'.$message->picture.'</td><td class="text">';
+        $output->html .= '<span class="event">'.$output->text.'</span></td></tr></table>';
+        $output->basic = '<dl><dt class="event">'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'</dt></dl>';
 
         if($message->message == 'exit' or $message->message == 'enter') {
-            $result->refreshusers = true; //force user panel refresh ASAP
+            $output->refreshusers = true; //force user panel refresh ASAP
         }
-        return $result;
+        return $output;
     }
 
     // It's not a system event
+
     $text = $message->message;
 
     /// Parse the text to clean and filter it
+
     $options = new object();
     $options->para = false;
     $text = format_text($text, FORMAT_MOODLE, $options, $courseid);
 
     // And now check for special cases
     $special = false;
-    $outtime = $message->strtime;
 
     if (substr($text, 0, 5) == 'beep ') {
         /// It's a beep!
@@ -824,13 +820,15 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
         $beepwho = trim(substr($text, 5));
 
         if ($beepwho == 'all') {   // everyone
-            $outmain =  get_string('messagebeepseveryone', 'chat', fullname($sender));
-            $result->beep = true;  // (eventually this should be set to
+            $outinfo = $message->strtime.': '.get_string('messagebeepseveryone', 'chat', fullname($sender));
+            $outmain = '';
+            $output->beep = true;  // (eventually this should be set to
                                    //  to a filename uploaded by the user)
 
         } else if ($beepwho == $currentuser->id) {  // current user
-            $outmain = get_string('messagebeepsyou', 'chat', fullname($sender));
-            $result->beep = true;
+            $outinfo = $message->strtime.': '.get_string('messagebeepsyou', 'chat', fullname($sender));
+            $outmain = '';
+            $output->beep = true;
 
         } else {  //something is not caught?
             return false;
@@ -843,6 +841,7 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
         switch ($command){
         case 'me':
             $special = true;
+            $outinfo = $message->strtime;
             $outmain = '*** <b>'.$sender->firstname.' '.substr($text, 4).'</b>';
             break;
         }
@@ -850,35 +849,29 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
         $pattern = '#To[[:space:]](.*):(.*)#';
         preg_match($pattern, trim($text), $matches);
         $special = true;
-        $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.$matches[1].'</i>: '.$matches[2];
+        $outinfo = $message->strtime;
+        $outmain = $sender->firstname.' '.get_string('saidto', 'chat').' <i>'.$matches[1].'</i>: '.$matches[2];
     }
 
     if(!$special) {
+        $outinfo = $message->strtime.' '.$sender->firstname;
         $outmain = $text;
     }
 
-    $result->text = strip_tags($outtime.': '.$outmain);
+    /// Format the message as a small table
 
-    $result->html  = "<table class=\"chat-message\"><tr$rowclass><td class=\"picture\" valign=\"top\">$message->picture</td><td class=\"text\">";
+    $output->text  = strip_tags($outinfo.': '.$outmain);
 
-    $result->html .= "<span class=\"time\">[{$outtime}]</span> ";
-    if(!$special) {
-        $result->html .= "<span class=\"user\">{$sender->firstname}</span>";
-        $result->html .= ": $outmain";
+    $output->html  = "<table class=\"chat-message\"><tr$rowclass><td class=\"picture\" valign=\"top\">$message->picture</td><td class=\"text\">";
+    $output->html .= "<span class=\"title\">$outinfo</span>";
+    if ($outmain) {
+        $output->html .= ": $outmain";
+        $output->basic = '<dl><dt class="title">'.$outinfo.':</dt><dd class="text">'.$outmain.'</dd></dl>';
     } else {
-        $result->html .= "$outmain";
+        $output->basic = '<dl><dt class="title">'.$outinfo.'</dt></dl>';
     }
-    $result->html .= "</td></tr></table>";
-
-    $result->basic = '<dl><dt>';
-    $result->basic .= '<span cass="time">['.$outtime.']</span> '; 
-    $result->basic .= '<span class="user">'.$sender->firstname.'</span>'; 
-    $result->basic .= ': ';
-    $result->basic .= '</dt>';
-    $result->basic .= '<dd class="text">'.$outmain.'</dd>';
-    $result->basic .= '</dl>';
-
-    return $result;
+    $output->html .= "</td></tr></table>";
+    return $output;
 }
 
 /**
@@ -907,6 +900,157 @@ function chat_format_message($message, $courseid, $currentuser, $chat_lastrow=NU
     return chat_format_message_manually($message, $courseid, $user, $currentuser, $chat_lastrow);
 }
 
+/**
+ * @global object
+ * @param object $message
+ * @param int $courseid
+ * @param object $currentuser
+ * @param string $chat_lastrow
+ * @return bool|string Returns HTML or false
+ */
+function chat_format_message_theme ($message, $courseid, $currentuser, $theme = 'bubble') {
+    global $CFG, $USER, $OUTPUT, $COURSE, $DB;
+
+    static $users;     // Cache user lookups
+
+    $result = new object();
+
+    if (file_exists($CFG->dirroot . '/mod/chat/gui_ajax/theme/'.$theme.'/config.php')) {
+        include($CFG->dirroot . '/mod/chat/gui_ajax/theme/'.$theme.'/config.php');
+    }
+
+    if (isset($users[$message->userid])) {
+        $sender = $users[$message->userid];
+    } else if ($sender = $DB->get_record('user', array('id'=>$message->userid), 'id,picture,firstname,lastname')) {
+        $users[$message->userid] = $sender;
+    } else {
+        return NULL;
+    }
+
+    $USER->timezone = 99;
+    $tz = get_user_timezone($currentuser->timezone);
+    $USER->timezone = $tz;
+
+    if (empty($courseid)) {
+        $courseid = $COURSE->id;
+    }
+
+    $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
+    $message->picture = $OUTPUT->user_picture(moodle_user_picture::make($sender, $courseid));
+
+    $message->picture = "<a target='_blank' href=\"$CFG->wwwroot/user/view.php?id=$sender->id&amp;course=$courseid\">$message->picture</a>";
+
+    // Start processing the message
+    if(!empty($message->system)) {
+        $result->type = 'system';
+
+        $userlink = new moodle_url($CFG->wwwroot.'/user/view.php', array('id'=>$message->userid,'course'=>$courseid));
+
+        $patterns = array();
+        $replacements = array();
+        $patterns[] = '___senderprofile___';
+        $patterns[] = '___sender___';
+        $patterns[] = '___time___';
+        $patterns[] = '___event___';
+        $replacements[] = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&amp;course='.$courseid;
+        $replacements[] = fullname($sender);
+        $replacements[] = $message->strtime;
+        $replacements[] = get_string('message'.$message->message, 'chat');
+        $result->html = str_replace($patterns, $replacements, $chattheme_cfg->event_message);
+        return $result;
+    }
+
+    // It's not a system event
+    $text = $message->message;
+
+    /// Parse the text to clean and filter it
+    $options = new object();
+    $options->para = false;
+    $text = format_text($text, FORMAT_MOODLE, $options, $courseid);
+
+    // And now check for special cases
+    $special = false;
+    $outtime = $message->strtime;
+
+    if (substr($text, 0, 5) == 'beep ') {
+        $special = true;
+        /// It's a beep!
+        $result->type = 'beep';
+        $beepwho = trim(substr($text, 5));
+
+        if ($beepwho == 'all') {   // everyone
+            $outmain =  get_string('messagebeepseveryone', 'chat', fullname($sender));
+        } else if ($beepwho == $currentuser->id) {  // current user
+            $outmain = get_string('messagebeepsyou', 'chat', fullname($sender));
+        } else if ($sender->id == $currentuser->id) {  //something is not caught?
+
+            $receiver = $DB->get_record('user', array('id'=>$beepwho), 'id,picture,firstname,lastname');
+            $outmain = get_string('messageyoubeep', 'chat', fullname($receiver));
+        }
+    } else if (substr($text, 0, 1) == '/') {     /// It's a user command
+        $special = true;
+        $result->type = 'command';
+        // support some IRC commands
+        $pattern = '#(^\/)(\w+).*#';
+        preg_match($pattern, trim($text), $matches);
+        $command = $matches[2];
+        $special = true;
+        switch ($command){
+        case 'me':
+            $outmain = '*** <b>'.$sender->firstname.' '.substr($text, 4).'</b>';
+            break;
+        }
+    } elseif (substr($text, 0, 2) == 'To') {
+        $special = true;
+        $result->type = 'dialogue';
+        $pattern = '#To[[:space:]](.*):(.*)#';
+        preg_match($pattern, trim($text), $matches);
+        $special = true;
+        $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.$matches[1].'</i>: '.$matches[2];
+    }
+
+    if(!$special) {
+        $outmain = $text;
+    }
+
+    $result->text = strip_tags($outtime.': '.$outmain);
+
+    $ismymessage = '';
+    $rightalign = '';
+    if ($sender->id == $USER->id) {
+        $ismymessage = ' class="mymessage"';
+        $rightalign = ' align="right"';
+    }
+    $patterns = array();
+    $replacements = array();
+    $patterns[] = '___avatar___';
+    $patterns[] = '___sender___';
+    $patterns[] = '___senderprofile___';
+    $patterns[] = '___time___';
+    $patterns[] = '___message___';
+    $patterns[] = '___mymessageclass___';
+    $patterns[] = '___tablealign___';
+    $replacements[] = $message->picture;
+    $replacements[] = fullname($sender);
+    $replacements[] = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&amp;course='.$courseid;
+    $replacements[] = $outtime;
+    $replacements[] = $outmain;
+    $replacements[] = $ismymessage;
+    $replacements[] = $rightalign;
+    if (!empty($chattheme_cfg->avatar) and !empty($chattheme_cfg->align)) {
+        if (!empty($ismymessage)) {
+            $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message_right);
+        } else {
+            $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message_left);
+        }
+    } else {
+        $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message);
+    }
+
+    return $result;
+}
+
+
 /**
  * @global object $DB
  * @global object $CFG
@@ -1289,4 +1433,4 @@ function chat_extend_settings_navigation($settingsnav, $module) {
     if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
         $chatnav->add(get_string('updatethis', '', get_string('modulename', 'chat')), new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
     }
-}
\ No newline at end of file
+}
index 21e08dd411aa6c594b8a150d9132fa1e2bcc83ca..a173fd210295f0f123ba6a2f06c8eca0a7ee2287 100644 (file)
 
         if ($CFG->enableajax) {
             echo '<p>';
-            
+
             $link = html_link::make("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam", get_string('ajax_gui', 'message'));
-            $link->add_action(new popup_action('click', $link->url, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700)));
+            $link->add_action(new popup_action('click', $link->url, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700, 'toolbar' => false, 'resizeable' => false, 'status' => false)));
             $link->title = get_string('modulename', 'chat');
             echo $OUTPUT->link($link);
             echo '</p>';
index a0cddcf5bb41c96b6ee4f9d76397de6efca1b584..eed8ff40b5f59eba00606c186cde2cc9a5abcb19 100644 (file)
@@ -4031,8 +4031,8 @@ table.mod_index {
   width:100%;
   padding:0;
   margin-top:7px
+  display:block;
 }
-
 #mod-chat-view #chatcurrentusers .chatuserdetails {
   vertical-align: middle;
 }
@@ -4044,16 +4044,6 @@ table.mod_index {
   width: 50%;
 }
 
-.chat-event .picture,
-.chat-message .picture {
-  width:40px;
-  vertical-align:top;
-}
-.chat-event .text,
-.chat-message .text {
-  text-align: left;
-}
-
 #mod-chat-gui_basic #participants ul {
   margin:0px;
   padding:0px;
@@ -4081,11 +4071,33 @@ table.mod_index {
   padding:0px;
   display:inline;
 }
-
-body.mod-chat-gui_ajax .yui-layout-doc .yui-layout-unit .yui-layout-wrap .yui-layout-hd h2 {
-  font-size:100%;
-  padding:0px;
-  font-weight:normal;
+#mod-chat-gui_ajax-index .mdl-chat-entry, .mdl-chat-my-entry {
+    clear:both;
+    display:block;
+}
+#mod-chat-gui_ajax-index #messages-list, #users-list {
+    list-style-type:none;
+    margin:0;
+    padding:0;
+}
+#mod-chat-gui_ajax-index #users-list a {
+    color: grey;
+    font-size: 10px;
+}
+#mod-chat-gui_ajax-index #chat-header {
+    font-size: 200%;
+}
+#mod-chat-gui_ajax-index #chat-header p{
+    display: inline;
+    font-size: 50%;
+}
+#mod-chat-gui_ajax-index .chat-event {
+ color:grey;
+ text-align:center;
+}
+#mod-chat-gui_ajax-index .time, #mod-chat-gui_ajax-index .user{
+    color: grey;
+    font-size: 9px;
 }
 
 /***