Merge branch 'ent-7531-menu-lateral-no-se-oculta-correctamente' into 'develop'

Clean code and fix issue with lateral main menu

Closes pandora_enterprise#7531

See merge request artica/pandorafms!4213
This commit is contained in:
Daniel Rodriguez 2021-08-17 07:08:34 +00:00
commit af6319eeb4
6 changed files with 105 additions and 81 deletions

View File

@ -23,13 +23,8 @@ ui_require_css_file('order_interpreter');
// Global errors/warnings checking.
config_check();
echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
if ($config['menu_type'] == 'classic') {
echo '<div id="header_table" class="header_table_classic">';
} else {
echo '<div id="header_table" class="header_table_collapsed">';
}
?>
<div id="header_table_inner">
<?php

View File

@ -1,17 +1,33 @@
<?php
/**
* Lateral Main Menu.
*
* @category Main Menu.
* @package Pandora FMS.
* @subpackage OpenSource.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
if (! isset($config['id_user'])) {
// Begin.
if (isset($config['id_user']) === false) {
include 'general/login_page.php';
exit();
}
@ -20,9 +36,9 @@ if (! isset($config['id_user'])) {
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var menuType_value = "<?php echo $config['menu_type']; ?>";
var menuType_value = "<?php echo $_SESSION['menu_type']; ?>";
if (menuType_value == 'classic') {
if (menuType_value === 'classic') {
$('ul.submenu').css('left', '214px');
}
else{
@ -34,26 +50,22 @@ $(document).ready(function(){
<?php
$autohidden_menu = 0;
if (isset($config['autohidden_menu']) && $config['autohidden_menu']) {
if (isset($config['autohidden_menu']) === true && (bool) $config['autohidden_menu'] === true) {
$autohidden_menu = 1;
}
// Menu container prepared to autohide menu
if ($config['menu_type'] == 'classic') {
echo '<div id="menu_full" class="menu_full_classic">';
} else {
echo '<div id="menu_full" class="menu_full_collapsed">';
}
// Start of full lateral menu.
echo sprintf('<div id="menu_full" class="menu_full_%s">', $menuTypeClass);
$custom_logo = 'images/custom_logo/'.$config['custom_logo'];
$custom_logo_collapsed = 'images/custom_logo/'.$config['custom_logo_collapsed'];
if (!defined('PANDORA_ENTERPRISE')) {
if (defined('PANDORA_ENTERPRISE') === false) {
$logo_title = get_product_name().' Opensource';
$custom_logo = 'images/custom_logo/pandora_logo_head_3.png';
$custom_logo_collapsed = 'images/custom_logo/pandora_logo_green_collapsed.png';
} else {
if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo)) {
if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo) === true) {
$custom_logo = ENTERPRISE_DIR.'/'.$custom_logo;
}
@ -61,54 +73,48 @@ if (!defined('PANDORA_ENTERPRISE')) {
}
echo '<div class="logo_green"><a href="index.php?sec=main">';
if (isset($config['custom_logo'])) {
if ($config['menu_type'] == 'classic') {
echo html_print_image($custom_logo, true, ['border' => '0', 'width' => '215', 'alt' => $logo_title, 'class' => 'logo_full', 'style' => 'display:block']);
} else {
echo html_print_image($custom_logo, true, ['border' => '0', 'width' => '215', 'alt' => $logo_title, 'class' => 'logo_full', 'style' => 'display:none']);
}
if (isset($config['custom_logo']) === true) {
echo html_print_image(
$custom_logo,
true,
[
'border' => '0',
'width' => '215',
'alt' => $logo_title,
'class' => 'logo_full',
'style' => ($menuCollapsed === true) ? 'display:none' : 'display:block',
]
);
}
if (isset($config['custom_logo_collapsed'])) {
if ($config['menu_type'] == 'classic') {
echo html_print_image($custom_logo_collapsed, true, ['border' => '0', 'width' => '60', 'alt' => $logo_title, 'class' => 'logo_icon', 'style' => 'display:none']);
} else {
echo html_print_image($custom_logo_collapsed, true, ['border' => '0', 'width' => '60', 'alt' => $logo_title, 'class' => 'logo_icon', 'style' => 'display:block']);
}
if (isset($config['custom_logo_collapsed']) === true) {
echo html_print_image(
$custom_logo_collapsed,
true,
[
'border' => '0',
'width' => '60',
'alt' => $logo_title,
'class' => 'logo_icon',
'style' => ($menuCollapsed === true) ? 'display:block' : 'display:none',
]
);
}
echo '</a></div>';
// echo '<div class="tit bg titop">:: '.__('Operation').' ::</div>';
require 'operation/menu.php';
// Check all enterprise ACL used in godmenu items to print menu headers
if (check_acl($config['id_user'], 0, 'AW')
|| check_acl($config['id_user'], 0, 'PM')
|| check_acl($config['id_user'], 0, 'LM')
|| check_acl($config['id_user'], 0, 'UM')
|| check_acl($config['id_user'], 0, 'LW')
|| check_acl($config['id_user'], 0, 'EW')
|| check_acl($config['id_user'], 0, 'DW')
) {
// echo '<div class="tit bg3">:: '.__('Administration').' ::</div>';
}
require 'godmode/menu.php';
if ($config['menu_type'] == 'classic') {
echo '<div id="button_collapse" class="button_classic button_collapse"></div>';
} else {
echo '<div id="button_collapse" class="button_collapsed button_collapse"></div>';
}
echo sprintf('<div id="button_collapse" class="button_%s button_collapse"></div>', $menuTypeClass);
// require ("links_menu.php");
echo '</div>';
// menu_container
// Menu_container.
ui_require_jquery_file('cookie');
$config_fixed_header = false;
if (isset($config['fixed_header'])) {
if (isset($config['fixed_header']) === true) {
$config_fixed_header = $config['fixed_header'];
}
?>

View File

@ -306,7 +306,7 @@ switch ($config['dbtype']) {
// ======================================================================
// Menu display mode.
if (isset($_SESSION['meny_type']) === true && $_SESSION['menu_type']) {
if (isset($_SESSION['meny_type']) === true && empty($_SESSION['menu_type']) === false) {
$config['menu_type'] = $_SESSION['menu_type'];
} else {
$config['menu_type'] = 'classic';

View File

@ -30,7 +30,7 @@
global $config;
// Set variable to store menu type (classic or collapsed).
if (!empty(get_parameter('menuType'))) {
if (is_ajax() === true && empty(get_parameter('menuType')) === false) {
$_SESSION['menu_type'] = get_parameter('menuType', 'classic');
return;
}
@ -108,7 +108,7 @@ function menu_print_menu(&$menu)
$submenu = false;
if ($config['menu_type'] == 'classic') {
if ($_SESSION['menu_type'] === 'classic') {
$classes = [
'menu_icon',
'no_hidden_menu',
@ -413,7 +413,7 @@ function menu_print_menu(&$menu)
$length = strlen(__($main['text']));
$padding_top = ( $length >= 18) ? 6 : 12;
if ($config['menu_type'] == 'classic') {
if ($_SESSION['menu_type'] === 'classic') {
$output .= '<div id="title_menu" class="title_menu_classic">'.$main['text'].'</div>';
} else {
$output .= '<div id="title_menu" class="title_menu_collapsed">'.$main['text'].'</div>';

View File

@ -416,11 +416,11 @@ ul li {
}
.menu_full_classic .title_menu_classic {
display: flex;
display: flex !important;
}
.menu_full_collapsed .title_menu_collapsed {
display: none;
display: none !important;
}
.button_classic {

View File

@ -1112,17 +1112,36 @@ if (get_parameter('login', 0) !== 0) {
}
}
// Header.
if ($config['pure'] == 0) {
echo '<div id="container"><div id="head">';
include 'general/header.php';
if ($config['menu_type'] == 'classic') {
echo '</div><div id="page" class="page_classic"><div id="menu">';
} else {
echo '</div><div id="page" class="page_collapsed"><div id="menu">';
if ((bool) $config['maintenance_mode'] === true
&& (bool) users_is_admin() === false
) {
// Show maintenance web-page. For non-admin users only.
include 'general/maintenance.php';
while (ob_get_length() > 0) {
ob_end_flush();
}
exit('</html>');
}
// Pure.
if ($config['pure'] == 0) {
// Menu container prepared to autohide menu.
$menuCollapsed = (isset($_SESSION['menu_type']) === true && $_SESSION['menu_type'] !== 'classic');
$menuTypeClass = ($menuCollapsed === true) ? 'collapsed' : 'classic';
// Container.
echo '<div id="container">';
// Header.
echo '<div id="head">';
include 'general/header.php';
echo '</div>';
// Main menu.
echo sprintf('<div id="page" class="page_%s">', $menuTypeClass);
echo '<div id="menu">';
include 'general/main_menu.php';
echo '</div>';
echo '<button onclick="topFunction()" id="top_btn" title="Go to top"></button>';
@ -1330,11 +1349,15 @@ if ($config['pure'] == 0) {
// Main pure.
}
echo '<div id="wiz_container">';
echo '</div>';
html_print_div(
['id' => 'wiz_container'],
true
);
echo '<div id="um_msg_receiver">';
echo '</div>';
html_print_div(
['id' => 'um_msg_receiver'],
true
);
// Connection lost alert.
ui_require_javascript_file('connection_check');