1 | <?php |
||
15 | class TreeBuildingRules |
||
16 | { |
||
17 | |||
18 | protected static $tags = array( |
||
19 | 'li' => 1, |
||
20 | 'dd' => 1, |
||
21 | 'dt' => 1, |
||
22 | 'rt' => 1, |
||
23 | 'rp' => 1, |
||
24 | 'tr' => 1, |
||
25 | 'th' => 1, |
||
26 | 'td' => 1, |
||
27 | 'thead' => 1, |
||
28 | 'tfoot' => 1, |
||
29 | 'tbody' => 1, |
||
30 | 'table' => 1, |
||
31 | 'optgroup' => 1, |
||
32 | 'option' => 1 |
||
33 | ); |
||
34 | |||
35 | /** |
||
36 | * Build a new rules engine. |
||
37 | * |
||
38 | * @param \DOMDocument $doc |
||
39 | * The DOM document to use for evaluation and modification. |
||
40 | */ |
||
41 | 111 | public function __construct($doc) |
|
45 | |||
46 | /** |
||
47 | * Returns true if the given tagname has special processing rules. |
||
48 | */ |
||
49 | 107 | public function hasRules($tagname) |
|
53 | |||
54 | /** |
||
55 | * Evaluate the rule for the current tag name. |
||
56 | * |
||
57 | * This may modify the existing DOM. |
||
58 | * |
||
59 | * @return \DOMElement The new Current DOM element. |
||
60 | */ |
||
61 | 6 | public function evaluate($new, $current) |
|
104 | |||
105 | 2 | protected function handleLI($ele, $current) |
|
111 | |||
112 | 1 | protected function handleDT($ele, $current) |
|
119 | |||
120 | protected function handleRT($ele, $current) |
||
127 | |||
128 | 6 | protected function closeIfCurrentMatches($ele, $current, $match) |
|
138 | } |
||
139 |