remove line breaks method
This commit is contained in:
parent
41fae2f808
commit
e4a08873ac
|
@ -126,6 +126,11 @@ class Text {
|
||||||
return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string);
|
return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function removeLineBreaks($string)
|
||||||
|
{
|
||||||
|
return str_replace(array("\r", "\n"), '', $string);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert unicode characters to utf-8 characters
|
// Convert unicode characters to utf-8 characters
|
||||||
// Characters that cannot be converted will be removed from the string
|
// Characters that cannot be converted will be removed from the string
|
||||||
// This function can return an empty string
|
// This function can return an empty string
|
||||||
|
@ -137,6 +142,7 @@ class Text {
|
||||||
$string = self::lowercase($string);
|
$string = self::lowercase($string);
|
||||||
$string = trim($string, $separator);
|
$string = trim($string, $separator);
|
||||||
$string = self::removeSpecialCharacters($string, $separator);
|
$string = self::removeSpecialCharacters($string, $separator);
|
||||||
|
$string = self::removeLineBreaks($string);
|
||||||
$string = trim($string, $separator);
|
$string = trim($string, $separator);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,8 +606,7 @@ class Pages extends dbJSON {
|
||||||
// Returns string without HTML tags and truncated
|
// Returns string without HTML tags and truncated
|
||||||
private function generateSlug($text, $truncateLength=60) {
|
private function generateSlug($text, $truncateLength=60) {
|
||||||
$tmpslug = Text::removeHTMLTags($text);
|
$tmpslug = Text::removeHTMLTags($text);
|
||||||
// Remove break lines
|
$tmpslug = Text::removeLineBreaks($tmpslug);
|
||||||
$tmpslug = str_replace(array("\r", "\n"), '', $tmpslug);
|
|
||||||
return Text::truncate($tmpslug, $truncateLength, '');
|
return Text::truncate($tmpslug, $truncateLength, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue