[UI][ROUTES][CONTROLLER] Settings pages routes and styling done.

This commit is contained in:
rainydaysavings 2020-06-26 23:44:53 +01:00 committed by Hugo Sales
parent f100d33d94
commit 0211771d5f
10 changed files with 304 additions and 26 deletions

View File

@ -0,0 +1,41 @@
<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* FAQ main page
*
* @package GNUsocial
* @category Controller
*
* @author Eliseu Amaro <eliseu@fc.up.pt>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class FaqHome extends AbstractController
{
public function __invoke()
{
return $this->render('faq/home.html.twig', []);
}
}

View File

@ -23,16 +23,18 @@
* @package GNUsocial * @package GNUsocial
* @category Controller * @category Controller
* *
* @author Eliseu Amaro <eliseu@fc.up.pt> * @author Hugo Sales <hugo@fc.up.pt>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
namespace App\Controller; namespace App\Controller;
// use App\Core\GSEvent as Event; // use App\Core\Event;
// use App\Util\Common; // use App\Util\Common;
use App\Core\DB\DB;
use App\Core\DB\DefaultSettings; use App\Core\DB\DefaultSettings;
use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@ -44,32 +46,52 @@ class UserAdminPanel extends AbstractController
{ {
public function __invoke(Request $request) public function __invoke(Request $request)
{ {
$defaults = DefaultSettings::$defaults;
$options = []; $options = [];
foreach (DefaultSettings::$defaults as $key => $inner) { foreach ($defaults as $key => $inner) {
$options[$key] = []; $options[$key] = [];
foreach (array_keys($inner) as $inner_key) { foreach (array_keys($inner) as $inner_key) {
$options[_m($key)][_m($inner_key)] = "{$key}:{$inner_key}"; $options[_m($key)][_m($inner_key)] = "{$key}:{$inner_key}";
} }
} }
$form = $this->createFormBuilder(null, ['translation_domain' => false]) $form = Form::create([[_m('Setting'), ChoiceType::class, ['choices' => $options]],
->add(_m('Setting'), ChoiceType::class, ['choices' => $options]) [_m('Value'), TextType::class],
->add(_m('Value'), TextType::class) ['save', SubmitType::class, ['label' => _m('Set site setting')]], ]);
->add('save', SubmitType::class, ['label' => _m('Set site setting')])
->getForm();
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted()) {
$data = $form->getData(); $data = $form->getData();
if ($form->isValid() && array_key_exists(_m('Setting'), $data)) {
var_dump($data); list($section, $setting) = explode(':', $data[_m('Setting')]);
$value = $data[_m('Value')];
// Stay in this page $default = $defaults[$section][$setting];
return $this->redirect($request->getUri()); 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', [
'form' => $form->createView(),
'old_value' => unserialize($old_value),
'default' => $default,
]);
} else {
// Display error
}
} }
return $this->render('settings/profile.html.twig', [ foreach (['profile', 'avatar'] as $s) {
return $this->render('settings/' . $s . '.html.twig', [
'form' => $form->createView(),
]);
}
foreach (['email', 'pass', 'bak'] as $s) {
return $this->render('settings/account' . $s . '.html.twig', [
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
} }
} }
}

42
src/Routes/Faq.php Normal file
View File

@ -0,0 +1,42 @@
<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* Define FAQ's main routes
*
* @package GNUsocial
* @category Router
*
* @author Eliseu Amaro <eliseu@fc.up.pt>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Routes;
use App\Controller\FaqHome;
use App\Core\RouteLoader;
abstract class Faq
{
public static function load(RouteLoader $r): void
{
$r->connect('doc_faq', '/doc/faq', FaqHome::class);
}
}

View File

@ -46,6 +46,12 @@ abstract class Main
$r->connect('doc_' . $s, 'doc/' . $s, TemplateController::class, [], ['defaults' => ['template' => 'faq/' . $s . '.html.twig']]); $r->connect('doc_' . $s, 'doc/' . $s, TemplateController::class, [], ['defaults' => ['template' => 'faq/' . $s . '.html.twig']]);
} }
$r->connect('settings_profile', '/settings/profile', C\UserAdminPanel::class); 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);
}
} }
} }

View File

@ -0,0 +1 @@
{% extends "base.html.twig" %}

View File

@ -0,0 +1,43 @@
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}" media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_mid.css') }}" media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
{% endblock %}
{% block nav %}
<nav class='set-nav'>
<ul>
<li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
</li>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_' %}active{% endif %}'>Account</a>
</li>
<li>
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
</li>
</ul>
</nav>
<nav class='set-nav2'>
<ul>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_email' %}active{% endif %}'>Email</a>
</li>
<li>
<a href="{{ path('account_pass') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_pass' %}active{% endif %}'>Password</a>
</li>
<li>
<a href="{{ path('account_bak') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_bak' %}active{% endif %}'>Backup and Restore</a>
</li>
</ul>
</nav>
{% endblock %}
{% block body %}
<div class="content">
{{ form(form) }}
</div>
{% endblock %}

View File

@ -0,0 +1,43 @@
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}" media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_mid.css') }}" media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
{% endblock %}
{% block nav %}
<nav class='set-nav'>
<ul>
<li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
</li>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_' %}active{% endif %}'>Account</a>
</li>
<li>
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
</li>
</ul>
</nav>
<nav class='set-nav2'>
<ul>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_email' %}active{% endif %}'>Email</a>
</li>
<li>
<a href="{{ path('account_pass') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_pass' %}active{% endif %}'>Password</a>
</li>
<li>
<a href="{{ path('account_bak') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_bak' %}active{% endif %}'>Backup and Restore</a>
</li>
</ul>
</nav>
{% endblock %}
{% block body %}
<div class="content">
{{ form(form) }}
</div>
{% endblock %}

View File

@ -0,0 +1,43 @@
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}" media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_mid.css') }}" media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
{% endblock %}
{% block nav %}
<nav class='set-nav'>
<ul>
<li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
</li>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_' %}active{% endif %}'>Account</a>
</li>
<li>
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
</li>
</ul>
</nav>
<nav class='set-nav2'>
<ul>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_email' %}active{% endif %}'>Email</a>
</li>
<li>
<a href="{{ path('account_pass') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_pass' %}active{% endif %}'>Password</a>
</li>
<li>
<a href="{{ path('account_bak') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_bak' %}active{% endif %}'>Backup and Restore</a>
</li>
</ul>
</nav>
{% endblock %}
{% block body %}
<div class="content">
{{ form(form) }}
</div>
{% endblock %}

View File

@ -0,0 +1,40 @@
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}" media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_mid.css') }}" media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
{% endblock %}
{% block nav %}
<nav class='set-nav'>
<ul>
<li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
</li>
<li>
<a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_' %}active{% endif %}'>Account</a>
</li>
<li>
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
</li>
</ul>
</nav>
<nav class='set-nav2'>
<ul>
<li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_profile' %}active{% endif %}'>Profile</a>
</li>
<li>
<a href="{{ path('settings_avatar') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_avatar' %}active{% endif %}'>Avatar</a>
</li>
</ul>
</nav>
{% endblock %}
{% block body %}
<div class="content">
{{ form(form) }}
</div>
{% endblock %}

View File

@ -10,10 +10,10 @@
<nav class='set-nav'> <nav class='set-nav'>
<ul> <ul>
<li> <li>
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_profile' %}active{% endif %}'>Settings</a> <a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
</li> </li>
<li> <li>
<a href="{{ path('doc_contact') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_contact' %}active{% endif %}'>Account</a> <a href="{{ path('account_email') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_' %}active{% endif %}'>Account</a>
</li> </li>
<li> <li>
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a> <a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
@ -27,10 +27,7 @@
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_profile' %}active{% endif %}'>Profile</a> <a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_profile' %}active{% endif %}'>Profile</a>
</li> </li>
<li> <li>
<a href="{{ path('doc_contact') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_contact' %}active{% endif %}'>Avatar</a> <a href="{{ path('settings_avatar') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_avatar' %}active{% endif %}'>Avatar</a>
</li>
<li>
<a href="{{ path('doc_contact') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_contact' %}active{% endif %}'>Cover</a>
</li> </li>
</ul> </ul>
</nav> </nav>