ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
HTMLPurifier_Injector_RemoveSpansWithoutAttributes Class Reference

Injector that removes spans with no attributes. More...

+ Inheritance diagram for HTMLPurifier_Injector_RemoveSpansWithoutAttributes:
+ Collaboration diagram for HTMLPurifier_Injector_RemoveSpansWithoutAttributes:

Public Member Functions

 prepare ($config, $context)
 
 handleElement (&$token)
 
 handleEnd (&$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...
 

Data Fields

 $name = 'RemoveSpansWithoutAttributes'
 string More...
 
 $needed = array('span')
 array More...
 
- 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

 $attrValidator
 HTMLPurifier_AttrValidator More...
 
 $config
 Used by AttrValidator. More...
 
 $context
 HTMLPurifier_Context More...
 

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...
 
- Protected Attributes inherited from HTMLPurifier_Injector
 $htmlDefinition
 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

Injector that removes spans with no attributes.

Definition at line 6 of file RemoveSpansWithoutAttributes.php.

Member Function Documentation

◆ handleElement()

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

Definition at line 45 of file RemoveSpansWithoutAttributes.php.

References HTMLPurifier_Injector\forwardUntilEndToken().

46  {
47  if ($token->name !== 'span' || !$token instanceof HTMLPurifier_Token_Start) {
48  return;
49  }
50 
51  // We need to validate the attributes now since this doesn't normally
52  // happen until after MakeWellFormed. If all the attributes are removed
53  // the span needs to be removed too.
54  $this->attrValidator->validateToken($token, $this->config, $this->context);
55  $token->armor['ValidateAttributes'] = true;
56 
57  if (!empty($token->attr)) {
58  return;
59  }
60 
61  $nesting = 0;
62  while ($this->forwardUntilEndToken($i, $current, $nesting)) {
63  }
64 
65  if ($current instanceof HTMLPurifier_Token_End && $current->name === 'span') {
66  // Mark closing span tag for deletion
67  $current->markForDeletion = true;
68  // Delete open span tag
69  $token = false;
70  }
71  }
Concrete end token class.
Definition: End.php:10
Concrete start token class.
Definition: Start.php:6
forwardUntilEndToken(&$i, &$current, &$nesting)
Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and st...
Definition: Injector.php:204
+ Here is the call graph for this function:

◆ handleEnd()

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::handleEnd ( $token)
Parameters
HTMLPurifier_Token$token

Definition at line 76 of file RemoveSpansWithoutAttributes.php.

77  {
78  if ($token->markForDeletion) {
79  $token = false;
80  }
81  }

◆ prepare()

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::prepare (   $config,
  $context 
)

Definition at line 34 of file RemoveSpansWithoutAttributes.php.

References $config, and $context.

35  {
36  $this->attrValidator = new HTMLPurifier_AttrValidator();
37  $this->config = $config;
38  $this->context = $context;
39  return parent::prepare($config, $context);
40  }
Validates the attributes of a token.

Field Documentation

◆ $attrValidator

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::$attrValidator
private

◆ $config

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::$config
private

Used by AttrValidator.

HTMLPurifier_Config

Definition at line 27 of file RemoveSpansWithoutAttributes.php.

Referenced by prepare().

◆ $context

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::$context
private

HTMLPurifier_Context

Definition at line 32 of file RemoveSpansWithoutAttributes.php.

Referenced by prepare().

◆ $name

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::$name = 'RemoveSpansWithoutAttributes'

string

Definition at line 11 of file RemoveSpansWithoutAttributes.php.

◆ $needed

HTMLPurifier_Injector_RemoveSpansWithoutAttributes::$needed = array('span')

array

Definition at line 16 of file RemoveSpansWithoutAttributes.php.


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