Support for flashvars in HTML.SafeEmbed.
[htmlpurifier.git] / configdoc / generate.php
blobe0c4e674ae4f4443215585d3b5e8d8bd8059677b
1 <?php
3 /**
4 * Generates XML and HTML documents describing configuration.
5 * @note PHP 5.2+ only!
6 */
8 /*
9 TODO:
10 - make XML format richer
11 - extend XSLT transformation (see the corresponding XSLT file)
12 - allow generation of packaged docs that can be easily moved
13 - multipage documentation
14 - determine how to multilingualize
15 - add blurbs to ToC
18 if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
19 error_reporting(E_ALL | E_STRICT);
21 // load dual-libraries
22 require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
23 require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
25 // setup HTML Purifier singleton
26 HTMLPurifier::getInstance(array(
27 'AutoFormat.PurifierLinkify' => true
28 ));
30 $builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
31 $interchange = new HTMLPurifier_ConfigSchema_Interchange();
32 $builder->buildDir($interchange);
33 $loader = dirname(__FILE__) . '/../config-schema.php';
34 if (file_exists($loader)) include $loader;
35 $interchange->validate();
37 $style = 'plain'; // use $_GET in the future, careful to validate!
38 $configdoc_xml = dirname(__FILE__) . '/configdoc.xml';
40 $xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
41 $xml_builder->openURI($configdoc_xml);
42 $xml_builder->build($interchange);
43 unset($xml_builder); // free handle
45 $xslt = new ConfigDoc_HTMLXSLTProcessor();
46 $xslt->importStylesheet(dirname(__FILE__) . "/styles/$style.xsl");
47 $output = $xslt->transformToHTML($configdoc_xml);
49 if (!$output) {
50 echo "Error in generating files\n";
51 exit(1);
54 // write out
55 file_put_contents(dirname(__FILE__) . "/$style.html", $output);
57 if (php_sapi_name() != 'cli') {
58 // output (instant feedback if it's a browser)
59 echo $output;
60 } else {
61 echo "Files generated successfully.\n";
64 // vim: et sw=4 sts=4