ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
package_algorithms_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| execute_script_line ($ScriptLine)
| get_master_package ($PackageFilePath, $MasterPackageName, $MasterPackageVersion)
| install_package ($PackageFilePath, $MasterPackageName, $MasterPackageVersion)
| get_package_time ($Directory, $TimeFunc= '')
| get_packages_list ()
| get_meta_files ($PackageInfo)
| get_config_files ($PackageInfo)
| get_packages_tree ($List=false)
| select_packages ($Start, $Limit, $Field=false, $Order=false)

## Data Fields
| $Utilities = false

## Detailed Description

This manager helps to manage packages.

Author
  Dodonov A.A.

Definition at line 26 of file package_algorithms.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 50 of file package_algorithms.php.

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

## Member Function Documentation

execute_script_line | ( |  | $ScriptLine | ) |

Function executes command.

Parameters

  $ScriptLine | - Command.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 80 of file package_algorithms.php.

{
try
{
$Params = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$Params->load_settings( $ScriptLine );
if( $Params->get_setting( 'command' , '' ) === 'install_package' )
{
$PackageFilePath = $Params->get_setting( 'package_file_path' , '' );
$MasterPackageName = $Params->get_setting( 'master_package_name' , '' );
$MasterPackageVersion = $Params->get_setting( 'master_package_version' , '' );
$this->install_package( $PackageFilePath , $MasterPackageName , $MasterPackageVersion );
return;
}
throw( new Exception( 'Command '.$ScriptLine.' was not executed' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_config_files | ( |  | $PackageInfo | ) |

Function returns configs of the package.

Parameters

  $PackageInfo | - Package's name and version.

Returns
  List of config files.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 422 of file package_algorithms.php.

{
try
{
$PackagePath = _get_package_relative_path_ex(
$PackageInfo[ 'full_package_name' ] , $PackageInfo[ 'full_package_version' ]
);
return( $this->Utilities->get_files_from_directory( "$PackagePath/conf" , '/_.+/' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_master_package | ( |  | $PackageFilePath,
|  |  | $MasterPackageName,
|  |  | $MasterPackageVersion
| ) |  |

Function fetches name and version of the master package.

Parameters

  $PackageFilePath | - Path to the installing package's archive.
  $MasterPackageName | - Name of the master-package.
  $MasterPackageVersion | - Version of the master package.

Returns
  array( $PackageName , $PackageVersion ).

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 135 of file package_algorithms.php.

{
try
{
if( $MasterPackageName === 'auto' )
{
$Zip = new ZipArchive;
if( $Zip->open( $FileSource ) === true )
{
$Conf = $Zip->getFromName( './install/cf_install' );
if( $Conf === false )
{
$Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$Settings->load_setings( $Conf );
$MasterPackageName = $Settings->get_setting( 'master_package_name' , '/' );
$MasterPackageVersion = $Settings->get_setting( 'master_package_version' , 'last' );
}
$Zip->close();
}
}
return( array( $MasterPackageName , $MasterPackageVersion ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_meta_files | ( |  | $PackageInfo | ) |

Function returns meta-files of the package.

Parameters

  $PackageInfo | - Package's name and version.

Returns
  List of meta files.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 384 of file package_algorithms.php.

{
try
{
$PackagePath = _get_package_relative_path_ex(
$PackageInfo[ 'full_package_name' ] , $PackageInfo[ 'full_package_version' ]
);
return( $this->Utilities->get_files_from_directory( "$PackagePath/meta" , '/meta_.+/' ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_package_time | ( |  | $Directory,
|  |  | $TimeFunc = `''`
| ) |  |

Function returns package modification date.

Parameters

  $Directory | - Package's directory.
  $TimeFunc | - Time extraction function.

Returns
  Modification time.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 288 of file package_algorithms.php.

{
try
{
$Utilities = get_package( 'utilities' , 'last' , __FILE__ );
$Files = $Utilities->get_files_from_directory( $Directory );
if( count( $Files ) )
{
$Time = $TimeFunc( $Files[ 0 ] );
foreach( $Files as $k => $v )
{
$Tmp = $TimeFunc( $v );
if( $Tmp > $Time )
{
$Time = $Tmp;
}
}
return( $Time );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_packages_list | ( |  | ) |

Function returns all packages in the system.

Returns
  List of packages.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 336 of file package_algorithms.php.

{
try
{
$List = _get_packages_list();
foreach( $List as $i => $l )
{
$RootDir = _get_root_dir( $l[ 'package_name' ] , $l[ 'package_version' ] , INSTALL_DIR );
$PackagePath = _get_package_path( $l[ 'package_name' ] , $l[ 'package_version' ] , $RootDir );
$FileMTime = $this->get_package_time( $PackagePath , 'filemtime' );
$List[ $i ][ 'modify_date' ] = date( 'Y-m-d&\nb\sp;G:i:s' , $FileMTime );
$FileATime = $this->get_package_time( $PackagePath , 'fileatime' );
$List[ $i ][ 'access_date' ] = date( 'Y-m-d&\nb\sp;G:i:s' , $FileATime );
}
return( $List );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_packages_tree | ( |  | $List = `false` | ) |

Function returns all packages in the system.

Parameters

  $List | - List of packages.

Returns
  List of packages.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 460 of file package_algorithms.php.

{
try
{
if( $List === false )
{
$List = _get_packages_tree();
}
foreach( $List as $i => $l )
{
$List[ $i ][ 'subpackages' ] = $this->get_packages_tree( $List[ $i ][ 'subpackages' ] );
$List[ $i ][ 'meta' ] = $this->get_meta_files( $List[ $i ] );
$List[ $i ][ 'conf' ] = $this->get_config_files( $List[ $i ] );
}
return( $List );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

install_package | ( |  | $PackageFilePath,
|  |  | $MasterPackageName,
|  |  | $MasterPackageVersion
| ) |  |

Function installs package.

Parameters

  $PackageFilePath | - Path to the installing package's archive.
  $MasterPackageName | - Name of the master-package.
  $MasterPackageVersion | - Version of the master package.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 239 of file package_algorithms.php.

{
try
{
list( $MasterPackageName , $MasterPackageVersion ) = $this->get_master_package(
$PackageFilePath , $MasterPackageName , $MasterPackageVersion
);
$ROOT_DIR = $this->get_root_dir( $MasterPackageName , $MasterPackageVersion );
$PackageFolder = _install_package( $PackageFilePath , $ROOT_DIR );
$PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
$PageComposer->add_success_message( 'package_was_installed' );
_drop_core_cache();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

select_packages | ( |  | $Start,
|  |  | $Limit,
|  |  | $Field = `false`,
|  |  | $Order = `false`
| ) |  |

Function draws component.

Parameters

  $Start | - Number of the first record.
  $Limit | - Count of records.
  $Field | - Field to sort by.
  $Order | - Sorting order.

Returns
  HTML code of the компонента.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 518 of file package_algorithms.php.

{
try
{
$List = $this->get_all_packages();
if( $Order !== false )
{
$SortSign = $Order === 'ascending' ? '<' : '>';
$SortFunc = create_function(
'$a , $b' ,
"if( \$a[ '$Field' ] == \$b[ '$Field' ] )return(0);".
"return( \$a[ '$Field' ] $SortSign \$b[ '$Field' ] ? -1 : 1 );"
);
usort( $List , $SortFunc );
}
$Ret = array();
foreach( $List as $i => $l )
{
if( $i >= $Start && $i < $Start + $Limit )
{
$Ret [] = $l;
}
}
return( $Ret );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Utilities = false

Cached object.

Author
  Dodonov A.A.

Definition at line 38 of file package_algorithms.php.

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

- packages/core/packages/package_algorithms/package_algorithms.php