diff --git a/.gitignore b/.gitignore index 3b3a8a90..3a15df53 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ php_error.log /vendor/* /panel/accounts/* -/panel/avatars/* +/panel/assets/images/users/* /panel/logs/* !.gitkeep diff --git a/formwork/defaults.php b/formwork/defaults.php index 46e74ab9..92ed4323 100644 --- a/formwork/defaults.php +++ b/formwork/defaults.php @@ -9,7 +9,7 @@ return [ 'loginResetTime' => 300, 'logoutRedirect' => 'login', 'sessionTimeout' => 20, - 'avatarSize' => 512, + 'userImageSize' => 512, 'colorScheme' => 'light', 'paths' => [ 'accounts' => PANEL_PATH . 'accounts' . DS, diff --git a/formwork/src/Panel/Controllers/UsersController.php b/formwork/src/Panel/Controllers/UsersController.php index 0539ccde..a4158a31 100644 --- a/formwork/src/Panel/Controllers/UsersController.php +++ b/formwork/src/Panel/Controllers/UsersController.php @@ -90,7 +90,7 @@ class UsersController extends AbstractController ); } FileSystem::delete(Formwork::instance()->config()->get('panel.paths.accounts') . $user->username() . '.yml'); - $this->deleteAvatar($user); + $this->deleteImage($user); } catch (TranslatedException $e) { $this->panel()->notify($e->getTranslatedMessage(), 'error'); return $this->redirectToReferer(302, '/users/'); @@ -185,8 +185,8 @@ class UsersController extends AbstractController } // Handle incoming files - if (HTTPRequest::hasFiles() && ($avatar = $this->uploadAvatar($user)) !== null) { - $data['avatar'] = $avatar; + if (HTTPRequest::hasFiles() && ($image = $this->uploadImage($user)) !== null) { + $data['image'] = $image; } // Filter empty items from $data and merge them with $user ones @@ -196,14 +196,14 @@ class UsersController extends AbstractController } /** - * Upload a new avatar for a user + * Upload a new image for a user */ - protected function uploadAvatar(User $user): ?string + protected function uploadImage(User $user): ?string { - $avatarsPath = PANEL_PATH . 'avatars' . DS; + $imagesPath = PANEL_PATH . 'assets' . DS . 'images' . DS . 'users' . DS; $uploader = new Uploader( - $avatarsPath, + $imagesPath, [ 'allowedMimeTypes' => ['image/gif', 'image/jpeg', 'image/png', 'image/webp'], ] @@ -212,28 +212,28 @@ class UsersController extends AbstractController $hasUploaded = $uploader->upload(FileSystem::randomName()); if ($hasUploaded) { - $avatarSize = Formwork::instance()->config()->get('panel.avatarSize'); + $userImageSize = Formwork::instance()->config()->get('panel.userImageSize'); - // Square off uploaded avatar - $image = new Image($avatarsPath . $uploader->uploadedFiles()[0]); - $image->square($avatarSize)->save(); + // Square off uploaded image + $image = new Image($imagesPath . $uploader->uploadedFiles()[0]); + $image->square($userImageSize)->save(); - // Delete old avatar - $this->deleteAvatar($user); + // Delete old image + $this->deleteImage($user); - $this->panel()->notify($this->translate('panel.user.avatar.uploaded'), 'success'); + $this->panel()->notify($this->translate('panel.user.image.uploaded'), 'success'); return $uploader->uploadedFiles()[0]; } } /** - * Delete the avatar of a given user + * Delete the image of a given user */ - protected function deleteAvatar(User $user): void + protected function deleteImage(User $user): void { - $avatar = $user->avatar()->path(); - if ($avatar !== null && FileSystem::exists($avatar)) { - FileSystem::delete($avatar); + $image = $user->image()->path(); + if ($image !== null && FileSystem::exists($image)) { + FileSystem::delete($image); } } } diff --git a/formwork/src/Panel/Updater.php b/formwork/src/Panel/Updater.php index 0ef603be..2e6d6a82 100644 --- a/formwork/src/Panel/Updater.php +++ b/formwork/src/Panel/Updater.php @@ -96,7 +96,7 @@ class Updater 'cleanupAfterInstall' => false, 'ignore' => [ 'panel/accounts/*', - 'panel/avatars/*', + 'panel/assets/images/users/*', 'panel/logs/*', 'assets/*', 'backup/*', diff --git a/formwork/src/Panel/Users/User.php b/formwork/src/Panel/Users/User.php index ed8b6b16..9c2866c0 100644 --- a/formwork/src/Panel/Users/User.php +++ b/formwork/src/Panel/Users/User.php @@ -25,7 +25,7 @@ class User implements Arrayable 'email' => null, 'language' => 'en', 'role' => 'user', - 'avatar' => null, + 'image' => null, 'colorScheme' => 'auto', ]; @@ -60,9 +60,9 @@ class User implements Arrayable protected string $role; /** - * User avatar + * User image */ - protected Avatar $avatar; + protected UserImage $image; /** * User permissions @@ -136,15 +136,15 @@ class User implements Arrayable } /** - * Return user avatar + * Return user image */ - public function avatar(): Avatar + public function image(): UserImage { - if (isset($this->avatar)) { - return $this->avatar; + if (isset($this->image)) { + return $this->image; } - return $this->avatar = new Avatar($this->data['avatar']); + return $this->image = new UserImage($this->data['image']); } /** diff --git a/formwork/src/Panel/Users/Avatar.php b/formwork/src/Panel/Users/UserImage.php similarity index 65% rename from formwork/src/Panel/Users/Avatar.php rename to formwork/src/Panel/Users/UserImage.php index bf8015dd..01127d82 100644 --- a/formwork/src/Panel/Users/Avatar.php +++ b/formwork/src/Panel/Users/UserImage.php @@ -5,39 +5,36 @@ namespace Formwork\Panel\Users; use Formwork\Formwork; use Formwork\Utils\FileSystem; -class Avatar +class UserImage { /** - * Default avatar URI + * Default image URI */ - protected const DEFAULT_AVATAR_URI = '/assets/images/avatar.svg'; + protected const DEFAULT_IMAGE_URI = '/assets/images/user-image.svg'; /** - * Avatar URI + * Image URI */ protected string $uri; /** - * Avatar file path + * Image file path */ protected ?string $path = null; - /** - * Create a new Avatar instance - */ public function __construct(?string $filename) { - $path = PANEL_PATH . 'avatars/' . $filename; + $path = PANEL_PATH . 'assets' . DS . 'images' . DS . 'users' . DS . $filename; if ($filename !== null && FileSystem::exists($path)) { - $this->uri = Formwork::instance()->panel()->realUri('/avatars/' . basename($path)); + $this->uri = Formwork::instance()->panel()->realUri('/assets/images/users/' . basename($path)); $this->path = $path; } else { - $this->uri = Formwork::instance()->panel()->realUri(self::DEFAULT_AVATAR_URI); + $this->uri = Formwork::instance()->panel()->realUri(self::DEFAULT_IMAGE_URI); } } /** - * Return avatar URI + * Return image URI */ public function uri(): string { @@ -45,7 +42,7 @@ class Avatar } /** - * Return avatar path + * Return image path */ public function path(): ?string { diff --git a/panel/assets/images/avatar.svg b/panel/assets/images/user-image.svg similarity index 100% rename from panel/assets/images/avatar.svg rename to panel/assets/images/user-image.svg diff --git a/panel/avatars/.gitkeep b/panel/assets/images/users/.gitkeep similarity index 100% rename from panel/avatars/.gitkeep rename to panel/assets/images/users/.gitkeep diff --git a/panel/schemes/users/user.yml b/panel/schemes/users/user.yml index 9b118601..bcb390df 100644 --- a/panel/schemes/users/user.yml +++ b/panel/schemes/users/user.yml @@ -5,7 +5,7 @@ layout: sections: user: label: '{{panel.users.user}}' - fields: [fullname, email, password, language, role, colorScheme, avatar] + fields: [fullname, email, password, language, role, colorScheme, image] fields: fullname: @@ -49,7 +49,7 @@ fields: dark: '{{panel.user.colorScheme.dark}}' auto: '{{panel.user.colorScheme.auto}}' - avatar: + image: type: file - label: '{{panel.user.avatar}}' + label: '{{panel.user.image}}' accept: .jpg, .jpeg, .png, .gif diff --git a/panel/translations/en.yml b/panel/translations/en.yml index 1970d17d..b04d66b0 100644 --- a/panel/translations/en.yml +++ b/panel/translations/en.yml @@ -229,8 +229,8 @@ panel.uploader.error.phpExtension: File upload stopped by extension panel.uploader.error.size: The uploaded file exceeds the maximum file size panel.uploader.uploaded: File uploaded panel.user.actions: Actions -panel.user.avatar: Avatar -panel.user.avatar.uploaded: Avatar uploaded +panel.user.image: Image +panel.user.image.uploaded: User image uploaded panel.user.colorScheme: Color Scheme panel.user.colorScheme.auto: Auto panel.user.colorScheme.dark: Dark diff --git a/panel/translations/fr.yml b/panel/translations/fr.yml index bbcd5553..361c08c5 100644 --- a/panel/translations/fr.yml +++ b/panel/translations/fr.yml @@ -214,8 +214,8 @@ panel.uploader.error.phpExtension: Téléversement du fichier arrêté par exten panel.uploader.error.size: Le fichier téléversé dépasse la taille de fichier maximale panel.uploader.uploaded: Fichier envoyé ! panel.user.actions: Actions -panel.user.avatar: Photo de profil -panel.user.avatar.uploaded: Photo de profil téléversée avec succès. +panel.user.image: Photo de profil +panel.user.image.uploaded: Photo de profil téléversée avec succès. panel.user.email: Adresse de messagerie panel.user.fullname: Nom complet panel.user.language: Langue diff --git a/panel/translations/it.yml b/panel/translations/it.yml index c254a569..9010211a 100644 --- a/panel/translations/it.yml +++ b/panel/translations/it.yml @@ -229,8 +229,8 @@ panel.uploader.error.phpExtension: Il caricamento è stato interrotto da un’es panel.uploader.error.size: Il file caricato supera la dimensione massima consentita panel.uploader.uploaded: File caricato panel.user.actions: Azioni -panel.user.avatar: Immagine -panel.user.avatar.uploaded: Immagine caricata +panel.user.image: Immagine +panel.user.image.uploaded: Immagine caricata panel.user.colorScheme: Combinazione di colori panel.user.colorScheme.auto: Automatica panel.user.colorScheme.dark: Scura diff --git a/panel/translations/pt.yml b/panel/translations/pt.yml index d2c3bc12..5ef84ecd 100644 --- a/panel/translations/pt.yml +++ b/panel/translations/pt.yml @@ -223,8 +223,8 @@ panel.uploader.error.phpExtension: Envio de ficheiro interrompido por extensão panel.uploader.error.size: O ficheiro enviado excede o tamanho máximo permitido. panel.uploader.uploaded: Ficheiro enviado panel.user.actions: Acções -panel.user.avatar: Avatar -panel.user.avatar.uploaded: Avatar enviado +panel.user.image: Imagem +panel.user.image.uploaded: Imagem do utilizador enviada panel.user.colorScheme: Esquema de cores panel.user.colorScheme.auto: Auto panel.user.colorScheme.dark: Escuro diff --git a/panel/translations/ru.yml b/panel/translations/ru.yml index b7f2fd02..d1c8fdeb 100644 --- a/panel/translations/ru.yml +++ b/panel/translations/ru.yml @@ -206,8 +206,8 @@ panel.uploader.error.phpExtension: Загрузка файла останавл panel.uploader.error.size: Загруженный файл превышает максимальный размер файла panel.uploader.uploaded: Файл загружен panel.user.actions: Действия -panel.user.avatar: Аватар -panel.user.avatar.uploaded: Аватар закачанный +panel.user.image: Аватар +panel.user.image.uploaded: Аватар закачанный panel.user.email: Email panel.user.fullname: Полное имя panel.user.language: Язык diff --git a/panel/views/partials/sidebar.php b/panel/views/partials/sidebar.php index 9d6013d7..55ffeb73 100644 --- a/panel/views/partials/sidebar.php +++ b/panel/views/partials/sidebar.php @@ -4,7 +4,7 @@
- +
escape($panel->user()->fullname()) ?>
diff --git a/panel/views/users/profile.php b/panel/views/users/profile.php index 8eb4a79d..5325c630 100644 --- a/panel/views/users/profile.php +++ b/panel/views/users/profile.php @@ -12,7 +12,7 @@
- +

escape($user->fullname()) ?>