Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix handling of global search output
  • Loading branch information
cedric-anne authored and trasher committed Sep 14, 2022
1 parent e66a0df commit e248ed5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Search.php
Expand Up @@ -6307,6 +6307,14 @@ public static function giveItem(
}
}

$html_output = in_array(
self::$output_type,
[
self::HTML_OUTPUT,
self::GLOBAL_SEARCH, // For a global search, output will be done in HTML context
]
);

if (isset($so["table"])) {
$table = $so["table"];
$field = $so["field"];
Expand Down Expand Up @@ -6988,7 +6996,7 @@ public static function giveItem(
return "";

case 'glpi_ticketsatisfactions.satisfaction':
if (self::$output_type == self::HTML_OUTPUT) {
if ($html_output) {
return TicketSatisfaction::displaySatisfaction($data[$ID][0]['name']);
}
break;
Expand All @@ -7009,20 +7017,20 @@ public static function giveItem(
return Cartridge::getCount(
$data["id"],
$data[$ID][0]['alarm_threshold'],
self::$output_type != self::HTML_OUTPUT
!$html_output
);

case 'glpi_printers._virtual':
return Cartridge::getCountForPrinter(
$data["id"],
self::$output_type != self::HTML_OUTPUT
!$html_output
);

case 'glpi_consumableitems._virtual':
return Consumable::getCount(
$data["id"],
$data[$ID][0]['alarm_threshold'],
self::$output_type != self::HTML_OUTPUT
!$html_output
);

case 'glpi_links._virtual':
Expand Down Expand Up @@ -7164,10 +7172,9 @@ public static function giveItem(
}
$count_display++;

$plaintext = RichText::getTextFromHtml($data[$ID][$k]['name'], false, true, $html_output);

$plaintext = RichText::getTextFromHtml($data[$ID][$k]['name'], false, true, self::$output_type == self::HTML_OUTPUT);

if (self::$output_type == self::HTML_OUTPUT && (Toolbox::strlen($plaintext) > $CFG_GLPI['cut'])) {
if ($html_output && (Toolbox::strlen($plaintext) > $CFG_GLPI['cut'])) {
$rand = mt_rand();
$popup_params = [
'display' => false,
Expand Down

0 comments on commit e248ed5

Please sign in to comment.