clean_utf8 = $config->get('Core', 'CleanUTF8DuringGeneration'); if (!$tokens) return ''; foreach ($tokens as $token) { $html .= $this->generateFromToken($token); } return $html; } function generateFromToken($token) { if (!isset($token->type)) return ''; if ($token->type == 'start') { $attr = $this->generateAttributes($token->attributes); return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; } elseif ($token->type == 'end') { return 'name . '>'; } elseif ($token->type == 'empty') { $attr = $this->generateAttributes($token->attributes); return '<' . $token->name . ($attr ? ' ' : '') . $attr . ' />'; } elseif ($token->type == 'text') { return $this->escape($token->data); } else { return ''; } } function generateAttributes($assoc_array_of_attributes) { $html = ''; foreach ($assoc_array_of_attributes as $key => $value) { $html .= $key.'="'.$this->escape($value).'" '; } return rtrim($html); } function escape($string) { if ($this->clean_utf8) $string = HTMLPurifier_Lexer::cleanUTF8($string); return htmlspecialchars($string, ENT_COMPAT, 'UTF-8'); } } ?>