mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-10 09:16:20 +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:
@ -10,12 +10,12 @@ require_once 'HTMLPurifier/AttrTransform/BdoDir.php';
|
||||
class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Bdo';
|
||||
var $attr_collections = array(
|
||||
public $name = 'Bdo';
|
||||
public $attr_collections = array(
|
||||
'I18N' => array('dir' => false)
|
||||
);
|
||||
|
||||
function HTMLPurifier_HTMLModule_Bdo() {
|
||||
public function HTMLPurifier_HTMLModule_Bdo() {
|
||||
$bdo =& $this->addElement(
|
||||
'bdo', true, 'Inline', 'Inline', array('Core', 'Lang'),
|
||||
array(
|
||||
|
@ -4,9 +4,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
|
||||
class HTMLPurifier_HTMLModule_CommonAttributes extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
var $name = 'CommonAttributes';
|
||||
public $name = 'CommonAttributes';
|
||||
|
||||
var $attr_collections = array(
|
||||
public $attr_collections = array(
|
||||
'Core' => array(
|
||||
0 => array('Style'),
|
||||
// 'xml:space' => false,
|
||||
|
@ -10,9 +10,9 @@ require_once 'HTMLPurifier/ChildDef/Chameleon.php';
|
||||
class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Edit';
|
||||
public $name = 'Edit';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Edit() {
|
||||
public function HTMLPurifier_HTMLModule_Edit() {
|
||||
$contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow';
|
||||
$attr = array(
|
||||
'cite' => 'URI',
|
||||
@ -29,8 +29,8 @@ class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
|
||||
// Inline context ! Block context (exclamation mark is
|
||||
// separator, see getChildDef for parsing)
|
||||
|
||||
var $defines_child_def = true;
|
||||
function getChildDef($def) {
|
||||
public $defines_child_def = true;
|
||||
public function getChildDef($def) {
|
||||
if ($def->content_model_type != 'chameleon') return false;
|
||||
$value = explode('!', $def->content_model);
|
||||
return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]);
|
||||
|
@ -9,9 +9,9 @@ require_once 'HTMLPurifier/AttrDef/HTML/LinkTypes.php';
|
||||
class HTMLPurifier_HTMLModule_Hypertext extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Hypertext';
|
||||
public $name = 'Hypertext';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Hypertext() {
|
||||
public function HTMLPurifier_HTMLModule_Hypertext() {
|
||||
$a =& $this->addElement(
|
||||
'a', true, 'Inline', 'Inline', 'Common',
|
||||
array(
|
||||
|
@ -13,9 +13,9 @@ require_once 'HTMLPurifier/AttrTransform/ImgRequired.php';
|
||||
class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Image';
|
||||
public $name = 'Image';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Image() {
|
||||
public function HTMLPurifier_HTMLModule_Image() {
|
||||
$img =& $this->addElement(
|
||||
'img', true, 'Inline', 'Empty', 'Common',
|
||||
array(
|
||||
|
@ -21,11 +21,9 @@ require_once 'HTMLPurifier/AttrDef/HTML/Bool.php';
|
||||
class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
// incomplete
|
||||
public $name = 'Legacy';
|
||||
|
||||
var $name = 'Legacy';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Legacy() {
|
||||
public function HTMLPurifier_HTMLModule_Legacy() {
|
||||
|
||||
$this->addElement('basefont', true, 'Inline', 'Empty', false, array(
|
||||
'color' => 'Color',
|
||||
|
@ -8,7 +8,7 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'List';
|
||||
public $name = 'List';
|
||||
|
||||
// According to the abstract schema, the List content set is a fully formed
|
||||
// one or more expr, but it invariably occurs in an optional declaration
|
||||
@ -19,9 +19,9 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
|
||||
// we don't have support for such nested expressions without using
|
||||
// the incredibly inefficient and draconic Custom ChildDef.
|
||||
|
||||
var $content_sets = array('Flow' => 'List');
|
||||
public $content_sets = array('Flow' => 'List');
|
||||
|
||||
function HTMLPurifier_HTMLModule_List() {
|
||||
public function HTMLPurifier_HTMLModule_List() {
|
||||
$this->addElement('ol', true, 'List', 'Required: li', 'Common');
|
||||
$this->addElement('ul', true, 'List', 'Required: li', 'Common');
|
||||
$this->addElement('dl', true, 'List', 'Required: dt | dd', 'Common');
|
||||
|
@ -4,9 +4,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
|
||||
class HTMLPurifier_HTMLModule_NonXMLCommonAttributes extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
var $name = 'NonXMLCommonAttributes';
|
||||
public $name = 'NonXMLCommonAttributes';
|
||||
|
||||
var $attr_collections = array(
|
||||
public $attr_collections = array(
|
||||
'Lang' => array(
|
||||
'lang' => 'LanguageCode',
|
||||
)
|
||||
|
@ -10,9 +10,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
class HTMLPurifier_HTMLModule_Object extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Object';
|
||||
public $name = 'Object';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Object() {
|
||||
public function HTMLPurifier_HTMLModule_Object() {
|
||||
|
||||
$this->addElement('object', false, 'Inline', 'Optional: #PCDATA | Flow | param', 'Common',
|
||||
array(
|
||||
|
@ -15,9 +15,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
class HTMLPurifier_HTMLModule_Presentation extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Presentation';
|
||||
public $name = 'Presentation';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Presentation() {
|
||||
public function HTMLPurifier_HTMLModule_Presentation() {
|
||||
$this->addElement('b', true, 'Inline', 'Inline', 'Common');
|
||||
$this->addElement('big', true, 'Inline', 'Inline', 'Common');
|
||||
$this->addElement('hr', true, 'Block', 'Empty', 'Common');
|
||||
|
@ -9,9 +9,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
class HTMLPurifier_HTMLModule_Ruby extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Ruby';
|
||||
public $name = 'Ruby';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Ruby() {
|
||||
public function HTMLPurifier_HTMLModule_Ruby() {
|
||||
$this->addElement('ruby', true, 'Inline',
|
||||
'Custom: ((rb, (rt | (rp, rt, rp))) | (rbc, rtc, rtc?))',
|
||||
'Common');
|
||||
|
@ -12,7 +12,7 @@ INSIDE HTML PURIFIER DOCUMENTS. USE ONLY WITH TRUSTED USER INPUT!!!
|
||||
*/
|
||||
class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransform
|
||||
{
|
||||
function transform($attr, $config, &$context) {
|
||||
public function transform($attr, $config, &$context) {
|
||||
if (!isset($attr['type'])) {
|
||||
$attr['type'] = 'text/javascript';
|
||||
}
|
||||
@ -28,11 +28,11 @@ class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransfo
|
||||
*/
|
||||
class HTMLPurifier_HTMLModule_Scripting extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
var $name = 'Scripting';
|
||||
var $elements = array('script', 'noscript');
|
||||
var $content_sets = array('Block' => 'script | noscript', 'Inline' => 'script | noscript');
|
||||
public $name = 'Scripting';
|
||||
public $elements = array('script', 'noscript');
|
||||
public $content_sets = array('Block' => 'script | noscript', 'Inline' => 'script | noscript');
|
||||
|
||||
function HTMLPurifier_HTMLModule_Scripting() {
|
||||
public function HTMLPurifier_HTMLModule_Scripting() {
|
||||
// TODO: create custom child-definition for noscript that
|
||||
// auto-wraps stray #PCDATA in a similar manner to
|
||||
// blockquote's custom definition (we would use it but
|
||||
|
@ -10,15 +10,15 @@ require_once 'HTMLPurifier/AttrDef/CSS.php';
|
||||
class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'StyleAttribute';
|
||||
var $attr_collections = array(
|
||||
public $name = 'StyleAttribute';
|
||||
public $attr_collections = array(
|
||||
// The inclusion routine differs from the Abstract Modules but
|
||||
// is in line with the DTD and XML Schemas.
|
||||
'Style' => array('style' => false), // see constructor
|
||||
'Core' => array(0 => array('Style'))
|
||||
);
|
||||
|
||||
function HTMLPurifier_HTMLModule_StyleAttribute() {
|
||||
public function HTMLPurifier_HTMLModule_StyleAttribute() {
|
||||
$this->attr_collections['Style']['style'] = new HTMLPurifier_AttrDef_CSS();
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ require_once 'HTMLPurifier/ChildDef/Table.php';
|
||||
class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Tables';
|
||||
public $name = 'Tables';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Tables() {
|
||||
public function HTMLPurifier_HTMLModule_Tables() {
|
||||
|
||||
$this->addElement('caption', true, false, 'Inline', 'Common');
|
||||
|
||||
|
@ -8,9 +8,9 @@ require_once 'HTMLPurifier/AttrDef/HTML/FrameTarget.php';
|
||||
class HTMLPurifier_HTMLModule_Target extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Target';
|
||||
public $name = 'Target';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Target() {
|
||||
public function HTMLPurifier_HTMLModule_Target() {
|
||||
$elements = array('a');
|
||||
foreach ($elements as $name) {
|
||||
$e =& $this->addBlankElement($name);
|
||||
|
@ -17,12 +17,12 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
|
||||
var $name = 'Text';
|
||||
var $content_sets = array(
|
||||
public $name = 'Text';
|
||||
public $content_sets = array(
|
||||
'Flow' => 'Heading | Block | Inline'
|
||||
);
|
||||
|
||||
function HTMLPurifier_HTMLModule_Text() {
|
||||
public function HTMLPurifier_HTMLModule_Text() {
|
||||
|
||||
// Inline Phrasal -------------------------------------------------
|
||||
$this->addElement('abbr', true, 'Inline', 'Inline', 'Common');
|
||||
|
@ -39,6 +39,7 @@ directive has been available since 2.0.0.
|
||||
/**
|
||||
* Abstract class for a set of proprietary modules that clean up (tidy)
|
||||
* poorly written HTML.
|
||||
* @todo Figure out how to protect some of these methods/properties
|
||||
*/
|
||||
class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
@ -47,18 +48,18 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* List of supported levels. Index zero is a special case "no fixes"
|
||||
* level.
|
||||
*/
|
||||
var $levels = array(0 => 'none', 'light', 'medium', 'heavy');
|
||||
public $levels = array(0 => 'none', 'light', 'medium', 'heavy');
|
||||
|
||||
/**
|
||||
* Default level to place all fixes in. Disabled by default
|
||||
*/
|
||||
var $defaultLevel = null;
|
||||
public $defaultLevel = null;
|
||||
|
||||
/**
|
||||
* Lists of fixes used by getFixesForLevel(). Format is:
|
||||
* HTMLModule_Tidy->fixesForLevel[$level] = array('fix-1', 'fix-2');
|
||||
*/
|
||||
var $fixesForLevel = array(
|
||||
public $fixesForLevel = array(
|
||||
'light' => array(),
|
||||
'medium' => array(),
|
||||
'heavy' => array()
|
||||
@ -70,7 +71,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* @todo Wildcard matching and error reporting when an added or
|
||||
* subtracted fix has no effect.
|
||||
*/
|
||||
function construct($config) {
|
||||
public function construct($config) {
|
||||
|
||||
// create fixes, initialize fixesForLevel
|
||||
$fixes = $this->makeFixes();
|
||||
@ -105,7 +106,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* @param $level String level identifier, see $levels for valid values
|
||||
* @return Lookup up table of fixes
|
||||
*/
|
||||
function getFixesForLevel($level) {
|
||||
public function getFixesForLevel($level) {
|
||||
if ($level == $this->levels[0]) {
|
||||
return array();
|
||||
}
|
||||
@ -135,7 +136,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* the fixes array. It may be custom overloaded, used in conjunction
|
||||
* with $defaultLevel, or not used at all.
|
||||
*/
|
||||
function makeFixesForLevel($fixes) {
|
||||
public function makeFixesForLevel($fixes) {
|
||||
if (!isset($this->defaultLevel)) return;
|
||||
if (!isset($this->fixesForLevel[$this->defaultLevel])) {
|
||||
trigger_error(
|
||||
@ -152,7 +153,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* based on a list of fixes passed to it
|
||||
* @param $lookup Lookup table of fixes to activate
|
||||
*/
|
||||
function populate($fixes) {
|
||||
public function populate($fixes) {
|
||||
foreach ($fixes as $name => $fix) {
|
||||
// determine what the fix is for
|
||||
list($type, $params) = $this->getFixType($name);
|
||||
@ -202,7 +203,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
* @note $fix_parameters is type dependant, see populate() for usage
|
||||
* of these parameters
|
||||
*/
|
||||
function getFixType($name) {
|
||||
public function getFixType($name) {
|
||||
// parse it
|
||||
$property = $attr = null;
|
||||
if (strpos($name, '#') !== false) list($name, $property) = explode('#', $name);
|
||||
@ -232,9 +233,8 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
|
||||
/**
|
||||
* Defines all fixes the module will perform in a compact
|
||||
* associative array of fix name to fix implementation.
|
||||
* @abstract
|
||||
*/
|
||||
function makeFixes() {}
|
||||
public function makeFixes() {}
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,10 @@ class HTMLPurifier_HTMLModule_Tidy_Proprietary extends
|
||||
HTMLPurifier_HTMLModule_Tidy
|
||||
{
|
||||
|
||||
var $name = 'Tidy_Proprietary';
|
||||
var $defaultLevel = 'light';
|
||||
public $name = 'Tidy_Proprietary';
|
||||
public $defaultLevel = 'light';
|
||||
|
||||
function makeFixes() {
|
||||
public function makeFixes() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,10 @@ class HTMLPurifier_HTMLModule_Tidy_XHTML extends
|
||||
HTMLPurifier_HTMLModule_Tidy
|
||||
{
|
||||
|
||||
var $name = 'Tidy_XHTML';
|
||||
var $defaultLevel = 'medium';
|
||||
public $name = 'Tidy_XHTML';
|
||||
public $defaultLevel = 'medium';
|
||||
|
||||
function makeFixes() {
|
||||
public function makeFixes() {
|
||||
$r = array();
|
||||
$r['@lang'] = new HTMLPurifier_AttrTransform_Lang();
|
||||
return $r;
|
||||
|
@ -19,7 +19,7 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
|
||||
HTMLPurifier_HTMLModule_Tidy
|
||||
{
|
||||
|
||||
function makeFixes() {
|
||||
public function makeFixes() {
|
||||
|
||||
$r = array();
|
||||
|
||||
@ -181,24 +181,24 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
|
||||
class HTMLPurifier_HTMLModule_Tidy_Transitional extends
|
||||
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
|
||||
{
|
||||
var $name = 'Tidy_Transitional';
|
||||
var $defaultLevel = 'heavy';
|
||||
public $name = 'Tidy_Transitional';
|
||||
public $defaultLevel = 'heavy';
|
||||
}
|
||||
|
||||
class HTMLPurifier_HTMLModule_Tidy_Strict extends
|
||||
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
|
||||
{
|
||||
var $name = 'Tidy_Strict';
|
||||
var $defaultLevel = 'light';
|
||||
public $name = 'Tidy_Strict';
|
||||
public $defaultLevel = 'light';
|
||||
|
||||
function makeFixes() {
|
||||
public function makeFixes() {
|
||||
$r = parent::makeFixes();
|
||||
$r['blockquote#content_model_type'] = 'strictblockquote';
|
||||
return $r;
|
||||
}
|
||||
|
||||
var $defines_child_def = true;
|
||||
function getChildDef($def) {
|
||||
public $defines_child_def = true;
|
||||
public function getChildDef($def) {
|
||||
if ($def->content_model_type != 'strictblockquote') return parent::getChildDef($def);
|
||||
return new HTMLPurifier_ChildDef_StrictBlockquote($def->content_model);
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
||||
|
||||
class HTMLPurifier_HTMLModule_XMLCommonAttributes extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
var $name = 'XMLCommonAttributes';
|
||||
public $name = 'XMLCommonAttributes';
|
||||
|
||||
var $attr_collections = array(
|
||||
public $attr_collections = array(
|
||||
'Lang' => array(
|
||||
'xml:lang' => 'LanguageCode',
|
||||
)
|
||||
|
Reference in New Issue
Block a user