aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php
diff options
context:
space:
mode:
authorKlaus <Klaus.Weidenbach@gmx.net>2017-03-27 21:39:02 +0200
committerGitHub <noreply@github.com>2017-03-27 21:39:02 +0200
commit6375401e0af6c52d151dd2b944aa6a054b8ddc05 (patch)
tree982ab84421ffa8ee2c48f38cc2d1eef11853dbf6 /vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php
parentb6b62506c5f4ed5bc354d548702538bda36aff36 (diff)
parentf718e2b0db0fe3477212a8dd6c3ec067f4432862 (diff)
downloadvolse-hubzilla-6375401e0af6c52d151dd2b944aa6a054b8ddc05.tar.gz
volse-hubzilla-6375401e0af6c52d151dd2b944aa6a054b8ddc05.tar.bz2
volse-hubzilla-6375401e0af6c52d151dd2b944aa6a054b8ddc05.zip
Merge pull request #701 from dawnbreak/HTMLpurifier
HTMLPurifier library update
Diffstat (limited to 'vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php')
-rw-r--r--vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php b/vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php
new file mode 100644
index 000000000..514a08dd9
--- /dev/null
+++ b/vendor/ezyang/htmlpurifier/maintenance/old-extract-schema.php
@@ -0,0 +1,71 @@
+#!/usr/bin/php
+<?php
+
+chdir(dirname(__FILE__));
+require_once 'common.php';
+assertCli();
+
+echo "Please do not run this script. It is here for historical purposes only.";
+exit;
+
+/**
+ * @file
+ * Extracts all definitions inside a configuration schema
+ * (HTMLPurifier_ConfigSchema) and exports them as plain text files.
+ *
+ * @todo Extract version numbers.
+ */
+
+define('HTMLPURIFIER_SCHEMA_STRICT', true); // description data needs to be collected
+require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
+
+// We need includes to ensure all HTMLPurifier_ConfigSchema calls are
+// performed.
+require_once 'HTMLPurifier.includes.php';
+
+// Also, these extra files will be necessary.
+require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
+
+/**
+ * Takes a hash and saves its contents to library/HTMLPurifier/ConfigSchema/
+ */
+function saveHash($hash)
+{
+ if ($hash === false) return;
+ $dir = realpath(dirname(__FILE__) . '/../library/HTMLPurifier/ConfigSchema');
+ $name = $hash['ID'] . '.txt';
+ $file = $dir . '/' . $name;
+ if (file_exists($file)) {
+ trigger_error("File already exists; skipped $name");
+ return;
+ }
+ $file = new FSTools_File($file);
+ $file->open('w');
+ $multiline = false;
+ foreach ($hash as $key => $value) {
+ $multiline = $multiline || (strpos($value, "\n") !== false);
+ if ($multiline) {
+ $file->put("--$key--" . PHP_EOL);
+ $file->put(str_replace("\n", PHP_EOL, $value) . PHP_EOL);
+ } else {
+ if ($key == 'ID') {
+ $file->put("$value" . PHP_EOL);
+ } else {
+ $file->put("$key: $value" . PHP_EOL);
+ }
+ }
+ }
+ $file->close();
+}
+
+$schema = HTMLPurifier_ConfigSchema::instance();
+$adapter = new HTMLPurifier_ConfigSchema_StringHashReverseAdapter($schema);
+
+foreach ($schema->info as $ns => $ns_array) {
+ saveHash($adapter->get($ns));
+ foreach ($ns_array as $dir => $x) {
+ saveHash($adapter->get($ns, $dir));
+ }
+}
+
+// vim: et sw=4 sts=4