class Archive (View source)

Properties

protected string $targetDirectory

The directory where this archive will be unzipped.

protected File $f

File helper instance.

Methods

__construct()

No description

string
uploadZipToTemp(string $file)

Moves an uploaded file to the tmp directory.

string
unzip(string $directory)

Unzips a file at a directory level by concatenating ".zip" onto the end of it.

string
getArchiveDirectory(string $dir)

Returns either the directory (if the archive itself contains files at the first level) or the subdirectory if, like many archiving programs, we the zip archive is a directory, THEN a list of files.

string
install($file, bool $inplace = false)

Installs a zip file from the passed directory.

Details

__construct()

No description

protected string uploadZipToTemp(string $file)

Moves an uploaded file to the tmp directory.

Parameters

string $file

The full path of the file to copy

Return Value

string

Return the base name of the file copied to the temporary directory.

protected string unzip(string $directory)

Unzips a file at a directory level by concatenating ".zip" onto the end of it.


 unzip("/path/to/files/themes/mytheme") // will unzip "mytheme.zip"
```.

Parameters

string $directory

The base name of the file (without extension, assumed to be in the the temporary directory).

Return Value

string

Return the full path of the extracted directory.

protected string getArchiveDirectory(string $dir)

Returns either the directory (if the archive itself contains files at the first level) or the subdirectory if, like many archiving programs, we the zip archive is a directory, THEN a list of files.

Parameters

string $dir

The full path of the directory to be analyzed.

Return Value

string

Returns the final directory containing the files to be used.

protected string install($file, bool $inplace = false)

Installs a zip file from the passed directory.

This is theme-specific - it really ought to be moved to the page_theme_archive class, at least most it.

Parameters

$file
bool $inplace

Set to false if $file should be moved to the temporary directory before working on it, set to true if it's already in the temp directory.

Return Value

string

Returns the base directory into which the zipfile was unzipped