Move photo page url resolution to model

мб пофиксит 842 янеипу
This commit is contained in:
celestora 2023-01-29 19:14:29 +02:00
parent 5401871b38
commit beb8b4eaa6
3 changed files with 10 additions and 3 deletions

View file

@ -283,6 +283,14 @@ class Photo extends Media
return [$x, $y];
}
function getPageURL(): string
{
if($this->isAnonymous())
return "/photos/" . base_convert((string) $this->getId(), 10, 32);
return "/photo" . $this->getPrettyId();
}
function getAlbum(): ?Album
{
return (new Albums)->getAlbumByPhotoId($this);

View file

@ -1,7 +1,6 @@
{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}">
<a href="{$attachment->getPageUrl()}">
<img class="media" src="{$attachment->getURLBySizeId('normal')}" alt="{$attachment->getDescription()}" />
</a>
{else}

View file

@ -1,4 +1,4 @@
{var $user = $notification->getModel(0)}
{var $post = $notification->getModel(1)}
{_nt_you_were_mentioned_u} <a href="{$user->getURL()}"><b>{$user->getCanonicalName()}</b></a> {$notification->getDateTime()} <a href="/photo{$post->getURL()}"><b>{_nt_mention_in_photo}</b></a>: "{$notification->getData()}"
{_nt_you_were_mentioned_u} <a href="{$user->getURL()}"><b>{$user->getCanonicalName()}</b></a> {$notification->getDateTime()} <a href="/photo{$post->getPageURL()}"><b>{_nt_mention_in_photo}</b></a>: "{$notification->getData()}"