public function createArchive(array $files, $path = NULL) { require_once TOOLKIT . '/class.archivezip.php'; $archive = new ArchiveZip(); $flag = Administration::instance()->Configuration->get('show-hidden', 'filemanager') == 'yes' ? ArchiveZip::IGNORE_HIDDEN : NULL; $root = DOCROOT . $this->getStartLocation(); foreach ($files as $f) { if (is_dir($root . $f)) { $archive->addDirectory($root . $f, $root . rtrim($path, '/'), $flag); } else { $archive->addFromFile($root . $f, basename($f)); } } $zip_file = $root . rtrim($path, '/') . '/' . $this->findAvailableArchiveName($root . (count($files) > 1 || is_dir($root . $files[0]) ? rtrim($path, '/') : $f)); $archive->save($zip_file); return @file_exists($zip_file) ? $zip_file : NULL; }
function exportZIP($lang) { require_once TOOLKIT . '/class.archivezip.php'; $zip = new ArchiveZip(); foreach ($this->_tm->listExtensions($lang) as $extension) { $path = TranslationManager::filePath($lang, $extension); if (!$zip->addFromFile($path, str_replace(DOCROOT, '', $path))) { $this->pageAlert(__('Cannot add <code>%s</code> to ZIP file. Please check file permissions.', array($path)), Alert::ERROR); return false; } } $data = $zip->save(); if (!$data) { $this->pageAlert(__('Cannot generate ZIP data.'), Alert::ERROR); return false; } header('Content-Type: application/zip; charset=utf-8'); header('Content-Disposition: attachment; filename="symphony-language-' . $lang . '.zip"'); header("Content-Description: File Transfer"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); echo $data; exit; }