ultimix
package_paths.php File Reference

Go to the source code of this file.

Functions

 _get_package_relative_path ($File)
 get_top_data ($PackageName, $PackageVersion)
 _fetch_package_path ($PackageName, $Version, $ROOT_DIR=INSTALL_DIR)
 _get_package_path ($PackageName, $PackageVersion, $ROOT_DIR=INSTALL_DIR)
 _prepare_data ($thePackageName, $thePackageVersion, $ROOT_DIR=INSTALL_DIR)
 _get_root_dir ($thePackageName, $thePackageVersion, $ROOT_DIR=INSTALL_DIR)

Variables

 $PackageRelativePathCacheChanged = false
 $PackageRelativePathCache = array()
 $PackagePathCacheChanged = false
 $PackagePathCache = array()
 $FetchPackagePathCacheChanged = false
 $FetchPackagePathCache = array()
 $RootDirCacheChanged = false
 $RootDirCache = array()

Function Documentation

_fetch_package_path (   $PackageName,
  $Version,
  $ROOT_DIR = INSTALL_DIR 
)

Function returns real path to the requested package directory.

Parameters
$PackageName- Package name after rewriting.
$Version- Package's real version.
$ROOT_DIR- root directory for package search.
Returns
Real path to the requested package.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 148 of file package_paths.php.

{
try
{
$Info = _load_packages_list( $ROOT_DIR );
$Version = _get_package_real_version( $PackageName , $Version , $ROOT_DIR );
$PackageNameAndVersion = $PackageName.'.'.$Version;
foreach( $Info as $pi )
{
if( $pi[ 0 ][ 0 ] === $PackageNameAndVersion[ 0 ] && strpos( $pi[ 0 ] , $PackageNameAndVersion ) === 0 )
{
return( $ROOT_DIR.'/packages/'.$pi[ 1 ] );
}
}
throw( new Exception( 'Package '.$PackageName. ' with version '.$Version.' was not found' ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}
_get_package_path (   $PackageName,
  $PackageVersion,
  $ROOT_DIR = INSTALL_DIR 
)

Function returns real path to the requested package directory.

Parameters
$PackageName- package name after rewriting.
$PackageVersion- Package's real version.
$ROOT_DIR- root directory for package search.
Returns
Real path to the requested package.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 206 of file package_paths.php.

{
try
{
$Key = "$PackageName $PackageVersion $ROOT_DIR";
if( isset( $PackagePathCache[ $Key ] ) === false )
{
list( $PackageName , $PackageVersion ) = get_top_data( $PackageName , $PackageVersion );
$PackagePathCacheChanged = true;
$PackagePathCache[ $Key ] = _fetch_package_path( $PackageName , $PackageVersion , $ROOT_DIR );
}
return( $PackagePathCache[ $Key ] );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}
_get_package_relative_path (   $File)

Function provides information about package's installation path.

Parameters
$File- Path to the file with package class.
Returns
Relative path from installation directory to the file $File.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 41 of file package_paths.php.

{
if( isset( $PackageRelativePathCache[ $File ] ) )
{
return( $PackageRelativePathCache[ $File ] );
}
$RelativePath = '';
$Dir = dirname( $File );
do
{
$RelativePath = '/packages/'.basename( $Dir ).$RelativePath;
$Dir = dirname( dirname( $Dir ) );
}
while( file_exists( $Dir.'/../../packages/core/data/package_list' ) );
$PackageRelativePathCacheChanged = true;
return( $PackageRelativePathCache[ $File ] = '.'.$RelativePath );
}
_get_root_dir (   $thePackageName,
  $thePackageVersion,
  $ROOT_DIR = INSTALL_DIR 
)

Function returns real path to master-package's directory, wich contains requested packages.

Parameters
$thePackageName- package name
$thePackageVersion- Package's version.
$ROOT_DIR- root directory for package search.
Returns
Real path to the root directory.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 314 of file package_paths.php.

{
try
{
$Key = "$thePackageName $thePackageVersion $ROOT_DIR";
if( isset( $RootDirCache[ $Key ] ) == false )
{
list( $PackagePath , $PackageName , $PackageVersion ) =
_prepare_data( $thePackageName , $thePackageVersion , $ROOT_DIR );
$RootDirCacheChanged = true;
$RootDirCache[ $Key ] = $PackageName == '' ? $ROOT_DIR : _get_root_dir(
$PackageName , $PackageVersion , $PackagePath
);
}
return( $RootDirCache[ $Key ] );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}
_prepare_data (   $thePackageName,
  $thePackageVersion,
  $ROOT_DIR = INSTALL_DIR 
)

Function returns real path to master-package's directory, wich contains requested packages.

Parameters
$thePackageName- package name
$thePackageVersion- Package's version.
$ROOT_DIR- root directory for package search.
Returns
array( $PackagePath , $PackageName , $PackageVersion )
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 263 of file package_paths.php.

{
try
{
$PackageNames = explode( '::' , $thePackageName );
$PackageVersions = explode( '::' , $thePackageVersion );
$PackageName = substr_replace( $thePackageName , '' , 0 , strlen( $PackageNames[ 0 ] ) + 2 );
$PackageVersion = substr_replace( $thePackageVersion , '', 0 , strlen( $PackageVersions[ 0 ] ) + 2 );
$PackagePath = _get_package_path(
$PackageNames[ 0 ] ,
_get_package_real_version( $PackageNames[ 0 ] , $PackageVersions[ 0 ] , $ROOT_DIR ) , $ROOT_DIR
);
return( array( $PackagePath , $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}
get_top_data (   $PackageName,
  $PackageVersion 
)

Function returns real path to the requested package directory.

Parameters
$PackageName- package name after rewriting.
$PackageVersion- Package's real version.
Returns
array( $PackageName , $PackageVersion ).
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

cutting package's name

cutting package's name

Definition at line 93 of file package_paths.php.

{
try
{
$PackageName = explode( '::' , $PackageName );
$PackageName = array_pop( $PackageName );
$PackageVersion = explode( '::' , $PackageVersion );
$PackageVersion = array_pop( $PackageVersion );
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

Variable Documentation

$FetchPackagePathCache = array()

Definition at line 116 of file package_paths.php.

$FetchPackagePathCacheChanged = false

Definition at line 115 of file package_paths.php.

$PackagePathCache = array()

Definition at line 65 of file package_paths.php.

$PackagePathCacheChanged = false

Definition at line 64 of file package_paths.php.

$PackageRelativePathCache = array()

Definition at line 17 of file package_paths.php.

$PackageRelativePathCacheChanged = false

Definition at line 16 of file package_paths.php.

$RootDirCache = array()

Definition at line 231 of file package_paths.php.

$RootDirCacheChanged = false

Definition at line 230 of file package_paths.php.