src/UI/Template.php
public function add( $elements, $overwrite = FALSE )
	{
		if( !is_array( $elements ) )
			return 0;
		$number	= 0;
		foreach( $elements as $key => $value )
		{
			if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) )
				throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' );
			if( !strlen( trim( $key ) ) )
				throw new InvalidArgumentException( 'Key cannot be empty' );

			$isListObject	= $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
			$isPrimitive	= is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value );
			$isTemplate		= $value instanceof $this->className;
			if( is_null( $value ) )
				continue;
			else if( is_array( $value ) || $isListObject )
				$number	+= $this->addArrayRecursive( $key, $value, array(), $overwrite );
			else if( $isPrimitive || $isTemplate )
			{
//				if( $overwrite == TRUE )
//					$this->elements[$key] = array();
//				$this->elements[$key][] = $value;
				$this->elements[$key] = $value;
				$number	++;
			}
			else if( is_object( $value ) )
				$this->addObject( $key, $value, array(), $overwrite );
			else
				throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' );
		}
		return $number;
	}
public function add( $elements, $overwrite = FALSE )
	{
		if( !is_array( $elements ) )
			return 0;
		$number	= 0;
		foreach( $elements as $key => $value )
		{
			if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) )
				throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' );
			if( !strlen( trim( $key ) ) )
				throw new InvalidArgumentException( 'Key cannot be empty' );

			$isListObject	= $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
			$isPrimitive	= is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value );
			$isTemplate		= $value instanceof $this->className;
			if( is_null( $value ) )
				continue;
			else if( is_array( $value ) || $isListObject )
				$number	+= $this->addArrayRecursive( $key, $value, array(), $overwrite );
			else if( $isPrimitive || $isTemplate )
			{
//				if( $overwrite == TRUE )
//					$this->elements[$key] = array();
//				$this->elements[$key][] = $value;
				$this->elements[$key] = $value;
				$number	++;
			}
			else if( is_object( $value ) )
				$this->addObject( $key, $value, array(), $overwrite );
			else
				throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' );
		}
		return $number;
	}
public function add ( $ elements , $ overwrite = FALSE ) { if ( ! is_array ( $ elements ) ) return 0 ; $ number = 0 ; foreach ( $ elements as $ key => $ value ) { if ( ! ( is_string ( $ key ) || is_int ( $ key ) || is_float ( $ key ) ) ) throw new InvalidArgumentException ( 'Invalid key type "' . gettype ( $ key ) . '"' ) ; if ( ! strlen ( trim ( $ key ) ) ) throw new InvalidArgumentException ( 'Key cannot be empty' ) ; $ isListObject = $ value instanceof ArrayObject || $ value instanceof ADT_List_Dictionary ; $ isPrimitive = is_string ( $ value ) || is_int ( $ value ) || is_float ( $ value ) || is_bool ( $ value ) ; $ isTemplate = $ value instanceof $ this -> className ; if ( is_null ( $ value ) ) continue ; else if ( is_array ( $ value ) || $ isListObject ) $ number += $ this -> addArrayRecursive ( $ key , $ value , array ( ) , $ overwrite ) ; else if ( $ isPrimitive || $ isTemplate ) { //				if( $overwrite == TRUE ) //					$this->elements[$key] = array(); //				$this->elements[$key][] = $value; $ this -> elements [ $ key ] = $ value ; $ number ++ ; } else if ( is_object ( $ value ) ) $ this -> addObject ( $ key , $ value , array ( ) , $ overwrite ) ; else throw new InvalidArgumentException ( 'Unsupported type ' . gettype ( $ value ) . ' for "' . $ key . '"' ) ; } return $ number ; }
Adds an associative array with labels and elements to the template and returns number of added elements.
@param		array 		Array where the <b>key</b> can be a string, integer or
float and is the <b>label</b>. The <b>value</b> can be a
string, integer, float or a template object and represents
the element to add.
@param		boolean		if TRUE an a tag is already used, it will overwrite it
@return		integer
Adds an associative array with labels and elements to the template and returns number of added elements .