Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/main/chat/header_frame.inc.php

270 lines
148 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* Header of each frame of the Chat tool
*
* @author Olivier Brouckaert
* Modified by Denes Nagy
* @package chamilo.chat
*/
require_once '../inc/global.inc.php';
if (!defined('FRAME')) {
exit();
}
$bodyXtra = ' class="course_chat" dir="'.api_get_text_direction().'" ';
if (FRAME == 'hidden') {
$bodyXtra .= 'onload="javascript: updateChat(); updateConnected(); setTimeout(\'submitHiddenForm();\', 5000);"';
// Change timeout to change refresh time of the chat window
} elseif (FRAME == 'message') {
$bodyXtra .= 'onload="javascript: eventMessage();"';
}
$mycourseid=api_get_cidreq();
if (empty($mycourseid)) {
// If it is not set $mycourse id we reload the chat_message window in order to hide the textarea to submit a message.
echo '<script type="text/javascript" language="javascript">';
echo "parent.chat_message.location.href='chat_whoisonline.php?".api_get_cidreq()."';";
echo '</script>';
}
/*
* Choose CSS style (platform's, user's, or course's)
*/
$my_style = api_get_visual_theme();
$chat_size_old = isset($chat_size_old) ? $chat_size_old : null;
$chat_size_new = isset($chat_size_new) ? $chat_size_new : null;
$connected_new = isset($connected_new) ? $connected_new : null;
$connected_old = isset($connected_old) ? $connected_old : null;
$icons = Emojione\Emojione::$shortcode_replace;
$iconList = array();
$iconNameToInclude = array(
':bowtie:',
':smile:',
':laughing:',
':blush:',
':smiley:',
':relaxed:',
':smirk:',
':heart_eyes:',
':kissing_heart:',
':kissing_closed_eyes:',
':flushed:',
':relieved:',
':satisfied:',
':grin:',
':wink:',
':stuck_out_tongue_winking_eye:',
':stuck_out_tongue_closed_eyes:',
':grinning:',
':kissing:',
':kissing_smiling_eyes:',
':stuck_out_tongue:',
':sleeping:',
':worried:',
':frowning:',
':anguished:',
':open_mouth:',
':grimacing:',
':confused:',
':hushed:',
':expressionless:',
':unamused:',
':sweat_smile:',
':sweat:',
':disappointed_relieved:',
':weary:',
':pensive:',
':disappointed:',
':confounded:',
':fearful:',
':cold_sweat:',
':persevere:',
':cry:',
':sob:',
':joy:',
':astonished:',
':scream:',
':neckbeard:',
':tired_face:',
':angry:',
':rage:',
':triumph:',
':sleepy:',
':yum:',
':mask:',
':sunglasses:',
':dizzy_face:',
':imp:',
':smiling_imp:',
':neutral_face:',
':no_mouth:',
':innocent:',
':alien:',
);
foreach ($icons as $key => $icon) {
if (in_array($key, $iconNameToInclude)) {
$iconList[$key] = strtoupper($icon) . '.png';
}
}
$icons = json_encode($iconList);
$ajax = api_get_path(WEB_AJAX_PATH).'chat.ajax.php?action=preview&'.api_get_cidreq();
header('Content-Type: text/html; charset=UTF-8');
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Chat</title>
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_PATH); ?>web/assets/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-emojiarea/jquery.emojiarea.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>chat.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>markdown.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-textcomplete/jquery.textcomplete.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/emojione/css/emojione.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/emojione/css/autocomplete.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/highlight/styles/github.css">
<?php echo api_get_jquery_js(); ?>
<?php echo api_get_asset('bootstrap/dist/js/bootstrap.min.js'); ?>
<?php echo api_get_js('highlight/highlight.pack.js'); ?>
<?php echo api_get_js('jquery-textcomplete/jquery.textcomplete.js'); ?>
<?php echo api_get_js('emojione/js/emojione.min.js'); ?>
<?php echo api_get_js('jquery-emojiarea/jquery.emojiarea.js'); ?>
<?php echo api_get_js('jquery.tinyscrollbar.js'); ?>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
emojione.ascii = true;
emojione.imagePathPNG = '<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/';?>';
emojione.imagePathSVG ='<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/svg/';?>';
emojione.imagePathSVGSprites = '<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/sprites/';?>';
// emoji strategy for .textcomplete() (latest version available in our repo: emoji_strategy.json)
var emojiStrategy = {"hearts":{"unicode":"2665","shortname":":hearts:","aliases":"","keywords":"black heart suit cards poker"},"joy":{"unicode":"1F602","shortname":":joy:","aliases":"","keywords":"face with tears of joy cry face haha happy tears tears cry joy happy weep"},"unamused":{"unicode":"1F612","shortname":":unamused:","aliases":"","keywords":"unamused face bored face indifference serious straight face unamused not amused depressed unhappy disapprove lame"},"heart_eyes":{"unicode":"1F60D","shortname":":heart_eyes:","aliases":"","keywords":"smiling face with heart-shaped eyes affection crush face infatuation like love valentines smiling heart lovestruck love flirt smile heart-shaped"},"heart":{"unicode":"2764","shortname":":heart:","aliases":"","keywords":"heavy black heart like love red pink black heart love passion romance intense desire death evil cold valentines"},"relaxed":{"unicode":"263A","shortname":":relaxed:","aliases":"","keywords":"white smiling face blush face happiness massage smile"},"ok_hand":{"unicode":"1F44C","shortname":":ok_hand:","aliases":"","keywords":"ok hand sign fingers limbs perfect okay ok smoke smoking marijuana joint pot 420"},"kissing_heart":{"unicode":"1F618","shortname":":kissing_heart:","aliases":"","keywords":"face throwing a kiss affection face infatuation kiss blowing kiss heart love lips like love valentines"},"blush":{"unicode":"1F60A","shortname":":blush:","aliases":"","keywords":"smiling face with smiling eyes crush embarrassed face flushed happy shy smile smiling smile smiley"},"weary":{"unicode":"1F629","shortname":":weary:","aliases":"","keywords":"weary face face frustrated sad sleepy tired weary sleepy tired tiredness study finals school exhausted"},"pensive":{"unicode":"1F614","shortname":":pensive:","aliases":"","keywords":"pensive face face okay sad pensive thoughtful think reflective wistful meditate serious"},"sob":{"unicode":"1F62D","shortname":":sob:","aliases":"","keywords":"loudly crying face cry face sad tears upset cry sob tears sad melancholy morn somber hurt"},"smirk":{"unicode":"1F60F","shortname":":smirk:","aliases":"","keywords":"smirking face mean prank smile smug smirking smirk smug smile half-smile conceited"},"two_hearts":{"unicode":"1F495","shortname":":two_hearts:","aliases":"","keywords":"two hearts affection like love valentines heart hearts two love emotion"},"grin":{"unicode":"1F601","shortname":":grin:","aliases":"","keywords":"grinning face with smiling eyes face happy joy smile grin grinning smiling smile smiley"},"flushed":{"unicode":"1F633","shortname":":flushed:","aliases":"","keywords":"flushed face blush face flattered flush blush red pink cheeks shy"},"thumbsup":{"unicode":"1F44D","shortname":":thumbsup:","aliases":":+1:","keywords":"thumbs up sign cool hand like yes"},"raised_hands":{"unicode":"1F64C","shortname":":raised_hands:","aliases":"","keywords":"person raising both hands in celebration gesture hooray winning woot yay banzai"},"wink":{"unicode":"1F609","shortname":":wink:","aliases":"","keywords":"winking face face happy mischievous secret wink winking friendly joke"},"information_desk_person":{"unicode":"1F481","shortname":":information_desk_person:","aliases":"","keywords":"information desk person female girl human woman information help question answer sassy unimpressed attitude snarky"},"relieved":{"unicode":"1F60C","shortname":":relieved:","aliases":"","keywords":"relieved face face happiness massage phew relaxed relieved satisfied phew relief"},"see_no_evil":{"unicode":"1F648","shortname":":see_no_evil:","aliases":"","keywords":"see-no-evil monkey animal monkey nature monkey see eyes vision sight mizaru"},"v":{"unicode":"270C","shortname":":v:","aliases":"","keywords":"victory hand fingers hand ohyeah peace two victory"},"pray":{"unicode":"1F64F","shortname":":pray:","aliases":"","keywords":"person with folded hands highfive hope namaste please wish pray high five hands sorrow regret sorry"},"yum":{"unicode":"1F60B","shortname":":yum:","aliases":"","keywords":"face savouring delicious food face happy joy smile tongu
var url = '<?php echo $ajax; ?>';
$(document).ready(function() {
/*$("textarea").on('keyup change input',function(e) {
var source = $(this).val();
var preview = emojione.toImage(source);
$('textarea').html(preview);
});*/
//$('#preview').onclick
$.emojiarea.path = '<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/';?>';
$.emojiarea.icons = <?php echo $icons ?>;
$('#preview').on('click', function() {
var params = $('#formMessage').serialize();
$.ajax({
url: url + '&' + params,
success: function (data) {
$('#html-preview').html(data);
}
});
});
$('#emojis').on('click', function() {
var $tab = $('[data-toggle="tab"][href="#tab1"]');
$tab.click(function(e) { // Binding for later use (for user interaction)
e.preventDefault();
$tab.tab('show');
});
$tab.show(); // Display the tab
$tab.tab('show');
});
$('textarea').emojiarea({button: '#emojis'});
$("textarea").textcomplete([ {
match: /\B:([\-+\w]*)$/,
search: function (term, callback) {
var results = [];
var results2 = [];
var results3 = [];
$.each(emojiStrategy,function(shortname,data) {
if(shortname.indexOf(term) > -1) { results.push(shortname); }
else {
if((data.aliases !== null) && (data.aliases.indexOf(term) > -1)) {
results2.push(shortname);
}
else if((data.keywords !== null) && (data.keywords.indexOf(term) > -1)) {
results3.push(shortname);
}
}
});
if(term.length >= 3) {
results.sort(function(a,b) { return (a.length > b.length); });
results2.sort(function(a,b) { return (a.length > b.length); });
results3.sort();
}
var newResults = results.concat(results2).concat(results3);
callback(newResults);
},
template: function (shortname) {
return '<img class="emojione" src="<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/';?>'+emojiStrategy[shortname].unicode+'.png"> :'+shortname+':';
},
replace: function (shortname) {
return ':'+shortname+': ';
},
index: 1,
maxCount: 10
}
],{
//footer: '<a href="http://www.emoji.codes" target="_blank">Browse All<span class="arrow">»</span></a>'
});
$('#user-online-scroll').tinyscrollbar();
});
function play_notification()
{
document.getElementById('audio').play();
}
function updateChat()
{
if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>') {
parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size_new.'&'.api_get_cidreq(); ?>#bottom';
play_notification();
}
}
function updateConnected()
{
if ('<?php echo $connected_old; ?>' != '<?php echo $connected_new; ?>'){
parent.chat_whoisonline.location.href='chat_whoisonline.php?size=<?php echo $connected_new; ?>';
}
}
function submitHiddenForm()
{
document.formHidden.submit();
}
function eventMessage()
{
<?php if (isset($chat_size) && $chat_size): ?>
parent.chat_hidden.document.formHidden.chat_size_old.value='<?php echo $chat_size; ?>';
parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size.'&'.api_get_cidreq(); ?>#bottom';
<?php endif; ?>
document.formMessage.message.focus();
}
function send_message(keyEvent)
{
for (prop in keyEvent) {
if(prop == 'which') key = keyEvent.which; else key = keyEvent.keyCode;
}
if (key == 13) {
document.formMessage.submit();
}
}
</script>
</head>
<body <?php echo $bodyXtra; ?> >