Implement AbsolutePath and IEConditionalComments filters. Add an xc namespace (urn...
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / IEConditionalComments.php
blob211f1fd85defae1d312164ae4824ee9f437f9ce8
1 <?php
3 class XHTMLCompiler_DOMFilter_IEConditionalComments extends XHTMLCompiler_DOMFilter
6 protected $name = 'IEConditionalComments';
7 protected $xcAttr = array('ie-condition');
9 public function process(DOMDocument $dom, $page) {
11 $nodes = $this->query( "//*[@xc:ie-condition]" );
13 foreach ($nodes as $node) {
14 $condition = $this->confiscateAttr($node, $this->ns, 'ie-condition');
15 if ($condition) {
16 $sxml = simplexml_import_dom($node);
17 $code = $sxml->asXml();
18 $comment = "[if $condition]>$code<![endif]";
19 $parent = $node->parentNode;
20 $parent->replaceChild($dom->createComment($comment), $node);