From 8740e7a63f53440367c38ee91686bfb0933446ac Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 24 Sep 2023 00:18:16 +0300 Subject: [PATCH] add user avatar #14 #15 --- src/app/controller/module/profile.php | 5 ++++ src/app/controller/user.php | 25 +++++++++++++++++++ .../view/theme/default/module/profile.phtml | 9 ++++++- src/config/bootstrap.php | 3 +++ .../assets/theme/default/css/framework.css | 23 ++++++++++++++++- 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/app/controller/module/profile.php b/src/app/controller/module/profile.php index a84364c..9300539 100644 --- a/src/app/controller/module/profile.php +++ b/src/app/controller/module/profile.php @@ -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'; } } \ No newline at end of file diff --git a/src/app/controller/user.php b/src/app/controller/user.php index ba58cdb..0f6b883 100644 --- a/src/app/controller/user.php +++ b/src/app/controller/user.php @@ -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( diff --git a/src/app/view/theme/default/module/profile.phtml b/src/app/view/theme/default/module/profile.phtml index b102482..42c70dc 100644 --- a/src/app/view/theme/default/module/profile.phtml +++ b/src/app/view/theme/default/module/profile.phtml @@ -1,4 +1,11 @@ -
+
+
+ + identicon + + identicon + +
diff --git a/src/config/bootstrap.php b/src/config/bootstrap.php index cd88737..846cdeb 100644 --- a/src/config/bootstrap.php +++ b/src/config/bootstrap.php @@ -38,6 +38,9 @@ if (!file_exists(__DIR__ . '/env.' . PHP_ENV . '.php')) // Load environment require_once __DIR__ . '/env.' . PHP_ENV . '.php'; +// Autoload vendors +require_once __DIR__ . '/../../vendor/autoload.php'; + // Route parse_str($_SERVER['QUERY_STRING'], $request); diff --git a/src/public/assets/theme/default/css/framework.css b/src/public/assets/theme/default/css/framework.css index 4f5968b..420b599 100644 --- a/src/public/assets/theme/default/css/framework.css +++ b/src/public/assets/theme/default/css/framework.css @@ -108,6 +108,10 @@ a.label-green:hover { position: fixed; } +.vertical-align-middle { + vertical-align: middle; +} + .top--2 { top: -2px; } @@ -124,14 +128,22 @@ a.label-green:hover { border-radius: 3px; } +.border-radius-50 { + border-radius: 50%; +} + .border-pink-light { border: 1px #9b6895 solid; } -.border-pink { +.border-color-pink { border: 1px #a44399 solid; } +.border-color-green { + border: 1px #65916d solid; +} + .border-bottom-pink { border-bottom: 1px #a44399 solid; } @@ -148,6 +160,10 @@ a.label-green:hover { border-top: 1px #5d627d solid; } +.border-width-2 { + border-width: 2px; +} + .background-color-night { background-color: #34384f; } @@ -314,6 +330,11 @@ a:visited.background-color-hover-night-light:hover { margin-bottom: 8px; } +.margin-y-16 { + margin-top: 16px; + margin-bottom: 16px; +} + .margin-t-16 { margin-top: 16px; }