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,12 +7,11 @@
|
||||
|
||||
/*
|
||||
TODO:
|
||||
- make XML format richer (see below)
|
||||
- make XML format richer (see XMLSerializer_ConfigSchema)
|
||||
- extend XSLT transformation (see the corresponding XSLT file)
|
||||
- allow generation of packaged docs that can be easily moved
|
||||
- multipage documentation
|
||||
- determine how to multilingualize
|
||||
- factor out code into classes
|
||||
*/
|
||||
|
||||
// there are several hacks for the configForm.php smoketest
|
||||
@@ -37,53 +36,17 @@ require_once 'library/ConfigDoc.auto.php';
|
||||
// ---------------------------------------------------------------------------
|
||||
// Load copies of HTMLPurifier_ConfigDef and HTMLPurifier
|
||||
|
||||
// hack
|
||||
if (defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
|
||||
// included from somewhere else
|
||||
$var = HTMLPURIFIER_CUSTOM_SCHEMA;
|
||||
$schema = $$var;
|
||||
chdir(dirname(__FILE__));
|
||||
} else {
|
||||
$schema = HTMLPurifier_ConfigSchema::instance();
|
||||
}
|
||||
$purifier = new HTMLPurifier();
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate types.xml, a document describing the constraint "type"
|
||||
|
||||
$types_serializer = new ConfigDoc_XMLSerializer_Types();
|
||||
$types_document = $types_serializer->serialize($schema);
|
||||
$types_document->save('types.xml');
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate configdoc.xml, a document documenting configuration directives
|
||||
|
||||
$schema_serializer = new ConfigDoc_XMLSerializer_ConfigSchema();
|
||||
$dom_document = $schema_serializer->serialize($schema);
|
||||
$dom_document->save('configdoc.xml');
|
||||
|
||||
$schema = HTMLPurifier_ConfigSchema::instance();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate final output using XSLT
|
||||
|
||||
// determine stylesheet name
|
||||
$xsl_stylesheet_name = 'plain';
|
||||
$xsl_stylesheet = "styles/$xsl_stylesheet_name.xsl";
|
||||
$xsl_stylesheet_name = 'plain'; // use $_GET in the future
|
||||
$configdoc = new ConfigDoc();
|
||||
$html_output = $configdoc->generate($schema, $xsl_stylesheet_name);
|
||||
|
||||
// transform
|
||||
$xslt_processor = new ConfigDoc_HTMLXSLTProcessor();
|
||||
$xslt_processor->importStylesheet($xsl_stylesheet);
|
||||
$html_output = $xslt_processor->transformToHTML($dom_document);
|
||||
|
||||
// hack
|
||||
if (!defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
|
||||
// write it to a file (todo: parse into seperate pages)
|
||||
file_put_contents("$xsl_stylesheet_name.html", $html_output);
|
||||
} elseif (defined('HTMLPURIFIER_SCRIPT_LOCATION')) {
|
||||
$html_output = str_replace('styles/plain.css', HTMLPURIFIER_SCRIPT_LOCATION . 'styles/plain.css', $html_output);
|
||||
}
|
||||
file_put_contents("$xsl_stylesheet_name.html", $html_output);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Output for instant feedback
|
||||
|
Reference in New Issue
Block a user