ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
old-extract-schema.php
Go to the documentation of this file.
1#!/usr/bin/php
2<?php
3
4chdir(dirname(__FILE__));
5require_once 'common.php';
7
8echo "Please do not run this script. It is here for historical purposes only.";
10
19define('HTMLPURIFIER_SCHEMA_STRICT', true); // description data needs to be collected
20require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
21
22// We need includes to ensure all HTMLPurifier_ConfigSchema calls are
23// performed.
24require_once 'HTMLPurifier.includes.php';
25
26// Also, these extra files will be necessary.
27require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
28
32function saveHash($hash)
33{
34 if ($hash === false) return;
35 $dir = realpath(dirname(__FILE__) . '/../library/HTMLPurifier/ConfigSchema');
36 $name = $hash['ID'] . '.txt';
37 $file = $dir . '/' . $name;
38 if (file_exists($file)) {
39 trigger_error("File already exists; skipped $name");
40 return;
41 }
43 $file->open('w');
44 $multiline = false;
45 foreach ($hash as $key => $value) {
46 $multiline = $multiline || (strpos($value, "\n") !== false);
47 if ($multiline) {
48 $file->put("--$key--" . PHP_EOL);
49 $file->put(str_replace("\n", PHP_EOL, $value) . PHP_EOL);
50 } else {
51 if ($key == 'ID') {
52 $file->put("$value" . PHP_EOL);
53 } else {
54 $file->put("$key: $value" . PHP_EOL);
55 }
56 }
57 }
58 $file->close();
59}
60
62$adapter = new HTMLPurifier_ConfigSchema_StringHashReverseAdapter($schema);
63
64foreach ($schema->info as $ns => $ns_array) {
65 saveHash($adapter->get($ns));
66 foreach ($ns_array as $dir => $x) {
67 saveHash($adapter->get($ns, $dir));
68 }
69}
70
71// vim: et sw=4 sts=4
An exception for terminatinating execution or to throw for unit testing.
Represents a file in the filesystem.
Definition: File.php:11
static instance($prototype=null)
Retrieves an instance of the application-wide configuration definition.
assertCli()
Definition: common.php:3
$key
Definition: croninfo.php:18
$x
Definition: example_009.php:98
if($format !==null) $name
Definition: metadata.php:146
saveHash($hash)
Takes a hash and saves its contents to library/HTMLPurifier/ConfigSchema/.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file