Poprawki API i panelu admina
This commit is contained in:
20
api/message_text_helper.php
Normal file
20
api/message_text_helper.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Normalizuje komunikat kolejki do zwykłego tekstu (wiersze = \n w JSON).
|
||||
* Starsze wpisy HTML (<br>, tagi) są konwertowane na plain text.
|
||||
*/
|
||||
function normalizeQueueMessageText(string $text): string
|
||||
{
|
||||
$text = trim($text);
|
||||
if ($text === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$text = preg_replace('/<br\s*\/?>/i', "\n", $text) ?? $text;
|
||||
$text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
$text = str_replace(["\r\n", "\r"], "\n", $text);
|
||||
$text = preg_replace("/\n{3,}/", "\n\n", $text) ?? $text;
|
||||
|
||||
return trim($text);
|
||||
}
|
||||
Reference in New Issue
Block a user