45 protected function start($tag, $attr = array()) {
46 return $this->generator->generateFromToken(
55 protected function end($tag) {
56 return $this->generator->generateFromToken(
68 protected function element($tag, $contents, $attr = array(), $escape =
true) {
69 return $this->
start($tag, $attr) .
70 ($escape ? $this->
escape($contents) : $contents) .
75 return $this->generator->generateFromToken(
80 protected function text($text) {
81 return $this->generator->generateFromToken(
91 protected function row($name, $value) {
92 if (is_bool($value)) $value = $value ?
'On' :
'Off';
94 $this->
start(
'tr') .
"\n" .
95 $this->
element(
'th', $name) .
"\n" .
96 $this->
element(
'td', $value) .
"\n" .
107 $string = htmlspecialchars($string, ENT_COMPAT,
'UTF-8');
116 protected function listify($array, $polite =
false) {
117 if (empty($array))
return 'None';
120 foreach ($array as $value) {
123 if ($i > 0 && !($polite && $i == 1))
$ret .=
', ';
124 if ($polite && $i == 1)
$ret .=
'and ';
134 protected function getClass($obj, $sec_prefix =
'') {
136 if ($five === null) $five = version_compare(PHP_VERSION,
'5',
'>=');
137 $prefix =
'HTMLPurifier_' . $sec_prefix;
138 if (!$five) $prefix = strtolower($prefix);
139 $class = str_replace($prefix,
'', get_class($obj));
140 $lclass = strtolower($class);
145 foreach ($obj->valid_values as $value => $bool) {
148 $class .= implode(
', ', $values);
150 case 'css_composite':
152 foreach ($obj->defs as $def) {
153 $values[] = $this->
getClass($def, $sec_prefix);
155 $class .= implode(
', ', $values);
158 $class .= $this->
getClass($obj->single, $sec_prefix) .
', ';
161 case 'css_denyelementdecorator':
162 $class .= $this->
getClass($obj->def, $sec_prefix) .
', ';
163 $class .= $obj->element;
165 case 'css_importantdecorator':
166 $class .= $this->
getClass($obj->def, $sec_prefix);
167 if ($obj->allow) $class .=
', !important';