]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8022 Chat accessibility - new gui_basic should integrated and fully working now
authorskodak <skodak>
Sat, 30 Dec 2006 19:45:24 +0000 (19:45 +0000)
committerskodak <skodak>
Sat, 30 Dec 2006 19:45:24 +0000 (19:45 +0000)
+ improved print_user_picture() to allow images with empty alt to prevent repetitive reading of usernames in jaws when username is printed next to avatar

lib/weblib.php
mod/chat/gui_basic/index.php
mod/chat/lib.php
mod/chat/view.php
theme/standard/styles_color.css
theme/standard/styles_fonts.css
theme/standard/styles_layout.css

index 92b06c4a6592c90c93297538c52087aa9be3bcdb..2e5a357402e8c455b70c6ecdb80e3618af238271 100644 (file)
@@ -3040,10 +3040,12 @@ function print_file_picture($path, $courseid=0, $height='', $width='', $link='',
  * @param int $size Size in pixels.  Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatability
  * @param boolean $return If false print picture to current page, otherwise return the output as string
  * @param boolean $link Enclose printed image in a link to view specified course?
+ * @param string $target link target attribute
+ * @param boolean $alttext use username or userspecified text in image alt attribute
  * return string
  * @todo Finish documenting this function
  */
-function print_user_picture($userid, $courseid, $picture, $size=0, $return=false, $link=true, $target='') {
+function print_user_picture($userid, $courseid, $picture, $size=0, $return=false, $link=true, $target='', $alttext=true) {
     global $CFG;
 
     if ($link) {
@@ -3076,13 +3078,16 @@ function print_user_picture($userid, $courseid, $picture, $size=0, $return=false
         $class .= " defaultuserpic";
         $src =  "$CFG->pixpath/u/$file.png\"";
     }
-    if ($user = get_record('user','id',$userid)) {
+    if (!$alttext) {
+        $imagealt = '';
+    } else if ($user = get_record('user','id',$userid)) {
         if (!empty($user->imagealt)) {
             $imagealt = $user->imagealt;
         } else {
             $imagealt = get_string('pictureof','',fullname($user));
         }    
     }
+
     $output .= "<img class=\"$class\" align=\"middle\" src=\"$src".
                    " border=\"0\" width=\"$size\" height=\"$size\" alt=\"".s($imagealt)."\" />";
     if ($link) {
index a7e28e0fedb4fa268a05c57652f5671069c92031..e72aaacfbcabb8c3876797283c579a664a41bf84 100644 (file)
         error('Could not log in to chat room!!');
     }
 
-    if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
-    }
-
     if (!$chatusers = chat_get_users($chat->id, $groupid)) {
         error(get_string('errornousers', 'chat'));
     }
 
-    set_field('chat_users', 'lastping', time(), 'id', $USER->id);
+    set_field('chat_users', 'lastping', time(), 'sid', $chat_sid);
 
     if (!isset($SESSION->chatprefs)) {
         $SESSION->chatprefs = array();
         $SESSION->chatprefs[$chat->id]['chatentered'] = time();
     }
     $chatentered = $SESSION->chatprefs[$chat->id]['chatentered'];
-    
+
     $refreshedmessage = '';
 
     if (!empty($refresh) and data_submitted()) {
         $refreshedmessage = $message;
 
-    } else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
-
         chat_delete_old_users();
 
+    } else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
+
         if ($message!='') {
             $newmessage = new object();
             $newmessage->chatid = $chat->id;
                 error('Could not insert a chat message!');
             }
 
-            set_field('chat_users', 'lastmessageping', time(), 'id', $USER->id);
+            set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid);
 
             add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id);
         }
 
+        chat_delete_old_users();
+
         redirect('index.php?id='.$id.'&amp;newonly='.$newonly.'&amp;last='.$last);
     }
 
 
-    print_header($strchat.': '.format_string($chat->name));
+    print_header("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname");
 
-    echo '<div class="chat-basic">';
-    echo '<h2>'.get_string('participants').'</h2>';
-    echo '<div class="participants"><ul>';
+    echo '<div id="mod-chat-gui_basic">';
+    echo '<h1>'.get_string('participants').'</h1>';
+    echo '<div id="participants"><ul>';
     foreach($chatusers as $chu) {
         echo '<li>';
-        print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false);
-        echo '&nbsp;'.fullname($chu).' - ';
-        $lastping = time() - $chatuser->lastmessageping;
-        $min = (int) ($lastping/60);
-        $sec = $lastping - ($min*60);
-        $min = $min < 10 ? '0'.$min : $min;
-        $sec = $sec < 10 ? '0'.$sec : $sec;
-        $idle = $min.':'.$sec;
-        echo '<span class="idle">'.$stridle.' '.format_time($lastping).'</span>';
+        print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false, '', false);
+        echo '<div class="userinfo">';
+        echo fullname($chu).' ';
+        if ($idle = time() - $chu->lastmessageping) {
+            echo '<span class="idle">'.$stridle.' '.format_time($idle).'</span>';
+        } else {
+            echo '<span class="idle" />';
+        }
+        echo '</div>';
         echo '</li>';
     }
     echo '</ul></div>';
     echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
 
     $usehtmleditor = can_use_html_editor();
-    echo '<h2><label for="edit-message">'.get_string('sendmessage', 'message').'</label></h2>';
+    echo '<h1><label for="message">'.get_string('sendmessage', 'message').'</label></h1>';
     echo '<div>';
-    print_textarea(false, 2, 50, 0, 0, 'message', $refreshedmessage);
+    echo '<input type="text" id="message" name="message" value="'.s($refreshedmessage, true).'" size="60" />';
     echo '</div><div>';
     echo '<input type="submit" value="'.get_string('submit').'" />&nbsp;';
     echo '<input type="submit" name="refresh" value="'.get_string('refresh').'" />';
     echo '</div>';
 
     echo '<div id="messages">';
-    echo '<h2>'.get_string('messages', 'chat').'</h2>';
+    echo '<h1>'.get_string('messages', 'chat').'</h1>';
 
     $allmessages = array();
     $options = new object();
index 0a99b81e3206c4f83d014d497fd9ecdec85e1f5e..c6188ab4b3081fe14de2609c06d417d486bc419f 100644 (file)
@@ -454,7 +454,7 @@ function chat_delete_old_users() {
     global $CFG;
 
     $timeold = time() - $CFG->chat_old_ping;
-    $timeoldext = time() - ($CFG->chat_old_ping*2); // JSless basic gui needs much longer timeouts
+    $timeoldext = time() - ($CFG->chat_old_ping*10); // JSless gui_basic needs much longer timeouts
 
     $query = "(version<>'basic' AND lastping<'$timeold') OR (version='basic' AND lastping<'$timeoldext')";
 
@@ -556,7 +556,7 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
         $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>'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'</dt></dl>'; 
+        $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') {
             $output->refreshusers = true; //force user panel refresh ASAP
@@ -619,9 +619,9 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
     $output->html .= "<span class=\"title\">$outinfo</span>";
     if ($outmain) {
         $output->html .= ": $outmain";
-        $output->basic = '<dl><dt>'.$outinfo.':</dt><dd>'.$outmain.'</dd></dl>'; 
+        $output->basic = '<dl><dt class="title">'.$outinfo.':</dt><dd class="text">'.$outmain.'</dd></dl>'; 
     } else {
-        $output->basic = '<dl><dt>'.$outinfo.'</dt></dl>'; 
+        $output->basic = '<dl><dt class="title">'.$outinfo.'</dt></dl>'; 
     }
     $output->html .= "</td></tr></table>";
     return $output;
index e7d0a76eb3acff6b9345af844dbd32471f7ccb30..ee107d4300e27fc2d8b4efa3a76d59b5475048d9 100644 (file)
         link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam",
                               "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
         print_simple_box_end();
+        if ($CFG->chat_method == 'header_js') {
+            // show frame/js-less alternative
+            print_simple_box_start('center');
+            link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam",
+                                  "chat$course->id$chat->id$groupparam", '('.get_string('noframesjs', 'message').')', 500, 700, get_string('modulename', 'chat'));
+            print_simple_box_end();
+        }
     } else {
 /*    XXX TODO
         $wwwroot = $CFG->wwwroot.'/login/index.php';
index 9e91111aab96cfd008d4bae0536b973e11681fe5..d7cd969ec93827a778cb044da84031eca747141e 100644 (file)
@@ -748,9 +748,13 @@ table.message_search_results td {
  *** Modules: Chat
  ***/
 
+#mod-chat-gui_basic .text,
 #mod-chat-gui_header_js-jsupdate .text {
   color:#000
 }
+
+#mod-chat-gui_basic .event,
+#mod-chat-gui_basic .title,
 #mod-chat-gui_header_js-jsupdate .event,
 #mod-chat-gui_header_js-jsupdate .title {
   color:#888
index 5a35189b103736270ce8e9d84dfbbff8fc760ba7..d4fe7b75ed5ee4d3c39b0b0609a8b2a42fbf9bad 100644 (file)
@@ -628,6 +628,15 @@ body#user-index #longtimenosee {
   font-size:0.8em;
 }
 
+
+#mod-chat-gui_basic h1 {
+  font-size:1.4em;
+}
+
+#mod-chat-gui_basic #participants .idle {
+  font-size:0.6em;
+}
+
 /***
  *** Modules: Choice
  ***/
index 7d38a3e2e51176591f384f2b82f9fc557e52fc50..71f8d53ff4ab73a32b50d510a6c1be4feb451457 100644 (file)
@@ -1767,6 +1767,34 @@ body#user-index .rolesform {
   text-align: left;
 }
 
+#mod-chat-gui_basic #participants ul {
+  margin:0px;
+  padding:0px;
+  list-style-type:none;
+}
+
+#mod-chat-gui_basic #participants ul li {
+  display:inline;
+  margin-right:10px;
+}
+
+#mod-chat-gui_basic #participants ul li .userinfo {
+  display:inline;
+}
+
+#mod-chat-gui_basic #messages dl {
+  padding:0px;
+  margin:1px;
+}
+
+#mod-chat-gui_basic #messages dd,
+#mod-chat-gui_basic #messages dt {
+  margin-left:0px;
+  margin-right:5px;
+  padding:0px;
+  display:inline;
+}
+
 /***
  *** Modules: Choice
  ***/