From 2bb016474a32f180e463a36b4407bdd91b52f32c Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 12 Apr 2023 13:37:51 +0200 Subject: [PATCH] #10909 Fix icon group 2 --- .../godmode/groups/configure_group.php | 28 +++++++++++++++++-- pandora_console/godmode/groups/group_list.php | 13 +++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 8d81d44540..88966378de 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -120,6 +120,16 @@ if (is_metaconsole() === true) { // Data before table. $files = list_files(((is_metaconsole() === true) ? '../../' : '').'images/', '@groups.svg', 1, 0); +$files_old = list_files('images/groups_small/', 'png', 1, 0); +foreach ($files_old as $key => $f) { + // Remove from the list the non-desired .png files. + if (strpos($f, '.bad.png') !== false || strpos($f, '.default.png') !== false || strpos($f, '.ok.png') !== false || strpos($f, '.warning.png') !== false) { + unset($files_old[$key]); + } +} + +$files = array_merge($files, $files_old); + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filter-table-adv'; @@ -133,10 +143,19 @@ $table->data[0][0] = html_print_label_input_block( html_print_input_text('name', $name, '', 35, 100, true) ); +$extension = pathinfo($icon, PATHINFO_EXTENSION); +if (empty($extension) === true) { + $icon .= '.png'; +} + $input_icon = html_print_select($files, 'icon', $icon, '', 'None', '', true, false, true, '', false, 'width: 100%;'); $input_icon .= ' '; if (empty($icon) === false) { - $input_icon .= html_print_image('images/'.$icon, true); + if (empty($extension) === true || $extension === 'png') { + $input_icon .= html_print_image('images/groups_small/'.$icon, true); + } else { + $input_icon .= html_print_image('images/'.$icon, true); + } } $input_icon .= ''; @@ -304,12 +323,17 @@ echo ''; function icon_changed () { var inputs = []; var data = this.value; + var extension = data.split('.').pop(); $('#icon_preview').fadeOut ('normal', function () { $('#icon_preview').empty (); if (data != "") { var params = []; params.push("get_image_path=1"); - params.push("img_src=images/" + data); + if (extension === 'png') { + params.push("img_src=images/groups_small/" + data); + } else { + params.push("img_src=images/" + data); + } params.push("page=include/ajax/skins.ajax"); params.push("only_src=1"); jQuery.ajax ({ diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index ee0cd1c6d2..4647231927 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -921,9 +921,18 @@ if ($tab == 'tree') { if ($group['icon'] != '') { $extension = pathinfo($group['icon'], PATHINFO_EXTENSION); - $extension = (empty($extension) === true) ? '.png' : ''; + if (empty($extension) === true) { + $group['icon'] .= '.png'; + } + + if (empty($extension) === true || $extension === 'png') { + $path = 'images/groups_small/'.$group['icon']; + } else { + $path = 'images/'.$group['icon']; + } + $table->data[$key][2] = html_print_image( - 'images/'.$group['icon'].$extension, + $path, true, [ 'style' => '',