From fd3ffcef082b9b16549002c583d65ba78f0dd82f Mon Sep 17 00:00:00 2001 From: veselcraft Date: Fri, 8 Oct 2021 20:44:57 +0300 Subject: [PATCH] Wall: Now you can comment when you're reposting (fixes #167) --- Web/Presenters/WallPresenter.php | 5 ++-- .../components/post/microblogpost.xml | 2 +- .../templates/components/post/oldpost.xml | 2 +- Web/static/js/openvk.cls.js | 27 ++++++++++++++++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index eb2d0051..01c2ca0f 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -298,7 +298,7 @@ final class WallPresenter extends OpenVKPresenter $nPost = new Post; $nPost->setOwner($this->user->id); $nPost->setWall($this->user->id); - $nPost->setContent(""); + $nPost->setContent($this->postParam("text")); $nPost->save(); $nPost->attach($post); @@ -306,8 +306,7 @@ final class WallPresenter extends OpenVKPresenter (new RepostNotification($post->getOwner(false), $post, $this->user->identity))->emit(); }; - $this->flash("succ", "Успешно", "Запись появится на вашей стене. Вернуться к записи."); - $this->redirect($this->user->identity->getURL()); + exit(json_encode(["wall_owner" => $this->user->identity->getId()])); } function renderDelete(int $wall, int $post_id): void diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index 60cf8ce2..6f29a281 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -82,7 +82,7 @@
-
{$post->getRepostCount()} diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 4b46117a..d111b2ae 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -91,7 +91,7 @@  |  {/if} -
+ {if $post->getRepostCount() > 0} {_"share"} ({$post->getRepostCount()}) diff --git a/Web/static/js/openvk.cls.js b/Web/static/js/openvk.cls.js index 7d00f07c..c6db0380 100644 --- a/Web/static/js/openvk.cls.js +++ b/Web/static/js/openvk.cls.js @@ -1,5 +1,3 @@ - - function expand_wall_textarea() { var el = document.getElementById('post-buttons'); var wi = document.getElementById('wall-post-input'); @@ -82,4 +80,27 @@ u("#_noteDelete").on("click", function(e) { return e.preventDefault(); }); -}); //END ONREADY DECLS \ No newline at end of file +}); //END ONREADY DECLS + +function repostPost(id, hash) { + uRepostMsgTxt = "Ваш комментарий:

"; + + MessageBox("Поделиться", uRepostMsgTxt, ["Отправить", "Отменить"], [ + (function() { + text = document.querySelector("#uRepostMsgInput_"+id).value; + xhr = new XMLHttpRequest(); + xhr.open("POST", "/wall"+id+"/repost?hash="+hash, true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhr.onload = (function() { + if(xhr.responseText.indexOf("wall_owner") === -1) + MessageBox("Помилка", "Не удалось поделиться записью...", ["OK"], [Function.noop]); + else { + let jsonR = JSON.parse(xhr.responseText); + MessageBox("Успешно", "Запись появится на вашей стене.
Перейти на свою стену.", ["OK"], [Function.noop]); + } + }); + xhr.send('text=' + encodeURI(text)); + }), + Function.noop + ]); +}