remove line breaks method

This commit is contained in:
Diego Najar 2018-08-26 13:44:18 +02:00
parent 41fae2f808
commit e4a08873ac
2 changed files with 7 additions and 2 deletions

View File

@ -126,6 +126,11 @@ class Text {
return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string);
}
public static function removeLineBreaks($string)
{
return str_replace(array("\r", "\n"), '', $string);
}
// Convert unicode characters to utf-8 characters
// Characters that cannot be converted will be removed from the string
// This function can return an empty string
@ -137,6 +142,7 @@ class Text {
$string = self::lowercase($string);
$string = trim($string, $separator);
$string = self::removeSpecialCharacters($string, $separator);
$string = self::removeLineBreaks($string);
$string = trim($string, $separator);
return $string;
}

View File

@ -606,8 +606,7 @@ class Pages extends dbJSON {
// Returns string without HTML tags and truncated
private function generateSlug($text, $truncateLength=60) {
$tmpslug = Text::removeHTMLTags($text);
// Remove break lines
$tmpslug = str_replace(array("\r", "\n"), '', $tmpslug);
$tmpslug = Text::removeLineBreaks($tmpslug);
return Text::truncate($tmpslug, $truncateLength, '');
}