1 | <?php namespace Luminaire\Premailer\Parser; |
||
22 | class StylesheetParser |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * The DOM Document instance |
||
27 | * |
||
28 | * @var \DOMDocument |
||
29 | */ |
||
30 | protected $document; |
||
31 | |||
32 | /** |
||
33 | * Create a new instance of Style Sheet Extractor |
||
34 | * |
||
35 | * @param \DOMDocument|null $document |
||
36 | */ |
||
37 | public function __construct(DOMDocument $document = null) |
||
44 | |||
45 | /** |
||
46 | * Get the DOM Document instance |
||
47 | * |
||
48 | * @return \DOMDocument|null |
||
49 | */ |
||
50 | public function getDocument() |
||
54 | |||
55 | /** |
||
56 | * Set the DOM Document instance |
||
57 | * |
||
58 | * @param \DOMDocument $document |
||
59 | * @return $this |
||
60 | */ |
||
61 | public function setDocument(DOMDocument $document) |
||
67 | |||
68 | /** |
||
69 | * Get all CSS in the mail template |
||
70 | * |
||
71 | * @return string |
||
72 | * |
||
73 | * @throws \RuntimeException |
||
74 | */ |
||
75 | public function extract() |
||
96 | |||
97 | /** |
||
98 | * Get all DOM element that has "style" attribute |
||
99 | * |
||
100 | * @param \DOMDocument $doc |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function getStyleTags(DOMDocument $doc) |
||
114 | |||
115 | /** |
||
116 | * Get the HTML <style> tag CSS content |
||
117 | * |
||
118 | * @param \DOMElement $node |
||
119 | * @return string|null |
||
120 | */ |
||
121 | protected function getStyleTagContent(DOMElement $node) |
||
130 | |||
131 | /** |
||
132 | * Check if the HTML <style> tag has no [media] attribute or if it has a |
||
133 | * [media] attribute, then it must either have a value of "all" or "screen". |
||
134 | * |
||
135 | * @param \DOMElement $style_node |
||
136 | * @return bool |
||
137 | */ |
||
138 | private function isStyleMediaAllowed(DOMElement $style_node) |
||
149 | |||
150 | /** |
||
151 | * Check if the HTML <style> tag has the default [type] attribute or the value |
||
152 | * of the [type] attribute is set to "text/css". |
||
153 | * |
||
154 | * @param \DOMElement $style_node |
||
155 | * @return bool |
||
156 | */ |
||
157 | private function isStyleTypeAllowed(DOMElement $style_node) |
||
163 | |||
164 | } |
||
165 |