MDL-14898 upgraded html purifier to 3.1.0 in HEAD
This commit is contained in:
@@ -1,44 +1,26 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/DefinitionCache.php';
|
||||
require_once 'HTMLPurifier/DefinitionCache/Serializer.php';
|
||||
|
||||
HTMLPurifier_ConfigSchema::define(
|
||||
'Cache', 'DefinitionImpl', 'Serializer', 'string/null', '
|
||||
This directive defines which method to use when caching definitions,
|
||||
the complex data-type that makes HTML Purifier tick. Set to null
|
||||
to disable caching (not recommended, as you will see a definite
|
||||
performance degradation). This directive has been available since 2.0.0.
|
||||
');
|
||||
|
||||
HTMLPurifier_ConfigSchema::defineAlias(
|
||||
'Core', 'DefinitionCache',
|
||||
'Cache', 'DefinitionImpl'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for creating definition caches.
|
||||
*/
|
||||
class HTMLPurifier_DefinitionCacheFactory
|
||||
{
|
||||
|
||||
var $caches = array('Serializer' => array());
|
||||
var $implementations = array();
|
||||
var $decorators = array();
|
||||
protected $caches = array('Serializer' => array());
|
||||
protected $implementations = array();
|
||||
protected $decorators = array();
|
||||
|
||||
/**
|
||||
* Initialize default decorators
|
||||
*/
|
||||
function setup() {
|
||||
public function setup() {
|
||||
$this->addDecorator('Cleanup');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an instance of global definition cache factory.
|
||||
* @static
|
||||
*/
|
||||
function &instance($prototype = null) {
|
||||
public static function instance($prototype = null) {
|
||||
static $instance;
|
||||
if ($prototype !== null) {
|
||||
$instance = $prototype;
|
||||
@@ -54,7 +36,7 @@ class HTMLPurifier_DefinitionCacheFactory
|
||||
* @param $short Short name of cache object, for reference
|
||||
* @param $long Full class name of cache object, for construction
|
||||
*/
|
||||
function register($short, $long) {
|
||||
public function register($short, $long) {
|
||||
$this->implementations[$short] = $long;
|
||||
}
|
||||
|
||||
@@ -63,18 +45,17 @@ class HTMLPurifier_DefinitionCacheFactory
|
||||
* @param $name Name of definitions handled by cache
|
||||
* @param $config Instance of HTMLPurifier_Config
|
||||
*/
|
||||
function &create($type, $config) {
|
||||
public function create($type, $config) {
|
||||
$method = $config->get('Cache', 'DefinitionImpl');
|
||||
if ($method === null) {
|
||||
$null = new HTMLPurifier_DefinitionCache_Null($type);
|
||||
return $null;
|
||||
return new HTMLPurifier_DefinitionCache_Null($type);
|
||||
}
|
||||
if (!empty($this->caches[$method][$type])) {
|
||||
return $this->caches[$method][$type];
|
||||
}
|
||||
if (
|
||||
isset($this->implementations[$method]) &&
|
||||
class_exists($class = $this->implementations[$method])
|
||||
class_exists($class = $this->implementations[$method], false)
|
||||
) {
|
||||
$cache = new $class($type);
|
||||
} else {
|
||||
@@ -97,7 +78,7 @@ class HTMLPurifier_DefinitionCacheFactory
|
||||
* Registers a decorator to add to all new cache objects
|
||||
* @param
|
||||
*/
|
||||
function addDecorator($decorator) {
|
||||
public function addDecorator($decorator) {
|
||||
if (is_string($decorator)) {
|
||||
$class = "HTMLPurifier_DefinitionCache_Decorator_$decorator";
|
||||
$decorator = new $class;
|
||||
|
||||
Reference in New Issue
Block a user