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-04-22 22:28:54 +00:00
|
|
|
if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
|
2008-02-25 21:21:12 +00:00
|
|
|
error_reporting(E_ALL | E_STRICT);
|
2006-09-10 02:02:40 +00:00
|
|
|
|
2007-05-28 03:58:02 +00:00
|
|
|
// load dual-libraries
|
2009-05-30 02:10:47 +00:00
|
|
|
require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
|
|
|
|
require_once dirname(__FILE__) . '/../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
|
|
|
|
));
|
|
|
|
|
2009-05-30 02:10:47 +00:00
|
|
|
$builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
|
|
|
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
|
|
|
$builder->buildDir($interchange);
|
|
|
|
$loader = dirname(__FILE__) . '/../config-schema.php';
|
|
|
|
if (file_exists($loader)) include $loader;
|
2008-04-22 01:58:06 +00:00
|
|
|
$interchange->validate();
|
|
|
|
|
|
|
|
$style = 'plain'; // use $_GET in the future, careful to validate!
|
2009-05-30 02:10:47 +00:00
|
|
|
$configdoc_xml = dirname(__FILE__) . '/configdoc.xml';
|
2008-04-22 01:58:06 +00:00
|
|
|
|
|
|
|
$xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
|
|
|
|
$xml_builder->openURI($configdoc_xml);
|
|
|
|
$xml_builder->build($interchange);
|
2008-04-26 01:13:58 +00:00
|
|
|
unset($xml_builder); // free handle
|
2008-04-22 01:58:06 +00:00
|
|
|
|
|
|
|
$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
|
2009-05-30 02:10:47 +00:00
|
|
|
file_put_contents(dirname(__FILE__) . "/$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 {
|
2009-05-30 02:10:47 +00:00
|
|
|
echo "Files generated successfully.\n";
|
2006-09-10 22:47:27 +00:00
|
|
|
}
|
2006-09-10 02:02:40 +00:00
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|