From 06f324f98cf985631e3aeb833eb9087e399fbf28 Mon Sep 17 00:00:00 2001 From: lalka2018 <99399973+lalka2016@users.noreply.github.com> Date: Sat, 16 Sep 2023 19:14:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20#980=20=D0=B8=20#979=20(#982)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Что я должен здесь сказать? * playerock * Copypaste --- Web/Models/Entities/Post.php | 3 +++ Web/Models/Entities/Postable.php | 4 +-- Web/Presenters/WallPresenter.php | 1 + .../templates/Photos/UploadPhoto.xml | 10 ++++--- .../templates/components/comment.xml | 6 ++--- .../components/post/microblogpost.xml | 2 +- .../templates/components/post/oldpost.xml | 2 +- Web/static/js/al_photos.js | 27 ++++++++++++++++--- Web/static/js/al_wall.js | 3 ++- 9 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Web/Models/Entities/Post.php b/Web/Models/Entities/Post.php index 2d323a8e..8c38c567 100644 --- a/Web/Models/Entities/Post.php +++ b/Web/Models/Entities/Post.php @@ -254,6 +254,9 @@ class Post extends Postable if($this->isDeactivationMessage() || $this->isUpdateAvatarMessage()) return false; + if($this->getTargetWall() > 0) + return $this->getPublicationTime()->timestamp() + WEEK > time(); + return $user->getId() == $this->getOwner(false)->getId(); } diff --git a/Web/Models/Entities/Postable.php b/Web/Models/Entities/Postable.php index 23981cc1..ffbf480c 100644 --- a/Web/Models/Entities/Postable.php +++ b/Web/Models/Entities/Postable.php @@ -167,9 +167,9 @@ abstract class Postable extends Attachable $this->stateChanges("created", time()); $this->stateChanges("virtual_id", $pCount + 1); - } else { + } /*else { $this->stateChanges("edited", time()); - } + }*/ parent::save(); } diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 09392bc3..96b61b48 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -552,6 +552,7 @@ final class WallPresenter extends OpenVKPresenter "nsfw" => $this->postParam("type") === "post" ? (int)$post->isExplicit() : 0, "from_group" => $this->postParam("type") === "post" && $post->getTargetWall() < 0 ? ((int)$post->isPostedOnBehalfOfGroup()) : "false", + "new_text" => $post->getText(false), "author" => [ "name" => $post->getOwner()->getCanonicalName(), "avatar" => $post->getOwner()->getAvatarUrl() diff --git a/Web/Presenters/templates/Photos/UploadPhoto.xml b/Web/Presenters/templates/Photos/UploadPhoto.xml index 6ea987cb..ab81d3aa 100644 --- a/Web/Presenters/templates/Photos/UploadPhoto.xml +++ b/Web/Presenters/templates/Photos/UploadPhoto.xml @@ -2,9 +2,13 @@ {block title}{_upload_photo}{/block} {block header} - {$thisUser->getCanonicalName()} + {$album->getOwner()->getCanonicalName()} » - {_albums} + {if $album->getOwner() instanceof openvk\Web\Models\Entities\Club} + {_albums} + {else} + {_albums} + {/if} » {$album->getName()} » @@ -23,7 +27,7 @@ -
+
diff --git a/Web/Presenters/templates/components/comment.xml b/Web/Presenters/templates/components/comment.xml index fb8fb244..69238417 100644 --- a/Web/Presenters/templates/components/comment.xml +++ b/Web/Presenters/templates/components/comment.xml @@ -8,19 +8,19 @@ - +
- {$comment->getText()|noescape} + {$comment->getText()|noescape}
diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index c8cd2a12..6b0444c7 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -72,7 +72,7 @@
- {$post->getText()|noescape} + {$post->getText()|noescape}
diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index ad7896f2..6e0b4c53 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -63,7 +63,7 @@
{var $owner = $author->getId()} - {$post->getText()|noescape} + {$post->getText()|noescape}
diff --git a/Web/static/js/al_photos.js b/Web/static/js/al_photos.js index 59965c09..b4632d60 100644 --- a/Web/static/js/al_photos.js +++ b/Web/static/js/al_photos.js @@ -6,6 +6,18 @@ $(document).on("change", "#uploadButton", (e) => { return; } + for(const file of e.currentTarget.files) { + if(!file.type.startsWith('image/')) { + MessageBox(tr("error"), tr("only_images_accepted", escapeHtml(file.name)), [tr("ok")], [() => {Function.noop}]) + return; + } + + if(file.size > 5 * 1024 * 1024) { + MessageBox(tr("error"), tr("max_filesize", 5), [tr("ok")], [() => {Function.noop}]) + return; + } + } + if(document.querySelector(".whiteBox").style.display == "block") { document.querySelector(".whiteBox").style.display = "none" document.querySelector(".insertThere").append(document.getElementById("fakeButton")); @@ -142,23 +154,23 @@ $(document).on("dragover drop", (e) => { return false; }) -$(document).on("dragover", (e) => { +$(".container_gray").on("dragover", (e) => { e.preventDefault() document.querySelector("#fakeButton").classList.add("dragged") document.querySelector("#fakeButton").value = tr("drag_files_here") }) -$(document).on("dragleave", (e) => { +$(".container_gray").on("dragleave", (e) => { e.preventDefault() document.querySelector("#fakeButton").classList.remove("dragged") document.querySelector("#fakeButton").value = tr("upload_picts") }) -$("#fakeButton").on("drop", (e) => { +$(".container_gray").on("drop", (e) => { e.originalEvent.dataTransfer.dropEffect = 'move'; e.preventDefault() - $(document).trigger("dragleave") + $(".container_gray").trigger("dragleave") let files = e.originalEvent.dataTransfer.files @@ -177,3 +189,10 @@ $("#fakeButton").on("drop", (e) => { document.getElementById("uploadButton").files = files u("#uploadButton").trigger("change") }) + +u(".container_gray").on("paste", (e) => { + if(e.clipboardData.files.length > 0 && e.clipboardData.files.length < 10) { + document.getElementById("uploadButton").files = e.clipboardData.files; + u("#uploadButton").trigger("change") + } +}) diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 9b54adce..4c8bb933 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -273,7 +273,7 @@ $(document).on("click", "#editPost", (e) => { content.insertAdjacentHTML("afterbegin", `
- +
@@ -343,6 +343,7 @@ $(document).on("click", "#editPost", (e) => { post.querySelector(".post-avatar").setAttribute("src", result.author.avatar) post.querySelector(".post-author-name").innerHTML = result.author.name + post.querySelector(".really_text").setAttribute("data-text", result.new_text) } else { MessageBox(tr("error"), result.error, [tr("ok")], [Function.noop]) post.querySelector("#editPost").click()