Skip to content

Commit

Permalink
Фиксы для #980 и #979 (#982)
Browse files Browse the repository at this point in the history
* Что я должен здесь сказать?

* playerock

* Copypaste
  • Loading branch information
mrilyew authored Sep 16, 2023
1 parent 97a176c commit 06f324f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Web/Models/Entities/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ function canBeEditedBy(?User $user = NULL): bool
if($this->isDeactivationMessage() || $this->isUpdateAvatarMessage())
return false;

if($this->getTargetWall() > 0)
return $this->getPublicationTime()->timestamp() + WEEK > time();

return $user->getId() == $this->getOwner(false)->getId();
}

Expand Down
4 changes: 2 additions & 2 deletions Web/Models/Entities/Postable.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ function save(): void
$this->stateChanges("created", time());

$this->stateChanges("virtual_id", $pCount + 1);
} else {
} /*else {
$this->stateChanges("edited", time());
}
}*/

parent::save();
}
Expand Down
1 change: 1 addition & 0 deletions Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ function renderEdit()
"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()
Expand Down
10 changes: 7 additions & 3 deletions Web/Presenters/templates/Photos/UploadPhoto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
{block title}{_upload_photo}{/block}

{block header}
<a href="{$thisUser->getURL()}">{$thisUser->getCanonicalName()}</a>
<a href="{$album->getOwner()->getURL()}">{$album->getOwner()->getCanonicalName()}</a>
»
<a href="/albums{$thisUser->getId()}">{_albums}</a>
{if $album->getOwner() instanceof openvk\Web\Models\Entities\Club}
<a href="/albums{$album->getOwner()->getId() * -1}">{_albums}</a>
{else}
<a href="/albums{$album->getOwner()->getId()}">{_albums}</a>
{/if}
»
<a href="/album{$album->getPrettyId()}">{$album->getName()}</a>
»
Expand All @@ -23,7 +27,7 @@

<input type="file" accept=".jpg,.png,.gif" name="files[]" multiple class="button" id="uploadButton" style="display:none">

<div class="container_gray" style="height: 344px;">
<div class="container_gray" style="min-height: 344px;">
<div class="insertThere"></div>
<div class="whiteBox" style="display: block;">
<div class="boxContent">
Expand Down
6 changes: 3 additions & 3 deletions Web/Presenters/templates/components/comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
<tr>
<td width="30" valign="top">
<a href="{$author->getURL()}">
<img src="{$author->getAvatarURL('miniscule')}" width="30" class="cCompactAvatars" />
<img src="{$author->getAvatarURL('miniscule')}" width="30" class="cCompactAvatars post-avatar" />
</a>
</td>
<td width="100%" valign="top">
<div class="post-author">
<a href="{$author->getURL()}"><b>
<a href="{$author->getURL()}"><b class="post-author-name">
{$author->getCanonicalName()}
</b></a>
<img n:if="$author->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png"><br/>
</div>
<div class="post-content" id="{$comment->getId()}">
<div class="text" id="text{$comment->getId()}">
<span class="really_text">{$comment->getText()|noescape}</span>
<span data-text="{$comment->getText(false)}" class="really_text">{$comment->getText()|noescape}</span>

<div n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$comment->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/templates/components/post/microblogpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</div>
<div class="post-content" id="{$post->getPrettyId()}">
<div class="text">
<span class="really_text">{$post->getText()|noescape}</span>
<span data-text="{$post->getText(false)}" class="really_text">{$post->getText()|noescape}</span>

<div n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/templates/components/post/oldpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<div class="text">
{var $owner = $author->getId()}

<span class="really_text">{$post->getText()|noescape}</span>
<span data-text="{$post->getText(false)}" class="really_text">{$post->getText()|noescape}</span>

<div n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
Expand Down
27 changes: 23 additions & 4 deletions Web/static/js/al_photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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

Expand All @@ -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")
}
})
3 changes: 2 additions & 1 deletion Web/static/js/al_wall.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ $(document).on("click", "#editPost", (e) => {
content.insertAdjacentHTML("afterbegin", `
<div class="editMenu">
<div id="wall-post-input999">
<textarea id="new_content">${text.innerHTML.replace(/(<([^>]+)>)/gi, '')}</textarea>
<textarea id="new_content">${text.dataset.text}</textarea>
<input type="button" class="button" value="${tr("save")}" id="endEditing">
<input type="button" class="button" value="${tr("cancel")}" id="cancelEditing">
</div>
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 06f324f

Please sign in to comment.