1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 21:57:26 +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

@@ -12,26 +12,27 @@ class HTMLPurifier_Printer
/**
* Instance of HTMLPurifier_Generator for HTML generation convenience funcs
*/
var $generator;
protected $generator;
/**
* Instance of HTMLPurifier_Config, for easy access
*/
var $config;
protected $config;
/**
* Initialize $generator.
*/
function HTMLPurifier_Printer() {
public function HTMLPurifier_Printer() {
$this->generator = new HTMLPurifier_Generator();
}
/**
* Give generator necessary configuration if possible
*/
function prepareGenerator($config) {
public function prepareGenerator($config) {
// hack for smoketests/configForm.php
if (empty($config->conf['HTML'])) return;
$all = $config->getAll();
if (empty($all['HTML'])) return;
$context = new HTMLPurifier_Context();
$this->generator->generateFromTokens(array(), $config, $context);
}
@@ -47,7 +48,7 @@ class HTMLPurifier_Printer
* @param $tag Tag name
* @param $attr Attribute array
*/
function start($tag, $attr = array()) {
protected function start($tag, $attr = array()) {
return $this->generator->generateFromToken(
new HTMLPurifier_Token_Start($tag, $attr ? $attr : array())
);
@@ -57,7 +58,7 @@ class HTMLPurifier_Printer
* Returns an end teg
* @param $tag Tag name
*/
function end($tag) {
protected function end($tag) {
return $this->generator->generateFromToken(
new HTMLPurifier_Token_End($tag)
);
@@ -70,19 +71,19 @@ class HTMLPurifier_Printer
* @param $attr Tag attributes
* @param $escape Bool whether or not to escape contents
*/
function element($tag, $contents, $attr = array(), $escape = true) {
protected function element($tag, $contents, $attr = array(), $escape = true) {
return $this->start($tag, $attr) .
($escape ? $this->escape($contents) : $contents) .
$this->end($tag);
}
function elementEmpty($tag, $attr = array()) {
protected function elementEmpty($tag, $attr = array()) {
return $this->generator->generateFromToken(
new HTMLPurifier_Token_Empty($tag, $attr)
);
}
function text($text) {
protected function text($text) {
return $this->generator->generateFromToken(
new HTMLPurifier_Token_Text($text)
);
@@ -93,7 +94,7 @@ class HTMLPurifier_Printer
* @param $name Key
* @param $value Value
*/
function row($name, $value) {
protected function row($name, $value) {
if (is_bool($value)) $value = $value ? 'On' : 'Off';
return
$this->start('tr') . "\n" .
@@ -107,7 +108,7 @@ class HTMLPurifier_Printer
* Escapes a string for HTML output.
* @param $string String to escape
*/
function escape($string) {
protected function escape($string) {
$string = HTMLPurifier_Encoder::cleanUTF8($string);
$string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
return $string;
@@ -118,7 +119,7 @@ class HTMLPurifier_Printer
* @param $array List of strings
* @param $polite Bool whether or not to add an end before the last
*/
function listify($array, $polite = false) {
protected function listify($array, $polite = false) {
if (empty($array)) return 'None';
$ret = '';
$i = count($array);
@@ -136,7 +137,7 @@ class HTMLPurifier_Printer
* @param $obj Object to determine class of
* @param $prefix Further prefix to remove
*/
function getClass($obj, $sec_prefix = '') {
protected function getClass($obj, $sec_prefix = '') {
static $five = null;
if ($five === null) $five = version_compare(PHP_VERSION, '5', '>=');
$prefix = 'HTMLPurifier_' . $sec_prefix;
@@ -152,14 +153,14 @@ class HTMLPurifier_Printer
}
$class .= implode(', ', $values);
break;
case 'composite':
case 'css_composite':
$values = array();
foreach ($obj->defs as $def) {
$values[] = $this->getClass($def, $sec_prefix);
}
$class .= implode(', ', $values);
break;
case 'multiple':
case 'css_multiple':
$class .= $this->getClass($obj->single, $sec_prefix) . ', ';
$class .= $obj->max;
break;