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
|
|
|
|
* library/HTMLPurifier/ConfigSchema/schema.ser
|
|
|
|
*/
|
|
|
|
|
|
|
|
$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-02-10 20:34:39 +00:00
|
|
|
|
|
|
|
$namespaces = array();
|
|
|
|
$directives = array();
|
|
|
|
|
|
|
|
// Generate string hashes
|
2008-02-24 06:19:28 +00:00
|
|
|
$parser = new HTMLPurifier_ConfigSchema_StringHashParser();
|
2008-02-10 20:34:39 +00:00
|
|
|
foreach ($files as $file) {
|
|
|
|
$hash = $parser->parseFile($file);
|
|
|
|
if (strpos($hash['ID'], '.') === false) {
|
|
|
|
$namespaces[] = $hash;
|
|
|
|
} else {
|
|
|
|
$directives[] = $hash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-24 06:19:28 +00:00
|
|
|
$adapter = new HTMLPurifier_ConfigSchema_StringHashAdapter();
|
2008-02-10 20:34:39 +00:00
|
|
|
$schema = new HTMLPurifier_ConfigSchema();
|
|
|
|
|
|
|
|
foreach ($namespaces as $hash) $adapter->adapt($hash, $schema);
|
|
|
|
foreach ($directives as $hash) $adapter->adapt($hash, $schema);
|
|
|
|
|
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";
|