Compare commits

...

2 commits

Author SHA1 Message Date
Kazhnuz
62a64e21ca (user): add support for display name 2025-01-10 00:17:32 +01:00
Kazhnuz
63d0e7a14a 💄 (edit-users): add subtitles 2025-01-09 23:46:32 +01:00
6 changed files with 60 additions and 3 deletions

View file

@ -37,7 +37,10 @@ echo Bootstrap::formInputHidden(array(
<div class="tab-content" id="nav-tabContent">
<!-- Profile tab -->
<div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<?php
echo Bootstrap::formTitle(array('title' => $L->g('Base Infos')));
// Display username but disable the field
echo Bootstrap::formInputText(array(
'name' => 'usernameDisabled',
@ -69,6 +72,8 @@ echo Bootstrap::formInputHidden(array(
'tip' => ''
));
echo Bootstrap::formTitle(array('title' => $L->g('Name')));
echo Bootstrap::formInputText(array(
'name' => 'nickname',
'label' => $L->g('Nickname'),
@ -96,6 +101,17 @@ echo Bootstrap::formInputHidden(array(
'tip' => ''
));
echo Bootstrap::formSelect(array(
'name' => 'displayNameMode',
'label' => $L->g('Display Name'),
'options' => array('nickname' => $L->g('Nickname'), 'fullname' => $L->g('Full Name'), 'firstname' => $L->g('First Name')),
'selected' => $user->displayNameMode(),
'class' => '',
'tip' => $L->g('if-not-present-fallback-on-username')
));
echo Bootstrap::formTitle(array('title' => $L->g('More Infos')));
echo Bootstrap::formInputText(array(
'name' => 'pronouns',
'label' => $L->g(string: 'Pronouns'),

View file

@ -50,6 +50,36 @@ class User
return $this->getValue('username');
}
public function displayName()
{
$mode = $this->getValue('displayNameMode');
$name = $this->firstName();
$lastName = $this->lastName();
$nickname = $this->nickname();
$username = $this->username();
switch ($mode) {
case 'fullname':
if ($name && $lastName) {
return $name." ".$lastName;
} elseif ($name) {
return $name;
} else {
return $username;
}
case 'firstname':
return $name ?? $username;
case '':
case 'nickname':
default:
return $nickname ?? $username;
}
}
public function displayNameMode()
{
return $this->getValue('displayNameMode');
}
public function pronouns()
{
return $this->getValue('pronouns');

View file

@ -6,6 +6,7 @@ class Users extends dbJSON {
'firstName'=>'',
'lastName'=>'',
'nickname'=>'',
'displayNameMode'=>'nickname',
'pronouns'=>'',
'description'=>'',
'homepage'=>'',

View file

@ -130,10 +130,13 @@
"add-a-new-category": "Add a new category",
"name": "Name",
"username": "Username",
"display-name": "Display Name",
"first-name": "First name",
"last-name": "Last name",
"full-name": "Full name",
"pronouns": "Pronouns",
"to-schedule-the-content-select-the-date-and-time": "To schedule the content select the date and time, the status has to be set to \"Published\".",
"if-not-present-fallback-on-username":"If the value isn't present, it'll fallback on the username",
"email": "Email",
"role": "Role",
"registered": "Registered",
@ -397,5 +400,7 @@
"start-typing-to-see-a-list-of-suggestions": "Start typing to see a list of suggestions.",
"view": "View",
"insert-thumbnail": "Insert thumbnail",
"insert-linked-thumbnail": "Insert linked thumbnail"
"insert-linked-thumbnail": "Insert linked thumbnail",
"more-infos": "More infos",
"base-infos": "Base infos"
}

View file

@ -130,10 +130,13 @@
"add-a-new-category": "Ajouter une nouvelle catégorie",
"name": "Nom",
"username": "Nom dutilisateur",
"display-name": "Nom affiché",
"first-name": "Prénom",
"last-name": "Nom",
"full-name": "Prénom et Nom",
"pronouns": "Pronoms",
"to-schedule-the-content-select-the-date-and-time": "Pour planifier votre contenu, sélectionnez la date et lheure, le statut doit être défini sur \"Publié\".",
"if-not-present-fallback-on-username":"Si la valeur n'est pas présente, alors cela affichera le nom d'utilisateur",
"email": "E-mail",
"role": "Rôle",
"registered": "Inscrit",
@ -397,5 +400,7 @@
"start-typing-to-see-a-list-of-suggestions": "Commencez à taper pour voir une liste de suggestions.",
"view": "Vue",
"insert-thumbnail": "Insérer une miniature",
"insert-linked-thumbnail": "Insérer une miniature liée"
"insert-linked-thumbnail": "Insérer une miniature liée",
"more-infos": "Infos supplémentaires",
"base-infos": "Infos de bases"
}

View file

@ -14,7 +14,7 @@
<span class="pr-3"><i class="bi bi-clock"></i><?php echo $page->readingTime() . ' ' . $L->get('minutes') . ' ' . $L->g('read') ?></span>
<!-- Page author -->
<span><i class="bi bi-person"></i><?php echo $page->user('nickname') ?></span>
<span><i class="bi bi-person"></i><?php echo $page->user('displayName') ?></span>
</div>
<?php endif ?>