addon export WIP (pages missing)
This commit is contained in:
parent
d900380822
commit
af72107c79
@ -1017,6 +1017,38 @@ class common {
|
|||||||
return ( rmdir($path) );
|
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
|
* Mises à jour
|
||||||
*/
|
*/
|
||||||
|
@ -322,8 +322,8 @@ class addon extends common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// création du zip
|
// création du zip
|
||||||
$fileName = self::TEMP_DIR . '/' . $this->geturl(2) . 'zip';
|
$fileName = $this->getUrl(2) . '.zip';
|
||||||
$this->createZip($fileName,$tmpFolder);
|
$this->makeZip ($fileName, $tmpFolder, []);
|
||||||
if (file_exists($fileName)) {
|
if (file_exists($fileName)) {
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
||||||
@ -333,10 +333,9 @@ class addon extends common {
|
|||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'display' => self::DISPLAY_RAW
|
'display' => self::DISPLAY_RAW
|
||||||
]);
|
]);
|
||||||
//unlink($filename);
|
unlink($fileName);
|
||||||
//$this->removeDir($tmpFolder);
|
$this->removeDir($tmpFolder);
|
||||||
// Valeurs en sortie
|
exit();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
|
Loading…
Reference in New Issue
Block a user