_label=$label; $this->_properties['label']=$label; $this->uid = create_guid(); $this->set_property('id',$id); $this->expanded = $show_expanded; } //properties set here will be accessible via //node.data object in javascript. //users can add a collection of paramaters that will //be passed to objects responding to tree events function set_property($name, $value, $is_param=false) { if(!empty($name) && ($value === 0 || !empty($value))) { if ($is_param==false) { $this->_properties[$name]=$value; } else { $this->_params[$name]=$value; } } } //add a child node. function add_node($node) { $this->nodes[$node->uid]=$node; } //return definition of the node. the definition is a multi-dimension array and has 3 parts. // data-> definition of the current node. // attributes=> collection of additional attributes such as style class etc.. // nodes: definition of children nodes. function get_definition() { $ret=array(); $ret['data']=$this->_properties; if (count($this->_params) > 0) { $ret['data']['param']=$this->_params; } $ret['custom']['dynamicload']=$this->dynamic_load; $ret['custom']['dynamicloadfunction']=$this->dynamicloadfunction; $ret['custom']['expanded']=$this->expanded; foreach ($this->nodes as $node) { $ret['nodes'][]=$node->get_definition(); } return $ret; } } ?>