ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 getRewindOffset ()
 Retrieves rewind offset, and then unsets it.
 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.
 allowsElement ($name)
 Tests if the context node allows a certain element.
 handleText (&$token)
 Handler that is called when a text token is processed.
 handleEnd (&$token)
 Handler that is called when an end token is processed.
 notifyEnd ($token)
 Notifier that is called when an end token is processed.

Private Attributes

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

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_Injector
 $name
 Advisory name of injector, this is for friendly error messages.
 $needed = array()
 Array of elements and attributes this injector creates and therefore need to be allowed by the definition.
- 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.
 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.
 backward (&$i, &$current)
 Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
- Protected Attributes inherited from HTMLPurifier_Injector
 $htmlDefinition
 HTMLPurifier_HTMLDefinition
 $currentNesting
 Reference to CurrentNesting variable in Context.
 $currentToken
 Reference to current token.
 $inputZipper
 Reference to InputZipper variable in Context.
 $rewindOffset = false
 Number of elements to rewind backwards (relative).

Detailed Description

Definition at line 3 of file RemoveEmpty.php.

Member Function Documentation

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

Reimplemented from HTMLPurifier_Injector.

Definition at line 54 of file RemoveEmpty.php.

References HTMLPurifier_Injector\rewindOffset().

{
if (!$token instanceof HTMLPurifier_Token_Start) {
return;
}
$next = false;
$deleted = 1; // the current tag
for ($i = count($this->inputZipper->back) - 1; $i >= 0; $i--, $deleted++) {
$next = $this->inputZipper->back[$i];
if ($next instanceof HTMLPurifier_Token_Text) {
if ($next->is_whitespace) {
continue;
}
if ($this->removeNbsp && !isset($this->removeNbspExceptions[$token->name])) {
$plain = str_replace("\xC2\xA0", "", $next->data);
$isWsOrNbsp = $plain === '' || ctype_space($plain);
if ($isWsOrNbsp) {
continue;
}
}
}
break;
}
if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) {
if (isset($this->_exclude[$token->name])) {
return;
}
$this->attrValidator->validateToken($token, $this->config, $this->context);
$token->armor['ValidateAttributes'] = true;
if (isset($token->attr['id']) || isset($token->attr['name'])) {
return;
}
$token = $deleted + 1;
for ($b = 0, $c = count($this->inputZipper->front); $b < $c; $b++) {
$prev = $this->inputZipper->front[$b];
if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) {
continue;
}
break;
}
// This is safe because we removed the token that triggered this.
$this->rewindOffset($b+$deleted);
return;
}
}

+ Here is the call graph for this function:

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.

References $config, and $context.

{
$this->config = $config;
$this->context = $context;
$this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp');
$this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions');
$this->attrValidator = new HTMLPurifier_AttrValidator();
}

Field Documentation

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

array TODO: make me configurable

Definition at line 34 of file RemoveEmpty.php.

HTMLPurifier_Injector_RemoveEmpty::$attrValidator
private

HTMLPurifier_AttrValidator

Definition at line 18 of file RemoveEmpty.php.

HTMLPurifier_Injector_RemoveEmpty::$config
private

HTMLPurifier_Config

Definition at line 13 of file RemoveEmpty.php.

Referenced by prepare().

HTMLPurifier_Injector_RemoveEmpty::$context
private

HTMLPurifier_Context

Definition at line 8 of file RemoveEmpty.php.

Referenced by prepare().

HTMLPurifier_Injector_RemoveEmpty::$removeNbsp
private

bool

Definition at line 23 of file RemoveEmpty.php.

HTMLPurifier_Injector_RemoveEmpty::$removeNbspExceptions
private

bool

Definition at line 28 of file RemoveEmpty.php.


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