2006-07-23 00:11:03 +00:00
|
|
|
<?php
|
|
|
|
|
2006-07-23 13:20:15 +00:00
|
|
|
/**
|
|
|
|
* Abstract base token class that all others inherit from.
|
|
|
|
*/
|
2013-10-17 23:13:04 +00:00
|
|
|
abstract class HTMLPurifier_Token
|
2013-07-16 11:56:14 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Line number node was on in source document. Null if unknown.
|
|
|
|
* @type int
|
|
|
|
*/
|
|
|
|
public $line;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Column of line node was on in source document. Null if unknown.
|
|
|
|
* @type int
|
|
|
|
*/
|
|
|
|
public $col;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-20 21:39:28 +00:00
|
|
|
/**
|
|
|
|
* Lookup array of processing that this token is exempt from.
|
2007-06-26 15:07:07 +00:00
|
|
|
* Currently, valid values are "ValidateAttributes" and
|
|
|
|
* "MakeWellFormed_TagClosedError"
|
2013-07-16 11:56:14 +00:00
|
|
|
* @type array
|
2007-06-20 21:39:28 +00:00
|
|
|
*/
|
2007-11-25 02:24:39 +00:00
|
|
|
public $armor = array();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-10-01 07:14:28 +00:00
|
|
|
/**
|
2017-03-07 04:31:28 +00:00
|
|
|
* Used during MakeWellFormed. See Note [Injector skips]
|
2013-07-16 11:56:14 +00:00
|
|
|
* @type
|
2008-10-01 07:14:28 +00:00
|
|
|
*/
|
|
|
|
public $skip;
|
2013-07-16 11:56:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type
|
|
|
|
*/
|
2008-10-01 07:14:28 +00:00
|
|
|
public $rewind;
|
2013-07-16 11:56:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type
|
|
|
|
*/
|
2008-12-20 18:06:00 +00:00
|
|
|
public $carryover;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param string $n
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function __get($n)
|
|
|
|
{
|
|
|
|
if ($n === 'type') {
|
|
|
|
trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE);
|
|
|
|
switch (get_class($this)) {
|
|
|
|
case 'HTMLPurifier_Token_Start':
|
|
|
|
return 'start';
|
|
|
|
case 'HTMLPurifier_Token_Empty':
|
|
|
|
return 'empty';
|
|
|
|
case 'HTMLPurifier_Token_End':
|
|
|
|
return 'end';
|
|
|
|
case 'HTMLPurifier_Token_Text':
|
|
|
|
return 'text';
|
|
|
|
case 'HTMLPurifier_Token_Comment':
|
|
|
|
return 'comment';
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2008-01-19 20:23:01 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-01 18:10:10 +00:00
|
|
|
/**
|
|
|
|
* Sets the position of the token in the source document.
|
2013-07-16 11:56:14 +00:00
|
|
|
* @param int $l
|
|
|
|
* @param int $c
|
2008-09-01 18:10:10 +00:00
|
|
|
*/
|
2013-07-16 11:56:14 +00:00
|
|
|
public function position($l = null, $c = null)
|
|
|
|
{
|
2008-09-01 18:10:10 +00:00
|
|
|
$this->line = $l;
|
2013-07-16 11:56:14 +00:00
|
|
|
$this->col = $c;
|
2008-09-01 18:10:10 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-09-01 18:10:10 +00:00
|
|
|
/**
|
|
|
|
* Convenience function for DirectLex settings line/col position.
|
2013-07-16 11:56:14 +00:00
|
|
|
* @param int $l
|
|
|
|
* @param int $c
|
2008-09-01 18:10:10 +00:00
|
|
|
*/
|
2013-07-16 11:56:14 +00:00
|
|
|
public function rawPosition($l, $c)
|
|
|
|
{
|
|
|
|
if ($c === -1) {
|
|
|
|
$l++;
|
|
|
|
}
|
2008-09-01 18:10:10 +00:00
|
|
|
$this->line = $l;
|
2013-07-16 11:56:14 +00:00
|
|
|
$this->col = $c;
|
2008-09-01 18:10:10 +00:00
|
|
|
}
|
2013-10-20 22:05:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a token into its corresponding node.
|
|
|
|
*/
|
|
|
|
abstract public function toNode();
|
2006-07-23 13:20:15 +00:00
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|