mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +03:00
parent
4ab9d67718
commit
129d415877
4 changed files with 37 additions and 20 deletions
|
@ -38,7 +38,18 @@ final class CommentPresenter extends OpenVKPresenter
|
||||||
$entity = $repo->get($eId);
|
$entity = $repo->get($eId);
|
||||||
if(!$entity) $this->notFound();
|
if(!$entity) $this->notFound();
|
||||||
|
|
||||||
|
$photo = NULL;
|
||||||
|
if($_FILES["_pic_attachment"]["error"] === UPLOAD_ERR_OK) {
|
||||||
try {
|
try {
|
||||||
|
$photo = Photo::fastMake($this->user->id, $this->postParam("text"), $_FILES["_pic_attachment"]);
|
||||||
|
} catch(ISE $ex) {
|
||||||
|
$this->flashFail("err", "Не удалось опубликовать пост", "Файл изображения повреждён, слишком велик или одна сторона изображения в разы больше другой.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($this->postParam("text")) && is_null($photo))
|
||||||
|
$this->flashFail("err", "Не удалось опубликовать комментарий", "Нельзя опубликовать пустой комментарий.");
|
||||||
|
|
||||||
$comment = new Comment;
|
$comment = new Comment;
|
||||||
$comment->setOwner($this->user->id);
|
$comment->setOwner($this->user->id);
|
||||||
$comment->setModel(get_class($entity));
|
$comment->setModel(get_class($entity));
|
||||||
|
@ -47,17 +58,8 @@ final class CommentPresenter extends OpenVKPresenter
|
||||||
$comment->setCreated(time());
|
$comment->setCreated(time());
|
||||||
$comment->save();
|
$comment->save();
|
||||||
|
|
||||||
if($_FILES["_pic_attachment"]["error"] === UPLOAD_ERR_OK) {
|
if(!is_null($photo))
|
||||||
try {
|
|
||||||
$photo = Photo::fastMake($this->user->id, $this->postParam("text"), $_FILES["_pic_attachment"]);
|
|
||||||
$comment->attach($photo);
|
$comment->attach($photo);
|
||||||
} catch(ISE $ex) {
|
|
||||||
$this->flashFail("err", "Не удалось опубликовать пост", "Файл изображения повреждён, слишком велик или одна сторона изображения в разы больше другой.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(\LogicException $ex) {
|
|
||||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Нельзя опубликовать пустой комментарий.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if($entity->getOwner()->getId() !== $this->user->identity->getId())
|
if($entity->getOwner()->getId() !== $this->user->identity->getId())
|
||||||
if(($owner = $entity->getOwner()) instanceof User)
|
if(($owner = $entity->getOwner()) instanceof User)
|
||||||
|
|
|
@ -34,3 +34,7 @@
|
||||||
<a class="profile_link" style="display:block;width:96%;" href="/report.pl/{$post->getId()}?type=post">{_report}</a>
|
<a class="profile_link" style="display:block;width:96%;" href="/report.pl/{$post->getId()}?type=post">{_report}</a>
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
|
{block bodyScripts}
|
||||||
|
{script "js/al_comments.js"}
|
||||||
|
{/block}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{var author = $comment->getOwner()}
|
{var author = $comment->getOwner()}
|
||||||
|
|
||||||
<a name="cid={$comment->getId()}"></a>
|
<a name="cid={$comment->getId()}"></a>
|
||||||
<table border="0" style="font-size: 11px;" class="post">
|
<table border="0" style="font-size: 11px;" class="post" data-comment-id="{$comment->getId()}" data-owner-id="{$author->getId()}">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="54" valign="top">
|
<td width="54" valign="top">
|
||||||
|
@ -30,9 +30,11 @@
|
||||||
{var canDelete = $comment->getOwner()->getId() == $thisUser->getId()}
|
{var canDelete = $comment->getOwner()->getId() == $thisUser->getId()}
|
||||||
{var canDelete = $canDelete || $comment->getTarget()->getOwner()->getId() == $thisUser->getId()}
|
{var canDelete = $canDelete || $comment->getTarget()->getOwner()->getId() == $thisUser->getId()}
|
||||||
{if $canDelete}
|
{if $canDelete}
|
||||||
<a href="/comment{$comment->getId()}/delete">{_"delete"}</a>
|
<a href="/comment{$comment->getId()}/delete">{_"delete"}</a> |
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<a class="comment-reply">Ответить</a>
|
||||||
|
|
||||||
<div style="float: right; font-size: .7rem;">
|
<div style="float: right; font-size: .7rem;">
|
||||||
<a href="/comment{$comment->getId()}/like?hash={rawurlencode($csrfToken)}">
|
<a href="/comment{$comment->getId()}/like?hash={rawurlencode($csrfToken)}">
|
||||||
<div class="heart" style="{if $comment->hasLikeFrom($thisUser)}opacity: 1;{else}opacity: 0.4;{/if}"></div>
|
<div class="heart" style="{if $comment->hasLikeFrom($thisUser)}opacity: 1;{else}opacity: 0.4;{/if}"></div>
|
||||||
|
|
9
Web/static/js/al_comments.js
Normal file
9
Web/static/js/al_comments.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
u(".comment-reply").on("click", function(e) {
|
||||||
|
let inputbox = u("#write textarea");
|
||||||
|
let comment = u(e.target).closest(".post");
|
||||||
|
let authorId = comment.data("owner-id");
|
||||||
|
let authorNm = u(".post-author > a > b", comment.first()).text().trim();
|
||||||
|
|
||||||
|
inputbox.text("[id" + authorId + "|" + authorNm + "], ");
|
||||||
|
inputbox.trigger("focusin");
|
||||||
|
});
|
Loading…
Reference in a new issue