Installation du thème
This commit is contained in:
parent
55b25b239a
commit
83ecfc4ba6
@ -587,7 +587,9 @@ class common {
|
||||
if ($sampleSite === true) {
|
||||
foreach(init::$siteContent as $key => $value) {
|
||||
// Creation du contenu de la page
|
||||
file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $key, 'content']), $value);
|
||||
if (!empty($this->getData(['page', $key, 'content'])) ) {
|
||||
file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $key, 'content']), $value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Créer la page d'accueil
|
||||
|
@ -22,6 +22,8 @@ class install extends common {
|
||||
'update' => self::GROUP_ADMIN
|
||||
];
|
||||
|
||||
// Thèmes proposés à l'installation
|
||||
public static $themes = [];
|
||||
|
||||
public static $newVersion;
|
||||
|
||||
@ -52,8 +54,11 @@ class install extends common {
|
||||
$userLastname = $this->getInput('installLastname', helper::FILTER_STRING_SHORT, true);
|
||||
$userMail = $this->getInput('installMail', helper::FILTER_MAIL, true);
|
||||
$userId = $this->getInput('installId', helper::FILTER_ID, true);
|
||||
|
||||
|
||||
// Création de l'utilisateur si les données sont complétées.
|
||||
// success retour de l'enregistrement des données
|
||||
|
||||
$success = $this->setData([
|
||||
'user',
|
||||
$userId,
|
||||
@ -68,6 +73,7 @@ class install extends common {
|
||||
'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true)
|
||||
]
|
||||
]);
|
||||
|
||||
// Compte créé, envoi du mail et création des données du site
|
||||
if ($success) { // Formulaire complété envoi du mail
|
||||
// Envoie le mail
|
||||
@ -115,6 +121,16 @@ class install extends common {
|
||||
$this->setData(['core', 'baseUrl', helper::baseUrl(false,false) ]);
|
||||
// Créer sitemap
|
||||
$this->createSitemap();
|
||||
|
||||
// Installation du thème
|
||||
$dataThemes = file_get_contents("core/module/install/ressource/themes/themes.json");
|
||||
$dataThemes = json_decode($dataThemes, true);
|
||||
$themeId = $dataThemes [$this->getInput('installTheme', helper::FILTER_STRING_SHORT)]['filename'];
|
||||
if ($themeId !== 'default' ) {
|
||||
$theme = new theme;
|
||||
$theme->import('core/module/install/ressource/themes/' . $themeId);
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl(false),
|
||||
@ -123,7 +139,11 @@ class install extends common {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupération de la liste des thèmes
|
||||
$dataThemes = file_get_contents('core/module/install/ressource/themes/themes.json');
|
||||
$dataThemes = json_decode($dataThemes, true);
|
||||
self::$themes = helper::arrayCollumn($dataThemes, 'name');
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
||||
|
Binary file not shown.
BIN
core/module/install/ressource/themes/theme_affaire.zip
Normal file
BIN
core/module/install/ressource/themes/theme_affaire.zip
Normal file
Binary file not shown.
10
core/module/install/ressource/themes/themes.json
Normal file
10
core/module/install/ressource/themes/themes.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"defaut" : {
|
||||
"name": "Par défaut",
|
||||
"filename": ""
|
||||
},
|
||||
"affaire": {
|
||||
"name": "Affaire",
|
||||
"filename": "theme_affaire.zip"
|
||||
}
|
||||
}
|
@ -36,6 +36,13 @@
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::select('installTheme', $module::$themes, [
|
||||
'label' => 'Thème',
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::checkbox('installDefaultData',true , 'Ne pas charger l\'exemple de site (utilisateurs avancés)', [
|
||||
|
@ -28,6 +28,7 @@ class theme extends common {
|
||||
'admin' => self::GROUP_ADMIN,
|
||||
'manage' => self::GROUP_ADMIN,
|
||||
'export' => self::GROUP_ADMIN,
|
||||
'import' => self::GROUP_ADMIN,
|
||||
'save' => self::GROUP_ADMIN,
|
||||
'checkImport' => self::GROUP_ADMIN
|
||||
];
|
||||
@ -628,18 +629,51 @@ class theme extends common {
|
||||
*/
|
||||
public function manage() {
|
||||
if($this->isPost() ) {
|
||||
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => $data['notification'],
|
||||
'state' => $data['success'],
|
||||
'title' => 'Gestion des thèmes',
|
||||
'view' => 'manage'
|
||||
]);;
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => 'Gestion des thèmes',
|
||||
'view' => 'manage'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Importe un thème
|
||||
* @param string Url du thème à télécharger
|
||||
* @param @return array contenant $success = true ou false ; $ notification string message à afficher
|
||||
*/
|
||||
|
||||
public function import($zipName = '') {
|
||||
|
||||
if ($zipName !== '' &&
|
||||
file_exists($zipName)) {
|
||||
// Init variables de retour
|
||||
$success = false;
|
||||
$notification = '';
|
||||
// Dossier temporaire
|
||||
$tempFolder = uniqid();
|
||||
// Ouvrir le zip
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open(self::FILE_DIR.'source/'.$zipFilename) === TRUE) {
|
||||
if ($zip->open($zipName) === TRUE) {
|
||||
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
||||
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
||||
$modele = '';
|
||||
// Archive de thème ?
|
||||
if (
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
|
||||
) {
|
||||
$modele = 'theme';
|
||||
}
|
||||
@ -670,19 +704,10 @@ class theme extends common {
|
||||
$success = false;
|
||||
$notification = 'Impossible d\'ouvrir l\'archive';
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => $notification,
|
||||
'state' => $success,
|
||||
'title' => 'Gestion des thèmes',
|
||||
'view' => 'manage'
|
||||
]);;
|
||||
return (['success' => $success, 'notification' => $notification]);
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => 'Gestion des thèmes',
|
||||
'view' => 'manage'
|
||||
]);
|
||||
|
||||
return (['success' => false, 'notification' => 'Archive non spécifiée ou introuvable']);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user