#10676 increase chars in agents name in monitor view and truncate at the end
This commit is contained in:
parent
885ed9747b
commit
9cdc7273a6
|
@ -99,13 +99,18 @@ function ui_print_truncate_text(
|
||||||
$forced_title=false
|
$forced_title=false
|
||||||
) {
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
$truncate_at_end = false;
|
||||||
if (is_string($numChars)) {
|
if (is_string($numChars)) {
|
||||||
switch ($numChars) {
|
switch ($numChars) {
|
||||||
case 'agent_small':
|
case 'agent_small':
|
||||||
$numChars = $config['agent_size_text_small'];
|
$numChars = $config['agent_size_text_small'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'truncate_at_end':
|
||||||
|
$numChars = 28;
|
||||||
|
$truncate_at_end = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'agent_medium':
|
case 'agent_medium':
|
||||||
$numChars = $config['agent_size_text_medium'];
|
$numChars = $config['agent_size_text_medium'];
|
||||||
break;
|
break;
|
||||||
|
@ -147,27 +152,33 @@ function ui_print_truncate_text(
|
||||||
// '/2' because [...] is in the middle of the word.
|
// '/2' because [...] is in the middle of the word.
|
||||||
$half_length = intval(($numChars - 3) / 2);
|
$half_length = intval(($numChars - 3) / 2);
|
||||||
|
|
||||||
// Depending on the strange behavior of mb_strimwidth() itself,
|
if ($truncate_at_end === true) {
|
||||||
// the 3rd parameter is not to be $numChars but the length of
|
// Recover the html entities to avoid XSS attacks.
|
||||||
// original text (just means 'large enough').
|
$truncateText = ($text_has_entities) ? io_safe_input(substr($text_html_decoded, 0, $numChars)) : $text_html_decoded;
|
||||||
$truncateText2 = mb_strimwidth(
|
$truncateText .= '...';
|
||||||
$text_html_decoded,
|
} else {
|
||||||
(mb_strlen($text_html_decoded, 'UTF-8') - $half_length),
|
// Depending on the strange behavior of mb_strimwidth() itself,
|
||||||
mb_strlen($text_html_decoded, 'UTF-8'),
|
// the 3rd parameter is not to be $numChars but the length of
|
||||||
'',
|
// original text (just means 'large enough').
|
||||||
'UTF-8'
|
$truncateText2 = mb_strimwidth(
|
||||||
);
|
$text_html_decoded,
|
||||||
|
(mb_strlen($text_html_decoded, 'UTF-8') - $half_length),
|
||||||
|
mb_strlen($text_html_decoded, 'UTF-8'),
|
||||||
|
'',
|
||||||
|
'UTF-8'
|
||||||
|
);
|
||||||
|
|
||||||
$truncateText = mb_strimwidth(
|
$truncateText = mb_strimwidth(
|
||||||
$text_html_decoded,
|
$text_html_decoded,
|
||||||
0,
|
0,
|
||||||
($numChars - $half_length),
|
($numChars - $half_length),
|
||||||
'',
|
'',
|
||||||
'UTF-8'
|
'UTF-8'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Recover the html entities to avoid XSS attacks.
|
// Recover the html entities to avoid XSS attacks.
|
||||||
$truncateText = ($text_has_entities) ? io_safe_input($truncateText).$suffix.io_safe_input($truncateText2) : $truncateText.$suffix.$truncateText2;
|
$truncateText = ($text_has_entities) ? io_safe_input($truncateText).$suffix.io_safe_input($truncateText2) : $truncateText.$suffix.$truncateText2;
|
||||||
|
}
|
||||||
|
|
||||||
if ($showTextInTitle) {
|
if ($showTextInTitle) {
|
||||||
if ($style === null) {
|
if ($style === null) {
|
||||||
|
|
|
@ -1729,7 +1729,7 @@ if (empty($result) === false) {
|
||||||
|
|
||||||
$agent_alias = ui_print_truncate_text(
|
$agent_alias = ui_print_truncate_text(
|
||||||
$agent_alias,
|
$agent_alias,
|
||||||
'agent_small',
|
'truncate_at_end',
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
@ -1743,7 +1743,7 @@ if (empty($result) === false) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data[1] = '<strong><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agent'].'">';
|
$data[1] = '<strong><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agent'].'">';
|
||||||
$data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;');
|
$data[1] .= ui_print_truncate_text($agent_alias, 'agent_at_end', false, true, false, '[…]', 'font-size:7.5pt;');
|
||||||
$data[1] .= '</a></strong>';
|
$data[1] .= '</a></strong>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue