Detailed Description
This manager helps to manage packages.
- Author
- Dodonov A.A.
Definition at line 26 of file package_algorithms.php.
Constructor & Destructor Documentation
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 )
{
}
}
Member Function Documentation
| execute_script_line |
( |
|
$ScriptLine | ) |
|
Function executes command.
- Parameters
-
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 80 of file package_algorithms.php.
{
try
{
$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 )
{
}
}
| 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
{
$PackageInfo[ 'full_package_name' ] , $PackageInfo[ 'full_package_version' ]
);
return( $this->Utilities->get_files_from_directory( "$PackagePath/conf" , '/_.+/' ) );
}
catch( Exception $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->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 )
{
}
}
| 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
{
$PackageInfo[ 'full_package_name' ] , $PackageInfo[ 'full_package_version' ]
);
return( $this->Utilities->get_files_from_directory( "$PackagePath/meta" , '/meta_.+/' ) );
}
catch( Exception $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
{
$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 )
{
}
}
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
{
foreach( $List as $i => $l )
{
$PackagePath =
_get_package_path( $l[
'package_name' ] , $l[
'package_version' ] , $RootDir );
$List[ $i ][ 'modify_date' ] = date( 'Y-m-d&\nb\sp;G:i:s' , $FileMTime );
$List[ $i ][ 'access_date' ] = date( 'Y-m-d&\nb\sp;G:i:s' , $FileATime );
}
return( $List );
}
catch( Exception $e )
{
}
}
| get_packages_tree |
( |
|
$List = false | ) |
|
Function returns all packages in the system.
- Parameters
-
- 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 )
{
}
foreach( $List as $i => $l )
{
$List[ $i ][
'subpackages' ] = $this->
get_packages_tree( $List[ $i ][
'subpackages' ] );
}
return( $List );
}
catch( Exception $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
{
$PackageFilePath , $MasterPackageName , $MasterPackageVersion
);
$ROOT_DIR = $this->get_root_dir( $MasterPackageName , $MasterPackageVersion );
$PageComposer =
get_package(
'page::page_composer' ,
'last' , __FILE__ );
$PageComposer->add_success_message( 'package_was_installed' );
}
catch( Exception $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 )
{
}
}
Field Documentation
The documentation for this class was generated from the following file: