NEWS for 4.9.2
[htmlpurifier.git] / smoketests / allConfigForm.php
blob2677d7b8523b6c779207cacea46629ade6dbe0f2
1 <?php
3 require_once 'common.php'; // load library
5 require_once 'HTMLPurifier/Printer/ConfigForm.php';
7 $config = HTMLPurifier_Config::loadArrayFromForm($_POST, 'config');
9 // you can do custom configuration!
10 if (file_exists('allConfigForm.settings.php')) {
11 include 'allConfigForm.settings.php';
14 $gen_config = HTMLPurifier_Config::createDefault();
16 $printer_config_form = new HTMLPurifier_Printer_ConfigForm(
17 'config',
18 'http://htmlpurifier.org/live/configdoc/plain.html#%s'
21 $purifier = new HTMLPurifier($config);
22 $html = isset($_POST['html']) ? $_POST['html'] : "";
23 $purified = $purifier->purify($html);
25 echo '<?xml version="1.0" encoding="UTF-8" ?>';
28 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
29 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
30 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
31 <head>
32 <title>HTML Purifier All Config Form smoketest</title>
33 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
34 <style type="text/css">
35 .hp-config {margin-left:auto; margin-right:auto;}
36 .HTMLPurifier_Printer table {border-collapse:collapse;
37 border:1px solid #000; width:600px;
38 margin:1em auto;font-family:sans-serif;font-size:75%;}
39 .HTMLPurifier_Printer td, .HTMLPurifier_Printer th {padding:3px;
40 border:1px solid #000;background:#CCC; vertical-align: baseline;}
41 .HTMLPurifier_Printer th {text-align:left;background:#CCF;width:20%;}
42 .HTMLPurifier_Printer caption {font-size:1.5em; font-weight:bold;}
43 .HTMLPurifier_Printer .heavy {background:#99C;text-align:center;}
44 .HTMLPurifier_Printer .unsafe {background:#C99;}
45 dt {font-weight:bold;}
46 </style>
47 <link rel="stylesheet" href="../library/HTMLPurifier/Printer/ConfigForm.css" type="text/css" />
48 <script defer="defer" type="text/javascript" src="../library/HTMLPurifier/Printer/ConfigForm.js"></script>
49 </head>
50 <body>
52 <h1>HTML Purifier All Config Form Smoketest</h1>
54 <p>This prints config form for everything we support.</p>
56 <form method="post" action="" name="hp-configform">
57 <table style="width:100%">
58 <tr><th>Input</th><th>Output</th>
59 <tr><td style="width:50%">
60 <textarea name="html" style="width:100%" rows="15"><?php echo htmlspecialchars($html) ?></textarea>
61 </td><td style="width:50%">
62 <textarea name="result" style="width:100%" rows="15"><?php echo htmlspecialchars($purified) ?></textarea>
63 </td></tr>
64 </table>
65 <input type="submit" />
66 <?php
67 echo $printer_config_form->render($config);
69 </form>
70 <pre><?php
71 echo htmlspecialchars(var_export($config->getAll(), true));
72 ?></pre>
73 <?php
75 // vim: et sw=4 sts=4