1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Adding raw-parameter for jsonify

This commit is contained in:
Tim Düsterhus 2011-12-27 12:38:05 +01:00
parent b7683db870
commit 530c2ab788

View File

@ -89,10 +89,11 @@ public function getUsername() {
/** /**
* Converts this message into json-form. * Converts this message into json-form.
* *
* @param boolean $raw
* @return string * @return string
*/ */
public function jsonify() { public function jsonify($raw = false) {
return \wcf\util\JSON::encode(array( $array = array(
'formattedUsername' => $this->getFormattedUsername(), 'formattedUsername' => $this->getFormattedUsername(),
'formattedMessage' => (string) $this, 'formattedMessage' => (string) $this,
'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'), 'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'),
@ -102,6 +103,9 @@ public function jsonify() {
'receiver' => $this->receiver, 'receiver' => $this->receiver,
'type' => $this->type, 'type' => $this->type,
'roomID' => $this->roomID 'roomID' => $this->roomID
)); );
if ($raw) return $array;
return \wcf\util\JSON::encode($array);
} }
} }