installation d'un module ok

This commit is contained in:
fredtempez 2021-03-26 16:47:50 +01:00
parent 2f256c65f0
commit 66c4395069
3 changed files with 143 additions and 115 deletions

View File

@ -26,7 +26,7 @@ class addon extends common {
'store' => self::GROUP_ADMIN,
'item' => self::GROUP_ADMIN,
'upload' => self::GROUP_ADMIN,
'storeDownload'=> self::GROUP_ADMIN
'storeUpload'=> self::GROUP_ADMIN
];
const URL_STORE = 'http://zwiicms.fr/?modules/list';
@ -91,19 +91,13 @@ class addon extends common {
}
/***
* Installation manuel d'un module par téléchargement
* Installation d'un module
* Fonction utilisée par upload et storeUpload
*/
public function upload() {
// Soumission du formulaire
if($this->isPost()) {
// Installation d'un module
$success = true;
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
if( $zipFilename !== ''){
private function install ($moduleName, $checkValid){
$tempFolder = 'datamodules';//uniqid();
$zip = new ZipArchive();
if ($zip->open(self::FILE_DIR.'source/'.$zipFilename) === TRUE) {
if ($zip->open($moduleName) === TRUE) {
$notification = 'Archive ouverte';
mkdir (self::TEMP_DIR . $tempFolder);
$zip->extractTo(self::TEMP_DIR . $tempFolder );
@ -162,7 +156,7 @@ class addon extends common {
$valInstalVersion = floatval( $infoModules[$moduleName]['version'] );
$newVersion = false;
if( $valNewVersion > $valInstalVersion ) $newVersion = true;
$validMaj = $valUpdate && ( $newVersion || $checkValidMaj);
$validMaj = $valUpdate && ( $newVersion || $checkValid);
// Nouvelle installation ou mise à jour du module
if( ! $moduleInstal || $validMaj ){
@ -203,12 +197,28 @@ class addon extends common {
$success = false;
$notification = 'Impossible d\'ouvrir l\'archive';
}
return(['success' => $success,
'notification'=> $notification
]);
}
/***
* Installation manuel d'un module à partir du gestionnaire de fichier
*/
public function upload() {
// Soumission du formulaire
if($this->isPost()) {
// Installation d'un module
$success = true;
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
if( $zipFilename !== ''){
$state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
}
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => $notification,
'state' => $success
'notification' => $state['notification'],
'state' => $state['success']
]);
}
// Valeurs en sortie
@ -218,6 +228,24 @@ class addon extends common {
]);
}
/***
* Installation manuel d'un module par le catalogue
*/
public function uploadStore() {
// Installation d'un module
$success = true;
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
if( $zipFilename !== ''){
$state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
}
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => $state['notification'],
'state' => $state['success']
]);
}
/**
* Catalogue des modules sur le site ZwiiCMS.fr
*/

View File

@ -7,10 +7,16 @@
'value' => 'Retour'
]); ?>
</div>
<div class="col2 offset8">
<div class="col3 offset4">
<?php echo template::button('configStoreUpload', [
'href' => helper::baseUrl() . 'addon/upload',
'value' => 'Téléverser un module'
]); ?>
</div>
<div class="col3">
<?php echo template::button('configModulesStore', [
'href' => helper::baseUrl() . 'addon/store',
'value' => 'Catalogue'
'value' => 'Catalogue en ligne'
]); ?>
</div>
</div>

View File

@ -7,12 +7,6 @@
'value' => 'Retour'
]); ?>
</div>
<div class="col3 offset7">
<?php echo template::button('configStoreUpload', [
'href' => helper::baseUrl() . 'addon/upload',
'value' => 'Téléverser un module'
]); ?>
</div>
</div>
<?php if($module::$storeList): ?>
<?php echo template::table([4, 2, 2, 3, 1], $module::$storeList, ['Module', 'Version', 'Date', 'Pages', 'Télécharger']); ?>