From 953eb6f3156d9554a11fcbc119f754ecba286f63 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 30 Dec 2006 19:45:24 +0000 Subject: [PATCH] MDL-8022 Chat accessibility - new gui_basic should integrated and fully working now + 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 | 9 ++++-- mod/chat/gui_basic/index.php | 48 +++++++++++++++----------------- mod/chat/lib.php | 8 +++--- mod/chat/view.php | 7 +++++ theme/standard/styles_color.css | 4 +++ theme/standard/styles_fonts.css | 9 ++++++ theme/standard/styles_layout.css | 28 +++++++++++++++++++ 7 files changed, 82 insertions(+), 31 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 92b06c4a65..2e5a357402 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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 .= "\"".s($imagealt)."\""; if ($link) { diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php index a7e28e0fed..e72aaacfbc 100644 --- a/mod/chat/gui_basic/index.php +++ b/mod/chat/gui_basic/index.php @@ -48,15 +48,11 @@ 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(); @@ -66,16 +62,16 @@ $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; @@ -88,31 +84,33 @@ 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.'&newonly='.$newonly.'&last='.$last); } - print_header($strchat.': '.format_string($chat->name)); + print_header("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname"); - echo '
'; - echo '

'.get_string('participants').'

'; - echo '
    '; + echo '
    '; + echo '

    '.get_string('participants').'

    '; + echo '
      '; foreach($chatusers as $chu) { echo '
    • '; - print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false); - echo ' '.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 ''.$stridle.' '.format_time($lastping).''; + print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false, '', false); + echo '
      '; + echo fullname($chu).' '; + if ($idle = time() - $chu->lastmessageping) { + echo ''.$stridle.' '.format_time($idle).''; + } else { + echo ''; + } + echo '
      '; echo '
    • '; } echo '
    '; @@ -124,9 +122,9 @@ echo ''; $usehtmleditor = can_use_html_editor(); - echo '

    '; + echo '

    '; echo '
    '; - print_textarea(false, 2, 50, 0, 0, 'message', $refreshedmessage); + echo ''; echo '
    '; echo ' '; echo ''; @@ -136,7 +134,7 @@ echo '
    '; echo '
    '; - echo '

    '.get_string('messages', 'chat').'

    '; + echo '

    '.get_string('messages', 'chat').'

    '; $allmessages = array(); $options = new object(); diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 0a99b81e32..c6188ab4b3 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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 = '
    '.$message->picture.''; $output->html .= ''.$output->text.'
    '; - $output->basic = '
    '.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'
    '; + $output->basic = '
    '.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'
    '; 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 .= "$outinfo"; if ($outmain) { $output->html .= ": $outmain"; - $output->basic = '
    '.$outinfo.':
    '.$outmain.'
    '; + $output->basic = '
    '.$outinfo.':
    '.$outmain.'
    '; } else { - $output->basic = '
    '.$outinfo.'
    '; + $output->basic = '
    '.$outinfo.'
    '; } $output->html .= ""; return $output; diff --git a/mod/chat/view.php b/mod/chat/view.php index e7d0a76eb3..ee107d4300 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -107,6 +107,13 @@ 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'; diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index 9e91111aab..d7cd969ec9 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -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 diff --git a/theme/standard/styles_fonts.css b/theme/standard/styles_fonts.css index 5a35189b10..d4fe7b75ed 100644 --- a/theme/standard/styles_fonts.css +++ b/theme/standard/styles_fonts.css @@ -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 ***/ diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 7d38a3e2e5..71f8d53ff4 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -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 ***/ -- 2.39.5