Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

46 lines
1.3KB

  1. #!/usr/bin/php
  2. <?php
  3. require_once dirname(__FILE__) . '/common.php';
  4. require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
  5. assertCli();
  6. /**
  7. * @file
  8. * Generates a schema cache file, saving it to
  9. * library/HTMLPurifier/ConfigSchema/schema.ser.
  10. *
  11. * This should be run when new configuration options are added to
  12. * HTML Purifier. A cached version is available via the repository
  13. * so this does not normally have to be regenerated.
  14. *
  15. * If you have a directory containing custom configuration schema files,
  16. * you can simple add a path to that directory as a parameter to
  17. * this, and they will get included.
  18. */
  19. $target = dirname(__FILE__) . '/../library/HTMLPurifier/ConfigSchema/schema.ser';
  20. $builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
  21. $interchange = new HTMLPurifier_ConfigSchema_Interchange();
  22. $builder->buildDir($interchange);
  23. $loader = dirname(__FILE__) . '/../config-schema.php';
  24. if (file_exists($loader)) include $loader;
  25. foreach ($_SERVER['argv'] as $i => $dir) {
  26. if ($i === 0) continue;
  27. $builder->buildDir($interchange, realpath($dir));
  28. }
  29. $interchange->validate();
  30. $schema_builder = new HTMLPurifier_ConfigSchema_Builder_ConfigSchema();
  31. $schema = $schema_builder->build($interchange);
  32. echo "Saving schema... ";
  33. file_put_contents($target, serialize($schema));
  34. echo "done!\n";
  35. // vim: et sw=4 sts=4