Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

65 lines
1.8KB

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