Import WIP + une correction dans le theme (nom de fonction en double)
This commit is contained in:
parent
ef2aee3f59
commit
14af9847f6
|
@ -22,6 +22,7 @@ class addon extends common {
|
||||||
'index' => self::GROUP_ADMIN,
|
'index' => self::GROUP_ADMIN,
|
||||||
'moduleDelete' => self::GROUP_ADMIN,
|
'moduleDelete' => self::GROUP_ADMIN,
|
||||||
'export' => self::GROUP_ADMIN,
|
'export' => self::GROUP_ADMIN,
|
||||||
|
'import' => self::GROUP_ADMIN
|
||||||
];
|
];
|
||||||
|
|
||||||
// Gestion des modules
|
// Gestion des modules
|
||||||
|
@ -99,6 +100,13 @@ class addon extends common {
|
||||||
? template::button('moduleExport' . $key, [
|
? template::button('moduleExport' . $key, [
|
||||||
'class' => 'buttonBlue',
|
'class' => 'buttonBlue',
|
||||||
'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key,// appel de fonction vaut exécution, utiliser un paramètre
|
'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key,// appel de fonction vaut exécution, utiliser un paramètre
|
||||||
|
'value' => template::ico('download')
|
||||||
|
])
|
||||||
|
: '',
|
||||||
|
is_array($infoModules[$key]['dataDirectory']) && implode(', ',array_keys($inPages,$key)) !== ''
|
||||||
|
? template::button('moduleExport' . $key, [
|
||||||
|
'class' => 'buttonBlue',
|
||||||
|
'href' => helper::baseUrl(). $this->getUrl(0) . '/import/' . $key,// appel de fonction vaut exécution, utiliser un paramètre
|
||||||
'value' => template::ico('upload')
|
'value' => template::ico('upload')
|
||||||
])
|
])
|
||||||
: ''
|
: ''
|
||||||
|
@ -288,7 +296,7 @@ class addon extends common {
|
||||||
*/
|
*/
|
||||||
if ( file_exists(self::DATA_DIR . '/' . $moduleId)
|
if ( file_exists(self::DATA_DIR . '/' . $moduleId)
|
||||||
&& !file_exists($tmpFolder . '/' . $moduleId ) ) {
|
&& !file_exists($tmpFolder . '/' . $moduleId ) ) {
|
||||||
copy ( self::DATA_DIR . '/' . $moduleId, $tmpFolder . '/' . $moduleId );
|
$this->custom_copy ( self::DATA_DIR . '/' . $moduleId, $tmpFolder . '/' . $moduleId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,7 +330,32 @@ class addon extends common {
|
||||||
'state' => false
|
'state' => false
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Importer des données d'un module externes ou interne à module.json
|
||||||
|
*/
|
||||||
|
public function import(){
|
||||||
|
// Soumission du formulaire
|
||||||
|
if($this->isPost()) {
|
||||||
|
// Récupérer le fichier et le décompacter
|
||||||
|
$zipFilename = $this->getInput('addonImportFile', helper::FILTER_STRING_SHORT, true);
|
||||||
|
$tempFolder = uniqid();
|
||||||
|
mkdir (self::TEMP_DIR . $tempFolder);
|
||||||
|
echo $zipFilename;
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
|
||||||
|
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer le dossier temporaire même si le thème est invalide
|
||||||
|
//$this->removeDir(self::TEMP_DIR . $tempFolder);
|
||||||
|
$zip->close();
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => 'Importer des données de module',
|
||||||
|
'view' => 'import'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/**
|
||||||
|
* This file is part of Zwii.
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @author Rémi Jean <remi.jean@outlook.com>
|
||||||
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
||||||
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
||||||
|
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
|
||||||
|
* @license GNU General Public License, version 3
|
||||||
|
* @link http://zwiicms.fr/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** NE PAS EFFACER
|
||||||
|
* admin.css
|
||||||
|
*/
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php echo template::formOpen('addonImportForm'); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col2">
|
||||||
|
<?php echo template::button('addonImportBack', [
|
||||||
|
'class' => 'buttonGrey',
|
||||||
|
'href' => helper::baseUrl() . 'addon',
|
||||||
|
'ico' => 'left',
|
||||||
|
'value' => 'Retour'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col2 offset8">
|
||||||
|
<?php echo template::submit('addonImportSubmit', [
|
||||||
|
'value' => 'Appliquer'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col12">
|
||||||
|
<div class="block">
|
||||||
|
<h4>Installer des données de module</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col6 offset3">
|
||||||
|
<?php echo template::file('addonImportFile', [
|
||||||
|
'label' => 'Archive ZIP :',
|
||||||
|
'type' => 2
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -40,7 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
<?php echo template::formClose(); ?>
|
<?php echo template::formClose(); ?>
|
||||||
<?php if($module::$modInstal): ?>
|
<?php if($module::$modInstal): ?>
|
||||||
<?php echo template::table([2, 3, 2, 3, 1, 1], $module::$modInstal, ['Module installé', 'Alias', 'Version', 'Page(s)', 'Supprimer', 'Exporter']); ?>
|
<?php echo template::table([2, 3, 2, 2, 1, 1, 1], $module::$modInstal, ['Module installé', 'Alias', 'Version', 'Page(s)', 'Supprimer', 'Exporter', 'Importer']); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo template::speech('Aucun module installé.'); ?>
|
<?php echo template::speech('Aucun module installé.'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -692,7 +692,7 @@ class theme extends common {
|
||||||
*/
|
*/
|
||||||
public function export() {
|
public function export() {
|
||||||
// Make zip
|
// Make zip
|
||||||
$zipFilename = $this->makezip($this->getUrl(2));
|
$zipFilename = $this->zipTheme($this->getUrl(2));
|
||||||
// Téléchargement du ZIP
|
// Téléchargement du ZIP
|
||||||
header('Content-Description: File Transfer');
|
header('Content-Description: File Transfer');
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
|
@ -710,7 +710,7 @@ class theme extends common {
|
||||||
*/
|
*/
|
||||||
public function save() {
|
public function save() {
|
||||||
// Make zip
|
// Make zip
|
||||||
$zipFilename = $this->makezip($this->getUrl(2));
|
$zipFilename = $this->zipTheme($this->getUrl(2));
|
||||||
// Téléchargement du ZIP
|
// Téléchargement du ZIP
|
||||||
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
||||||
mkdir(self::FILE_DIR.'source/theme');
|
mkdir(self::FILE_DIR.'source/theme');
|
||||||
|
@ -772,7 +772,7 @@ class theme extends common {
|
||||||
* construction du zip
|
* construction du zip
|
||||||
* @param string $modele theme ou admin
|
* @param string $modele theme ou admin
|
||||||
*/
|
*/
|
||||||
private function makezip($modele) {
|
private function zipTheme($modele) {
|
||||||
// Creation du dossier
|
// Creation du dossier
|
||||||
$zipFilename = $modele . ' ' .date('d m Y').' '.date('H i s ').'.zip';
|
$zipFilename = $modele . ' ' .date('d m Y').' '.date('H i s ').'.zip';
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
|
|
Loading…
Reference in New Issue