add change pwd|lang|theme; twig-ify standard_error()

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-02-17 22:03:09 +01:00
parent 9dce16e5c7
commit 28526b4544
7 changed files with 157 additions and 16 deletions

View File

@@ -182,7 +182,6 @@ if ($page == 'overview') {
'uptime' => $uptime
];
// @fixme add all the overview/dashboard data from above
UI::Twig()->addGlobal('userinfo', $userinfo);
UI::TwigBuffer('user/index.html.twig', [
'sysinfo' => $sysinfo,
@@ -239,7 +238,8 @@ if ($page == 'overview') {
));
}
} else {
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_password") . "\";");
UI::TwigBuffer('user/change_password.html.twig');
UI::TwigOutputBuffer();
}
} elseif ($page == 'change_language') {
@@ -279,11 +279,11 @@ if ($page == 'overview') {
$default_lang = $userinfo['def_language'];
}
foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $default_lang, true);
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_language") . "\";");
UI::TwigBuffer('user/change_language.html.twig', [
'languages' => $languages,
'default_lang' => $default_lang
]);
UI::TwigOutputBuffer();
}
} elseif ($page == 'change_theme') {
@@ -322,11 +322,12 @@ if ($page == 'overview') {
}
$themes_avail = \Froxlor\UI\Template::getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true);
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_theme") . "\";");
UI::TwigBuffer('user/change_theme.html.twig', [
'themes' => $themes_avail,
'default_theme' => $default_theme
]);
UI::TwigOutputBuffer();
}
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') {

View File

@@ -81,7 +81,7 @@ class Response
*/
public static function standard_error($errors = '', $replacer = '', $throw_exception = false)
{
global $userinfo, $s, $header, $footer, $lng, $theme;
global $lng;
$_SESSION['requestData'] = $_POST;
$replacer = htmlentities($replacer);
@@ -92,9 +92,9 @@ class Response
);
}
$link = '';
$link_ref = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
$link_ref = htmlentities($_SERVER['HTTP_REFERER']);
}
$error = '';
@@ -119,8 +119,15 @@ class Response
if ($throw_exception) {
throw new \Exception(strip_tags($error), 400);
}
eval("echo \"" . Template::getTemplate('misc/error', '1') . "\";");
exit();
\Froxlor\UI\Panel\UI::TwigBuffer('misc/alert.html.twig', [
'type' => 'danger',
'btntype' => 'light',
'heading' => $lng['error']['error'],
'alert_msg' => $error,
'redirect_link' => $link_ref
]);
\Froxlor\UI\Panel\UI::TwigOutputBuffer();
exit;
}
public static function dynamic_error($message)

View File

@@ -500,6 +500,10 @@ if ($page == '') {
$page = 'overview';
}
UI::Twig()->addGlobal('action', $action);
UI::Twig()->addGlobal('page', $page);
UI::Twig()->addGlobal('s', $s);
/**
* Initialize the mailingsystem
*/

View File

@@ -0,0 +1,25 @@
{% extends "Froxlor/userarea.html.twig" %}
{% set body_class = "min-vh-100 d-flex align-items-center" %}
{% block content %}
<div class="alert alert-{{ type }} fade show" role="alert">
<h4 class="alert-heading">
{{ heading }}
</h4>
<p>
{{ alert_msg|raw }}
</p>
{% if alert_info %}
<hr>
<p class="mb-0">
<pre>{{ alert_info|raw }}</pre>
</p>
{% endif %}
{% if redirect_link %}
<p class="mt-1">
<a href="{{ redirect_link }}" class="btn btn-{{ btntype }}">{% if type == 'danger' %}{{ lng('panel.back') }}{% else %}{{ lng('success.clickheretocontinue') }}{% endif %}</a>
</p>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,34 @@
{% extends "Froxlor/userarea.html.twig" %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<form action="{{ linker({'section':'index'}) }}" class="col-12 max-w-420 d-flex flex-column" method="post" enctype="application/x-www-form-urlencoded">
<div class="card shadow">
<div class="card-body">
<h5 class="card-title">{{ lng('menue.main.changelanguage') }}</h5>
<div>
<label for="def_language" class="col-form-label">{{ lng('login.language') }}</label>
<select class="form-select" name="def_language" id="def_language" required>
<option value="profile">{{ lng('login.profile_lng') }}</option>
{% for val,lang in languages %}
<option value="{{ val }}" {% if default_lang == val %} selected="selected" {% endif %}>{{ lang|raw }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="card-body d-grid gap-2">
<input type="hidden" name="s" value="{{ s }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="send"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changelanguage') }}</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,37 @@
{% extends "Froxlor/userarea.html.twig" %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<form action="{{ linker({'section':'index'}) }}" class="col-12 max-w-420 d-flex flex-column" method="post" enctype="application/x-www-form-urlencoded">
<div class="card shadow">
<div class="card-body">
<h5 class="card-title">{{ lng('menue.main.changepassword') }}</h5>
<div class="mb-3">
<label for="old_password" class="col-form-label">{{ lng('changepassword.old_password') }}</label>
<input class="form-control" type="password" name="old_password" id="old_password" value="" required/>
</div>
<div class="mb-3">
<label for="new_password" class="col-form-label">{{ lng('changepassword.new_password') }}</label>
<input class="form-control" type="password" name="new_password" id="new_password" value="" required/>
</div>
<div class="mb-3">
<label for="new_password_confirm" class="col-form-label">{{ lng('changepassword.new_password_confirm') }}</label>
<input class="form-control" type="password" name="new_password_confirm" id="new_password_confirm" value="" required/>
</div>
</div>
<div class="card-body d-grid gap-2">
<input type="hidden" name="s" value="{{ s }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="send"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changepassword') }}</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,33 @@
{% extends "Froxlor/userarea.html.twig" %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<form action="{{ linker({'section':'index'}) }}" class="col-12 max-w-420 d-flex flex-column" method="post" enctype="application/x-www-form-urlencoded">
<div class="card shadow">
<div class="card-body">
<h5 class="card-title">{{ lng('menue.main.changetheme') }}</h5>
<div>
<label for="theme" class="col-form-label">{{ lng('panel.theme') }}</label>
<select class="form-select" name="theme" id="theme" required>
{% for val,t in themes %}
<option value="{{ val }}" {% if default_theme == val %} selected="selected" {% endif %}>{{ t|raw }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="card-body d-grid gap-2">
<input type="hidden" name="s" value="{{ s }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="send"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changetheme') }}</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}