protected function _parseDomNode($dom_node, __ComplexConfigurationComponent &$configuration_component) { //Process root element $section_name = $dom_node->nodeName; $configuration_section =& $configuration_component->createSection($section_name); if ($dom_node->hasAttributes()) { $dom_attributes = $dom_node->attributes; $attributes = array(); foreach ($dom_attributes as $dom_attribute) { $attributes[$dom_attribute->name] = $dom_attribute->value; } $configuration_section->setAttributes($attributes); } //Process childrens: $dom_node = $dom_node->firstChild; while ($dom_node != null) { switch ($dom_node->nodeType) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: if (!(trim($dom_node->nodeValue) == "")) { $configuration_section->createProperty($dom_node->nodeName, $dom_node->nodeValue); } break; case XML_COMMENT_NODE: if (!(trim($dom_node->nodeValue) == "")) { $configuration_section->createComment($dom_node->nodeValue); } break; case XML_ELEMENT_NODE: $this->_parseDomNode($dom_node, $configuration_section); break; } $dom_node = $dom_node->nextSibling; } }
/** * Returns the root configuration component in the configuration hierarchy that current component is from. * * @return __ConfigurationComponent */ public function &getRootConfigurationComponent() { if ($this->isRoot() == true) { $return_value =& $this; } else { $return_value =& $this->_parent->getRootConfigurationComponent(); } return $return_value; }
/** * Returns a key/value pair array of the container and its children. * * Format : section[property][index] = value * If the container has attributes, it will use '@' and '#' * index is here because multiple propertys can have the same name. * * @param bool $use_attributes Whether to return the attributes too * @return array */ function toArray($use_attributes = true) { $return_value = parent::toArray(); $return_value = $return_value[$this->_name]; return $return_value; }