ILIAS  release_4-4 Revision
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
 rewind ($index)
 Rewind to a spot to re-perform processing. More...
 
 getRewind ()
 Retrieves rewind, 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...
 

Data Fields

 $config
 
 $attrValidator
 
 $removeNbsp
 
 $removeNbspExceptions
 
- 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...
 

Private Attributes

 $context
 
 $_exclude = array('colgroup' => 1, 'th' => 1, 'td' => 1, 'iframe' => 1)
 

Additional Inherited Members

- 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...
 
 current (&$i, &$current)
 Initializes the iterator at the current position. More...
 
- Protected Attributes inherited from HTMLPurifier_Injector
 $htmlDefinition
 Instance of HTMLPurifier_HTMLDefinition. More...
 
 $currentNesting
 Reference to CurrentNesting variable in Context. More...
 
 $inputTokens
 Reference to InputTokens variable in Context. More...
 
 $inputIndex
 Reference to InputIndex variable in Context. More...
 
 $rewind = false
 Index of inputTokens to rewind to. More...
 

Detailed Description

Definition at line 3 of file RemoveEmpty.php.

Member Function Documentation

◆ handleElement()

HTMLPurifier_Injector_RemoveEmpty::handleElement ( $token)

Definition at line 20 of file RemoveEmpty.php.

References HTMLPurifier_Injector\rewind().

20  {
21  if (!$token instanceof HTMLPurifier_Token_Start) return;
22  $next = false;
23  for ($i = $this->inputIndex + 1, $c = count($this->inputTokens); $i < $c; $i++) {
24  $next = $this->inputTokens[$i];
25  if ($next instanceof HTMLPurifier_Token_Text) {
26  if ($next->is_whitespace) continue;
27  if ($this->removeNbsp && !isset($this->removeNbspExceptions[$token->name])) {
28  $plain = str_replace("\xC2\xA0", "", $next->data);
29  $isWsOrNbsp = $plain === '' || ctype_space($plain);
30  if ($isWsOrNbsp) continue;
31  }
32  }
33  break;
34  }
35  if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) {
36  if (isset($this->_exclude[$token->name])) return;
37  $this->attrValidator->validateToken($token, $this->config, $this->context);
38  $token->armor['ValidateAttributes'] = true;
39  if (isset($token->attr['id']) || isset($token->attr['name'])) return;
40  $token = $i - $this->inputIndex + 1;
41  for ($b = $this->inputIndex - 1; $b > 0; $b--) {
42  $prev = $this->inputTokens[$b];
43  if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) continue;
44  break;
45  }
46  // This is safe because we removed the token that triggered this.
47  $this->rewind($b - 1);
48  return;
49  }
50  }
Concrete end token class.
Definition: End.php:10
Concrete start token class.
Definition: Start.php:6
rewind($index)
Rewind to a spot to re-perform processing.
Definition: Injector.php:68
Concrete text token class.
Definition: Text.php:12
+ Here is the call graph for this function:

◆ prepare()

HTMLPurifier_Injector_RemoveEmpty::prepare (   $config,
  $context 
)

Definition at line 11 of file RemoveEmpty.php.

References $config, and $context.

11  {
12  parent::prepare($config, $context);
13  $this->config = $config;
14  $this->context = $context;
15  $this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp');
16  $this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions');
17  $this->attrValidator = new HTMLPurifier_AttrValidator();
18  }
Validates the attributes of a token.

Field Documentation

◆ $_exclude

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

Definition at line 9 of file RemoveEmpty.php.

◆ $attrValidator

HTMLPurifier_Injector_RemoveEmpty::$attrValidator

Definition at line 6 of file RemoveEmpty.php.

◆ $config

HTMLPurifier_Injector_RemoveEmpty::$config

Definition at line 6 of file RemoveEmpty.php.

Referenced by prepare().

◆ $context

HTMLPurifier_Injector_RemoveEmpty::$context
private

Definition at line 6 of file RemoveEmpty.php.

Referenced by prepare().

◆ $removeNbsp

HTMLPurifier_Injector_RemoveEmpty::$removeNbsp

Definition at line 6 of file RemoveEmpty.php.

◆ $removeNbspExceptions

HTMLPurifier_Injector_RemoveEmpty::$removeNbspExceptions

Definition at line 6 of file RemoveEmpty.php.


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