Add 4.0.0 release information.
[htmlpurifier/darkodev.git] / smoketests / configForm.php
blob90e80ac56aa5e3cbe4aa5ab8c87d4f5e04fcda8e
1 <?php
3 require_once 'common.php';
5 // Setup environment
6 require_once '../extras/HTMLPurifierExtras.auto.php';
7 $interchange = HTMLPurifier_ConfigSchema_InterchangeBuilder::buildFromDirectory('test-schema/');
8 $interchange->validate();
10 if (isset($_GET['doc'])) {
12 // Hijack page generation to supply documentation
14 if (file_exists('test-schema.html') && !isset($_GET['purge'])) {
15 echo file_get_contents('test-schema.html');
16 exit;
19 $style = 'plain';
20 $configdoc_xml = 'test-schema.xml';
22 $xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
23 $xml_builder->openURI($configdoc_xml);
24 $xml_builder->build($interchange);
25 unset($xml_builder); // free handle
27 $xslt = new ConfigDoc_HTMLXSLTProcessor();
28 $xslt->importStylesheet("../configdoc/styles/$style.xsl");
29 $xslt->setParameters(array(
30 'css' => '../configdoc/styles/plain.css',
31 ));
32 $html = $xslt->transformToHTML($configdoc_xml);
34 unlink('test-schema.xml');
35 file_put_contents('test-schema.html', $html);
36 echo $html;
38 exit;
41 ?><!DOCTYPE html
42 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
43 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
44 <html>
45 <head>
46 <title>HTML Purifier Config Form Smoketest</title>
47 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
48 <link rel="stylesheet" href="../library/HTMLPurifier/Printer/ConfigForm.css" type="text/css" />
49 <script defer="defer" type="text/javascript" src="../library/HTMLPurifier/Printer/ConfigForm.js"></script>
50 </head>
51 <body>
52 <h1>HTML Purifier Config Form Smoketest</h1>
53 <p>This file outputs the configuration form for every single type
54 of directive possible.</p>
55 <form id="htmlpurifier-config" name="htmlpurifier-config" method="get" action=""
56 style="float:right;">
57 <?php
59 $schema_builder = new HTMLPurifier_ConfigSchema_Builder_ConfigSchema();
60 $schema = $schema_builder->build($interchange);
62 $config = HTMLPurifier_Config::loadArrayFromForm($_GET, 'config', true, true, $schema);
63 $printer = new HTMLPurifier_Printer_ConfigForm('config', '?doc#%s');
64 echo $printer->render(array(HTMLPurifier_Config::createDefault(), $config));
67 </form>
68 <pre>
69 <?php
70 echo htmlspecialchars(var_export($config->getAll(), true));
72 </pre>
73 </body>
74 </html>
75 <?php
77 // vim: et sw=4 sts=4