Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Filter_Compress_Tar Class Reference
Inheritance diagram for Zend_Filter_Compress_Tar:
Zend_Filter_Compress_CompressAbstract Zend_Filter_Compress_CompressInterface

Public Member Functions

 __construct ($options=null)
 
 getArchive ()
 
 setArchive ($archive)
 
 getTarget ()
 
 setTarget ($target)
 
 getMode ()
 
 setMode ($mode)
 
 compress ($content)
 
 decompress ($content)
 
 toString ()
 
- Public Member Functions inherited from Zend_Filter_Compress_CompressAbstract
 __construct ($options=null)
 
 getOptions ($option=null)
 
 setOptions (array $options)
 

Protected Attributes

 $_options
 

Detailed Description

Definition at line 35 of file Tar.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = null)

Class constructor

Parameters
array$options(Optional) Options to set

Definition at line 57 of file Tar.php.

58  {
59  if (!class_exists('Archive_Tar')) {
60  #require_once 'Zend/Loader.php';
61  try {
62  Zend_Loader::loadClass('Archive_Tar');
63  } catch (Zend_Exception $e) {
64  #require_once 'Zend/Filter/Exception.php';
65  throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e);
66  }
67  }
68 
69  parent::__construct($options);
70  }
static loadClass($class, $dirs=null)
Definition: Loader.php:52

Member Function Documentation

◆ compress()

compress (   $content)

Compresses the given content

Parameters
string$content
Returns
string

Implements Zend_Filter_Compress_CompressInterface.

Definition at line 163 of file Tar.php.

164  {
165  $archive = new Archive_Tar($this->getArchive(), $this->getMode());
166  if (!file_exists($content)) {
167  $file = $this->getTarget();
168  if (is_dir($file)) {
169  $file .= DIRECTORY_SEPARATOR . "tar.tmp";
170  }
171 
173  if ($result === false) {
174  #require_once 'Zend/Filter/Exception.php';
175  throw new Zend_Filter_Exception('Error creating the temporary file');
176  }
177 
178  $content = $file;
179  }
180 
181  if (is_dir($content)) {
182  // collect all file infos
183  foreach (new RecursiveIteratorIterator(
184  new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME),
185  RecursiveIteratorIterator::SELF_FIRST
186  ) as $directory => $info
187  ) {
188  if ($info->isFile()) {
189  $file[] = $directory;
190  }
191  }
192 
193  $content = $file;
194  }
195 
196  $result = $archive->create($content);
197  if ($result === false) {
198  #require_once 'Zend/Filter/Exception.php';
199  throw new Zend_Filter_Exception('Error creating the Tar archive');
200  }
201 
202  return $this->getArchive();
203  }
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52

◆ decompress()

decompress (   $content)

Decompresses the given content

Parameters
string$content
Returns
boolean

Implements Zend_Filter_Compress_CompressInterface.

Definition at line 211 of file Tar.php.

212  {
213  $archive = $this->getArchive();
214  if (file_exists($content)) {
215  $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
216  } elseif (empty($archive) || !file_exists($archive)) {
217  #require_once 'Zend/Filter/Exception.php';
218  throw new Zend_Filter_Exception('Tar Archive not found');
219  }
220 
221  $archive = new Archive_Tar($archive, $this->getMode());
222  $target = $this->getTarget();
223  if (!is_dir($target)) {
224  $target = dirname($target);
225  }
226 
227  $result = $archive->extract($target);
228  if ($result === false) {
229  #require_once 'Zend/Filter/Exception.php';
230  throw new Zend_Filter_Exception('Error while extracting the Tar archive');
231  }
232 
233  return true;
234  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$target
Definition: skip.phtml:8

◆ getArchive()

getArchive ( )

Returns the set archive

Returns
string

Definition at line 77 of file Tar.php.

78  {
79  return $this->_options['archive'];
80  }

◆ getMode()

getMode ( )

Returns the set compression mode

Definition at line 127 of file Tar.php.

128  {
129  return $this->_options['mode'];
130  }

◆ getTarget()

getTarget ( )

Returns the set targetpath

Returns
string

Definition at line 101 of file Tar.php.

102  {
103  return $this->_options['target'];
104  }

◆ setArchive()

setArchive (   $archive)

Sets the archive to use for de-/compression

Parameters
string$archiveArchive to use
Returns
Zend_Filter_Compress_Tar

Definition at line 88 of file Tar.php.

89  {
90  $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive);
91  $this->_options['archive'] = (string) $archive;
92 
93  return $this;
94  }

◆ setMode()

setMode (   $mode)

Compression mode to use Eighter Gz or Bz2

Parameters
string$mode

Definition at line 138 of file Tar.php.

139  {
140  $mode = ucfirst(strtolower($mode));
141  if (($mode != 'Bz2') && ($mode != 'Gz')) {
142  #require_once 'Zend/Filter/Exception.php';
143  throw new Zend_Filter_Exception("The mode '$mode' is unknown");
144  }
145 
146  if (($mode == 'Bz2') && (!extension_loaded('bz2'))) {
147  #require_once 'Zend/Filter/Exception.php';
148  throw new Zend_Filter_Exception('This mode needs the bz2 extension');
149  }
150 
151  if (($mode == 'Gz') && (!extension_loaded('zlib'))) {
152  #require_once 'Zend/Filter/Exception.php';
153  throw new Zend_Filter_Exception('This mode needs the zlib extension');
154  }
155  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

◆ setTarget()

setTarget (   $target)

Sets the targetpath to use

Parameters
string$target
Returns
Zend_Filter_Compress_Tar

Definition at line 112 of file Tar.php.

113  {
114  if (!file_exists(dirname($target))) {
115  #require_once 'Zend/Filter/Exception.php';
116  throw new Zend_Filter_Exception("The directory '$target' does not exist");
117  }
118 
119  $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
120  $this->_options['target'] = (string) $target;
121  return $this;
122  }
$target
Definition: skip.phtml:8

◆ toString()

toString ( )

Returns the adapter name

Returns
string

Implements Zend_Filter_Compress_CompressInterface.

Definition at line 241 of file Tar.php.

242  {
243  return 'Tar';
244  }

Field Documentation

◆ $_options

$_options
protected
Initial value:
= array(
'archive' => null,
'target' => '.',
'mode' => null,
)

Definition at line 46 of file Tar.php.


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