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 @@