0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-19 18:55:19 +00:00
htmlpurifier/smoketests/configForm.php
Edward Z. Yang 14d934c7ca [3.1.1] Land vs's HTMLPurifier_Generator patch, and a number of other bugfixes for that change
- Convert a number of calls to use new constructor signature for Generator
- Make generator require configuration; this exposes a number of latent bugs
- Removed generator hack
- Convert Printers to use new optimized ConfigSchema format
- Hack with Printer configuration; pass an array(generator config, render config) to distinguish between output and target.
- HTML/CSS Printers need to be primed, otherwise fatal errors
- Convert a few test-cases to use member properties

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1770 48356398-32a2-884e-a903-53898d9a118a
2008-05-26 04:05:48 +00:00

75 lines
2.3 KiB
PHP

<?php
require_once 'common.php';
// Setup environment
require_once '../extras/HTMLPurifierExtras.auto.php';
$interchange = HTMLPurifier_ConfigSchema_InterchangeBuilder::buildFromDirectory('test-schema/');
$interchange->validate();
if (isset($_GET['doc'])) {
// Hijack page generation to supply documentation
if (file_exists('test-schema.html') && !isset($_GET['purge'])) {
echo file_get_contents('test-schema.html');
exit;
}
$style = 'plain';
$configdoc_xml = 'test-schema.xml';
$xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
$xml_builder->openURI($configdoc_xml);
$xml_builder->build($interchange);
unset($xml_builder); // free handle
$xslt = new ConfigDoc_HTMLXSLTProcessor();
$xslt->importStylesheet("../configdoc/styles/$style.xsl");
$xslt->setParameters(array(
'css' => '../configdoc/styles/plain.css',
));
$html = $xslt->transformToHTML($configdoc_xml);
unlink('test-schema.xml');
file_put_contents('test-schema.html', $html);
echo $html;
exit;
}
?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML Purifier Config Form Smoketest</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../library/HTMLPurifier/Printer/ConfigForm.css" type="text/css" />
<script defer="defer" type="text/javascript" src="../library/HTMLPurifier/Printer/ConfigForm.js"></script>
</head>
<body>
<h1>HTML Purifier Config Form Smoketest</h1>
<p>This file outputs the configuration form for every single type
of directive possible.</p>
<form id="htmlpurifier-config" name="htmlpurifier-config" method="get" action=""
style="float:right;">
<?php
$schema_builder = new HTMLPurifier_ConfigSchema_Builder_ConfigSchema();
$schema = $schema_builder->build($interchange);
$config = HTMLPurifier_Config::loadArrayFromForm($_GET, 'config', true, true, $schema);
$printer = new HTMLPurifier_Printer_ConfigForm('config', '?doc#%s');
echo $printer->render(array(HTMLPurifier_Config::createDefault(), $config));
?>
</form>
<pre>
<?php
echo htmlspecialchars(var_export($config->getAll(), true));
?>
</pre>
</body>
</html>