Example #1
0
 public function handleMatch($node)
 {
     $PXHTMLTemplate = new PXHTMLTemplate();
     $xtn = $node->getAttribute('xtn') ? '.' . $node->getAttribute('xtn') : '.php';
     $cdata = $node->getAttribute('cdata') ? $node->getAttribute('cdata') : FALSE;
     $dom = $PXHTMLTemplate->parse(chip($node->getAttribute('file'))->getFilePath() . $xtn, TRUE, $cdata);
     // collect all things under the PXHTML root in new_dom, and
     // attach them as an appendChild statement
     $xpath = new DOMXPath($dom);
     $results = $xpath->query('/pxhtml:root');
     $results = $results->item(0)->firstChild;
     // transfer all of the nodes from the include into the document at the include point
     while ($results) {
         $new_node = $this->importNode($results);
         $node->parentNode->insertBefore($new_node, $node);
         $results = $results->nextSibling;
     }
     $node->parentNode->removeChild($node);
 }
Example #2
0
 public function handleMatch($node)
 {
     $attr = $node->getAttributeNS('http://xml.zope.org/namespaces/tal', 'attributes');
     // mask ;;, explode on ;, inside loop restore
     $attr = str_replace(';;', '__DBLSEMI__', $attr);
     $attr_pieces = explode(';', $attr);
     foreach ($attr_pieces as $attr) {
         $attr = str_replace('__DBLSEMI__', ';', $attr);
         $attr = trim($attr);
         if (strpos($attr, ' ') === FALSE) {
             throw new Exception(' attr misdefined');
         }
         list($attr, $as) = explode(' ', $attr, 2);
         $append = strpos($attr, '+') === FALSE ? '' : $node->getAttribute(trim($attr, '+')) . ' ';
         $attr = trim($attr, '+');
         $c = $this->createLocalVariable();
         // we can't put raw PHP into the dom, or it will get escaped
         $str = $this->processTales($as, $c . ' = %s;');
         $php_inst = PXHTMLTemplate::php()->register($str . 'echo htmlspecialchars(' . $c . '); unset(' . $c . ');');
         $node->setAttribute($attr, $append . $php_inst);
     }
     $node->removeAttributeNS('http://xml.zope.org/namespaces/tal', 'attributes');
 }
Example #3
0
 public static function registerNS($name, $url)
 {
     PXHTMLTemplate::cfg()->registerNS($name, $url);
 }