diff --git a/CHANGES.md b/CHANGES.md index f5a3e765..25d93d7a 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,10 @@ # Changelog ## Version 12.2.01 -### Améliorations : -- Gère les erreurs d'écritures à l'aide dun contrôle des données écrites sur le disque. Cinq tentatives se terminent par un arrêt en cas d'impossibilité d'enregistrer les données. +### Correction : +- Bug majeur lors de l'installation d'une version fraiche, erreur lors de la création de la base de données des langues. +### Amélioration : +- Gestion des erreurs d'écritures à l'aide dun contrôle des données écrites sur le disque. Cinq tentatives se terminent par un arrêt en cas d'impossibilité d'enregistrer les données. ## Version 12.2.00 ### Nouveautés : diff --git a/core/core.php b/core/core.php index 30d48b7c..a54c71f1 100644 --- a/core/core.php +++ b/core/core.php @@ -52,7 +52,7 @@ class common // URL langues de l'UI en ligne const ZWII_UI_URL = 'https://forge.chapril.org/ZwiiCMS-Team/zwiicms-translations/raw/branch/master/'; - // Numéro de version et branche pour l'autoupdate + // Numéro de version et branche pour l'auto-update const ZWII_VERSION = '12.2.01'; const ZWII_UPDATE_CHANNEL = "v12"; @@ -110,7 +110,8 @@ class common 'showPageContent' => false, 'state' => false, 'style' => '', - 'title' => null, // Null car un titre peut être vide + 'title' => null, + // Null car un titre peut être vide // Trié par ordre d'exécution 'vendor' => [ 'jquery', @@ -226,70 +227,70 @@ class common ]; public static $fontsWebSafe = [ - 'arial' => [ - 'name' => 'Arial', - 'font-family' => 'Arial, Helvetica, sans-serif', - 'resource' => 'websafe' + 'arial' => [ + 'name' => 'Arial', + 'font-family' => 'Arial, Helvetica, sans-serif', + 'resource' => 'websafe' ], 'arial-black' => [ - 'name' => 'Arial Black', - 'font-family' => '\'Arial Black\', Gadget, sans-serif', - 'resource' => 'websafe' + 'name' => 'Arial Black', + 'font-family' => '\'Arial Black\', Gadget, sans-serif', + 'resource' => 'websafe' ], 'courrier' => [ - 'name' => 'Courier', - 'font-family' => 'Courier, \'Liberation Mono\', monospace', - 'resource' => 'websafe' + 'name' => 'Courier', + 'font-family' => 'Courier, \'Liberation Mono\', monospace', + 'resource' => 'websafe' ], - 'courrier-new' => [ - 'name' => 'Courier New', - 'font-family' => '\'Courier New\', Courier, monospace', - 'resource' => 'websafe' + 'courrier-new' => [ + 'name' => 'Courier New', + 'font-family' => '\'Courier New\', Courier, monospace', + 'resource' => 'websafe' ], - 'garamond' => [ - 'name' => 'Garamond', - 'font-family' => 'Garamond, serif', - 'resource' => 'websafe' + 'garamond' => [ + 'name' => 'Garamond', + 'font-family' => 'Garamond, serif', + 'resource' => 'websafe' ], - 'georgia' => [ - 'name' => 'Geogia', - 'font-family' => 'Georgia, serif', - 'resource' => 'websafe' + 'georgia' => [ + 'name' => 'Geogia', + 'font-family' => 'Georgia, serif', + 'resource' => 'websafe' ], - 'impact' => [ - 'name' => 'Impact', - 'font-family' => 'Impact, Charcoal, sans-serif', - 'resource' => 'websafe' + 'impact' => [ + 'name' => 'Impact', + 'font-family' => 'Impact, Charcoal, sans-serif', + 'resource' => 'websafe' ], - 'lucida' => [ - 'name' => 'Lucida', - 'font-family' => '\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif', - 'resource' => 'websafe' + 'lucida' => [ + 'name' => 'Lucida', + 'font-family' => '\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif', + 'resource' => 'websafe' ], - 'tahoma' => [ - 'name' => 'Tahoma', - 'font-family' => 'Tahoma, Geneva, sans-serif', - 'resource' => 'websafe' + 'tahoma' => [ + 'name' => 'Tahoma', + 'font-family' => 'Tahoma, Geneva, sans-serif', + 'resource' => 'websafe' ], - 'times-new-roman' => [ - 'name' => 'Times New Roman', - 'font-family' => '\'Times New Roman\', \'Liberation Serif\', serif', - 'resource' => 'websafe' + 'times-new-roman' => [ + 'name' => 'Times New Roman', + 'font-family' => '\'Times New Roman\', \'Liberation Serif\', serif', + 'resource' => 'websafe' ], - 'trebuchet' => [ - 'name' => 'Trebuchet', - 'font-family' => '\'Trebuchet MS\', Arial, Helvetica, sans-serif', - 'resource' => 'websafe' + 'trebuchet' => [ + 'name' => 'Trebuchet', + 'font-family' => '\'Trebuchet MS\', Arial, Helvetica, sans-serif', + 'resource' => 'websafe' ], - 'tahoma' => [ - 'name' => 'Tahoma', - 'font-family' => 'Tahoma, Geneva, sans-serif', - 'resource' => 'websafe' + 'tahoma' => [ + 'name' => 'Tahoma', + 'font-family' => 'Tahoma, Geneva, sans-serif', + 'resource' => 'websafe' ], - 'verdana' => [ - 'name' => 'Verdana', - 'font-family' => 'Verdana, Geneva, sans-serif;', - 'resource' => 'websafe' + 'verdana' => [ + 'name' => 'Verdana', + 'font-family' => 'Verdana, Geneva, sans-serif;', + 'resource' => 'websafe' ] ]; @@ -325,9 +326,9 @@ class common if ($version['core']['dataVersion'] < 12000) { // Correspondance pour les dossiers de langue à convertir $languages = [ - 'fr' => 'fr_FR', - 'en' => 'en_EN', - 'pt' => 'pt_PT' + 'fr' => 'fr_FR', + 'en' => 'en_EN', + 'pt' => 'pt_PT' ]; // Convertit les dossiers vers la nouvelle structure foreach ($languages as $key => $value) { @@ -351,7 +352,8 @@ class common 'name' => $keys . '.json', 'dir' => $this->dataPath($keys, self::$i18nContent), 'backup' => file_exists('site/data/.backup') - ]);; + ]); + ; } // Installation fraîche, initialisation des modules manquants @@ -374,14 +376,14 @@ class common // Langue sélectionnée dans le compte self::$i18nUI = $this->getData(['user', $this->getUser('id'), 'language']); // Validation de la langue - self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI)) ? 'fr_FR' : self::$i18nUI; + self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI)) ? 'fr_FR' : self::$i18nUI; } // Le fichier existe-t-il ? if (!file_exists(self::I18N_DIR . self::$i18nUI . '.json')) { self::$i18nUI = 'fr_FR'; } - \setlocale(LC_TIME, self::$i18nUI . '.UTF-8'); + \setlocale(LC_TIME, self::$i18nUI . '.UTF-8'); // Stocker le cookie de langue pour l'éditeur de texte setcookie('ZWII_UI', self::$i18nUI, time() + 3600, '/', '', false, false); @@ -457,7 +459,7 @@ class common $this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR); } self::$dialog = json_decode(file_get_contents(self::I18N_DIR . self::$i18nUI . '.json'), true); - + // Dialogue du module if ($this->getData(['page', $this->getUrl(0), 'moduleId'])) { $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); @@ -471,7 +473,8 @@ class common } // Mise à jour des données core - if ($this->getData(['core', 'dataVersion']) !== intval(str_replace('.', '', self::ZWII_VERSION))) include('core/include/update.inc.php'); + if ($this->getData(['core', 'dataVersion']) !== intval(str_replace('.', '', self::ZWII_VERSION))) + include('core/include/update.inc.php'); // Données de proxy $proxy = $this->getData(['config', 'proxyType']) . $this->getData(['config', 'proxyUrl']) . ':' . $this->getData(['config', 'proxyPort']); @@ -483,7 +486,7 @@ class common 'http' => array( 'proxy' => $proxy, 'request_fulluri' => true, - 'verify_peer' => false, + 'verify_peer' => false, 'verify_peer_name' => false, ), "ssl" => array( @@ -664,11 +667,19 @@ class common public function initData($module, $lang, $sampleSite = false) { + // Créer la base de données des langues + if ($module === 'languages') { + copy('core/module/install/ressource/i18n/languages.json', self::DATA_DIR . 'languages.json'); + $this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR); + unlink(self::I18N_DIR . 'languages.json'); + return; + } + // Tableau avec les données vierges require_once('core/module/install/ressource/defaultdata.php'); // Stockage dans un sous-dossier localisé - if (!file_exists(self::DATA_DIR . $lang)) { + if (!file_exists(self::DATA_DIR . $lang)) { mkdir(self::DATA_DIR . $lang, 0755); } $db = $this->dataFiles[$module]; @@ -680,14 +691,6 @@ class common } $db->save; - - // Créer la base de données des langues - if ($module === 'languages') { - copy('core/module/install/ressource/i18n/languages.json', self::DATA_DIR . 'languages.json'); - $this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR); - unlink(self::I18N_DIR . 'languages.json'); - } - // Créer le jeu de pages du site de test if ($module === 'page') { $langFolder = $lang . '/content/'; @@ -718,7 +721,7 @@ class common // Page dans une autre langue, page d'accueil $this->setData(['page', init::$defaultDataI18n[$lang]['page']]); // Créer la page d'accueil - $pageId = init::$defaultDataI18n[$lang]['locale']['homePageId']; + $pageId = init::$defaultDataI18n[$lang]['locale']['homePageId']; $content = init::$defaultDataI18n[$lang]['html']; file_put_contents(self::DATA_DIR . $langFolder . init::$defaultDataI18n[$lang]['page'][$pageId]['content'], $content); } @@ -880,12 +883,12 @@ class common if (empty($childIds)) { // Pas d'enfant, uniquement l'entrée du parent $parents[] = [ - 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), + 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), 'value' => $rewrite . $parentId ]; } else { // Des enfants, on ajoute la page parent en premier - array_unshift($children, [ + array_unshift($children, [ 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), 'value' => $rewrite . $parentId ]); @@ -935,7 +938,7 @@ class common // Sauf pour les pages et les modules if ( $id === 'page' || - $id === 'module' || + $id === 'module' || $id === 'locale' ) { $folder = self::DATA_DIR . $lang . '/'; @@ -983,7 +986,7 @@ class common foreach ($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { // Exclure les barres et les pages non publiques et les pages masquées if ( - $this->getData(['page', $parentPageId, 'group']) !== 0 || + $this->getData(['page', $parentPageId, 'group']) !== 0 || $this->getData(['page', $parentPageId, 'block']) === 'bar' ) { continue; @@ -1002,7 +1005,7 @@ class common foreach ($this->getData(['module', $parentPageId, 'posts']) as $articleId => $article) { if ($this->getData(['module', $parentPageId, 'posts', $articleId, 'state']) === true) { $date = $this->getData(['module', $parentPageId, 'posts', $articleId, 'publishedOn']); - $sitemap->addUrl('/' . $parentPageId . '/' . $articleId, new DateTime("@{$date}", new DateTimeZone($timezone))); + $sitemap->addUrl('/' . $parentPageId . '/' . $articleId, new DateTime("@{$date}", new DateTimeZone($timezone))); } } } @@ -1044,7 +1047,7 @@ class common } $sitemap->updateRobots(); } else { - file_put_contents('robots.txt', 'User-agent: *' . PHP_EOL . 'Disallow: /'); + file_put_contents('robots.txt', 'User-agent: *' . PHP_EOL . 'Disallow: /'); } // Submit your sitemaps to Google, Yahoo, Bing and Ask.com @@ -1056,12 +1059,12 @@ class common } /* - * Création d'une miniature - * Fonction utilisée lors de la mise à jour d'une version 9 à une version 10 - * @param string $src image source - * @param string $dets image destination - * @param integer $desired_width largeur demandée - */ + * Création d'une miniature + * Fonction utilisée lors de la mise à jour d'une version 9 à une version 10 + * @param string $src image source + * @param string $dets image destination + * @param integer $desired_width largeur demandée + */ function makeThumb($src, $dest, $desired_width) { // Vérifier l'existence du dossier de destination. @@ -1193,19 +1196,21 @@ class common public function removeDir($path) { foreach (new DirectoryIterator($path) as $item) { - if ($item->isFile()) @unlink($item->getRealPath()); - if (!$item->isDot() && $item->isDir()) $this->removeDir($item->getRealPath()); + if ($item->isFile()) + @unlink($item->getRealPath()); + if (!$item->isDot() && $item->isDir()) + $this->removeDir($item->getRealPath()); } return (rmdir($path)); } /* - * Copie récursive de dossiers - * @param string $src dossier source - * @param string $dst dossier destination - * @return bool - */ + * Copie récursive de dossiers + * @param string $src dossier source + * @param string $dst dossier destination + * @return bool + */ public function copyDir($src, $dst) { // Ouvrir le dossier source @@ -1225,7 +1230,7 @@ class common if (($file != '.') && ($file != '..')) { if (is_dir($src . '/' . $file)) { // Appel récursif des sous-dossiers - $s = $this->copyDir($src . '/' . $file, $dst . '/' . $file); + $s = $this->copyDir($src . '/' . $file, $dst . '/' . $file); $success = $s || $success; } else { $s = copy($src . '/' . $file, $dst . '/' . $file); @@ -1270,11 +1275,11 @@ class common $zip = new ZipArchive(); $zip->open($fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); //$directory = 'site/'; - $files = new RecursiveIteratorIterator( + $files = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( new RecursiveDirectoryIterator( $folder, - RecursiveDirectoryIterator::SKIP_DOTS + RecursiveDirectoryIterator::SKIP_DOTS ), function ($fileInfo, $key, $iterator) use ($filter) { return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); @@ -1303,10 +1308,10 @@ class common return; } // Le cookie est déjà validé - if ($this->getInput('ZWII_COOKIE_CONSENT') === 'true') { + if ($this->getInput('ZWII_COOKIE_CONSENT') === 'true') { return; } - $item = '
'; + $item = '
'; // Bouton de fermeture $item .= '
'; $item .= template::ico('cancel'); @@ -1348,27 +1353,29 @@ class common $blockleft = ''; $blockright = ''; switch (sizeof($blocks)) { - case 1: // une colonne - $content = 'col' . $blocks[0]; + case 1: // une colonne + $content = 'col' . $blocks[0]; break; - case 2: // 2 blocs + case 2: // 2 blocs if ($blocks[0] < $blocks[1]) { // détermine la position de la colonne $blockleft = 'col' . $blocks[0]; - $content = 'col' . $blocks[1]; + $content = 'col' . $blocks[1]; } else { - $content = 'col' . $blocks[0]; - $blockright = 'col' . $blocks[1]; + $content = 'col' . $blocks[0]; + $blockright = 'col' . $blocks[1]; } break; - case 3: // 3 blocs - $blockleft = 'col' . $blocks[0]; - $content = 'col' . $blocks[1]; + case 3: // 3 blocs + $blockleft = 'col' . $blocks[0]; + $content = 'col' . $blocks[1]; $blockright = 'col' . $blocks[2]; } // Page pleine pour la configuration des modules et l'édition des pages sauf l'affichage d'un article de blog $pattern = ['config', 'edit', 'add', 'comment', 'data']; - if ((sizeof($blocks) === 1 || - in_array($this->getUrl(1), $pattern))) { // Pleine page en mode configuration + if ( + (sizeof($blocks) === 1 || + in_array($this->getUrl(1), $pattern)) + ) { // Pleine page en mode configuration $this->showContent(); } else { echo '
'; @@ -1385,14 +1392,14 @@ class common // $mark contient 0 le menu est positionné à la fin du contenu $contentLeft = str_replace('[]', '[MENU]', $this->output['contentLeft']); $contentLeft = str_replace('[menu]', '[MENU]', $contentLeft); - $mark = strrpos($contentLeft, '[MENU]') !== false ? strrpos($contentLeft, '[MENU]') : strlen($contentLeft); + $mark = strrpos($contentLeft, '[MENU]') !== false ? strrpos($contentLeft, '[MENU]') : strlen($contentLeft); echo substr($contentLeft, 0, $mark); echo ''; echo substr($contentLeft, $mark + 6, strlen($contentLeft)); } - echo "
"; + echo "
"; } /** * Contenu de page @@ -1413,7 +1420,7 @@ class common // $mark contient 0 le menu est positionné à la fin du contenu $contentRight = str_replace('[]', '[MENU]', $this->output['contentRight']); $contentRight = str_replace('[menu]', '[MENU]', $contentRight); - $mark = strrpos($contentRight, '[MENU]') !== false ? strrpos($contentRight, '[MENU]') : strlen($contentRight); + $mark = strrpos($contentRight, '[MENU]') !== false ? strrpos($contentRight, '[MENU]') : strlen($contentRight); echo substr($contentRight, 0, $mark); echo '