1
+ − 1
<?php
+ − 2
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+ − 3
/**
+ − 4
* Format class for the Xhtml rendering
+ − 5
*
+ − 6
* PHP versions 4 and 5
+ − 7
*
+ − 8
* @category Text
+ − 9
* @package Text_Wiki
+ − 10
* @author Paul M. Jones <pmjones@php.net>
+ − 11
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ − 12
* @version CVS: $Id: Xhtml.php,v 1.9 2006/02/10 22:31:50 toggg Exp $
+ − 13
* @link http://pear.php.net/package/Text_Wiki
+ − 14
*/
+ − 15
+ − 16
/**
+ − 17
* Format class for the Xhtml rendering
+ − 18
*
+ − 19
* @category Text
+ − 20
* @package Text_Wiki
+ − 21
* @author Paul M. Jones <pmjones@php.net>
+ − 22
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ − 23
* @version Release: @package_version@
+ − 24
* @link http://pear.php.net/package/Text_Wiki
+ − 25
*/
+ − 26
class Text_Wiki_Render_Xhtml extends Text_Wiki_Render {
+ − 27
+ − 28
var $conf = array(
+ − 29
'translate' => HTML_ENTITIES,
+ − 30
'quotes' => ENT_COMPAT,
+ − 31
'charset' => 'ISO-8859-1'
+ − 32
);
+ − 33
+ − 34
function pre()
+ − 35
{
+ − 36
$this->wiki->source = $this->textEncode($this->wiki->source);
+ − 37
}
+ − 38
+ − 39
function post()
+ − 40
{
+ − 41
return;
+ − 42
}
+ − 43
+ − 44
+ − 45
/**
+ − 46
* Method to render text
+ − 47
*
+ − 48
* @access public
+ − 49
* @param string $text the text to render
+ − 50
* @return rendered text
+ − 51
*
+ − 52
*/
+ − 53
+ − 54
function textEncode($text)
+ − 55
{
+ − 56
// attempt to translate HTML entities in the source.
+ − 57
// get the config options.
+ − 58
$type = $this->getConf('translate', HTML_ENTITIES);
+ − 59
$quotes = $this->getConf('quotes', ENT_COMPAT);
+ − 60
$charset = $this->getConf('charset', 'ISO-8859-1');
+ − 61
+ − 62
// have to check null and false because HTML_ENTITIES is a zero
+ − 63
if ($type === HTML_ENTITIES) {
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
diff
changeset
+ − 64
/*
1
+ − 65
+ − 66
// keep a copy of the translated version of the delimiter
+ − 67
// so we can convert it back.
+ − 68
$new_delim = htmlentities($this->wiki->delim, $quotes, $charset);
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
diff
changeset
+ − 69
1
+ − 70
// convert the entities. we silence the call here so that
+ − 71
// errors about charsets don't pop up, per counsel from
+ − 72
// Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474)
+ − 73
$text = @htmlentities(
+ − 74
$text,
+ − 75
$quotes,
+ − 76
$charset
+ − 77
);
+ − 78
+ − 79
// Mod for Enano: undo any HTML cleaning - we will take care of this ourselves
+ − 80
$text = str_replace(Array('<', '>', '"', '&', '''),
+ − 81
Array('<', '>', '"', '&', "'" ),
+ − 82
$text);
+ − 83
+ − 84
// re-convert the delimiter
+ − 85
$text = str_replace(
+ − 86
$new_delim, $this->wiki->delim, $text
+ − 87
);
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
diff
changeset
+ − 88
*/
1
+ − 89
+ − 90
} elseif ($type === HTML_SPECIALCHARS) {
+ − 91
+ − 92
// keep a copy of the translated version of the delimiter
+ − 93
// so we can convert it back.
+ − 94
$new_delim = htmlspecialchars($this->wiki->delim, $quotes,
+ − 95
$charset);
+ − 96
+ − 97
// convert the entities. we silence the call here so that
+ − 98
// errors about charsets don't pop up, per counsel from
+ − 99
// Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474)
+ − 100
$text = @htmlspecialchars(
+ − 101
$text,
+ − 102
$quotes,
+ − 103
$charset
+ − 104
);
+ − 105
+ − 106
// re-convert the delimiter
+ − 107
$text = str_replace(
+ − 108
$new_delim, $this->wiki->delim, $text
+ − 109
);
+ − 110
}
+ − 111
return $text;
+ − 112
}
+ − 113
}
+ − 114
?>