1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-04 21:28:06 +02:00

Convert to PHP 5 only codebase, adding visibility modifiers to all members and methods in the main library area (function only for test methods)

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1458 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-11-25 02:24:39 +00:00
parent 85a23bacb6
commit 43f01925cd
195 changed files with 1003 additions and 1064 deletions

View File

@@ -8,15 +8,15 @@ class HTMLPurifier_DefinitionCache_Decorator extends HTMLPurifier_DefinitionCach
/**
* Cache object we are decorating
*/
var $cache;
public $cache;
function HTMLPurifier_DefinitionCache_Decorator() {}
public function HTMLPurifier_DefinitionCache_Decorator() {}
/**
* Lazy decorator function
* @param $cache Reference to cache object to decorate
*/
function decorate(&$cache) {
public function decorate(&$cache) {
$decorator = $this->copy();
// reference is necessary for mocks in PHP 4
$decorator->cache =& $cache;
@@ -27,31 +27,35 @@ class HTMLPurifier_DefinitionCache_Decorator extends HTMLPurifier_DefinitionCach
/**
* Cross-compatible clone substitute
*/
function copy() {
public function copy() {
return new HTMLPurifier_DefinitionCache_Decorator();
}
function add($def, $config) {
public function add($def, $config) {
return $this->cache->add($def, $config);
}
function set($def, $config) {
public function set($def, $config) {
return $this->cache->set($def, $config);
}
function replace($def, $config) {
public function replace($def, $config) {
return $this->cache->replace($def, $config);
}
function get($config) {
public function get($config) {
return $this->cache->get($config);
}
function flush($config) {
public function remove($config) {
return $this->cache->remove($config);
}
public function flush($config) {
return $this->cache->flush($config);
}
function cleanup($config) {
public function cleanup($config) {
return $this->cache->cleanup($config);
}

View File

@@ -10,31 +10,31 @@ class HTMLPurifier_DefinitionCache_Decorator_Cleanup extends
HTMLPurifier_DefinitionCache_Decorator
{
var $name = 'Cleanup';
public $name = 'Cleanup';
function copy() {
public function copy() {
return new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
}
function add($def, $config) {
public function add($def, $config) {
$status = parent::add($def, $config);
if (!$status) parent::cleanup($config);
return $status;
}
function set($def, $config) {
public function set($def, $config) {
$status = parent::set($def, $config);
if (!$status) parent::cleanup($config);
return $status;
}
function replace($def, $config) {
public function replace($def, $config) {
$status = parent::replace($def, $config);
if (!$status) parent::cleanup($config);
return $status;
}
function get($config) {
public function get($config) {
$ret = parent::get($config);
if (!$ret) parent::cleanup($config);
return $ret;

View File

@@ -11,32 +11,32 @@ class HTMLPurifier_DefinitionCache_Decorator_Memory extends
HTMLPurifier_DefinitionCache_Decorator
{
var $definitions;
var $name = 'Memory';
protected $definitions;
public $name = 'Memory';
function copy() {
public function copy() {
return new HTMLPurifier_DefinitionCache_Decorator_Memory();
}
function add($def, $config) {
public function add($def, $config) {
$status = parent::add($def, $config);
if ($status) $this->definitions[$this->generateKey($config)] = $def;
return $status;
}
function set($def, $config) {
public function set($def, $config) {
$status = parent::set($def, $config);
if ($status) $this->definitions[$this->generateKey($config)] = $def;
return $status;
}
function replace($def, $config) {
public function replace($def, $config) {
$status = parent::replace($def, $config);
if ($status) $this->definitions[$this->generateKey($config)] = $def;
return $status;
}
function get($config) {
public function get($config) {
$key = $this->generateKey($config);
if (isset($this->definitions[$key])) return $this->definitions[$key];
$this->definitions[$key] = parent::get($config);

View File

@@ -8,27 +8,31 @@ require_once 'HTMLPurifier/DefinitionCache.php';
class HTMLPurifier_DefinitionCache_Null extends HTMLPurifier_DefinitionCache
{
function add($def, $config) {
public function add($def, $config) {
return false;
}
function set($def, $config) {
public function set($def, $config) {
return false;
}
function replace($def, $config) {
public function replace($def, $config) {
return false;
}
function get($config) {
public function remove($config) {
return false;
}
function flush($config) {
public function get($config) {
return false;
}
function cleanup($config) {
public function flush($config) {
return false;
}
public function cleanup($config) {
return false;
}

View File

@@ -17,7 +17,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
HTMLPurifier_DefinitionCache
{
function add($def, $config) {
public function add($def, $config) {
if (!$this->checkDefType($def)) return;
$file = $this->generateFilePath($config);
if (file_exists($file)) return false;
@@ -25,14 +25,14 @@ class HTMLPurifier_DefinitionCache_Serializer extends
return $this->_write($file, serialize($def));
}
function set($def, $config) {
public function set($def, $config) {
if (!$this->checkDefType($def)) return;
$file = $this->generateFilePath($config);
if (!$this->_prepareDir($config)) return false;
return $this->_write($file, serialize($def));
}
function replace($def, $config) {
public function replace($def, $config) {
if (!$this->checkDefType($def)) return;
$file = $this->generateFilePath($config);
if (!file_exists($file)) return false;
@@ -40,19 +40,19 @@ class HTMLPurifier_DefinitionCache_Serializer extends
return $this->_write($file, serialize($def));
}
function get($config) {
public function get($config) {
$file = $this->generateFilePath($config);
if (!file_exists($file)) return false;
return unserialize(file_get_contents($file));
}
function remove($config) {
public function remove($config) {
$file = $this->generateFilePath($config);
if (!file_exists($file)) return false;
return unlink($file);
}
function flush($config) {
public function flush($config) {
if (!$this->_prepareDir($config)) return false;
$dir = $this->generateDirectoryPath($config);
$dh = opendir($dir);
@@ -63,7 +63,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
}
}
function cleanup($config) {
public function cleanup($config) {
if (!$this->_prepareDir($config)) return false;
$dir = $this->generateDirectoryPath($config);
$dh = opendir($dir);
@@ -78,8 +78,9 @@ class HTMLPurifier_DefinitionCache_Serializer extends
/**
* Generates the file path to the serial file corresponding to
* the configuration and definition name
* @todo Make protected
*/
function generateFilePath($config) {
public function generateFilePath($config) {
$key = $this->generateKey($config);
return $this->generateDirectoryPath($config) . '/' . $key . '.ser';
}
@@ -87,8 +88,9 @@ class HTMLPurifier_DefinitionCache_Serializer extends
/**
* Generates the path to the directory contain this cache's serial files
* @note No trailing slash
* @todo Make protected
*/
function generateDirectoryPath($config) {
public function generateDirectoryPath($config) {
$base = $this->generateBaseDirectoryPath($config);
return $base . '/' . $this->type;
}
@@ -96,8 +98,9 @@ class HTMLPurifier_DefinitionCache_Serializer extends
/**
* Generates path to base directory that contains all definition type
* serials
* @todo Make protected
*/
function generateBaseDirectoryPath($config) {
public function generateBaseDirectoryPath($config) {
$base = $config->get('Cache', 'SerializerPath');
$base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base;
return $base;
@@ -109,7 +112,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
* @param $data Data to write into file
* @return Number of bytes written if success, or false if failure.
*/
function _write($file, $data) {
private function _write($file, $data) {
static $file_put_contents;
if ($file_put_contents === null) {
$file_put_contents = function_exists('file_put_contents');
@@ -128,7 +131,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
* Prepares the directory that this type stores the serials in
* @return True if successful
*/
function _prepareDir($config) {
private function _prepareDir($config) {
$directory = $this->generateDirectoryPath($config);
if (!is_dir($directory)) {
$base = $this->generateBaseDirectoryPath($config);
@@ -151,7 +154,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
* Tests permissions on a directory and throws out friendly
* error messages and attempts to chmod it itself if possible
*/
function _testPermissions($dir) {
private function _testPermissions($dir) {
// early abort, if it is writable, everything is hunky-dory
if (is_writable($dir)) return true;
if (!is_dir($dir)) {