public function interpret(Node $node){
		$link = $node->getAttribute('@0');
		$text = $node->getAttribute('@1');
		$theme = $node->getAttribute('@2');
		$template = $node->getAttribute('template');
		$id = $node->getAttribute('id');
		
		
		$ret = '<a data-role="button"';
		if($link != '#'){
			$ret .= 'href="'.$link.'"';
		}
		if($id != ''){
			$ret .= ' id="'.$id.'"';
		}
		if(strpos($link, 'ttp://')){
			$ret .= ' rel="external"';
		}
		if($theme != ''){
			$ret .= ' data-theme="'.$theme.'"';
		}
		if($template != ''){
			$ret .= $this->$template($node);
		}
		$ret .='>'.$text.'</a>';
		
		return $ret;
	}
	public function interpret(Node $node){
		$name = $node->getAttribute('#');
				
		$ret = '';
		if($name == 'html'){
			return $node->getAttribute('[]');
		}else if(in_array($name, $this->htmlTokens)){
			$ret .= '<'.$name;
			foreach ($this->htmlAttrType as $htmlAttr){
				if($node->hasAttribute($htmlAttr)){
					$v = $node->getAttribute($htmlAttr);
					$ret .= ' '.$htmlAttr.'="'.$v.'"';		
				}
			}
			if(in_array($name, $this->specialAttr)){
				$atAttrs = $node->getAtAttributes();
				$i = 0;
				foreach($this->specialAttr[$name] as $attr){
					$ret .= ' '.$attr.'="'.$atAttrs[$i++].'"';
				}
			}
			$ret .= '>';
			$ret .= $this->iterate($node);
			$ret .= '</'.$name.'>';
		}
		
		return $ret;
	}
 /**
  * @dataProvider provideNodes
  */
 public function testGetDocComment(array $attributes, Node $node)
 {
     $this->assertSame('/** doc comment */', $node->getDocComment()->getText());
     array_pop($node->getAttribute('comments'));
     // remove doc comment
     $this->assertNull($node->getDocComment());
     array_pop($node->getAttribute('comments'));
     // remove comment
     $this->assertNull($node->getDocComment());
 }
	function textarea(Node $node){
		$id = $node->getAttribute('id');
		$text = $node->getAttribute('@0');
		$style = $node->getAttribute('style');
		
		$ret = '<label for="'.$id.'">'.$text.'</label>';
		$ret .= '<textarea name="'.$id.'" id="'.$id.'" style="'.$style.'" >';
		$ret .= '</textarea>';
		return $ret;	
	}
	public function interpret(Node $node){
		$template = $node->getAttribute('template');
		$script = $node->getAttribute('[]');
		
		$ret = '<script ';
		if($template != ''){
			$ret .= $this->$template($node);
		}
		$ret .= '>'.$script."</script>";
		
		return $ret;
	}
	public function interpret(Node $node){
		$link = $node->getAttribute('@0');
		$text = $node->getAttribute('@1');
		$target = $node->getAttribute('@2');

		$ret = '<a href="'.$link.'"';
		if($target != ''){
			$ret .= ' target="'.$target.'"';
		}
		$ret .= '>'.$text.'</a>';

		return $ret;
	}
	public function interpret(Node $node){
		$text = $node->getAttribute('@0');
		
		$ret = '<h1>'.$text.'</h1>';
		
		return $ret;
	}
Exemple #8
0
	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 attributeAccessors()
 {
     $n = new Node('node');
     $n->setAttribute('id', 1);
     $this->assertTrue($n->hasAttribute('id'));
     $this->assertFalse($n->hasAttribute('href'));
     $this->assertEquals(1, $n->getAttribute('id'));
 }
Exemple #10
0
	public function interpret(Node $node){
		$name = $node->getAttribute('#');
		$theme = $node->getAttribute('@0');
		
		$ret = '<div data-role="page" id="'.$node->getAttribute('id').'"';
		
		if($theme != ''){
			$ret .= ' data-theme="'.$theme.'" ';
		}
		$ret .='>';
		
		$ret .= parent::interpret($node);
		
		$ret .='</div>';
		
		return $ret;
	}
Exemple #11
0
	public function interpret(Node $node){
		$name = $node->getAttribute('#');
		$subinterpreter = $this->getInterpreter($name);	
		$ret = '';
		if(NULL != $subinterpreter){
			$ret .= $subinterpreter->interpret($node);
		}
		
		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;
	}
 /**
  * Dumps a node or array.
  *
  * @param array|Node $node Node or array to dump
  *
  * @return string Dumped value
  */
 public function dump($node)
 {
     if ($node instanceof Node) {
         $r = $node->getType() . '(';
         foreach ($node->getSubNodeNames() as $key) {
             $r .= "\n    " . $key . ': ';
             $value = $node->{$key};
             if (null === $value) {
                 $r .= 'null';
             } elseif (false === $value) {
                 $r .= 'false';
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= $value;
             } else {
                 $r .= str_replace("\n", "\n    ", $this->dump($value));
             }
         }
         if ($this->dumpComments && ($comments = $node->getAttribute('comments'))) {
             $r .= "\n    comments: " . str_replace("\n", "\n    ", $this->dump($comments));
         }
     } elseif (is_array($node)) {
         $r = 'array(';
         foreach ($node as $key => $value) {
             $r .= "\n    " . $key . ': ';
             if (null === $value) {
                 $r .= 'null';
             } elseif (false === $value) {
                 $r .= 'false';
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= $value;
             } else {
                 $r .= str_replace("\n", "\n    ", $this->dump($value));
             }
         }
     } elseif ($node instanceof Comment) {
         return $node->getReformattedText();
     } else {
         throw new \InvalidArgumentException('Can only dump nodes and arrays.');
     }
     return $r . "\n)";
 }
	function li(Node $node, Node $parent){
		$text = $node->getAttribute('@0');
		$style = $node->getAttribute('style');
		if($text == ''){
			$text = $node->getAttribute('[]');
		}
		
		$ret = '<li data-icon="false"';
		if($style != ''){
			$ret .= ' style="'.$style.'"';
		}
		$ret .= '>';
		
		if($text != ''){
			$ret .= $text;
		}else{
			$ret .=parent::interpret($node);
		}
		$ret .= '</li>';
		return $ret;
	}
Exemple #15
0
	public function interpret(Node $node){
		$text = $node->getAttribute('@0');
		
		return $text;
	}