Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

old-extract-schema.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/php
  2. <?php
  3. chdir(dirname(__FILE__));
  4. require_once 'common.php';
  5. assertCli();
  6. echo "Please do not run this script. It is here for historical purposes only.";
  7. exit;
  8. /**
  9. * @file
  10. * Extracts all definitions inside a configuration schema
  11. * (HTMLPurifier_ConfigSchema) and exports them as plain text files.
  12. *
  13. * @todo Extract version numbers.
  14. */
  15. define('HTMLPURIFIER_SCHEMA_STRICT', true); // description data needs to be collected
  16. require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
  17. // We need includes to ensure all HTMLPurifier_ConfigSchema calls are
  18. // performed.
  19. require_once 'HTMLPurifier.includes.php';
  20. // Also, these extra files will be necessary.
  21. require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
  22. /**
  23. * Takes a hash and saves its contents to library/HTMLPurifier/ConfigSchema/
  24. */
  25. function saveHash($hash)
  26. {
  27. if ($hash === false) return;
  28. $dir = realpath(dirname(__FILE__) . '/../library/HTMLPurifier/ConfigSchema');
  29. $name = $hash['ID'] . '.txt';
  30. $file = $dir . '/' . $name;
  31. if (file_exists($file)) {
  32. trigger_error("File already exists; skipped $name");
  33. return;
  34. }
  35. $file = new FSTools_File($file);
  36. $file->open('w');
  37. $multiline = false;
  38. foreach ($hash as $key => $value) {
  39. $multiline = $multiline || (strpos($value, "\n") !== false);
  40. if ($multiline) {
  41. $file->put("--$key--" . PHP_EOL);
  42. $file->put(str_replace("\n", PHP_EOL, $value) . PHP_EOL);
  43. } else {
  44. if ($key == 'ID') {
  45. $file->put("$value" . PHP_EOL);
  46. } else {
  47. $file->put("$key: $value" . PHP_EOL);
  48. }
  49. }
  50. }
  51. $file->close();
  52. }
  53. $schema = HTMLPurifier_ConfigSchema::instance();
  54. $adapter = new HTMLPurifier_ConfigSchema_StringHashReverseAdapter($schema);
  55. foreach ($schema->info as $ns => $ns_array) {
  56. saveHash($adapter->get($ns));
  57. foreach ($ns_array as $dir => $x) {
  58. saveHash($adapter->get($ns, $dir));
  59. }
  60. }
  61. // vim: et sw=4 sts=4