ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

Functions | Variables
rewrites.php File Reference

Go to the source code of this file.

## Functions
| _set_rewrite_map ($PackageScriptPath=false, $FileName= 'local_rewrite_map')
| _reset_rewrite_map ()
| _complete_package_version ($PackageName)
| _make_full_version ($PackageName, $PackageVersion)
| _apply_to_the_whole_name ($PackageName, $PackageVersion, $Rules)
| _set_rewrited (&$PackageNameSegments, $r)
| _apply_to_the_parts ($PackageName, $PackageVersion, $Rules)
| _apply_both_transforms ($PackageName, $PackageVersion)
| _apply_local_rewrite_map ($PackageName, $PackageVersion, $PackageScriptPath)
| _apply_global_rewrite_map ($Name, $Version, $ROOT_DIR)
| _apply_rewrites ($PackageName, $PackageVersion, $PackageScriptPath)
| _fill_rewrites_cache ($PackageName, $PackageVersion, $PackageScriptPath)
| _get_package_info_after_rewrites ($PackageName, $PackageVersion, $PackageScriptPath=false)

## Variables
global | $RewritesCacheChanged
global | $RewritesCache = array()
global | $RewriteMap = array()
| $MakeFullVersionCacheChanged = false
| $MakeFullVersionCache = array()
global | $RewritedPackageCacheChanged = false
global | $RewritedPackageCache = array()
| $PackageInfoAfterRewritesCacheChanged = false
| $PackageInfoAfterRewritesCache = array()

## Function Documentation

_apply_both_transforms | ( |  | $PackageName,
|  |  | $PackageVersion
| ) |  |

Function transforms packages name and version (global rewrite).

Parameters

  $PackageName | - package name
  $PackageVersion | - Package's version.

Returns
  Package's name and version after transformation.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 407 of file rewrites.php.

{
try
{
global $RewriteMap;
list( $PackageName , $PackageVersion ) = _apply_to_the_whole_name(
$PackageName ,
$PackageVersion ,
$RewriteMap
);
$PackageVersion = _make_full_version( $PackageName , $PackageVersion );
$NameParts = explode( '::' , $PackageName );
$VersionParts = explode( '::' , $PackageVersion );
list( $PackageName , $PackageVersion ) = _apply_to_the_parts(
$PackageName ,
$PackageVersion ,
$RewriteMap
);
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_apply_global_rewrite_map | ( |  | $Name,
|  |  | $Version,
|  |  | $ROOT_DIR
| ) |  |

Function transforms packages name and version (global rewrite).

Parameters

  $Name | - Package name.
  $Version | - Package's version.
  $ROOT_DIR | - Root directory for package search.

Returns
  Package's name and version after transformation.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 524 of file rewrites.php.

{
try
{
global $RewritedPackageCache;
$Key = "$Name $Version $ROOT_DIR";
if( isset( $RewritedPackageCache[ $Key ] ) === false )
{
_set_rewrite_map( "$ROOT_DIR/packages/_core_data/unexisting_file" , "cf_global_rewrite_rules" );
global $RewriteMap;
if( $RewriteMap !== false )
{
list( $Name , $Version ) = _apply_both_transforms( $Name , $Version );
}
_reset_rewrite_map();
global $RewritedPackageCacheChanged;
$RewritedPackageCacheChanged = true;
$RewritedPackageCache[ $Key ] = array( $Name , $Version );
}
return( $RewritedPackageCache[ $Key ] );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_apply_local_rewrite_map | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $PackageScriptPath
| ) |  |

Function applies local rewrite map.

Parameters

  $PackageName | - package's name.
  $PackageVersion | - package's version.
  $PackageScriptPath | - path to the package's script.

Returns
  Array ( $PackageName , $PackageVersion ).

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 464 of file rewrites.php.

{
try
{
_set_rewrite_map( $PackageScriptPath );
global $RewriteMap;
if( $RewriteMap !== false )
{
# \~russian пытаемся применить карты рерайтов ко всему имени пакета
# \~english trying to apply rewrite map to the hole package name and version
list( $PackageName , $PackageVersion ) = _apply_both_transforms( $PackageName , $PackageVersion );
}
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_apply_rewrites | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $PackageScriptPath
| ) |  |

Function transforms packages name and version (global rewrite).

Parameters

  $PackageName | - package name
  $PackageVersion | - Package's version.
  $PackageScriptPath | - path to the package's script.

Returns
  Package's name and version after transformation.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 582 of file rewrites.php.

{
try
{
list( $PackageName , $PackageVersion ) = _apply_local_rewrite_map(
$PackageName ,
$PackageVersion ,
$PackageScriptPath
);
# глобальная переадресация
# global rewriting
list( $PackageName , $PackageVersion ) = _apply_global_rewrite_map(
$PackageName ,
$PackageVersion ,
INSTALL_DIR
);
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_apply_to_the_parts | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $Rules
| ) |  |

Function applies local rewrite map.

Parameters

  $PackageName | - Package's name.
  $PackageVersion | - Package's version.
  $Rules | - Rewrites rules.

Returns
  List ( $PackageName , $PackageVersion ).

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 350 of file rewrites.php.

{
try
{
global $RewriteMap;
$PackageNameSegments = explode( '::' , $PackageName );
$PackageVersionSegments = explode( '::' , $PackageVersion );
foreach( $RewriteMap as $r )
{
for( $j = 0 ; $j < count( $PackageNameSegments ) ; $j++ )
{
if( _set_rewrited( $PackageNameSegments[ $j ] , $r ) )
{
break;
}
}
}
$PackageName = implode( '::' , $PackageNameSegments );
$PackageVersion = implode( '::' , $PackageVersionSegments );
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_apply_to_the_whole_name | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $Rules
| ) |  |

Function applies local rewrite map to the string "full_package_name.full_package_version".

Parameters

  $PackageName | - Package's name.
  $PackageVersion | - Package's version.
  $Rules | - Rewrites rules.

Returns
  List ( $PackageName , $PackageVersion ).

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 239 of file rewrites.php.

{
try
{
global $RewriteMap;
foreach( $RewriteMap as $i => $r )
{
if( preg_match( $r[ 0 ] , $PackageName.'.'.$PackageVersion ) > 0 )
{
$PackageName = $r[ 1 ];
$PackageVersion = $r[ 2 ];
break;
}
}
return( array( $PackageName , $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_complete_package_version | ( |  | $PackageName | ) |

Function transforms package's version from 'last' to last\:\:last\:\:...\:\:last.

Parameters

  $PackageName | - Package name.

Returns
  Package's full version.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 139 of file rewrites.php.

{
$FullPackageVersion = '';
$Packages = explode( '::' , $PackageName );
if( isset( $Packages[ 1 ] ) )
{
$l = count( $Packages ) - 1;
for( $i = 0 ; $i < $l ; $i++ )
{
$FullPackageVersion .= 'last::';
}
}
return( $FullPackageVersion );
}

_fill_rewrites_cache | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $PackageScriptPath
| ) |  |

Function returns information about package after all erwrites.

Parameters

  $PackageName | - name of the package.
  $PackageVersion | - package's version. In case string 'last' is passed, then method returns the latest version.
  $PackageScriptPath | - path to the package's script.

Returns
  Information about package.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 642 of file rewrites.php.

{
try
{
global $ENABLE_REWRITES;
if( $ENABLE_REWRITES )
{
list( $PackageName , $PackageVersion ) = _apply_rewrites(
$PackageName ,
$PackageVersion ,
$PackageScriptPath
);
global $RewritesCacheChanged;
$RewritesCacheChanged = true;
}
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_get_package_info_after_rewrites | ( |  | $PackageName,
|  |  | $PackageVersion,
|  |  | $PackageScriptPath = `false`
| ) |  |

Function returns information about package after all erwrites.

Parameters

  $PackageName | - name of the package.
  $PackageVersion | - package's version. In case string 'last' is passed, then method returns the latest version.
  $PackageScriptPath | - path to the package's script.

Returns
  Information about package.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 696 of file rewrites.php.

{
try
{
global $RewritesCache;
$Key = "$PackageName $PackageVersion $PackageScriptPath";
if( isset( $RewritesCache[ $Key ] ) )
{
return( $RewritesCache[ $Key ] );
}
$PackageVersion = _make_full_version( $PackageName , $PackageVersion );
_fill_rewrites_cache( $PackageName , $PackageVersion , $PackageScriptPath );
return( $RewritesCache[ $Key ] = array( 0 => $PackageName , 1 => $PackageVersion ) );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_make_full_version | ( |  | $PackageName,
|  |  | $PackageVersion
| ) |  |

Function transforms package's version from 'last' to last\:\:last\:\:...\:\:last.

Parameters

  $PackageName | - Package name.
  $PackageVersion | - Package's version.

Returns
  Package's full version.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 182 of file rewrites.php.

{
try
{
global $MakeFullVersionCache;
if( isset( $MakeFullVersionCache[ "$PackageName.$PackageVersion" ] ) )
{
return( $MakeFullVersionCache[ "$PackageName.$PackageVersion" ] );
}
$FullPackageVersion = $PackageVersion;
if( $PackageVersion == 'last' || strpos( $PackageVersion , '::' ) === false )
{
$FullPackageVersion = _complete_package_version( $PackageName ).$PackageVersion;
}
global $MakeFullVersionCacheChanged;
$MakeFullVersionCacheChanged = true;
return( $MakeFullVersionCache[ "$PackageName.$PackageVersion" ] = $FullPackageVersion );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_reset_rewrite_map | ( |  | ) |

Function resets rewrite map.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 101 of file rewrites.php.

{
try
{
global $RewriteMap;
$RewriteMap = false;
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_set_rewrite_map | ( |  | $PackageScriptPath = `false`,
|  |  | $FileName = `'local_rewrite_map'`
| ) |  |

Function sets local rewrite maps.

Parameters

  $PackageScriptPath | - Path to the package's script.
  $FileName | - Map file name.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 55 of file rewrites.php.

{
try
{
global $RewriteMap;
if( $PackageScriptPath !== false )
{
$RewriteMap = _file_get_contents( dirname( $PackageScriptPath )."/conf/$FileName" );
if( $RewriteMap === false )
{
return;
}
$RewriteMap = str_replace( "\r" , "\n" , $RewriteMap );
$RewriteMap = str_replace( "\n\n" , "\n" , $RewriteMap );
if( $RewriteMap != '' )
{
$RewriteMap = explode( "\n" , $RewriteMap );
for( $i = 0 ; $i < count( $RewriteMap ) ; $i++ )
{
$RewriteMap[ $i ] = explode( '#' , $RewriteMap[ $i ] );
}
return;
}
$RewriteMap = false;
}
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

_set_rewrited | ( | & | $PackageNameSegments,
|  |  | $r
| ) |  |

Function applies local rewrite map.

Parameters

  $PackageNameSegments | - Package name segments.
  $r | - Rewrited values.

Returns
  true/false

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 289 of file rewrites.php.

{
try
{
if( preg_match( $r[ 0 ] , $PackageNameSegments[ $j ].'.'.$PackageVersionSegments[ $j ] ) > 0 )
{
$PackageNameSegments[ $j ] = $r[ 1 ];
$PackageInfoParts = explode( '.' , $r[ 2 ] );
if( count( $PackageInfoParts ) == 2 )
{
$PackageVersionSegments[ $j ] = $PackageInfoParts[ 0 ];
}
else
{
$PackageVersionSegments[ $j ] = $PackageInfoParts[ 0 ].'.';
$PackageVersionSegments[ $j ] .= $PackageInfoParts[ 1 ].'.';
$PackageVersionSegments[ $j ] .= $PackageInfoParts[ 2 ];
}
return( true );
}
return( false );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}

## Variable Documentation

$MakeFullVersionCache = array()

Definition at line 115 of file rewrites.php.

$MakeFullVersionCacheChanged = false

Definition at line 114 of file rewrites.php.

$PackageInfoAfterRewritesCache = array()

Definition at line 609 of file rewrites.php.

$PackageInfoAfterRewritesCacheChanged = false

Definition at line 608 of file rewrites.php.

$RewritedPackageCache = array()

Definition at line 491 of file rewrites.php.

$RewritedPackageCacheChanged = false

Definition at line 488 of file rewrites.php.

$RewriteMap = array()

Map of aliases for package's versions and names.

Author
  Dodonov A.A.

Definition at line 30 of file rewrites.php.

$RewritesCache = array()

Definition at line 17 of file rewrites.php.

global $RewritesCacheChanged

Definition at line 16 of file rewrites.php.