XBRL-Report-Compare.php
public function preparePresentation( $prune = true )
	{
		$docs = $this->getInstanceDocuments();

		$existingYears = null;

		foreach ( $docs as $instanceKey => $instance )
		{
			$instanceYears = array();

			foreach ( $instance->usedContexts as $key => $context )
			{
				$instanceYears[ $context['year'] ] = $context['year'];
			}

			// Eliminate any years that are not in the valid years list
			if ( $this->validYears )
			{
				$diffYears = array_diff( $instanceYears, $this->validYears );
				if ( $diffYears )
				{
					sort( $diffYears );
					$omittedYears = implode( ",", $diffYears );
					$this->log()->info( "Data in the instance document {$instance->getDocumentName()} for $omittedYears will not be included in the generated report." );
				}
				$instanceYears = array_intersect( $instanceYears, $this->validYears );
			}

			if ( $existingYears === null )
			{
				$existingYears = $instanceYears;
				continue;
			}

			// Check the instances have overlaps.  Order the arrays this way so the $instanceYears are checked
			$diffYears = array_diff( $instanceYears, $existingYears ) + array_diff( $existingYears, $instanceYears );
			if ( ! $diffYears ) continue;

			if ( ! array_intersect( $diffYears, $instanceYears ) )
			{
				$this->log()->info( "None of the years in instance {$instance->getDefaultCurrency()} overlap with other documents included in this report" );
			}
			if ( count( array_intersect( $diffYears, $instanceYears ) ) !== count( $instanceYears ) )
			{
				$omittedYears = implode( ",", $diffYears );
				$this->log()->info( "Some of the years ($omittedYears) in instance {$instance->getDefaultCurrency()} do not overlap with other documents included in this report" );
			}

			$existingYears = array_intersect_key( $existingYears, $instanceYears );

		}

		if ( ! $existingYears )
		{
			$message = $this->validYears
				? "There are no years in the instance documents selected that match the valid years you have chosen"
				: "The instance documents you have selected contain no data.";
			throw new Exception( $message );
		}

		// Make sure only $existingYears exist in $this->years
		$this->years = array_intersect_key( $this->years, $existingYears );

		parent::preparePresentation( $prune );
	}
public function preparePresentation( $prune = true )
	{
		$docs = $this->getInstanceDocuments();

		$existingYears = null;

		foreach ( $docs as $instanceKey => $instance )
		{
			$instanceYears = array();

			foreach ( $instance->usedContexts as $key => $context )
			{
				$instanceYears[ $context['year'] ] = $context['year'];
			}

			// Eliminate any years that are not in the valid years list
			if ( $this->validYears )
			{
				$diffYears = array_diff( $instanceYears, $this->validYears );
				if ( $diffYears )
				{
					sort( $diffYears );
					$omittedYears = implode( ",", $diffYears );
					$this->log()->info( "Data in the instance document {$instance->getDocumentName()} for $omittedYears will not be included in the generated report." );
				}
				$instanceYears = array_intersect( $instanceYears, $this->validYears );
			}

			if ( $existingYears === null )
			{
				$existingYears = $instanceYears;
				continue;
			}

			// Check the instances have overlaps.  Order the arrays this way so the $instanceYears are checked
			$diffYears = array_diff( $instanceYears, $existingYears ) + array_diff( $existingYears, $instanceYears );
			if ( ! $diffYears ) continue;

			if ( ! array_intersect( $diffYears, $instanceYears ) )
			{
				$this->log()->info( "None of the years in instance {$instance->getDefaultCurrency()} overlap with other documents included in this report" );
			}
			if ( count( array_intersect( $diffYears, $instanceYears ) ) !== count( $instanceYears ) )
			{
				$omittedYears = implode( ",", $diffYears );
				$this->log()->info( "Some of the years ($omittedYears) in instance {$instance->getDefaultCurrency()} do not overlap with other documents included in this report" );
			}

			$existingYears = array_intersect_key( $existingYears, $instanceYears );

		}

		if ( ! $existingYears )
		{
			$message = $this->validYears
				? "There are no years in the instance documents selected that match the valid years you have chosen"
				: "The instance documents you have selected contain no data.";
			throw new Exception( $message );
		}

		// Make sure only $existingYears exist in $this->years
		$this->years = array_intersect_key( $this->years, $existingYears );

		parent::preparePresentation( $prune );
	}
public function preparePresentation ( $ prune = true ) { $ docs = $ this -> getInstanceDocuments ( ) ; $ existingYears = null ; foreach ( $ docs as $ instanceKey => $ instance ) { $ instanceYears = array ( ) ; foreach ( $ instance -> usedContexts as $ key => $ context ) { $ instanceYears [ $ context [ 'year' ] ] = $ context [ 'year' ] ; } // Eliminate any years that are not in the valid years list
 if ( $ this -> validYears ) { $ diffYears = array_diff ( $ instanceYears , $ this -> validYears ) ; if ( $ diffYears ) { sort ( $ diffYears ) ; $ omittedYears = implode ( "," , $ diffYears ) ; $ this -> log ( ) -> info ( "Data in the instance document {$instance->getDocumentName()} for $omittedYears will not be included in the generated report." ) ; } $ instanceYears = array_intersect ( $ instanceYears , $ this -> validYears ) ; } if ( $ existingYears === null ) { $ existingYears = $ instanceYears ; continue ; } // Check the instances have overlaps.  Order the arrays this way so the $instanceYears are checked
 $ diffYears = array_diff ( $ instanceYears , $ existingYears ) + array_diff ( $ existingYears , $ instanceYears ) ; if ( ! $ diffYears ) continue ; if ( ! array_intersect ( $ diffYears , $ instanceYears ) ) { $ this -> log ( ) -> info ( "None of the years in instance {$instance->getDefaultCurrency()} overlap with other documents included in this report" ) ; } if ( count ( array_intersect ( $ diffYears , $ instanceYears ) ) !== count ( $ instanceYears ) ) { $ omittedYears = implode ( "," , $ diffYears ) ; $ this -> log ( ) -> info ( "Some of the years ($omittedYears) in instance {$instance->getDefaultCurrency()} do not overlap with other documents included in this report" ) ; } $ existingYears = array_intersect_key ( $ existingYears , $ instanceYears ) ; } if ( ! $ existingYears ) { $ message = $ this -> validYears ? "There are no years in the instance documents selected that match the valid years you have chosen" : "The instance documents you have selected contain no data." ; throw new Exception ( $ message ) ; } // Make sure only $existingYears exist in $this->years
 $ this -> years = array_intersect_key ( $ this -> years , $ existingYears ) ; parent :: preparePresentation ( $ prune ) ; }
This function is overridden to check the validity of the instance documents included

@param bool $prune True if the presentation hierarchies should be pruned to keep only items with elements assigned
@return void
This function is overridden to check the validity of the instance documents included