/** * Sanatise all line endings to '\r' Mac format * * Function will convert all line ending Mac format '\r' * * @access public * @param string $str The string to convert all line endings to * @return string The converted string */ function SanatiseStringToMac($str) { return str_replace("\n", "\r", SanatiseStringToUnix($str)); }
/** * If the editor is disabled then we'll see if we need to run * nl2br on the text if it doesn't contain any HTML tags */ public function FormatWYSIWYGHTML($HTML) { if (GetConfig('UseWYSIWYG')) { return $HTML; } else { // We need to sanitise all the line feeds first to 'nl' $HTML = SanatiseStringToUnix($HTML); // Now we can use nl2br() $HTML = nl2br($HTML); // But we still need to strip out the new lines as nl2br doesn't really 'replace' the new lines, it just inserts <br />before it $HTML = str_replace("\n", "", $HTML); // Fix up new lines and block level elements. $HTML = preg_replace("#(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)\\s*<br />#i", "\$1", $HTML); $HTML = preg_replace("#( )+(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "\$2", $HTML); return $HTML; } }