Whoops, forgot to edit WHATSNEW
[htmlpurifier.git] / smoketests / extractStyleBlocks.php
blobbb330b5f229f6f672c69e3098028c8fd9d7b97cb
1 <?php
3 require_once 'common.php';
4 require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
6 // need CSSTidy location
7 $csstidy_location = false;
8 if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
9 if (file_exists('../test-settings.php')) include '../test-settings.php';
11 if (!$csstidy_location) {
13 Error: <a href="http://csstidy.sourceforge.net/">CSSTidy</a> library not
14 found, please install and configure <code>test-settings.php</code>
15 accordingly.
16 <?php
17 exit;
20 require_once $csstidy_location . 'class.csstidy.php';
21 require_once $csstidy_location . 'class.csstidy_print.php';
23 $purifier = new HTMLPurifier(array(
24 'Filter.ExtractStyleBlocks' => true,
25 ));
27 $html = isset($_POST['html']) ? $_POST['html'] : '';
28 $purified_html = $purifier->purify($html);
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>Extract Style Blocks - HTML Purifier Smoketest</title>
36 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
37 <?php
39 // generate style blocks
40 foreach ($purifier->context->get('StyleBlocks') as $style) {
41 ?><style type="text/css">
42 <!--/*--><![CDATA[/*><!--*/
43 <?php echo $style; ?>
45 /*]]>*/-->
46 </style>
47 <?php
51 </head>
52 <body>
53 <h1>Extract Style Blocks</h1>
54 <p>
55 This smoketest allows users to specify global style sheets for the
56 document, allowing for interesting techniques and compact markup
57 that wouldn't normally be possible, using the ExtractStyleBlocks filter.
58 </p>
59 <p>
60 User submitted content:
61 </p>
62 <div style="border: 1px solid #CCC; margin: 1em; padding: 1em;">
63 <?php echo $purified_html ?>
64 </div>
65 <form action="" method="post">
66 <textarea cols="100" rows="20" name="html"><?php echo escapeHTML($html) ?></textarea>
67 <input type="submit" value="Submit" />
68 </form>
69 </body>
70 </html>
71 <?php
73 // vim: et sw=4 sts=4