diff --git a/LISEZMOI.md b/LISEZMOI.md index 01073475..fdfcb7b2 100644 --- a/LISEZMOI.md +++ b/LISEZMOI.md @@ -1,4 +1,4 @@ -# ZwiiCMS 12.3.02 +# ZwiiCMS 12.3.03 Zwii est un CMS sans base de données (flat-file) qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation. diff --git a/README.md b/README.md index 9636a164..b7374707 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ZwiiCMS 12.3.02 +# ZwiiCMS 12.3.03 Zwii is a database-less (flat-file) CMS that allows you to easily create and manage a web site without any programming knowledge. diff --git a/core/core.php b/core/core.php index 94a7a14b..693a7156 100644 --- a/core/core.php +++ b/core/core.php @@ -59,7 +59,7 @@ class common // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_UPDATE_CHANNEL = "v12"; + const ZWII_UPDATE_CHANNEL = "test"; // Constantes de test //const ZWII_UPDATE_URL = 'http://localhost/update/'; @@ -1119,15 +1119,19 @@ class common try { // Paramètres SMTP perso if ($this->getdata(['config', 'smtp', 'enable'])) { - //$mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; + $mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->SMTPAutoTLS = false; + $mail->SMTPSecure = false; + $mail->SMTPAuth = false; $mail->Host = $this->getdata(['config', 'smtp', 'host']); $mail->Port = (int) $this->getdata(['config', 'smtp', 'port']); if ($this->getData(['config', 'smtp', 'auth'])) { + $mail->SMTPAutoTLS = true; + $mail->SMTPSecure = true; + $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->Username = $this->getData(['config', 'smtp', 'username']); $mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password'])); - $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->SMTPSecure = $this->getData(['config', 'smtp', 'secure']); } } diff --git a/core/module/install/install.php b/core/module/install/install.php index afcac519..2d079cce 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -268,6 +268,7 @@ class install extends common // Préparation case 1: $success = true; + $message = ''; // RAZ la mise à jour auto $this->setData(['core', 'updateAvailable', false]); // Backup du dossier Data @@ -275,20 +276,23 @@ class install extends common // Sauvegarde htaccess if ($this->getData(['config', 'autoUpdateHtaccess'])) { $success = copy('.htaccess', '.htaccess' . '.bak'); + $message = 'Erreur de copie du fichier htaccess'; } // Nettoyage des fichiers d'installation précédents if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz'); + $message = 'Impossible d\'effacer la mise à jour précédente'; } if (file_exists(self::TEMP_DIR . 'update.tar') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar'); + $message = 'Impossible d\'effacer la mise à jour précédente'; } // Valeurs en sortie $this->addOutput([ 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $success, - 'data' => null + 'data' => $success ? null : json_encode($message) ] ]); break; @@ -296,14 +300,14 @@ class install extends common case 2: file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz')); $md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5'); - $md5origin = (explode(' ', $md5origin)); + $md5origin = explode(' ', $md5origin); $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz'); // Valeurs en sortie $this->addOutput([ 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $md5origin[0] === $md5target, - 'data' => null + 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle') ] ]); break; @@ -341,6 +345,7 @@ class install extends common // Configuration case 4: $success = true; + $message = null; $rewrite = $this->getInput('data'); // Réécriture d'URL if ($rewrite === "true") { // Ajout des lignes dans le .htaccess @@ -361,6 +366,7 @@ class install extends common $fileContent ); $success = $r === false ? false : true; + $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null; } // Recopie htaccess if ( @@ -396,7 +402,7 @@ class install extends common 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $success, - 'data' => null + 'data' => $message ] ]); } diff --git a/core/module/install/view/update/update.js.php b/core/module/install/view/update/update.js.php index 0252e321..baff6248 100644 --- a/core/module/install/view/update/update.js.php +++ b/core/module/install/view/update/update.js.php @@ -1,6 +1,7 @@ function step(i, data) { var errors = ["", "", "", ""]; - $(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show(), $.ajax({ + $(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show(); + $.ajax({ type: "POST", url: "?install/steps", data: { @@ -8,13 +9,41 @@ function step(i, data) { data: data }, success: function (result) { + if (!result.success) { // Vérification de la propriété "success" + // Appel de la fonction de gestion d'erreur + showError(i, result, errors); + return; + } setTimeout((function () { - !0 === result.success ? 4 === i ? ($("#installUpdateSuccess").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide()) : step(i + 1, result.data) : ($("#installUpdateErrorStep").text(errors[i]), $("#installUpdateError").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide(), console.error(result), $("#installUpdateErrorMessage").text(result.replace(/<[^p].*?>/g, ""))) + if (4 === i) { + $("#installUpdateSuccess").show(); + $("#installUpdateEnd").removeClass("disabled"); + $("#installUpdateProgress").hide(); + } else { + step(i + 1, result.data); + } }), 2e3) }, error: function (xhr) { - $("#installUpdateErrorStep").text(errors[1]), $("#installUpdateError").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide(), console.error(xhr.responseText), $("#installUpdateErrorMessage").text(xhr.responseText.replace(/<[^p].*?>/g, "")) + // Appel de la fonction de gestion d'erreur + showError(1, xhr.responseText, errors); } - }) + }); } -$(window).on("load", step(1, null)); \ No newline at end of file + +function showError(step, message, errors) { + $("#installUpdateErrorStep").text(errors[step]); + $("#installUpdateError").show(); + $("#installUpdateEnd").removeClass("disabled"); + $("#installUpdateProgress").hide(); + if (typeof message === 'object' && message.data) { + var errorMessage = message.data.replace(/"/g, ""); + $("#installUpdateErrorMessage").text(errorMessage); + } else { + $("#installUpdateErrorMessage").text(message.replace(/<[^p].*?>/g, "")); + } +} + +$(window).on("load", function() { + step(1, null); +}); diff --git a/core/module/page/page.php b/core/module/page/page.php index e7b636b8..9c747c43 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -632,4 +632,18 @@ class page extends common 'view' => 'jsEditor' ]); } + + /** + * Retourne les informations sur les pages en omettant les clés CSS et JS qui occasionnent des bugs d'affichage dans l'éditeur de page + * @return array tableau associatif des pages dans le menu + */ + public function getPageInfo() { + $p = $this->getData(['page']); + $d = array_map(function($d) { + unset($d["css"], $d["js"]); + return $d; + }, $p); + return json_encode($d); + + } } \ No newline at end of file diff --git a/core/module/page/view/edit/edit.js.php b/core/module/page/view/edit/edit.js.php index 93fb5dde..0f1def16 100644 --- a/core/module/page/view/edit/edit.js.php +++ b/core/module/page/view/edit/edit.js.php @@ -644,7 +644,7 @@ $("#pageEditParentPageId").on("change", function() { function buildPagesList(extraPosition) { var hierarchy = getHierarchy()); ?>; - var pages = getData(['page'])); ?>; + var pages = getPageInfo(); ?>; var positionInitial = getData(['page',$this->getUrl(2),"position"]); ?>; var extraPosition = $("#pageEditExtraPosition").val(); var positionDOM = $("#pageEditPosition"); diff --git a/core/vendor/tinymce/init.js b/core/vendor/tinymce/init.js index 836f3130..423f8508 100755 --- a/core/vendor/tinymce/init.js +++ b/core/vendor/tinymce/init.js @@ -10,7 +10,6 @@ if (typeof (privateKey) == 'undefined') { var privateKey = null; }; -console.log(getCookie('ZWII_UI')); tinymce.init({ // Classe où appliquer l'éditeur selector: ".editorWysiwyg", @@ -331,7 +330,6 @@ function getCookie(name) { for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); - if (c.indexOf(nameEQ) == 0) console.log(c.substring(nameEQ.length, c.length)); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null;