mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Improve attachments in UI
This commit is contained in:
parent
77830cf6fb
commit
3fe5016c9a
@ -69,7 +69,7 @@ public function __toString() {
|
|||||||
* @param string $outputType outputtype for messageparser
|
* @param string $outputType outputtype for messageparser
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormattedMessage($type = 'text/html', $attachmentList = null) {
|
public function getFormattedMessage($type = 'text/html') {
|
||||||
$message = $this->message;
|
$message = $this->message;
|
||||||
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
||||||
$messageParser->setOutputType($type);
|
$messageParser->setOutputType($type);
|
||||||
@ -90,11 +90,9 @@ public function getFormattedMessage($type = 'text/html', $attachmentList = null)
|
|||||||
$message = $messageParser->parse($message, false, false, true, false);
|
$message = $messageParser->parse($message, false, false, true, false);
|
||||||
break;
|
break;
|
||||||
case self::TYPE_ATTACHMENT:
|
case self::TYPE_ATTACHMENT:
|
||||||
if ($attachmentList === null) {
|
$attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
|
||||||
$attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
|
$attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
|
||||||
$attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
|
$attachmentList->readObjects();
|
||||||
$attachmentList->readObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
AttachmentBBCode::setAttachmentList($attachmentList);
|
AttachmentBBCode::setAttachmentList($attachmentList);
|
||||||
AttachmentBBCode::setObjectID($this->messageID);
|
AttachmentBBCode::setObjectID($this->messageID);
|
||||||
@ -149,28 +147,12 @@ public function jsonify($raw = false) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachment = null;
|
|
||||||
$attachmentList = null;
|
|
||||||
|
|
||||||
if ($this->attachmentID !== 0) {
|
|
||||||
$attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
|
|
||||||
$attachmentList->getConditionBuilder()->add('attachment.attachmentID = ?', array($this->attachmentID));
|
|
||||||
$attachmentList->getConditionBuilder()->add('attachment.objectID = ?', array($this->messageID));
|
|
||||||
$attachmentList->readObjects();
|
|
||||||
|
|
||||||
if (isset($attachmentList->objectIDs[0]) && $attachmentList->objectIDs[0] != 0) {
|
|
||||||
$attachment = $attachmentList->objects[$attachmentList->objectIDs[0]];
|
|
||||||
$attachment->data['imageinfo'] = WCF::getLanguage()->getDynamicVariable('wcf.attachment.image.info', array('attachment' => $attachment));
|
|
||||||
$attachment = $attachment->data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$array = array(
|
$array = array(
|
||||||
'formattedUsername' => $this->getUsername(true),
|
'formattedUsername' => $this->getUsername(true),
|
||||||
'formattedMessage' => $this->getFormattedMessage('text/html', ($attachmentList !== null) ? $attachmentList : null),
|
'formattedMessage' => $this->getFormattedMessage('text/html'),
|
||||||
'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'),
|
||||||
'separator' => $separator,
|
'separator' => $separator,
|
||||||
'message' => $this->getFormattedMessage('text/plain', ($attachmentList !== null) ? $attachmentList : null),
|
'message' => $this->getFormattedMessage('text/plain'),
|
||||||
'sender' => (int) $this->sender,
|
'sender' => (int) $this->sender,
|
||||||
'username' => $this->getUsername(),
|
'username' => $this->getUsername(),
|
||||||
'time' => (int) $this->time,
|
'time' => (int) $this->time,
|
||||||
@ -178,8 +160,7 @@ public function jsonify($raw = false) {
|
|||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
'roomID' => (int) $this->roomID,
|
'roomID' => (int) $this->roomID,
|
||||||
'messageID' => (int) $this->messageID,
|
'messageID' => (int) $this->messageID,
|
||||||
'additionalData' => $this->additionalData,
|
'additionalData' => $this->additionalData
|
||||||
'attachment' => $attachment
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($raw) return $array;
|
if ($raw) return $array;
|
||||||
|
@ -192,9 +192,24 @@
|
|||||||
padding: 5px 20px 5px 5px;
|
padding: 5px 20px 5px 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.userAvatar {
|
> div.avatarContainer {
|
||||||
float: left;
|
position: absolute;
|
||||||
margin-left: 16px;
|
width: 40px;
|
||||||
|
height: 38px;
|
||||||
|
|
||||||
|
> .userAvatar {
|
||||||
|
float: left;
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .avatarExtra {
|
||||||
|
box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.3);
|
||||||
|
position: absolute;
|
||||||
|
left: 24px;
|
||||||
|
bottom: -2px;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.innerMessage {
|
.innerMessage {
|
||||||
@ -219,11 +234,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.bubble {
|
&.bubble {
|
||||||
.userAvatar {
|
> div.avatarContainer {
|
||||||
margin-left: 0;
|
.userAvatar {
|
||||||
|
margin-left: 0;
|
||||||
.icon {
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
{literal}
|
{literal}
|
||||||
<div class="messageIcon">
|
{if $message.type == $messageTypes.LEAVE || $message.type == $messageTypes.JOIN}
|
||||||
{if $message.type == $messageTypes.LEAVE || $message.type == $messageTypes.JOIN || $message.type == $messageTypes.ATTACHMENT}
|
<div class="messageIcon">
|
||||||
<span class="icon icon16 icon-{if $message.type == $messageTypes.LEAVE}signout{elseif $message.type == $messageTypes.JOIN}signin{else}paperclip{/if}"></span>
|
<span class="icon icon16 icon-{if $message.type == $messageTypes.LEAVE}signout{elseif $message.type == $messageTypes.JOIN}signin{/if}"></span>
|
||||||
{/if}
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
<div class="innerMessageContainer{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER || $message.type == $messageTypes.INFORMATION} bubble{/if}{if $message.type == $messageTypes.WHISPER && $message.sender != $__wcf.User.userID} right{/if}">
|
<div class="innerMessageContainer{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER || $message.type == $messageTypes.INFORMATION || $message.type == $messageTypes.ATTACHMENT} bubble{/if}{if $message.type == $messageTypes.WHISPER && $message.sender != $__wcf.User.userID} right{/if}">
|
||||||
<div class="userAvatar framed">
|
<div class="avatarContainer">
|
||||||
{if $message.type != $messageTypes.INFORMATION}
|
<div class="userAvatar framed">
|
||||||
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER}
|
{if $message.type != $messageTypes.INFORMATION}
|
||||||
{@$message.avatar[32]}
|
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER || $message.type == $messageTypes.ATTACHMENT}
|
||||||
|
{@$message.avatar[32]}
|
||||||
|
{else}
|
||||||
|
{@$message.avatar[16]}
|
||||||
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
{@$message.avatar[16]}
|
<span class="icon icon32 icon-info-sign"></span>
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
</div>
|
||||||
<span class="icon icon32 icon-info-sign"></span>
|
{if $message.type == $messageTypes.ATTACHMENT}
|
||||||
|
<small class="framed avatarExtra">
|
||||||
|
<span class="icon icon16 icon-paperclip"></span>
|
||||||
|
</small>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="innerMessage">
|
<div class="innerMessage">
|
||||||
@ -36,7 +43,8 @@
|
|||||||
|
|
||||||
<time>{@$message.formattedTime}</time>
|
<time>{@$message.formattedTime}</time>
|
||||||
|
|
||||||
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER}
|
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER || $message.type == $messageTypes.ATTACHMENT}
|
||||||
|
{if $message.type == $messageTypes.ATTACHMENT}<span>{lang}chat.message.{$messageTypes.ATTACHMENT}{/lang}</span>{/if}
|
||||||
<ul class="text">
|
<ul class="text">
|
||||||
<li>
|
<li>
|
||||||
{if $message.isFollowUp} <time>{@$message.formattedTime}</time>{/if}
|
{if $message.isFollowUp} <time>{@$message.formattedTime}</time>{/if}
|
||||||
@ -44,24 +52,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{else}
|
{else}
|
||||||
{if $message.type == $messageTypes.ATTACHMENT && $message.attachment != null}
|
<span class="text">{@$message.formattedMessage}</span>
|
||||||
{if parseInt($message.attachment.isImage) == 1}
|
|
||||||
<span class="text">{lang}chat.message.{$messageTypes.ATTACHMENT}{/lang}</span>
|
|
||||||
<ul>
|
|
||||||
<li class="attachmentThumbnail">
|
|
||||||
{@$message.formattedMessage}
|
|
||||||
<div title="{$message.attachment.imageinfo}">
|
|
||||||
<p>{$message.attachment.filename}</p>
|
|
||||||
<small>{$message.attachment.imageinfo}</small>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{else}
|
|
||||||
<span class="text">{lang}chat.message.{$messageTypes.ATTACHMENT}{/lang} {@$message.formattedMessage}</span>
|
|
||||||
{/if}
|
|
||||||
{else}
|
|
||||||
<span class="text">{@$message.formattedMessage}</span>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span class="markContainer">
|
<span class="markContainer">
|
||||||
|
Loading…
Reference in New Issue
Block a user