mirror of
https://github.com/openvk/openvk
synced 2025-03-15 05:55:29 +03:00
Редактирование постов
This commit is contained in:
parent
4891030ed0
commit
504cedfb1f
5 changed files with 59 additions and 21 deletions
|
@ -207,7 +207,7 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMakePost(int $wall): void
|
function renderMakePost(int $wall, ?int $editTarget = 0): void
|
||||||
{
|
{
|
||||||
$this->assertUserLoggedIn();
|
$this->assertUserLoggedIn();
|
||||||
$this->willExecuteWriteAction();
|
$this->willExecuteWriteAction();
|
||||||
|
@ -272,15 +272,25 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
|
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$post = new Post;
|
if ($editTarget) {
|
||||||
$post->setOwner($this->user->id);
|
$post = $this->posts->getPostById($this->user->id, $editTarget);
|
||||||
$post->setWall($wall);
|
$post->setEdited(time());
|
||||||
$post->setCreated(time());
|
$post->setContent($this->postParam("text"));
|
||||||
$post->setContent($this->postParam("text"));
|
$post->setFlags($flags);
|
||||||
$post->setAnonymous($anon);
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
$post->setFlags($flags);
|
$post->save();
|
||||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
} else {
|
||||||
$post->save();
|
$post = new Post;
|
||||||
|
$post->setOwner($this->user->id);
|
||||||
|
$post->setWall($wall);
|
||||||
|
$post->setCreated(time());
|
||||||
|
$post->setContent($this->postParam("text"));
|
||||||
|
$post->setAnonymous($anon);
|
||||||
|
$post->setFlags($flags);
|
||||||
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
|
$post->save();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (\LengthException $ex) {
|
} catch (\LengthException $ex) {
|
||||||
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big"));
|
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,12 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content" id="{$post->getPrettyId()}">
|
<div class="post-content" id="{$post->getPrettyId()}">
|
||||||
<div class="text" id="text{$post->getPrettyId()}">
|
<div class="text">
|
||||||
{$post->getText()|noescape}
|
<span id="text{$post->getPrettyId()}">{$post->getText()|noescape}</span>
|
||||||
|
|
||||||
|
<div class="edit" id="text_edit{$post->getPrettyId()}" style="display: none;">
|
||||||
|
{include "../textArea.xml", route => "/wall$owner/makePost/{$post->getVirtualId()}"}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div n:ifcontent class="attachments_b">
|
<div n:ifcontent class="attachments_b">
|
||||||
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
||||||
|
@ -73,6 +77,9 @@
|
||||||
<br/>
|
<br/>
|
||||||
! Этот пост был размещён за взятку.
|
! Этот пост был размещён за взятку.
|
||||||
</div>
|
</div>
|
||||||
|
<div n:if="$post->getEditTime()" style="color:grey;">
|
||||||
|
ред. {$post->getEditTime()}
|
||||||
|
</div>
|
||||||
<div n:if="$post->isSigned()" class="post-signature">
|
<div n:if="$post->isSigned()" class="post-signature">
|
||||||
{var $actualAuthor = $post->getOwner(false)}
|
{var $actualAuthor = $post->getOwner(false)}
|
||||||
<span>
|
<span>
|
||||||
|
@ -88,6 +95,10 @@
|
||||||
{if isset($thisUser)}
|
{if isset($thisUser)}
|
||||||
|
|
||||||
|
|
||||||
|
{if !($forceNoEditLink ?? false) && $post->canBePinnedBy($thisUser)}
|
||||||
|
<a onClick="edit_post({$author->getId()}, {$post->getVirtualId()})">Редактировать</a> |
|
||||||
|
{/if}
|
||||||
|
|
||||||
<a n:if="!($forceNoCommentsLink ?? false) && $commentsCount == 0" href="javascript:expand_comment_textarea({$commentTextAreaId})">{_comment}</a>
|
<a n:if="!($forceNoCommentsLink ?? false) && $commentsCount == 0" href="javascript:expand_comment_textarea({$commentTextAreaId})">{_comment}</a>
|
||||||
|
|
||||||
<div class="like_wrap">
|
<div class="like_wrap">
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
{var $deac = "post_deact_silent"}
|
{var $deac = "post_deact_silent"}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<table border="0" style="font-size: 11px;" n:class="post, $post->isExplicit() ? post-nsfw">
|
<table border="0" style="font-size: 11px;" n:class="post, $post->isExplicit() ? post-nsfw">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -41,8 +43,14 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content" id="{$post->getPrettyId()}">
|
<div class="post-content" id="{$post->getPrettyId()}">
|
||||||
<div class="text" id="text{$post->getPrettyId()}">
|
<div class="text">
|
||||||
{$post->getText()|noescape}
|
{var $owner = $author->getId()}
|
||||||
|
|
||||||
|
<span id="text{$post->getPrettyId()}">{$post->getText()|noescape}</span>
|
||||||
|
|
||||||
|
<div class="edit" id="text_edit{$post->getPrettyId()}" style="display: none;">
|
||||||
|
{include "../textArea.xml", route => "/wall$owner/makePost/{$post->getVirtualId()}"}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div n:ifcontent class="attachments_b">
|
<div n:ifcontent class="attachments_b">
|
||||||
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
||||||
|
@ -54,6 +62,9 @@
|
||||||
<br/>
|
<br/>
|
||||||
! Этот пост был размещён за взятку.
|
! Этот пост был размещён за взятку.
|
||||||
</div>
|
</div>
|
||||||
|
<div n:if="$post->getEditTime()" style="color:grey;">
|
||||||
|
ред. {$post->getEditTime()}
|
||||||
|
</div>
|
||||||
<div n:if="$post->isSigned()" class="post-signature">
|
<div n:if="$post->isSigned()" class="post-signature">
|
||||||
{var $actualAuthor = $post->getOwner(false)}
|
{var $actualAuthor = $post->getOwner(false)}
|
||||||
<span>
|
<span>
|
||||||
|
@ -70,6 +81,10 @@
|
||||||
{var $forceNoPinLink = true}
|
{var $forceNoPinLink = true}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{if !($forceNoEditLink ?? false) && $post->canBePinnedBy($thisUser)}
|
||||||
|
<a onClick="edit_post({$author->getId()}, {$post->getVirtualId()})">Редактировать</a> |
|
||||||
|
{/if}
|
||||||
|
|
||||||
{if !($forceNoDeleteLink ?? false) && $post->canBeDeletedBy($thisUser)}
|
{if !($forceNoDeleteLink ?? false) && $post->canBeDeletedBy($thisUser)}
|
||||||
<a href="/wall{$post->getPrettyId()}/delete">{_delete}</a> |
|
<a href="/wall{$post->getPrettyId()}/delete">{_delete}</a> |
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -119,6 +119,8 @@ routes:
|
||||||
handler: "Wall->rss"
|
handler: "Wall->rss"
|
||||||
- url: "/wall{num}/makePost"
|
- url: "/wall{num}/makePost"
|
||||||
handler: "Wall->makePost"
|
handler: "Wall->makePost"
|
||||||
|
- url: "/wall{num}/makePost/{num}"
|
||||||
|
handler: "Wall->makePost"
|
||||||
- url: "/wall{num}_{num}"
|
- url: "/wall{num}_{num}"
|
||||||
handler: "Wall->post"
|
handler: "Wall->post"
|
||||||
- url: "/wall{num}_{num}/like"
|
- url: "/wall{num}_{num}/like"
|
||||||
|
|
|
@ -13,8 +13,8 @@ function expand_comment_textarea(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit_post(id, wid) {
|
function edit_post(id, wid) {
|
||||||
var el = document.getElementById('text'+wid+'_'+id);
|
var el = document.getElementById(`text${id}_${wid}`);
|
||||||
var ed = document.getElementById('text_edit'+wid+'_'+id);
|
var ed = document.getElementById(`text_edit${id}_${wid}`);
|
||||||
if (el.style.display == "none") {
|
if (el.style.display == "none") {
|
||||||
el.style.display = "block";
|
el.style.display = "block";
|
||||||
ed.style.display = "none";
|
ed.style.display = "none";
|
||||||
|
|
Loading…
Reference in a new issue