コード例 #1
0
 /**
  * Unpack a zip archive to a specified location.
  *
  * @uses compression.xPDOZip OR compression.PclZip
  * @todo Refactor this to be implemented in a service class external to xPDOTransport.
  *
  * @param xPDO &$xpdo A reference to an xPDO instance.
  * @param string $from An absolute file system location to a valid zip archive.
  * @param string $to A file system location to extract the contents of the archive to.
  * @return array|boolean An array of unpacked resources or false on failure.
  */
 public static function _unpack(&$xpdo, $from, $to)
 {
     $resources = false;
     if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive', true) && $xpdo->loadClass('compression.xPDOZip', XPDO_CORE_PATH, true, true)) {
         $archive = new xPDOZip($xpdo, $from);
         if ($archive) {
             $resources = $archive->unpack($to);
             $archive->close();
         }
     } elseif (class_exists('PclZip') || (include XPDO_CORE_PATH . 'compression/pclzip.lib.php')) {
         $archive = new PclZip($from);
         if ($archive) {
             $resources = $archive->extract(PCLZIP_OPT_PATH, $to);
         }
     }
     return $resources;
 }
コード例 #2
0
 /**
  * Unpack the zip file using the xPDOZip class
  * 
  * @return bool|string
  */
 public function unpack()
 {
     if (!$this->modx->loadClass('compression.xPDOZip', $this->modx->getOption('core_path') . 'xpdo/', true, true)) {
         return $this->modx->lexicon('gallery.xpdozip_err_nf');
     }
     /* unpack zip file */
     $archive = new xPDOZip($this->modx, $this->source['tmp_name']);
     if (!$archive) {
         return $this->modx->lexicon('gallery.zip_err_unpack');
     }
     $archive->unpack($this->target);
     $archive->close();
     return true;
 }