PHP Класс 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
Автор: EllisLab Dev Team
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
_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

Описание методов

__construct() публичный Метод

Initialize zip compression class
public __construct ( ) : void
Результат void

_add_data() защищенный Метод

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
Результат void

_add_dir() защищенный Метод

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
Результат void

_get_mod_time() защищенный Метод

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
Результат array filemtime/filemdate

add_data() публичный Метод

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
Результат void

add_dir() публичный Метод

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
Результат void

archive() публичный Метод

Lets you write a file
public archive ( string $filepath ) : boolean
$filepath string the file name
Результат boolean

clear_data() публичный Метод

Lets you clear current zip data. Useful if you need to create multiple zips with different data.
public clear_data ( ) : CI_Zip
Результат CI_Zip

download() публичный Метод

Download
public download ( string $filename = 'backup.zip' ) : void
$filename string the file name
Результат void

get_zip() публичный Метод

Get the Zip file
public get_zip ( ) : string
Результат string (binary encoded)

read_dir() публичный Метод

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
Результат boolean

read_file() публичный Метод

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
Результат boolean

Описание свойств

$compression_level публичное свойство

Ranges from 0 to 9, with 9 being the highest level.
public int $compression_level
Результат integer

$directory публичное свойство

Zip data for a directory in string form
public string $directory
Результат string

$entries публичное свойство

Number of files/folder in zip file
public int $entries
Результат integer

$file_num публичное свойство

Number of files in zip
public int $file_num
Результат integer

$now публичное свойство

Reference to time at init
public int $now
Результат integer

$offset публичное свойство

relative offset of local header
public int $offset
Результат integer

$zipdata публичное свойство

Zip data in string form
public string $zipdata
Результат string