aboutsummaryrefslogtreecommitdiffstats
path: root/lib/htmlpurifier/configdoc/generate.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-12 17:57:41 -0700
committerfriendica <info@friendica.com>2012-07-18 20:40:31 +1000
commit7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch)
treea9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/configdoc/generate.php
parentcd727cb26b78a1dade09d510b071446898477356 (diff)
downloadvolse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/configdoc/generate.php')
-rw-r--r--lib/htmlpurifier/configdoc/generate.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/htmlpurifier/configdoc/generate.php b/lib/htmlpurifier/configdoc/generate.php
new file mode 100644
index 000000000..e0c4e674a
--- /dev/null
+++ b/lib/htmlpurifier/configdoc/generate.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * Generates XML and HTML documents describing configuration.
+ * @note PHP 5.2+ only!
+ */
+
+/*
+TODO:
+- make XML format richer
+- extend XSLT transformation (see the corresponding XSLT file)
+- allow generation of packaged docs that can be easily moved
+- multipage documentation
+- determine how to multilingualize
+- add blurbs to ToC
+*/
+
+if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
+error_reporting(E_ALL | E_STRICT);
+
+// load dual-libraries
+require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
+require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
+
+// setup HTML Purifier singleton
+HTMLPurifier::getInstance(array(
+ 'AutoFormat.PurifierLinkify' => true
+));
+
+$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;
+$interchange->validate();
+
+$style = 'plain'; // use $_GET in the future, careful to validate!
+$configdoc_xml = dirname(__FILE__) . '/configdoc.xml';
+
+$xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
+$xml_builder->openURI($configdoc_xml);
+$xml_builder->build($interchange);
+unset($xml_builder); // free handle
+
+$xslt = new ConfigDoc_HTMLXSLTProcessor();
+$xslt->importStylesheet(dirname(__FILE__) . "/styles/$style.xsl");
+$output = $xslt->transformToHTML($configdoc_xml);
+
+if (!$output) {
+ echo "Error in generating files\n";
+ exit(1);
+}
+
+// write out
+file_put_contents(dirname(__FILE__) . "/$style.html", $output);
+
+if (php_sapi_name() != 'cli') {
+ // output (instant feedback if it's a browser)
+ echo $output;
+} else {
+ echo "Files generated successfully.\n";
+}
+
+// vim: et sw=4 sts=4