ultimix
core_utilities.php File Reference

Go to the source code of this file.

Functions

 _file_get_contents ($FilePath)
 _rmdir_recurse ($Path)
 _get_loaded_packages_paths ()
 _compile_data ($k, $v)
 _return_params ($Params)
 _compile_params ($Params)
 _collapse_params (&$Params)
 _get_exception_object ($Method, $Args, $ExceptionObject)
 _throw_exception_object ($Method, $Args, $ExceptionObject)
 str_replace_once ($Pattern, $Replacement, $Str)

Variables

global $CachedFiles = array()
global $LoadedPackagesPaths = array()
global $_parsed_objects = array()
global $_collapse_span_id = 0

Function Documentation

_collapse_params ( $Params)

Function collapses parameters.

Parameters
$Params- Data for displaying.
Author
Dodonov A.A.

Definition at line 264 of file core_utilities.php.

{
if( is_array( $Params ) && count( $Params ) == 0 )
{
return( '' );
}
if( is_array( $Params ) || is_object( $Params ) )
{
return( _compile_params( $Params ) );
}
else
{
return( _return_params( $Params ) );
}
}
_compile_data (   $k,
  $v 
)

Function prcesses data.

Parameters
$k- Key.
$v- Data for displaying.
Returns
Processed data.
Author
Dodonov A.A.

Definition at line 148 of file core_utilities.php.

{
if( is_object( $v ) || is_array( $v ) )
{
if( in_array( $k , $_parsed_objects ) === false || is_numeric( $k ) )
{
$_parsed_objects[] = $k;
$Data = base64_encode( ' { '._collapse_params( $v ).' } ' );
}
else
{
$Data = base64_encode( ' {X} ' );
}
}
else
{
$Data = base64_encode( _collapse_params( $v ).' ' );
}
return( $Data );
}
_compile_params (   $Params)

Function compiles parameters.

Parameters
$Params- Parameters for displaying.
Returns
Compiled parameters.
Author
Dodonov A.A.

Definition at line 227 of file core_utilities.php.

{
$Str = ' ';
foreach( $Params as $k => $v )
{
$Data = _compile_data( $k , $v );
$_collapse_span_id += 1;
$PlaceHolders = array( '{id}' , '{data}' , '{k}' );
$Template = _file_get_contents( dirname( __FILE__ ).'/../../res/templates/func_link.tpl' );
$Str .= str_replace( $PlaceHolders , array( $id , $Data , $k ) , $Template );
}
return( $Str );
}
_file_get_contents (   $FilePath)

Function loads file and cache it.

Parameters
$FilePath- Path to the loading file.
Returns
Content of the loaded file.
Author
Dodonov A.A.

Definition at line 37 of file core_utilities.php.

{
global $CachedFiles;
if( isset( $CachedFiles[ $FilePath ] ) === false )
{
$CachedFiles[ $FilePath ] = @file_get_contents( $FilePath );
}
return( $CachedFiles[ $FilePath ] );
}
_get_exception_object (   $Method,
  $Args,
  $ExceptionObject 
)

Function creates exception object.

Parameters
$Method- Method.
$Args- Arguments.
$ExceptionObject- Object of the caught exception.
Returns
Exception object.
Author
Dodonov A.A.

Definition at line 307 of file core_utilities.php.

{
$ExceptionMessage = $ExceptionObject->getMessage();
return( new Exception( "$Method("._collapse_params( $Args ).")::$ExceptionMessage" ) );
}
_get_loaded_packages_paths ( )

Definition at line 109 of file core_utilities.php.

{
try
{
return( $LoadedPackagesPaths );
}
catch( Exception $e )
{
$Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
}
}
_return_params (   $Params)

Function processes parameters.

Parameters
$Params- Parameters for displaying.
Returns
Processed parameters.
Author
Dodonov A.A.

Definition at line 190 of file core_utilities.php.

{
if( $Params === false )
{
return( 'false' );
}
elseif( $Params === true )
{
return( 'true' );
}
else
{
return( $Params );
}
}
_rmdir_recurse (   $Path)

Function recursively deletes directory.

Parameters
$Path- Directory to delete.
Author
Dodonov A.A.

Definition at line 63 of file core_utilities.php.

{
$Handle = @opendir( $Path = rtrim( $Path , '/' ).'/' );
if( $Handle !== false )
{
for( ; false !== ( $File = readdir( $Handle ) ) ; )
{
if( $File != "." and $File != ".." )
{
$FullPath = $Path.$File;
if( is_dir( $FullPath ) )
{
_rmdir_recurse( $FullPath );
rmdir( $FullPath );
}
else
{
unlink( $FullPath );
}
}
}
closedir( $Handle );
}
}
_throw_exception_object (   $Method,
  $Args,
  $ExceptionObject 
)

Function throws exception.

Parameters
$Method- Method.
$Args- Arguments.
$ExceptionObject- Object of the caught exception.
Author
Dodonov A.A.

Definition at line 336 of file core_utilities.php.

{
throw( _get_exception_object( $Method , $Args , $ExceptionObject ) );
}
str_replace_once (   $Pattern,
  $Replacement,
  $Str 
)

Function replaces substring only once.

Parameters
$Pattern- String to be replaced with.
$Replacement- Replacement.
$Str- String.
Returns
Processed string.
Author
Dodonov A.A.

Definition at line 367 of file core_utilities.php.

{
if( strpos( $Str , $Pattern ) !== false )
{
return( substr_replace( $Str , $Replacement , strpos( $Str , $Pattern ) , strlen( $Pattern ) ) );
}
return( $Str );
}

Variable Documentation

$_collapse_span_id = 0

Definition at line 206 of file core_utilities.php.

$_parsed_objects = array()

Definition at line 123 of file core_utilities.php.

$CachedFiles = array()

Definition at line 16 of file core_utilities.php.

$LoadedPackagesPaths = array()

Definition at line 88 of file core_utilities.php.