mirror of
https://github.com/openvk/openvk
synced 2024-12-22 08:31:18 +03:00
Перенос ветки posts-edit (#958)
* Редактирование постов * Log posts changes * Fixes * Features * Совместимость с логами
This commit is contained in:
parent
ee2e5e8d1c
commit
37fc460b25
7 changed files with 69 additions and 22 deletions
|
@ -17,7 +17,7 @@ final class WallPresenter extends OpenVKPresenter
|
|||
function __construct(Posts $posts)
|
||||
{
|
||||
$this->posts = $posts;
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
@ -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->willExecuteWriteAction();
|
||||
|
@ -298,17 +298,28 @@ final class WallPresenter extends OpenVKPresenter
|
|||
|
||||
if(empty($this->postParam("text")) && !$photo && !$video && !$poll && !$note)
|
||||
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
|
||||
|
||||
|
||||
try {
|
||||
$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();
|
||||
if ($editTarget) {
|
||||
$post = $this->posts->getPostById($this->user->id, $editTarget);
|
||||
|
||||
$post->setEdited(time());
|
||||
$post->setContent($this->postParam("text"));
|
||||
$post->setFlags($flags);
|
||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||
$post->save();
|
||||
} else {
|
||||
$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) {
|
||||
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big"));
|
||||
}
|
||||
|
|
|
@ -34,6 +34,14 @@
|
|||
{/if}
|
||||
|
||||
<a n:if="$canDelete ?? false" class="profile_link" style="display:block;width:96%;" href="/wall{$post->getPrettyId()}/delete">{_delete}</a>
|
||||
<a
|
||||
n:if="$thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL) AND $post->getEditTime()"
|
||||
style="display:block;width:96%;"
|
||||
class="profile_link"
|
||||
href="/admin/logs?type=1&obj_type=Post&obj_id={$post->getId()}"
|
||||
>
|
||||
История изменений
|
||||
</a>
|
||||
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPost()">{_report}</a>
|
||||
</div>
|
||||
<script n:if="$canReport ?? false">
|
||||
|
|
|
@ -64,9 +64,13 @@
|
|||
{/if}
|
||||
</div>
|
||||
<div class="post-content" id="{$post->getPrettyId()}">
|
||||
<div class="text" id="text{$post->getPrettyId()}">
|
||||
{$post->getText()|noescape}
|
||||
|
||||
<div class="text">
|
||||
<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()}", value => $post->getText()}
|
||||
</div>
|
||||
|
||||
<div n:ifcontent class="attachments_b">
|
||||
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
||||
{include "../attachment.xml", attachment => $attachment}
|
||||
|
@ -77,6 +81,9 @@
|
|||
<br/>
|
||||
! Этот пост был размещён за взятку.
|
||||
</div>
|
||||
<div n:if="$post->getEditTime()" style="color:grey;">
|
||||
ред. {$post->getEditTime()}
|
||||
</div>
|
||||
<div n:if="$post->isSigned()" class="post-signature">
|
||||
{var $actualAuthor = $post->getOwner(false)}
|
||||
<span>
|
||||
|
@ -94,7 +101,11 @@
|
|||
</a>
|
||||
{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>
|
||||
|
||||
<div class="like_wrap">
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
{var $deac = "post_deact_silent"}
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
<table border="0" style="font-size: 11px;" n:class="post, $post->isExplicit() ? post-nsfw">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -58,9 +60,15 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="post-content" id="{$post->getPrettyId()}">
|
||||
<div class="text" id="text{$post->getPrettyId()}">
|
||||
{$post->getText()|noescape}
|
||||
|
||||
<div class="text">
|
||||
{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()}", value => $post->getText()}
|
||||
</div>
|
||||
|
||||
<div n:ifcontent class="attachments_b">
|
||||
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
|
||||
{include "../attachment.xml", attachment => $attachment}
|
||||
|
@ -71,6 +79,9 @@
|
|||
<br/>
|
||||
! Этот пост был размещён за взятку.
|
||||
</div>
|
||||
<div n:if="$post->getEditTime()" style="color:grey;">
|
||||
ред. {$post->getEditTime()}
|
||||
</div>
|
||||
<div n:if="$post->isSigned()" class="post-signature">
|
||||
{var $actualAuthor = $post->getOwner(false)}
|
||||
<span>
|
||||
|
@ -87,6 +98,10 @@
|
|||
{var $forceNoPinLink = true}
|
||||
{/if}
|
||||
|
||||
{if !($forceNoEditLink ?? false) && $post->canBePinnedBy($thisUser)}
|
||||
<a onClick="edit_post({$author->getId()}, {$post->getVirtualId()})">Редактировать</a> |
|
||||
{/if}
|
||||
|
||||
{if !($forceNoDeleteLink ?? false) && $post->canBeDeletedBy($thisUser)}
|
||||
<a href="/wall{$post->getPrettyId()}/delete">{_delete}</a> |
|
||||
{/if}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<div id="write" style="padding: 5px 0;" onfocusin="expand_wall_textarea({$textAreaId});">
|
||||
<form action="{$route}" method="post" enctype="multipart/form-data" style="margin:0;">
|
||||
<textarea id="wall-post-input{$textAreaId}" placeholder="{_write}" name="text" style="width: 100%;resize: none;" class="small-textarea"></textarea>
|
||||
<textarea id="wall-post-input{$textAreaId}" placeholder="{_write}" name="text" style="width: 100%;resize: none;" class="small-textarea">{$value|noescape}</textarea>
|
||||
<div>
|
||||
<!-- padding to fix <br/> bug -->
|
||||
</div>
|
||||
|
|
|
@ -129,6 +129,8 @@ routes:
|
|||
handler: "Wall->rss"
|
||||
- url: "/wall{num}/makePost"
|
||||
handler: "Wall->makePost"
|
||||
- url: "/wall{num}/makePost/{num}"
|
||||
handler: "Wall->makePost"
|
||||
- url: "/wall{num}_{num}"
|
||||
handler: "Wall->post"
|
||||
- url: "/wall{num}_{num}/like"
|
||||
|
|
|
@ -14,8 +14,8 @@ function expand_comment_textarea(id) {
|
|||
}
|
||||
|
||||
function edit_post(id, wid) {
|
||||
var el = document.getElementById('text'+wid+'_'+id);
|
||||
var ed = document.getElementById('text_edit'+wid+'_'+id);
|
||||
var el = document.getElementById(`text${id}_${wid}`);
|
||||
var ed = document.getElementById(`text_edit${id}_${wid}`);
|
||||
if (el.style.display == "none") {
|
||||
el.style.display = "block";
|
||||
ed.style.display = "none";
|
||||
|
|
Loading…
Reference in a new issue