ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Filesystem\Util\Archive\LegacyArchives Class Reference
+ Collaboration diagram for ILIAS\Filesystem\Util\Archive\LegacyArchives:

Public Member Functions

 __construct ()
 
 zip (string $directory_to_zip, string $path_to_output_zip, bool $ensure_top_directory=false)
 
 unzip (string $path_to_zip, ?string $extract_to_path=null, bool $overwrite=false, bool $flat=false, bool $ensure_top_directory=false)
 

Private Attributes

Archives $archives
 
ZipOptions $zip_options
 
UnzipOptions $unzip_options
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s
Deprecated:
This class is deprecated and will be removed with ILIAS 10. Please use the Archives implementation instead. LegacyArchives can be used to zip individual files or directories and extract a zip file to a specified location. We should do without these possibilities as soon as possible, but for the moment very many places in ILIAS use such functionalities.

Definition at line 33 of file LegacyArchives.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Filesystem\Util\Archive\LegacyArchives::__construct ( )

Definition at line 41 of file LegacyArchives.php.

References CLIENT_ID, and ILIAS_DATA_DIR.

42  {
43  $this->archives = new Archives();
44  if (defined('ILIAS_DATA_DIR') && defined('CLIENT_ID')) {
45  $base_temp_path = \ILIAS_DATA_DIR . '/' . \CLIENT_ID . '/temp';
46  } else {
47  $base_temp_path = sys_get_temp_dir();
48  }
49 
50  $this->zip_options = $this->archives->zipOptions();
51  $this->zip_options = $this->zip_options
52  ->withZipOutputPath($base_temp_path);
53  $this->unzip_options = $this->archives->unzipOptions();
54  }
const CLIENT_ID
Definition: constants.php:41
const ILIAS_DATA_DIR
Definition: constants.php:44

Member Function Documentation

◆ unzip()

ILIAS\Filesystem\Util\Archive\LegacyArchives::unzip ( string  $path_to_zip,
?string  $extract_to_path = null,
bool  $overwrite = false,
bool  $flat = false,
bool  $ensure_top_directory = false 
)
Deprecated:
Use ::unzip() instead.

Will be removed in ILIAS 10.

Definition at line 84 of file LegacyArchives.php.

References ILIAS\Filesystem\Util\Archive\FLAT_STRUCTURE.

90  : bool {
91  $extract_to_path ??= dirname($path_to_zip);
92  if ($flat) {
94  } else {
95  $dir_handling = $ensure_top_directory ? ZipDirectoryHandling::ENSURE_SINGLE_TOP_DIR : ZipDirectoryHandling::KEEP_STRUCTURE;
96  }
97 
98  $unzip = $this->archives->unzip(
99  Streams::ofResource(fopen($path_to_zip, 'rb')),
100  $this->unzip_options
101  ->withZipOutputPath($extract_to_path)
102  ->withOverwrite($overwrite)
103  ->withDirectoryHandling($dir_handling)
104  );
105  return $unzip->extract();
106  }
Will keep the top directory of the ZIP file if there is one (simple unzip).

◆ zip()

ILIAS\Filesystem\Util\Archive\LegacyArchives::zip ( string  $directory_to_zip,
string  $path_to_output_zip,
bool  $ensure_top_directory = false 
)
Deprecated:
Use ::zip() instead.

Will be removed in ILIAS 10.

Definition at line 59 of file LegacyArchives.php.

63  : bool {
64  $directory_to_zip = $this->normalizePath($directory_to_zip);
65  $path_to_output_zip = $this->normalizePath($path_to_output_zip);
66 
67  $zip = $this->archives->zip(
68  [],
69  $this->zip_options
70  ->withZipOutputPath(dirname($path_to_output_zip))
71  ->withZipOutputName(basename($path_to_output_zip))
72  ->withDirectoryHandling($ensure_top_directory ? ZipDirectoryHandling::ENSURE_SINGLE_TOP_DIR : ZipDirectoryHandling::KEEP_STRUCTURE)
73  );
74 
75  $zip->addDirectory($directory_to_zip);
76  $zip_stream = $zip->get();
77 
78  return $zip_stream->getSize() > 0;
79  }

Field Documentation

◆ $archives

Archives ILIAS\Filesystem\Util\Archive\LegacyArchives::$archives
private

Definition at line 37 of file LegacyArchives.php.

◆ $unzip_options

UnzipOptions ILIAS\Filesystem\Util\Archive\LegacyArchives::$unzip_options
private

Definition at line 39 of file LegacyArchives.php.

◆ $zip_options

ZipOptions ILIAS\Filesystem\Util\Archive\LegacyArchives::$zip_options
private

Definition at line 38 of file LegacyArchives.php.


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