mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 04:34:17 +00:00
implement theme settings #17
This commit is contained in:
parent
0ab282e1c4
commit
5a940541ee
3
.env
3
.env
@ -52,6 +52,9 @@ APP_NAME=YGGtracker
|
||||
APP_LOCALE=en
|
||||
APP_LOCALES=en|cs|eo|fr|ka|de|he|it|lv|pl|pt|ru|es|uk
|
||||
|
||||
APP_THEME=default
|
||||
APP_THEMES=default
|
||||
|
||||
APP_TRACKERS=http://[201:23b4:991a:634d:8359:4521:5576:15b7]:2023/announce|http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce|http://[316:c51a:62a3:8b9::5]/announce
|
||||
|
||||
APP_PAGE_TITLE_LENGTH_MIN=10
|
||||
|
@ -3,6 +3,7 @@ twig:
|
||||
globals:
|
||||
version: '%app.version%'
|
||||
name: '%app.name%'
|
||||
theme: '%app.theme%'
|
||||
|
||||
when@test:
|
||||
twig:
|
||||
|
@ -8,6 +8,8 @@ parameters:
|
||||
app.name: '%env(APP_NAME)%'
|
||||
app.locale: '%env(APP_LOCALE)%'
|
||||
app.locales: '%env(APP_LOCALES)%'
|
||||
app.theme: '%env(APP_THEME)%'
|
||||
app.themes: '%env(APP_THEMES)%'
|
||||
app.trackers: '%env(APP_TRACKERS)%'
|
||||
app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%'
|
||||
app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%'
|
||||
|
@ -134,6 +134,14 @@ class UserController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Update theme
|
||||
if (in_array($request->get('theme'), explode('|', $this->getParameter('app.themes'))))
|
||||
{
|
||||
$user->setTheme(
|
||||
$request->get('theme')
|
||||
);
|
||||
}
|
||||
|
||||
// Save changes to DB
|
||||
$userService->save($user);
|
||||
|
||||
@ -158,13 +166,15 @@ class UserController extends AbstractController
|
||||
'status' => $user->isStatus(),
|
||||
'locale' => $user->getLocale(),
|
||||
'locales' => $user->getLocales(),
|
||||
'theme' => $user->getTheme(),
|
||||
'added' => $user->getAdded(),
|
||||
'identicon' => $userService->identicon(
|
||||
$user->getAddress(),
|
||||
48
|
||||
),
|
||||
],
|
||||
'locales' => explode('|', $this->getParameter('app.locales'))
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'themes' => explode('|', $this->getParameter('app.themes'))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ class User
|
||||
#[ORM\Column(type: Types::ARRAY)]
|
||||
private array $locales = [];
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $theme = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -130,4 +133,16 @@ class User
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTheme(): ?string
|
||||
{
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
public function setTheme(string $theme): static
|
||||
{
|
||||
$this->theme = $theme;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class UserService
|
||||
$user->setLocales(
|
||||
explode('|', $this->parameterBagInterface->get('app.locales'))
|
||||
);
|
||||
$user->setTheme(
|
||||
$this->parameterBagInterface->get('app.theme')
|
||||
);
|
||||
|
||||
$this->save($user);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8" />
|
||||
<title>{% block title %}{{ name }}{% endblock %}</title>
|
||||
{% block stylesheets %}
|
||||
<link href="{{ asset('asset/default/css/framework.css') }}?{{ version }}" rel="stylesheet" />
|
||||
<link href="{{ asset('asset/default/css/common.css') }}?{{ version }}" rel="stylesheet" />
|
||||
<link href="{{ asset('asset/' ~ theme ~ '/css/framework.css') }}?{{ version }}" rel="stylesheet" />
|
||||
<link href="{{ asset('asset/' ~ theme ~ '/css/common.css') }}?{{ version }}" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
|
@ -101,6 +101,24 @@
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding-t-16-px">{{ 'Theme'|trans }}</td>
|
||||
<td class="padding-t-16-px">
|
||||
<select name="theme">
|
||||
{% for theme in themes %}
|
||||
{% if theme == user.theme %}
|
||||
<option value="{{ theme }}" selected="selected">
|
||||
{{ theme }}
|
||||
</option>
|
||||
{% else %}
|
||||
<option value="{{ theme }}">
|
||||
{{ theme }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-right">
|
||||
|
Loading…
x
Reference in New Issue
Block a user