1: <?php
2:
3: /**
4: * Class ArbitraryCompositeNode
5: *
6: * @version 1.0.3
7: * @author v.raskin
8: * @package vsword.node
9: */
10: class ArbitraryCompositeNode extends EmptyCompositeNode {
11: protected $name;
12: public function __construct($name, $attributes = NULL) {
13: $this->name = $name;
14: if(!is_null($attributes)) {
15: $this->addAttributes($attributes);
16: }
17: }
18:
19: public function getName() {
20: return $this->name;
21: }
22:
23: public function getHtml() {
24: $str = $this->beforeRenderChildrensWord();
25: foreach($this->childrens as $child) {
26: $str .= $child->getHtml();
27: }
28: $str .= $this->afterRenderChildrensWord();
29: return $str;
30: }
31:
32: protected function beforeRenderChildrensWord() {
33: return '<'.$this->name.$this->attributeToString().'>';
34: }
35:
36: protected function afterRenderChildrensWord() {
37: return '</'.$this->name.'>';
38: }
39:
40: /**
41: * @return string
42: */
43: public function look($tab = '') {
44: $str = $tab.($this).':'.$this->name."\n";;
45: $tab .= "\t";
46: foreach($this->childrens as $child)
47: $str .= $tab.$child->look($tab);
48: return $str;
49: }
50:
51:
52: }