From 0fb18e34f539c5f1ba4c15bf26fcb0c6f5475f71 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:57:25 +0300 Subject: [PATCH] feat(docs): corct aud/img preview, hide report btn when doc is yours. --- Web/Models/Entities/Document.php | 10 ++++++ Web/Presenters/DocumentsPresenter.php | 2 +- Web/Presenters/templates/Documents/Page.xml | 10 ++++-- Web/static/css/main.css | 5 +++ Web/static/js/al_docs.js | 36 +++++++++++---------- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Web/Models/Entities/Document.php b/Web/Models/Entities/Document.php index 54d647d3..6f6bf369 100644 --- a/Web/Models/Entities/Document.php +++ b/Web/Models/Entities/Document.php @@ -166,6 +166,16 @@ class Document extends Media return in_array($this->getVKAPIType(), [3, 4]); } + function isBook(): bool + { + return in_array($this->getFileExtension(), ["pdf"]); + } + + function isAudio(): bool + { + return in_array($this->getVKAPIType(), [Document::VKAPI_TYPE_AUDIO]); + } + function isGif(): bool { return $this->getVKAPIType() == 3; diff --git a/Web/Presenters/DocumentsPresenter.php b/Web/Presenters/DocumentsPresenter.php index 92dd73b0..92521e20 100644 --- a/Web/Presenters/DocumentsPresenter.php +++ b/Web/Presenters/DocumentsPresenter.php @@ -139,7 +139,7 @@ final class DocumentsPresenter extends OpenVKPresenter } catch(\TypeError $e) { $this->flashFail("err", tr("forbidden"), $e->getMessage(), null, $isAjax); } catch(ISE $e) { - $this->flashFail("err", tr("forbidden"), tr("error_file_preview"), null, $isAjax); + $this->flashFail("err", tr("forbidden"), "corrupted file", null, $isAjax); } catch(\ValueError $e) { $this->flashFail("err", tr("forbidden"), $e->getMessage(), null, $isAjax); } catch(\ImagickException $e) { diff --git a/Web/Presenters/templates/Documents/Page.xml b/Web/Presenters/templates/Documents/Page.xml index b6640185..ca4fc78a 100644 --- a/Web/Presenters/templates/Documents/Page.xml +++ b/Web/Presenters/templates/Documents/Page.xml @@ -22,8 +22,12 @@