PHP Class CI_Zip, TastyIgniter

This class is based on a library I found at Zend: http://www.zend.com/codex.php?id=696&single=1 The original library is a little rough around the edges so I refactored it and added several additional methods -- Rick Ellis
Author: EllisLab Dev Team
Afficher le fichier Open project: tastyigniter/tastyigniter Class Usage Examples

Méthodes publiques

Свойство Type Description
$compression_level integer Ranges from 0 to 9, with 9 being the highest level.
$directory string Zip data for a directory in string form
$entries integer Number of files/folder in zip file
$file_num integer Number of files in zip
$now integer Reference to time at init
$offset integer relative offset of local header
$zipdata string Zip data in string form

Méthodes publiques

Méthode Description
__construct ( ) : void Initialize zip compression class
add_data ( mixed $filepath, string $data = NULL ) : void Add Data to Zip
add_dir ( mixed $directory ) : void Add Directory
archive ( string $filepath ) : boolean Write File to the specified directory
clear_data ( ) : CI_Zip Initialize Data
download ( string $filename = 'backup.zip' ) : void Download
get_zip ( ) : string Get the Zip file
read_dir ( string $path, boolean $preserve_filepath = TRUE, string $root_path = NULL ) : boolean Read a directory and add it to the zip.
read_file ( string $path, boolean $archive_filepath = FALSE ) : boolean Read the contents of a file and add it to the zip

Méthodes protégées

Méthode Description
_add_data ( string $filepath, string $data, integer $file_mtime, integer $file_mdate ) : void Add Data to Zip
_add_dir ( string $dir, integer $file_mtime, integer $file_mdate ) : void Add Directory
_get_mod_time ( string $dir ) : array Get file/directory modification time

Method Details

__construct() public méthode

Initialize zip compression class
public __construct ( ) : void
Résultat void

_add_data() protected méthode

Add Data to Zip
protected _add_data ( string $filepath, string $data, integer $file_mtime, integer $file_mdate ) : void
$filepath string the file name/path
$data string the data to be encoded
$file_mtime integer
$file_mdate integer
Résultat void

_add_dir() protected méthode

Add Directory
protected _add_dir ( string $dir, integer $file_mtime, integer $file_mdate ) : void
$dir string the directory name
$file_mtime integer
$file_mdate integer
Résultat void

_get_mod_time() protected méthode

If this is a newly created file/dir, we will set the time to 'now'
protected _get_mod_time ( string $dir ) : array
$dir string path to file
Résultat array filemtime/filemdate

add_data() public méthode

Lets you add files to the archive. If the path is included in the filename it will be placed within a directory. Make sure you use add_dir() first to create the folder.
public add_data ( mixed $filepath, string $data = NULL ) : void
$filepath mixed A single filepath or an array of file => data pairs
$data string Single file contents
Résultat void

add_dir() public méthode

Lets you add a virtual directory into which you can place files.
public add_dir ( mixed $directory ) : void
$directory mixed the directory name. Can be string or array
Résultat void

archive() public méthode

Lets you write a file
public archive ( string $filepath ) : boolean
$filepath string the file name
Résultat boolean

clear_data() public méthode

Lets you clear current zip data. Useful if you need to create multiple zips with different data.
public clear_data ( ) : CI_Zip
Résultat CI_Zip

download() public méthode

Download
public download ( string $filename = 'backup.zip' ) : void
$filename string the file name
Résultat void

get_zip() public méthode

Get the Zip file
public get_zip ( ) : string
Résultat string (binary encoded)

read_dir() public méthode

This function recursively reads a folder and everything it contains (including sub-folders) and creates a zip based on it. Whatever directory structure is in the original file path will be recreated in the zip file.
public read_dir ( string $path, boolean $preserve_filepath = TRUE, string $root_path = NULL ) : boolean
$path string path to source directory
$preserve_filepath boolean
$root_path string
Résultat boolean

read_file() public méthode

Read the contents of a file and add it to the zip
public read_file ( string $path, boolean $archive_filepath = FALSE ) : boolean
$path string
$archive_filepath boolean
Résultat boolean

Property Details

$compression_level public_oe property

Ranges from 0 to 9, with 9 being the highest level.
public int $compression_level
Résultat integer

$directory public_oe property

Zip data for a directory in string form
public string $directory
Résultat string

$entries public_oe property

Number of files/folder in zip file
public int $entries
Résultat integer

$file_num public_oe property

Number of files in zip
public int $file_num
Résultat integer

$now public_oe property

Reference to time at init
public int $now
Résultat integer

$offset public_oe property

relative offset of local header
public int $offset
Résultat integer

$zipdata public_oe property

Zip data in string form
public string $zipdata
Résultat string