english/libraries/joomla/form/form.php
/**
	 * Merges new elements into a source <fields> element.
	 *
	 * @param   SimpleXMLElement  $source  The source element.
	 * @param   SimpleXMLElement  $new     The new element to merge.
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
Merges new elements into a source  element.
@param   SimpleXMLElement  $source  The source element.
@param   SimpleXMLElement  $new     The new element to merge.

@return  void


Merges new elements into a source element . @param SimpleXMLElement $source The source element . @param SimpleXMLElement $new The new element to merge . @return void
protected static function mergeNodes(SimpleXMLElement $source, SimpleXMLElement $new)
	{
		foreach ($new->attributes() as $name => $value)
		{
			if (isset($source[$name])) {
				$source[$name] = (string) $value;
			} else {
				$source->addAttribute($name, $value);
			}
		}
		foreach ($new->children() as $child)
		{
			$type = $child->getName();
			$name = $child['name'];
						$fields = $source->xpath($type.'[@name="'.$name.'"]');
			if (empty($fields)) {
				self::addNode($source, $child);
			}
			else {
				switch ($type) {
					case 'field':
						self::mergeNode($fields[0], $child);
						break;
					default:
						self::mergeNodes($fields[0], $child);
						break;
				}
			}
		}
	}
protected static function mergeNodes ( SimpleXMLElement $ source , SimpleXMLElement $ new ) { foreach ( $ new -> attributes ( ) as $ name => $ value ) { if ( isset ( $ source [ $ name ] ) ) { $ source [ $ name ] = ( string ) $ value ; } else { $ source -> addAttribute ( $ name , $ value ) ; } } foreach ( $ new -> children ( ) as $ child ) { $ type = $ child -> getName ( ) ; $ name = $ child [ 'name' ] ; $ fields = $ source -> xpath ( $ type . '[@name="' . $ name . '"]' ) ; if ( empty ( $ fields ) ) { self :: addNode ( $ source , $ child ) ; } else { switch ( $ type ) { case 'field' : self :: mergeNode ( $ fields [ 0 ] , $ child ) ; break ; default : self :: mergeNodes ( $ fields [ 0 ] , $ child ) ; break ; } } } }
Merges new elements into a source <fields> element.
Merges new elements into a source <fields > element .
// The assumption is that the inputs are at the same relative level. // So we just have to scan the children and deal with them. // Update the attributes of the child node. // Does this node exist?
 // This node does not exist, so add it. // This node does exist.