Fiks fotos viver four coments.

This commit is contained in:
lalka2016 2023-09-19 18:13:57 +03:00
parent f0490bd05e
commit ed49596674
7 changed files with 21 additions and 14 deletions

View file

@ -11,7 +11,7 @@ class Comment extends Post
function getPrettyId(): string
{
return $this->getRecord()->id;
return (string)$this->getRecord()->id;
}
function getVirtualId(): int

View file

@ -1,6 +1,6 @@
<?php declare(strict_types=1);
namespace openvk\Web\Presenters;
use openvk\Web\Models\Repositories\Posts;
use openvk\Web\Models\Repositories\{Posts, Comments};
use MessagePack\MessagePack;
use Chandler\Session\Session;
@ -102,8 +102,13 @@ final class InternalAPIPresenter extends OpenVKPresenter
header("HTTP/1.1 405 Method Not Allowed");
exit("иди нахуй заебал");
}
$post = (new Posts)->getPostById($owner_id, $post_id);
if($this->postParam("parentType", false) == "post") {
$post = (new Posts)->getPostById($owner_id, $post_id);
} else {
$post = (new Comments)->get($post_id);
}
if(is_null($post)) {
$this->returnJson([

View file

@ -1,7 +1,7 @@
{if $attachment instanceof \openvk\Web\Models\Entities\Photo}
{if !$attachment->isDeleted()}
{var $link = "/photo" . ($attachment->isAnonymous() ? ("s/" . base_convert((string) $attachment->getId(), 10, 32)) : $attachment->getPrettyId())}
<a href="{$link}" onclick="OpenMiniature(event, {$attachment->getURLBySizeId('normal')}, {$post->getPrettyId()}, {$attachment->getPrettyId()})">
<a href="{$link}" onclick="OpenMiniature(event, {$attachment->getURLBySizeId('normal')}, {$parent->getPrettyId()}, {$attachment->getPrettyId()}, {$parentType})">
<img class="media media_makima" src="{$attachment->getURLBySizeId('normal')}" alt="{$attachment->getDescription()}" />
</a>
{else}

View file

@ -24,7 +24,7 @@
<div n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$comment->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
{include "attachment.xml", attachment => $attachment}
{include "attachment.xml", attachment => $attachment, parent => $comment, parentType => "comment"}
</div>
</div>
</div>

View file

@ -81,7 +81,7 @@
{var $attachmentsLayout = $post->getChildrenWithLayout($width)}
<div n:ifcontent class="attachments attachments_b" style="height: {$attachmentsLayout->height|noescape}; width: {$attachmentsLayout->width|noescape};">
<div class="attachment" n:foreach="$attachmentsLayout->tiles as $attachment" style="float: {$attachment[3]|noescape}; width: {$attachment[0]|noescape}; height: {$attachment[1]|noescape};" data-localized-nsfw-text="{_nsfw_warning}">
{include "../attachment.xml", attachment => $attachment[2], post => $post}
{include "../attachment.xml", attachment => $attachment[2], parent => $post, parentType => "post"}
</div>
</div>

View file

@ -72,7 +72,7 @@
{var $attachmentsLayout = $post->getChildrenWithLayout($width)}
<div n:ifcontent class="attachments attachments_b" style="height: {$attachmentsLayout->height|noescape}; width: {$attachmentsLayout->width|noescape};">
<div class="attachment" n:foreach="$attachmentsLayout->tiles as $attachment" style="float: {$attachment[3]|noescape}; width: {$attachment[0]|noescape}; height: {$attachment[1]|noescape};" data-localized-nsfw-text="{_nsfw_warning}">
{include "../attachment.xml", attachment => $attachment[2], post => $post}
{include "../attachment.xml", attachment => $attachment[2], parent => $post, parentType => "post"}
</div>
</div>

View file

@ -158,7 +158,7 @@ function removePicture(idA) {
u(`div#aP${idA}`).nodes[0].remove();
}
function OpenMiniature(e, photo, post, photo_id) {
function OpenMiniature(e, photo, post, photo_id, type = "post") {
/*
костыли но смешные однако
*/
@ -275,7 +275,9 @@ function OpenMiniature(e, photo, post, photo_id) {
__slidePhoto(1);
});
ky.post("/iapi/getPhotosFromPost/" + post, {
let data = new FormData()
data.append('parentType', type);
ky.post("/iapi/getPhotosFromPost/" + (type == "post" ? post : "1_"+post), {
hooks: {
afterResponse: [
async (_request, _options, response) => {
@ -297,7 +299,8 @@ function OpenMiniature(e, photo, post, photo_id) {
__reloadTitleBar();
__loadDetails(json.body[imagesIndex - 1].id, imagesIndex); }
]
}
},
body: data
});
return u(".ovk-photo-view-dimmer");
@ -753,7 +756,6 @@ $(document).on("click", "#photosAttachments", async (e) => {
}
document.querySelector(".photosInsert h4").innerHTML = tr("is_x_photos", photos.count)
console.log(photos)
let pagesCount = Math.ceil(Number(photos.count) / 24)
u("#loader").remove()
@ -772,7 +774,7 @@ $(document).on("click", "#photosAttachments", async (e) => {
if(page < pagesCount) {
insertPlace.insertAdjacentHTML("beforeend", `
<div id="showMorePhotos" data-pagesCount="${pagesCount}" data-page="${page + 1}" style="width: 100%;text-align: center;background: #d5d5d5;height: 22px;padding-top: 9px;cursor:pointer;">
<div id="showMorePhotos" data-pagesCount="${pagesCount}" data-page="${page + 1}" style="width: 100%;text-align: center;background: #f0f0f0;height: 22px;padding-top: 9px;cursor:pointer;">
<span>more...</span>
</div>`)
}
@ -790,7 +792,7 @@ $(document).on("click", "#photosAttachments", async (e) => {
$(".photosInsert").on("click", "#showMorePhotos", (e) => {
u(e.currentTarget).remove()
insertPhotos(Number(e.currentTarget.dataset.page))
insertPhotos(Number(e.currentTarget.dataset.page), document.querySelector(".topGrayBlock #albumSelect").value)
})
$(".topGrayBlock #albumSelect").on("change", (evv) => {