2008-02-10 20:34:39 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
chdir(dirname(__FILE__));
|
|
|
|
require_once 'common.php';
|
|
|
|
require_once '../library/HTMLPurifier.auto.php';
|
|
|
|
assertCli();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Generates a schema cache file from the contents of
|
2008-04-03 22:39:50 +00:00
|
|
|
* library/HTMLPurifier/ConfigSchema/schema.ser.
|
|
|
|
*
|
|
|
|
* This should be run when new configuration options are added to
|
|
|
|
* HTML Purifier. A cached version is available via SVN so this does not
|
|
|
|
* normally have to be regenerated.
|
2008-02-10 20:34:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
$target = '../library/HTMLPurifier/ConfigSchema/schema.ser';
|
|
|
|
$FS = new FSTools();
|
|
|
|
|
2008-02-24 05:59:57 +00:00
|
|
|
$files = $FS->globr('../library/HTMLPurifier/ConfigSchema/schema', '*.txt');
|
2008-04-03 20:52:08 +00:00
|
|
|
if (!$files) throw new Exception('Did not find any schema files');
|
2008-02-10 20:34:39 +00:00
|
|
|
|
2008-03-22 19:30:37 +00:00
|
|
|
$parser = new HTMLPurifier_StringHashParser();
|
2008-03-22 03:55:59 +00:00
|
|
|
$builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
|
|
|
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
2008-02-10 20:34:39 +00:00
|
|
|
foreach ($files as $file) {
|
2008-03-22 19:30:37 +00:00
|
|
|
$builder->build($interchange, new HTMLPurifier_StringHash($parser->parseFile($file)));
|
2008-02-10 20:34:39 +00:00
|
|
|
}
|
|
|
|
|
2008-03-22 20:26:04 +00:00
|
|
|
$validator = new HTMLPurifier_ConfigSchema_Validator();
|
|
|
|
$validator->validate($interchange);
|
|
|
|
|
2008-03-22 03:55:59 +00:00
|
|
|
$schema_builder = new HTMLPurifier_ConfigSchema_Builder_ConfigSchema();
|
|
|
|
$schema = $schema_builder->build($interchange);
|
2008-02-10 20:34:39 +00:00
|
|
|
|
2008-02-24 05:06:39 +00:00
|
|
|
echo "Saving schema... ";
|
2008-02-10 20:34:39 +00:00
|
|
|
file_put_contents($target, serialize($schema));
|
2008-02-24 05:06:39 +00:00
|
|
|
echo "done!\n";
|