diff --git a/src/messenger/webim/libs/classes/thread.php b/src/messenger/webim/libs/classes/thread.php
index 9ebdbbdc..e4a9da10 100644
--- a/src/messenger/webim/libs/classes/thread.php
+++ b/src/messenger/webim/libs/classes/thread.php
@@ -381,6 +381,55 @@ Class Thread {
return $kind_names[$message_kind];
}
+ /**
+ * Theme message to display in chat window
+ *
+ * @param array $message Message array
+ * @return string Ready to display themed message
+ */
+ public static function themeMessage($message) {
+ global $webim_encoding;
+
+ // No theming for avatars
+ if ($message['ikind'] == Thread::KIND_AVATAR) {
+ return '';
+ }
+
+ // Prepare messages fields
+ $creation_date = date("H:i:s", $message['created']);
+ $kind_name = Thread::kindToString($message['ikind']);
+ $sender_name = $message['tname']
+ ? "" . htmlspecialchars($message['tname']) . ": "
+ : '';
+
+ // Prepare message text
+ // Escape special chars
+ $text = htmlspecialchars($message['tmessage']);
+ // Replace URL's by tags
+ $text = preg_replace('/(https?|ftp):\/\/\S*/', '$0', $text);
+ // Add
tags instead of \n chars
+ $text = str_replace("\n", "
", $text);
+ // Span and storng tags available for system messages
+ if ($message['ikind'] != Thread::KIND_USER && $message['ikind'] != Thread::KIND_AGENT) {
+ $text = preg_replace('/<(span|strong)>(.*)<\/\1>/U', '<$1>$2$1>', $text);
+ $text = preg_replace(
+ '/<span class="(.*)">(.*)<\/span>/U',
+ '$2',
+ $text
+ );
+ }
+
+ // Build result message
+ $result = sprintf(
+ "%s %s%s
",
+ $creation_date,
+ $sender_name,
+ $kind_name,
+ $text
+ );
+ return myiconv($webim_encoding, "utf-8", $result);
+ }
+
/**
* Return next revision number (last revision number plus one)
*
diff --git a/src/messenger/webim/libs/classes/thread_processor.php b/src/messenger/webim/libs/classes/thread_processor.php
index a9b14ad3..35806ce2 100644
--- a/src/messenger/webim/libs/classes/thread_processor.php
+++ b/src/messenger/webim/libs/classes/thread_processor.php
@@ -224,55 +224,6 @@ class ThreadProcessor extends RequestProcessor {
return $requests;
}
- /**
- * Theme message to display in chat window
- *
- * @param array $message Message array
- * @return string Ready to display themed message
- */
- protected function themeMessage($message) {
- global $webim_encoding;
-
- // No theming for avatars
- if ($message['ikind'] == Thread::KIND_AVATAR) {
- return '';
- }
-
- // Prepare messages fields
- $creation_date = date("H:i:s", $message['created']);
- $kind_name = Thread::kindToString($message['ikind']);
- $sender_name = $message['tname']
- ? "" . htmlspecialchars($message['tname']) . ": "
- : '';
-
- // Prepare message text
- // Escape special chars
- $text = htmlspecialchars($message['tmessage']);
- // Replace URL's by tags
- $text = preg_replace('/(https?|ftp):\/\/\S*/', '$0', $text);
- // Add
tags instead of \n chars
- $text = str_replace("\n", "
", $text);
- // Span and storng tags available for system messages
- if ($message['ikind'] != Thread::KIND_USER && $message['ikind'] != Thread::KIND_AGENT) {
- $text = preg_replace('/<(span|strong)>(.*)<\/\1>/U', '<$1>$2$1>', $text);
- $text = preg_replace(
- '/<span class="(.*)">(.*)<\/span>/U',
- '$2',
- $text
- );
- }
-
- // Build result message
- $result = sprintf(
- "%s %s%s
",
- $creation_date,
- $sender_name,
- $kind_name,
- $text
- );
- return myiconv($webim_encoding, "utf-8", $result);
- }
-
/**
* Send new messages to window
*
@@ -287,7 +238,7 @@ class ThreadProcessor extends RequestProcessor {
$messages = $thread->getMessages($is_user, $last_message_id);
if (! empty($messages)) {
foreach($messages as $key => $msg) {
- $messages[$key] = $this->themeMessage($msg);
+ $messages[$key] = Thread::themeMessage($msg);
}
$this->responses[] = array(
'token' => md5(time() . rand()),