mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
[3.1.0] De-crudify the ConfigSchema space; we're starting over again
- Optimize ConfigSchema by removing non-essential runtime data. We can probably optimize even more by collapsing object structures to arrays. - Removed validation data from ConfigSchema; this will be reimplemented on Interchange - Implement a sane Interchange composite hierarchy that doesn't use arrays - Implement StringHash -> Interchange -> ConfigSchema, and rewrite maintenance file to account for this git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1615 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -17,25 +17,15 @@ $FS = new FSTools();
|
||||
|
||||
$files = $FS->globr('../library/HTMLPurifier/ConfigSchema/schema', '*.txt');
|
||||
|
||||
$namespaces = array();
|
||||
$directives = array();
|
||||
|
||||
// Generate string hashes
|
||||
$parser = new HTMLPurifier_ConfigSchema_StringHashParser();
|
||||
$parser = new HTMLPurifier_ConfigSchema_StringHashParser();
|
||||
$builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
||||
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
||||
foreach ($files as $file) {
|
||||
$hash = $parser->parseFile($file);
|
||||
if (strpos($hash['ID'], '.') === false) {
|
||||
$namespaces[] = $hash;
|
||||
} else {
|
||||
$directives[] = $hash;
|
||||
}
|
||||
$builder->build($interchange, $parser->parseFile($file));
|
||||
}
|
||||
|
||||
$adapter = new HTMLPurifier_ConfigSchema_StringHashAdapter();
|
||||
$schema = new HTMLPurifier_ConfigSchema();
|
||||
|
||||
foreach ($namespaces as $hash) $adapter->adapt($hash, $schema);
|
||||
foreach ($directives as $hash) $adapter->adapt($hash, $schema);
|
||||
$schema_builder = new HTMLPurifier_ConfigSchema_Builder_ConfigSchema();
|
||||
$schema = $schema_builder->build($interchange);
|
||||
|
||||
echo "Saving schema... ";
|
||||
file_put_contents($target, serialize($schema));
|
||||
|
Reference in New Issue
Block a user