public function __construct(&$raw, Document &$document, Node &$parent = null) { $this->raw =& $raw; //$this->document = &$document; $this->parent =& $parent; if ($this->parent) { $this->inParentIndex = count($this->parent->getChilds()); } $this->process($document); $this->isSelfClosing = $document->isSelfClosing($this->getName()); }
public function interpret(Node &$node){ $name = $node->getAttribute('#'); $childs = $node->getChilds(); if($name != ''){ $ret = '<'.$name; }else{ $ret = '<Node noname="true"'; } foreach ($node->attrs as $k => $v){ if(!in_array($k[0], array('#', '>', '@'))){ $ret .= ' '.$k.'="'.$v.'"'; } } for($i=0; $i<$node->atidx; ++$i){ $ret .= ' attr'.$i.'="'.$node->attrs['@'.$i].'"'; } $ret .='>'; foreach ($childs as $child){ $ret .= $this->interpret($child); } if($name != ''){ $ret .= '</'.$name.'>'; }else{ $ret .= '</Node>'; } return $ret; }
public function interpret(Node $node){ $childs = $node->getChilds(); $ret = ''; foreach ($childs as $child){ $ret .= $this->parentInterpreter->interpret($child); } return $ret; }
public function interpret(Node &$node, $intent = 0){ $name = $node->getAttribute('#'); $childs = $node->getChilds(); if($name != ''){ $ret = $this->getIntent($intent).$name; }else{ $ret = $this->getIntent($intent); } $hasAttr = false; for($i=0; $i<$node->atidx; ++$i){ if(!$hasAttr){ $hasAttr = true; $ret .= '('; } $ret .= '"'.$node->attrs['@'.$i].'", '; } foreach ($node->attrs as $k => $v){ if(!in_array($k[0], array('#', '>', '@'))){ if(!$hasAttr){ $hasAttr = true; $ret .= '('; } $ret .= $k.'="'.$v.'", '; } } if($hasAttr){ $ret .= ')'; } $hasChild = false; foreach ($childs as $child){ if(!$hasChild){ $ret .= '{'.chr(10); $hasChild = true; } $ret .= $this->interpret($child, $intent+1); } if($hasChild){ $ret .= $this->getIntent($intent).'}'; } $ret.=chr(10); return $ret; }
function select(Node $node){ $id = $node->getAttribute('id'); $dvalue = $node->getAttribute('@1'); $text = $node->getAttribute('@0'); $options = $node->getChilds(); $selected = $node->getAttribute('selected'); $ret = '<label for="'.$id.'">'.$text.'</label>'; $ret .= '<select name="'.$id.'" id="'.$id.'">'; foreach ($options as $option){ $val = $option->getAttribute('@0'); $text = $option->getAttribute('@1'); if($selected == $val){ $ret .= '<option value="'.$val.'" selected="true">'.$text.'</option>'; }else{ $ret .= '<option value="'.$val.'">'.$text.'</option>'; } } $ret .= '</select>'; return $ret; }
function divider(Node $node, Node $parent){ $text = $node->getAttribute('@0'); $count = $node->getAttribute('@1'); $ret = '<li data-role="list-divider">'; if($text != ''){ $ret .= $text; } if($count != ''){ if($count == 'auto'){ $childs = $parent->getChilds(); $count = (count($childs)-1); } $ret.='<span class="ui-li-count">'.$count.'</span>'; } $ret .= '</li>'; return $ret; }