1
0
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:
Maximilian Mader 2013-11-02 23:08:12 +01:00
parent 77830cf6fb
commit 3fe5016c9a
3 changed files with 51 additions and 66 deletions

View File

@ -69,7 +69,7 @@ public function __toString() {
* @param string $outputType outputtype for messageparser
* @return string
*/
public function getFormattedMessage($type = 'text/html', $attachmentList = null) {
public function getFormattedMessage($type = 'text/html') {
$message = $this->message;
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
$messageParser->setOutputType($type);
@ -90,11 +90,9 @@ public function getFormattedMessage($type = 'text/html', $attachmentList = null)
$message = $messageParser->parse($message, false, false, true, false);
break;
case self::TYPE_ATTACHMENT:
if ($attachmentList === null) {
$attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
$attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
$attachmentList->readObjects();
}
$attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
$attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
$attachmentList->readObjects();
AttachmentBBCode::setAttachmentList($attachmentList);
AttachmentBBCode::setObjectID($this->messageID);
@ -149,28 +147,12 @@ public function jsonify($raw = false) {
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(
'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'),
'separator' => $separator,
'message' => $this->getFormattedMessage('text/plain', ($attachmentList !== null) ? $attachmentList : null),
'message' => $this->getFormattedMessage('text/plain'),
'sender' => (int) $this->sender,
'username' => $this->getUsername(),
'time' => (int) $this->time,
@ -178,8 +160,7 @@ public function jsonify($raw = false) {
'type' => (int) $this->type,
'roomID' => (int) $this->roomID,
'messageID' => (int) $this->messageID,
'additionalData' => $this->additionalData,
'attachment' => $attachment
'additionalData' => $this->additionalData
);
if ($raw) return $array;

View File

@ -192,9 +192,24 @@
padding: 5px 20px 5px 5px;
position: relative;
.userAvatar {
float: left;
margin-left: 16px;
> div.avatarContainer {
position: absolute;
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 {
@ -219,11 +234,9 @@
}
&.bubble {
.userAvatar {
margin-left: 0;
.icon {
padding: 2px;
> div.avatarContainer {
.userAvatar {
margin-left: 0;
}
}

View File

@ -1,19 +1,26 @@
{literal}
<div class="messageIcon">
{if $message.type == $messageTypes.LEAVE || $message.type == $messageTypes.JOIN || $message.type == $messageTypes.ATTACHMENT}
<span class="icon icon16 icon-{if $message.type == $messageTypes.LEAVE}signout{elseif $message.type == $messageTypes.JOIN}signin{else}paperclip{/if}"></span>
{/if}
</div>
<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="userAvatar framed">
{if $message.type != $messageTypes.INFORMATION}
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER}
{@$message.avatar[32]}
{if $message.type == $messageTypes.LEAVE || $message.type == $messageTypes.JOIN}
<div class="messageIcon">
<span class="icon icon16 icon-{if $message.type == $messageTypes.LEAVE}signout{elseif $message.type == $messageTypes.JOIN}signin{/if}"></span>
</div>
{/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="avatarContainer">
<div class="userAvatar framed">
{if $message.type != $messageTypes.INFORMATION}
{if $message.type == $messageTypes.NORMAL || $message.type == $messageTypes.WHISPER || $message.type == $messageTypes.ATTACHMENT}
{@$message.avatar[32]}
{else}
{@$message.avatar[16]}
{/if}
{else}
{@$message.avatar[16]}
<span class="icon icon32 icon-info-sign"></span>
{/if}
{else}
<span class="icon icon32 icon-info-sign"></span>
</div>
{if $message.type == $messageTypes.ATTACHMENT}
<small class="framed avatarExtra">
<span class="icon icon16 icon-paperclip"></span>
</small>
{/if}
</div>
<div class="innerMessage">
@ -36,7 +43,8 @@
<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">
<li>
{if $message.isFollowUp} <time>{@$message.formattedTime}</time>{/if}
@ -44,24 +52,7 @@
</li>
</ul>
{else}
{if $message.type == $messageTypes.ATTACHMENT && $message.attachment != null}
{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}
<span class="text">{@$message.formattedMessage}</span>
{/if}
</div>
<span class="markContainer">