diff --git a/lib/Froxlor/Database/Database.php b/lib/Froxlor/Database/Database.php
index b0cd15d4..85c09b0f 100644
--- a/lib/Froxlor/Database/Database.php
+++ b/lib/Froxlor/Database/Database.php
@@ -442,7 +442,7 @@ class Database
if (empty($sql['debug'])) {
$error_trace = '';
} elseif (!is_null($stmt)) {
- $error_trace .= "
" . $stmt->queryString;
+ $error_trace .= "\n\n" . $stmt->queryString;
}
if ($showerror && $json_response) {
diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php
index 9555ef79..fdc508c5 100644
--- a/lib/Froxlor/PhpHelper.php
+++ b/lib/Froxlor/PhpHelper.php
@@ -152,7 +152,7 @@ class PhpHelper
return false;
}
- public static function phpExceptionHandler(\Exception $exception)
+ public static function phpExceptionHandler(\Throwable $exception)
{
if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
$err_display = '
';
diff --git a/lib/Froxlor/UI/HTML.php b/lib/Froxlor/UI/HTML.php
index daffbc47..39eabc2f 100644
--- a/lib/Froxlor/UI/HTML.php
+++ b/lib/Froxlor/UI/HTML.php
@@ -1,4 +1,5 @@
0 || $userinfo[$box['required_resources']] == '-1')))) {
- $navigation_links = '';
+ if ((!isset($box['show_element']) || $box['show_element'] === true) && (!isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
+ $navigation_links = [];
foreach ($box['elements'] as $element_id => $element) {
- if ((! isset($element['show_element']) || $element['show_element'] === true) && (! isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
+ if ((!isset($element['show_element']) || $element['show_element'] === true) && (!isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
$target = '';
- $active = '';
+ $active = false;
$navurl = '#';
if (isset($element['url']) && trim($element['url']) != '') {
// append sid only to local
- if (! preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
+ if (!preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($element['url'], '?') !== false) {
@@ -55,9 +54,9 @@ class HTML
}
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
- $active = ' active';
- } elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && ! isset($_GET['action'])) {
- $active = ' active';
+ $active = true;
+ } elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && !isset($_GET['action'])) {
+ $active = true;
}
$navurl = htmlspecialchars($element['url']);
@@ -66,16 +65,21 @@ class HTML
$navlabel = $element['label'];
}
- eval("\$navigation_links .= \"" . \Froxlor\UI\Template::getTemplate("navigation_link", 1) . "\";");
+ $navigation_links[] = [
+ 'url' => $navurl,
+ 'target' => $target,
+ 'is_active' => $active,
+ 'label' => $navlabel
+ ];
}
}
- if ($navigation_links != '') {
+ if (!empty($navigation_links)) {
$target = '';
if (isset($box['url']) && trim($box['url']) != '') {
// append sid only to local
- if (! preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
+ if (!preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($box['url'], '?') !== false) {
@@ -96,7 +100,12 @@ class HTML
$navlabel = $box['label'];
}
- eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("navigation_element", 1) . "\";");
+ $returnvalue[] = [
+ 'url' => $navurl,
+ 'target' => $target,
+ 'label' => $navlabel,
+ 'items' => $navigation_links
+ ];
}
}
}
@@ -134,11 +143,11 @@ class HTML
$checked = '';
}
- if (! $title_trusted) {
+ if (!$title_trusted) {
$title = htmlspecialchars($title);
}
- if (! $value_trusted) {
+ if (!$value_trusted) {
$value = htmlspecialchars($value);
}
@@ -181,11 +190,11 @@ class HTML
$selected .= ' disabled="disabled"';
}
- if (! $title_trusted) {
+ if (!$title_trusted) {
$title = htmlspecialchars($title);
}
- if (! $value_trusted) {
+ if (!$value_trusted) {
$value = htmlspecialchars($value);
}
diff --git a/lib/Froxlor/UI/Panel/FroxlorTwig.php b/lib/Froxlor/UI/Panel/FroxlorTwig.php
index 4a4f47b1..266c8a66 100644
--- a/lib/Froxlor/UI/Panel/FroxlorTwig.php
+++ b/lib/Froxlor/UI/Panel/FroxlorTwig.php
@@ -44,6 +44,10 @@ class FroxlorTwig extends \Twig\Extension\AbstractExtension
new \Twig\TwigFunction('lng', [
$this,
'getLang'
+ ]),
+ new \Twig\TwigFunction('linker', [
+ $this,
+ 'getLink'
])
);
}
@@ -91,6 +95,11 @@ class FroxlorTwig extends \Twig\Extension\AbstractExtension
return \Froxlor\UI\Panel\UI::getLng($identifier);
}
+ public function getLink($linkopts)
+ {
+ return \Froxlor\UI\Panel\UI::getLinker()->getLink($linkopts);
+ }
+
/**
*
* {@inheritdoc}
diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php
index 37296458..b99f7aec 100644
--- a/lib/Froxlor/UI/Panel/UI.php
+++ b/lib/Froxlor/UI/Panel/UI.php
@@ -28,6 +28,11 @@ class UI
*/
private static $lng = array();
+ /**
+ * linker class object
+ */
+ private static $linker = null;
+
/**
* default fallback theme
*
@@ -207,6 +212,16 @@ class UI
self::$twigbuf = [];
}
+ public static function setLinker($linker = null)
+ {
+ self::$linker = $linker;
+ }
+
+ public static function getLinker()
+ {
+ return self::$linker;
+ }
+
public static function setLng($lng = array())
{
self::$lng = $lng;
diff --git a/lib/init.php b/lib/init.php
index 714bc207..6fa94cf5 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -176,7 +176,7 @@ if (isset($s) && $s != "" && $nosession != 1) {
ini_set("url_rewriter.tags", "");
ini_set("session.use_cookies", false);
ini_set("session.cookie_httponly", true);
- ini_set("session.cookie_secure", $is_ssl);
+ ini_set("session.cookie_secure", UI::$SSL_REQ);
session_id($s);
session_start();
$query = "SELECT `s`.*, `u`.* FROM `" . TABLE_PANEL_SESSIONS . "` `s` LEFT JOIN `";
@@ -305,8 +305,9 @@ include_once \Froxlor\FileDir::makeSecurePath('lng/lng_references.php');
UI::setLng($lng);
-// Initialize our new link - class
+// Initialize our link - class
$linker = new \Froxlor\UI\Linker('index.php', $s);
+UI::setLinker($linker);
/**
* global Theme-variable
@@ -360,6 +361,9 @@ if (Settings::Get('panel.logo_overridecustom') == 0 && file_exists($hl_path . '/
}
}
+UI::Twig()->addGlobal('header_logo_login', $header_logo_login);
+UI::Twig()->addGlobal('header_logo', $header_logo);
+
/**
* Redirects to index.php (login page) if no session exists
*/
@@ -373,10 +377,7 @@ if ($nosession == 1 && AREA != 'login') {
exit();
}
-/**
- * Initialize Template Engine
- */
-$templatecache = array();
+UI::Twig()->addGlobal('userinfo', ($userinfo ?? []));
/**
* Logic moved out of lng-file
@@ -390,7 +391,7 @@ if (isset($userinfo['loginname']) && $userinfo['loginname'] != '') {
/**
* Fills variables for navigation, header and footer
*/
-$navigation = "";
+$navigation = [];
if (AREA == 'admin' || AREA == 'customer') {
if (\Froxlor\Froxlor::hasUpdates() || \Froxlor\Froxlor::hasDbUpdates()) {
/*
@@ -431,8 +432,8 @@ if (AREA == 'admin' || AREA == 'customer') {
$navigation_data = \Froxlor\PhpHelper::loadConfigArrayDir('lib/navigation/');
$navigation = \Froxlor\UI\HTML::buildNavigation($navigation_data[AREA], $userinfo);
}
- unset($navigation_data);
}
+UI::Twig()->addGlobal('nav_entries', $navigation);
$js = "";
if (is_array($_themeoptions) && array_key_exists('js', $_themeoptions['variants'][$themevariant]) && is_array($_themeoptions['variants'][$themevariant]['js'])) {
diff --git a/templates/Froxlor/admin/index.html.twig b/templates/Froxlor/admin/index.html.twig
new file mode 100644
index 00000000..513d47a0
--- /dev/null
+++ b/templates/Froxlor/admin/index.html.twig
@@ -0,0 +1,5 @@
+{% extends "Froxlor/userarea.html.twig" %}
+
+{% block content %}
+test text
+{% endblock %}
\ No newline at end of file
diff --git a/templates/Froxlor/base.html.twig b/templates/Froxlor/base.html.twig
index c3007c72..395ed047 100644
--- a/templates/Froxlor/base.html.twig
+++ b/templates/Froxlor/base.html.twig
@@ -22,44 +22,10 @@
+
+ {% block navigation %}{% endblock %}
+
- {% block navigation %}{% endblock %}
-
{{ global_errors|raw }}
diff --git a/templates/Froxlor/login/login.html.twig b/templates/Froxlor/login/login.html.twig
index c9264cba..611888c5 100644
--- a/templates/Froxlor/login/login.html.twig
+++ b/templates/Froxlor/login/login.html.twig
@@ -6,7 +6,7 @@