ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPExcel_Shared_ZipArchive Class Reference
+ Collaboration diagram for PHPExcel_Shared_ZipArchive:

Public Member Functions

 open ($fileName)
 Open a new zip archive. More...
 
 close ()
 Close this zip archive. More...
 
 addFromString ($localname, $contents)
 Add a new file to the zip archive from a string of raw data. More...
 
 locateName ($fileName)
 Find if given fileName exist in archive (Emulate ZipArchive locateName()) More...
 
 getFromName ($fileName)
 Extract file from archive by given fileName (Emulate ZipArchive getFromName()) More...
 

Data Fields

const OVERWRITE = 'OVERWRITE'
 constants More...
 
const CREATE = 'CREATE'
 

Private Attributes

 $_tempDir
 
 $_zip
 

Detailed Description

Definition at line 41 of file ZipArchive.php.

Member Function Documentation

◆ addFromString()

PHPExcel_Shared_ZipArchive::addFromString (   $localname,
  $contents 
)

Add a new file to the zip archive from a string of raw data.

Parameters
string$localnameDirectory/Name of the file to add to the zip archive
string$contentsString of data to add to the zip archive

Definition at line 95 of file ZipArchive.php.

96 {
97 $filenameParts = pathinfo($localname);
98
99 $handle = fopen($this->_tempDir.'/'.$filenameParts["basename"], "wb");
100 fwrite($handle, $contents);
101 fclose($handle);
102
103 $res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"],
104 PCLZIP_OPT_REMOVE_PATH, $this->_tempDir,
105 PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]
106 );
107 if ($res == 0) {
108 throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true));
109 }
110
111 unlink($this->_tempDir.'/'.$filenameParts["basename"]);
112 }
const PCLZIP_OPT_ADD_PATH
Definition: pclzip.lib.php:129
const PCLZIP_OPT_REMOVE_PATH
Definition: pclzip.lib.php:130
foreach($_POST as $key=> $value) $res

References $contents, $res, PCLZIP_OPT_ADD_PATH, and PCLZIP_OPT_REMOVE_PATH.

◆ close()

PHPExcel_Shared_ZipArchive::close ( )

Close this zip archive.

Definition at line 84 of file ZipArchive.php.

85 {
86 }

◆ getFromName()

PHPExcel_Shared_ZipArchive::getFromName (   $fileName)

Extract file from archive by given fileName (Emulate ZipArchive getFromName())

Parameters
string$fileNameFilename for the file in zip archive
Returns
string $contents File string contents

Definition at line 141 of file ZipArchive.php.

142 {
143 $list = $this->_zip->listContent();
144 $listCount = count($list);
145 $list_index = -1;
146 for ($i = 0; $i < $listCount; ++$i) {
147 if (strtolower($list[$i]["filename"]) == strtolower($fileName) ||
148 strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) {
149 $list_index = $i;
150 break;
151 }
152 }
153
154 $extracted = "";
155 if ($list_index != -1) {
156 $extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING);
157 } else {
158 $filename = substr($fileName, 1);
159 $list_index = -1;
160 for ($i = 0; $i < $listCount; ++$i) {
161 if (strtolower($list[$i]["filename"]) == strtolower($fileName) ||
162 strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) {
163 $list_index = $i;
164 break;
165 }
166 }
167 $extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING);
168 }
169 if ((is_array($extracted)) && ($extracted != 0)) {
170 $contents = $extracted[0]["content"];
171 }
172
173 return $contents;
174 }
$i
Definition: disco.tpl.php:19
const PCLZIP_OPT_EXTRACT_AS_STRING
Definition: pclzip.lib.php:133
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41

References $contents, $filename, $i, $list, and PCLZIP_OPT_EXTRACT_AS_STRING.

◆ locateName()

PHPExcel_Shared_ZipArchive::locateName (   $fileName)

Find if given fileName exist in archive (Emulate ZipArchive locateName())

Parameters
string$fileNameFilename for the file in zip archive
Returns
boolean

Definition at line 120 of file ZipArchive.php.

121 {
122 $list = $this->_zip->listContent();
123 $listCount = count($list);
124 $list_index = -1;
125 for ($i = 0; $i < $listCount; ++$i) {
126 if (strtolower($list[$i]["filename"]) == strtolower($fileName) ||
127 strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) {
128 $list_index = $i;
129 break;
130 }
131 }
132 return ($list_index > -1);
133 }

References $i, and $list.

◆ open()

PHPExcel_Shared_ZipArchive::open (   $fileName)

Open a new zip archive.

Parameters
string$fileNameFilename for the zip archive
Returns
boolean

Definition at line 70 of file ZipArchive.php.

71 {
73
74 $this->_zip = new PclZip($fileName);
75
76 return true;
77 }
static sys_get_temp_dir()
Get the systems temporary directory.
Definition: File.php:135

References PHPExcel_Shared_File\sys_get_temp_dir().

+ Here is the call graph for this function:

Field Documentation

◆ $_tempDir

PHPExcel_Shared_ZipArchive::$_tempDir
private

Definition at line 54 of file ZipArchive.php.

◆ $_zip

PHPExcel_Shared_ZipArchive::$_zip
private

Definition at line 61 of file ZipArchive.php.

◆ CREATE

const PHPExcel_Shared_ZipArchive::CREATE = 'CREATE'

Definition at line 46 of file ZipArchive.php.

◆ OVERWRITE

const PHPExcel_Shared_ZipArchive::OVERWRITE = 'OVERWRITE'

constants

Definition at line 45 of file ZipArchive.php.


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