♻️ Use an array for the user socials
This commit is contained in:
parent
770a65e15c
commit
54170e1e30
3 changed files with 25 additions and 98 deletions
|
@ -249,104 +249,18 @@ echo Bootstrap::formInputHidden(array(
|
||||||
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="nav-social-tab">
|
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="nav-social-tab">
|
||||||
<?php
|
<?php
|
||||||
echo Bootstrap::cardBegin($L->g('Social Networks'));
|
echo Bootstrap::cardBegin($L->g('Social Networks'));
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'twitter',
|
|
||||||
'label' => 'Twitter',
|
|
||||||
'value' => $user->twitter(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $value) {
|
||||||
'name' => 'facebook',
|
echo Bootstrap::formInputText(array(
|
||||||
'label' => 'Facebook',
|
'name' => Text::cleanUrl($value),
|
||||||
'value' => $user->facebook(),
|
'label' => $value,
|
||||||
'class' => '',
|
'value' => $user->getSocialNetwork($value),
|
||||||
'placeholder' => '',
|
'class' => '',
|
||||||
'tip' => ''
|
'placeholder' => '',
|
||||||
));
|
'tip' => ''
|
||||||
|
));
|
||||||
echo Bootstrap::formInputText(array(
|
}
|
||||||
'name' => 'codepen',
|
|
||||||
'label' => 'CodePen',
|
|
||||||
'value' => $user->codepen(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'instagram',
|
|
||||||
'label' => 'Instagram',
|
|
||||||
'value' => $user->instagram(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'gitlab',
|
|
||||||
'label' => 'GitLab',
|
|
||||||
'value' => $user->gitlab(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'github',
|
|
||||||
'label' => 'GitHub',
|
|
||||||
'value' => $user->github(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'linkedin',
|
|
||||||
'label' => 'LinkedIn',
|
|
||||||
'value' => $user->linkedin(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'xing',
|
|
||||||
'label' => 'Xing',
|
|
||||||
'value' => $user->xing(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'telegram',
|
|
||||||
'label' => 'Telegram',
|
|
||||||
'value' => $user->telegram(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'mastodon',
|
|
||||||
'label' => 'Mastodon',
|
|
||||||
'value' => $user->mastodon(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name' => 'vk',
|
|
||||||
'label' => 'VK',
|
|
||||||
'value' => $user->vk(),
|
|
||||||
'class' => '',
|
|
||||||
'placeholder' => '',
|
|
||||||
'tip' => ''
|
|
||||||
));
|
|
||||||
echo Bootstrap::cardEnd();
|
echo Bootstrap::cardEnd();
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -205,6 +205,10 @@ class User
|
||||||
return $this->getValue('vk');
|
return $this->getValue('vk');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSocialNetwork($social) {
|
||||||
|
return $this->getValue('socials')[Text::cleanUrl($social)];
|
||||||
|
}
|
||||||
|
|
||||||
public function profilePicture()
|
public function profilePicture()
|
||||||
{
|
{
|
||||||
$filename = $this->getValue('username') . '.png';
|
$filename = $this->getValue('username') . '.png';
|
||||||
|
|
|
@ -26,7 +26,8 @@ class Users extends dbJSON {
|
||||||
'gitlab'=>'',
|
'gitlab'=>'',
|
||||||
'linkedin'=>'',
|
'linkedin'=>'',
|
||||||
'mastodon'=>'',
|
'mastodon'=>'',
|
||||||
'vk'=>''
|
'vk'=>'',
|
||||||
|
'socials' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
|
@ -128,6 +129,14 @@ class Users extends dbJSON {
|
||||||
$row['tokenAuth'] = $this->generateAuthToken();
|
$row['tokenAuth'] = $this->generateAuthToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$row['socials'] = array();
|
||||||
|
foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $social) {
|
||||||
|
$socialKey = Text::cleanUrl($social);
|
||||||
|
if (isset($args[$socialKey])) {
|
||||||
|
$row['socials'][$socialKey] = $args[$socialKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save the database
|
// Save the database
|
||||||
$this->db[$username] = $row;
|
$this->db[$username] = $row;
|
||||||
return $this->save();
|
return $this->save();
|
||||||
|
|
Loading…
Add table
Reference in a new issue