Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use strict variables in Twig #18685

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Glpi/Application/View/TemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ public function __construct(string $rootdir = GLPI_ROOT, string $cachedir = GLPI
}

$env_params = [
'debug' => $_SESSION['glpi_use_mode'] ?? null === Session::DEBUG_MODE,
'auto_reload' => GLPI_ENVIRONMENT_TYPE !== GLPI::ENV_PRODUCTION,
'debug' => $_SESSION['glpi_use_mode'] ?? null === Session::DEBUG_MODE,
'auto_reload' => GLPI_ENVIRONMENT_TYPE !== GLPI::ENV_PRODUCTION,
'strict_variables' => true,
];

$tpl_cachedir = $cachedir . '/templates';
Expand Down
7 changes: 2 additions & 5 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,10 +1184,6 @@ public static function includeHeader(
// load log filters everywhere
Html::requireJs('log_filters');

if (isset($_SESSION['glpihighcontrast_css']) && $_SESSION['glpihighcontrast_css']) {
$tpl_vars['high_contrast'] = true;
}

// Add specific css for plugins
if (isset($PLUGIN_HOOKS[Hooks::ADD_CSS]) && count($PLUGIN_HOOKS[Hooks::ADD_CSS])) {
foreach ($PLUGIN_HOOKS[Hooks::ADD_CSS] as $plugin => $files) {
Expand Down Expand Up @@ -1725,7 +1721,8 @@ public static function footer()
}

$tpl_vars = [
'js_files' => [],
'js_files' => [],
'js_modules' => [],
];

// On demand scripts
Expand Down
2 changes: 1 addition & 1 deletion templates/layout/parts/head.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<!DOCTYPE html>
<html lang="{{ lang }}"
{% if high_contrast %}
{% if session('glpihighcontrast_css') %}
data-high-contrast="1"
{% endif %}
{% if theme is defined %}
Expand Down
4 changes: 2 additions & 2 deletions templates/layout/parts/menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

<ul class="navbar-nav" id="menu_{{ rand }}">
{% for firstlevel in menu %}
{% set firstlevel_active = menu[sector]['title'] == firstlevel['title'] %}
{% set firstlevel_shown = (menu[sector]['title'] == firstlevel['title'] and is_vertical and is_menu_folded == false) %}
{% set firstlevel_active = menu[sector]['title'] is defined and menu[sector]['title'] == firstlevel['title'] %}
{% set firstlevel_shown = firstlevel_active and is_vertical and is_menu_folded == false %}
{% set has_subitems = false %}
{% if firstlevel['content'] is defined %}
{# Are there any items under contents with a page property? #}
Expand Down
Loading