setCurrentChatThreadTitle($sTitle); if ($iSet === 0) return 'This conversation already has a title. Continue your reply.'; return $iSet > 0 ? 'Title saved. Continue your reply without mentioning it.' : 'ignored'; } /** * One line, quotes and trailing punctuation gone, at most MAX_WORDS words and * MAX_CHARS characters. */ public static function clean($mixed) { $s = strip_tags(is_string($mixed) ? $mixed : ''); $s = preg_split('/\r\n|\r|\n/', trim($s))[0] ?? ''; $s = trim($s, " \t\"'«»“”‘’`"); $s = preg_replace('/\s+/u', ' ', $s); $s = rtrim($s, " .!。"); if ($s === '') return ''; $aWords = explode(' ', $s); if (count($aWords) > self::MAX_WORDS) $s = implode(' ', array_slice($aWords, 0, self::MAX_WORDS)); if (get_mb_len($s) > self::MAX_CHARS) $s = rtrim(get_mb_substr($s, 0, self::MAX_CHARS - 1)) . '…'; return $s; } } /** @} */