ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
HTMLPurifier_Injector_RemoveEmpty Class Reference
+ Inheritance diagram for HTMLPurifier_Injector_RemoveEmpty:
+ Collaboration diagram for HTMLPurifier_Injector_RemoveEmpty:

Public Member Functions

 prepare ($config, $context)
 
 handleElement (&$token)
 
- Public Member Functions inherited from HTMLPurifier_Injector
 rewindOffset ($offset)
 Rewind to a spot to re-perform processing. More...
 
 getRewindOffset ()
 Retrieves rewind offset, and then unsets it. More...
 
 prepare ($config, $context)
 Prepares the injector by giving it the config and context objects: this allows references to important variables to be made within the injector. More...
 
 checkNeeded ($config)
 This function checks if the HTML environment will work with the Injector: if p tags are not allowed, the Auto-Paragraphing injector should not be enabled. More...
 
 allowsElement ($name)
 Tests if the context node allows a certain element. More...
 
 handleText (&$token)
 Handler that is called when a text token is processed. More...
 
 handleElement (&$token)
 Handler that is called when a start or empty token is processed. More...
 
 handleEnd (&$token)
 Handler that is called when an end token is processed. More...
 
 notifyEnd ($token)
 Notifier that is called when an end token is processed. More...
 

Private Attributes

 $context
 @type HTMLPurifier_Context More...
 
 $config
 @type HTMLPurifier_Config More...
 
 $attrValidator
 @type HTMLPurifier_AttrValidator More...
 
 $removeNbsp
 @type bool More...
 
 $removeNbspExceptions
 @type bool More...
 
 $_exclude = array('colgroup' => 1, 'th' => 1, 'td' => 1, 'iframe' => 1)
 @type array TODO: make me configurable More...
 

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_Injector
 $name
 Advisory name of injector, this is for friendly error messages. More...
 
 $needed = array()
 Array of elements and attributes this injector creates and therefore need to be allowed by the definition. More...
 
- Protected Member Functions inherited from HTMLPurifier_Injector
 forward (&$i, &$current)
 Iterator function, which starts with the next token and continues until you reach the end of the input tokens. More...
 
 forwardUntilEndToken (&$i, &$current, &$nesting)
 Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and stops when we hit the end tag for the node $this->inputIndex starts in. More...
 
 backward (&$i, &$current)
 Iterator function, starts with the previous token and continues until you reach the beginning of input tokens. More...
 
- Protected Attributes inherited from HTMLPurifier_Injector
 $htmlDefinition
 @type HTMLPurifier_HTMLDefinition More...
 
 $currentNesting
 Reference to CurrentNesting variable in Context. More...
 
 $currentToken
 Reference to current token. More...
 
 $inputZipper
 Reference to InputZipper variable in Context. More...
 
 $rewindOffset = false
 Number of elements to rewind backwards (relative). More...
 

Detailed Description

Definition at line 3 of file RemoveEmpty.php.

Member Function Documentation

◆ handleElement()

HTMLPurifier_Injector_RemoveEmpty::handleElement ( $token)
Parameters
HTMLPurifier_Token$token

Reimplemented from HTMLPurifier_Injector.

Definition at line 54 of file RemoveEmpty.php.

55 {
56 if (!$token instanceof HTMLPurifier_Token_Start) {
57 return;
58 }
59 $next = false;
60 $deleted = 1; // the current tag
61 for ($i = count($this->inputZipper->back) - 1; $i >= 0; $i--, $deleted++) {
62 $next = $this->inputZipper->back[$i];
63 if ($next instanceof HTMLPurifier_Token_Text) {
64 if ($next->is_whitespace) {
65 continue;
66 }
67 if ($this->removeNbsp && !isset($this->removeNbspExceptions[$token->name])) {
68 $plain = str_replace("\xC2\xA0", "", $next->data);
69 $isWsOrNbsp = $plain === '' || ctype_space($plain);
70 if ($isWsOrNbsp) {
71 continue;
72 }
73 }
74 }
75 break;
76 }
77 if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) {
78 if (isset($this->_exclude[$token->name])) {
79 return;
80 }
81 $this->attrValidator->validateToken($token, $this->config, $this->context);
82 $token->armor['ValidateAttributes'] = true;
83 if (isset($token->attr['id']) || isset($token->attr['name'])) {
84 return;
85 }
86 $token = $deleted + 1;
87 for ($b = 0, $c = count($this->inputZipper->front); $b < $c; $b++) {
88 $prev = $this->inputZipper->front[$b];
89 if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) {
90 continue;
91 }
92 break;
93 }
94 // This is safe because we removed the token that triggered this.
95 $this->rewindOffset($b+$deleted);
96 return;
97 }
98 }
rewindOffset($offset)
Rewind to a spot to re-perform processing.
Definition: Injector.php:72
Concrete end token class.
Definition: End.php:11
Concrete start token class.
Definition: Start.php:7
Concrete text token class.
Definition: Text.php:13

References HTMLPurifier_Injector\rewindOffset().

+ Here is the call graph for this function:

◆ prepare()

HTMLPurifier_Injector_RemoveEmpty::prepare (   $config,
  $context 
)
Parameters
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
void

Reimplemented from HTMLPurifier_Injector.

Definition at line 41 of file RemoveEmpty.php.

42 {
43 parent::prepare($config, $context);
44 $this->config = $config;
45 $this->context = $context;
46 $this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp');
47 $this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions');
48 $this->attrValidator = new HTMLPurifier_AttrValidator();
49 }
Validates the attributes of a token.
$config
@type HTMLPurifier_Config
Definition: RemoveEmpty.php:13
$context
@type HTMLPurifier_Context
Definition: RemoveEmpty.php:8

References $config, and $context.

Field Documentation

◆ $_exclude

HTMLPurifier_Injector_RemoveEmpty::$_exclude = array('colgroup' => 1, 'th' => 1, 'td' => 1, 'iframe' => 1)
private

@type array TODO: make me configurable

Definition at line 34 of file RemoveEmpty.php.

◆ $attrValidator

HTMLPurifier_Injector_RemoveEmpty::$attrValidator
private

@type HTMLPurifier_AttrValidator

Definition at line 18 of file RemoveEmpty.php.

◆ $config

HTMLPurifier_Injector_RemoveEmpty::$config
private

@type HTMLPurifier_Config

Definition at line 13 of file RemoveEmpty.php.

Referenced by prepare().

◆ $context

HTMLPurifier_Injector_RemoveEmpty::$context
private

@type HTMLPurifier_Context

Definition at line 8 of file RemoveEmpty.php.

Referenced by prepare().

◆ $removeNbsp

HTMLPurifier_Injector_RemoveEmpty::$removeNbsp
private

@type bool

Definition at line 23 of file RemoveEmpty.php.

◆ $removeNbspExceptions

HTMLPurifier_Injector_RemoveEmpty::$removeNbspExceptions
private

@type bool

Definition at line 28 of file RemoveEmpty.php.


The documentation for this class was generated from the following file: