addon export WIP (pages missing)
This commit is contained in:
parent
d900380822
commit
af72107c79
@ -1017,6 +1017,38 @@ class common {
|
||||
return ( rmdir($path) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Génère une archive d'un dossier et des sous-dossiers
|
||||
* @param string fileName path et nom de l'archive
|
||||
* @param string folder path à zipper
|
||||
* @param array filter dossiers à exclure
|
||||
*/
|
||||
public function makeZip ($fileName, $folder, $filter ) {
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
//$directory = 'site/';
|
||||
$files = new RecursiveIteratorIterator(
|
||||
new RecursiveCallbackFilterIterator(
|
||||
new RecursiveDirectoryIterator(
|
||||
$folder,
|
||||
RecursiveDirectoryIterator::SKIP_DOTS
|
||||
),
|
||||
function ($fileInfo, $key, $iterator) use ($filter) {
|
||||
return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter);
|
||||
}
|
||||
)
|
||||
);
|
||||
foreach ($files as $name => $file) {
|
||||
if (!$file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen(realpath($folder)) + 1);
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mises à jour
|
||||
*/
|
||||
|
@ -322,8 +322,8 @@ class addon extends common {
|
||||
}
|
||||
}
|
||||
// création du zip
|
||||
$fileName = self::TEMP_DIR . '/' . $this->geturl(2) . 'zip';
|
||||
$this->createZip($fileName,$tmpFolder);
|
||||
$fileName = $this->getUrl(2) . '.zip';
|
||||
$this->makeZip ($fileName, $tmpFolder, []);
|
||||
if (file_exists($fileName)) {
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
||||
@ -333,10 +333,9 @@ class addon extends common {
|
||||
$this->addOutput([
|
||||
'display' => self::DISPLAY_RAW
|
||||
]);
|
||||
//unlink($filename);
|
||||
//$this->removeDir($tmpFolder);
|
||||
// Valeurs en sortie
|
||||
|
||||
unlink($fileName);
|
||||
$this->removeDir($tmpFolder);
|
||||
exit();
|
||||
} else {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
|
Loading…
Reference in New Issue
Block a user