From e71bb2a791470ea7bd3940da2593c1741409b4f3 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 27 Aug 2019 16:01:18 +0200 Subject: [PATCH] Long custom fields urls and text truncated --- pandora_console/include/functions_ui.php | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 008c05b8d7..b9af85318c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -39,7 +39,7 @@ if (isset($config['homedir'])) { /** - * Transform bbcode to HTML. + * Transform bbcode to HTML and truncate log. * * @param string $text Text. * @param array $allowed_tags Allowed_tags. @@ -48,16 +48,22 @@ if (isset($config['homedir'])) { */ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) { - if (array_search('[url]', $allowed_tags) !== false) { - // If link hasn't http, add it. - if (preg_match('/https?:\/\//', $text)) { - $html_bbcode = '$2'; - } else { - $html_bbcode = '$2'; - } - + if (array_search('[url]', $allowed_tags) !== false || a) { // Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes - $return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $text); + preg_match('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $text, $matches); + if ($matches) { + $url = $matches[1]; + // Truncate text + $t_text = ui_print_truncate_text($matches[2]); + // If link hasn't http, add it. + if (preg_match('/https?:\/\//', $text)) { + $return = ''.$t_text.''; + } else { + $return = ''.$t_text.''; + } + } else { + $return = ui_print_truncate_text($text); + } } return $return;