forked from GNUsocial/gnu-social
[UI][ROUTES][CONTROLLER] Settings pages routes and styling done.
This commit is contained in:
parent
f100d33d94
commit
0211771d5f
41
src/Controller/FaqHome.php
Normal file
41
src/Controller/FaqHome.php
Normal 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', []);
|
||||
}
|
||||
}
|
@ -23,16 +23,18 @@
|
||||
* @package GNUsocial
|
||||
* @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
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
// use App\Core\GSEvent as Event;
|
||||
// use App\Core\Event;
|
||||
// use App\Util\Common;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\DB\DefaultSettings;
|
||||
use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@ -44,32 +46,52 @@ class UserAdminPanel extends AbstractController
|
||||
{
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$options = [];
|
||||
foreach (DefaultSettings::$defaults as $key => $inner) {
|
||||
$defaults = DefaultSettings::$defaults;
|
||||
$options = [];
|
||||
foreach ($defaults as $key => $inner) {
|
||||
$options[$key] = [];
|
||||
foreach (array_keys($inner) as $inner_key) {
|
||||
$options[_m($key)][_m($inner_key)] = "{$key}:{$inner_key}";
|
||||
}
|
||||
}
|
||||
|
||||
$form = $this->createFormBuilder(null, ['translation_domain' => false])
|
||||
->add(_m('Setting'), ChoiceType::class, ['choices' => $options])
|
||||
->add(_m('Value'), TextType::class)
|
||||
->add('save', SubmitType::class, ['label' => _m('Set site setting')])
|
||||
->getForm();
|
||||
$form = Form::create([[_m('Setting'), ChoiceType::class, ['choices' => $options]],
|
||||
[_m('Value'), TextType::class],
|
||||
['save', SubmitType::class, ['label' => _m('Set site setting')]], ]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($form->isSubmitted()) {
|
||||
$data = $form->getData();
|
||||
|
||||
var_dump($data);
|
||||
|
||||
// Stay in this page
|
||||
return $this->redirect($request->getUri());
|
||||
if ($form->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', [
|
||||
'form' => $form->createView(),
|
||||
'old_value' => unserialize($old_value),
|
||||
'default' => $default,
|
||||
]);
|
||||
} else {
|
||||
// Display error
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('settings/profile.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
42
src/Routes/Faq.php
Normal file
42
src/Routes/Faq.php
Normal 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);
|
||||
}
|
||||
}
|
@ -46,6 +46,12 @@ abstract class Main
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
templates/faq/home.html.twig
Normal file
1
templates/faq/home.html.twig
Normal file
@ -0,0 +1 @@
|
||||
{% extends "base.html.twig" %}
|
43
templates/settings/account/bak.html.twig
Normal file
43
templates/settings/account/bak.html.twig
Normal 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 %}
|
43
templates/settings/account/email.html.twig
Normal file
43
templates/settings/account/email.html.twig
Normal 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 %}
|
43
templates/settings/account/pass.html.twig
Normal file
43
templates/settings/account/pass.html.twig
Normal 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 %}
|
40
templates/settings/avatar.html.twig
Normal file
40
templates/settings/avatar.html.twig
Normal 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 %}
|
@ -10,10 +10,10 @@
|
||||
<nav class='set-nav'>
|
||||
<ul>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('doc_contact') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_contact' %}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>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user