ILIAS  release_4-4 Revision
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)
 
- Public Member Functions inherited from HTMLPurifier_ChildDef_Required
 __construct ($elements)
 
 validateChildren ($tokens_of_children, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_ChildDef
 getAllowedElements ($config)
 Get lookup of tag names that should not close this element automatically. More...
 
 validateChildren ($tokens_of_children, $config, $context)
 Validates nodes according to definition and returns modification. More...
 

Data Fields

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

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. More...
 

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

◆ getAllowedElements()

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

Definition at line 18 of file StrictBlockquote.php.

References $fake_elements, and init().

+ Here is the call graph for this function:

◆ init()

HTMLPurifier_ChildDef_StrictBlockquote::init (   $config)
private

Definition at line 76 of file StrictBlockquote.php.

References HTMLPurifier_ChildDef_Required\$elements.

Referenced by getAllowedElements(), and validateChildren().

76  {
77  if (!$this->init) {
78  $def = $config->getHTMLDefinition();
79  // allow all inline elements
80  $this->real_elements = $this->elements;
81  $this->fake_elements = $def->info_content_sets['Flow'];
82  $this->fake_elements['#PCDATA'] = true;
83  $this->init = true;
84  }
85  }
$elements
Lookup table of allowed elements.
Definition: Required.php:12
+ Here is the caller graph for this function:

◆ validateChildren()

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

Definition at line 23 of file StrictBlockquote.php.

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

23  {
24 
25  $this->init($config);
26 
27  // trick the parent class into thinking it allows more
28  $this->elements = $this->fake_elements;
29  $result = parent::validateChildren($tokens_of_children, $config, $context);
30  $this->elements = $this->real_elements;
31 
32  if ($result === false) return array();
33  if ($result === true) $result = $tokens_of_children;
34 
35  $def = $config->getHTMLDefinition();
36  $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper);
37  $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper);
38  $is_inline = false;
39  $depth = 0;
40  $ret = array();
41 
42  // assuming that there are no comment tokens
43  foreach ($result as $i => $token) {
44  $token = $result[$i];
45  // ifs are nested for readability
46  if (!$is_inline) {
47  if (!$depth) {
48  if (
49  ($token instanceof HTMLPurifier_Token_Text && !$token->is_whitespace) ||
50  (!$token instanceof HTMLPurifier_Token_Text && !isset($this->elements[$token->name]))
51  ) {
52  $is_inline = true;
53  $ret[] = $block_wrap_start;
54  }
55  }
56  } else {
57  if (!$depth) {
58  // starting tokens have been inline text / empty
59  if ($token instanceof HTMLPurifier_Token_Start || $token instanceof HTMLPurifier_Token_Empty) {
60  if (isset($this->elements[$token->name])) {
61  // ended
62  $ret[] = $block_wrap_end;
63  $is_inline = false;
64  }
65  }
66  }
67  }
68  $ret[] = $token;
69  if ($token instanceof HTMLPurifier_Token_Start) $depth++;
70  if ($token instanceof HTMLPurifier_Token_End) $depth--;
71  }
72  if ($is_inline) $ret[] = $block_wrap_end;
73  return $ret;
74  }
Concrete end token class.
Definition: End.php:10
$result
Concrete start token class.
Definition: Start.php:6
Concrete empty token class.
Definition: Empty.php:6
Concrete text token class.
Definition: Text.php:12
+ Here is the call graph for this function:

Field Documentation

◆ $allow_empty

HTMLPurifier_ChildDef_StrictBlockquote::$allow_empty = true

Definition at line 10 of file StrictBlockquote.php.

◆ $fake_elements

HTMLPurifier_ChildDef_StrictBlockquote::$fake_elements
protected

Definition at line 9 of file StrictBlockquote.php.

Referenced by getAllowedElements(), and validateChildren().

◆ $init

HTMLPurifier_ChildDef_StrictBlockquote::$init = false
protected

Definition at line 12 of file StrictBlockquote.php.

◆ $real_elements

HTMLPurifier_ChildDef_StrictBlockquote::$real_elements
protected

Definition at line 8 of file StrictBlockquote.php.

Referenced by validateChildren().

◆ $type

HTMLPurifier_ChildDef_StrictBlockquote::$type = 'strictblockquote'

Definition at line 11 of file StrictBlockquote.php.


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