add userarea-layout + sidebar and topmenu
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -442,7 +442,7 @@ class Database
|
||||
if (empty($sql['debug'])) {
|
||||
$error_trace = '';
|
||||
} elseif (!is_null($stmt)) {
|
||||
$error_trace .= "<br><br>" . $stmt->queryString;
|
||||
$error_trace .= "\n\n" . $stmt->queryString;
|
||||
}
|
||||
|
||||
if ($showerror && $json_response) {
|
||||
|
||||
@@ -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 = '<div class="alert alert-danger my-1" role="alert">';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Froxlor\UI;
|
||||
|
||||
class HTML
|
||||
@@ -17,9 +18,7 @@ class HTML
|
||||
*/
|
||||
public static function buildNavigation($navigation, $userinfo)
|
||||
{
|
||||
global $theme;
|
||||
|
||||
$returnvalue = '';
|
||||
$returnvalue = [];
|
||||
|
||||
// sanitize user-given input (url-manipulation)
|
||||
if (isset($_GET['page']) && is_array($_GET['page'])) {
|
||||
@@ -30,17 +29,17 @@ class HTML
|
||||
}
|
||||
|
||||
foreach ($navigation as $box) {
|
||||
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 = '';
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
|
||||
17
lib/init.php
17
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'])) {
|
||||
|
||||
Reference in New Issue
Block a user