Changeset 2640
- Timestamp:
- 08/01/08 11:00:37 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/david-xml_only_config_system/src/config/util/dom/AgaviXmlConfigDomElement.class.php
r2632 r2640 71 71 } 72 72 73 /** 74 * Count the number of child elements with a given name. 75 * 76 * @param string The name of the element. 77 * @param string The namespace URI. If null, the document default 78 * namespace will be used. If an empty string, no namespace 79 * will be used. 80 * 81 * @return int The number of child elements with the given name. 82 * 83 * @author Noah Fontes <noah.fontes@bitextender.com> 84 * @since 1.0.0 85 */ 73 86 public function countChildren($name, $namespaceUri = null) 74 87 { … … 86 99 } 87 100 101 /** 102 * Determine whether there is at least one instance of a child element with a 103 * given name. 104 * 105 * @param string The name of the element. 106 * @param string The namespace URI. If null, the document default 107 * namespace will be used. If an empty string, no namespace 108 * will be used. 109 * 110 * @return bool True if one or more child elements with the given name 111 * exist, false otherwise. 112 * 113 * @author Noah Fontes <noah.fontes@bitextender.com> 114 * @since 1.0.0 115 */ 88 116 public function hasChildren($name, $namespaceUri = null) 89 117 { … … 91 119 } 92 120 121 /** 122 * Retrieve all children with the given element name. 123 * 124 * @param string The name of the element. 125 * @param string The namespace URI. If null, the document default 126 * namespace will be used. If an empty string, no namespace 127 * will be used. 128 * 129 * @return DOMNodeList A list of the child elements. 130 * 131 * @author Noah Fontes <noah.fontes@bitextender.com> 132 * @since 1.0.0 133 */ 93 134 public function getChildren($name, $namespaceUri = null) 94 135 { … … 107 148 } 108 149 150 /** 151 * Determine whether this element has a particular child element. This method 152 * succeeds only when there is exactly one child element with the given name. 153 * 154 * @param string The name of the element. 155 * @param string The namespace URI. If null, the document default 156 * namespace will be used. If an empty string, no namespace 157 * will be used. 158 * 159 * @return bool True if there is exactly one instance of an element with 160 * the given name; false otherwise. 161 * 162 * @author Noah Fontes <noah.fontes@bitextender.com> 163 * @since 1.0.0 164 */ 109 165 public function hasChild($name, $namespaceUri = null) 110 166 { … … 117 173 118 174 /** 119 * Return sa single child element with a given name.175 * Return a single child element with a given name. 120 176 * 121 177 * @param string The name of the element. … … 194 250 } 195 251 196 public function getAgaviParameters(array $existing = array()) 197 { 252 /** 253 * Retrieve all of the Agavi parameter elements associated with this 254 * element. 255 * 256 * @param array An array of existing parameters. 257 * @param bool Whether or not input values should be literalized once 258 * they are read. 259 * 260 * @return array The complete array of parameters. 261 * 262 * @author Noah Fontes <noah.fontes@bitextender.com> 263 * @since 1.0.0 264 */ 265 public function getAgaviParameters(array $existing = array(), $literalize = true) 266 { 267 $result = $existing; 268 198 269 if($this->ownerDocument->isAgaviConfiguration()) { 199 270 $elements = $this->getChildren('parameters', AgaviXmlConfigParser::AGAVI_ENVELOPE_NAMESPACE_LATEST); 200 $result = array();201 271 202 272 foreach($elements as $element) { 273 $key = null; 274 if(!$element->hasAttribute('name')) { 275 $result[] = null; 276 end($result); 277 $key = key($result); 278 } else { 279 $key = $element->getAttribute('name'); 280 } 281 203 282 if($element->hasChildren('parameters', AgaviXmlConfigParser::AGAVI_ENVELOPE_NAMESPACE_LATEST)) { 204 $result[$element->getAttribute('name')] = $element->getAgaviParameters(); 283 $result[$key] = isset($result[$key]) && is_array($result[$key]) ? $result[$key] : array(); 284 $result[$key] = $element->getAgaviParameters($result[$key], $literalize); 205 285 } else { 206 $result[$ element->getAttribute('name')] =$element->getValue();286 $result[$key] = $literalize ? AgaviToolkit::literalize($element->getValue()) : $element->getValue(); 207 287 } 208 288 } 209 210 return array_merge($existing, $result); 211 } else { 212 return $existing; 213 } 289 } 290 291 return $result; 214 292 } 215 293 }

