_label = $label; $this->id = $id; $this->_properties['text'] = $label; $this->uid = microtime(); $this->set_property('id', $id); $this->expanded = $show_expanded; } /** * @param $name * @param $value * @param bool $is_param */ public 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. * @param $node */ function add_node($node) { $this->nodes[$node->uid] = $node; } /** * @return array - 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 = $this->_properties; if (!empty($this->_params)) { $ret[] = $this->_params; } $ret['dynamicload'] = $this->dynamic_load; $ret['dynamicloadfunction'] = $this->dynamicloadfunction; $ret['expanded'] = $this->expanded; $ret['children'] = array(); $ret['type'] = 1; foreach ($this->nodes as $node) { $ret['children'][] = $node->get_definition(); } //$ret['leaf'] = empty($ret['children']); return $ret; } }