90 public function prepare($config, $context) {
91 $this->htmlDefinition = $config->getHTMLDefinition();
97 $this->currentNesting =& $context->get(
'CurrentNesting');
98 $this->inputTokens =& $context->get(
'InputTokens');
99 $this->inputIndex =& $context->get(
'InputIndex');
112 $def = $config->getHTMLDefinition();
113 foreach ($this->needed as $element => $attributes) {
114 if (is_int($element)) $element = $attributes;
115 if (!isset($def->info[$element]))
return $element;
116 if (!is_array($attributes))
continue;
117 foreach ($attributes as
$name) {
118 if (!isset($def->info[$element]->attr[$name]))
return "$element.$name";
130 if (!empty($this->currentNesting)) {
131 $parent_token = array_pop($this->currentNesting);
132 $this->currentNesting[] = $parent_token;
133 $parent = $this->htmlDefinition->info[$parent_token->name];
135 $parent = $this->htmlDefinition->info_parent_def;
137 if (!isset($parent->child->elements[
$name]) || isset($parent->excludes[
$name])) {
141 for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) {
142 $node = $this->currentNesting[$i];
143 $def = $this->htmlDefinition->info[$node->name];
144 if (isset($def->excludes[
$name]))
return false;
158 if ($i === null) $i = $this->inputIndex + 1;
160 if (!isset($this->inputTokens[$i]))
return false;
161 $current = $this->inputTokens[$i];
173 if ($nesting === null) $nesting = 0;
176 if ($nesting <= 0)
return false;
191 if ($i === null) $i = $this->inputIndex - 1;
193 if ($i < 0)
return false;
194 $current = $this->inputTokens[$i];
209 $current = $this->inputTokens[$i];
allowsElement($name)
Tests if the context node allows a certain element.
$htmlDefinition
Instance of HTMLPurifier_HTMLDefinition.
Concrete end token class.
$inputTokens
Reference to InputTokens variable in Context.
Concrete start token class.
forward(&$i, &$current)
Iterator function, which starts with the next token and continues until you reach the end of the inpu...
prepare($config, $context)
Prepares the injector by giving it the config and context objects: this allows references to importan...
$rewind
Index of inputTokens to rewind to.
forwardUntilEndToken(&$i, &$current, &$nesting)
Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and st...
notifyEnd($token)
Notifier that is called when an end token is processed.
rewind($index)
Rewind to a spot to re-perform processing.
$inputIndex
Reference to InputIndex variable in Context.
$name
Advisory name of injector, this is for friendly error messages.
checkNeeded($config)
This function checks if the HTML environment will work with the Injector: if p tags are not allowed...
Injects tokens into the document while parsing for well-formedness.
backward(&$i, &$current)
Iterator function, starts with the previous token and continues until you reach the beginning of inpu...
handleText(&$token)
Handler that is called when a text token is processed.
handleEnd(&$token)
Handler that is called when an end token is processed.
getRewind()
Retrieves rewind, and then unsets it.
$currentNesting
Reference to CurrentNesting variable in Context.
current(&$i, &$current)
Initializes the iterator at the current position.
handleElement(&$token)
Handler that is called when a start or empty token is processed.
$needed
Array of elements and attributes this injector creates and therefore need to be allowed by the defini...