✨ (user): add support for display name
This commit is contained in:
parent
63d0e7a14a
commit
62a64e21ca
6 changed files with 47 additions and 1 deletions
|
@ -101,6 +101,15 @@ echo Bootstrap::formInputHidden(array(
|
||||||
'tip' => ''
|
'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::formTitle(array('title' => $L->g('More Infos')));
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
echo Bootstrap::formInputText(array(
|
||||||
|
|
|
@ -50,6 +50,36 @@ class User
|
||||||
return $this->getValue('username');
|
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()
|
public function pronouns()
|
||||||
{
|
{
|
||||||
return $this->getValue('pronouns');
|
return $this->getValue('pronouns');
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Users extends dbJSON {
|
||||||
'firstName'=>'',
|
'firstName'=>'',
|
||||||
'lastName'=>'',
|
'lastName'=>'',
|
||||||
'nickname'=>'',
|
'nickname'=>'',
|
||||||
|
'displayNameMode'=>'nickname',
|
||||||
'pronouns'=>'',
|
'pronouns'=>'',
|
||||||
'description'=>'',
|
'description'=>'',
|
||||||
'homepage'=>'',
|
'homepage'=>'',
|
||||||
|
|
|
@ -130,10 +130,13 @@
|
||||||
"add-a-new-category": "Add a new category",
|
"add-a-new-category": "Add a new category",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
|
"display-name": "Display Name",
|
||||||
"first-name": "First name",
|
"first-name": "First name",
|
||||||
"last-name": "Last name",
|
"last-name": "Last name",
|
||||||
|
"full-name": "Full name",
|
||||||
"pronouns": "Pronouns",
|
"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\".",
|
"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",
|
"email": "Email",
|
||||||
"role": "Role",
|
"role": "Role",
|
||||||
"registered": "Registered",
|
"registered": "Registered",
|
||||||
|
|
|
@ -130,10 +130,13 @@
|
||||||
"add-a-new-category": "Ajouter une nouvelle catégorie",
|
"add-a-new-category": "Ajouter une nouvelle catégorie",
|
||||||
"name": "Nom",
|
"name": "Nom",
|
||||||
"username": "Nom d’utilisateur",
|
"username": "Nom d’utilisateur",
|
||||||
|
"display-name": "Nom affiché",
|
||||||
"first-name": "Prénom",
|
"first-name": "Prénom",
|
||||||
"last-name": "Nom",
|
"last-name": "Nom",
|
||||||
|
"full-name": "Prénom et Nom",
|
||||||
"pronouns": "Pronoms",
|
"pronouns": "Pronoms",
|
||||||
"to-schedule-the-content-select-the-date-and-time": "Pour planifier votre contenu, sélectionnez la date et l’heure, le statut doit être défini sur \"Publié\".",
|
"to-schedule-the-content-select-the-date-and-time": "Pour planifier votre contenu, sélectionnez la date et l’heure, 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",
|
"email": "E-mail",
|
||||||
"role": "Rôle",
|
"role": "Rôle",
|
||||||
"registered": "Inscrit",
|
"registered": "Inscrit",
|
||||||
|
|
|
@ -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>
|
<span class="pr-3"><i class="bi bi-clock"></i><?php echo $page->readingTime() . ' ' . $L->get('minutes') . ' ' . $L->g('read') ?></span>
|
||||||
|
|
||||||
<!-- Page author -->
|
<!-- 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>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue