本文整理汇总了PHP中chat_format_message函数的典型用法代码示例。如果您正苦于以下问题:PHP chat_format_message函数的具体用法?PHP chat_format_message怎么用?PHP chat_format_message使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chat_format_message函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_package
/**
* @todo Document this function
*/
public function prepare_package()
{
$content = '';
$lasttime = 0;
$sessiongap = 5 * 60;
// 5 minutes silence means a new session
foreach ($this->messages as $message) {
// We are walking FORWARDS through messages
$m = clone $message;
// grrrrrr - this causes the sha1 to change as chat_format_message changes what it's passed.
$formatmessage = chat_format_message($m, null, $this->user);
if (!isset($formatmessage->html)) {
continue;
}
if (empty($lasttime) || $message->timestamp - $lasttime > $sessiongap) {
$content .= '<hr />';
$content .= userdate($message->timestamp);
}
$content .= $formatmessage->html;
$lasttime = $message->timestamp;
}
$content = preg_replace('/\\<img[^>]*\\>/', '', $content);
$this->exporter->write_new_file($content, clean_filename($this->cm->name . '-session.html'), false);
}
示例2: sleep
print " \n";
print $CHAT_DUMMY_DATA;
sleep($CFG->chat_refresh_room);
continue;
}
print '<script type="text/javascript">' . "\n";
print "//<![CDATA[\n\n";
$chatnewrow = ($chatlastrow + $num) % 2;
$refreshusers = false;
$us = array();
if ($chatlasttime != $chatnewlasttime and $messages) {
$beep = false;
$refreshusers = false;
foreach ($messages as $message) {
$chatlastrow = ($chatlastrow + 1) % 2;
$formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow);
if ($formatmessage->beep) {
$beep = true;
}
if ($formatmessage->refreshusers) {
$refreshusers = true;
}
$us[$message->userid] = $timenow - $message->timestamp;
echo "parent.msg.document.write('" . addslashes_js($formatmessage->html) . "\\n');\n";
}
// From the last message printed.
// A strange case where lack of closures is useful!
$chatlasttime = $message->timestamp;
$chatlastid = $message->id;
}
if ($refreshusers) {
示例3: foreach
if ($newonly) {
$lastsql = "AND timestamp > :last";
} else {
$lastsql = "";
}
$groupselect = $groupid ? "AND (groupid=:groupid OR groupid=0)" : "";
$messages = $DB->get_records_select("chat_messages_current",
"chatid = :chatid AND timestamp > :chatentered $lastsql $groupselect", $params,
"timestamp DESC");
if ($messages) {
foreach ($messages as $message) {
$allmessages[] = chat_format_message($message, $course->id, $USER);
}
}
if (empty($allmessages)) {
echo get_string('nomessagesfound', 'message');
} else {
foreach ($allmessages as $message) {
echo $message->basic;
}
}
echo '</div>';
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
示例4: userdate
"chatid = :chatid AND timestamp >= :start AND timestamp <= :end $groupselect",
$params,
"timestamp ASC")) {
echo $OUTPUT->heading(get_string('nomessages', 'chat'));
} else {
echo '<p class="boxaligncenter">'.userdate($start).' --> '. userdate($end).'</p>';
echo $OUTPUT->box_start('center');
$participates = array();
foreach ($messages as $message) { // We are walking FORWARDS through messages.
if (!isset($participates[$message->userid])) {
$participates[$message->userid] = true;
}
$formatmessage = chat_format_message($message, $course->id, $USER);
if (isset($formatmessage->html)) {
echo $formatmessage->html;
}
}
$participatedcap = array_key_exists($USER->id, $participates)
&& has_capability('mod/chat:exportparticipatedsession', $context);
if (!empty($CFG->enableportfolios) && ($canexportsess || $participatedcap)) {
require_once($CFG->libdir . '/portfoliolib.php');
$buttonoptions = array(
'id' => $cm->id,
'start' => $start,
'end' => $end,
);
$button = new portfolio_add_button();
示例5: count
$num = count($messages);
} else {
$num = 0;
}
$chat_newrow = ($chat_lastrow + $num) % 2;
$send_user_list = false;
if ($messages && $chat_lasttime != $chat_newlasttime) {
foreach ($messages as $n => &$message) {
$tmp = new stdclass();
// when somebody enter room, user list will be updated
if ($message->system == 1) {
$send_user_list = true;
$tmp->type = 'system';
$users = format_user_list(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->msg = $html->html;
$message = $tmp;
} else {
unset($message);
}
}
}
if (!empty($users) && $send_user_list) {
// return users when system message coming
$response['users'] = $users;