|
1 | 1 | <?php |
2 | 2 |
|
3 | | -class HTMLPurifier_ChildDef_Figure extends HTMLPurifier_ChildDef |
4 | | -{ |
5 | | - public $type = 'figure'; |
6 | | - |
7 | | - public $elements = array( |
8 | | - 'figcaption' => true, |
9 | | - ); |
10 | | - |
11 | | - protected $allowedElements; |
12 | | - |
13 | | - /** |
14 | | - * @param HTMLPurifier_Config $config |
15 | | - * @return array |
16 | | - */ |
17 | | - public function getAllowedElements($config) |
18 | | - { |
19 | | - if (null === $this->allowedElements) { |
20 | | - // Add Flow content to allowed elements to prevent MakeWellFormed |
21 | | - // strategy moving them outside 'figure' element |
22 | | - $def = $config->getHTMLDefinition(); |
23 | | - |
24 | | - $this->allowedElements = array_merge( |
25 | | - $def->info_content_sets['Flow'], |
26 | | - $this->elements |
27 | | - ); |
28 | | - } |
29 | | - return $this->allowedElements; |
30 | | - } |
31 | | - |
32 | | - /** |
33 | | - * @param array $children |
34 | | - * @param HTMLPurifier_Config $config |
35 | | - * @param HTMLPurifier_Context $context |
36 | | - * @return array|bool |
37 | | - */ |
38 | | - public function validateChildren($children, $config, $context) |
39 | | - { |
40 | | - $hasFigcaption = false; |
41 | | - $figcaptionPos = -1; |
42 | | - |
43 | | - $result = array(); |
44 | | - |
45 | | - // Content model: |
46 | | - // Either: one figcaption element followed by flow content. |
47 | | - // Or: flow content followed by one figcaption element. |
48 | | - // Or: flow content. |
49 | | - |
50 | | - // Scan through children, accept at most one figcaption. |
51 | | - foreach ($children as $node) { |
52 | | - if ($node->name === 'figcaption') { |
53 | | - if (!$hasFigcaption) { |
54 | | - $hasFigcaption = true; |
55 | | - $figcaptionPos = count($result); |
56 | | - $result[] = $node; |
57 | | - } |
58 | | - continue; |
59 | | - } |
60 | | - |
61 | | - // Figcaption must be a first or last child of a figure element. |
62 | | - // If it's not first, then we ignore all siblings that come after. |
63 | | - if ($hasFigcaption && $figcaptionPos > 0) { |
64 | | - break; |
65 | | - } |
66 | | - |
67 | | - $result[] = $node; |
68 | | - } |
69 | | - |
70 | | - $whitespaceOnly = true; |
71 | | - foreach ($result as $node) { |
72 | | - $whitespaceOnly = $whitespaceOnly && !empty($node->is_whitespace); |
73 | | - } |
74 | | - |
75 | | - // remove parent node if there are no children or all children are whitespace-only |
76 | | - if (empty($result) || $whitespaceOnly) { |
77 | | - return false; |
78 | | - } |
79 | | - |
80 | | - return $result; |
81 | | - } |
82 | | -} |
| 3 | +/** |
| 4 | + * @deprecated Use {@link HTMLPurifier_ChildDef_HTML5_Figure} class |
| 5 | + * @codeCoverageIgnore |
| 6 | + */ |
| 7 | +class HTMLPurifier_ChildDef_Figure extends HTMLPurifier_ChildDef_HTML5_Figure |
| 8 | +{} |
0 commit comments