ultimix
cached_multy_fs_1_0_0 Class Reference

Public Member Functions

 __construct ()
 reset ()
 load_mounted_storages_from_file ($FilePath)
 load_mounted_storages_if_necessary ()
 get_file_path ($FilePath, $ThrowException=true)
 file_exists ($OriginalFilePath)
 transform_file_contents ($Data, $Mode)
 file_get_contents ($OriginalFilePath, $Mode= 'none')
 compound_file_get_contents ($OriginalFilePath, $Mode= 'none')
 file_put_contents ($OriginalFilePath, $Data)
 get_template ($PackagePath, $FileName)
 get_config ($PackagePath, $FileName)
 get_data ($PackagePath, $FileName, $Mode= 'none')
 get_package_template ($PackageName, $PackageVersion, $FileName)
 get_package_config ($PackageName, $PackageVersion, $FileName)
 get_package_data ($PackageName, $PackageVersion, $FileName, $Mode= 'none')
 get_mounted_storages ()
 flush ()

Data Fields

 $MountedStorages = false
 $Cache = false
 $CachedFS = false
 $Text = false

Detailed Description

Class provides virtual FS manipulation routine.

Author
Dodonov A.A.

Definition at line 26 of file cached_multy_fs.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 68 of file cached_multy_fs.php.

{
try
{
$this->Cache = get_package( 'cache' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

compound_file_get_contents (   $OriginalFilePath,
  $Mode = 'none' 
)

Cached input from compound file.

Parameters
$OriginalFilePath- path to the requesting file.
$Mode- Processing mode of the loaded file.
Returns
File's content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 506 of file cached_multy_fs.php.

{
try
{
$Data = $this->Cache->get_data( $OriginalFilePath );
if( $Data === false )
{
$FileName = basename( $OriginalFilePath );
$Content = '';
if( file_exists( $OriginalFilePath ) )
{
$Content .= file_get_contents( $OriginalFilePath );
}
foreach( $this->MountedStorages as $ms )
{
if( file_exists( $ms.'/'.$FileName ) )
{
$Content .= file_get_contents( $ms.'/'.$FileName );
}
}
$this->Cache->add_data( $OriginalFilePath , $Content );
}
$Data = $Mode !== 'none' ? $this->transform_file_contents( $Data , $Mode ) : $Data;
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
file_exists (   $OriginalFilePath)

Function validates if the file exists.

Parameters
$OriginalFilePath- Path to the requesting file.
Returns
true if the file exists, otherwise false.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 342 of file cached_multy_fs.php.

{
try
{
$Data = $this->Cache->get_data( $OriginalFilePath );
if( $Data === false )
{
$FilePath = $this->get_file_path( $OriginalFilePath , false );
if( $this->CachedFS === false )
{
$this->CachedFS = get_package( 'cached_fs' , 'last' , __FILE__ );
}
return( $this->CachedFS->store_file_exists_info( $OriginalFilePath , $FilePath ) );
}
else
{
return( $Data == '_file_was_not_found' ? false : true );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
file_get_contents (   $OriginalFilePath,
  $Mode = 'none' 
)

Cached input from file.

Parameters
$OriginalFilePath- Path to the requesting file.
$Mode- Processing mode of the loaded file.
Returns
File's content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 452 of file cached_multy_fs.php.

{
try
{
$Data = $this->Cache->get_data( $OriginalFilePath );
if( $Data === false )
{
$Data = @file_get_contents( $this->get_file_path( $OriginalFilePath ) );
if( $Data === false )
{
$Data = '';
}
$this->Cache->add_data( $OriginalFilePath , $Data );
}
if( $Mode !== 'none' )
{
$Data = $this->transform_file_contents( $Data , $Mode );
}
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
file_put_contents (   $OriginalFilePath,
  $Data 
)

Cached input from file.

Parameters
$OriginalFilePathpath to the requesting file.
Data- File's content to store.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 560 of file cached_multy_fs.php.

{
try
{
if( $this->Cache->data_exists( $OriginalFilePath ) )
{
$this->Cache->set_data( $OriginalFilePath , $Data );
}
else
{
$this->Cache->add_data( $OriginalFilePath , $Data );
}
$FilePath = $this->get_file_path( $OriginalFilePath , false );
@file_put_contents( $FilePath === false ? $OriginalFilePath : $FilePath , $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
flush ( )

Function flushes all data on disk.

Exceptions
Exception- An exception of this type is thrown.

Dodonov A.A.

Definition at line 881 of file cached_multy_fs.php.

{
try
{
$this->Cache->flush();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_config (   $PackagePath,
  $FileName 
)

Function loads config.

Parameters
$PackagePath- Path to the package.
FileName- Config file name.
Returns
Config file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 647 of file cached_multy_fs.php.

{
try
{
return( $this->file_get_contents( dirname( $PackagePath )."/conf/$FileName" , 'cleaned' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_data (   $PackagePath,
  $FileName,
  $Mode = 'none' 
)

Function loads data file.

Parameters
$PackagePath- Path to the package.
FileName- Data file name.
$Mode- Processing mode of the loaded file.
Returns
Data file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 689 of file cached_multy_fs.php.

{
try
{
return( $this->file_get_contents( dirname( $PackagePath )."/data/$FileName" , $Mode ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_file_path (   $FilePath,
  $ThrowException = true 
)

Function returns file path from storage.

Parameters
$FilePath- Path to file.
$ThrowException- Should be exception be thrown if the requested file was not found.
Returns
Path to file.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 290 of file cached_multy_fs.php.

{
try
{
$FilePath = str_replace( '/./' , '/' , $FilePath );
$FileName = basename( $FilePath );
foreach( $this->MountedStorages as $ms )
{
if( file_exists( $ms.'/'.$FileName ) )
{
return( $ms.'/'.$FileName );
}
}
if( file_exists( $FilePath ) )
{
return( $FilePath );
}
return( $this->handle_file_was_not_found_error( $ThrowException ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_mounted_storages ( )

Function returns a list of mounted directories.

Returns
A list of mounted directories.
Exceptions
Exception- An exception of this type is thrown.

Dodonov A.A.

Definition at line 855 of file cached_multy_fs.php.

{
try
{
return( $this->MountedStorages );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_config (   $PackageName,
  $PackageVersion,
  $FileName 
)

Function loads config.

Parameters
$PackageName- Package name.
$PackageVersion- Package version.
FileName- Config file name.
Returns
Config file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 775 of file cached_multy_fs.php.

{
try
{
$PackagePath = _get_package_relative_path_ex( $PackageName , $PackageVersion );
return( $this->file_get_contents( "$PackagePath/conf/$FileName" , 'cleaned' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_data (   $PackageName,
  $PackageVersion,
  $FileName,
  $Mode = 'none' 
)

Function loads data file.

Parameters
$PackageName- Package name.
$PackageVersion- Package version.
FileName- Data file name.
$Mode- Processing mode of the loaded file.
Returns
Data file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 823 of file cached_multy_fs.php.

{
try
{
$PackagePath = _get_package_relative_path_ex( $PackageName , $PackageVersion );
return( $this->file_get_contents( "$PackagePath/data/$FileName" , $Mode ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_template (   $PackageName,
  $PackageVersion,
  $FileName 
)

Function loads template.

Parameters
$PackageName- Package name.
$PackageVersion- Package version.
FileName- Template file name.
Returns
Template file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 731 of file cached_multy_fs.php.

{
try
{
$PackagePath = _get_package_relative_path_ex( $PackageName , $PackageVersion );
return( $this->file_get_contents( "$PackagePath/res/templates/$FileName" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_template (   $PackagePath,
  $FileName 
)

Function loads template.

Parameters
$PackagePath- Path to the package.
FileName- Template file name.
Returns
Template file content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 609 of file cached_multy_fs.php.

{
try
{
return( $this->file_get_contents( dirname( $PackagePath )."/res/templates/$FileName" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_mounted_storages_from_file (   $FilePath)

Function loads the list of mounted storages.

Parameters
$FilePath- Path to file.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 158 of file cached_multy_fs.php.

{
try
{
$Data = $this->Cache->get_data( $FilePath );
if( $Data !== false )
{
$this->MountedStorages = $Data;
}
else
{
$this->get_mounted_storages_from_file( $FilePath );
}
$this->MountedStorages = str_replace( "\r" , "\n" , $this->MountedStorages );
$this->MountedStorages = str_replace( "\n\n" , "\n" , $this->MountedStorages );
$this->MountedStorages = explode( "\n" , $this->MountedStorages );
foreach( $this->MountedStorages as $i => $v )
{
$this->MountedStorages[ $i ] = dirname( __FILE__ ).'/../../'.$this->MountedStorages[ $i ];
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_mounted_storages_if_necessary ( )

Function loads the list of mounted storages, if necessary.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 200 of file cached_multy_fs.php.

{
try
{
if( $this->MountedStorages === false )
{
if( file_exists( dirname( __FILE__ ).'/conf/'.DOMAIN.'.cf_data_storages' ) )
{
$StoragesConfig = dirname( __FILE__ ).'/conf/'.DOMAIN.'.cf_data_storages';
$this->load_mounted_storages_from_file( $StoragesConfig );
}
else
{
$this->load_mounted_storages_from_file( dirname( __FILE__ ).'/conf/cf_data_storages' );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
reset ( )

Function resets settings.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 94 of file cached_multy_fs.php.

{
try
{
$this->Cache->reset();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
transform_file_contents (   $Data,
  $Mode 
)

Function transforms loaded file.

Parameters
$Data- Loaded file.
$Mode- Processing mode of the loaded file.
Returns
File's content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 396 of file cached_multy_fs.php.

{
try
{
if( $Mode == 'cleaned' )
{
$Data = str_replace( "\r" , "\n" , $Data );
$Data = str_replace( "\n\n" , "\n" , $Data );
if( $this->Text === false )
{
$this->Text = get_package( 'string::text' , 'last' , __FILE__ );
}
$Data = $this->Text->remove_bom( $Data );
}
if( $Mode == 'exploded' )
{
$Data = str_replace( "\r" , "\n" , $Data );
$Data = str_replace( "\n\n" , "\n" , $Data );
$Data = explode( "\n" , $Data );
}
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$Cache = false

String processing algorithms.

Author
Dodonov A.A.

Definition at line 50 of file cached_multy_fs.php.

$CachedFS = false

Definition at line 51 of file cached_multy_fs.php.

$MountedStorages = false

List of the mounted storages.

Author
Dodonov A.A.

Definition at line 38 of file cached_multy_fs.php.

$Text = false

Definition at line 52 of file cached_multy_fs.php.


The documentation for this class was generated from the following file: