You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.3KB

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