mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
Further refactoring to remove hacks. Move everything into the ConfigDoc facade object. Add parameters to plain.xsl. Optionally singleton-ize HTML Purifier. Add loadArrayFromForm to Config object.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1105 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -7,7 +7,33 @@ require_once 'ConfigDoc/XMLSerializer/ConfigSchema.php';
|
||||
class ConfigDoc
|
||||
{
|
||||
|
||||
// useless...
|
||||
function generate($schema, $xsl_stylesheet_name = 'plain', $parameters = array()) {
|
||||
// generate types document, describing type constraints
|
||||
$types_serializer = new ConfigDoc_XMLSerializer_Types();
|
||||
$types_document = $types_serializer->serialize($schema);
|
||||
$types_document->save('types.xml');
|
||||
|
||||
// generate configdoc.xml, documents configuration directives
|
||||
$schema_serializer = new ConfigDoc_XMLSerializer_ConfigSchema();
|
||||
$schema_document = $schema_serializer->serialize($schema);
|
||||
$schema_document->save('configdoc.xml');
|
||||
|
||||
// setup transformation
|
||||
$xsl_stylesheet = dirname(__FILE__) . "/../styles/$xsl_stylesheet_name.xsl";
|
||||
$xslt_processor = new ConfigDoc_HTMLXSLTProcessor();
|
||||
$xslt_processor->setParameters($parameters);
|
||||
$xslt_processor->importStylesheet($xsl_stylesheet);
|
||||
|
||||
return $xslt_processor->transformToHTML($schema_document);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any generated files
|
||||
*/
|
||||
function cleanup() {
|
||||
unlink('types.xml');
|
||||
unlink('configdoc.xml');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -51,6 +51,12 @@ class ConfigDoc_HTMLXSLTProcessor
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function setParameters($options) {
|
||||
foreach ($options as $name => $value) {
|
||||
$this->xsltProcessor->setParameter('', $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -9,8 +9,7 @@ class ConfigDoc_XMLSerializer
|
||||
{
|
||||
|
||||
protected function appendHTMLDiv($document, $node, $html) {
|
||||
// oh no, it's a global!
|
||||
global $purifier;
|
||||
$purifier = HTMLPurifier::getInstance();
|
||||
$html = $purifier->purify($html);
|
||||
$dom_html = $document->createDocumentFragment();
|
||||
$dom_html->appendXML($html);
|
||||
|
@@ -95,8 +95,8 @@ class ConfigDoc_XMLSerializer_ConfigSchema extends ConfigDoc_XMLSerializer
|
||||
foreach ($info->descriptions as $file => $file_descriptions) {
|
||||
foreach ($file_descriptions as $line => $description) {
|
||||
$dom_description = $dom_document->createElement('description');
|
||||
// hack
|
||||
if (!defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
|
||||
// refuse to write $file if it's a full path
|
||||
if (str_replace('\\', '/', realpath($file)) != $file) {
|
||||
$dom_description->setAttribute('file', $file);
|
||||
$dom_description->setAttribute('line', $line);
|
||||
}
|
||||
|
Reference in New Issue
Block a user