Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/KnowbaseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ public static function showRecentPopular(string $type = "", bool $display = true
<table class="table table-sm">
<tr><th>{{ title }}</th></tr>
{% for data in iterator %}
{% set name = data['transname'] is not empty ? data['transname'] : data['name'] %}
{% set name = (data['transname'] ?? '') is not empty ? data['transname'] : data['name'] %}
<tr>
<td class="text-start">
<div class="kb">
Expand Down
2 changes: 2 additions & 0 deletions src/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,8 @@ public function showAndAddRuleForm($item)
'name' => $name,
'description' => $rule->fields["description"],
'is_active' => Dropdown::getYesNo($rule->fields["is_active"]),
'itemtype' => $rule::class,
'id' => $rule->fields["id"],
];
}

Expand Down
2 changes: 1 addition & 1 deletion templates/components/dashboard/widget_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
) }}
</div>

{% set palette_displayed = edit and widget_def['haspalette'] %}
{% set palette_displayed = edit and (widget_def['haspalette'] ?? false) %}
{% set palette_disabled = use_gradient %}
{% set palettes = call("Glpi\\Dashboard\\Palette::getAllPalettes") %}
<div class="palette_field" {% if not palette_displayed %}style="display: none;"{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion templates/components/form/basic_inputs_macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

{% macro color(name, value, options = {}) %}
{% set options = {
id: name ~ '_' ~ options.rand
id: name ~ '_' ~ (options.rand ?? random()),
}|merge(options) %}

{{ _self.input(name, value, options|merge({
Expand Down
8 changes: 6 additions & 2 deletions templates/components/form/fields_macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}) %}
{% endif %}
{% if item.fields[name] is defined and item.fields[name] is not null %}
{% set value = call('autoName', [item.fields[name], name, (withtemplate == 2), item.getType(), item.fields['entities_id']]) %}
{% set value = call('autoName', [item.fields[name], name, (withtemplate == 2), item.getType(), item.fields['entities_id'] ?? null]) %}
{% else %}
{% set value = null %}
{% endif %}
Expand Down Expand Up @@ -625,6 +625,7 @@
{% set options = {
'rand': random(),
'width': '100%',
'disabled': false,
}|merge(options) %}
{% if options.fields_template.isMandatoryField(name)|default(false) %}
{% set options = {'required': true}|merge(options) %}
Expand All @@ -648,7 +649,10 @@
{% endmacro %}

{% macro dropdownFrequency(name, value, label = '', options = {}) %}
{% set options = {'rand': random()}|merge(options) %}
{% set options = {
'rand': random(),
'disabled': false,
}|merge(options) %}
{% if options.fields_template.isMandatoryField(name)|default(false) %}
{% set options = {'required': true}|merge(options) %}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/components/printer_graph_buttons.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'rand': random()
} %}

{% if not timerange_presets %}
{% if timerange_presets is not defined %}
{% set timerange_presets = {
'P1D': __('Last day'),
'P1W': __('Last 7 days'),
Expand All @@ -47,7 +47,7 @@
} %}
{% endif %}

{% if not format_presets %}
{% if format_presets is not defined %}
{% set format_presets = {
'dynamic': __('Dynamic distribution'),
'daily': __('Daily'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@
contentType: false, // Needed when using FormData object
}).done(function() {
glpi_toast_info("{{ __("Filter saved") }}");

{% if delete_action_id is defined %}
// Show delete button if it wasn't already enabled
$("#{{ delete_action_id }}").removeClass('d-none');
{% endif %}

// Add badge to menu to hint that a filter have been set
const tab = $("a.nav-link[href*='CriteriaFilter']");
Expand Down
10 changes: 5 additions & 5 deletions templates/components/search/display_data.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

{# Remove namespace separators for use in HTML attributes #}
{% set normalized_itemtype = itemtype|replace({'\\': ''}) %}
{% set as_map = data['search']['as_map'] == 1 %}
{% set as_map = (data['search']['as_map'] ?? false) == 1 %}

<div
class="card search-card"
Expand Down Expand Up @@ -70,18 +70,18 @@
data-start="{{ start }}" data-count="{{ count }}" data-limit="{{ limit }}" data-submit-once
class="masssearchform">

{% if data['search']['as_map'] == 0 %}
{% if not as_map %}
{{ include('components/search/table.html.twig') }}
{% elseif count > 0 %}
{{ include('components/search/map.html.twig') }}
{% endif %}
{% if count > 0 %}
{% if data['display_type'] != constant('Search::GLOBAL_SEARCH') and data['search']['as_map'] == 0 %}
{% if data['display_type'] != constant('Search::GLOBAL_SEARCH') and not as_map %}
<div class="card-footer search-footer {{ not user_pref('search_pagination_on_top') ? "d-block" : "d-block d-xxl-none" }}">
{{ include('components/pager.html.twig') }}
</div>
{% endif %}
{% elseif data['search']['as_map'] == 1 %}
{% elseif as_map %}
{% if search_error %}
{{ alerts.alert_danger(__('An error occured during the search'), __('Consider changing the search criteria or adjusting the displayed columns.')) }}
{% else %}
Expand All @@ -93,7 +93,7 @@
{% if not is_ajax %}
</div>

{% if data['search']['as_map'] == 0 %}
{% if not as_map %}
<script>
window.initFluidSearch{{ rand }} = () => {
const allowed_forced_params = ['hide_controls', 'usesession', 'forcetoview', 'criteria'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@
{% endif %}
</div>
<ul class="list-group">
{% for opt in entries|filter(v => v['fixed'] == true) %}
{% for opt in entries|filter(v => (v['fixed'] ?? false) == true) %}
<li data-opt-id="{{ opt['id'] }}" data-fixed="true" class="list-group-item py-2 disabled px-2">
<i class="ti ti-grip-vertical bs-invisible"></i>
<span>{{ opt['name'] }}</span>
</li>
{% endfor %}
{% for opt in entries|filter(v => v['fixed'] != true) %}
{% for opt in entries|filter(v => (v['fixed'] ?? false) != true) %}
{% set name_prefix = opt['group'] is not empty ? (opt['group']) : '' %}
<li data-opt-id="{{ opt['id'] }}" class="cursor-grab list-group-item py-2 d-flex px-2 align-items-center">
<i class="ti ti-grip-vertical"></i>
Expand Down
3 changes: 2 additions & 1 deletion templates/components/search/table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{% endif %}

{% set sorts = data['search']['sort'] %}

{% if search_was_executed %}
{% for col in data['data']['cols'] %}
{# construct header link (for sorting) #}
{% set linkto = '' %}
Expand Down Expand Up @@ -94,6 +94,7 @@
{% endif %}
</th>
{% endfor %}
{% endif %}

{# display itemtype in AllAssets #}
{% if union_search_type[itemtype] is defined %}
Expand Down
10 changes: 7 additions & 3 deletions templates/pages/admin/form/form_translation.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<input type="hidden" name="translations[{{ rand }}][key]" value="{{ handler.getKey() }}" />

<div class="d-flex align-items-center">
{% if translation.isPossiblyObsolete() %}
{% if translation and translation.isPossiblyObsolete() %}
<i
class="ti ti-alert-circle text-warning me-1"
aria-hidden="true"
Expand All @@ -50,10 +50,14 @@
></i>
{% endif %}

{% set current_translation = '' %}
{% if translation %}
{% set current_translation = translation.getTranslation() %}
{% endif %}
{% if handler.isRichText() %}
{{ fields.textareaField(
'translations[%s][translations][one]'|format(rand),
translation.getTranslation(),
current_translation,
'',
{
'no_label' : true,
Expand All @@ -72,7 +76,7 @@
name="translations[{{ rand }}][translations][one]"
class="form-control"
placeholder="{{ __('Enter translation') }}"
value="{{ translation.getTranslation() }}"
value="{{ current_translation }}"
aria-label="{{ __('Enter translation') }}"
/>
{% endif %}
Expand Down
6 changes: 2 additions & 4 deletions templates/pages/admin/rules/ruleright_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
{% import 'components/form/fields_macros.html.twig' as fields %}

{% block more_fields %}
{% if short %}
{{ fields.dropdownField('Profile', 'profiles_id', 0, 'Profile'|itemtype_name) }}
{{ fields.dropdownYesNo('is_recursive', 0, __('Recursive')) }}
{% endif %}
{{ fields.dropdownField('Profile', 'profiles_id', 0, 'Profile'|itemtype_name) }}
{{ fields.dropdownYesNo('is_recursive', 0, __('Recursive')) }}
{% endblock %}
15 changes: 7 additions & 8 deletions templates/pages/admin/user.substitute.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

{% import 'components/form/fields_macros.html.twig' as fields %}

{% set id = item.fields['id'] ?? -1 %}
{% set id = item.fields['id'] ?? -1 %}

<div class="asset">

Expand All @@ -42,10 +42,10 @@

<div id="mainformtable">

{{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::PRE_ITEM_FORM'), {'item': item, 'options': params}) }}
{{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::PRE_ITEM_FORM'), {'item': item, 'options': params ?? []}) }}

<div class="card-body d-flex flex-wrap">
<div class="col-12 col-xxl-{{ item_has_pictures ? '9' : '12' }} flex-column">
<div class="col-12 col-xxl-{{ (item_has_pictures ?? false) ? '9' : '12' }} flex-column">
<div class="d-flex flex-row flex-wrap flex-xl-nowrap">
<div class="row flex-row align-items-start flex-grow-1">
<div class="row flex-row">
Expand Down Expand Up @@ -129,10 +129,10 @@
</div> {# .card-body #}

<div class="row">
{{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::POST_ITEM_FORM'), {'item': item, 'options': params}) }}
{{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::POST_ITEM_FORM'), {'item': item, 'options': params ?? []}) }}
</div>

{% if canedit %}
{% if canedit %}
<div class="card-body mx-n2 mb-4 border-top d-flex flex-row-reverse align-items-start flex-wrap">
<button class="btn btn-primary me-2" type="submit" name="update" value="1">
<i class="ti ti-device-floppy"></i>
Expand All @@ -143,7 +143,6 @@
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
</div> {# #mainformtable #}
</form> {# [name=asset_form] #}
{% else %}
</div> {# #mainformtable #}
{% endif %}
</div>
</div> {# #mainformtable #}

3 changes: 2 additions & 1 deletion templates/pages/admin/user/user.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
{# Preference form = My Settings page #}
{% set is_preference_form = is_preference_form|default(false) %}
{% set target = path(is_preference_form ? '/front/preference.php' : '/front/user.form.php') %}
{% set higher_rights = higher_rights|default(false) %}

<div class="asset">
<form id="main-form" name="asset_form" method="post" action="{{ target }}" enctype="multipart/form-data" data-submit-once>
Expand Down Expand Up @@ -254,7 +255,7 @@
{{ fields.textField('phone2', item.fields['phone2'], __('Phone 2')) }}
{% endif %}

{% if not item.isNewItem() and (caneditpassword or is_preference_form) %}
{% if not item.isNewItem() and ((caneditpassword ?? false) or is_preference_form) %}
{{ fields.smallTitle(__('Passwords and access keys')) }}
{{ fields.passwordField('api_token', item.fields['api_token'], __('API token'), {
can_regenerate: true,
Expand Down
4 changes: 2 additions & 2 deletions templates/pages/assistance/planning/single_filter.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</a>
</li>
<li class="dropdown-item">
<a target="_blank" href="webcal://{{ url.host }}:{{ url.port }}{{ url.path }}{{ export_url }}">
<a target="_blank" href="webcal://{{ url.host }}:{{ url.port }}{{ url.path ?? '' }}{{ export_url }}">
{{ _x('button', 'Export') }} - {{ __('Webcal') }}
</a>
</li>
Expand All @@ -92,7 +92,7 @@
</div>
{% endif %}
</span>
{% if caldav_item_url is not empty and filter_data.type == 'group_users' %}
{% if (caldav_item_url ?? '') is not empty and filter_data.type == 'group_users' %}
<ul class="group_listofusers filters">
{% for user_key, user_data in filter_data.users %}
{% do call('Planning::showSingleLinePlanningFilter', [user_key, user_data, {
Expand Down
4 changes: 2 additions & 2 deletions templates/pages/setup/crontask/crontask.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

{% import 'components/form/fields_macros.html.twig' as fields %}

<div class="asset {{ bg }}">
<div class="asset">
{{ include('components/form/header.html.twig') }}

{% set rand = random() %}
Expand All @@ -44,7 +44,7 @@
{% set can_execute = item.canEdit(item.fields['id']) %}

<div class="card-body d-flex flex-wrap">
<div class="col-12 col-xxl-{{ item_has_pictures ? '9' : '12' }} flex-column">
<div class="col-12 col-xxl-12 flex-column">
<div class="d-flex flex-row flex-wrap flex-xl-nowrap">
<div class="row flex-row align-items-start flex-grow-1">
<div class="row flex-row">
Expand Down
4 changes: 2 additions & 2 deletions templates/pages/setup/general/assistance_setup.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
})) }}
{% set planning_end_field %}
<span class="mx-1">-></span>
{{ fields.dropdownHoursField(planning_end, config['planning_end'], '', field_options|merge({
{{ fields.dropdownHoursField('planning_end', config['planning_end'], '', field_options|merge({
no_label: true
})) }}
{% endset %}
{{ fields.dropdownHoursField(planning_begin, config['planning_begin'], __('Limit of the schedules for planning'), field_options|merge({
{{ fields.dropdownHoursField('planning_begin', config['planning_begin'], __('Limit of the schedules for planning'), field_options|merge({
add_field_html: planning_end_field
})) }}

Expand Down
4 changes: 2 additions & 2 deletions templates/pages/setup/general/preferences_setup.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@
{% if call('\\Glpi\\Dashboard\\Grid::canViewOneDashboard') %}
{{ fields.smallTitle(__('Dashboards'), call('Glpi\\Dashboard\\Dashboard::getIcon'), '', 'section-dashboards') }}
{% macro dropdownDashboard(name, config, context = 'core', disabled_option = false) %}
{% macro dropdownDashboard(name, config, thecontext = "core", disabled_option = false) %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why. Maybe context is a kind of reserved keyword in this... context... ?

{% do call('\\Glpi\\Dashboard\\Grid::dropdownDashboard', [name, {
value: config[name],
display_emptychoice: true,
context: context
context: thecontext
}, disabled_option]) %}
{% endmacro %}
Expand Down
Loading