2006-09-10 02:02:40 +00:00
|
|
|
<?php
|
|
|
|
|
2006-09-11 02:52:47 +00:00
|
|
|
/**
|
|
|
|
* Generates XML and HTML documents describing configuration.
|
2008-02-26 01:45:03 +00:00
|
|
|
* @note PHP 5.2+ only!
|
2006-09-11 02:52:47 +00:00
|
|
|
*/
|
|
|
|
|
2006-09-10 20:21:19 +00:00
|
|
|
/*
|
|
|
|
TODO:
|
2008-02-26 01:45:03 +00:00
|
|
|
- make XML format richer
|
2006-09-10 20:21:19 +00:00
|
|
|
- extend XSLT transformation (see the corresponding XSLT file)
|
|
|
|
- allow generation of packaged docs that can be easily moved
|
|
|
|
- multipage documentation
|
|
|
|
- determine how to multilingualize
|
2007-05-29 21:26:43 +00:00
|
|
|
- add blurbs to ToC
|
2006-09-10 20:21:19 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-25 21:21:12 +00:00
|
|
|
if (version_compare(PHP_VERSION, '5.2.0', '<')) exit('PHP 5.2.0 or greater required.');
|
|
|
|
error_reporting(E_ALL | E_STRICT);
|
2006-09-10 02:02:40 +00:00
|
|
|
|
2008-04-22 01:58:06 +00:00
|
|
|
chdir(dirname(__FILE__));
|
2007-07-31 01:04:38 +00:00
|
|
|
|
2007-05-28 03:58:02 +00:00
|
|
|
// load dual-libraries
|
2008-02-25 21:21:12 +00:00
|
|
|
require_once '../extras/HTMLPurifierExtras.auto.php';
|
|
|
|
require_once '../library/HTMLPurifier.auto.php';
|
2006-09-10 02:02:40 +00:00
|
|
|
|
2008-02-25 21:21:12 +00:00
|
|
|
// setup HTML Purifier singleton
|
|
|
|
HTMLPurifier::getInstance(array(
|
2007-06-24 22:22:00 +00:00
|
|
|
'AutoFormat.PurifierLinkify' => true
|
|
|
|
));
|
|
|
|
|
2008-04-22 01:58:06 +00:00
|
|
|
$interchange = HTMLPurifier_ConfigSchema_InterchangeBuilder::buildFromDirectory();
|
|
|
|
$interchange->validate();
|
|
|
|
|
|
|
|
$style = 'plain'; // use $_GET in the future, careful to validate!
|
|
|
|
$configdoc_xml = 'configdoc.xml';
|
|
|
|
|
|
|
|
$xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
|
|
|
|
$xml_builder->openURI($configdoc_xml);
|
|
|
|
$xml_builder->build($interchange);
|
|
|
|
|
|
|
|
$xslt = new ConfigDoc_HTMLXSLTProcessor();
|
|
|
|
$xslt->importStylesheet(dirname(__FILE__) . "/styles/$style.xsl");
|
|
|
|
$output = $xslt->transformToHTML($configdoc_xml);
|
2006-09-11 02:52:47 +00:00
|
|
|
|
2008-02-25 21:21:12 +00:00
|
|
|
if (!$output) {
|
|
|
|
echo "Error in generating files\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2007-05-28 03:58:02 +00:00
|
|
|
// write out
|
|
|
|
file_put_contents("$style.html", $output);
|
2006-09-11 02:52:47 +00:00
|
|
|
|
2006-09-10 22:47:27 +00:00
|
|
|
if (php_sapi_name() != 'cli') {
|
2008-02-25 21:21:12 +00:00
|
|
|
// output (instant feedback if it's a browser)
|
2007-05-28 03:58:02 +00:00
|
|
|
echo $output;
|
2006-09-10 22:47:27 +00:00
|
|
|
} else {
|
2006-09-10 22:53:40 +00:00
|
|
|
echo 'Files generated successfully.';
|
2006-09-10 22:47:27 +00:00
|
|
|
}
|
2006-09-10 02:02:40 +00:00
|
|
|
|