function exportToArchive($archivePath) { $temporaryExportPath = eZPackage::temporaryExportPath(); $tempPath = $temporaryExportPath . '/' . $this->attribute('name'); $this->removeFiles($tempPath); // Create package temp dir and copy package's XML file there $this->storePackageFile($tempPath, false); // Copy package's directories $directoryList = array($this->documentDirectory(), $this->filesDirectory(), $this->simpleFilesDirectory(), $this->settingsDirectory()); $installItems = $this->Parameters['install']; foreach ($installItems as $installItem) { if (!in_array($installItem['sub-directory'], $directoryList)) { $directoryList[] = $installItem['sub-directory']; } } $path = $this->path(); foreach ($directoryList as $dirName) { $destDir = $tempPath; $dir = $path . '/' . $dirName; if (file_exists($dir)) { eZDir::copy($dir, $destDir); } } $tarArchivePath = $temporaryExportPath . '/archive.tmp'; $tarArchive = ezcArchive::open($tarArchivePath, ezcArchive::TAR_USTAR); $tarArchive->truncate(); $prefix = $tempPath . '/'; $fileList = array(); eZDir::recursiveList($tempPath, $tempPath, $fileList); foreach ($fileList as $fileInfo) { $path = $fileInfo['type'] === 'dir' ? $fileInfo['path'] . '/' . $fileInfo['name'] . '/' : $fileInfo['path'] . '/' . $fileInfo['name']; $tarArchive->append(array($path), $prefix); } $tarArchive->close(); copy($tarArchivePath, "compress.zlib://{$archivePath}"); unlink($tarArchivePath); $this->removeFiles($tempPath); return $archivePath; }
/** * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.6 * @package kernel */ $module = $Params['Module']; $packageName = $Params['PackageName']; $package = eZPackage::fetch($packageName); if (!$package) { return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if (!$package->attribute('can_export')) { return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'); } $exportDirectory = eZPackage::temporaryExportPath(); $exportName = $package->exportName(); $exportPath = $exportDirectory . '/' . $exportName; $exportPath = $package->exportToArchive($exportPath); //return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) ); $fileName = $exportPath; if ($fileName != "" and file_exists($fileName)) { clearstatcache(); $fileSize = filesize($fileName); $mimeType = 'application/octet-stream'; $originalFileName = $exportName; $contentLength = $fileSize; $fileOffset = false; $fileLength = false; if (isset($_SERVER['HTTP_RANGE'])) { $httpRange = trim($_SERVER['HTTP_RANGE']);