// methods converting to user interface string ---------------------------
/** Convert a string to HTML.
* @param string $string The string to convert
* @param boolean $breaksForLineFeeds Wheather to convert line feeds to <BR>
* $param boolean $preformatAndTab if set > 0 convert multiple spaces to non-breaking spaces
and replace tabs by the specified number of non-breaking spaces
* @return String with HTML */
function ($string, $breaksForLineFeeds=false, $preformatAndTab=0) {
if ($this->type=='html') return $string;
if ($string===null) return '';
$result = htmlspecialchars($string, ENT_QUOTES | $this->html_version_flag, $this->());
if ($breaksForLineFeeds) {
$br = $this->html_version_ent=='ENT_XML1' || $this->html_version_ent=='ENT_XHTML'
? "<br />\n" : "<br>\n";
$result = preg_replace("/\r\n|\n\r|\n|\r/", $br, $result);
}
if ($preformatAndTab) {
$result = str_replace("\t", str_pad(' ', $preformatAndTab), $result);
$result = str_replace(" ", " ", $result);
$result = str_replace(" ", " ", $result);
}
return $result;
}
|