Move kindToString() method from ThreadProcessor to Thread

This commit is contained in:
Dmitriy Simushev 2012-09-28 14:35:34 +00:00
parent 2ba492d94f
commit 50283a0b21
2 changed files with 23 additions and 23 deletions

View File

@ -334,6 +334,28 @@ Class Thread {
return false; return false;
} }
/**
* Return message kind name corresponding to kind code
*
* @param int $message_kind Message kind. One of the Thread::KIND_* constants
* @return string kind's full name or its shortening
*/
public static function kindToString($message_kind) {
$kind_names = array(
Thread::KIND_USER => 'user',
Thread::KIND_AGENT => 'agent',
Thread::KIND_FOR_AGENT => 'hidden',
Thread::KIND_INFO => 'inf',
Thread::KIND_CONN => 'conn',
Thread::KIND_EVENTS => 'event',
Thread::KIND_AVATAR => 'avatar'
);
if (! array_key_exists($message_kind, $kind_names)) {
return '';
}
return $kind_names[$message_kind];
}
/** /**
* Return next revision number (last revision number plus one) * Return next revision number (last revision number plus one)
* *

View File

@ -224,28 +224,6 @@ class ThreadProcessor extends RequestProcessor {
return $requests; return $requests;
} }
/**
* Return message kind name corresponding to kind code
*
* @param int $message_kind Message kind. One of the Thread::KIND_* constants
* @return string kind name
*/
protected function kindToString($message_kind) {
$kind_names = array(
Thread::KIND_USER => 'user',
Thread::KIND_AGENT => 'agent',
Thread::KIND_FOR_AGENT => 'hidden',
Thread::KIND_INFO => 'inf',
Thread::KIND_CONN => 'conn',
Thread::KIND_EVENTS => 'event',
Thread::KIND_AVATAR => 'avatar'
);
if (! array_key_exists($message_kind, $kind_names)) {
return '';
}
return $kind_names[$message_kind];
}
/** /**
* Theme message to display in chat window * Theme message to display in chat window
* *
@ -262,7 +240,7 @@ class ThreadProcessor extends RequestProcessor {
// Prepare messages fields // Prepare messages fields
$creation_date = date("H:i:s", $message['created']); $creation_date = date("H:i:s", $message['created']);
$kind_name = $this->kindToString($message['ikind']); $kind_name = Thread::kindToString($message['ikind']);
$sender_name = $message['tname'] $sender_name = $message['tname']
? "<span class='n{$kind_name}'>" . htmlspecialchars($message['tname']) . "</span>: " ? "<span class='n{$kind_name}'>" . htmlspecialchars($message['tname']) . "</span>: "
: ''; : '';