1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

Further refactoring to remove hacks. Move everything into the ConfigDoc facade object. Add parameters to plain.xsl. Optionally singleton-ize HTML Purifier. Add loadArrayFromForm to Config object.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1105 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-05-28 03:33:12 +00:00
parent aaf4839c34
commit e06929c218
9 changed files with 112 additions and 67 deletions

View File

@@ -3,12 +3,37 @@
require_once 'common.php';
if (isset($_GET['doc'])) {
if (
file_exists('testSchema.html') &&
filemtime('testSchema.php') < filemtime('testSchema.html') &&
!isset($_GET['purge'])
) {
echo file_get_contents('testSchema.html');
exit;
}
if (version_compare('5', PHP_VERSION, '>')) exit('Requires PHP 5 or higher.');
// setup schema for parsing
require_once 'testSchema.php';
$new_schema = $custom_schema;
HTMLPurifier_ConfigSchema::instance($old);
define('HTMLPURIFIER_CUSTOM_SCHEMA', 'new_schema');
define('HTMLPURIFIER_SCRIPT_LOCATION', '../configdoc/');
require_once '../configdoc/generate.php';
$new_schema = $custom_schema; // dereference the reference
HTMLPurifier_ConfigSchema::instance($old); // restore old version
// setup ConfigDoc environment
require_once '../configdoc/library/ConfigDoc.auto.php';
// perform the ConfigDoc generation
$configdoc = new ConfigDoc();
$html = $configdoc->generate($new_schema, 'plain', array(
'css' => '../configdoc/styles/plain.css',
'title' => 'Sample Configuration Documentation'
));
$configdoc->cleanup();
file_put_contents('testSchema.html', $html);
echo $html;
exit;
}
@@ -37,17 +62,7 @@ require_once 'HTMLPurifier/Printer/ConfigForm.php';
require_once 'testSchema.php';
// cleanup ( this should be rolled into Config )
$get = isset($_GET) ? $_GET : array();
$mq = get_magic_quotes_gpc();
foreach ($_GET as $key => $value) {
if (!strncmp($key, 'Null_', 5) && !empty($value)) {
unset($get[substr($key, 5)]);
unset($get[$key]);
}
if ($mq) $get[$key] = stripslashes($value);
}
$config = @HTMLPurifier_Config::create($get);
$config = HTMLPurifier_Config::loadArrayFromForm($_GET);
$printer = new HTMLPurifier_Printer_ConfigForm('?doc');
echo $printer->render($config);