ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_ChildDef_StrictBlockquote Class Reference

Takes the contents of blockquote when in strict and reformats for validation. More...

+ Inheritance diagram for HTMLPurifier_ChildDef_StrictBlockquote:
+ Collaboration diagram for HTMLPurifier_ChildDef_StrictBlockquote:

Public Member Functions

 getAllowedElements ($config)
 validateChildren ($tokens_of_children, $config, $context)
 Validates nodes according to definition and returns modification.
- Public Member Functions inherited from HTMLPurifier_ChildDef_Required
 __construct ($elements)

Data Fields

 $allow_empty = true
 $type = 'strictblockquote'
- Data Fields inherited from HTMLPurifier_ChildDef_Required
 $elements = array()
 Lookup table of allowed elements.
 $allow_empty = false
 $type = 'required'
- Data Fields inherited from HTMLPurifier_ChildDef
 $type
 Type of child definition, usually right-most part of class name lowercase.
 $allow_empty
 Bool that 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

 $real_elements
 $fake_elements
 $init = false
- Protected Attributes inherited from HTMLPurifier_ChildDef_Required
 $whitespace = false
 Whether or not the last passed node was all whitespace.

Private Member Functions

 init ($config)

Detailed Description

Takes the contents of blockquote when in strict and reformats for validation.

Definition at line 6 of file StrictBlockquote.php.

Member Function Documentation

HTMLPurifier_ChildDef_StrictBlockquote::getAllowedElements (   $config)
Note
We don't want MakeWellFormed to auto-close inline elements since they might be allowed.

Reimplemented from HTMLPurifier_ChildDef.

Definition at line 18 of file StrictBlockquote.php.

References $fake_elements, and init().

{
$this->init($config);
}

+ Here is the call graph for this function:

HTMLPurifier_ChildDef_StrictBlockquote::init (   $config)
private

Definition at line 76 of file StrictBlockquote.php.

References HTMLPurifier_ChildDef_Required\$elements.

Referenced by getAllowedElements(), and validateChildren().

{
if (!$this->init) {
$def = $config->getHTMLDefinition();
// allow all inline elements
$this->real_elements = $this->elements;
$this->fake_elements = $def->info_content_sets['Flow'];
$this->fake_elements['#PCDATA'] = true;
$this->init = true;
}
}

+ Here is the caller graph for this function:

HTMLPurifier_ChildDef_StrictBlockquote::validateChildren (   $tokens_of_children,
  $config,
  $context 
)

Validates nodes according to definition and returns modification.

Parameters
$tokens_of_childrenArray of HTMLPurifier_Token
$configHTMLPurifier_Config object
$contextHTMLPurifier_Context object
Returns
bool true to leave nodes as is
bool false to remove parent node
array of replacement child tokens

Reimplemented from HTMLPurifier_ChildDef_Required.

Definition at line 23 of file StrictBlockquote.php.

References $fake_elements, $real_elements, $result, $ret, and init().

{
$this->init($config);
// trick the parent class into thinking it allows more
$this->elements = $this->fake_elements;
$result = parent::validateChildren($tokens_of_children, $config, $context);
$this->elements = $this->real_elements;
if ($result === false) return array();
if ($result === true) $result = $tokens_of_children;
$def = $config->getHTMLDefinition();
$block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper);
$block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper);
$is_inline = false;
$depth = 0;
$ret = array();
// assuming that there are no comment tokens
foreach ($result as $i => $token) {
$token = $result[$i];
// ifs are nested for readability
if (!$is_inline) {
if (!$depth) {
if (
($token instanceof HTMLPurifier_Token_Text && !$token->is_whitespace) ||
(!$token instanceof HTMLPurifier_Token_Text && !isset($this->elements[$token->name]))
) {
$is_inline = true;
$ret[] = $block_wrap_start;
}
}
} else {
if (!$depth) {
// starting tokens have been inline text / empty
if ($token instanceof HTMLPurifier_Token_Start || $token instanceof HTMLPurifier_Token_Empty) {
if (isset($this->elements[$token->name])) {
// ended
$ret[] = $block_wrap_end;
$is_inline = false;
}
}
}
}
$ret[] = $token;
if ($token instanceof HTMLPurifier_Token_Start) $depth++;
if ($token instanceof HTMLPurifier_Token_End) $depth--;
}
if ($is_inline) $ret[] = $block_wrap_end;
return $ret;
}

+ Here is the call graph for this function:

Field Documentation

HTMLPurifier_ChildDef_StrictBlockquote::$allow_empty = true

Definition at line 10 of file StrictBlockquote.php.

HTMLPurifier_ChildDef_StrictBlockquote::$fake_elements
protected

Definition at line 9 of file StrictBlockquote.php.

Referenced by getAllowedElements(), and validateChildren().

HTMLPurifier_ChildDef_StrictBlockquote::$init = false
protected

Definition at line 12 of file StrictBlockquote.php.

HTMLPurifier_ChildDef_StrictBlockquote::$real_elements
protected

Definition at line 8 of file StrictBlockquote.php.

Referenced by validateChildren().

HTMLPurifier_ChildDef_StrictBlockquote::$type = 'strictblockquote'

Definition at line 11 of file StrictBlockquote.php.


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