XBRL.php
private function createHierarchyPaths( $nodes, $paths = array(), $path = "" )
	{
		foreach ( $nodes as $nodeKey => $node )
		{
			$nodePath = $path . ( empty( $path ) ? "" : "/" ) . $node['label'];

			$parts = parse_url( $node['label'] );
			$taxonomy = $parts['path'] == $this->getTaxonomyXSD()
				? $this
				: $this->getTaxonomyForXSD( $parts['path'] );
			$taxonomy_element = $taxonomy->getElementById( $parts['fragment'] );
			// $key = strpos( $node['label'], "#" ) === false ? $node['label'] : $parts[ 'fragment' ];
			$key = $taxonomy_element['id'];

			if ( isset( $paths[ $key ] ) )
			{
				// Check to make sure there is no recursion.  This is indicative
				// of a circular reference but these will be formally detected
				// in the validation function.
				if ( strpos( $path, $node['label'] ) !== false )
				{
					continue;
				}
			}
			else
			{
				$paths[ $key ] = array();
			}

			$paths[ $key ][] = $nodePath;

			if ( ! isset( $node['children'] ) || count( $node['children'] ) === 0 ) continue;
			$paths = $this->createHierarchyPaths( $node['children'], $paths, $nodePath );
		}

		if ( empty( $path ) ) ksort( $paths );
		return $paths;
	}
private function createHierarchyPaths( $nodes, $paths = array(), $path = "" )
	{
		foreach ( $nodes as $nodeKey => $node )
		{
			$nodePath = $path . ( empty( $path ) ? "" : "/" ) . $node['label'];

			$parts = parse_url( $node['label'] );
			$taxonomy = $parts['path'] == $this->getTaxonomyXSD()
				? $this
				: $this->getTaxonomyForXSD( $parts['path'] );
			$taxonomy_element = $taxonomy->getElementById( $parts['fragment'] );
			// $key = strpos( $node['label'], "#" ) === false ? $node['label'] : $parts[ 'fragment' ];
			$key = $taxonomy_element['id'];

			if ( isset( $paths[ $key ] ) )
			{
				// Check to make sure there is no recursion.  This is indicative
				// of a circular reference but these will be formally detected
				// in the validation function.
				if ( strpos( $path, $node['label'] ) !== false )
				{
					continue;
				}
			}
			else
			{
				$paths[ $key ] = array();
			}

			$paths[ $key ][] = $nodePath;

			if ( ! isset( $node['children'] ) || count( $node['children'] ) === 0 ) continue;
			$paths = $this->createHierarchyPaths( $node['children'], $paths, $nodePath );
		}

		if ( empty( $path ) ) ksort( $paths );
		return $paths;
	}
private function createHierarchyPaths ( $ nodes , $ paths = array ( ) , $ path = "" ) { foreach ( $ nodes as $ nodeKey => $ node ) { $ nodePath = $ path . ( empty ( $ path ) ? "" : "/" ) . $ node [ 'label' ] ; $ parts = parse_url ( $ node [ 'label' ] ) ; $ taxonomy = $ parts [ 'path' ] == $ this -> getTaxonomyXSD ( ) ? $ this : $ this -> getTaxonomyForXSD ( $ parts [ 'path' ] ) ; $ taxonomy_element = $ taxonomy -> getElementById ( $ parts [ 'fragment' ] ) ; // $key = strpos( $node['label'], "#" ) === false ? $node['label'] : $parts[ 'fragment' ];
 $ key = $ taxonomy_element [ 'id' ] ; if ( isset ( $ paths [ $ key ] ) ) { // Check to make sure there is no recursion.  This is indicative
 // of a circular reference but these will be formally detected
 // in the validation function.
 if ( strpos ( $ path , $ node [ 'label' ] ) !== false ) { continue ; } } else { $ paths [ $ key ] = array ( ) ; } $ paths [ $ key ] [ ] = $ nodePath ; if ( ! isset ( $ node [ 'children' ] ) || count ( $ node [ 'children' ] ) === 0 ) continue ; $ paths = $ this -> createHierarchyPaths ( $ node [ 'children' ] , $ paths , $ nodePath ) ; } if ( empty ( $ path ) ) ksort ( $ paths ) ; return $ paths ; }
Process the nodes of a role hierarchy to build a primary items path index
@param array $nodes An array of nodes, ones that have a 'children' element
@param array $paths An array of paths accumulated to date.  Defaults to an empty array.
@param string $path The node path of the parent.  Defaults to an empty string
@return An array indexed by node labels of paths to each node
Process the nodes of a role hierarchy to build a primary items path index