@@ -5,113 +5,113 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef |
7 | 7 | { |
8 | - /** |
|
9 | - * Lookup table of allowed elements. |
|
10 | - * @public |
|
11 | - */ |
|
12 | - public $elements = array(); |
|
13 | - /** |
|
14 | - * Whether or not the last passed node was all whitespace. |
|
15 | - */ |
|
16 | - protected $whitespace = false; |
|
17 | - /** |
|
18 | - * @param $elements List of allowed element names (lowercase). |
|
19 | - */ |
|
20 | - public function __construct($elements) { |
|
21 | - if (is_string($elements)) { |
|
22 | - $elements = str_replace(' ', '', $elements); |
|
23 | - $elements = explode('|', $elements); |
|
24 | - } |
|
25 | - $keys = array_keys($elements); |
|
26 | - if ($keys == array_keys($keys)) { |
|
27 | - $elements = array_flip($elements); |
|
28 | - foreach ($elements as $i => $x) { |
|
29 | - $elements[$i] = true; |
|
30 | - if (empty($i)) unset($elements[$i]); // remove blank |
|
31 | - } |
|
32 | - } |
|
33 | - $this->elements = $elements; |
|
34 | - } |
|
35 | - public $allow_empty = false; |
|
36 | - public $type = 'required'; |
|
37 | - public function validateChildren($tokens_of_children, $config, $context) { |
|
38 | - // Flag for subclasses |
|
39 | - $this->whitespace = false; |
|
8 | + /** |
|
9 | + * Lookup table of allowed elements. |
|
10 | + * @public |
|
11 | + */ |
|
12 | + public $elements = array(); |
|
13 | + /** |
|
14 | + * Whether or not the last passed node was all whitespace. |
|
15 | + */ |
|
16 | + protected $whitespace = false; |
|
17 | + /** |
|
18 | + * @param $elements List of allowed element names (lowercase). |
|
19 | + */ |
|
20 | + public function __construct($elements) { |
|
21 | + if (is_string($elements)) { |
|
22 | + $elements = str_replace(' ', '', $elements); |
|
23 | + $elements = explode('|', $elements); |
|
24 | + } |
|
25 | + $keys = array_keys($elements); |
|
26 | + if ($keys == array_keys($keys)) { |
|
27 | + $elements = array_flip($elements); |
|
28 | + foreach ($elements as $i => $x) { |
|
29 | + $elements[$i] = true; |
|
30 | + if (empty($i)) unset($elements[$i]); // remove blank |
|
31 | + } |
|
32 | + } |
|
33 | + $this->elements = $elements; |
|
34 | + } |
|
35 | + public $allow_empty = false; |
|
36 | + public $type = 'required'; |
|
37 | + public function validateChildren($tokens_of_children, $config, $context) { |
|
38 | + // Flag for subclasses |
|
39 | + $this->whitespace = false; |
|
40 | 40 | |
41 | - // if there are no tokens, delete parent node |
|
42 | - if (empty($tokens_of_children)) return false; |
|
41 | + // if there are no tokens, delete parent node |
|
42 | + if (empty($tokens_of_children)) return false; |
|
43 | 43 | |
44 | - // the new set of children |
|
45 | - $result = array(); |
|
44 | + // the new set of children |
|
45 | + $result = array(); |
|
46 | 46 | |
47 | - // current depth into the nest |
|
48 | - $nesting = 0; |
|
47 | + // current depth into the nest |
|
48 | + $nesting = 0; |
|
49 | 49 | |
50 | - // whether or not we're deleting a node |
|
51 | - $is_deleting = false; |
|
50 | + // whether or not we're deleting a node |
|
51 | + $is_deleting = false; |
|
52 | 52 | |
53 | - // whether or not parsed character data is allowed |
|
54 | - // this controls whether or not we silently drop a tag |
|
55 | - // or generate escaped HTML from it |
|
56 | - $pcdata_allowed = isset($this->elements['#PCDATA']); |
|
53 | + // whether or not parsed character data is allowed |
|
54 | + // this controls whether or not we silently drop a tag |
|
55 | + // or generate escaped HTML from it |
|
56 | + $pcdata_allowed = isset($this->elements['#PCDATA']); |
|
57 | 57 | |
58 | - // a little sanity check to make sure it's not ALL whitespace |
|
59 | - $all_whitespace = true; |
|
58 | + // a little sanity check to make sure it's not ALL whitespace |
|
59 | + $all_whitespace = true; |
|
60 | 60 | |
61 | - // some configuration |
|
62 | - $escape_invalid_children = $config->get('Core.EscapeInvalidChildren'); |
|
61 | + // some configuration |
|
62 | + $escape_invalid_children = $config->get('Core.EscapeInvalidChildren'); |
|
63 | 63 | |
64 | - // generator |
|
65 | - $gen = new HTMLPurifier_Generator($config, $context); |
|
64 | + // generator |
|
65 | + $gen = new HTMLPurifier_Generator($config, $context); |
|
66 | 66 | |
67 | - foreach ($tokens_of_children as $token) { |
|
68 | - if (!empty($token->is_whitespace)) { |
|
69 | - $result[] = $token; |
|
70 | - continue; |
|
71 | - } |
|
72 | - $all_whitespace = false; // phew, we're not talking about whitespace |
|
67 | + foreach ($tokens_of_children as $token) { |
|
68 | + if (!empty($token->is_whitespace)) { |
|
69 | + $result[] = $token; |
|
70 | + continue; |
|
71 | + } |
|
72 | + $all_whitespace = false; // phew, we're not talking about whitespace |
|
73 | 73 | |
74 | - $is_child = ($nesting == 0); |
|
74 | + $is_child = ($nesting == 0); |
|
75 | 75 | |
76 | - if ($token instanceof HTMLPurifier_Token_Start) { |
|
77 | - $nesting++; |
|
78 | - } elseif ($token instanceof HTMLPurifier_Token_End) { |
|
79 | - $nesting--; |
|
80 | - } |
|
76 | + if ($token instanceof HTMLPurifier_Token_Start) { |
|
77 | + $nesting++; |
|
78 | + } elseif ($token instanceof HTMLPurifier_Token_End) { |
|
79 | + $nesting--; |
|
80 | + } |
|
81 | 81 | |
82 | - if ($is_child) { |
|
83 | - $is_deleting = false; |
|
84 | - if (!isset($this->elements[$token->name])) { |
|
85 | - $is_deleting = true; |
|
86 | - if ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text) { |
|
87 | - $result[] = $token; |
|
88 | - } elseif ($pcdata_allowed && $escape_invalid_children) { |
|
89 | - $result[] = new HTMLPurifier_Token_Text( |
|
90 | - $gen->generateFromToken($token) |
|
91 | - ); |
|
92 | - } |
|
93 | - continue; |
|
94 | - } |
|
95 | - } |
|
96 | - if (!$is_deleting || ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text)) { |
|
97 | - $result[] = $token; |
|
98 | - } elseif ($pcdata_allowed && $escape_invalid_children) { |
|
99 | - $result[] = |
|
100 | - new HTMLPurifier_Token_Text( |
|
101 | - $gen->generateFromToken($token) |
|
102 | - ); |
|
103 | - } else { |
|
104 | - // drop silently |
|
105 | - } |
|
106 | - } |
|
107 | - if (empty($result)) return false; |
|
108 | - if ($all_whitespace) { |
|
109 | - $this->whitespace = true; |
|
110 | - return false; |
|
111 | - } |
|
112 | - if ($tokens_of_children == $result) return true; |
|
113 | - return $result; |
|
114 | - } |
|
82 | + if ($is_child) { |
|
83 | + $is_deleting = false; |
|
84 | + if (!isset($this->elements[$token->name])) { |
|
85 | + $is_deleting = true; |
|
86 | + if ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text) { |
|
87 | + $result[] = $token; |
|
88 | + } elseif ($pcdata_allowed && $escape_invalid_children) { |
|
89 | + $result[] = new HTMLPurifier_Token_Text( |
|
90 | + $gen->generateFromToken($token) |
|
91 | + ); |
|
92 | + } |
|
93 | + continue; |
|
94 | + } |
|
95 | + } |
|
96 | + if (!$is_deleting || ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text)) { |
|
97 | + $result[] = $token; |
|
98 | + } elseif ($pcdata_allowed && $escape_invalid_children) { |
|
99 | + $result[] = |
|
100 | + new HTMLPurifier_Token_Text( |
|
101 | + $gen->generateFromToken($token) |
|
102 | + ); |
|
103 | + } else { |
|
104 | + // drop silently |
|
105 | + } |
|
106 | + } |
|
107 | + if (empty($result)) return false; |
|
108 | + if ($all_whitespace) { |
|
109 | + $this->whitespace = true; |
|
110 | + return false; |
|
111 | + } |
|
112 | + if ($tokens_of_children == $result) return true; |
|
113 | + return $result; |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // vim: et sw=4 sts=4 |
@@ -27,7 +27,10 @@ discard block |
||
27 | 27 | $elements = array_flip($elements); |
28 | 28 | foreach ($elements as $i => $x) { |
29 | 29 | $elements[$i] = true; |
30 | - if (empty($i)) unset($elements[$i]); // remove blank |
|
30 | + if (empty($i)) { |
|
31 | + unset($elements[$i]); |
|
32 | + } |
|
33 | + // remove blank |
|
31 | 34 | } |
32 | 35 | } |
33 | 36 | $this->elements = $elements; |
@@ -39,7 +42,9 @@ discard block |
||
39 | 42 | $this->whitespace = false; |
40 | 43 | |
41 | 44 | // if there are no tokens, delete parent node |
42 | - if (empty($tokens_of_children)) return false; |
|
45 | + if (empty($tokens_of_children)) { |
|
46 | + return false; |
|
47 | + } |
|
43 | 48 | |
44 | 49 | // the new set of children |
45 | 50 | $result = array(); |
@@ -104,12 +109,16 @@ discard block |
||
104 | 109 | // drop silently |
105 | 110 | } |
106 | 111 | } |
107 | - if (empty($result)) return false; |
|
112 | + if (empty($result)) { |
|
113 | + return false; |
|
114 | + } |
|
108 | 115 | if ($all_whitespace) { |
109 | 116 | $this->whitespace = true; |
110 | 117 | return false; |
111 | 118 | } |
112 | - if ($tokens_of_children == $result) return true; |
|
119 | + if ($tokens_of_children == $result) { |
|
120 | + return true; |
|
121 | + } |
|
113 | 122 | return $result; |
114 | 123 | } |
115 | 124 | } |
@@ -5,84 +5,84 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Required |
7 | 7 | { |
8 | - protected $real_elements; |
|
9 | - protected $fake_elements; |
|
10 | - public $allow_empty = true; |
|
11 | - public $type = 'strictblockquote'; |
|
12 | - protected $init = false; |
|
8 | + protected $real_elements; |
|
9 | + protected $fake_elements; |
|
10 | + public $allow_empty = true; |
|
11 | + public $type = 'strictblockquote'; |
|
12 | + protected $init = false; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @note We don't want MakeWellFormed to auto-close inline elements since |
|
16 | - * they might be allowed. |
|
17 | - */ |
|
18 | - public function getAllowedElements($config) { |
|
19 | - $this->init($config); |
|
20 | - return $this->fake_elements; |
|
21 | - } |
|
14 | + /** |
|
15 | + * @note We don't want MakeWellFormed to auto-close inline elements since |
|
16 | + * they might be allowed. |
|
17 | + */ |
|
18 | + public function getAllowedElements($config) { |
|
19 | + $this->init($config); |
|
20 | + return $this->fake_elements; |
|
21 | + } |
|
22 | 22 | |
23 | - public function validateChildren($tokens_of_children, $config, $context) { |
|
23 | + public function validateChildren($tokens_of_children, $config, $context) { |
|
24 | 24 | |
25 | - $this->init($config); |
|
25 | + $this->init($config); |
|
26 | 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; |
|
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 | 31 | |
32 | - if ($result === false) return array(); |
|
33 | - if ($result === true) $result = $tokens_of_children; |
|
32 | + if ($result === false) return array(); |
|
33 | + if ($result === true) $result = $tokens_of_children; |
|
34 | 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(); |
|
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 | 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 | - } |
|
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 | + } |
|
75 | 75 | |
76 | - private function init($config) { |
|
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 | - } |
|
76 | + private function init($config) { |
|
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 | + } |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // vim: et sw=4 sts=4 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | $def = $config->getHTMLDefinition(); |
36 | 36 | $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper); |
37 | - $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper); |
|
37 | + $block_wrap_end = new HTMLPurifier_Token_End($def->info_block_wrapper); |
|
38 | 38 | $is_inline = false; |
39 | 39 | $depth = 0; |
40 | 40 | $ret = array(); |
@@ -29,8 +29,12 @@ discard block |
||
29 | 29 | $result = parent::validateChildren($tokens_of_children, $config, $context); |
30 | 30 | $this->elements = $this->real_elements; |
31 | 31 | |
32 | - if ($result === false) return array(); |
|
33 | - if ($result === true) $result = $tokens_of_children; |
|
32 | + if ($result === false) { |
|
33 | + return array(); |
|
34 | + } |
|
35 | + if ($result === true) { |
|
36 | + $result = $tokens_of_children; |
|
37 | + } |
|
34 | 38 | |
35 | 39 | $def = $config->getHTMLDefinition(); |
36 | 40 | $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper); |
@@ -66,10 +70,16 @@ discard block |
||
66 | 70 | } |
67 | 71 | } |
68 | 72 | $ret[] = $token; |
69 | - if ($token instanceof HTMLPurifier_Token_Start) $depth++; |
|
70 | - if ($token instanceof HTMLPurifier_Token_End) $depth--; |
|
73 | + if ($token instanceof HTMLPurifier_Token_Start) { |
|
74 | + $depth++; |
|
75 | + } |
|
76 | + if ($token instanceof HTMLPurifier_Token_End) { |
|
77 | + $depth--; |
|
78 | + } |
|
79 | + } |
|
80 | + if ($is_inline) { |
|
81 | + $ret[] = $block_wrap_end; |
|
71 | 82 | } |
72 | - if ($is_inline) $ret[] = $block_wrap_end; |
|
73 | 83 | return $ret; |
74 | 84 | } |
75 | 85 |
@@ -31,197 +31,197 @@ |
||
31 | 31 | */ |
32 | 32 | class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef |
33 | 33 | { |
34 | - public $allow_empty = false; |
|
35 | - public $type = 'table'; |
|
36 | - public $elements = array('tr' => true, 'tbody' => true, 'thead' => true, |
|
37 | - 'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true); |
|
38 | - public function __construct() {} |
|
39 | - public function validateChildren($tokens_of_children, $config, $context) { |
|
40 | - if (empty($tokens_of_children)) return false; |
|
41 | - |
|
42 | - // this ensures that the loop gets run one last time before closing |
|
43 | - // up. It's a little bit of a hack, but it works! Just make sure you |
|
44 | - // get rid of the token later. |
|
45 | - $tokens_of_children[] = false; |
|
46 | - |
|
47 | - // only one of these elements is allowed in a table |
|
48 | - $caption = false; |
|
49 | - $thead = false; |
|
50 | - $tfoot = false; |
|
51 | - |
|
52 | - // as many of these as you want |
|
53 | - $cols = array(); |
|
54 | - $content = array(); |
|
55 | - |
|
56 | - $nesting = 0; // current depth so we can determine nodes |
|
57 | - $is_collecting = false; // are we globbing together tokens to package |
|
58 | - // into one of the collectors? |
|
59 | - $collection = array(); // collected nodes |
|
60 | - $tag_index = 0; // the first node might be whitespace, |
|
61 | - // so this tells us where the start tag is |
|
62 | - $tbody_mode = false; // if true, then we need to wrap any stray |
|
63 | - // <tr>s with a <tbody>. |
|
64 | - |
|
65 | - foreach ($tokens_of_children as $token) { |
|
66 | - $is_child = ($nesting == 0); |
|
67 | - |
|
68 | - if ($token === false) { |
|
69 | - // terminating sequence started |
|
70 | - } elseif ($token instanceof HTMLPurifier_Token_Start) { |
|
71 | - $nesting++; |
|
72 | - } elseif ($token instanceof HTMLPurifier_Token_End) { |
|
73 | - $nesting--; |
|
74 | - } |
|
75 | - |
|
76 | - // handle node collection |
|
77 | - if ($is_collecting) { |
|
78 | - if ($is_child) { |
|
79 | - // okay, let's stash the tokens away |
|
80 | - // first token tells us the type of the collection |
|
81 | - switch ($collection[$tag_index]->name) { |
|
82 | - case 'tbody': |
|
83 | - $tbody_mode = true; |
|
84 | - case 'tr': |
|
85 | - $content[] = $collection; |
|
86 | - break; |
|
87 | - case 'caption': |
|
88 | - if ($caption !== false) break; |
|
89 | - $caption = $collection; |
|
90 | - break; |
|
91 | - case 'thead': |
|
92 | - case 'tfoot': |
|
93 | - $tbody_mode = true; |
|
94 | - // XXX This breaks rendering properties with |
|
95 | - // Firefox, which never floats a <thead> to |
|
96 | - // the top. Ever. (Our scheme will float the |
|
97 | - // first <thead> to the top.) So maybe |
|
98 | - // <thead>s that are not first should be |
|
99 | - // turned into <tbody>? Very tricky, indeed. |
|
100 | - |
|
101 | - // access the appropriate variable, $thead or $tfoot |
|
102 | - $var = $collection[$tag_index]->name; |
|
103 | - if ($$var === false) { |
|
104 | - $$var = $collection; |
|
105 | - } else { |
|
106 | - // Oops, there's a second one! What |
|
107 | - // should we do? Current behavior is to |
|
108 | - // transmutate the first and last entries into |
|
109 | - // tbody tags, and then put into content. |
|
110 | - // Maybe a better idea is to *attach |
|
111 | - // it* to the existing thead or tfoot? |
|
112 | - // We don't do this, because Firefox |
|
113 | - // doesn't float an extra tfoot to the |
|
114 | - // bottom like it does for the first one. |
|
115 | - $collection[$tag_index]->name = 'tbody'; |
|
116 | - $collection[count($collection)-1]->name = 'tbody'; |
|
117 | - $content[] = $collection; |
|
118 | - } |
|
119 | - break; |
|
120 | - case 'colgroup': |
|
121 | - $cols[] = $collection; |
|
122 | - break; |
|
123 | - } |
|
124 | - $collection = array(); |
|
125 | - $is_collecting = false; |
|
126 | - $tag_index = 0; |
|
127 | - } else { |
|
128 | - // add the node to the collection |
|
129 | - $collection[] = $token; |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - // terminate |
|
134 | - if ($token === false) break; |
|
135 | - |
|
136 | - if ($is_child) { |
|
137 | - // determine what we're dealing with |
|
138 | - if ($token->name == 'col') { |
|
139 | - // the only empty tag in the possie, we can handle it |
|
140 | - // immediately |
|
141 | - $cols[] = array_merge($collection, array($token)); |
|
142 | - $collection = array(); |
|
143 | - $tag_index = 0; |
|
144 | - continue; |
|
145 | - } |
|
146 | - switch($token->name) { |
|
147 | - case 'caption': |
|
148 | - case 'colgroup': |
|
149 | - case 'thead': |
|
150 | - case 'tfoot': |
|
151 | - case 'tbody': |
|
152 | - case 'tr': |
|
153 | - $is_collecting = true; |
|
154 | - $collection[] = $token; |
|
155 | - continue; |
|
156 | - default: |
|
157 | - if (!empty($token->is_whitespace)) { |
|
158 | - $collection[] = $token; |
|
159 | - $tag_index++; |
|
160 | - } |
|
161 | - continue; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - if (empty($content)) return false; |
|
167 | - |
|
168 | - $ret = array(); |
|
169 | - if ($caption !== false) $ret = array_merge($ret, $caption); |
|
170 | - if ($cols !== false) foreach ($cols as $token_array) $ret = array_merge($ret, $token_array); |
|
171 | - if ($thead !== false) $ret = array_merge($ret, $thead); |
|
172 | - if ($tfoot !== false) $ret = array_merge($ret, $tfoot); |
|
173 | - |
|
174 | - if ($tbody_mode) { |
|
175 | - // a little tricky, since the start of the collection may be |
|
176 | - // whitespace |
|
177 | - $inside_tbody = false; |
|
178 | - foreach ($content as $token_array) { |
|
179 | - // find the starting token |
|
180 | - foreach ($token_array as $t) { |
|
181 | - if ($t->name === 'tr' || $t->name === 'tbody') { |
|
182 | - break; |
|
183 | - } |
|
184 | - } // iterator variable carries over |
|
185 | - if ($t->name === 'tr') { |
|
186 | - if ($inside_tbody) { |
|
187 | - $ret = array_merge($ret, $token_array); |
|
188 | - } else { |
|
189 | - $ret[] = new HTMLPurifier_Token_Start('tbody'); |
|
190 | - $ret = array_merge($ret, $token_array); |
|
191 | - $inside_tbody = true; |
|
192 | - } |
|
193 | - } elseif ($t->name === 'tbody') { |
|
194 | - if ($inside_tbody) { |
|
195 | - $ret[] = new HTMLPurifier_Token_End('tbody'); |
|
196 | - $inside_tbody = false; |
|
197 | - $ret = array_merge($ret, $token_array); |
|
198 | - } else { |
|
199 | - $ret = array_merge($ret, $token_array); |
|
200 | - } |
|
201 | - } else { |
|
202 | - trigger_error("tr/tbody in content invariant failed in Table ChildDef", E_USER_ERROR); |
|
203 | - } |
|
204 | - } |
|
205 | - if ($inside_tbody) { |
|
206 | - $ret[] = new HTMLPurifier_Token_End('tbody'); |
|
207 | - } |
|
208 | - } else { |
|
209 | - foreach ($content as $token_array) { |
|
210 | - // invariant: everything in here is <tr>s |
|
211 | - $ret = array_merge($ret, $token_array); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - if (!empty($collection) && $is_collecting == false){ |
|
216 | - // grab the trailing space |
|
217 | - $ret = array_merge($ret, $collection); |
|
218 | - } |
|
219 | - |
|
220 | - array_pop($tokens_of_children); // remove phantom token |
|
221 | - |
|
222 | - return ($ret === $tokens_of_children) ? true : $ret; |
|
223 | - |
|
224 | - } |
|
34 | + public $allow_empty = false; |
|
35 | + public $type = 'table'; |
|
36 | + public $elements = array('tr' => true, 'tbody' => true, 'thead' => true, |
|
37 | + 'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true); |
|
38 | + public function __construct() {} |
|
39 | + public function validateChildren($tokens_of_children, $config, $context) { |
|
40 | + if (empty($tokens_of_children)) return false; |
|
41 | + |
|
42 | + // this ensures that the loop gets run one last time before closing |
|
43 | + // up. It's a little bit of a hack, but it works! Just make sure you |
|
44 | + // get rid of the token later. |
|
45 | + $tokens_of_children[] = false; |
|
46 | + |
|
47 | + // only one of these elements is allowed in a table |
|
48 | + $caption = false; |
|
49 | + $thead = false; |
|
50 | + $tfoot = false; |
|
51 | + |
|
52 | + // as many of these as you want |
|
53 | + $cols = array(); |
|
54 | + $content = array(); |
|
55 | + |
|
56 | + $nesting = 0; // current depth so we can determine nodes |
|
57 | + $is_collecting = false; // are we globbing together tokens to package |
|
58 | + // into one of the collectors? |
|
59 | + $collection = array(); // collected nodes |
|
60 | + $tag_index = 0; // the first node might be whitespace, |
|
61 | + // so this tells us where the start tag is |
|
62 | + $tbody_mode = false; // if true, then we need to wrap any stray |
|
63 | + // <tr>s with a <tbody>. |
|
64 | + |
|
65 | + foreach ($tokens_of_children as $token) { |
|
66 | + $is_child = ($nesting == 0); |
|
67 | + |
|
68 | + if ($token === false) { |
|
69 | + // terminating sequence started |
|
70 | + } elseif ($token instanceof HTMLPurifier_Token_Start) { |
|
71 | + $nesting++; |
|
72 | + } elseif ($token instanceof HTMLPurifier_Token_End) { |
|
73 | + $nesting--; |
|
74 | + } |
|
75 | + |
|
76 | + // handle node collection |
|
77 | + if ($is_collecting) { |
|
78 | + if ($is_child) { |
|
79 | + // okay, let's stash the tokens away |
|
80 | + // first token tells us the type of the collection |
|
81 | + switch ($collection[$tag_index]->name) { |
|
82 | + case 'tbody': |
|
83 | + $tbody_mode = true; |
|
84 | + case 'tr': |
|
85 | + $content[] = $collection; |
|
86 | + break; |
|
87 | + case 'caption': |
|
88 | + if ($caption !== false) break; |
|
89 | + $caption = $collection; |
|
90 | + break; |
|
91 | + case 'thead': |
|
92 | + case 'tfoot': |
|
93 | + $tbody_mode = true; |
|
94 | + // XXX This breaks rendering properties with |
|
95 | + // Firefox, which never floats a <thead> to |
|
96 | + // the top. Ever. (Our scheme will float the |
|
97 | + // first <thead> to the top.) So maybe |
|
98 | + // <thead>s that are not first should be |
|
99 | + // turned into <tbody>? Very tricky, indeed. |
|
100 | + |
|
101 | + // access the appropriate variable, $thead or $tfoot |
|
102 | + $var = $collection[$tag_index]->name; |
|
103 | + if ($$var === false) { |
|
104 | + $$var = $collection; |
|
105 | + } else { |
|
106 | + // Oops, there's a second one! What |
|
107 | + // should we do? Current behavior is to |
|
108 | + // transmutate the first and last entries into |
|
109 | + // tbody tags, and then put into content. |
|
110 | + // Maybe a better idea is to *attach |
|
111 | + // it* to the existing thead or tfoot? |
|
112 | + // We don't do this, because Firefox |
|
113 | + // doesn't float an extra tfoot to the |
|
114 | + // bottom like it does for the first one. |
|
115 | + $collection[$tag_index]->name = 'tbody'; |
|
116 | + $collection[count($collection)-1]->name = 'tbody'; |
|
117 | + $content[] = $collection; |
|
118 | + } |
|
119 | + break; |
|
120 | + case 'colgroup': |
|
121 | + $cols[] = $collection; |
|
122 | + break; |
|
123 | + } |
|
124 | + $collection = array(); |
|
125 | + $is_collecting = false; |
|
126 | + $tag_index = 0; |
|
127 | + } else { |
|
128 | + // add the node to the collection |
|
129 | + $collection[] = $token; |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + // terminate |
|
134 | + if ($token === false) break; |
|
135 | + |
|
136 | + if ($is_child) { |
|
137 | + // determine what we're dealing with |
|
138 | + if ($token->name == 'col') { |
|
139 | + // the only empty tag in the possie, we can handle it |
|
140 | + // immediately |
|
141 | + $cols[] = array_merge($collection, array($token)); |
|
142 | + $collection = array(); |
|
143 | + $tag_index = 0; |
|
144 | + continue; |
|
145 | + } |
|
146 | + switch($token->name) { |
|
147 | + case 'caption': |
|
148 | + case 'colgroup': |
|
149 | + case 'thead': |
|
150 | + case 'tfoot': |
|
151 | + case 'tbody': |
|
152 | + case 'tr': |
|
153 | + $is_collecting = true; |
|
154 | + $collection[] = $token; |
|
155 | + continue; |
|
156 | + default: |
|
157 | + if (!empty($token->is_whitespace)) { |
|
158 | + $collection[] = $token; |
|
159 | + $tag_index++; |
|
160 | + } |
|
161 | + continue; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + if (empty($content)) return false; |
|
167 | + |
|
168 | + $ret = array(); |
|
169 | + if ($caption !== false) $ret = array_merge($ret, $caption); |
|
170 | + if ($cols !== false) foreach ($cols as $token_array) $ret = array_merge($ret, $token_array); |
|
171 | + if ($thead !== false) $ret = array_merge($ret, $thead); |
|
172 | + if ($tfoot !== false) $ret = array_merge($ret, $tfoot); |
|
173 | + |
|
174 | + if ($tbody_mode) { |
|
175 | + // a little tricky, since the start of the collection may be |
|
176 | + // whitespace |
|
177 | + $inside_tbody = false; |
|
178 | + foreach ($content as $token_array) { |
|
179 | + // find the starting token |
|
180 | + foreach ($token_array as $t) { |
|
181 | + if ($t->name === 'tr' || $t->name === 'tbody') { |
|
182 | + break; |
|
183 | + } |
|
184 | + } // iterator variable carries over |
|
185 | + if ($t->name === 'tr') { |
|
186 | + if ($inside_tbody) { |
|
187 | + $ret = array_merge($ret, $token_array); |
|
188 | + } else { |
|
189 | + $ret[] = new HTMLPurifier_Token_Start('tbody'); |
|
190 | + $ret = array_merge($ret, $token_array); |
|
191 | + $inside_tbody = true; |
|
192 | + } |
|
193 | + } elseif ($t->name === 'tbody') { |
|
194 | + if ($inside_tbody) { |
|
195 | + $ret[] = new HTMLPurifier_Token_End('tbody'); |
|
196 | + $inside_tbody = false; |
|
197 | + $ret = array_merge($ret, $token_array); |
|
198 | + } else { |
|
199 | + $ret = array_merge($ret, $token_array); |
|
200 | + } |
|
201 | + } else { |
|
202 | + trigger_error("tr/tbody in content invariant failed in Table ChildDef", E_USER_ERROR); |
|
203 | + } |
|
204 | + } |
|
205 | + if ($inside_tbody) { |
|
206 | + $ret[] = new HTMLPurifier_Token_End('tbody'); |
|
207 | + } |
|
208 | + } else { |
|
209 | + foreach ($content as $token_array) { |
|
210 | + // invariant: everything in here is <tr>s |
|
211 | + $ret = array_merge($ret, $token_array); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + if (!empty($collection) && $is_collecting == false){ |
|
216 | + // grab the trailing space |
|
217 | + $ret = array_merge($ret, $collection); |
|
218 | + } |
|
219 | + |
|
220 | + array_pop($tokens_of_children); // remove phantom token |
|
221 | + |
|
222 | + return ($ret === $tokens_of_children) ? true : $ret; |
|
223 | + |
|
224 | + } |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // vim: et sw=4 sts=4 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // doesn't float an extra tfoot to the |
114 | 114 | // bottom like it does for the first one. |
115 | 115 | $collection[$tag_index]->name = 'tbody'; |
116 | - $collection[count($collection)-1]->name = 'tbody'; |
|
116 | + $collection[count($collection) - 1]->name = 'tbody'; |
|
117 | 117 | $content[] = $collection; |
118 | 118 | } |
119 | 119 | break; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $tag_index = 0; |
144 | 144 | continue; |
145 | 145 | } |
146 | - switch($token->name) { |
|
146 | + switch ($token->name) { |
|
147 | 147 | case 'caption': |
148 | 148 | case 'colgroup': |
149 | 149 | case 'thead': |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if (!empty($collection) && $is_collecting == false){ |
|
215 | + if (!empty($collection) && $is_collecting == false) { |
|
216 | 216 | // grab the trailing space |
217 | 217 | $ret = array_merge($ret, $collection); |
218 | 218 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | 'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true); |
38 | 38 | public function __construct() {} |
39 | 39 | public function validateChildren($tokens_of_children, $config, $context) { |
40 | - if (empty($tokens_of_children)) return false; |
|
40 | + if (empty($tokens_of_children)) { |
|
41 | + return false; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | // this ensures that the loop gets run one last time before closing |
43 | 45 | // up. It's a little bit of a hack, but it works! Just make sure you |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | $content[] = $collection; |
86 | 88 | break; |
87 | 89 | case 'caption': |
88 | - if ($caption !== false) break; |
|
90 | + if ($caption !== false) { |
|
91 | + break; |
|
92 | + } |
|
89 | 93 | $caption = $collection; |
90 | 94 | break; |
91 | 95 | case 'thead': |
@@ -131,7 +135,9 @@ discard block |
||
131 | 135 | } |
132 | 136 | |
133 | 137 | // terminate |
134 | - if ($token === false) break; |
|
138 | + if ($token === false) { |
|
139 | + break; |
|
140 | + } |
|
135 | 141 | |
136 | 142 | if ($is_child) { |
137 | 143 | // determine what we're dealing with |
@@ -163,13 +169,23 @@ discard block |
||
163 | 169 | } |
164 | 170 | } |
165 | 171 | |
166 | - if (empty($content)) return false; |
|
172 | + if (empty($content)) { |
|
173 | + return false; |
|
174 | + } |
|
167 | 175 | |
168 | 176 | $ret = array(); |
169 | - if ($caption !== false) $ret = array_merge($ret, $caption); |
|
170 | - if ($cols !== false) foreach ($cols as $token_array) $ret = array_merge($ret, $token_array); |
|
171 | - if ($thead !== false) $ret = array_merge($ret, $thead); |
|
172 | - if ($tfoot !== false) $ret = array_merge($ret, $tfoot); |
|
177 | + if ($caption !== false) { |
|
178 | + $ret = array_merge($ret, $caption); |
|
179 | + } |
|
180 | + if ($cols !== false) { |
|
181 | + foreach ($cols as $token_array) $ret = array_merge($ret, $token_array); |
|
182 | + } |
|
183 | + if ($thead !== false) { |
|
184 | + $ret = array_merge($ret, $thead); |
|
185 | + } |
|
186 | + if ($tfoot !== false) { |
|
187 | + $ret = array_merge($ret, $tfoot); |
|
188 | + } |
|
173 | 189 | |
174 | 190 | if ($tbody_mode) { |
175 | 191 | // a little tricky, since the start of the collection may be |
@@ -5,159 +5,159 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_ConfigSchema { |
7 | 7 | |
8 | - /** |
|
9 | - * Defaults of the directives and namespaces. |
|
10 | - * @note This shares the exact same structure as HTMLPurifier_Config::$conf |
|
11 | - */ |
|
12 | - public $defaults = array(); |
|
8 | + /** |
|
9 | + * Defaults of the directives and namespaces. |
|
10 | + * @note This shares the exact same structure as HTMLPurifier_Config::$conf |
|
11 | + */ |
|
12 | + public $defaults = array(); |
|
13 | 13 | |
14 | - /** |
|
15 | - * The default property list. Do not edit this property list. |
|
16 | - */ |
|
17 | - public $defaultPlist; |
|
14 | + /** |
|
15 | + * The default property list. Do not edit this property list. |
|
16 | + */ |
|
17 | + public $defaultPlist; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Definition of the directives. The structure of this is: |
|
21 | - * |
|
22 | - * array( |
|
23 | - * 'Namespace' => array( |
|
24 | - * 'Directive' => new stdclass(), |
|
25 | - * ) |
|
26 | - * ) |
|
27 | - * |
|
28 | - * The stdclass may have the following properties: |
|
29 | - * |
|
30 | - * - If isAlias isn't set: |
|
31 | - * - type: Integer type of directive, see HTMLPurifier_VarParser for definitions |
|
32 | - * - allow_null: If set, this directive allows null values |
|
33 | - * - aliases: If set, an associative array of value aliases to real values |
|
34 | - * - allowed: If set, a lookup array of allowed (string) values |
|
35 | - * - If isAlias is set: |
|
36 | - * - namespace: Namespace this directive aliases to |
|
37 | - * - name: Directive name this directive aliases to |
|
38 | - * |
|
39 | - * In certain degenerate cases, stdclass will actually be an integer. In |
|
40 | - * that case, the value is equivalent to an stdclass with the type |
|
41 | - * property set to the integer. If the integer is negative, type is |
|
42 | - * equal to the absolute value of integer, and allow_null is true. |
|
43 | - * |
|
44 | - * This class is friendly with HTMLPurifier_Config. If you need introspection |
|
45 | - * about the schema, you're better of using the ConfigSchema_Interchange, |
|
46 | - * which uses more memory but has much richer information. |
|
47 | - */ |
|
48 | - public $info = array(); |
|
19 | + /** |
|
20 | + * Definition of the directives. The structure of this is: |
|
21 | + * |
|
22 | + * array( |
|
23 | + * 'Namespace' => array( |
|
24 | + * 'Directive' => new stdclass(), |
|
25 | + * ) |
|
26 | + * ) |
|
27 | + * |
|
28 | + * The stdclass may have the following properties: |
|
29 | + * |
|
30 | + * - If isAlias isn't set: |
|
31 | + * - type: Integer type of directive, see HTMLPurifier_VarParser for definitions |
|
32 | + * - allow_null: If set, this directive allows null values |
|
33 | + * - aliases: If set, an associative array of value aliases to real values |
|
34 | + * - allowed: If set, a lookup array of allowed (string) values |
|
35 | + * - If isAlias is set: |
|
36 | + * - namespace: Namespace this directive aliases to |
|
37 | + * - name: Directive name this directive aliases to |
|
38 | + * |
|
39 | + * In certain degenerate cases, stdclass will actually be an integer. In |
|
40 | + * that case, the value is equivalent to an stdclass with the type |
|
41 | + * property set to the integer. If the integer is negative, type is |
|
42 | + * equal to the absolute value of integer, and allow_null is true. |
|
43 | + * |
|
44 | + * This class is friendly with HTMLPurifier_Config. If you need introspection |
|
45 | + * about the schema, you're better of using the ConfigSchema_Interchange, |
|
46 | + * which uses more memory but has much richer information. |
|
47 | + */ |
|
48 | + public $info = array(); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Application-wide singleton |
|
52 | - */ |
|
53 | - static protected $singleton; |
|
50 | + /** |
|
51 | + * Application-wide singleton |
|
52 | + */ |
|
53 | + static protected $singleton; |
|
54 | 54 | |
55 | - public function __construct() { |
|
56 | - $this->defaultPlist = new HTMLPurifier_PropertyList(); |
|
57 | - } |
|
55 | + public function __construct() { |
|
56 | + $this->defaultPlist = new HTMLPurifier_PropertyList(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Unserializes the default ConfigSchema. |
|
61 | - */ |
|
62 | - public static function makeFromSerial() { |
|
63 | - $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'); |
|
64 | - $r = unserialize($contents); |
|
65 | - if (!$r) { |
|
66 | - $hash = sha1($contents); |
|
67 | - trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR); |
|
68 | - } |
|
69 | - return $r; |
|
70 | - } |
|
59 | + /** |
|
60 | + * Unserializes the default ConfigSchema. |
|
61 | + */ |
|
62 | + public static function makeFromSerial() { |
|
63 | + $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'); |
|
64 | + $r = unserialize($contents); |
|
65 | + if (!$r) { |
|
66 | + $hash = sha1($contents); |
|
67 | + trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR); |
|
68 | + } |
|
69 | + return $r; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Retrieves an instance of the application-wide configuration definition. |
|
74 | - */ |
|
75 | - public static function instance($prototype = null) { |
|
76 | - if ($prototype !== null) { |
|
77 | - HTMLPurifier_ConfigSchema::$singleton = $prototype; |
|
78 | - } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) { |
|
79 | - HTMLPurifier_ConfigSchema::$singleton = HTMLPurifier_ConfigSchema::makeFromSerial(); |
|
80 | - } |
|
81 | - return HTMLPurifier_ConfigSchema::$singleton; |
|
82 | - } |
|
72 | + /** |
|
73 | + * Retrieves an instance of the application-wide configuration definition. |
|
74 | + */ |
|
75 | + public static function instance($prototype = null) { |
|
76 | + if ($prototype !== null) { |
|
77 | + HTMLPurifier_ConfigSchema::$singleton = $prototype; |
|
78 | + } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) { |
|
79 | + HTMLPurifier_ConfigSchema::$singleton = HTMLPurifier_ConfigSchema::makeFromSerial(); |
|
80 | + } |
|
81 | + return HTMLPurifier_ConfigSchema::$singleton; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Defines a directive for configuration |
|
86 | - * @warning Will fail of directive's namespace is defined. |
|
87 | - * @warning This method's signature is slightly different from the legacy |
|
88 | - * define() static method! Beware! |
|
89 | - * @param $namespace Namespace the directive is in |
|
90 | - * @param $name Key of directive |
|
91 | - * @param $default Default value of directive |
|
92 | - * @param $type Allowed type of the directive. See |
|
93 | - * HTMLPurifier_DirectiveDef::$type for allowed values |
|
94 | - * @param $allow_null Whether or not to allow null values |
|
95 | - */ |
|
96 | - public function add($key, $default, $type, $allow_null) { |
|
97 | - $obj = new stdclass(); |
|
98 | - $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type]; |
|
99 | - if ($allow_null) $obj->allow_null = true; |
|
100 | - $this->info[$key] = $obj; |
|
101 | - $this->defaults[$key] = $default; |
|
102 | - $this->defaultPlist->set($key, $default); |
|
103 | - } |
|
84 | + /** |
|
85 | + * Defines a directive for configuration |
|
86 | + * @warning Will fail of directive's namespace is defined. |
|
87 | + * @warning This method's signature is slightly different from the legacy |
|
88 | + * define() static method! Beware! |
|
89 | + * @param $namespace Namespace the directive is in |
|
90 | + * @param $name Key of directive |
|
91 | + * @param $default Default value of directive |
|
92 | + * @param $type Allowed type of the directive. See |
|
93 | + * HTMLPurifier_DirectiveDef::$type for allowed values |
|
94 | + * @param $allow_null Whether or not to allow null values |
|
95 | + */ |
|
96 | + public function add($key, $default, $type, $allow_null) { |
|
97 | + $obj = new stdclass(); |
|
98 | + $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type]; |
|
99 | + if ($allow_null) $obj->allow_null = true; |
|
100 | + $this->info[$key] = $obj; |
|
101 | + $this->defaults[$key] = $default; |
|
102 | + $this->defaultPlist->set($key, $default); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Defines a directive value alias. |
|
107 | - * |
|
108 | - * Directive value aliases are convenient for developers because it lets |
|
109 | - * them set a directive to several values and get the same result. |
|
110 | - * @param $namespace Directive's namespace |
|
111 | - * @param $name Name of Directive |
|
112 | - * @param $aliases Hash of aliased values to the real alias |
|
113 | - */ |
|
114 | - public function addValueAliases($key, $aliases) { |
|
115 | - if (!isset($this->info[$key]->aliases)) { |
|
116 | - $this->info[$key]->aliases = array(); |
|
117 | - } |
|
118 | - foreach ($aliases as $alias => $real) { |
|
119 | - $this->info[$key]->aliases[$alias] = $real; |
|
120 | - } |
|
121 | - } |
|
105 | + /** |
|
106 | + * Defines a directive value alias. |
|
107 | + * |
|
108 | + * Directive value aliases are convenient for developers because it lets |
|
109 | + * them set a directive to several values and get the same result. |
|
110 | + * @param $namespace Directive's namespace |
|
111 | + * @param $name Name of Directive |
|
112 | + * @param $aliases Hash of aliased values to the real alias |
|
113 | + */ |
|
114 | + public function addValueAliases($key, $aliases) { |
|
115 | + if (!isset($this->info[$key]->aliases)) { |
|
116 | + $this->info[$key]->aliases = array(); |
|
117 | + } |
|
118 | + foreach ($aliases as $alias => $real) { |
|
119 | + $this->info[$key]->aliases[$alias] = $real; |
|
120 | + } |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Defines a set of allowed values for a directive. |
|
125 | - * @warning This is slightly different from the corresponding static |
|
126 | - * method definition. |
|
127 | - * @param $namespace Namespace of directive |
|
128 | - * @param $name Name of directive |
|
129 | - * @param $allowed Lookup array of allowed values |
|
130 | - */ |
|
131 | - public function addAllowedValues($key, $allowed) { |
|
132 | - $this->info[$key]->allowed = $allowed; |
|
133 | - } |
|
123 | + /** |
|
124 | + * Defines a set of allowed values for a directive. |
|
125 | + * @warning This is slightly different from the corresponding static |
|
126 | + * method definition. |
|
127 | + * @param $namespace Namespace of directive |
|
128 | + * @param $name Name of directive |
|
129 | + * @param $allowed Lookup array of allowed values |
|
130 | + */ |
|
131 | + public function addAllowedValues($key, $allowed) { |
|
132 | + $this->info[$key]->allowed = $allowed; |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Defines a directive alias for backwards compatibility |
|
137 | - * @param $namespace |
|
138 | - * @param $name Directive that will be aliased |
|
139 | - * @param $new_namespace |
|
140 | - * @param $new_name Directive that the alias will be to |
|
141 | - */ |
|
142 | - public function addAlias($key, $new_key) { |
|
143 | - $obj = new stdclass; |
|
144 | - $obj->key = $new_key; |
|
145 | - $obj->isAlias = true; |
|
146 | - $this->info[$key] = $obj; |
|
147 | - } |
|
135 | + /** |
|
136 | + * Defines a directive alias for backwards compatibility |
|
137 | + * @param $namespace |
|
138 | + * @param $name Directive that will be aliased |
|
139 | + * @param $new_namespace |
|
140 | + * @param $new_name Directive that the alias will be to |
|
141 | + */ |
|
142 | + public function addAlias($key, $new_key) { |
|
143 | + $obj = new stdclass; |
|
144 | + $obj->key = $new_key; |
|
145 | + $obj->isAlias = true; |
|
146 | + $this->info[$key] = $obj; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Replaces any stdclass that only has the type property with type integer. |
|
151 | - */ |
|
152 | - public function postProcess() { |
|
153 | - foreach ($this->info as $key => $v) { |
|
154 | - if (count((array) $v) == 1) { |
|
155 | - $this->info[$key] = $v->type; |
|
156 | - } elseif (count((array) $v) == 2 && isset($v->allow_null)) { |
|
157 | - $this->info[$key] = -$v->type; |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
149 | + /** |
|
150 | + * Replaces any stdclass that only has the type property with type integer. |
|
151 | + */ |
|
152 | + public function postProcess() { |
|
153 | + foreach ($this->info as $key => $v) { |
|
154 | + if (count((array) $v) == 1) { |
|
155 | + $this->info[$key] = $v->type; |
|
156 | + } elseif (count((array) $v) == 2 && isset($v->allow_null)) { |
|
157 | + $this->info[$key] = -$v->type; |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | 162 | } |
163 | 163 |
@@ -96,7 +96,9 @@ |
||
96 | 96 | public function add($key, $default, $type, $allow_null) { |
97 | 97 | $obj = new stdclass(); |
98 | 98 | $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type]; |
99 | - if ($allow_null) $obj->allow_null = true; |
|
99 | + if ($allow_null) { |
|
100 | + $obj->allow_null = true; |
|
101 | + } |
|
100 | 102 | $this->info[$key] = $obj; |
101 | 103 | $this->defaults[$key] = $default; |
102 | 104 | $this->defaultPlist->set($key, $default); |
@@ -7,37 +7,37 @@ |
||
7 | 7 | class HTMLPurifier_ConfigSchema_Builder_ConfigSchema |
8 | 8 | { |
9 | 9 | |
10 | - public function build($interchange) { |
|
11 | - $schema = new HTMLPurifier_ConfigSchema(); |
|
12 | - foreach ($interchange->directives as $d) { |
|
13 | - $schema->add( |
|
14 | - $d->id->key, |
|
15 | - $d->default, |
|
16 | - $d->type, |
|
17 | - $d->typeAllowsNull |
|
18 | - ); |
|
19 | - if ($d->allowed !== null) { |
|
20 | - $schema->addAllowedValues( |
|
21 | - $d->id->key, |
|
22 | - $d->allowed |
|
23 | - ); |
|
24 | - } |
|
25 | - foreach ($d->aliases as $alias) { |
|
26 | - $schema->addAlias( |
|
27 | - $alias->key, |
|
28 | - $d->id->key |
|
29 | - ); |
|
30 | - } |
|
31 | - if ($d->valueAliases !== null) { |
|
32 | - $schema->addValueAliases( |
|
33 | - $d->id->key, |
|
34 | - $d->valueAliases |
|
35 | - ); |
|
36 | - } |
|
37 | - } |
|
38 | - $schema->postProcess(); |
|
39 | - return $schema; |
|
40 | - } |
|
10 | + public function build($interchange) { |
|
11 | + $schema = new HTMLPurifier_ConfigSchema(); |
|
12 | + foreach ($interchange->directives as $d) { |
|
13 | + $schema->add( |
|
14 | + $d->id->key, |
|
15 | + $d->default, |
|
16 | + $d->type, |
|
17 | + $d->typeAllowsNull |
|
18 | + ); |
|
19 | + if ($d->allowed !== null) { |
|
20 | + $schema->addAllowedValues( |
|
21 | + $d->id->key, |
|
22 | + $d->allowed |
|
23 | + ); |
|
24 | + } |
|
25 | + foreach ($d->aliases as $alias) { |
|
26 | + $schema->addAlias( |
|
27 | + $alias->key, |
|
28 | + $d->id->key |
|
29 | + ); |
|
30 | + } |
|
31 | + if ($d->valueAliases !== null) { |
|
32 | + $schema->addValueAliases( |
|
33 | + $d->id->key, |
|
34 | + $d->valueAliases |
|
35 | + ); |
|
36 | + } |
|
37 | + } |
|
38 | + $schema->postProcess(); |
|
39 | + return $schema; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
43 | 43 |
@@ -7,99 +7,99 @@ |
||
7 | 7 | class HTMLPurifier_ConfigSchema_Builder_Xml extends XMLWriter |
8 | 8 | { |
9 | 9 | |
10 | - protected $interchange; |
|
11 | - private $namespace; |
|
12 | - |
|
13 | - protected function writeHTMLDiv($html) { |
|
14 | - $this->startElement('div'); |
|
15 | - |
|
16 | - $purifier = HTMLPurifier::getInstance(); |
|
17 | - $html = $purifier->purify($html); |
|
18 | - $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); |
|
19 | - $this->writeRaw($html); |
|
20 | - |
|
21 | - $this->endElement(); // div |
|
22 | - } |
|
23 | - |
|
24 | - protected function export($var) { |
|
25 | - if ($var === array()) return 'array()'; |
|
26 | - return var_export($var, true); |
|
27 | - } |
|
28 | - |
|
29 | - public function build($interchange) { |
|
30 | - // global access, only use as last resort |
|
31 | - $this->interchange = $interchange; |
|
32 | - |
|
33 | - $this->setIndent(true); |
|
34 | - $this->startDocument('1.0', 'UTF-8'); |
|
35 | - $this->startElement('configdoc'); |
|
36 | - $this->writeElement('title', $interchange->name); |
|
37 | - |
|
38 | - foreach ($interchange->directives as $directive) { |
|
39 | - $this->buildDirective($directive); |
|
40 | - } |
|
41 | - |
|
42 | - if ($this->namespace) $this->endElement(); // namespace |
|
43 | - |
|
44 | - $this->endElement(); // configdoc |
|
45 | - $this->flush(); |
|
46 | - } |
|
47 | - |
|
48 | - public function buildDirective($directive) { |
|
49 | - |
|
50 | - // Kludge, although I suppose having a notion of a "root namespace" |
|
51 | - // certainly makes things look nicer when documentation is built. |
|
52 | - // Depends on things being sorted. |
|
53 | - if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { |
|
54 | - if ($this->namespace) $this->endElement(); // namespace |
|
55 | - $this->namespace = $directive->id->getRootNamespace(); |
|
56 | - $this->startElement('namespace'); |
|
57 | - $this->writeAttribute('id', $this->namespace); |
|
58 | - $this->writeElement('name', $this->namespace); |
|
59 | - } |
|
60 | - |
|
61 | - $this->startElement('directive'); |
|
62 | - $this->writeAttribute('id', $directive->id->toString()); |
|
63 | - |
|
64 | - $this->writeElement('name', $directive->id->getDirective()); |
|
65 | - |
|
66 | - $this->startElement('aliases'); |
|
67 | - foreach ($directive->aliases as $alias) $this->writeElement('alias', $alias->toString()); |
|
68 | - $this->endElement(); // aliases |
|
69 | - |
|
70 | - $this->startElement('constraints'); |
|
71 | - if ($directive->version) $this->writeElement('version', $directive->version); |
|
72 | - $this->startElement('type'); |
|
73 | - if ($directive->typeAllowsNull) $this->writeAttribute('allow-null', 'yes'); |
|
74 | - $this->text($directive->type); |
|
75 | - $this->endElement(); // type |
|
76 | - if ($directive->allowed) { |
|
77 | - $this->startElement('allowed'); |
|
78 | - foreach ($directive->allowed as $value => $x) $this->writeElement('value', $value); |
|
79 | - $this->endElement(); // allowed |
|
80 | - } |
|
81 | - $this->writeElement('default', $this->export($directive->default)); |
|
82 | - $this->writeAttribute('xml:space', 'preserve'); |
|
83 | - if ($directive->external) { |
|
84 | - $this->startElement('external'); |
|
85 | - foreach ($directive->external as $project) $this->writeElement('project', $project); |
|
86 | - $this->endElement(); |
|
87 | - } |
|
88 | - $this->endElement(); // constraints |
|
89 | - |
|
90 | - if ($directive->deprecatedVersion) { |
|
91 | - $this->startElement('deprecated'); |
|
92 | - $this->writeElement('version', $directive->deprecatedVersion); |
|
93 | - $this->writeElement('use', $directive->deprecatedUse->toString()); |
|
94 | - $this->endElement(); // deprecated |
|
95 | - } |
|
96 | - |
|
97 | - $this->startElement('description'); |
|
98 | - $this->writeHTMLDiv($directive->description); |
|
99 | - $this->endElement(); // description |
|
100 | - |
|
101 | - $this->endElement(); // directive |
|
102 | - } |
|
10 | + protected $interchange; |
|
11 | + private $namespace; |
|
12 | + |
|
13 | + protected function writeHTMLDiv($html) { |
|
14 | + $this->startElement('div'); |
|
15 | + |
|
16 | + $purifier = HTMLPurifier::getInstance(); |
|
17 | + $html = $purifier->purify($html); |
|
18 | + $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); |
|
19 | + $this->writeRaw($html); |
|
20 | + |
|
21 | + $this->endElement(); // div |
|
22 | + } |
|
23 | + |
|
24 | + protected function export($var) { |
|
25 | + if ($var === array()) return 'array()'; |
|
26 | + return var_export($var, true); |
|
27 | + } |
|
28 | + |
|
29 | + public function build($interchange) { |
|
30 | + // global access, only use as last resort |
|
31 | + $this->interchange = $interchange; |
|
32 | + |
|
33 | + $this->setIndent(true); |
|
34 | + $this->startDocument('1.0', 'UTF-8'); |
|
35 | + $this->startElement('configdoc'); |
|
36 | + $this->writeElement('title', $interchange->name); |
|
37 | + |
|
38 | + foreach ($interchange->directives as $directive) { |
|
39 | + $this->buildDirective($directive); |
|
40 | + } |
|
41 | + |
|
42 | + if ($this->namespace) $this->endElement(); // namespace |
|
43 | + |
|
44 | + $this->endElement(); // configdoc |
|
45 | + $this->flush(); |
|
46 | + } |
|
47 | + |
|
48 | + public function buildDirective($directive) { |
|
49 | + |
|
50 | + // Kludge, although I suppose having a notion of a "root namespace" |
|
51 | + // certainly makes things look nicer when documentation is built. |
|
52 | + // Depends on things being sorted. |
|
53 | + if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { |
|
54 | + if ($this->namespace) $this->endElement(); // namespace |
|
55 | + $this->namespace = $directive->id->getRootNamespace(); |
|
56 | + $this->startElement('namespace'); |
|
57 | + $this->writeAttribute('id', $this->namespace); |
|
58 | + $this->writeElement('name', $this->namespace); |
|
59 | + } |
|
60 | + |
|
61 | + $this->startElement('directive'); |
|
62 | + $this->writeAttribute('id', $directive->id->toString()); |
|
63 | + |
|
64 | + $this->writeElement('name', $directive->id->getDirective()); |
|
65 | + |
|
66 | + $this->startElement('aliases'); |
|
67 | + foreach ($directive->aliases as $alias) $this->writeElement('alias', $alias->toString()); |
|
68 | + $this->endElement(); // aliases |
|
69 | + |
|
70 | + $this->startElement('constraints'); |
|
71 | + if ($directive->version) $this->writeElement('version', $directive->version); |
|
72 | + $this->startElement('type'); |
|
73 | + if ($directive->typeAllowsNull) $this->writeAttribute('allow-null', 'yes'); |
|
74 | + $this->text($directive->type); |
|
75 | + $this->endElement(); // type |
|
76 | + if ($directive->allowed) { |
|
77 | + $this->startElement('allowed'); |
|
78 | + foreach ($directive->allowed as $value => $x) $this->writeElement('value', $value); |
|
79 | + $this->endElement(); // allowed |
|
80 | + } |
|
81 | + $this->writeElement('default', $this->export($directive->default)); |
|
82 | + $this->writeAttribute('xml:space', 'preserve'); |
|
83 | + if ($directive->external) { |
|
84 | + $this->startElement('external'); |
|
85 | + foreach ($directive->external as $project) $this->writeElement('project', $project); |
|
86 | + $this->endElement(); |
|
87 | + } |
|
88 | + $this->endElement(); // constraints |
|
89 | + |
|
90 | + if ($directive->deprecatedVersion) { |
|
91 | + $this->startElement('deprecated'); |
|
92 | + $this->writeElement('version', $directive->deprecatedVersion); |
|
93 | + $this->writeElement('use', $directive->deprecatedUse->toString()); |
|
94 | + $this->endElement(); // deprecated |
|
95 | + } |
|
96 | + |
|
97 | + $this->startElement('description'); |
|
98 | + $this->writeHTMLDiv($directive->description); |
|
99 | + $this->endElement(); // description |
|
100 | + |
|
101 | + $this->endElement(); // directive |
|
102 | + } |
|
103 | 103 | |
104 | 104 | } |
105 | 105 |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | protected function export($var) { |
25 | - if ($var === array()) return 'array()'; |
|
25 | + if ($var === array()) { |
|
26 | + return 'array()'; |
|
27 | + } |
|
26 | 28 | return var_export($var, true); |
27 | 29 | } |
28 | 30 | |
@@ -39,7 +41,10 @@ discard block |
||
39 | 41 | $this->buildDirective($directive); |
40 | 42 | } |
41 | 43 | |
42 | - if ($this->namespace) $this->endElement(); // namespace |
|
44 | + if ($this->namespace) { |
|
45 | + $this->endElement(); |
|
46 | + } |
|
47 | + // namespace |
|
43 | 48 | |
44 | 49 | $this->endElement(); // configdoc |
45 | 50 | $this->flush(); |
@@ -51,7 +56,10 @@ discard block |
||
51 | 56 | // certainly makes things look nicer when documentation is built. |
52 | 57 | // Depends on things being sorted. |
53 | 58 | if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { |
54 | - if ($this->namespace) $this->endElement(); // namespace |
|
59 | + if ($this->namespace) { |
|
60 | + $this->endElement(); |
|
61 | + } |
|
62 | + // namespace |
|
55 | 63 | $this->namespace = $directive->id->getRootNamespace(); |
56 | 64 | $this->startElement('namespace'); |
57 | 65 | $this->writeAttribute('id', $this->namespace); |
@@ -64,25 +72,35 @@ discard block |
||
64 | 72 | $this->writeElement('name', $directive->id->getDirective()); |
65 | 73 | |
66 | 74 | $this->startElement('aliases'); |
67 | - foreach ($directive->aliases as $alias) $this->writeElement('alias', $alias->toString()); |
|
75 | + foreach ($directive->aliases as $alias) { |
|
76 | + $this->writeElement('alias', $alias->toString()); |
|
77 | + } |
|
68 | 78 | $this->endElement(); // aliases |
69 | 79 | |
70 | 80 | $this->startElement('constraints'); |
71 | - if ($directive->version) $this->writeElement('version', $directive->version); |
|
81 | + if ($directive->version) { |
|
82 | + $this->writeElement('version', $directive->version); |
|
83 | + } |
|
72 | 84 | $this->startElement('type'); |
73 | - if ($directive->typeAllowsNull) $this->writeAttribute('allow-null', 'yes'); |
|
85 | + if ($directive->typeAllowsNull) { |
|
86 | + $this->writeAttribute('allow-null', 'yes'); |
|
87 | + } |
|
74 | 88 | $this->text($directive->type); |
75 | 89 | $this->endElement(); // type |
76 | 90 | if ($directive->allowed) { |
77 | 91 | $this->startElement('allowed'); |
78 | - foreach ($directive->allowed as $value => $x) $this->writeElement('value', $value); |
|
92 | + foreach ($directive->allowed as $value => $x) { |
|
93 | + $this->writeElement('value', $value); |
|
94 | + } |
|
79 | 95 | $this->endElement(); // allowed |
80 | 96 | } |
81 | 97 | $this->writeElement('default', $this->export($directive->default)); |
82 | 98 | $this->writeAttribute('xml:space', 'preserve'); |
83 | 99 | if ($directive->external) { |
84 | 100 | $this->startElement('external'); |
85 | - foreach ($directive->external as $project) $this->writeElement('project', $project); |
|
101 | + foreach ($directive->external as $project) { |
|
102 | + $this->writeElement('project', $project); |
|
103 | + } |
|
86 | 104 | $this->endElement(); |
87 | 105 | } |
88 | 106 | $this->endElement(); // constraints |
@@ -8,34 +8,34 @@ |
||
8 | 8 | class HTMLPurifier_ConfigSchema_Interchange |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Name of the application this schema is describing. |
|
13 | - */ |
|
14 | - public $name; |
|
11 | + /** |
|
12 | + * Name of the application this schema is describing. |
|
13 | + */ |
|
14 | + public $name; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Array of Directive ID => array(directive info) |
|
18 | - */ |
|
19 | - public $directives = array(); |
|
16 | + /** |
|
17 | + * Array of Directive ID => array(directive info) |
|
18 | + */ |
|
19 | + public $directives = array(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * Adds a directive array to $directives |
|
23 | - */ |
|
24 | - public function addDirective($directive) { |
|
25 | - if (isset($this->directives[$i = $directive->id->toString()])) { |
|
26 | - throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); |
|
27 | - } |
|
28 | - $this->directives[$i] = $directive; |
|
29 | - } |
|
21 | + /** |
|
22 | + * Adds a directive array to $directives |
|
23 | + */ |
|
24 | + public function addDirective($directive) { |
|
25 | + if (isset($this->directives[$i = $directive->id->toString()])) { |
|
26 | + throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); |
|
27 | + } |
|
28 | + $this->directives[$i] = $directive; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Convenience function to perform standard validation. Throws exception |
|
33 | - * on failed validation. |
|
34 | - */ |
|
35 | - public function validate() { |
|
36 | - $validator = new HTMLPurifier_ConfigSchema_Validator(); |
|
37 | - return $validator->validate($this); |
|
38 | - } |
|
31 | + /** |
|
32 | + * Convenience function to perform standard validation. Throws exception |
|
33 | + * on failed validation. |
|
34 | + */ |
|
35 | + public function validate() { |
|
36 | + $validator = new HTMLPurifier_ConfigSchema_Validator(); |
|
37 | + return $validator->validate($this); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
41 | 41 |
@@ -6,71 +6,71 @@ |
||
6 | 6 | class HTMLPurifier_ConfigSchema_Interchange_Directive |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * ID of directive, instance of HTMLPurifier_ConfigSchema_Interchange_Id. |
|
11 | - */ |
|
12 | - public $id; |
|
9 | + /** |
|
10 | + * ID of directive, instance of HTMLPurifier_ConfigSchema_Interchange_Id. |
|
11 | + */ |
|
12 | + public $id; |
|
13 | 13 | |
14 | - /** |
|
15 | - * String type, e.g. 'integer' or 'istring'. |
|
16 | - */ |
|
17 | - public $type; |
|
14 | + /** |
|
15 | + * String type, e.g. 'integer' or 'istring'. |
|
16 | + */ |
|
17 | + public $type; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Default value, e.g. 3 or 'DefaultVal'. |
|
21 | - */ |
|
22 | - public $default; |
|
19 | + /** |
|
20 | + * Default value, e.g. 3 or 'DefaultVal'. |
|
21 | + */ |
|
22 | + public $default; |
|
23 | 23 | |
24 | - /** |
|
25 | - * HTML description. |
|
26 | - */ |
|
27 | - public $description; |
|
24 | + /** |
|
25 | + * HTML description. |
|
26 | + */ |
|
27 | + public $description; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Boolean whether or not null is allowed as a value. |
|
31 | - */ |
|
32 | - public $typeAllowsNull = false; |
|
29 | + /** |
|
30 | + * Boolean whether or not null is allowed as a value. |
|
31 | + */ |
|
32 | + public $typeAllowsNull = false; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Lookup table of allowed scalar values, e.g. array('allowed' => true). |
|
36 | - * Null if all values are allowed. |
|
37 | - */ |
|
38 | - public $allowed; |
|
34 | + /** |
|
35 | + * Lookup table of allowed scalar values, e.g. array('allowed' => true). |
|
36 | + * Null if all values are allowed. |
|
37 | + */ |
|
38 | + public $allowed; |
|
39 | 39 | |
40 | - /** |
|
41 | - * List of aliases for the directive, |
|
42 | - * e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). |
|
43 | - */ |
|
44 | - public $aliases = array(); |
|
40 | + /** |
|
41 | + * List of aliases for the directive, |
|
42 | + * e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). |
|
43 | + */ |
|
44 | + public $aliases = array(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Hash of value aliases, e.g. array('alt' => 'real'). Null if value |
|
48 | - * aliasing is disabled (necessary for non-scalar types). |
|
49 | - */ |
|
50 | - public $valueAliases; |
|
46 | + /** |
|
47 | + * Hash of value aliases, e.g. array('alt' => 'real'). Null if value |
|
48 | + * aliasing is disabled (necessary for non-scalar types). |
|
49 | + */ |
|
50 | + public $valueAliases; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. |
|
54 | - * Null if the directive has always existed. |
|
55 | - */ |
|
56 | - public $version; |
|
52 | + /** |
|
53 | + * Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. |
|
54 | + * Null if the directive has always existed. |
|
55 | + */ |
|
56 | + public $version; |
|
57 | 57 | |
58 | - /** |
|
59 | - * ID of directive that supercedes this old directive, is an instance |
|
60 | - * of HTMLPurifier_ConfigSchema_Interchange_Id. Null if not deprecated. |
|
61 | - */ |
|
62 | - public $deprecatedUse; |
|
58 | + /** |
|
59 | + * ID of directive that supercedes this old directive, is an instance |
|
60 | + * of HTMLPurifier_ConfigSchema_Interchange_Id. Null if not deprecated. |
|
61 | + */ |
|
62 | + public $deprecatedUse; |
|
63 | 63 | |
64 | - /** |
|
65 | - * Version of HTML Purifier this directive was deprecated. Null if not |
|
66 | - * deprecated. |
|
67 | - */ |
|
68 | - public $deprecatedVersion; |
|
64 | + /** |
|
65 | + * Version of HTML Purifier this directive was deprecated. Null if not |
|
66 | + * deprecated. |
|
67 | + */ |
|
68 | + public $deprecatedVersion; |
|
69 | 69 | |
70 | - /** |
|
71 | - * List of external projects this directive depends on, e.g. array('CSSTidy'). |
|
72 | - */ |
|
73 | - public $external = array(); |
|
70 | + /** |
|
71 | + * List of external projects this directive depends on, e.g. array('CSSTidy'). |
|
72 | + */ |
|
73 | + public $external = array(); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 |
@@ -6,31 +6,31 @@ |
||
6 | 6 | class HTMLPurifier_ConfigSchema_Interchange_Id |
7 | 7 | { |
8 | 8 | |
9 | - public $key; |
|
10 | - |
|
11 | - public function __construct($key) { |
|
12 | - $this->key = $key; |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * @warning This is NOT magic, to ensure that people don't abuse SPL and |
|
17 | - * cause problems for PHP 5.0 support. |
|
18 | - */ |
|
19 | - public function toString() { |
|
20 | - return $this->key; |
|
21 | - } |
|
22 | - |
|
23 | - public function getRootNamespace() { |
|
24 | - return substr($this->key, 0, strpos($this->key, ".")); |
|
25 | - } |
|
26 | - |
|
27 | - public function getDirective() { |
|
28 | - return substr($this->key, strpos($this->key, ".") + 1); |
|
29 | - } |
|
30 | - |
|
31 | - public static function make($id) { |
|
32 | - return new HTMLPurifier_ConfigSchema_Interchange_Id($id); |
|
33 | - } |
|
9 | + public $key; |
|
10 | + |
|
11 | + public function __construct($key) { |
|
12 | + $this->key = $key; |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * @warning This is NOT magic, to ensure that people don't abuse SPL and |
|
17 | + * cause problems for PHP 5.0 support. |
|
18 | + */ |
|
19 | + public function toString() { |
|
20 | + return $this->key; |
|
21 | + } |
|
22 | + |
|
23 | + public function getRootNamespace() { |
|
24 | + return substr($this->key, 0, strpos($this->key, ".")); |
|
25 | + } |
|
26 | + |
|
27 | + public function getDirective() { |
|
28 | + return substr($this->key, strpos($this->key, ".") + 1); |
|
29 | + } |
|
30 | + |
|
31 | + public static function make($id) { |
|
32 | + return new HTMLPurifier_ConfigSchema_Interchange_Id($id); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | } |
36 | 36 |