libraries/tbs/plugins/tbs_plugin_opentbs.php
function OpenXML_GetRelativePath($FullPath, $RelativeTo) {
		
		$fp = explode('/', $FullPath);
		$fp_file = array_pop($fp);
		$fp_max = count($fp)-1;
		
		$rt = explode('/', $RelativeTo);
		$rt_file = array_pop($rt);
		$rt_max = count($rt)-1;
		
		// First different item
		$min = min($fp_max, $rt_max);
		while( ($min>=0) && ($fp[0]==$rt[0])  ) {
			$min--;
			array_shift($fp);
			array_shift($rt);
		}

		$path  = str_repeat('../', count($rt));
		$path .= implode('/', $fp);
		if (count($fp)>0) $path .= '/';
		$path .= $fp_file;
		
		return $path;
		
	}
function OpenXML_GetRelativePath($FullPath, $RelativeTo) {
		
		$fp = explode('/', $FullPath);
		$fp_file = array_pop($fp);
		$fp_max = count($fp)-1;
		
		$rt = explode('/', $RelativeTo);
		$rt_file = array_pop($rt);
		$rt_max = count($rt)-1;
		
		// First different item
		$min = min($fp_max, $rt_max);
		while( ($min>=0) && ($fp[0]==$rt[0])  ) {
			$min--;
			array_shift($fp);
			array_shift($rt);
		}

		$path  = str_repeat('../', count($rt));
		$path .= implode('/', $fp);
		if (count($fp)>0) $path .= '/';
		$path .= $fp_file;
		
		return $path;
		
	}
function OpenXML_GetRelativePath ( $ FullPath , $ RelativeTo ) { $ fp = explode ( '/' , $ FullPath ) ; $ fp_file = array_pop ( $ fp ) ; $ fp_max = count ( $ fp ) - 1 ; $ rt = explode ( '/' , $ RelativeTo ) ; $ rt_file = array_pop ( $ rt ) ; $ rt_max = count ( $ rt ) - 1 ; // First different item $ min = min ( $ fp_max , $ rt_max ) ; while ( ( $ min >= 0 ) && ( $ fp [ 0 ] == $ rt [ 0 ] ) ) { $ min -- ; array_shift ( $ fp ) ; array_shift ( $ rt ) ; } $ path = str_repeat ( '../' , count ( $ rt ) ) ; $ path .= implode ( '/' , $ fp ) ; if ( count ( $ fp ) > 0 ) $ path .= '/' ; $ path .= $ fp_file ; return $ path ; }
Return the path of file $FullPath relatively to the path of file $RelativeTo.
For example:
'dir1/dir2/file_a.xml' relatively to 'dir1/dir2/file_b.xml' is 'file_a.xml'
'dir1/file_a.xml' relatively to 'dir1/dir2/file_b.xml' is '../file_a.xml'
Return the path of file $FullPath relatively to the path of file $RelativeTo . For example : dir1 / dir2 / file_a . xml relatively to dir1 / dir2 / file_b . xml is file_a . xml dir1 / file_a . xml relatively to dir1 / dir2 / file_b . xml is .. / file_a . xml