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.

74 line
1.9KB

  1. <?php
  2. require_once 'common.php';
  3. require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
  4. // need CSSTidy location
  5. $csstidy_location = false;
  6. if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
  7. if (file_exists('../test-settings.php')) include '../test-settings.php';
  8. if (!$csstidy_location) {
  9. ?>
  10. Error: <a href="http://csstidy.sourceforge.net/">CSSTidy</a> library not
  11. found, please install and configure <code>test-settings.php</code>
  12. accordingly.
  13. <?php
  14. exit;
  15. }
  16. require_once $csstidy_location . 'class.csstidy.php';
  17. require_once $csstidy_location . 'class.csstidy_print.php';
  18. $purifier = new HTMLPurifier(array(
  19. 'Filter.ExtractStyleBlocks' => true,
  20. ));
  21. $html = isset($_POST['html']) ? $_POST['html'] : '';
  22. $purified_html = $purifier->purify($html);
  23. ?><!DOCTYPE html
  24. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  25. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <html>
  27. <head>
  28. <title>Extract Style Blocks - HTML Purifier Smoketest</title>
  29. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  30. <?php
  31. // generate style blocks
  32. foreach ($purifier->context->get('StyleBlocks') as $style) {
  33. ?><style type="text/css">
  34. <!--/*--><![CDATA[/*><!--*/
  35. <?php echo $style; ?>
  36. /*]]>*/-->
  37. </style>
  38. <?php
  39. }
  40. ?>
  41. </head>
  42. <body>
  43. <h1>Extract Style Blocks</h1>
  44. <p>
  45. This smoketest allows users to specify global style sheets for the
  46. document, allowing for interesting techniques and compact markup
  47. that wouldn't normally be possible, using the ExtractStyleBlocks filter.
  48. </p>
  49. <p>
  50. User submitted content:
  51. </p>
  52. <div style="border: 1px solid #CCC; margin: 1em; padding: 1em;">
  53. <?php echo $purified_html ?>
  54. </div>
  55. <form action="" method="post">
  56. <textarea cols="100" rows="20" name="html"><?php echo escapeHTML($html) ?></textarea>
  57. <input type="submit" value="Submit" />
  58. </form>
  59. </body>
  60. </html>
  61. <?php
  62. // vim: et sw=4 sts=4