diff --git a/public/assets/css/settings/settings.css b/public/assets/css/settings/settings.css index 19bc1949b0..8fbcb46457 100644 --- a/public/assets/css/settings/settings.css +++ b/public/assets/css/settings/settings.css @@ -10,7 +10,7 @@ margin-right: 20%; background-color: #00000080; padding: 1em 1em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } @@ -49,7 +49,7 @@ /*-------------------------------------*/ .set-nav2 { display: flex; - justify-content: space-between; + position: relative; flex-wrap: wrap; order: 2; width: 100%; @@ -60,7 +60,7 @@ border-top-left-radius: 1em; border-top-right-radius: 1em; padding: 0.8em 0.8em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } @@ -90,6 +90,16 @@ } +hr { + position: absolute; + margin-bottom: 0; + bottom: 0; + left: 0; + width: 80%; + margin-left: 10%; + color: #91b9d088; +} + /* CONTENT ----------------------------*/ .content { display: flex; @@ -103,7 +113,7 @@ padding: 1em 1em 1em 1em; border-bottom-left-radius: 1em; border-bottom-right-radius: 1em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } diff --git a/public/assets/css/settings/settings_mid.css b/public/assets/css/settings/settings_mid.css index ee64638d70..f7ec8f3c25 100644 --- a/public/assets/css/settings/settings_mid.css +++ b/public/assets/css/settings/settings_mid.css @@ -10,7 +10,7 @@ margin-right: 5%; background-color: #00000080; padding: 1em 1em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } @@ -49,7 +49,7 @@ /*-------------------------------------*/ .set-nav2 { display: flex; - justify-content: space-between; + position: relative; flex-wrap: wrap; order: 2; width: 100%; @@ -60,7 +60,7 @@ border-top-left-radius: 1em; border-top-right-radius: 1em; padding: 0.8em 0.8em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } @@ -90,6 +90,16 @@ } +hr { + position: absolute; + margin-bottom: 0; + bottom: 0; + left: 0; + width: 80%; + margin-left: 10%; + color: #91b9d088; +} + /* CONTENT ----------------------------*/ .content { display: flex; @@ -103,7 +113,7 @@ padding: 1em 1em 1em 1em; border-bottom-left-radius: 1em; border-bottom-right-radius: 1em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } diff --git a/public/assets/css/settings/settings_small.css b/public/assets/css/settings/settings_small.css index c375861087..d2f05c4961 100644 --- a/public/assets/css/settings/settings_small.css +++ b/public/assets/css/settings/settings_small.css @@ -48,8 +48,8 @@ /*-------------------------------------*/ /*-------------------------------------*/ .set-nav2 { + position: relative; display: flex; - justify-content: space-between; flex-wrap: wrap; order: 2; width: 100%; @@ -60,7 +60,7 @@ border-top-left-radius: 1em; border-top-right-radius: 1em; padding: 0.8em 0.8em; - font-size: 0.8em; + font-size: 0.7em; box-shadow: 0px 0px 60px -20px rgba(41, 50, 60, 1); } @@ -69,8 +69,6 @@ align-items: stretch; justify-content: space-evenly; width: 100%; - margin-left: 10%; - margin-right: 10%; padding: 0; } @@ -90,6 +88,16 @@ } +hr { + position: absolute; + margin-bottom: 0; + bottom: 0; + left: 0; + width: 80%; + margin-left: 10%; + color: #91b9d088; +} + /* CONTENT ----------------------------*/ .content { display: flex; diff --git a/src/Controller/UserAdminPanel.php b/src/Controller/UserAdminPanel.php index c67560cf22..fa1ed892b1 100644 --- a/src/Controller/UserAdminPanel.php +++ b/src/Controller/UserAdminPanel.php @@ -43,7 +43,7 @@ class UserAdminPanel extends AbstractController { public function __invoke(Request $request) { - $form = Form::create([ + $prof = Form::create([ [_m('Nickname'), TextType::class], [_m('FullName'), TextType::class], [_m('Homepage'), TextType::class], @@ -51,16 +51,31 @@ class UserAdminPanel extends AbstractController [_m('Location'), TextType::class], ['save', SubmitType::class, ['label' => _m('Save')]], ]); - foreach (['profile', 'avatar'] as $s) { - return $this->render('settings/' . $s . '.html.twig', [ - 'form' => $form->createView(), - ]); + $prof->handleRequest($request); + if ($prof->isSubmitted()) { + $data = $prof->getData(); + if ($prof->isValid() && array_key_exists(_m('Setting'), $data)) { + list($section, $setting) = explode(':', $data[_m('Setting')]); + $value = $data[_m('Value')]; + $default = $defaults[$section][$setting]; + if (gettype($default) === gettype($value)) { + $conf = DB::find('\App\Entity\Config', ['section' => $section, 'setting' => $setting]); + $old_value = $conf->getValue(); + $conf->setValue(serialize($value)); + DB::flush(); + } + return $this->render('config/admin.html.twig', [ + 'prof' => $prof->createView(), + 'old_value' => unserialize($old_value), + 'default' => $default, + ]); + } else { + // Display error + } } - foreach (['email', 'pass', 'bak'] as $s) { - return $this->render('settings/account' . $s . '.html.twig', [ - 'form' => $form->createView(), - ]); - } + return $this->render('settings/profile.html.twig', [ + 'prof' => $prof->createView(), + ]); } } diff --git a/src/Routes/Main.php b/src/Routes/Main.php index 21da7a7195..15d32d3e8d 100644 --- a/src/Routes/Main.php +++ b/src/Routes/Main.php @@ -46,12 +46,11 @@ abstract class Main $r->connect('doc_' . $s, 'doc/' . $s, TemplateController::class, [], ['defaults' => ['template' => 'faq/' . $s . '.html.twig']]); } + // Settings pages foreach (['profile', 'avatar'] as $s) { $r->connect('settings_' . $s, 'settings/' . $s, C\UserAdminPanel::class); } - foreach (['email', 'pass', 'bak'] as $s) { - $r->connect('account_' . $s, 'settings/account/' . $s, C\UserAdminPanel::class); - } + $r->connect('account_settings', 'settings/account', C\UserAdminPanel::class); } } diff --git a/templates/settings/account/bak.html.twig b/templates/settings/account.html.twig similarity index 55% rename from templates/settings/account/bak.html.twig rename to templates/settings/account.html.twig index f101e088f1..6544969928 100644 --- a/templates/settings/account/bak.html.twig +++ b/templates/settings/account.html.twig @@ -13,27 +13,13 @@ Settings
  • - Account + Account
  • Misc
  • - - {% endblock %} {% block body %} diff --git a/templates/settings/account/email.html.twig b/templates/settings/account/email.html.twig deleted file mode 100644 index f101e088f1..0000000000 --- a/templates/settings/account/email.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{% extends 'base.html.twig' %} -{% block stylesheets %} - {{ parent() }} - - - -{% endblock %} - -{% block nav %} - - - -{% endblock %} - -{% block body %} -
    - {{ form(form) }} -
    -{% endblock %} \ No newline at end of file diff --git a/templates/settings/account/pass.html.twig b/templates/settings/account/pass.html.twig deleted file mode 100644 index f101e088f1..0000000000 --- a/templates/settings/account/pass.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{% extends 'base.html.twig' %} -{% block stylesheets %} - {{ parent() }} - - - -{% endblock %} - -{% block nav %} - - - -{% endblock %} - -{% block body %} -
    - {{ form(form) }} -
    -{% endblock %} \ No newline at end of file diff --git a/templates/settings/avatar.html.twig b/templates/settings/avatar.html.twig index dbab731679..8215b148e2 100644 --- a/templates/settings/avatar.html.twig +++ b/templates/settings/avatar.html.twig @@ -13,14 +13,13 @@ Settings
  • - Account + Account
  • Misc
  • - {% endblock %} {% block body %} -
    - {{ form(form) }} +
    +
    +
    {{ form_label(prof.Nickname) }}
    {{ form_widget(prof.Nickname) }} +
    +
    +
    {{ form_label(prof.FullName) }}
    {{ form_widget(prof.FullName) }} +
    +
    +
    {{ form_label(prof.Homepage) }}
    {{ form_widget(prof.Homepage) }} +
    +
    +
    {{ form_label(prof.Bio) }}
    {{ form_widget(prof.Bio) }} +
    +
    +
    {{ form_label(prof.Location) }}
    {{ form_widget(prof.Location) }} +
    +
    + {{ form_widget(prof.save) }} +
    {% endblock %} \ No newline at end of file diff --git a/templates/settings/profile.html.twig b/templates/settings/profile.html.twig index 1828823bce..8215b148e2 100644 --- a/templates/settings/profile.html.twig +++ b/templates/settings/profile.html.twig @@ -13,14 +13,13 @@ Settings
  • - Account + Account
  • Misc
  • - {% endblock %} {% block body %}
    -
    {{ form_label(form.Nickname) }}
    {{ form_widget(form.Nickname) }} +
    {{ form_label(prof.Nickname) }}
    {{ form_widget(prof.Nickname) }}
    -
    {{ form_label(form.FullName) }}
    {{ form_widget(form.FullName) }} +
    {{ form_label(prof.FullName) }}
    {{ form_widget(prof.FullName) }}
    -
    {{ form_label(form.Homepage) }}
    {{ form_widget(form.Homepage) }} +
    {{ form_label(prof.Homepage) }}
    {{ form_widget(prof.Homepage) }}
    -
    {{ form_label(form.Bio) }}
    {{ form_widget(form.Bio) }} +
    {{ form_label(prof.Bio) }}
    {{ form_widget(prof.Bio) }}
    -
    {{ form_label(form.Location) }}
    {{ form_widget(form.Location) }} +
    {{ form_label(prof.Location) }}
    {{ form_widget(prof.Location) }}
    - {{ form_widget(form.save) }} + {{ form_widget(prof.save) }}
    {% endblock %} \ No newline at end of file