diff --git a/Web/Models/Entities/Comment.php b/Web/Models/Entities/Comment.php index d64a2763..37b06dda 100644 --- a/Web/Models/Entities/Comment.php +++ b/Web/Models/Entities/Comment.php @@ -11,7 +11,7 @@ class Comment extends Post function getPrettyId(): string { - return $this->getRecord()->id; + return (string)$this->getRecord()->id; } function getVirtualId(): int diff --git a/Web/Presenters/InternalAPIPresenter.php b/Web/Presenters/InternalAPIPresenter.php index d7caab01..e2e6b50e 100644 --- a/Web/Presenters/InternalAPIPresenter.php +++ b/Web/Presenters/InternalAPIPresenter.php @@ -1,6 +1,6 @@ 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([ diff --git a/Web/Presenters/templates/components/attachment.xml b/Web/Presenters/templates/components/attachment.xml index 94d12034..a46be837 100644 --- a/Web/Presenters/templates/components/attachment.xml +++ b/Web/Presenters/templates/components/attachment.xml @@ -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())} - + {$attachment->getDescription()} {else} diff --git a/Web/Presenters/templates/components/comment.xml b/Web/Presenters/templates/components/comment.xml index 9be7d838..1ba7ada3 100644 --- a/Web/Presenters/templates/components/comment.xml +++ b/Web/Presenters/templates/components/comment.xml @@ -24,7 +24,7 @@
- {include "attachment.xml", attachment => $attachment} + {include "attachment.xml", attachment => $attachment, parent => $comment, parentType => "comment"}
diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index aa2c992e..8dba32f4 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -81,7 +81,7 @@ {var $attachmentsLayout = $post->getChildrenWithLayout($width)}
- {include "../attachment.xml", attachment => $attachment[2], post => $post} + {include "../attachment.xml", attachment => $attachment[2], parent => $post, parentType => "post"}
diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 99877d91..3223e6b7 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -72,7 +72,7 @@ {var $attachmentsLayout = $post->getChildrenWithLayout($width)}
- {include "../attachment.xml", attachment => $attachment[2], post => $post} + {include "../attachment.xml", attachment => $attachment[2], parent => $post, parentType => "post"}
diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 67debb82..941ab6ba 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -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", ` -
+
more...
`) } @@ -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) => {