add user avatar #14 #15

This commit is contained in:
ghost 2023-09-24 00:18:16 +03:00
parent a600a08a28
commit 8740e7a63f
5 changed files with 63 additions and 2 deletions

View file

@ -19,6 +19,11 @@ class AppControllerModuleProfile
$comments = $this->_user->findUserPageCommentsDistinctTotal();
$editions = $this->_user->findUserPageEditionsDistinctTotal();
$identicon = $this->_user->getIdenticon(24);
$public = $this->_user->getPublic();
$address = $this->_user->getAddress();
include __DIR__ . '../../../view/theme/default/module/profile.phtml';
}
}

View file

@ -100,11 +100,36 @@ class AppControllerUser
exit;
}
public function getIdenticon(int $size)
{
$icon = new Jdenticon\Identicon();
$icon->setValue($this->_user->public ? $this->_user->address : $this->_user->userId);
$icon->setSize($size);
$icon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
]
);
return $icon->getImageDataUri('webp');
}
public function getUser()
{
return $this->_user;
}
public function getPublic()
{
return $this->_user->public;
}
public function getAddress()
{
return $this->_user->address;
}
public function findUserPageStarsDistinctTotalByValue(bool $value) : int
{
return $this->_database->findUserPageStarsDistinctTotal(

View file

@ -1,4 +1,11 @@
<div class="position-fixed width-160-px margin-l--176 margin-y-8 padding-y-8 background-color-night border-radius-3">
<div class="margin-y-8 padding-b-8 position-fixed width-160-px margin-l--176 background-color-night border-radius-3">
<div class="padding-8 margin-b-8 border-bottom-default">
<?php if ($public) { ?>
<img class="border-radius-50 border-color-green border-width-2 margin-r-8 vertical-align-middle" src="<?php echo $identicon ?>" alt="identicon" />
<?php } else { ?>
<img class="border-radius-50 border-color-pink border-width-2 margin-r-8 vertical-align-middle" src="<?php echo $identicon ?>" alt="identicon" />
<?php } ?>
</div>
<?php if ($route == '') { ?>
<span class="padding-x-16 padding-y-8 display-block background-color-green cursor-default text-color-white">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-house-door-fill" viewBox="0 0 16 16">