ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_ChildDef_Required Class Reference

Definition that allows a set of elements, but disallows empty children. More...

+ Inheritance diagram for HTMLPurifier_ChildDef_Required:
+ Collaboration diagram for HTMLPurifier_ChildDef_Required:

Public Member Functions

 __construct ($elements)
 validateChildren ($children, $config, $context)
- Public Member Functions inherited from HTMLPurifier_ChildDef
 getAllowedElements ($config)
 Get lookup of tag names that should not close this element automatically.

Data Fields

 $elements = array()
 Lookup table of allowed elements.
 $allow_empty = false
 bool
 $type = 'required'
 string
- Data Fields inherited from HTMLPurifier_ChildDef
 $type
 Type of child definition, usually right-most part of class name lowercase.
 $allow_empty
 Indicates whether or not an empty array of children is okay.
 $elements = array()
 Lookup array of all elements that this definition could possibly allow.

Protected Attributes

 $whitespace = false
 Whether or not the last passed node was all whitespace.

Detailed Description

Definition that allows a set of elements, but disallows empty children.

Definition at line 6 of file Required.php.

Constructor & Destructor Documentation

HTMLPurifier_ChildDef_Required::__construct (   $elements)
Parameters
array | string$elementsList of allowed element names (lowercase).

Definition at line 23 of file Required.php.

References $elements.

{
if (is_string($elements)) {
$elements = str_replace(' ', '', $elements);
$elements = explode('|', $elements);
}
$keys = array_keys($elements);
if ($keys == array_keys($keys)) {
$elements = array_flip($elements);
foreach ($elements as $i => $x) {
$elements[$i] = true;
if (empty($i)) {
unset($elements[$i]);
} // remove blank
}
}
$this->elements = $elements;
}

Member Function Documentation

HTMLPurifier_ChildDef_Required::validateChildren (   $children,
  $config,
  $context 
)
Parameters
array$children
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Reimplemented from HTMLPurifier_ChildDef.

Reimplemented in HTMLPurifier_ChildDef_StrictBlockquote, and HTMLPurifier_ChildDef_Optional.

Definition at line 58 of file Required.php.

References $result.

{
// Flag for subclasses
$this->whitespace = false;
// if there are no tokens, delete parent node
if (empty($children)) {
return false;
}
// the new set of children
$result = array();
// whether or not parsed character data is allowed
// this controls whether or not we silently drop a tag
// or generate escaped HTML from it
$pcdata_allowed = isset($this->elements['#PCDATA']);
// a little sanity check to make sure it's not ALL whitespace
$all_whitespace = true;
$stack = array_reverse($children);
while (!empty($stack)) {
$node = array_pop($stack);
if (!empty($node->is_whitespace)) {
$result[] = $node;
continue;
}
$all_whitespace = false; // phew, we're not talking about whitespace
if (!isset($this->elements[$node->name])) {
// special case text
// XXX One of these ought to be redundant or something
if ($pcdata_allowed && $node instanceof HTMLPurifier_Node_Text) {
$result[] = $node;
continue;
}
// spill the child contents in
// ToDo: Make configurable
if ($node instanceof HTMLPurifier_Node_Element) {
for ($i = count($node->children) - 1; $i >= 0; $i--) {
$stack[] = $node->children[$i];
}
continue;
}
continue;
}
$result[] = $node;
}
if (empty($result)) {
return false;
}
if ($all_whitespace) {
$this->whitespace = true;
return false;
}
return $result;
}

Field Documentation

HTMLPurifier_ChildDef_Required::$allow_empty = false

bool

Definition at line 45 of file Required.php.

HTMLPurifier_ChildDef_Required::$elements = array()

Lookup table of allowed elements.

array

Definition at line 12 of file Required.php.

Referenced by __construct(), and HTMLPurifier_ChildDef_StrictBlockquote\init().

HTMLPurifier_ChildDef_Required::$type = 'required'

string

Definition at line 50 of file Required.php.

HTMLPurifier_ChildDef_Required::$whitespace = false
protected

Whether or not the last passed node was all whitespace.

bool

Definition at line 18 of file Required.php.


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