* @package timwolla.wcf.chat * @subpackage data.chat.message */ class ChatMessage extends \wcf\data\DatabaseObject { /** * @see wcf\data\DatabaseObject::$databaseTableName */ protected static $databaseTableName = 'chat_message'; /** * @see wcf\data\DatabaseObject::$databaseTableIndexName */ protected static $databaseTableIndexName = 'messageID'; const TYPE_NORMAL = 0; const TYPE_JOIN = 1; const TYPE_LEAVE = 2; const TYPE_AWAY = 3; const TYPE_BACK = 4; const TYPE_MODERATE = 5; const TYPE_ME = 6; const TYPE_WHISPER = 7; const TYPE_INFORMATION = 8; const TYPE_CLEAR = 9; const TYPE_TEAM = 10; const TYPE_GLOBALMESSAGE = 11; /** * Returns the message. * * @return string */ public function __toString() { return $this->message; } /** * Returns the formatted username * * @return string */ public function getFormattedUsername() { $string = str_split($this->username); $r = (int) (($this->color1 >> 16 & 255) - ($this->color2 >> 16 & 255)) / (count($string) - 1); $g = (int) (($this->color1 >> 8 & 255) - ($this->color2 >> 8 & 255)) / (count($string) - 1); $b = (int) (($this->color1 & 255) - ($this->color2 & 255)) / (count($string) - 1); $result = ''; for ($i = 0, $max = count($string); $i < $max; $i++) { $result .= ''.$string[$i].''; } return ''.$result.''; } }