mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 17:45:31 +00:00
implement theme settings #17
This commit is contained in:
parent
0ab282e1c4
commit
5a940541ee
8 changed files with 55 additions and 3 deletions
3
.env
3
.env
|
|
@ -52,6 +52,9 @@ APP_NAME=YGGtracker
|
||||||
APP_LOCALE=en
|
APP_LOCALE=en
|
||||||
APP_LOCALES=en|cs|eo|fr|ka|de|he|it|lv|pl|pt|ru|es|uk
|
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_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
|
APP_PAGE_TITLE_LENGTH_MIN=10
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ twig:
|
||||||
globals:
|
globals:
|
||||||
version: '%app.version%'
|
version: '%app.version%'
|
||||||
name: '%app.name%'
|
name: '%app.name%'
|
||||||
|
theme: '%app.theme%'
|
||||||
|
|
||||||
when@test:
|
when@test:
|
||||||
twig:
|
twig:
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ parameters:
|
||||||
app.name: '%env(APP_NAME)%'
|
app.name: '%env(APP_NAME)%'
|
||||||
app.locale: '%env(APP_LOCALE)%'
|
app.locale: '%env(APP_LOCALE)%'
|
||||||
app.locales: '%env(APP_LOCALES)%'
|
app.locales: '%env(APP_LOCALES)%'
|
||||||
|
app.theme: '%env(APP_THEME)%'
|
||||||
|
app.themes: '%env(APP_THEMES)%'
|
||||||
app.trackers: '%env(APP_TRACKERS)%'
|
app.trackers: '%env(APP_TRACKERS)%'
|
||||||
app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%'
|
app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%'
|
||||||
app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%'
|
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
|
// Save changes to DB
|
||||||
$userService->save($user);
|
$userService->save($user);
|
||||||
|
|
||||||
|
|
@ -158,13 +166,15 @@ class UserController extends AbstractController
|
||||||
'status' => $user->isStatus(),
|
'status' => $user->isStatus(),
|
||||||
'locale' => $user->getLocale(),
|
'locale' => $user->getLocale(),
|
||||||
'locales' => $user->getLocales(),
|
'locales' => $user->getLocales(),
|
||||||
|
'theme' => $user->getTheme(),
|
||||||
'added' => $user->getAdded(),
|
'added' => $user->getAdded(),
|
||||||
'identicon' => $userService->identicon(
|
'identicon' => $userService->identicon(
|
||||||
$user->getAddress(),
|
$user->getAddress(),
|
||||||
48
|
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)]
|
#[ORM\Column(type: Types::ARRAY)]
|
||||||
private array $locales = [];
|
private array $locales = [];
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $theme = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
@ -130,4 +133,16 @@ class User
|
||||||
|
|
||||||
return $this;
|
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(
|
$user->setLocales(
|
||||||
explode('|', $this->parameterBagInterface->get('app.locales'))
|
explode('|', $this->parameterBagInterface->get('app.locales'))
|
||||||
);
|
);
|
||||||
|
$user->setTheme(
|
||||||
|
$this->parameterBagInterface->get('app.theme')
|
||||||
|
);
|
||||||
|
|
||||||
$this->save($user);
|
$this->save($user);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>{% block title %}{{ name }}{% endblock %}</title>
|
<title>{% block title %}{{ name }}{% endblock %}</title>
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
<link href="{{ asset('asset/default/css/framework.css') }}?{{ version }}" rel="stylesheet" />
|
<link href="{{ asset('asset/' ~ theme ~ '/css/framework.css') }}?{{ version }}" rel="stylesheet" />
|
||||||
<link href="{{ asset('asset/default/css/common.css') }}?{{ version }}" rel="stylesheet" />
|
<link href="{{ asset('asset/' ~ theme ~ '/css/common.css') }}?{{ version }}" rel="stylesheet" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,24 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue