src/UI/HTML/Tree/VariableDump.php
public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 )
	{
		if( $level === 0 )
			self::$count	= 0;
		$type		= gettype( $mixed );
		$children	= array();
		$keyLabel	= ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : "";
		$event		= NULL;
		self::$count++;
		switch( $type )
		{
			case 'array':
				self::$count--;
				foreach( $mixed as $childKey => $childValue )
					$children[]	= self::buildTree( $childValue, $childKey, $closed, $level + 1 );
				if( $key === NULL )
					$keyLabel	= self::$noteOpen."Array".self::$noteClose;
				$mixed		= "";
				$event		= '$(this).parent().toggleClass(\'closed\'); return false;';
				break;
			case 'object':
				self::$count--;
				$vars		= get_object_vars( $mixed );
				foreach( $vars as $childKey => $childValue )
					$children[]	= self::buildTree( $childValue, $childKey, $closed, $level + 1 ); 
				$keyLabel	= self::$noteOpen.get_class( $mixed ).self::$noteClose;
				$mixed		= "";
				$event		= '$(this).parent().toggleClass(\'closed\'); return false;';
				break;
			case 'bool':
				$mixed	= self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose;
				break;
			case 'NULL':
				if( $mixed === NULL )
					$mixed	= self::$noteOpen."NULL".self::$noteClose;
				break;
			case 'unknown type':
				throw new RuntimeException( 'Unknown type' );
			default:
				if( preg_match( "/pass(w(or)?d)?/", $key ) )
					$mixed	= str_repeat( '*', 8 );
				break;
		}
		$children	= $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : "";
		$pair		= $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' );
		$label		= UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) );
		$classes	= array( $type );
		if( $closed )
			$classes[]	= "closed";
		return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) );
	}
public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 )
	{
		if( $level === 0 )
			self::$count	= 0;
		$type		= gettype( $mixed );
		$children	= array();
		$keyLabel	= ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : "";
		$event		= NULL;
		self::$count++;
		switch( $type )
		{
			case 'array':
				self::$count--;
				foreach( $mixed as $childKey => $childValue )
					$children[]	= self::buildTree( $childValue, $childKey, $closed, $level + 1 );
				if( $key === NULL )
					$keyLabel	= self::$noteOpen."Array".self::$noteClose;
				$mixed		= "";
				$event		= '$(this).parent().toggleClass(\'closed\'); return false;';
				break;
			case 'object':
				self::$count--;
				$vars		= get_object_vars( $mixed );
				foreach( $vars as $childKey => $childValue )
					$children[]	= self::buildTree( $childValue, $childKey, $closed, $level + 1 ); 
				$keyLabel	= self::$noteOpen.get_class( $mixed ).self::$noteClose;
				$mixed		= "";
				$event		= '$(this).parent().toggleClass(\'closed\'); return false;';
				break;
			case 'bool':
				$mixed	= self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose;
				break;
			case 'NULL':
				if( $mixed === NULL )
					$mixed	= self::$noteOpen."NULL".self::$noteClose;
				break;
			case 'unknown type':
				throw new RuntimeException( 'Unknown type' );
			default:
				if( preg_match( "/pass(w(or)?d)?/", $key ) )
					$mixed	= str_repeat( '*', 8 );
				break;
		}
		$children	= $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : "";
		$pair		= $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' );
		$label		= UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) );
		$classes	= array( $type );
		if( $closed )
			$classes[]	= "closed";
		return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) );
	}
public static function buildTree ( $ mixed , $ key = NULL , $ closed = FALSE , $ level = 0 ) { if ( $ level === 0 ) self :: $ count = 0 ; $ type = gettype ( $ mixed ) ; $ children = array ( ) ; $ keyLabel = ( $ key !== NULL ) ? htmlentities ( $ key , ENT_QUOTES , 'UTF-8' ) . " -> " : "" ; $ event = NULL ; self :: $ count ++ ; switch ( $ type ) { case 'array' : self :: $ count -- ; foreach ( $ mixed as $ childKey => $ childValue ) $ children [ ] = self :: buildTree ( $ childValue , $ childKey , $ closed , $ level + 1 ) ; if ( $ key === NULL ) $ keyLabel = self :: $ noteOpen . "Array" . self :: $ noteClose ; $ mixed = "" ; $ event = '$(this).parent().toggleClass(\'closed\'); return false;' ; break ; case 'object' : self :: $ count -- ; $ vars = get_object_vars ( $ mixed ) ; foreach ( $ vars as $ childKey => $ childValue ) $ children [ ] = self :: buildTree ( $ childValue , $ childKey , $ closed , $ level + 1 ) ; $ keyLabel = self :: $ noteOpen . get_class ( $ mixed ) . self :: $ noteClose ; $ mixed = "" ; $ event = '$(this).parent().toggleClass(\'closed\'); return false;' ; break ; case 'bool' : $ mixed = self :: $ noteOpen . ( $ mixed ? "TRUE" : "FALSE" ) . self :: $ noteClose ; break ; case 'NULL' : if ( $ mixed === NULL ) $ mixed = self :: $ noteOpen . "NULL" . self :: $ noteClose ; break ; case 'unknown type' : throw new RuntimeException ( 'Unknown type' ) ; default : if ( preg_match ( "/pass(w(or)?d)?/" , $ key ) ) $ mixed = str_repeat ( '*' , 8 ) ; break ; } $ children = $ children ? "\n" . UI_HTML_Elements :: unorderedList ( $ children , $ level + 2 ) : "" ; $ pair = $ keyLabel . htmlentities ( $ mixed , ENT_QUOTES , 'UTF-8' ) ; $ label = UI_HTML_Tag :: create ( 'span' , $ pair , array ( 'onclick' => $ event ) ) ; $ classes = array ( $ type ) ; if ( $ closed ) $ classes [ ] = "closed" ; return UI_HTML_Elements :: ListItem ( $ label . $ children , $ level + 1 , array ( 'class' => implode ( " " , $ classes ) ) ) ; }
Builds and returns a Tree Display of a Variable, recursively.
@access		public
@static
@param		mixed		$mixed		Variable of every Type to build Tree for
@param		string		$key		Variable Name
@param		string		$closed		Flag: start with closed Nodes
@param		int			$level		Depth Level
@return		void
Builds and returns a Tree Display of a Variable recursively .