1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +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

@@ -164,6 +164,23 @@ class HTMLPurifier
return $array_of_html;
}
/**
* Singleton for enforcing just one HTML Purifier in your system
*/
function &getInstance($prototype = null) {
static $htmlpurifier;
if (!$htmlpurifier || $prototype) {
if (is_a($prototype, 'HTMLPurifier')) {
$htmlpurifier = $prototype;
} elseif ($prototype) {
$htmlpurifier = new HTMLPurifier(HTMLPurifier_Config::create($prototype));
} else {
$htmlpurifier = new HTMLPurifier();
}
}
return $htmlpurifier;
}
}

View File

@@ -297,6 +297,23 @@ class HTMLPurifier_Config
}
}
/**
* Loads configuration values from $_GET/$_POST that were posted
* via ConfigForm
* @static
*/
function loadArrayFromForm($array) {
$mq = get_magic_quotes_gpc();
foreach ($array as $key => $value) {
if (!strncmp($key, 'Null_', 5) && !empty($value)) {
unset($array[substr($key, 5)]);
unset($array[$key]);
}
if ($mq) $array[$key] = stripslashes($value);
}
return @HTMLPurifier_Config::create($array);
}
/**
* Loads configuration values from an ini file
* @param $filename Name of ini file